Skip to content

Commit ec22ac9

Browse files
DragonBlueprobimarko
authored andcommitted
kernel: rtl836x: remove legacy platform_data support
There are no platform_data based devices using it anymore. Also move header files to the driver folder. Signed-off-by: Shiji Yang <[email protected]> Link: openwrt/openwrt#21138 Signed-off-by: Robert Marko <[email protected]> (cherry picked from commit 852d17e)
1 parent bcbf4bd commit ec22ac9

File tree

7 files changed

+24
-225
lines changed

7 files changed

+24
-225
lines changed

target/linux/generic/files/drivers/net/phy/rtl8366_smi.c

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
#include <linux/spinlock.h>
1717
#include <linux/skbuff.h>
1818
#include <linux/of.h>
19-
#include <linux/of_platform.h>
2019
#include <linux/of_gpio.h>
21-
#include <linux/rtl8366.h>
2220
#include <linux/version.h>
2321
#include <linux/of_mdio.h>
22+
#include <linux/platform_device.h>
2423

2524
#ifdef CONFIG_RTL8366_SMI_DEBUG_FS
2625
#include <linux/debugfs.h>
@@ -1011,13 +1010,8 @@ static inline void rtl8366_debugfs_remove(struct rtl8366_smi *smi) {}
10111010
static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
10121011
{
10131012
int ret;
1014-
1015-
#ifdef CONFIG_OF
10161013
struct device_node *np = NULL;
10171014

1018-
np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
1019-
#endif
1020-
10211015
smi->mii_bus = mdiobus_alloc();
10221016
if (smi->mii_bus == NULL) {
10231017
ret = -ENOMEM;
@@ -1033,11 +1027,10 @@ static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
10331027
smi->mii_bus->parent = smi->parent;
10341028
smi->mii_bus->phy_mask = ~(0x1f);
10351029

1036-
#ifdef CONFIG_OF
1030+
np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
10371031
if (np)
10381032
ret = of_mdiobus_register(smi->mii_bus, np);
10391033
else
1040-
#endif
10411034
ret = mdiobus_register(smi->mii_bus);
10421035

10431036
if (ret)
@@ -1412,45 +1405,6 @@ static void __rtl8366_smi_cleanup(struct rtl8366_smi *smi)
14121405
}
14131406
}
14141407

1415-
enum rtl8366_type rtl8366_smi_detect(struct rtl8366_platform_data *pdata)
1416-
{
1417-
static struct rtl8366_smi smi;
1418-
enum rtl8366_type type = RTL8366_TYPE_UNKNOWN;
1419-
u32 reg = 0;
1420-
1421-
memset(&smi, 0, sizeof(smi));
1422-
smi.gpio_sda = pdata->gpio_sda;
1423-
smi.gpio_sck = pdata->gpio_sck;
1424-
smi.clk_delay = 10;
1425-
smi.cmd_read = 0xa9;
1426-
smi.cmd_write = 0xa8;
1427-
1428-
if (__rtl8366_smi_init(&smi, "rtl8366"))
1429-
goto out;
1430-
1431-
if (rtl8366_smi_read_reg(&smi, 0x5c, &reg))
1432-
goto cleanup;
1433-
1434-
switch(reg) {
1435-
case 0x6027:
1436-
printk("Found an RTL8366S switch\n");
1437-
type = RTL8366_TYPE_S;
1438-
break;
1439-
case 0x5937:
1440-
printk("Found an RTL8366RB switch\n");
1441-
type = RTL8366_TYPE_RB;
1442-
break;
1443-
default:
1444-
printk("Found an Unknown RTL8366 switch (id=0x%04x)\n", reg);
1445-
break;
1446-
}
1447-
1448-
cleanup:
1449-
__rtl8366_smi_cleanup(&smi);
1450-
out:
1451-
return type;
1452-
}
1453-
14541408
int rtl8366_smi_init(struct rtl8366_smi *smi)
14551409
{
14561410
int err;
@@ -1518,7 +1472,6 @@ void rtl8366_smi_cleanup(struct rtl8366_smi *smi)
15181472
}
15191473
EXPORT_SYMBOL_GPL(rtl8366_smi_cleanup);
15201474

