Skip to content

Commit f458ac4

Browse files
Linus Walleijkuba-moo
authored andcommitted
ARM/net: ixp4xx: Pass ethernet physical base as resource
In order to probe this ethernet interface from the device tree all physical MMIO regions must be passed as resources. Begin this rewrite by first passing the port base address as a resource for all platforms using this driver, remap it in the driver and avoid using any reference of the statically mapped virtual address in the driver. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3cb5b0e commit f458ac4

File tree

8 files changed

+131
-9
lines changed

8 files changed

+131
-9
lines changed

arch/arm/mach-ixp4xx/fsg-setup.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ static struct platform_device fsg_leds = {
132132
};
133133

134134
/* Built-in 10/100 Ethernet MAC interfaces */
135+
static struct resource fsg_eth_npeb_resources[] = {
136+
{
137+
.start = IXP4XX_EthB_BASE_PHYS,
138+
.end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
139+
.flags = IORESOURCE_MEM,
140+
},
141+
};
142+
143+
static struct resource fsg_eth_npec_resources[] = {
144+
{
145+
.start = IXP4XX_EthC_BASE_PHYS,
146+
.end = IXP4XX_EthC_BASE_PHYS + 0x0fff,
147+
.flags = IORESOURCE_MEM,
148+
},
149+
};
150+
135151
static struct eth_plat_info fsg_plat_eth[] = {
136152
{
137153
.phy = 5,
@@ -151,12 +167,16 @@ static struct platform_device fsg_eth[] = {
151167
.dev = {
152168
.platform_data = fsg_plat_eth,
153169
},
170+
.num_resources = ARRAY_SIZE(fsg_eth_npeb_resources),
171+
.resource = fsg_eth_npeb_resources,
154172
}, {
155173
.name = "ixp4xx_eth",
156174
.id = IXP4XX_ETH_NPEC,
157175
.dev = {
158176
.platform_data = fsg_plat_eth + 1,
159177
},
178+
.num_resources = ARRAY_SIZE(fsg_eth_npec_resources),
179+
.resource = fsg_eth_npec_resources,
160180
}
161181
};
162182

arch/arm/mach-ixp4xx/goramo_mlr.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,22 @@ static struct platform_device device_uarts = {
273273

274274

275275
/* Built-in 10/100 Ethernet MAC interfaces */
276+
static struct resource eth_npeb_resources[] = {
277+
{
278+
.start = IXP4XX_EthB_BASE_PHYS,
279+
.end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
280+
.flags = IORESOURCE_MEM,
281+
},
282+
};
283+
284+
static struct resource eth_npec_resources[] = {
285+
{
286+
.start = IXP4XX_EthC_BASE_PHYS,
287+
.end = IXP4XX_EthC_BASE_PHYS + 0x0fff,
288+
.flags = IORESOURCE_MEM,
289+
},
290+
};
291+
276292
static struct eth_plat_info eth_plat[] = {
277293
{
278294
.phy = 0,
@@ -290,10 +306,14 @@ static struct platform_device device_eth_tab[] = {
290306
.name = "ixp4xx_eth",
291307
.id = IXP4XX_ETH_NPEB,
292308
.dev.platform_data = eth_plat,
309+
.num_resources = ARRAY_SIZE(eth_npeb_resources),
310+
.resource = eth_npeb_resources,
293311
}, {
294312
.name = "ixp4xx_eth",
295313
.id = IXP4XX_ETH_NPEC,
296314
.dev.platform_data = eth_plat + 1,
315+
.num_resources = ARRAY_SIZE(eth_npec_resources),
316+
.resource = eth_npec_resources,
297317
}
298318
};
299319

arch/arm/mach-ixp4xx/ixdp425-setup.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,22 @@ static struct platform_device ixdp425_uart = {
187187
};
188188

189189
/* Built-in 10/100 Ethernet MAC interfaces */
190+
static struct resource ixp425_npeb_resources[] = {
191+
{
192+
.start = IXP4XX_EthB_BASE_PHYS,
193+
.end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
194+
.flags = IORESOURCE_MEM,
195+
},
196+
};
197+
198+
static struct resource ixp425_npec_resources[] = {
199+
{
200+
.start = IXP4XX_EthC_BASE_PHYS,
201+
.end = IXP4XX_EthC_BASE_PHYS + 0x0fff,
202+
.flags = IORESOURCE_MEM,
203+
},
204+
};
205+
190206
static struct eth_plat_info ixdp425_plat_eth[] = {
191207
{
192208
.phy = 0,
@@ -204,10 +220,14 @@ static struct platform_device ixdp425_eth[] = {
204220
.name = "ixp4xx_eth",
205221
.id = IXP4XX_ETH_NPEB,
206222
.dev.platform_data = ixdp425_plat_eth,
223+
.num_resources = ARRAY_SIZE(ixp425_npeb_resources),
224+
.resource = ixp425_npeb_resources,
207225
}, {
208226
.name = "ixp4xx_eth",
209227
.id = IXP4XX_ETH_NPEC,
210228
.dev.platform_data = ixdp425_plat_eth + 1,
229+
.num_resources = ARRAY_SIZE(ixp425_npec_resources),
230+
.resource = ixp425_npec_resources,
211231
}
212232
};
213233

arch/arm/mach-ixp4xx/nas100d-setup.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ static struct platform_device nas100d_uart = {
165165
};
166166

167167
/* Built-in 10/100 Ethernet MAC interfaces */
168+
static struct resource nas100d_eth_resources[] = {
169+
{
170+
.start = IXP4XX_EthB_BASE_PHYS,
171+
.end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
172+
.flags = IORESOURCE_MEM,
173+
},
174+
};
175+
168176
static struct eth_plat_info nas100d_plat_eth[] = {
169177
{
170178
.phy = 0,
@@ -178,6 +186,8 @@ static struct platform_device nas100d_eth[] = {
178186
.name = "ixp4xx_eth",
179187
.id = IXP4XX_ETH_NPEB,
180188
.dev.platform_data = nas100d_plat_eth,
189+
.num_resources = ARRAY_SIZE(nas100d_eth_resources),
190+
.resource = nas100d_eth_resources,
181191
}
182192
};
183193

arch/arm/mach-ixp4xx/nslu2-setup.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ static struct platform_device nslu2_uart = {
185185
};
186186

187187
/* Built-in 10/100 Ethernet MAC interfaces */
188+
static struct resource nslu2_eth_resources[] = {
189+
{
190+
.start = IXP4XX_EthB_BASE_PHYS,
191+
.end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
192+
.flags = IORESOURCE_MEM,
193+
},
194+
};
195+
188196
static struct eth_plat_info nslu2_plat_eth[] = {
189197
{
190198
.phy = 1,
@@ -198,6 +206,8 @@ static struct platform_device nslu2_eth[] = {
198206
.name = "ixp4xx_eth",
199207
.id = IXP4XX_ETH_NPEB,
200208
.dev.platform_data = nslu2_plat_eth,
209+
.num_resources = ARRAY_SIZE(nslu2_eth_resources),
210+
.resource = nslu2_eth_resources,
201211
}
202212
};
203213

arch/arm/mach-ixp4xx/omixp-setup.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,22 @@ static struct platform_device mic256_leds = {
170170
};
171171

172172
/* Built-in 10/100 Ethernet MAC interfaces */
173+
static struct resource ixp425_npeb_resources[] = {
174+
{
175+
.start = IXP4XX_EthB_BASE_PHYS,
176+
.end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
177+
.flags = IORESOURCE_MEM,
178+
},
179+
};
180+
181+
static struct resource ixp425_npec_resources[] = {
182+
{
183+
.start = IXP4XX_EthC_BASE_PHYS,
184+
.end = IXP4XX_EthC_BASE_PHYS + 0x0fff,
185+
.flags = IORESOURCE_MEM,
186+
},
187+
};
188+
173189
static struct eth_plat_info ixdp425_plat_eth[] = {
174190
{
175191
.phy = 0,
@@ -187,10 +203,14 @@ static struct platform_device ixdp425_eth[] = {
187203
.name = "ixp4xx_eth",
188204
.id = IXP4XX_ETH_NPEB,
189205
.dev.platform_data = ixdp425_plat_eth,
206+
.num_resources = ARRAY_SIZE(ixp425_npeb_resources),
207+
.resource = ixp425_npeb_resources,
190208
}, {
191209
.name = "ixp4xx_eth",
192210
.id = IXP4XX_ETH_NPEC,
193211
.dev.platform_data = ixdp425_plat_eth + 1,
212+
.num_resources = ARRAY_SIZE(ixp425_npec_resources),
213+
.resource = ixp425_npec_resources,
194214
},
195215
};
196216

arch/arm/mach-ixp4xx/vulcan-setup.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ static struct platform_device vulcan_uart = {
124124
.num_resources = ARRAY_SIZE(vulcan_uart_resources),
125125
};
126126

127+
static struct resource vulcan_npeb_resources[] = {
128+
{
129+
.start = IXP4XX_EthB_BASE_PHYS,
130+
.end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
131+
.flags = IORESOURCE_MEM,
132+
},
133+
};
134+
135+
static struct resource vulcan_npec_resources[] = {
136+
{
137+
.start = IXP4XX_EthC_BASE_PHYS,
138+
.end = IXP4XX_EthC_BASE_PHYS + 0x0fff,
139+
.flags = IORESOURCE_MEM,
140+
},
141+
};
142+
127143
static struct eth_plat_info vulcan_plat_eth[] = {
128144
[0] = {
129145
.phy = 0,
@@ -144,13 +160,17 @@ static struct platform_device vulcan_eth[] = {
144160
.dev = {
145161
.platform_data = &vulcan_plat_eth[0],
146162
},
163+
.num_resources = ARRAY_SIZE(vulcan_npeb_resources),
164+
.resource = vulcan_npeb_resources,
147165
},
148166
[1] = {
149167
.name = "ixp4xx_eth",
150168
.id = IXP4XX_ETH_NPEC,
151169
.dev = {
152170
.platform_data = &vulcan_plat_eth[1],
153171
},
172+
.num_resources = ARRAY_SIZE(vulcan_npec_resources),
173+
.resource = vulcan_npec_resources,
154174
},
155175
};
156176

drivers/net/ethernet/xscale/ixp4xx_eth.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,9 +1365,10 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
13651365
struct phy_device *phydev = NULL;
13661366
struct device *dev = &pdev->dev;
13671367
struct eth_plat_info *plat;
1368+
resource_size_t regs_phys;
13681369
struct net_device *ndev;
1370+
struct resource *res;
13691371
struct port *port;
1370-
u32 regs_phys;
13711372
int err;
13721373

13731374
plat = dev_get_platdata(dev);
@@ -1380,13 +1381,18 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
13801381
port->netdev = ndev;
13811382
port->id = pdev->id;
13821383

1384+
/* Get the port resource and remap */
1385+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1386+
if (!res)
1387+
return -ENODEV;
1388+
regs_phys = res->start;
1389+
port->regs = devm_ioremap_resource(dev, res);
1390+
13831391
switch (port->id) {
13841392
case IXP4XX_ETH_NPEA:
13851393
/* If the MDIO bus is not up yet, defer probe */
13861394
if (!mdio_bus)
13871395
return -EPROBE_DEFER;
1388-
port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT;
1389-
regs_phys = IXP4XX_EthA_BASE_PHYS;
13901396
break;
13911397
case IXP4XX_ETH_NPEB:
13921398
/*
@@ -1399,13 +1405,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
13991405
IXP4XX_FEATURE_NPEB_ETH0))
14001406
return -ENODEV;
14011407
/* Else register the MDIO bus on NPE-B */
1402-
if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
1408+
if ((err = ixp4xx_mdio_register(port->regs)))
14031409
return err;
14041410
}
14051411
if (!mdio_bus)
14061412
return -EPROBE_DEFER;
1407-
port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
1408-
regs_phys = IXP4XX_EthB_BASE_PHYS;
14091413
break;
14101414
case IXP4XX_ETH_NPEC:
14111415
/*
@@ -1417,13 +1421,11 @@ static int ixp4xx_eth_probe(struct platform_device *pdev)
14171421
IXP4XX_FEATURE_NPEC_ETH))
14181422
return -ENODEV;
14191423
/* Else register the MDIO bus on NPE-C */
1420-
if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
1424+
if ((err = ixp4xx_mdio_register(port->regs)))
14211425
return err;
14221426
}
14231427
if (!mdio_bus)
14241428
return -EPROBE_DEFER;
1425-
port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
1426-
regs_phys = IXP4XX_EthC_BASE_PHYS;
14271429
break;
14281430
default:
14291431
return -ENODEV;

0 commit comments

Comments
 (0)