1 From 387b75f8b31437792e8334390fdf5cf060d1e3da Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Tue, 2 Feb 2016 07:47:14 +0100
4 Subject: [PATCH] bgmac: add helper checking for BCM4707 / BCM53018 chip id
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Chipsets with BCM4707 / BCM53018 ID require special handling at a few
10 places in the code. It's likely there will be more IDs to check in the
11 future. To simplify it add this trivial helper.
13 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
16 drivers/net/ethernet/broadcom/bgmac.c | 30 ++++++++++++++++--------------
17 1 file changed, 16 insertions(+), 14 deletions(-)
19 --- a/drivers/net/ethernet/broadcom/bgmac.c
20 +++ b/drivers/net/ethernet/broadcom/bgmac.c
21 @@ -26,6 +26,17 @@ static const struct bcma_device_id bgmac
23 MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
25 +static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
27 + switch (bgmac->core->bus->chipinfo.id) {
28 + case BCMA_CHIP_ID_BCM4707:
29 + case BCMA_CHIP_ID_BCM53018:
36 static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
37 u32 value, int timeout)
39 @@ -987,11 +998,9 @@ static void bgmac_mac_speed(struct bgmac
40 static void bgmac_miiconfig(struct bgmac *bgmac)
42 struct bcma_device *core = bgmac->core;
43 - struct bcma_chipinfo *ci = &core->bus->chipinfo;
46 - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
47 - ci->id == BCMA_CHIP_ID_BCM53018) {
48 + if (bgmac_is_bcm4707_family(bgmac)) {
49 bcma_awrite32(core, BCMA_IOCTL,
50 bcma_aread32(core, BCMA_IOCTL) | 0x40 |
51 BGMAC_BCMA_IOCTL_SW_CLKEN);
52 @@ -1055,9 +1064,7 @@ static void bgmac_chip_reset(struct bgma
55 /* Request Misc PLL for corerev > 2 */
56 - if (core->id.rev > 2 &&
57 - ci->id != BCMA_CHIP_ID_BCM4707 &&
58 - ci->id != BCMA_CHIP_ID_BCM53018) {
59 + if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
60 bgmac_set(bgmac, BCMA_CLKCTLST,
61 BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
62 bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
63 @@ -1193,8 +1200,7 @@ static void bgmac_enable(struct bgmac *b
67 - if (ci->id != BCMA_CHIP_ID_BCM4707 &&
68 - ci->id != BCMA_CHIP_ID_BCM53018) {
69 + if (!bgmac_is_bcm4707_family(bgmac)) {
70 rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
71 rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
72 bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
73 @@ -1472,14 +1478,12 @@ static int bgmac_fixed_phy_register(stru
75 static int bgmac_mii_register(struct bgmac *bgmac)
77 - struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
78 struct mii_bus *mii_bus;
79 struct phy_device *phy_dev;
80 char bus_id[MII_BUS_ID_SIZE + 3];
83 - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
84 - ci->id == BCMA_CHIP_ID_BCM53018)
85 + if (bgmac_is_bcm4707_family(bgmac))
86 return bgmac_fixed_phy_register(bgmac);
88 mii_bus = mdiobus_alloc();
89 @@ -1550,7 +1554,6 @@ static void bgmac_mii_unregister(struct
90 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
91 static int bgmac_probe(struct bcma_device *core)
93 - struct bcma_chipinfo *ci = &core->bus->chipinfo;
94 struct net_device *net_dev;
96 struct ssb_sprom *sprom = &core->bus->sprom;
97 @@ -1631,8 +1634,7 @@ static int bgmac_probe(struct bcma_devic
98 bgmac_chip_reset(bgmac);
100 /* For Northstar, we have to take all GMAC core out of reset */
101 - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
102 - ci->id == BCMA_CHIP_ID_BCM53018) {
103 + if (bgmac_is_bcm4707_family(bgmac)) {
104 struct bcma_device *ns_core;