mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
generic: rtl8366: introduce rtl8366_smi_ops
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21910 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#endif
|
||||
|
||||
#define RTL8366S_DRIVER_DESC "Realtek RTL8366RB ethernet switch driver"
|
||||
#define RTL8366S_DRIVER_VER "0.2.0"
|
||||
#define RTL8366S_DRIVER_VER "0.2.2"
|
||||
|
||||
#define RTL8366S_PHY_NO_MAX 4
|
||||
#define RTL8366S_PHY_PAGE_MAX 7
|
||||
@@ -1573,35 +1573,8 @@ static int rtl8366rb_mii_bus_match(struct mii_bus *bus)
|
||||
|
||||
static int rtl8366rb_setup(struct rtl8366rb *rtl)
|
||||
{
|
||||
struct rtl8366_smi *smi = &rtl->smi;
|
||||
u32 chip_id = 0;
|
||||
u32 chip_ver = 0;
|
||||
int ret;
|
||||
|
||||
ret = rtl8366_smi_read_reg(smi, RTL8366S_CHIP_ID_REG, &chip_id);
|
||||
if (ret) {
|
||||
dev_err(rtl->parent, "unable to read chip id\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (chip_id) {
|
||||
case RTL8366S_CHIP_ID_8366:
|
||||
break;
|
||||
default:
|
||||
dev_err(rtl->parent, "unknown chip id (%04x)\n", chip_id);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = rtl8366_smi_read_reg(smi, RTL8366S_CHIP_VERSION_CTRL_REG,
|
||||
&chip_ver);
|
||||
if (ret) {
|
||||
dev_err(rtl->parent, "unable to read chip version\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_info(rtl->parent, "RTL%04x ver. %u chip found\n",
|
||||
chip_id, chip_ver & RTL8366S_CHIP_VERSION_MASK);
|
||||
|
||||
ret = rtl8366rb_reset_chip(rtl);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1610,6 +1583,43 @@ static int rtl8366rb_setup(struct rtl8366rb *rtl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rtl8366rb_detect(struct rtl8366_smi *smi)
|
||||
{
|
||||
u32 chip_id = 0;
|
||||
u32 chip_ver = 0;
|
||||
int ret;
|
||||
|
||||
ret = rtl8366_smi_read_reg(smi, RTL8366S_CHIP_ID_REG, &chip_id);
|
||||
if (ret) {
|
||||
dev_err(smi->parent, "unable to read chip id\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (chip_id) {
|
||||
case RTL8366S_CHIP_ID_8366:
|
||||
break;
|
||||
default:
|
||||
dev_err(smi->parent, "unknown chip id (%04x)\n", chip_id);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = rtl8366_smi_read_reg(smi, RTL8366S_CHIP_VERSION_CTRL_REG,
|
||||
&chip_ver);
|
||||
if (ret) {
|
||||
dev_err(smi->parent, "unable to read chip version\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_info(smi->parent, "RTL%04x ver. %u chip found\n",
|
||||
chip_id, chip_ver & RTL8366S_CHIP_VERSION_MASK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rtl8366_smi_ops rtl8366rb_smi_ops = {
|
||||
.detect = rtl8366rb_detect,
|
||||
};
|
||||
|
||||
static int __init rtl8366rb_probe(struct platform_device *pdev)
|
||||
{
|
||||
static int rtl8366_smi_version_printed;
|
||||
@@ -1642,6 +1652,7 @@ static int __init rtl8366rb_probe(struct platform_device *pdev)
|
||||
smi->parent = &pdev->dev;
|
||||
smi->gpio_sda = pdata->gpio_sda;
|
||||
smi->gpio_sck = pdata->gpio_sck;
|
||||
smi->ops = &rtl8366rb_smi_ops;
|
||||
|
||||
err = rtl8366_smi_init(smi);
|
||||
if (err)
|
||||
|
||||
Reference in New Issue
Block a user