mirror of
https://github.com/openwrt/openwrt.git
synced 2025-12-21 14:54:29 +04:00
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 <yangshiji66@outlook.com> Link: https://github.com/openwrt/openwrt/pull/21138 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
@@ -16,11 +16,10 @@
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/rtl8366.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/of_mdio.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#ifdef CONFIG_RTL8366_SMI_DEBUG_FS
|
||||
#include <linux/debugfs.h>
|
||||
@@ -1011,13 +1010,8 @@ static inline void rtl8366_debugfs_remove(struct rtl8366_smi *smi) {}
|
||||
static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
struct device_node *np = NULL;
|
||||
|
||||
np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
|
||||
#endif
|
||||
|
||||
smi->mii_bus = mdiobus_alloc();
|
||||
if (smi->mii_bus == NULL) {
|
||||
ret = -ENOMEM;
|
||||
@@ -1033,11 +1027,10 @@ static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
|
||||
smi->mii_bus->parent = smi->parent;
|
||||
smi->mii_bus->phy_mask = ~(0x1f);
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
|
||||
if (np)
|
||||
ret = of_mdiobus_register(smi->mii_bus, np);
|
||||
else
|
||||
#endif
|
||||
ret = mdiobus_register(smi->mii_bus);
|
||||
|
||||
if (ret)
|
||||
@@ -1412,45 +1405,6 @@ static void __rtl8366_smi_cleanup(struct rtl8366_smi *smi)
|
||||
}
|
||||
}
|
||||
|
||||
enum rtl8366_type rtl8366_smi_detect(struct rtl8366_platform_data *pdata)
|
||||
{
|
||||
static struct rtl8366_smi smi;
|
||||
enum rtl8366_type type = RTL8366_TYPE_UNKNOWN;
|
||||
u32 reg = 0;
|
||||
|
||||
memset(&smi, 0, sizeof(smi));
|
||||
smi.gpio_sda = pdata->gpio_sda;
|
||||
smi.gpio_sck = pdata->gpio_sck;
|
||||
smi.clk_delay = 10;
|
||||
smi.cmd_read = 0xa9;
|
||||
smi.cmd_write = 0xa8;
|
||||
|
||||
if (__rtl8366_smi_init(&smi, "rtl8366"))
|
||||
goto out;
|
||||
|
||||
if (rtl8366_smi_read_reg(&smi, 0x5c, ®))
|
||||
goto cleanup;
|
||||
|
||||
switch(reg) {
|
||||
case 0x6027:
|
||||
printk("Found an RTL8366S switch\n");
|
||||
type = RTL8366_TYPE_S;
|
||||
break;
|
||||
case 0x5937:
|
||||
printk("Found an RTL8366RB switch\n");
|
||||
type = RTL8366_TYPE_RB;
|
||||
break;
|
||||
default:
|
||||
printk("Found an Unknown RTL8366 switch (id=0x%04x)\n", reg);
|
||||
break;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
__rtl8366_smi_cleanup(&smi);
|
||||
out:
|
||||
return type;
|
||||
}
|
||||
|
||||
int rtl8366_smi_init(struct rtl8366_smi *smi)
|
||||
{
|
||||
int err;
|
||||
@@ -1518,7 +1472,6 @@ void rtl8366_smi_cleanup(struct rtl8366_smi *smi)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rtl8366_smi_cleanup);
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static void rtl8366_smi_reset(struct rtl8366_smi *smi, bool active)
|
||||
{
|
||||
if (active)
|
||||
@@ -1570,30 +1523,6 @@ try_gpio:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static inline int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int rtl8366_smi_probe_plat(struct platform_device *pdev, struct rtl8366_smi *smi)
|
||||
{
|
||||
struct rtl8366_platform_data *pdata = pdev->dev.platform_data;
|
||||
|
||||
if (!pdev->dev.platform_data) {
|
||||
dev_err(&pdev->dev, "no platform data specified\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
smi->gpio_sda = pdata->gpio_sda;
|
||||
smi->gpio_sck = pdata->gpio_sck;
|
||||
smi->hw_reset = pdata->hw_reset;
|
||||
smi->phy_id = MDC_REALTEK_PHY_ADDR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
|
||||
{
|
||||
@@ -1604,11 +1533,7 @@ struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
|
||||
if (!smi)
|
||||
return NULL;
|
||||
|
||||
if (pdev->dev.of_node)
|
||||
err = rtl8366_smi_probe_of(pdev, smi);
|
||||
else
|
||||
err = rtl8366_smi_probe_plat(pdev, smi);
|
||||
|
||||
err = rtl8366_smi_probe_of(pdev, smi);
|
||||
if (err)
|
||||
goto free_smi;
|
||||
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/rtl8366.h>
|
||||
|
||||
#include "rtl8366_smi.h"
|
||||
|
||||
#define RTL8366RB_DRIVER_DESC "Realtek RTL8366RB ethernet switch driver"
|
||||
#define RTL8366RB_DRIVER_VER "0.2.4"
|
||||
#define RTL8366RB_DRIVER_NAME "rtl8366rb"
|
||||
|
||||
#define RTL8366RB_PHY_NO_MAX 4
|
||||
#define RTL8366RB_PHY_PAGE_MAX 7
|
||||
@@ -285,13 +285,10 @@ static int rtl8366rb_reset_chip(struct rtl8366_smi *smi)
|
||||
static int rtl8366rb_setup(struct rtl8366_smi *smi)
|
||||
{
|
||||
int err;
|
||||
#ifdef CONFIG_OF
|
||||
unsigned i;
|
||||
struct device_node *np;
|
||||
unsigned num_initvals;
|
||||
const __be32 *paddr;
|
||||
|
||||
np = smi->parent->of_node;
|
||||
struct device_node *np = smi->parent->of_node;
|
||||
|
||||
paddr = of_get_property(np, "realtek,initvals", &num_initvals);
|
||||
if (paddr) {
|
||||
@@ -309,7 +306,6 @@ static int rtl8366rb_setup(struct rtl8366_smi *smi)
|
||||
REG_WR(smi, reg, val);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* set maximum packet length to 1536 bytes */
|
||||
REG_RMW(smi, RTL8366RB_SGCR, RTL8366RB_SGCR_MAX_LENGTH_MASK,
|
||||
@@ -1490,18 +1486,16 @@ static void rtl8366rb_remove(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id rtl8366rb_match[] = {
|
||||
{ .compatible = "realtek,rtl8366rb" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rtl8366rb_match);
|
||||
#endif
|
||||
|
||||
static struct platform_driver rtl8366rb_driver = {
|
||||
.driver = {
|
||||
.name = RTL8366RB_DRIVER_NAME,
|
||||
.of_match_table = of_match_ptr(rtl8366rb_match),
|
||||
.of_match_table = rtl8366rb_match,
|
||||
},
|
||||
.probe = rtl8366rb_probe,
|
||||
.remove_new = rtl8366rb_remove,
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/rtl8366.h>
|
||||
|
||||
#include "rtl8366_smi.h"
|
||||
|
||||
#define RTL8366S_DRIVER_DESC "Realtek RTL8366S ethernet switch driver"
|
||||
#define RTL8366S_DRIVER_VER "0.2.2"
|
||||
#define RTL8366S_DRIVER_NAME "rtl8366s"
|
||||
|
||||
#define RTL8366S_PHY_NO_MAX 4
|
||||
#define RTL8366S_PHY_PAGE_MAX 7
|
||||
@@ -375,25 +375,11 @@ static int rtl8366s_set_green(struct rtl8366_smi *smi, int enable)
|
||||
|
||||
static int rtl8366s_setup(struct rtl8366_smi *smi)
|
||||
{
|
||||
struct rtl8366_platform_data *pdata;
|
||||
int err;
|
||||
unsigned i;
|
||||
#ifdef CONFIG_OF
|
||||
struct device_node *np;
|
||||
unsigned num_initvals;
|
||||
const __be32 *paddr;
|
||||
#endif
|
||||
|
||||
pdata = smi->parent->platform_data;
|
||||
if (pdata && pdata->num_initvals && pdata->initvals) {
|
||||
dev_info(smi->parent, "applying initvals\n");
|
||||
for (i = 0; i < pdata->num_initvals; i++)
|
||||
REG_WR(smi, pdata->initvals[i].reg,
|
||||
pdata->initvals[i].val);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
np = smi->parent->of_node;
|
||||
struct device_node *np = smi->parent->of_node;
|
||||
|
||||
paddr = of_get_property(np, "realtek,initvals", &num_initvals);
|
||||
if (paddr) {
|
||||
@@ -425,7 +411,6 @@ static int rtl8366s_setup(struct rtl8366_smi *smi)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* set maximum packet length to 1536 bytes */
|
||||
REG_RMW(smi, RTL8366S_SGCR, RTL8366S_SGCR_MAX_LENGTH_MASK,
|
||||
@@ -1278,20 +1263,16 @@ static void rtl8366s_remove(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id rtl8366s_match[] = {
|
||||
{ .compatible = "realtek,rtl8366s" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rtl8366s_match);
|
||||
#endif
|
||||
|
||||
static struct platform_driver rtl8366s_driver = {
|
||||
.driver = {
|
||||
.name = RTL8366S_DRIVER_NAME,
|
||||
#ifdef CONFIG_OF
|
||||
.of_match_table = of_match_ptr(rtl8366s_match),
|
||||
#endif
|
||||
.of_match_table = rtl8366s_match,
|
||||
},
|
||||
.probe = rtl8366s_probe,
|
||||
.remove_new = rtl8366s_remove,
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/rtl8367.h>
|
||||
|
||||
#include "rtl8367.h"
|
||||
#include "rtl8366_smi.h"
|
||||
|
||||
#define RTL8367_RESET_DELAY 1000 /* msecs*/
|
||||
@@ -1076,7 +1076,6 @@ 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,
|
||||
const char *name)
|
||||
{
|
||||
@@ -1133,40 +1132,20 @@ err_init:
|
||||
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
|
||||
const char *name)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int rtl8367_setup(struct rtl8366_smi *smi)
|
||||
{
|
||||
struct rtl8367_platform_data *pdata;
|
||||
int err;
|
||||
int i;
|
||||
|
||||
pdata = smi->parent->platform_data;
|
||||
|
||||
err = rtl8367_init_regs(smi);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* initialize external interfaces */
|
||||
if (smi->parent->of_node) {
|
||||
err = rtl8367_extif_init_of(smi, "realtek,extif");
|
||||
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;
|
||||
}
|
||||
err = rtl8367_extif_init_of(smi, "realtek,extif");
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* set maximum packet length to 1536 bytes */
|
||||
REG_RMW(smi, RTL8367_SWC0_REG, RTL8367_SWC0_MAX_LENGTH_MASK,
|
||||
@@ -1821,20 +1800,16 @@ static void rtl8367_shutdown(struct platform_device *pdev)
|
||||
rtl8367_reset_chip(smi);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id rtl8367_match[] = {
|
||||
{ .compatible = "realtek,rtl8367" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rtl8367_match);
|
||||
#endif
|
||||
|
||||
static struct platform_driver rtl8367_driver = {
|
||||
.driver = {
|
||||
.name = RTL8367_DRIVER_NAME,
|
||||
#ifdef CONFIG_OF
|
||||
.of_match_table = of_match_ptr(rtl8367_match),
|
||||
#endif
|
||||
.of_match_table = rtl8367_match,
|
||||
},
|
||||
.probe = rtl8367_probe,
|
||||
.remove_new = rtl8367_remove,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Platform data definition for the Realtek RTL8367 ethernet switch driver
|
||||
* Realtek RTL8367 ethernet switch driver
|
||||
*
|
||||
* Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
|
||||
*
|
||||
@@ -51,13 +51,4 @@ struct rtl8367_extif_config {
|
||||
struct rtl8367_port_ability ability;
|
||||
};
|
||||
|
||||
struct rtl8367_platform_data {
|
||||
unsigned gpio_sda;
|
||||
unsigned gpio_sck;
|
||||
void (*hw_reset)(bool active);
|
||||
|
||||
struct rtl8367_extif_config *extif0_cfg;
|
||||
struct rtl8367_extif_config *extif1_cfg;
|
||||
};
|
||||
|
||||
#endif /* _RTL8367_H */
|
||||
@@ -15,11 +15,11 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/rtl8367.h>
|
||||
|
||||
#include "rtl8367.h"
|
||||
#include "rtl8366_smi.h"
|
||||
|
||||
#define RTL8367B_RESET_DELAY 1000 /* msecs*/
|
||||
@@ -765,7 +765,6 @@ static int rtl8367b_extif_init(struct rtl8366_smi *smi, int id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static int rtl8367b_extif_init_of(struct rtl8366_smi *smi,
|
||||
const char *name)
|
||||
{
|
||||
@@ -842,40 +841,20 @@ err_init:
|
||||
|
||||
return err;
|
||||
}
|
||||
#else
|
||||
static int rtl8367b_extif_init_of(struct rtl8366_smi *smi,
|
||||
const char *name)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int rtl8367b_setup(struct rtl8366_smi *smi)
|
||||
{
|
||||
struct rtl8367_platform_data *pdata;
|
||||
int err;
|
||||
int i;
|
||||
|
||||
pdata = smi->parent->platform_data;
|
||||
|
||||
err = rtl8367b_init_regs(smi);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* initialize external interfaces */
|
||||
if (smi->parent->of_node) {
|
||||
err = rtl8367b_extif_init_of(smi, "realtek,extif");
|
||||
if (err)
|
||||
return err;
|
||||
} else {
|
||||
err = rtl8367b_extif_init(smi, 0, pdata->extif0_cfg);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = rtl8367b_extif_init(smi, 1, pdata->extif1_cfg);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
err = rtl8367b_extif_init_of(smi, "realtek,extif");
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* set maximum packet length to 1536 bytes */
|
||||
REG_RMW(smi, RTL8367B_SWC0_REG, RTL8367B_SWC0_MAX_LENGTH_MASK,
|
||||
@@ -1619,20 +1598,16 @@ static void rtl8367b_shutdown(struct platform_device *pdev)
|
||||
rtl8367b_reset_chip(smi);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static const struct of_device_id rtl8367b_match[] = {
|
||||
{ .compatible = "realtek,rtl8367b" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rtl8367b_match);
|
||||
#endif
|
||||
|
||||
static struct platform_driver rtl8367b_driver = {
|
||||
.driver = {
|
||||
.name = RTL8367B_DRIVER_NAME,
|
||||
#ifdef CONFIG_OF
|
||||
.of_match_table = of_match_ptr(rtl8367b_match),
|
||||
#endif
|
||||
.of_match_table = rtl8367b_match,
|
||||
},
|
||||
.probe = rtl8367b_probe,
|
||||
.remove_new = rtl8367b_remove,
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Platform data definition for the Realtek RTL8366RB/S ethernet switch driver
|
||||
*
|
||||
* Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published
|
||||
* by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef _RTL8366_H
|
||||
#define _RTL8366_H
|
||||
|
||||
#define RTL8366_DRIVER_NAME "rtl8366"
|
||||
#define RTL8366S_DRIVER_NAME "rtl8366s"
|
||||
#define RTL8366RB_DRIVER_NAME "rtl8366rb"
|
||||
|
||||
struct rtl8366_smi;
|
||||
|
||||
enum rtl8366_type {
|
||||
RTL8366_TYPE_UNKNOWN,
|
||||
RTL8366_TYPE_S,
|
||||
RTL8366_TYPE_RB,
|
||||
};
|
||||
|
||||
struct rtl8366_initval {
|
||||
unsigned reg;
|
||||
u16 val;
|
||||
};
|
||||
|
||||
struct rtl8366_platform_data {
|
||||
unsigned gpio_sda;
|
||||
unsigned gpio_sck;
|
||||
void (*hw_reset)(struct rtl8366_smi *smi, bool active);
|
||||
|
||||
unsigned num_initvals;
|
||||
struct rtl8366_initval *initvals;
|
||||
};
|
||||
|
||||
enum rtl8366_type rtl8366_smi_detect(struct rtl8366_platform_data *pdata);
|
||||
|
||||
#endif /* _RTL8366_H */
|
||||
Reference in New Issue
Block a user