Commit f8397bc6 authored by Ganesan Ramalingam's avatar Ganesan Ramalingam Committed by Greg Kroah-Hartman

Staging: Netlogic: Move all the netdev under single parent device

XLR has one network controller and XLS has two network controllers, each
controller has 4 gmac devices. This patch initializes each controller as
a parent device and the four gmac devices of a controller are connected
to the parent controller as a child
Signed-off-by: default avatarGanesan Ramalingam <ganesanr@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e1a083be
* Implementing 64bit stat counter in software * Implementing 64bit stat counter in software
* All memory allocation should be changed to DMA allocations * All memory allocation should be changed to DMA allocations
* All the netdev should be linked to single pdev as parent
* Changing comments in to linux standred format * Changing comments in to linux standred format
Please send patches Please send patches
......
...@@ -72,116 +72,125 @@ static u32 xlr_gmac_irqs[] = { PIC_GMAC_0_IRQ, PIC_GMAC_1_IRQ, ...@@ -72,116 +72,125 @@ static u32 xlr_gmac_irqs[] = { PIC_GMAC_0_IRQ, PIC_GMAC_1_IRQ,
PIC_GMAC_6_IRQ, PIC_GMAC_7_IRQ PIC_GMAC_6_IRQ, PIC_GMAC_7_IRQ
}; };
static struct xlr_net_data ndata[MAX_NUM_GMAC]; static struct resource xlr_net0_res[8];
static struct resource xlr_net_res[8][2]; static struct resource xlr_net1_res[8];
static struct platform_device xlr_net_dev[8];
static u32 __iomem *gmac0_addr;
static u32 __iomem *gmac4_addr; static u32 __iomem *gmac4_addr;
static u32 __iomem *gpio_addr; static u32 __iomem *gpio_addr;
static void config_mac(struct xlr_net_data *nd, int phy, u32 __iomem *serdes, static void xlr_resource_init(struct resource *res, int offset, int irq)
u32 __iomem *pcs, int rfr, int tx, int *bkt_size,
struct xlr_fmn_info *gmac_fmn_info, int phy_addr)
{ {
nd->cpu_mask = nlm_current_node()->coremask; res->name = "gmac";
nd->phy_interface = phy;
nd->rfr_station = rfr; res->start = CPHYSADDR(nlm_mmio_base(offset));
nd->tx_stnid = tx; res->end = res->start + 0xfff;
nd->mii_addr = gmac0_addr; res->flags = IORESOURCE_MEM;
nd->serdes_addr = serdes;
nd->pcs_addr = pcs; res++;
nd->gpio_addr = gpio_addr; res->name = "gmac";
res->start = res->end = irq;
nd->bucket_size = bkt_size; res->flags = IORESOURCE_IRQ;
nd->gmac_fmn_info = gmac_fmn_info;
nd->phy_addr = phy_addr;
} }
static void net_device_init(int id, struct resource *res, int offset, int irq) static struct platform_device *gmac_controller2_init(void *gmac0_addr)
{ {
res[0].name = "gmac"; int mac;
res[0].start = CPHYSADDR(nlm_mmio_base(offset)); static struct xlr_net_data ndata1 = {
res[0].end = res[0].start + 0xfff; .phy_interface = PHY_INTERFACE_MODE_SGMII,
res[0].flags = IORESOURCE_MEM; .rfr_station = FMN_STNID_GMAC1_FR_0,
.bucket_size = xlr_board_fmn_config.bucket_size,
res[1].name = "gmac"; .gmac_fmn_info = &xlr_board_fmn_config.gmac[1],
res[1].start = irq; };
res[1].end = irq;
res[1].flags = IORESOURCE_IRQ; static struct platform_device xlr_net_dev1 = {
.name = "xlr-net",
xlr_net_dev[id].name = "xlr-net"; .id = 1,
xlr_net_dev[id].id = id; .dev.platform_data = &ndata1,
xlr_net_dev[id].num_resources = 2; };
xlr_net_dev[id].resource = res;
xlr_net_dev[id].dev.platform_data = &ndata[id]; gmac4_addr = ioremap(CPHYSADDR(
nlm_mmio_base(NETLOGIC_IO_GMAC_4_OFFSET)), 0xfff);
ndata1.serdes_addr = gmac4_addr;
ndata1.pcs_addr = gmac4_addr;
ndata1.mii_addr = gmac0_addr;
ndata1.gpio_addr = gpio_addr;
ndata1.cpu_mask = nlm_current_node()->coremask;
xlr_net_dev1.resource = xlr_net1_res;
for (mac = 0; mac < 4; mac++) {
ndata1.tx_stnid[mac] = FMN_STNID_GMAC1_TX0 + mac;
ndata1.phy_addr[mac] = mac + 4 + 0x10;
xlr_resource_init(&xlr_net1_res[mac * 2],
xlr_gmac_offsets[mac + 4],
xlr_gmac_irqs[mac + 4]);
}
xlr_net_dev1.num_resources = 8;
return &xlr_net_dev1;
} }
static void xls_gmac_init(void) static void xls_gmac_init(void)
{ {
int mac; int mac;
struct platform_device *xlr_net_dev1;
void __iomem *gmac0_addr = ioremap(CPHYSADDR(
nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
gmac4_addr = ioremap(CPHYSADDR( static struct xlr_net_data ndata0 = {
nlm_mmio_base(NETLOGIC_IO_GMAC_4_OFFSET)), 0xfff); .rfr_station = FMN_STNID_GMACRFR_0,
/* Passing GPIO base for serdes init. Only needed on sgmii ports*/ .bucket_size = xlr_board_fmn_config.bucket_size,
.gmac_fmn_info = &xlr_board_fmn_config.gmac[0],
};
static struct platform_device xlr_net_dev0 = {
.name = "xlr-net",
.id = 0,
};
xlr_net_dev0.dev.platform_data = &ndata0;
ndata0.serdes_addr = gmac0_addr;
ndata0.pcs_addr = gmac0_addr;
ndata0.mii_addr = gmac0_addr;
/* Passing GPIO base for serdes init. Only needed on sgmii ports */
gpio_addr = ioremap(CPHYSADDR( gpio_addr = ioremap(CPHYSADDR(
nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET)), 0xfff); nlm_mmio_base(NETLOGIC_IO_GPIO_OFFSET)), 0xfff);
ndata0.gpio_addr = gpio_addr;
ndata0.cpu_mask = nlm_current_node()->coremask;
xlr_net_dev0.resource = xlr_net0_res;
switch (nlm_prom_info.board_major_version) { switch (nlm_prom_info.board_major_version) {
case 12: case 12:
/* first block RGMII or XAUI, use RGMII */ /* first block RGMII or XAUI, use RGMII */
config_mac(&ndata[0], ndata0.phy_interface = PHY_INTERFACE_MODE_RGMII,
PHY_INTERFACE_MODE_RGMII, ndata0.tx_stnid[0] = FMN_STNID_GMAC0_TX0;
gmac0_addr, /* serdes */ ndata0.phy_addr[0] = 0;
gmac0_addr, /* pcs */
FMN_STNID_GMACRFR_0, xlr_net_dev0.num_resources = 2;
FMN_STNID_GMAC0_TX0,
xlr_board_fmn_config.bucket_size, xlr_resource_init(&xlr_net0_res[0], xlr_gmac_offsets[0],
&xlr_board_fmn_config.gmac[0],
0);
net_device_init(0, xlr_net_res[0], xlr_gmac_offsets[0],
xlr_gmac_irqs[0]); xlr_gmac_irqs[0]);
platform_device_register(&xlr_net_dev[0]); platform_device_register(&xlr_net_dev0);
/* second block is XAUI, not supported yet */ /* second block is XAUI, not supported yet */
break; break;
default: default:
/* default XLS config, all ports SGMII */ /* default XLS config, all ports SGMII */
ndata0.phy_interface = PHY_INTERFACE_MODE_SGMII;
for (mac = 0; mac < 4; mac++) { for (mac = 0; mac < 4; mac++) {
config_mac(&ndata[mac], ndata0.tx_stnid[mac] = FMN_STNID_GMAC0_TX0 + mac;
PHY_INTERFACE_MODE_SGMII, ndata0.phy_addr[mac] = mac + 0x10;
gmac0_addr, /* serdes */
gmac0_addr, /* pcs */
FMN_STNID_GMACRFR_0,
FMN_STNID_GMAC0_TX0 + mac,
xlr_board_fmn_config.bucket_size,
&xlr_board_fmn_config.gmac[0],
/* PHY address according to chip/board */
mac + 0x10);
net_device_init(mac, xlr_net_res[mac],
xlr_gmac_offsets[mac],
xlr_gmac_irqs[mac]);
platform_device_register(&xlr_net_dev[mac]);
}
for (mac = 4; mac < MAX_NUM_XLS_GMAC; mac++) { xlr_resource_init(&xlr_net0_res[mac * 2],
config_mac(&ndata[mac],
PHY_INTERFACE_MODE_SGMII,
gmac4_addr, /* serdes */
gmac4_addr, /* pcs */
FMN_STNID_GMAC1_FR_0,
FMN_STNID_GMAC1_TX0 + mac - 4,
xlr_board_fmn_config.bucket_size,
&xlr_board_fmn_config.gmac[1],
/* PHY address according to chip/board */
mac + 0x10);
net_device_init(mac, xlr_net_res[mac],
xlr_gmac_offsets[mac], xlr_gmac_offsets[mac],
xlr_gmac_irqs[mac]); xlr_gmac_irqs[mac]);
platform_device_register(&xlr_net_dev[mac]);
} }
xlr_net_dev0.num_resources = 8;
platform_device_register(&xlr_net_dev0);
xlr_net_dev1 = gmac_controller2_init(gmac0_addr);
platform_device_register(xlr_net_dev1);
} }
} }
...@@ -190,28 +199,41 @@ static void xlr_gmac_init(void) ...@@ -190,28 +199,41 @@ static void xlr_gmac_init(void)
int mac; int mac;
/* assume all GMACs for now */ /* assume all GMACs for now */
static struct xlr_net_data ndata0 = {
.phy_interface = PHY_INTERFACE_MODE_RGMII,
.serdes_addr = NULL,
.pcs_addr = NULL,
.rfr_station = FMN_STNID_GMACRFR_0,
.bucket_size = xlr_board_fmn_config.bucket_size,
.gmac_fmn_info = &xlr_board_fmn_config.gmac[0],
.gpio_addr = NULL,
};
static struct platform_device xlr_net_dev0 = {
.name = "xlr-net",
.id = 0,
.dev.platform_data = &ndata0,
};
ndata0.mii_addr = ioremap(CPHYSADDR(
nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
ndata0.cpu_mask = nlm_current_node()->coremask;
for (mac = 0; mac < MAX_NUM_XLR_GMAC; mac++) { for (mac = 0; mac < MAX_NUM_XLR_GMAC; mac++) {
config_mac(&ndata[mac], ndata0.tx_stnid[mac] = FMN_STNID_GMAC0_TX0 + mac;
PHY_INTERFACE_MODE_RGMII, ndata0.phy_addr[mac] = mac;
0, xlr_resource_init(&xlr_net0_res[mac * 2], xlr_gmac_offsets[mac],
0,
FMN_STNID_GMACRFR_0,
FMN_STNID_GMAC0_TX0,
xlr_board_fmn_config.bucket_size,
&xlr_board_fmn_config.gmac[0],
mac);
net_device_init(mac, xlr_net_res[mac], xlr_gmac_offsets[mac],
xlr_gmac_irqs[mac]); xlr_gmac_irqs[mac]);
platform_device_register(&xlr_net_dev[mac]);
} }
xlr_net_dev0.num_resources = 8;
xlr_net_dev0.resource = xlr_net0_res;
platform_device_register(&xlr_net_dev0);
} }
static int __init xlr_net_init(void) static int __init xlr_net_init(void)
{ {
gmac0_addr = ioremap(CPHYSADDR(
nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
if (nlm_chip_is_xls()) if (nlm_chip_is_xls())
xls_gmac_init(); xls_gmac_init();
else else
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#define PORTS_PER_CONTROLLER 4
struct xlr_net_data { struct xlr_net_data {
int cpu_mask; int cpu_mask;
u32 __iomem *mii_addr; u32 __iomem *mii_addr;
...@@ -39,8 +42,8 @@ struct xlr_net_data { ...@@ -39,8 +42,8 @@ struct xlr_net_data {
u32 __iomem *gpio_addr; u32 __iomem *gpio_addr;
int phy_interface; int phy_interface;
int rfr_station; int rfr_station;
int tx_stnid; int tx_stnid[PORTS_PER_CONTROLLER];
int *bucket_size; int *bucket_size;
int phy_addr; int phy_addr[PORTS_PER_CONTROLLER];
struct xlr_fmn_info *gmac_fmn_info; struct xlr_fmn_info *gmac_fmn_info;
}; };
This diff is collapsed.
...@@ -1069,14 +1069,20 @@ enum tsv_rsv_reg { ...@@ -1069,14 +1069,20 @@ enum tsv_rsv_reg {
CARRY_REG_2 = 0x4d, CARRY_REG_2 = 0x4d,
}; };
struct xlr_adapter {
struct net_device *netdev[4];
};
struct xlr_net_priv { struct xlr_net_priv {
u32 __iomem *base_addr; u32 __iomem *base_addr;
struct net_device *ndev; struct net_device *ndev;
struct xlr_adapter *adapter;
struct mii_bus *mii_bus; struct mii_bus *mii_bus;
int num_rx_desc; int num_rx_desc;
int phy_addr; /* PHY addr on MDIO bus */ int phy_addr; /* PHY addr on MDIO bus */
int pcs_id; /* PCS id on MDIO bus */ int pcs_id; /* PCS id on MDIO bus */
int port_id; /* Port(gmac/xgmac) number, i.e 0-7 */ int port_id; /* Port(gmac/xgmac) number, i.e 0-7 */
int tx_stnid;
u32 __iomem *mii_addr; u32 __iomem *mii_addr;
u32 __iomem *serdes_addr; u32 __iomem *serdes_addr;
u32 __iomem *pcs_addr; u32 __iomem *pcs_addr;
...@@ -1096,4 +1102,4 @@ struct xlr_net_priv { ...@@ -1096,4 +1102,4 @@ struct xlr_net_priv {
u64 *class_3_spill; u64 *class_3_spill;
}; };
void xlr_set_gmac_speed(struct xlr_net_priv *priv); extern void xlr_set_gmac_speed(struct xlr_net_priv *priv);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment