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
* 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
Please send patches
......
......@@ -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
};
static struct xlr_net_data ndata[MAX_NUM_GMAC];
static struct resource xlr_net_res[8][2];
static struct platform_device xlr_net_dev[8];
static u32 __iomem *gmac0_addr;
static struct resource xlr_net0_res[8];
static struct resource xlr_net1_res[8];
static u32 __iomem *gmac4_addr;
static u32 __iomem *gpio_addr;
static void config_mac(struct xlr_net_data *nd, int phy, u32 __iomem *serdes,
u32 __iomem *pcs, int rfr, int tx, int *bkt_size,
struct xlr_fmn_info *gmac_fmn_info, int phy_addr)
static void xlr_resource_init(struct resource *res, int offset, int irq)
{
nd->cpu_mask = nlm_current_node()->coremask;
nd->phy_interface = phy;
nd->rfr_station = rfr;
nd->tx_stnid = tx;
nd->mii_addr = gmac0_addr;
nd->serdes_addr = serdes;
nd->pcs_addr = pcs;
nd->gpio_addr = gpio_addr;
nd->bucket_size = bkt_size;
nd->gmac_fmn_info = gmac_fmn_info;
nd->phy_addr = phy_addr;
res->name = "gmac";
res->start = CPHYSADDR(nlm_mmio_base(offset));
res->end = res->start + 0xfff;
res->flags = IORESOURCE_MEM;
res++;
res->name = "gmac";
res->start = res->end = irq;
res->flags = IORESOURCE_IRQ;
}
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";
res[0].start = CPHYSADDR(nlm_mmio_base(offset));
res[0].end = res[0].start + 0xfff;
res[0].flags = IORESOURCE_MEM;
res[1].name = "gmac";
res[1].start = irq;
res[1].end = irq;
res[1].flags = IORESOURCE_IRQ;
xlr_net_dev[id].name = "xlr-net";
xlr_net_dev[id].id = id;
xlr_net_dev[id].num_resources = 2;
xlr_net_dev[id].resource = res;
xlr_net_dev[id].dev.platform_data = &ndata[id];
int mac;
static struct xlr_net_data ndata1 = {
.phy_interface = PHY_INTERFACE_MODE_SGMII,
.rfr_station = FMN_STNID_GMAC1_FR_0,
.bucket_size = xlr_board_fmn_config.bucket_size,
.gmac_fmn_info = &xlr_board_fmn_config.gmac[1],
};
static struct platform_device xlr_net_dev1 = {
.name = "xlr-net",
.id = 1,
.dev.platform_data = &ndata1,
};
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)
{
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(
nlm_mmio_base(NETLOGIC_IO_GMAC_4_OFFSET)), 0xfff);
/* Passing GPIO base for serdes init. Only needed on sgmii ports*/
static struct xlr_net_data ndata0 = {
.rfr_station = FMN_STNID_GMACRFR_0,
.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(
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) {
case 12:
/* first block RGMII or XAUI, use RGMII */
config_mac(&ndata[0],
PHY_INTERFACE_MODE_RGMII,
gmac0_addr, /* serdes */
gmac0_addr, /* pcs */
FMN_STNID_GMACRFR_0,
FMN_STNID_GMAC0_TX0,
xlr_board_fmn_config.bucket_size,
&xlr_board_fmn_config.gmac[0],
0);
net_device_init(0, xlr_net_res[0], xlr_gmac_offsets[0],
ndata0.phy_interface = PHY_INTERFACE_MODE_RGMII,
ndata0.tx_stnid[0] = FMN_STNID_GMAC0_TX0;
ndata0.phy_addr[0] = 0;
xlr_net_dev0.num_resources = 2;
xlr_resource_init(&xlr_net0_res[0], xlr_gmac_offsets[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 */
break;
default:
/* default XLS config, all ports SGMII */
ndata0.phy_interface = PHY_INTERFACE_MODE_SGMII;
for (mac = 0; mac < 4; mac++) {
config_mac(&ndata[mac],
PHY_INTERFACE_MODE_SGMII,
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]);
}
ndata0.tx_stnid[mac] = FMN_STNID_GMAC0_TX0 + mac;
ndata0.phy_addr[mac] = mac + 0x10;
for (mac = 4; mac < MAX_NUM_XLS_GMAC; mac++) {
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_resource_init(&xlr_net0_res[mac * 2],
xlr_gmac_offsets[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)
int mac;
/* 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++) {
config_mac(&ndata[mac],
PHY_INTERFACE_MODE_RGMII,
0,
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],
ndata0.tx_stnid[mac] = FMN_STNID_GMAC0_TX0 + mac;
ndata0.phy_addr[mac] = mac;
xlr_resource_init(&xlr_net0_res[mac * 2], xlr_gmac_offsets[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)
{
gmac0_addr = ioremap(CPHYSADDR(
nlm_mmio_base(NETLOGIC_IO_GMAC_0_OFFSET)), 0xfff);
if (nlm_chip_is_xls())
xls_gmac_init();
else
......
......@@ -31,6 +31,9 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define PORTS_PER_CONTROLLER 4
struct xlr_net_data {
int cpu_mask;
u32 __iomem *mii_addr;
......@@ -39,8 +42,8 @@ struct xlr_net_data {
u32 __iomem *gpio_addr;
int phy_interface;
int rfr_station;
int tx_stnid;
int tx_stnid[PORTS_PER_CONTROLLER];
int *bucket_size;
int phy_addr;
int phy_addr[PORTS_PER_CONTROLLER];
struct xlr_fmn_info *gmac_fmn_info;
};
This diff is collapsed.
......@@ -1069,14 +1069,20 @@ enum tsv_rsv_reg {
CARRY_REG_2 = 0x4d,
};
struct xlr_adapter {
struct net_device *netdev[4];
};
struct xlr_net_priv {
u32 __iomem *base_addr;
struct net_device *ndev;
struct xlr_adapter *adapter;
struct mii_bus *mii_bus;
int num_rx_desc;
int phy_addr; /* PHY addr on MDIO bus */
int pcs_id; /* PCS id on MDIO bus */
int port_id; /* Port(gmac/xgmac) number, i.e 0-7 */
int tx_stnid;
u32 __iomem *mii_addr;
u32 __iomem *serdes_addr;
u32 __iomem *pcs_addr;
......@@ -1096,4 +1102,4 @@ struct xlr_net_priv {
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