#endif
};
+struct macb_usrio_cfg {
+ unsigned int mii;
+ unsigned int rmii;
+ unsigned int rgmii;
+ unsigned int clken;
+};
+
struct macb_config {
unsigned int dma_burst_length;
unsigned int hw_dma_cap;
+ unsigned int caps;
int (*clk_init)(struct udevice *dev, ulong rate);
+ const struct macb_usrio_cfg *usrio;
};
#ifndef CONFIG_DM_ETH
{
#ifdef CONFIG_DM_ETH
struct macb_device *macb = dev_get_priv(dev);
+ unsigned int val = 0;
#endif
unsigned long paddr;
int ret;
* to select interface between RMII and MII.
*/
#ifdef CONFIG_DM_ETH
- if ((macb->phy_interface == PHY_INTERFACE_MODE_RMII) ||
- (macb->phy_interface == PHY_INTERFACE_MODE_RGMII))
- gem_writel(macb, USRIO, GEM_BIT(RGMII));
- else
- gem_writel(macb, USRIO, 0);
+ if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII)
+ val = macb->config->usrio->rgmii;
+ else if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
+ val = macb->config->usrio->rmii;
+ else if (macb->phy_interface == PHY_INTERFACE_MODE_MII)
+ val = macb->config->usrio->mii;
+
+ if (macb->config->caps & MACB_CAPS_USRIO_HAS_CLKEN)
+ val |= macb->config->usrio->clken;
+
+ gem_writel(macb, USRIO, val);
if (macb->phy_interface == PHY_INTERFACE_MODE_SGMII) {
unsigned int ncfgr = macb_readl(macb, NCFGR);
}
#else
#if defined(CONFIG_RGMII) || defined(CONFIG_RMII)
- gem_writel(macb, USRIO, GEM_BIT(RGMII));
+ gem_writel(macb, USRIO, macb->config->usrio->rgmii);
#else
gem_writel(macb, USRIO, 0);
#endif
#ifdef CONFIG_AT91FAMILY
if (macb->phy_interface == PHY_INTERFACE_MODE_RMII) {
macb_writel(macb, USRIO,
- MACB_BIT(RMII) | MACB_BIT(CLKEN));
+ macb->config->usrio->rmii |
+ macb->config->usrio->clken);
} else {
- macb_writel(macb, USRIO, MACB_BIT(CLKEN));
+ macb_writel(macb, USRIO, macb->config->usrio->clken);
}
#else
if (macb->phy_interface == PHY_INTERFACE_MODE_RMII)
macb_writel(macb, USRIO, 0);
else
- macb_writel(macb, USRIO, MACB_BIT(MII));
+ macb_writel(macb, USRIO, macb->config->usrio->mii);
#endif
#else
#ifdef CONFIG_RMII
#ifdef CONFIG_AT91FAMILY
- macb_writel(macb, USRIO, MACB_BIT(RMII) | MACB_BIT(CLKEN));
+ macb_writel(macb, USRIO, macb->config->usrio->rmii |
+ macb->config->usrio->clken);
#else
macb_writel(macb, USRIO, 0);
#endif
#else
#ifdef CONFIG_AT91FAMILY
- macb_writel(macb, USRIO, MACB_BIT(CLKEN));
+ macb_writel(macb, USRIO, macb->config->usrio->clken);
#else
- macb_writel(macb, USRIO, MACB_BIT(MII));
+ macb_writel(macb, USRIO, macb->config->usrio->mii);
#endif
#endif /* CONFIG_RMII */
#endif
}
#endif
+static const struct macb_usrio_cfg macb_default_usrio = {
+ .mii = MACB_BIT(MII),
+ .rmii = MACB_BIT(RMII),
+ .rgmii = GEM_BIT(RGMII),
+ .clken = MACB_BIT(CLKEN),
+};
+
static const struct macb_config default_gem_config = {
.dma_burst_length = 16,
.hw_dma_cap = HW_DMA_CAP_32B,
.clk_init = NULL,
+ .usrio = &macb_default_usrio,
};
static int macb_eth_probe(struct udevice *dev)
.dma_burst_length = 16,
.hw_dma_cap = HW_DMA_CAP_64B,
.clk_init = NULL,
+ .usrio = &macb_default_usrio,
};
static const struct macb_config sama5d4_config = {
.dma_burst_length = 4,
.hw_dma_cap = HW_DMA_CAP_32B,
.clk_init = NULL,
+ .usrio = &macb_default_usrio,
};
static const struct macb_config sifive_config = {
.dma_burst_length = 16,
.hw_dma_cap = HW_DMA_CAP_32B,
.clk_init = macb_sifive_clk_init,
+ .usrio = &macb_default_usrio,
};
static const struct udevice_id macb_eth_ids[] = {