int pch_gbe_probe(struct udevice *dev) { struct pch_gbe_priv *priv; struct eth_pdata *plat = dev_get_platdata(dev); void *iobase; /* * The priv structure contains the descriptors and frame buffers which * need a strict buswidth alignment (64 bytes). This is guaranteed by * DM_FLAG_ALLOC_PRIV_DMA flag in the U_BOOT_DRIVER. */ priv = dev_get_priv(dev); priv->dev = dev; iobase = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_1, PCI_REGION_MEM); plat->iobase = (ulong)iobase; priv->mac_regs = (struct pch_gbe_regs *)iobase; /* Read MAC address from SROM and initialize dev->enetaddr with it */ pch_gbe_mac_read(priv->mac_regs, plat->enetaddr); plat->phy_interface = PHY_INTERFACE_MODE_RGMII; pch_gbe_mdio_init(dev->name, priv->mac_regs); priv->bus = miiphy_get_dev_by_name(dev->name); return pch_gbe_phy_init(dev); }
int pch_gbe_register(bd_t *bis) { struct eth_device *dev; struct pch_gbe_priv *priv; pci_dev_t devno; u32 iobase; devno = pci_find_devices(supported, 0); if (devno == -1) return -ENODEV; dev = (struct eth_device *)malloc(sizeof(*dev)); if (!dev) return -ENOMEM; memset(dev, 0, sizeof(*dev)); /* * The priv structure contains the descriptors and frame buffers which * need a strict buswidth alignment (64 bytes) */ priv = (struct pch_gbe_priv *)memalign(PCH_GBE_ALIGN_SIZE, sizeof(*priv)); if (!priv) { free(dev); return -ENOMEM; } memset(priv, 0, sizeof(*priv)); dev->priv = priv; priv->dev = dev; priv->bdf = devno; pci_read_config_dword(devno, PCI_BASE_ADDRESS_1, &iobase); iobase &= PCI_BASE_ADDRESS_MEM_MASK; iobase = pci_mem_to_phys(devno, iobase); dev->iobase = iobase; priv->mac_regs = (struct pch_gbe_regs *)iobase; sprintf(dev->name, "pch_gbe.%x", iobase); /* Read MAC address from SROM and initialize dev->enetaddr with it */ pch_gbe_mac_read(priv->mac_regs, dev->enetaddr); dev->init = pch_gbe_init; dev->halt = pch_gbe_halt; dev->send = pch_gbe_send; dev->recv = pch_gbe_recv; eth_register(dev); priv->interface = PHY_INTERFACE_MODE_RGMII; pch_gbe_mdio_init(dev->name, priv->mac_regs); priv->bus = miiphy_get_dev_by_name(dev->name); return pch_gbe_phy_init(dev); }