提交 387b75f8 编写于 作者: R Rafał Miłecki 提交者: David S. Miller

bgmac: add helper checking for BCM4707 / BCM53018 chip id

Chipsets with BCM4707 / BCM53018 ID require special handling at a few
places in the code. It's likely there will be more IDs to check in the
future. To simplify it add this trivial helper.
Signed-off-by: NRafał Miłecki <zajec5@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 8ac2c867
...@@ -26,6 +26,17 @@ static const struct bcma_device_id bgmac_bcma_tbl[] = { ...@@ -26,6 +26,17 @@ static const struct bcma_device_id bgmac_bcma_tbl[] = {
}; };
MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl); MODULE_DEVICE_TABLE(bcma, bgmac_bcma_tbl);
static inline bool bgmac_is_bcm4707_family(struct bgmac *bgmac)
{
switch (bgmac->core->bus->chipinfo.id) {
case BCMA_CHIP_ID_BCM4707:
case BCMA_CHIP_ID_BCM53018:
return true;
default:
return false;
}
}
static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask, static bool bgmac_wait_value(struct bcma_device *core, u16 reg, u32 mask,
u32 value, int timeout) u32 value, int timeout)
{ {
...@@ -987,11 +998,9 @@ static void bgmac_mac_speed(struct bgmac *bgmac) ...@@ -987,11 +998,9 @@ static void bgmac_mac_speed(struct bgmac *bgmac)
static void bgmac_miiconfig(struct bgmac *bgmac) static void bgmac_miiconfig(struct bgmac *bgmac)
{ {
struct bcma_device *core = bgmac->core; struct bcma_device *core = bgmac->core;
struct bcma_chipinfo *ci = &core->bus->chipinfo;
u8 imode; u8 imode;
if (ci->id == BCMA_CHIP_ID_BCM4707 || if (bgmac_is_bcm4707_family(bgmac)) {
ci->id == BCMA_CHIP_ID_BCM53018) {
bcma_awrite32(core, BCMA_IOCTL, bcma_awrite32(core, BCMA_IOCTL,
bcma_aread32(core, BCMA_IOCTL) | 0x40 | bcma_aread32(core, BCMA_IOCTL) | 0x40 |
BGMAC_BCMA_IOCTL_SW_CLKEN); BGMAC_BCMA_IOCTL_SW_CLKEN);
...@@ -1055,9 +1064,7 @@ static void bgmac_chip_reset(struct bgmac *bgmac) ...@@ -1055,9 +1064,7 @@ static void bgmac_chip_reset(struct bgmac *bgmac)
} }
/* Request Misc PLL for corerev > 2 */ /* Request Misc PLL for corerev > 2 */
if (core->id.rev > 2 && if (core->id.rev > 2 && !bgmac_is_bcm4707_family(bgmac)) {
ci->id != BCMA_CHIP_ID_BCM4707 &&
ci->id != BCMA_CHIP_ID_BCM53018) {
bgmac_set(bgmac, BCMA_CLKCTLST, bgmac_set(bgmac, BCMA_CLKCTLST,
BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ); BGMAC_BCMA_CLKCTLST_MISC_PLL_REQ);
bgmac_wait_value(bgmac->core, BCMA_CLKCTLST, bgmac_wait_value(bgmac->core, BCMA_CLKCTLST,
...@@ -1193,8 +1200,7 @@ static void bgmac_enable(struct bgmac *bgmac) ...@@ -1193,8 +1200,7 @@ static void bgmac_enable(struct bgmac *bgmac)
break; break;
} }
if (ci->id != BCMA_CHIP_ID_BCM4707 && if (!bgmac_is_bcm4707_family(bgmac)) {
ci->id != BCMA_CHIP_ID_BCM53018) {
rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL); rxq_ctl = bgmac_read(bgmac, BGMAC_RXQ_CTL);
rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK; rxq_ctl &= ~BGMAC_RXQ_CTL_MDP_MASK;
bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) / bp_clk = bcma_pmu_get_bus_clock(&bgmac->core->bus->drv_cc) /
...@@ -1472,14 +1478,12 @@ static int bgmac_fixed_phy_register(struct bgmac *bgmac) ...@@ -1472,14 +1478,12 @@ static int bgmac_fixed_phy_register(struct bgmac *bgmac)
static int bgmac_mii_register(struct bgmac *bgmac) static int bgmac_mii_register(struct bgmac *bgmac)
{ {
struct bcma_chipinfo *ci = &bgmac->core->bus->chipinfo;
struct mii_bus *mii_bus; struct mii_bus *mii_bus;
struct phy_device *phy_dev; struct phy_device *phy_dev;
char bus_id[MII_BUS_ID_SIZE + 3]; char bus_id[MII_BUS_ID_SIZE + 3];
int err = 0; int err = 0;
if (ci->id == BCMA_CHIP_ID_BCM4707 || if (bgmac_is_bcm4707_family(bgmac))
ci->id == BCMA_CHIP_ID_BCM53018)
return bgmac_fixed_phy_register(bgmac); return bgmac_fixed_phy_register(bgmac);
mii_bus = mdiobus_alloc(); mii_bus = mdiobus_alloc();
...@@ -1539,7 +1543,6 @@ static void bgmac_mii_unregister(struct bgmac *bgmac) ...@@ -1539,7 +1543,6 @@ static void bgmac_mii_unregister(struct bgmac *bgmac)
/* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */ /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipattach */
static int bgmac_probe(struct bcma_device *core) static int bgmac_probe(struct bcma_device *core)
{ {
struct bcma_chipinfo *ci = &core->bus->chipinfo;
struct net_device *net_dev; struct net_device *net_dev;
struct bgmac *bgmac; struct bgmac *bgmac;
struct ssb_sprom *sprom = &core->bus->sprom; struct ssb_sprom *sprom = &core->bus->sprom;
...@@ -1620,8 +1623,7 @@ static int bgmac_probe(struct bcma_device *core) ...@@ -1620,8 +1623,7 @@ static int bgmac_probe(struct bcma_device *core)
bgmac_chip_reset(bgmac); bgmac_chip_reset(bgmac);
/* For Northstar, we have to take all GMAC core out of reset */ /* For Northstar, we have to take all GMAC core out of reset */
if (ci->id == BCMA_CHIP_ID_BCM4707 || if (bgmac_is_bcm4707_family(bgmac)) {
ci->id == BCMA_CHIP_ID_BCM53018) {
struct bcma_device *ns_core; struct bcma_device *ns_core;
int ns_gmac; int ns_gmac;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册