1521-
#ifdef CONFIG_OF
15221475
static void rtl8366_smi_reset(struct rtl8366_smi *smi, bool active)
15231476
{
15241477
if (active)
@@ -1570,30 +1523,6 @@ static int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi
15701523

15711524
return 0;
15721525
}
1573-
#else
1574-
static inline int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
1575-
{
1576-
return -ENODEV;
1577-
}
1578-
#endif
1579-
1580-
static int rtl8366_smi_probe_plat(struct platform_device *pdev, struct rtl8366_smi *smi)
1581-
{
1582-
struct rtl8366_platform_data *pdata = pdev->dev.platform_data;
1583-
1584-
if (!pdev->dev.platform_data) {
1585-
dev_err(&pdev->dev, "no platform data specified\n");
1586-
return -EINVAL;
1587-
}
1588-
1589-
smi->gpio_sda = pdata->gpio_sda;
1590-
smi->gpio_sck = pdata->gpio_sck;
1591-
smi->hw_reset = pdata->hw_reset;
1592-
smi->phy_id = MDC_REALTEK_PHY_ADDR;
1593-
1594-
return 0;
1595-
}
1596-
15971526

15981527
struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
15991528
{
@@ -1604,11 +1533,7 @@ struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
16041533
if (!smi)
16051534
return NULL;
16061535

1607-
if (pdev->dev.of_node)
1608-
err = rtl8366_smi_probe_of(pdev, smi);
1609-
else
1610-
err = rtl8366_smi_probe_plat(pdev, smi);
1611-
1536+
err = rtl8366_smi_probe_of(pdev, smi);
16121537
if (err)
16131538
goto free_smi;
16141539

target/linux/generic/files/drivers/net/phy/rtl8366rb.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
#include <linux/init.h>
1717
#include <linux/device.h>
1818
#include <linux/of.h>
19-
#include <linux/of_platform.h>
19+
#include <linux/platform_device.h>
2020
#include <linux/delay.h>
2121
#include <linux/skbuff.h>
22-
#include <linux/rtl8366.h>
2322

2423
#include "rtl8366_smi.h"
2524

2625
#define RTL8366RB_DRIVER_DESC "Realtek RTL8366RB ethernet switch driver"
2726
#define RTL8366RB_DRIVER_VER "0.2.4"
27+
#define RTL8366RB_DRIVER_NAME "rtl8366rb"
2828

2929
#define RTL8366RB_PHY_NO_MAX 4
3030
#define RTL8366RB_PHY_PAGE_MAX 7
@@ -285,13 +285,10 @@ static int rtl8366rb_reset_chip(struct rtl8366_smi *smi)
285285
static int rtl8366rb_setup(struct rtl8366_smi *smi)
286286
{
287287
int err;
288-
#ifdef CONFIG_OF
289288
unsigned i;
290-
struct device_node *np;
291289
unsigned num_initvals;
292290
const __be32 *paddr;
293-
294-
np = smi->parent->of_node;
291+
struct device_node *np = smi->parent->of_node;
295292

296293
paddr = of_get_property(np, "realtek,initvals", &num_initvals);
297294
if (paddr) {
@@ -309,7 +306,6 @@ static int rtl8366rb_setup(struct rtl8366_smi *smi)
309306
REG_WR(smi, reg, val);
310307
}
311308
}
312-
#endif
313309

314310
/* set maximum packet length to 1536 bytes */
315311
REG_RMW(smi, RTL8366RB_SGCR, RTL8366RB_SGCR_MAX_LENGTH_MASK,
@@ -1490,18 +1486,16 @@ static void rtl8366rb_remove(struct platform_device *pdev)
14901486
}
14911487
}
14921488

