1 From 1b49522dc7154751401512977d07ad01e5182c47 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Sat, 30 Jan 2016 00:35:37 +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>
15 drivers/net/ethernet/broadcom/bgmac.c | 29 ++++++++++++++++-------------
16 1 file changed, 16 insertions(+), 13 deletions(-)
18 --- a/drivers/net/ethernet/broadcom/bgmac.c
19 +++ b/drivers/net/ethernet/broadcom/bgmac.c
20 @@ -26,6 +26,17 @@ static const struct bcma_device_id bgmac
22 MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
24 +static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
26 + switch (bgmac->core->bus->chipinfo.id) {
27 + case BCMA_CHIP_ID_BCM4707:
28 + case BCMA_CHIP_ID_BCM53018:
35 static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
36 u32 value, int timeout)
38 @@ -982,11 +993,9 @@ static void bgmac_mac_speed(struct bgmac
39 static void bgmac_miiconfig(struct bgmac *bgmac)
41 struct bcma_device *core = bgmac->core;
42 - struct bcma_chipinfo *ci = &core->bus->chipinfo;
45 - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
46 - ci->id == BCMA_CHIP_ID_BCM53018) {
47 + if (bgmac_is_bcm4707_family(bgmac)) {
48 bcma_awrite32(core, BCMA_IOCTL,
49 bcma_aread32(core, BCMA_IOCTL) | 0x40 |
50 BGMAC_BCMA_IOCTL_SW_CLKEN);
51 @@ -1050,9 +1059,7 @@ static void bgmac_chip_reset(struct bgma
54 /* Request Misc PLL for corerev > 2 */
55 - if (core->id.rev > 2 &&
56 - ci->id != BCMA_CHIP_ID_BCM4707 &&
57 - ci->id != BCMA_CHIP_ID_BCM53018) {
58 + if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
59 bgmac_set(bgmac, BCMA_CLKCTLST,
60 BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
61 bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
62 @@ -1188,8 +1195,7 @@ static void bgmac_enable(struct bgmac *b
66 - if (ci->id != BCMA_CHIP_ID_BCM4707 &&
67 - ci->id != BCMA_CHIP_ID_BCM53018) {
68 + if (!bgmac_is_bcm4707_family(bgmac)) {
69 rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
70 rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
71 bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
72 @@ -1473,8 +1479,7 @@ static int bgmac_mii_register(struct bgm
73 char bus_id[MII_BUS_ID_SIZE + 3];
76 - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
77 - ci->id == BCMA_CHIP_ID_BCM53018)
78 + if (bgmac_is_bcm4707_family(bgmac))
79 return bgmac_fixed_phy_register(bgmac);
81 mii_bus = mdiobus_alloc();
82 @@ -1545,7 +1550,6 @@ static void bgmac_mii_unregister(struct
83 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
84 static int bgmac_probe(struct bcma_device *core)
86 - struct bcma_chipinfo *ci = &core->bus->chipinfo;
87 struct net_device *net_dev;
89 struct ssb_sprom *sprom = &core->bus->sprom;
90 @@ -1626,8 +1630,7 @@ static int bgmac_probe(struct bcma_devic
91 bgmac_chip_reset(bgmac);
93 /* For Northstar, we have to take all GMAC core out of reset */
94 - if (ci->id == BCMA_CHIP_ID_BCM4707 ||
95 - ci->id == BCMA_CHIP_ID_BCM53018) {
96 + if (bgmac_is_bcm4707_family(bgmac)) {
97 struct bcma_device *ns_core;