From 6886519f62cf784ed12a0367fa100092130d8522 Mon Sep 17 00:00:00 2001 From: blogic Date: Sat, 15 Dec 2012 01:59:08 +0000 Subject: [kernel] make rtl8366 driver OF capable git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34682 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../linux/generic/files/drivers/net/phy/rtl8367.c | 30 ++++++++++------------ 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8367.c') diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index ee2a04701..d2d4faab1 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -1677,22 +1677,9 @@ static int __devinit rtl8367_probe(struct platform_device *pdev) struct rtl8366_smi *smi; int err; - pdata = pdev->dev.platform_data; - if (!pdata) { - dev_err(&pdev->dev, "no platform data specified\n"); - err = -EINVAL; - goto err_out; - } - - smi = rtl8366_smi_alloc(&pdev->dev); - if (!smi) { - err = -ENOMEM; - goto err_out; - } - - smi->gpio_sda = pdata->gpio_sda; - smi->gpio_sck = pdata->gpio_sck; - smi->hw_reset = pdata->hw_reset; + smi = rtl8366_smi_probe(pdev); + if (!smi) + return -ENODEV; smi->clk_delay = 1500; smi->cmd_read = 0xb9; @@ -1747,10 +1734,19 @@ static void rtl8367_shutdown(struct platform_device *pdev) rtl8367_reset_chip(smi); } +#ifdef CONFIG_OF +static const struct of_device_id rtl8367_match[] = { + { .compatible = "rtl8367" }, + {}, +}; +MODULE_DEVICE_TABLE(of, rtl83767_match); +#endif + static struct platform_driver rtl8367_driver = { .driver = { .name = RTL8367_DRIVER_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(rtl8367_match), }, .probe = rtl8367_probe, .remove = __devexit_p(rtl8367_remove), -- cgit v1.2.3 From 6f8f4723ff1b59d2e5723da351e8a47fbaa30350 Mon Sep 17 00:00:00 2001 From: jogo Date: Sat, 15 Dec 2012 13:32:02 +0000 Subject: linux: generic: rtl836*: fix compilation with !CONFIG_OF fixes the following errors caused by r34682: CC [M] drivers/net/phy/rtl8366_smi.o In file included from drivers/net/phy/rtl8366_smi.c:26:0: drivers/net/phy/rtl8366_smi.h:149:46: warning: 'struct platform_device' declared inside parameter list [enabled by default] drivers/net/phy/rtl8366_smi.h:149:46: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] drivers/net/phy/rtl8366_smi.c:1398:65: warning: 'struct platform_device' declared inside parameter list [enabled by default] drivers/net/phy/rtl8366_smi.c: In function 'rtl8366_smi_probe_plat': drivers/net/phy/rtl8366_smi.c:1400:44: error: dereferencing pointer to incomplete type drivers/net/phy/rtl8366_smi.c:1402:11: error: dereferencing pointer to incomplete type drivers/net/phy/rtl8366_smi.c:1403:16: error: dereferencing pointer to incomplete type drivers/net/phy/rtl8366_smi.c: At top level: drivers/net/phy/rtl8366_smi.c:1415:46: warning: 'struct platform_device' declared inside parameter list [enabled by default] drivers/net/phy/rtl8366_smi.c:1415:21: error: conflicting types for 'rtl8366_smi_probe' drivers/net/phy/rtl8366_smi.h:149:21: note: previous declaration of 'rtl8366_smi_probe' was here drivers/net/phy/rtl8366_smi.c: In function 'rtl8366_smi_probe': drivers/net/phy/rtl8366_smi.c:1420:31: error: dereferencing pointer to incomplete type drivers/net/phy/rtl8366_smi.c:1424:10: error: dereferencing pointer to incomplete type drivers/net/phy/rtl8366_smi.c:1425:3: warning: passing argument 1 of 'rtl8366_smi_probe_of' from incompatible pointer type [enabled by default] drivers/net/phy/rtl8366_smi.c:1392:19: note: expected 'struct device_node *' but argument is of type 'struct platform_device *' drivers/net/phy/rtl8366_smi.c:1427:3: warning: passing argument 1 of 'rtl8366_smi_probe_plat' from incompatible pointer type [enabled by default] drivers/net/phy/rtl8366_smi.c:1398:5: note: expected 'struct platform_device *' but argument is of type 'struct platform_device *' drivers/net/phy/rtl8366_smi.c: At top level: drivers/net/phy/rtl8366_smi.c:1438:1: error: conflicting types for 'rtl8366_smi_probe' drivers/net/phy/rtl8366_smi.h:149:21: note: previous declaration of 'rtl8366_smi_probe' was here make[7]: *** [drivers/net/phy/rtl8366_smi.o] Error 1 make[6]: *** [drivers/net/phy] Error 2 make[5]: *** [drivers/net] Error 2 make[4]: *** [drivers] Error 2 Signed-off-by: Jonas Gorski git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34703 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/generic/files/drivers/net/phy/rtl8367.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8367.c') diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index d2d4faab1..c6ae6a5ef 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1746,7 +1747,9 @@ static struct platform_driver rtl8367_driver = { .driver = { .name = RTL8367_DRIVER_NAME, .owner = THIS_MODULE, +#ifdef CONFIG_OF .of_match_table = of_match_ptr(rtl8367_match), +#endif }, .probe = rtl8367_probe, .remove = __devexit_p(rtl8367_remove), -- cgit v1.2.3 From 1a20d913f9cea25528a396a129303f9e6405c616 Mon Sep 17 00:00:00 2001 From: juhosg Date: Mon, 17 Dec 2012 13:02:18 +0000 Subject: generic: rtl836x: fix compiler warnings CC drivers/net/phy/rtl8366rb.o In file included from drivers/net/phy/rtl8366s.c:16:0: include/linux/of_platform.h:106:13: warning: 'struct device' declared inside parameter list [enabled by default] include/linux/of_platform.h:106:13: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] drivers/net/phy/rtl8366s.c: In function 'rtl8366s_probe': drivers/net/phy/rtl8366s.c:1094:2: warning: label 'err_out' defined but not used [-Wunused-label] drivers/net/phy/rtl8366s.c:1055:32: warning: unused variable 'pdata'[-Wunused-variable] CC drivers/net/phy/rtl8366rb.o In file included from drivers/net/phy/rtl8366rb.c:17:0: include/linux/of_platform.h:106:13: warning: 'struct device' declared inside parameter list [enabled by default] include/linux/of_platform.h:106:13: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] drivers/net/phy/rtl8366rb.c: In function 'rtl8366rb_probe': drivers/net/phy/rtl8366rb.c:1214:2: warning: label 'err_out' defined but not used [-Wunused-label] drivers/net/phy/rtl8366rb.c:1175:32: warning: unused variable 'pdata'[-Wunused-variable] CC drivers/net/phy/rtl8367.o In file included from drivers/net/phy/rtl8367.c:15:0: include/linux/of_platform.h:106:13: warning: 'struct device' declared inside parameter list [enabled by default] include/linux/of_platform.h:106:13: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] drivers/net/phy/rtl8367.c: In function 'rtl8367_probe': drivers/net/phy/rtl8367.c:1712:2: warning: label 'err_out' defined but not used [-Wunused-label] drivers/net/phy/rtl8367.c:1677:32: warning: unused variable 'pdata' [-Wunused-variable] CC drivers/net/phy/rtl8367b.o In file included from drivers/net/phy/rtl8367b.c:15:0: include/linux/of_platform.h:106:13: warning: 'struct device' declared inside parameter list [enabled by default] include/linux/of_platform.h:106:13: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] drivers/net/phy/rtl8367b.c: In function 'rtl8367b_probe': drivers/net/phy/rtl8367b.c:1494:2: warning: label 'err_out' defined but not used [-Wunused-label] drivers/net/phy/rtl8367b.c:1459:32: warning: unused variable 'pdata' [-Wunused-variable] Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34731 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/generic/files/drivers/net/phy/rtl8367.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8367.c') diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index c6ae6a5ef..b225e6750 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1674,7 +1675,6 @@ static struct rtl8366_smi_ops rtl8367_smi_ops = { static int __devinit rtl8367_probe(struct platform_device *pdev) { - struct rtl8367_platform_data *pdata; struct rtl8366_smi *smi; int err; @@ -1709,7 +1709,6 @@ static int __devinit rtl8367_probe(struct platform_device *pdev) rtl8366_smi_cleanup(smi); err_free_smi: kfree(smi); - err_out: return err; } -- cgit v1.2.3 From 91ba1524d4179b776ff3ae90c22a37eb26827833 Mon Sep 17 00:00:00 2001 From: hauke Date: Sun, 27 Jan 2013 17:48:48 +0000 Subject: kernel: remove __devinit, __devexit and __devexit_p for kernel 3.8 These attributes where removed with kernel 3.8 and are now causing compile errors. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35328 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/generic/files/drivers/net/phy/rtl8367.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8367.c') diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index b225e6750..cd58bbb8f 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -1673,7 +1673,7 @@ static struct rtl8366_smi_ops rtl8367_smi_ops = { .enable_port = rtl8367_enable_port, }; -static int __devinit rtl8367_probe(struct platform_device *pdev) +static int rtl8367_probe(struct platform_device *pdev) { struct rtl8366_smi *smi; int err; @@ -1712,7 +1712,7 @@ static int __devinit rtl8367_probe(struct platform_device *pdev) return err; } -static int __devexit rtl8367_remove(struct platform_device *pdev) +static int rtl8367_remove(struct platform_device *pdev) { struct rtl8366_smi *smi = platform_get_drvdata(pdev); @@ -1751,7 +1751,7 @@ static struct platform_driver rtl8367_driver = { #endif }, .probe = rtl8367_probe, - .remove = __devexit_p(rtl8367_remove), + .remove = rtl8367_remove, .shutdown = rtl8367_shutdown, }; -- cgit v1.2.3 From 812bce2793fa95b26ec620a1da4899a7915a82c5 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sat, 6 Apr 2013 12:37:32 +0000 Subject: generic: rtl8367: add vendor prefix to the compatible string Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36218 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/generic/files/drivers/net/phy/rtl8367.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8367.c') diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index cd58bbb8f..8d4d0d3e7 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -1736,7 +1736,7 @@ static void rtl8367_shutdown(struct platform_device *pdev) #ifdef CONFIG_OF static const struct of_device_id rtl8367_match[] = { - { .compatible = "rtl8367" }, + { .compatible = "realtek,rtl8367" }, {}, }; MODULE_DEVICE_TABLE(of, rtl83767_match); -- cgit v1.2.3 From 324817d29dc79abed91115dbb234a317dac6c407 Mon Sep 17 00:00:00 2001 From: juhosg Date: Sat, 6 Apr 2013 12:37:34 +0000 Subject: generic: rtl8367: fix a typo in MODULE_DEVICE_TABLE macro Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36219 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- target/linux/generic/files/drivers/net/phy/rtl8367.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8367.c') diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index 8d4d0d3e7..cab07c831 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -1739,7 +1739,7 @@ static const struct of_device_id rtl8367_match[] = { { .compatible = "realtek,rtl8367" }, {}, }; -MODULE_DEVICE_TABLE(of, rtl83767_match); +MODULE_DEVICE_TABLE(of, rtl8367_match); #endif static struct platform_driver rtl8367_driver = { -- cgit v1.2.3 From 8d0f6ae2f6716cb2165dadc7ae4466fc60f93caf Mon Sep 17 00:00:00 2001 From: juhosg Date: Sat, 6 Apr 2013 12:37:36 +0000 Subject: generic: rtl8367: allow to load extif config from OF Signed-off-by: Gabor Juhos git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36220 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../linux/generic/files/drivers/net/phy/rtl8367.c | 67 ++++++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'target/linux/generic/files/drivers/net/phy/rtl8367.c') diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index cab07c831..3cd811e75 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -1073,6 +1073,51 @@ static int rtl8367_led_blinkrate_set(struct rtl8366_smi *smi, unsigned int rate) return 0; } +#ifdef CONFIG_OF +static int rtl8367_extif_init_of(struct rtl8366_smi *smi, int id, + const char *name) +{ + struct rtl8367_extif_config *cfg; + const __be32 *prop; + int size; + int err; + + prop = of_get_property(smi->parent->of_node, name, &size); + if (!prop) + return rtl8367_extif_init(smi, id, NULL); + + if (size != (9 * sizeof(*prop))) { + dev_err(smi->parent, "%s property is invalid\n", name); + return -EINVAL; + } + + cfg = kzalloc(sizeof(struct rtl8367_extif_config), GFP_KERNEL); + if (!cfg) + return -ENOMEM; + + cfg->txdelay = be32_to_cpup(prop++); + cfg->rxdelay = be32_to_cpup(prop++); + cfg->mode = be32_to_cpup(prop++); + cfg->ability.force_mode = be32_to_cpup(prop++); + cfg->ability.txpause = be32_to_cpup(prop++); + cfg->ability.rxpause = be32_to_cpup(prop++); + cfg->ability.link = be32_to_cpup(prop++); + cfg->ability.duplex = be32_to_cpup(prop++); + cfg->ability.speed = be32_to_cpup(prop++); + + err = rtl8367_extif_init(smi, id, cfg); + kfree(cfg); + + return err; +} +#else +static int rtl8367_extif_init_of(struct rtl8366_smi *smi, int id, + const char *name) +{ + return -EINVAL; +} +#endif + static int rtl8367_setup(struct rtl8366_smi *smi) { struct rtl8367_platform_data *pdata; @@ -1086,13 +1131,23 @@ static int rtl8367_setup(struct rtl8366_smi *smi) return err; /* initialize external interfaces */ - err = rtl8367_extif_init(smi, 0, pdata->extif0_cfg); - if (err) - return err; + if (smi->parent->of_node) { + err = rtl8367_extif_init_of(smi, 0, "realtek,extif0"); + if (err) + return err; - err = rtl8367_extif_init(smi, 1, pdata->extif1_cfg); - if (err) - return err; + err = rtl8367_extif_init_of(smi, 1, "realtek,extif1"); + if (err) + return err; + } else { + err = rtl8367_extif_init(smi, 0, pdata->extif0_cfg); + if (err) + return err; + + err = rtl8367_extif_init(smi, 1, pdata->extif1_cfg); + if (err) + return err; + } /* set maximum packet length to 1536 bytes */ REG_RMW(smi, RTL8367_SWC0_REG, RTL8367_SWC0_MAX_LENGTH_MASK, -- cgit v1.2.3