1493-
#ifdef CONFIG_OF
14941489
static const struct of_device_id rtl8366rb_match[] = {
14951490
{ .compatible = "realtek,rtl8366rb" },
14961491
{},
14971492
};
14981493
MODULE_DEVICE_TABLE(of, rtl8366rb_match);
1499-
#endif
15001494

15011495
static struct platform_driver rtl8366rb_driver = {
15021496
.driver = {
15031497
.name = RTL8366RB_DRIVER_NAME,
1504-
.of_match_table = of_match_ptr(rtl8366rb_match),
1498+
.of_match_table = rtl8366rb_match,
15051499
},
15061500
.probe = rtl8366rb_probe,
15071501
.remove_new = rtl8366rb_remove,

target/linux/generic/files/drivers/net/phy/rtl8366s.c

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
#include <linux/init.h>
1515
#include <linux/device.h>
1616
#include <linux/of.h>
17-
#include <linux/of_platform.h>
17+
#include <linux/platform_device.h>
1818
#include <linux/delay.h>
1919
#include <linux/skbuff.h>
20-
#include <linux/rtl8366.h>
2120

2221
#include "rtl8366_smi.h"
2322

2423
#define RTL8366S_DRIVER_DESC "Realtek RTL8366S ethernet switch driver"
2524
#define RTL8366S_DRIVER_VER "0.2.2"
25+
#define RTL8366S_DRIVER_NAME "rtl8366s"
2626

2727
#define RTL8366S_PHY_NO_MAX 4
2828
#define RTL8366S_PHY_PAGE_MAX 7
@@ -375,25 +375,11 @@ static int rtl8366s_set_green(struct rtl8366_smi *smi, int enable)
375375

376376
static int rtl8366s_setup(struct rtl8366_smi *smi)
377377
{
378-
struct rtl8366_platform_data *pdata;
379378
int err;
380379
unsigned i;
381-
#ifdef CONFIG_OF
382-
struct device_node *np;
383380
unsigned num_initvals;
384381
const __be32 *paddr;
385-
#endif
386-
387-
pdata = smi->parent->platform_data;
388-
if (pdata && pdata->num_initvals && pdata->initvals) {
389-
dev_info(smi->parent, "applying initvals\n");
390-
for (i = 0; i < pdata->num_initvals; i++)
391-
REG_WR(smi, pdata->initvals[i].reg,
392-
pdata->initvals[i].val);
393-
}
394-
395-
#ifdef CONFIG_OF
396-
np = smi->parent->of_node;
382+
struct device_node *np = smi->parent->of_node;
397383

398384
paddr = of_get_property(np, "realtek,initvals", &num_initvals);
399385
if (paddr) {
@@ -425,7 +411,6 @@ static int rtl8366s_setup(struct rtl8366_smi *smi)
425411
return err;
426412
}
427413
}
428-
#endif
429414

430415
/* set maximum packet length to 1536 bytes */
431416
REG_RMW(smi, RTL8366S_SGCR, RTL8366S_SGCR_MAX_LENGTH_MASK,
@@ -1278,20 +1263,16 @@ static void rtl8366s_remove(struct platform_device *pdev)
12781263
}
12791264
}
12801265

1281-
#ifdef CONFIG_OF
12821266
static const struct of_device_id rtl8366s_match[] = {
12831267
{ .compatible = "realtek,rtl8366s" },
12841268
{},
12851269
};
12861270
MODULE_DEVICE_TABLE(of, rtl8366s_match);
1287-
#endif
12881271

12891272
static struct platform_driver rtl8366s_driver = {
12901273
.driver = {
12911274
.name = RTL8366S_DRIVER_NAME,
1292-
#ifdef CONFIG_OF
1293-
.of_match_table = of_match_ptr(rtl8366s_match),
1294-
#endif
1275+
.of_match_table = rtl8366s_match,
12951276
},
12961277
.probe = rtl8366s_probe,
12971278
.remove_new = rtl8366s_remove,

target/linux/generic/files/drivers/net/phy/rtl8367.c

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
#include <linux/init.h>
1414
#include <linux/device.h>
1515
#include <linux/of.h>
16-
#include <linux/of_platform.h>
16+
#include <linux/platform_device.h>
1717
#include <linux/delay.h>
1818
#include <linux/skbuff.h>
19-
#include <linux/rtl8367.h>
2019

20+
#include "rtl8367.h"
2121
#include "rtl8366_smi.h"
2222

2323
#define RTL8367_RESET_DELAY 1000 /* msecs*/
@@ -1076,7 +1076,6 @@ static int rtl8367_led_blinkrate_set(struct rtl8366_smi *smi, unsigned int rate)
10761076
return 0;
10771077
}
10781078

