mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-12-12 00:44:03 +02:00
ar71xx: ag71xx: detect the built-in switch of the AR934X SoCs
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29551 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
e61b2d1ed9
commit
f97a00297e
@ -25,6 +25,8 @@
|
|||||||
#define AR7240_MASK_CTRL_REVISION_M BITM(8)
|
#define AR7240_MASK_CTRL_REVISION_M BITM(8)
|
||||||
#define AR7240_MASK_CTRL_VERSION_M BITM(8)
|
#define AR7240_MASK_CTRL_VERSION_M BITM(8)
|
||||||
#define AR7240_MASK_CTRL_VERSION_S 8
|
#define AR7240_MASK_CTRL_VERSION_S 8
|
||||||
|
#define AR7240_MASK_CTRL_VERSION_AR7240 0x01
|
||||||
|
#define AR7240_MASK_CTRL_VERSION_AR934X 0x02
|
||||||
#define AR7240_MASK_CTRL_SOFT_RESET BIT(31)
|
#define AR7240_MASK_CTRL_SOFT_RESET BIT(31)
|
||||||
|
|
||||||
#define AR7240_REG_MAC_ADDR0 0x20
|
#define AR7240_REG_MAC_ADDR0 0x20
|
||||||
@ -192,6 +194,9 @@
|
|||||||
#define AR7240_PHY_ID1 0x004d
|
#define AR7240_PHY_ID1 0x004d
|
||||||
#define AR7240_PHY_ID2 0xd041
|
#define AR7240_PHY_ID2 0xd041
|
||||||
|
|
||||||
|
#define AR934X_PHY_ID1 0x004d
|
||||||
|
#define AR934X_PHY_ID2 0xd042
|
||||||
|
|
||||||
#define AR7240_MAX_VLANS 16
|
#define AR7240_MAX_VLANS 16
|
||||||
|
|
||||||
#define sw_to_ar7240(_dev) container_of(_dev, struct ar7240sw, swdev)
|
#define sw_to_ar7240(_dev) container_of(_dev, struct ar7240sw, swdev)
|
||||||
@ -201,6 +206,7 @@ struct ar7240sw {
|
|||||||
struct ag71xx_switch_platform_data *swdata;
|
struct ag71xx_switch_platform_data *swdata;
|
||||||
struct switch_dev swdev;
|
struct switch_dev swdev;
|
||||||
int num_ports;
|
int num_ports;
|
||||||
|
u8 ver;
|
||||||
bool vlan;
|
bool vlan;
|
||||||
u16 vlan_id[AR7240_MAX_VLANS];
|
u16 vlan_id[AR7240_MAX_VLANS];
|
||||||
u8 vlan_table[AR7240_MAX_VLANS];
|
u8 vlan_table[AR7240_MAX_VLANS];
|
||||||
@ -217,6 +223,16 @@ struct ar7240sw_hw_stat {
|
|||||||
|
|
||||||
static DEFINE_MUTEX(reg_mutex);
|
static DEFINE_MUTEX(reg_mutex);
|
||||||
|
|
||||||
|
static inline int sw_is_ar7240(struct ar7240sw *as)
|
||||||
|
{
|
||||||
|
return as->ver == AR7240_MASK_CTRL_VERSION_AR7240;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int sw_is_ar934x(struct ar7240sw *as)
|
||||||
|
{
|
||||||
|
return as->ver == AR7240_MASK_CTRL_VERSION_AR934X;
|
||||||
|
}
|
||||||
|
|
||||||
static inline u32 ar7240sw_port_mask(struct ar7240sw *as, int port)
|
static inline u32 ar7240sw_port_mask(struct ar7240sw *as, int port)
|
||||||
{
|
{
|
||||||
return BIT(port);
|
return BIT(port);
|
||||||
@ -851,12 +867,12 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
|
|||||||
u32 ctrl;
|
u32 ctrl;
|
||||||
u16 phy_id1;
|
u16 phy_id1;
|
||||||
u16 phy_id2;
|
u16 phy_id2;
|
||||||
u8 ver;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1);
|
phy_id1 = ar7240sw_phy_read(mii, 0, MII_PHYSID1);
|
||||||
phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2);
|
phy_id2 = ar7240sw_phy_read(mii, 0, MII_PHYSID2);
|
||||||
if (phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) {
|
if ((phy_id1 != AR7240_PHY_ID1 || phy_id2 != AR7240_PHY_ID2) &&
|
||||||
|
(phy_id1 != AR934X_PHY_ID1 || phy_id2 != AR934X_PHY_ID2)) {
|
||||||
pr_err("%s: unknown phy id '%04x:%04x'\n",
|
pr_err("%s: unknown phy id '%04x:%04x'\n",
|
||||||
ag->dev->name, phy_id1, phy_id2);
|
ag->dev->name, phy_id1, phy_id2);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -869,27 +885,31 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
|
|||||||
as->mii_bus = mii;
|
as->mii_bus = mii;
|
||||||
as->swdata = pdata->switch_data;
|
as->swdata = pdata->switch_data;
|
||||||
|
|
||||||
|
swdev = &as->swdev;
|
||||||
|
|
||||||
ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL);
|
ctrl = ar7240sw_reg_read(mii, AR7240_REG_MASK_CTRL);
|
||||||
ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) & AR7240_MASK_CTRL_VERSION_M;
|
as->ver = (ctrl >> AR7240_MASK_CTRL_VERSION_S) &
|
||||||
if (ver != 1) {
|
AR7240_MASK_CTRL_VERSION_M;
|
||||||
|
|
||||||
|
if (sw_is_ar7240(as)) {
|
||||||
|
swdev->name = "AR7240/AR9330 built-in switch";
|
||||||
|
} else if (sw_is_ar934x(as)) {
|
||||||
|
swdev->name = "AR934X built-in switch";
|
||||||
|
} else {
|
||||||
pr_err("%s: unsupported chip, ctrl=%08x\n",
|
pr_err("%s: unsupported chip, ctrl=%08x\n",
|
||||||
ag->dev->name, ctrl);
|
ag->dev->name, ctrl);
|
||||||
return NULL;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
swdev = &as->swdev;
|
|
||||||
swdev->name = "AR7240 built-in switch";
|
|
||||||
swdev->ports = AR7240_NUM_PORTS - 1;
|
swdev->ports = AR7240_NUM_PORTS - 1;
|
||||||
swdev->cpu_port = AR7240_PORT_CPU;
|
swdev->cpu_port = AR7240_PORT_CPU;
|
||||||
swdev->vlans = AR7240_MAX_VLANS;
|
swdev->vlans = AR7240_MAX_VLANS;
|
||||||
swdev->ops = &ar7240_ops;
|
swdev->ops = &ar7240_ops;
|
||||||
|
|
||||||
if (register_switch(&as->swdev, ag->dev) < 0) {
|
if (register_switch(&as->swdev, ag->dev) < 0)
|
||||||
kfree(as);
|
goto err_free;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pr_info("%s: Found an AR7240 built-in switch\n", ag->dev->name);
|
pr_info("%s: Found an %s\n", ag->dev->name, swdev->name);
|
||||||
|
|
||||||
/* initialize defaults */
|
/* initialize defaults */
|
||||||
for (i = 0; i < AR7240_MAX_VLANS; i++)
|
for (i = 0; i < AR7240_MAX_VLANS; i++)
|
||||||
@ -898,6 +918,10 @@ static struct ar7240sw *ar7240_probe(struct ag71xx *ag)
|
|||||||
as->vlan_table[0] = ar7240sw_port_mask_all(as);
|
as->vlan_table[0] = ar7240sw_port_mask_all(as);
|
||||||
|
|
||||||
return as;
|
return as;
|
||||||
|
|
||||||
|
err_free:
|
||||||
|
kfree(as);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void link_function(struct work_struct *work) {
|
static void link_function(struct work_struct *work) {
|
||||||
|
Loading…
Reference in New Issue
Block a user