From d00a8281bcc962027dfe409c2f3e3f0546be9200 Mon Sep 17 00:00:00 2001 From: Jon Mason Date: Thu, 7 Jul 2016 19:08:53 -0400 Subject: net: ethernet: bgmac: change bgmac_* prints to dev_* prints The bgmac_* print wrappers call dev_* prints with the dev pointer from the bcma core. In anticipation of removing the bcma requirement for this driver, these must be changed to not reference that struct. So, simply change all of the bgmac_* prints to their dev_* counterparts. In some cases netdev_* prints are more appropriate, so change those as well. Signed-off-by: Jon Mason Acked-by: Arnd Bergmann Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bgmac.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/net/ethernet/broadcom/bgmac.h') diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index 99beb18..abb9dd8 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h @@ -1,17 +1,6 @@ #ifndef _BGMAC_H #define _BGMAC_H -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#define bgmac_err(bgmac, fmt, ...) \ - dev_err(&(bgmac)->core->dev, fmt, ##__VA_ARGS__) -#define bgmac_warn(bgmac, fmt, ...) \ - dev_warn(&(bgmac)->core->dev, fmt, ##__VA_ARGS__) -#define bgmac_info(bgmac, fmt, ...) \ - dev_info(&(bgmac)->core->dev, fmt, ##__VA_ARGS__) -#define bgmac_dbg(bgmac, fmt, ...) \ - dev_dbg(&(bgmac)->core->dev, fmt, ##__VA_ARGS__) - #include #include #include @@ -438,6 +427,8 @@ struct bgmac_rx_header { struct bgmac { struct bcma_device *core; struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */ + + struct device *dev; struct net_device *net_dev; struct napi_struct napi; struct mii_bus *mii_bus; @@ -489,5 +480,4 @@ static inline void bgmac_set(struct bgmac *bgmac, u16 offset, u32 set) { bgmac_maskset(bgmac, offset, ~0, set); } - #endif /* _BGMAC_H */ -- cgit v1.1 From a0b68486f6f680c7c0352a47c60042d7d95ffd87 Mon Sep 17 00:00:00 2001 From: Jon Mason Date: Thu, 7 Jul 2016 19:08:54 -0400 Subject: net: ethernet: bgmac: add dma_dev pointer The dma buffer allocation, etc references a dma_dev device pointer from the bcma core. In anticipation of removing the bcma requirement for this driver, these must be changed to not reference that struct. Add a dma_dev device pointer to the bgmac stuct and reference that instead. Signed-off-by: Jon Mason Acked-by: Arnd Bergmann Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bgmac.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/ethernet/broadcom/bgmac.h') diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index abb9dd8..fd20018 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h @@ -429,6 +429,7 @@ struct bgmac { struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */ struct device *dev; + struct device *dma_dev; struct net_device *net_dev; struct napi_struct napi; struct mii_bus *mii_bus; -- cgit v1.1 From 55954f3bfdacc5908515b0c306cea23e77fab740 Mon Sep 17 00:00:00 2001 From: Jon Mason Date: Thu, 7 Jul 2016 19:08:55 -0400 Subject: net: ethernet: bgmac: move BCMA MDIO Phy code into a separate file Move the BCMA MDIO phy into a separate file, as it is very tightly coupled with the BCMA bus. This will help with the upcoming BCMA removal from the bgmac driver. Optimally, this should be moved into phy drivers, but it is too tightly coupled with the bgmac driver to effectively move it without more changes to the driver. Note: the phy_reset was intentionally removed, as the mdio phy subsystem automatically resets the phy if a reset function pointer is present. In addition to the moving of the driver, this reset function is added. Signed-off-by: Jon Mason Acked-by: Arnd Bergmann Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bgmac.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/net/ethernet/broadcom/bgmac.h') diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index fd20018..191e64a 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h @@ -456,6 +456,9 @@ struct bgmac { bool loopback; }; +struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr); +void bcma_mdio_mii_unregister(struct mii_bus *mii_bus); + static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset) { return bcma_read32(bgmac->core, offset); -- cgit v1.1 From db791eb2970bad193b1dc95a4461b222dd22cb64 Mon Sep 17 00:00:00 2001 From: Jon Mason Date: Thu, 7 Jul 2016 19:08:56 -0400 Subject: net: ethernet: bgmac: convert to feature flags The bgmac driver is using the bcma provides device ID and revision, as well as the SoC ID and package, to determine which features are necessary to enable, reset, etc in the driver. In anticipation of removing the bcma requirement for this driver, these must be changed to not reference that struct. In place of that, each "feature" has been given a flag, and the flags are enabled for their respective device and SoC. Signed-off-by: Jon Mason Acked-by: Arnd Bergmann Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bgmac.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers/net/ethernet/broadcom/bgmac.h') diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index 191e64a..89dfee1 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h @@ -190,7 +190,6 @@ #define BGMAC_CMDCFG_HD_SHIFT 10 #define BGMAC_CMDCFG_SR_REV0 0x00000800 /* Set to reset mode, for core rev 0-3 */ #define BGMAC_CMDCFG_SR_REV4 0x00002000 /* Set to reset mode, for core rev >= 4 */ -#define BGMAC_CMDCFG_SR(rev) ((rev >= 4) ? BGMAC_CMDCFG_SR_REV4 : BGMAC_CMDCFG_SR_REV0) #define BGMAC_CMDCFG_ML 0x00008000 /* Set to activate mac loopback mode */ #define BGMAC_CMDCFG_AE 0x00400000 #define BGMAC_CMDCFG_CFE 0x00800000 @@ -376,6 +375,24 @@ #define ETHER_MAX_LEN 1518 +/* Feature Flags */ +#define BGMAC_FEAT_TX_MASK_SETUP BIT(0) +#define BGMAC_FEAT_RX_MASK_SETUP BIT(1) +#define BGMAC_FEAT_IOST_ATTACHED BIT(2) +#define BGMAC_FEAT_NO_RESET BIT(3) +#define BGMAC_FEAT_MISC_PLL_REQ BIT(4) +#define BGMAC_FEAT_SW_TYPE_PHY BIT(5) +#define BGMAC_FEAT_SW_TYPE_EPHYRMII BIT(6) +#define BGMAC_FEAT_SW_TYPE_RGMII BIT(7) +#define BGMAC_FEAT_CMN_PHY_CTL BIT(8) +#define BGMAC_FEAT_FLW_CTRL1 BIT(9) +#define BGMAC_FEAT_FLW_CTRL2 BIT(10) +#define BGMAC_FEAT_SET_RXQ_CLK BIT(11) +#define BGMAC_FEAT_CLKCTLST BIT(12) +#define BGMAC_FEAT_NO_CLR_MIB BIT(13) +#define BGMAC_FEAT_FORCE_SPEED_2500 BIT(14) +#define BGMAC_FEAT_CMDCFG_SR_REV4 BIT(15) + struct bgmac_slot_info { union { struct sk_buff *skb; @@ -430,6 +447,8 @@ struct bgmac { struct device *dev; struct device *dma_dev; + u32 feature_flags; + struct net_device *net_dev; struct napi_struct napi; struct mii_bus *mii_bus; -- cgit v1.1 From f6a95a24957aec5bb488c3f978c4ed508177998f Mon Sep 17 00:00:00 2001 From: Jon Mason Date: Thu, 7 Jul 2016 19:08:57 -0400 Subject: net: ethernet: bgmac: Add platform device support The bcma portion of the driver has been split off into a bcma specific driver. This has been mirrored for the platform driver. The last references to the bcma core struct have been changed into a generic function call. These function calls are wrappers to either the original bcma code or new platform functions that access the same areas via MMIO. This necessitated adding function pointers for both platform and bcma to hide which backend is being used from the generic bgmac code. Signed-off-by: Jon Mason Acked-by: Arnd Bergmann Reviewed-by: Florian Fainelli Tested-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bgmac.h | 73 ++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 6 deletions(-) (limited to 'drivers/net/ethernet/broadcom/bgmac.h') diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index 89dfee1..24a2502 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h @@ -1,8 +1,6 @@ #ifndef _BGMAC_H #define _BGMAC_H -#include -#include #include #define BGMAC_DEV_CTL 0x000 @@ -442,11 +440,21 @@ struct bgmac_rx_header { }; struct bgmac { - struct bcma_device *core; - struct bcma_device *cmn; /* Reference to CMN core for BCM4706 */ + union { + struct { + void *base; + void *idm_base; + } plat; + struct { + struct bcma_device *core; + /* Reference to CMN core for BCM4706 */ + struct bcma_device *cmn; + } bcma; + }; struct device *dev; struct device *dma_dev; + unsigned char mac_addr[ETH_ALEN]; u32 feature_flags; struct net_device *net_dev; @@ -463,6 +471,7 @@ struct bgmac { u32 mib_rx_regs[BGMAC_NUM_MIB_RX_REGS]; /* Int */ + int irq; u32 int_mask; /* Current MAC state */ @@ -473,19 +482,71 @@ struct bgmac { bool has_robosw; bool loopback; + + u32 (*read)(struct bgmac *bgmac, u16 offset); + void (*write)(struct bgmac *bgmac, u16 offset, u32 value); + u32 (*idm_read)(struct bgmac *bgmac, u16 offset); + void (*idm_write)(struct bgmac *bgmac, u16 offset, u32 value); + bool (*clk_enabled)(struct bgmac *bgmac); + void (*clk_enable)(struct bgmac *bgmac, u32 flags); + void (*cco_ctl_maskset)(struct bgmac *bgmac, u32 offset, u32 mask, + u32 set); + u32 (*get_bus_clock)(struct bgmac *bgmac); + void (*cmn_maskset32)(struct bgmac *bgmac, u16 offset, u32 mask, + u32 set); }; +int bgmac_enet_probe(struct bgmac *info); +void bgmac_enet_remove(struct bgmac *bgmac); + struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr); void bcma_mdio_mii_unregister(struct mii_bus *mii_bus); static inline u32 bgmac_read(struct bgmac *bgmac, u16 offset) { - return bcma_read32(bgmac->core, offset); + return bgmac->read(bgmac, offset); } static inline void bgmac_write(struct bgmac *bgmac, u16 offset, u32 value) { - bcma_write32(bgmac->core, offset, value); + bgmac->write(bgmac, offset, value); +} + +static inline u32 bgmac_idm_read(struct bgmac *bgmac, u16 offset) +{ + return bgmac->idm_read(bgmac, offset); +} + +static inline void bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value) +{ + bgmac->idm_write(bgmac, offset, value); +} + +static inline bool bgmac_clk_enabled(struct bgmac *bgmac) +{ + return bgmac->clk_enabled(bgmac); +} + +static inline void bgmac_clk_enable(struct bgmac *bgmac, u32 flags) +{ + bgmac->clk_enable(bgmac, flags); +} + +static inline void bgmac_cco_ctl_maskset(struct bgmac *bgmac, u32 offset, + u32 mask, u32 set) +{ + bgmac->cco_ctl_maskset(bgmac, offset, mask, set); +} + +static inline u32 bgmac_get_bus_clock(struct bgmac *bgmac) +{ + return bgmac->get_bus_clock(bgmac); +} + +static inline void bgmac_cmn_maskset32(struct bgmac *bgmac, u16 offset, + u32 mask, u32 set) +{ + bgmac->cmn_maskset32(bgmac, offset, mask, set); } static inline void bgmac_maskset(struct bgmac *bgmac, u16 offset, u32 mask, -- cgit v1.1