1079-
#ifdef CONFIG_OF
10801079
static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
10811080
const char *name)
10821081
{
@@ -1133,40 +1132,20 @@ static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
11331132

11341133
return err;
11351134
}
1136-
#else
1137-
static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
1138-
const char *name)
1139-
{
1140-
return -EINVAL;
1141-
}
1142-
#endif
11431135

11441136
static int rtl8367_setup(struct rtl8366_smi *smi)
11451137
{
1146-
struct rtl8367_platform_data *pdata;
11471138
int err;
11481139
int i;
11491140

1150-
pdata = smi->parent->platform_data;
1151-
11521141
err = rtl8367_init_regs(smi);
11531142
if (err)
11541143
return err;
11551144

11561145
/* initialize external interfaces */
1157-
if (smi->parent->of_node) {
1158-
err = rtl8367_extif_init_of(smi, "realtek,extif");
1159-
if (err)
1160-
return err;
1161-
} else {
1162-
err = rtl8367_extif_init(smi, 0, pdata->extif0_cfg);
1163-
if (err)
1164-
return err;
1165-
1166-
err = rtl8367_extif_init(smi, 1, pdata->extif1_cfg);
1167-
if (err)
1168-
return err;
1169-
}
1146+
err = rtl8367_extif_init_of(smi, "realtek,extif");
1147+
if (err)
1148+
return err;
11701149

11711150
/* set maximum packet length to 1536 bytes */
11721151
REG_RMW(smi, RTL8367_SWC0_REG, RTL8367_SWC0_MAX_LENGTH_MASK,
@@ -1821,20 +1800,16 @@ static void rtl8367_shutdown(struct platform_device *pdev)
18211800
rtl8367_reset_chip(smi);
18221801
}
18231802

1824-
#ifdef CONFIG_OF
18251803
static const struct of_device_id rtl8367_match[] = {
18261804
{ .compatible = "realtek,rtl8367" },
18271805
{},
18281806
};
18291807
MODULE_DEVICE_TABLE(of, rtl8367_match);
1830-
#endif
18311808

18321809
static struct platform_driver rtl8367_driver = {
18331810
.driver = {
18341811
.name = RTL8367_DRIVER_NAME,
1835-
#ifdef CONFIG_OF
1836-
.of_match_table = of_match_ptr(rtl8367_match),
1837-
#endif
1812+
.of_match_table = rtl8367_match,
18381813
},
18391814
.probe = rtl8367_probe,
18401815
.remove_new = rtl8367_remove,

target/linux/generic/files/include/linux/rtl8367.h renamed to target/linux/generic/files/drivers/net/phy/rtl8367.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Platform data definition for the Realtek RTL8367 ethernet switch driver
2+
* Realtek RTL8367 ethernet switch driver
33
*
44
* Copyright (C) 2011 Gabor Juhos <[email protected]>
55
*
@@ -51,13 +51,4 @@ struct rtl8367_extif_config {
5151
struct rtl8367_port_ability ability;
5252
};
5353

54-
struct rtl8367_platform_data {
55-
unsigned gpio_sda;
56-
unsigned gpio_sck;
57-
void (*hw_reset)(bool active);
58-
59-
struct rtl8367_extif_config *extif0_cfg;
60-
struct rtl8367_extif_config *extif1_cfg;
61-
};
62-
6354
#endif /* _RTL8367_H */

0 commit comments

Comments
 (0)