18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Driver for (BCM4706)? GBit MAC core on BCMA bus. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2012 Rafał Miłecki <zajec5@gmail.com> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Licensed under the GNU/GPL. See COPYING for details. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/bcma/bcma.h> 128c2ecf20Sopenharmony_ci#include <linux/brcmphy.h> 138c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 148c2ecf20Sopenharmony_ci#include <linux/of_net.h> 158c2ecf20Sopenharmony_ci#include "bgmac.h" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistatic inline bool bgmac_is_bcm4707_family(struct bcma_device *core) 188c2ecf20Sopenharmony_ci{ 198c2ecf20Sopenharmony_ci switch (core->bus->chipinfo.id) { 208c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM4707: 218c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM47094: 228c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM53018: 238c2ecf20Sopenharmony_ci return true; 248c2ecf20Sopenharmony_ci default: 258c2ecf20Sopenharmony_ci return false; 268c2ecf20Sopenharmony_ci } 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/************************************************** 308c2ecf20Sopenharmony_ci * BCMA bus ops 318c2ecf20Sopenharmony_ci **************************************************/ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistatic u32 bcma_bgmac_read(struct bgmac *bgmac, u16 offset) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci return bcma_read32(bgmac->bcma.core, offset); 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistatic void bcma_bgmac_write(struct bgmac *bgmac, u16 offset, u32 value) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci bcma_write32(bgmac->bcma.core, offset, value); 418c2ecf20Sopenharmony_ci} 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_cistatic u32 bcma_bgmac_idm_read(struct bgmac *bgmac, u16 offset) 448c2ecf20Sopenharmony_ci{ 458c2ecf20Sopenharmony_ci return bcma_aread32(bgmac->bcma.core, offset); 468c2ecf20Sopenharmony_ci} 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic void bcma_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci return bcma_awrite32(bgmac->bcma.core, offset, value); 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic bool bcma_bgmac_clk_enabled(struct bgmac *bgmac) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci return bcma_core_is_enabled(bgmac->bcma.core); 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic void bcma_bgmac_clk_enable(struct bgmac *bgmac, u32 flags) 598c2ecf20Sopenharmony_ci{ 608c2ecf20Sopenharmony_ci bcma_core_enable(bgmac->bcma.core, flags); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistatic void bcma_bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset, 648c2ecf20Sopenharmony_ci u32 mask, u32 set) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci bcma_chipco_chipctl_maskset(cc, offset, mask, set); 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistatic u32 bcma_bgmac_get_bus_clock(struct bgmac *bgmac) 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci struct bcma_drv_cc *cc = &bgmac->bcma.core->bus->drv_cc; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci return bcma_pmu_get_bus_clock(cc); 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic void bcma_bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, u32 mask, 798c2ecf20Sopenharmony_ci u32 set) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci bcma_maskset32(bgmac->bcma.cmn, offset, mask, set); 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_cistatic int bcma_phy_connect(struct bgmac *bgmac) 858c2ecf20Sopenharmony_ci{ 868c2ecf20Sopenharmony_ci struct phy_device *phy_dev; 878c2ecf20Sopenharmony_ci char bus_id[MII_BUS_ID_SIZE + 3]; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci /* Connect to the PHY */ 908c2ecf20Sopenharmony_ci snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id, 918c2ecf20Sopenharmony_ci bgmac->phyaddr); 928c2ecf20Sopenharmony_ci phy_dev = phy_connect(bgmac->net_dev, bus_id, bgmac_adjust_link, 938c2ecf20Sopenharmony_ci PHY_INTERFACE_MODE_MII); 948c2ecf20Sopenharmony_ci if (IS_ERR(phy_dev)) { 958c2ecf20Sopenharmony_ci dev_err(bgmac->dev, "PHY connection failed\n"); 968c2ecf20Sopenharmony_ci return PTR_ERR(phy_dev); 978c2ecf20Sopenharmony_ci } 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci return 0; 1008c2ecf20Sopenharmony_ci} 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic const struct bcma_device_id bgmac_bcma_tbl[] = { 1038c2ecf20Sopenharmony_ci BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_4706_MAC_GBIT, 1048c2ecf20Sopenharmony_ci BCMA_ANY_REV, BCMA_ANY_CLASS), 1058c2ecf20Sopenharmony_ci BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_MAC_GBIT, BCMA_ANY_REV, 1068c2ecf20Sopenharmony_ci BCMA_ANY_CLASS), 1078c2ecf20Sopenharmony_ci {}, 1088c2ecf20Sopenharmony_ci}; 1098c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */ 1128c2ecf20Sopenharmony_cistatic int bgmac_probe(struct bcma_device *core) 1138c2ecf20Sopenharmony_ci{ 1148c2ecf20Sopenharmony_ci struct bcma_chipinfo *ci = &core->bus->chipinfo; 1158c2ecf20Sopenharmony_ci struct ssb_sprom *sprom = &core->bus->sprom; 1168c2ecf20Sopenharmony_ci struct mii_bus *mii_bus; 1178c2ecf20Sopenharmony_ci struct bgmac *bgmac; 1188c2ecf20Sopenharmony_ci const u8 *mac = NULL; 1198c2ecf20Sopenharmony_ci int err; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci bgmac = bgmac_alloc(&core->dev); 1228c2ecf20Sopenharmony_ci if (!bgmac) 1238c2ecf20Sopenharmony_ci return -ENOMEM; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci bgmac->bcma.core = core; 1268c2ecf20Sopenharmony_ci bgmac->dma_dev = core->dma_dev; 1278c2ecf20Sopenharmony_ci bgmac->irq = core->irq; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci bcma_set_drvdata(core, bgmac); 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci if (bgmac->dev->of_node) 1328c2ecf20Sopenharmony_ci mac = of_get_mac_address(bgmac->dev->of_node); 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci /* If no MAC address assigned via device tree, check SPROM */ 1358c2ecf20Sopenharmony_ci if (IS_ERR_OR_NULL(mac)) { 1368c2ecf20Sopenharmony_ci switch (core->core_unit) { 1378c2ecf20Sopenharmony_ci case 0: 1388c2ecf20Sopenharmony_ci mac = sprom->et0mac; 1398c2ecf20Sopenharmony_ci break; 1408c2ecf20Sopenharmony_ci case 1: 1418c2ecf20Sopenharmony_ci mac = sprom->et1mac; 1428c2ecf20Sopenharmony_ci break; 1438c2ecf20Sopenharmony_ci case 2: 1448c2ecf20Sopenharmony_ci mac = sprom->et2mac; 1458c2ecf20Sopenharmony_ci break; 1468c2ecf20Sopenharmony_ci default: 1478c2ecf20Sopenharmony_ci dev_err(bgmac->dev, "Unsupported core_unit %d\n", 1488c2ecf20Sopenharmony_ci core->core_unit); 1498c2ecf20Sopenharmony_ci err = -ENOTSUPP; 1508c2ecf20Sopenharmony_ci goto err; 1518c2ecf20Sopenharmony_ci } 1528c2ecf20Sopenharmony_ci } 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci ether_addr_copy(bgmac->net_dev->dev_addr, mac); 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci /* On BCM4706 we need common core to access PHY */ 1578c2ecf20Sopenharmony_ci if (core->id.id == BCMA_CORE_4706_MAC_GBIT && 1588c2ecf20Sopenharmony_ci !core->bus->drv_gmac_cmn.core) { 1598c2ecf20Sopenharmony_ci dev_err(bgmac->dev, "GMAC CMN core not found (required for BCM4706)\n"); 1608c2ecf20Sopenharmony_ci err = -ENODEV; 1618c2ecf20Sopenharmony_ci goto err; 1628c2ecf20Sopenharmony_ci } 1638c2ecf20Sopenharmony_ci bgmac->bcma.cmn = core->bus->drv_gmac_cmn.core; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci switch (core->core_unit) { 1668c2ecf20Sopenharmony_ci case 0: 1678c2ecf20Sopenharmony_ci bgmac->phyaddr = sprom->et0phyaddr; 1688c2ecf20Sopenharmony_ci break; 1698c2ecf20Sopenharmony_ci case 1: 1708c2ecf20Sopenharmony_ci bgmac->phyaddr = sprom->et1phyaddr; 1718c2ecf20Sopenharmony_ci break; 1728c2ecf20Sopenharmony_ci case 2: 1738c2ecf20Sopenharmony_ci bgmac->phyaddr = sprom->et2phyaddr; 1748c2ecf20Sopenharmony_ci break; 1758c2ecf20Sopenharmony_ci } 1768c2ecf20Sopenharmony_ci bgmac->phyaddr &= BGMAC_PHY_MASK; 1778c2ecf20Sopenharmony_ci if (bgmac->phyaddr == BGMAC_PHY_MASK) { 1788c2ecf20Sopenharmony_ci dev_err(bgmac->dev, "No PHY found\n"); 1798c2ecf20Sopenharmony_ci err = -ENODEV; 1808c2ecf20Sopenharmony_ci goto err; 1818c2ecf20Sopenharmony_ci } 1828c2ecf20Sopenharmony_ci dev_info(bgmac->dev, "Found PHY addr: %d%s\n", bgmac->phyaddr, 1838c2ecf20Sopenharmony_ci bgmac->phyaddr == BGMAC_PHY_NOREGS ? " (NOREGS)" : ""); 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci if (!bgmac_is_bcm4707_family(core) && 1868c2ecf20Sopenharmony_ci !(ci->id == BCMA_CHIP_ID_BCM53573 && core->core_unit == 1)) { 1878c2ecf20Sopenharmony_ci struct phy_device *phydev; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci mii_bus = bcma_mdio_mii_register(bgmac); 1908c2ecf20Sopenharmony_ci if (IS_ERR(mii_bus)) { 1918c2ecf20Sopenharmony_ci err = PTR_ERR(mii_bus); 1928c2ecf20Sopenharmony_ci goto err; 1938c2ecf20Sopenharmony_ci } 1948c2ecf20Sopenharmony_ci bgmac->mii_bus = mii_bus; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci phydev = mdiobus_get_phy(bgmac->mii_bus, bgmac->phyaddr); 1978c2ecf20Sopenharmony_ci if (ci->id == BCMA_CHIP_ID_BCM53573 && phydev && 1988c2ecf20Sopenharmony_ci (phydev->drv->phy_id & phydev->drv->phy_id_mask) == PHY_ID_BCM54210E) 1998c2ecf20Sopenharmony_ci phydev->dev_flags |= PHY_BRCM_EN_MASTER_MODE; 2008c2ecf20Sopenharmony_ci } 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) { 2038c2ecf20Sopenharmony_ci dev_err(bgmac->dev, "PCI setup not implemented\n"); 2048c2ecf20Sopenharmony_ci err = -ENOTSUPP; 2058c2ecf20Sopenharmony_ci goto err1; 2068c2ecf20Sopenharmony_ci } 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci bgmac->has_robosw = !!(sprom->boardflags_lo & BGMAC_BFL_ENETROBO); 2098c2ecf20Sopenharmony_ci if (bgmac->has_robosw) 2108c2ecf20Sopenharmony_ci dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n"); 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci if (sprom->boardflags_lo & BGMAC_BFL_ENETADM) 2138c2ecf20Sopenharmony_ci dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n"); 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci /* Feature Flags */ 2168c2ecf20Sopenharmony_ci switch (ci->id) { 2178c2ecf20Sopenharmony_ci /* BCM 471X/535X family */ 2188c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM4716: 2198c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; 2208c2ecf20Sopenharmony_ci fallthrough; 2218c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM47162: 2228c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2; 2238c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK; 2248c2ecf20Sopenharmony_ci break; 2258c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM5357: 2268c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM53572: 2278c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK; 2288c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; 2298c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1; 2308c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY; 2318c2ecf20Sopenharmony_ci if ((ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM47186) || 2328c2ecf20Sopenharmony_ci (ci->id == BCMA_CHIP_ID_BCM53572 && ci->pkg == BCMA_PKG_ID_BCM47188)) { 2338c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII; 2348c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED; 2358c2ecf20Sopenharmony_ci } 2368c2ecf20Sopenharmony_ci if (ci->id == BCMA_CHIP_ID_BCM5357 && ci->pkg == BCMA_PKG_ID_BCM5358) 2378c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII; 2388c2ecf20Sopenharmony_ci break; 2398c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM53573: 2408c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; 2418c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK; 2428c2ecf20Sopenharmony_ci if (ci->pkg == BCMA_PKG_ID_BCM47189) 2438c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED; 2448c2ecf20Sopenharmony_ci if (core->core_unit == 0) { 2458c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CC4_IF_SW_TYPE; 2468c2ecf20Sopenharmony_ci if (ci->pkg == BCMA_PKG_ID_BCM47189) 2478c2ecf20Sopenharmony_ci bgmac->feature_flags |= 2488c2ecf20Sopenharmony_ci BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII; 2498c2ecf20Sopenharmony_ci } else if (core->core_unit == 1) { 2508c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_IRQ_ID_OOB_6; 2518c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CC7_IF_TYPE_RGMII; 2528c2ecf20Sopenharmony_ci } 2538c2ecf20Sopenharmony_ci break; 2548c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM4749: 2558c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK; 2568c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; 2578c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1; 2588c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY; 2598c2ecf20Sopenharmony_ci if (ci->pkg == 10) { 2608c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII; 2618c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED; 2628c2ecf20Sopenharmony_ci } 2638c2ecf20Sopenharmony_ci break; 2648c2ecf20Sopenharmony_ci /* bcm4707_family */ 2658c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM4707: 2668c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM47094: 2678c2ecf20Sopenharmony_ci case BCMA_CHIP_ID_BCM53018: 2688c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; 2698c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_NO_RESET; 2708c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500; 2718c2ecf20Sopenharmony_ci break; 2728c2ecf20Sopenharmony_ci default: 2738c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; 2748c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK; 2758c2ecf20Sopenharmony_ci } 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci if (!bgmac_is_bcm4707_family(core) && core->id.rev > 2) 2788c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_MISC_PLL_REQ; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci if (core->id.id == BCMA_CORE_4706_MAC_GBIT) { 2818c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CMN_PHY_CTL; 2828c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_NO_CLR_MIB; 2838c2ecf20Sopenharmony_ci } 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci if (core->id.rev >= 4) { 2868c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4; 2878c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP; 2888c2ecf20Sopenharmony_ci bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP; 2898c2ecf20Sopenharmony_ci } 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci bgmac->read = bcma_bgmac_read; 2928c2ecf20Sopenharmony_ci bgmac->write = bcma_bgmac_write; 2938c2ecf20Sopenharmony_ci bgmac->idm_read = bcma_bgmac_idm_read; 2948c2ecf20Sopenharmony_ci bgmac->idm_write = bcma_bgmac_idm_write; 2958c2ecf20Sopenharmony_ci bgmac->clk_enabled = bcma_bgmac_clk_enabled; 2968c2ecf20Sopenharmony_ci bgmac->clk_enable = bcma_bgmac_clk_enable; 2978c2ecf20Sopenharmony_ci bgmac->cco_ctl_maskset = bcma_bgmac_cco_ctl_maskset; 2988c2ecf20Sopenharmony_ci bgmac->get_bus_clock = bcma_bgmac_get_bus_clock; 2998c2ecf20Sopenharmony_ci bgmac->cmn_maskset32 = bcma_bgmac_cmn_maskset32; 3008c2ecf20Sopenharmony_ci if (bgmac->mii_bus) 3018c2ecf20Sopenharmony_ci bgmac->phy_connect = bcma_phy_connect; 3028c2ecf20Sopenharmony_ci else 3038c2ecf20Sopenharmony_ci bgmac->phy_connect = bgmac_phy_connect_direct; 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_ci err = bgmac_enet_probe(bgmac); 3068c2ecf20Sopenharmony_ci if (err) 3078c2ecf20Sopenharmony_ci goto err1; 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci return 0; 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_cierr1: 3128c2ecf20Sopenharmony_ci bcma_mdio_mii_unregister(bgmac->mii_bus); 3138c2ecf20Sopenharmony_cierr: 3148c2ecf20Sopenharmony_ci bcma_set_drvdata(core, NULL); 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci return err; 3178c2ecf20Sopenharmony_ci} 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_cistatic void bgmac_remove(struct bcma_device *core) 3208c2ecf20Sopenharmony_ci{ 3218c2ecf20Sopenharmony_ci struct bgmac *bgmac = bcma_get_drvdata(core); 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci bcma_mdio_mii_unregister(bgmac->mii_bus); 3248c2ecf20Sopenharmony_ci bgmac_enet_remove(bgmac); 3258c2ecf20Sopenharmony_ci bcma_set_drvdata(core, NULL); 3268c2ecf20Sopenharmony_ci} 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cistatic struct bcma_driver bgmac_bcma_driver = { 3298c2ecf20Sopenharmony_ci .name = KBUILD_MODNAME, 3308c2ecf20Sopenharmony_ci .id_table = bgmac_bcma_tbl, 3318c2ecf20Sopenharmony_ci .probe = bgmac_probe, 3328c2ecf20Sopenharmony_ci .remove = bgmac_remove, 3338c2ecf20Sopenharmony_ci}; 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_cistatic int __init bgmac_init(void) 3368c2ecf20Sopenharmony_ci{ 3378c2ecf20Sopenharmony_ci int err; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci err = bcma_driver_register(&bgmac_bcma_driver); 3408c2ecf20Sopenharmony_ci if (err) 3418c2ecf20Sopenharmony_ci return err; 3428c2ecf20Sopenharmony_ci pr_info("Broadcom 47xx GBit MAC driver loaded\n"); 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci return 0; 3458c2ecf20Sopenharmony_ci} 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_cistatic void __exit bgmac_exit(void) 3488c2ecf20Sopenharmony_ci{ 3498c2ecf20Sopenharmony_ci bcma_driver_unregister(&bgmac_bcma_driver); 3508c2ecf20Sopenharmony_ci} 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_cimodule_init(bgmac_init) 3538c2ecf20Sopenharmony_cimodule_exit(bgmac_exit) 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ciMODULE_AUTHOR("Rafał Miłecki"); 3568c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 357