aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-01-07 19:36:30 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-01-07 19:36:30 +0000
commit87fb92ee03d6d3ceaa403d057a068001d8fecc1d (patch)
tree7bbe73e17a4b4cf0aebffdc71213144438993ac9
parent43196813d775921d16cc238fe805e438a24c529f (diff)
downloadupstream-87fb92ee03d6d3ceaa403d057a068001d8fecc1d.tar.gz
upstream-87fb92ee03d6d3ceaa403d057a068001d8fecc1d.tar.bz2
upstream-87fb92ee03d6d3ceaa403d057a068001d8fecc1d.zip
generic: rtl8366: preparing for RTL8367 support
* make clock delay configurable * make read,write commands configurable * use u16 for member and untag fields SVN-Revision: 29677
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.c7
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366_smi.h13
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366rb.c3
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8366s.c3
4 files changed, 17 insertions, 9 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
index f0a92bcd7f..c3fde0dd10 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
@@ -24,11 +24,10 @@
#include "rtl8366_smi.h"
#define RTL8366_SMI_ACK_RETRY_COUNT 5
-#define RTL8366_SMI_CLK_DELAY 10 /* nsec */
static inline void rtl8366_smi_clk_delay(struct rtl8366_smi *smi)
{
- ndelay(RTL8366_SMI_CLK_DELAY);
+ ndelay(smi->clk_delay);
}
static void rtl8366_smi_start(struct rtl8366_smi *smi)
@@ -198,7 +197,7 @@ int rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data)
rtl8366_smi_start(smi);
/* send READ command */
- ret = rtl8366_smi_write_byte(smi, 0x0a << 4 | 0x04 << 1 | 0x01);
+ ret = rtl8366_smi_write_byte(smi, smi->cmd_read);
if (ret)
goto out;
@@ -239,7 +238,7 @@ int rtl8366_smi_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data)
rtl8366_smi_start(smi);
/* send WRITE command */
- ret = rtl8366_smi_write_byte(smi, 0x0a << 4 | 0x04 << 1 | 0x00);
+ ret = rtl8366_smi_write_byte(smi, smi->cmd_write);
if (ret)
goto out;
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
index 2e84a8d913..9db2576c88 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h
@@ -32,6 +32,9 @@ struct rtl8366_smi {
struct device *parent;
unsigned int gpio_sda;
unsigned int gpio_sck;
+ unsigned int clk_delay; /* ns */
+ u8 cmd_read;
+ u8 cmd_write;
spinlock_t lock;
struct mii_bus *mii_bus;
int mii_irq[PHY_MAX_ADDR];
@@ -58,16 +61,16 @@ struct rtl8366_smi {
struct rtl8366_vlan_mc {
u16 vid;
- u8 priority;
- u8 untag;
- u8 member;
+ u16 untag;
+ u16 member;
u8 fid;
+ u8 priority;
};
struct rtl8366_vlan_4k {
u16 vid;
- u8 untag;
- u8 member;
+ u16 untag;
+ u16 member;
u8 fid;
};
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
index b337408b5a..49dd03e274 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c
@@ -1247,6 +1247,9 @@ static int __devinit rtl8366rb_probe(struct platform_device *pdev)
smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck;
+ smi->clk_delay = 10;
+ smi->cmd_read = 0xa9;
+ smi->cmd_write = 0xa8;
smi->ops = &rtl8366rb_smi_ops;
smi->cpu_port = RTL8366RB_PORT_NUM_CPU;
smi->num_ports = RTL8366RB_NUM_PORTS;
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366s.c b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
index 30916589b3..27e9aa45e4 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8366s.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8366s.c
@@ -1127,6 +1127,9 @@ static int __devinit rtl8366s_probe(struct platform_device *pdev)
smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck;
+ smi->clk_delay = 10;
+ smi->cmd_read = 0xa9;
+ smi->cmd_write = 0xa8;
smi->ops = &rtl8366s_smi_ops;
smi->cpu_port = RTL8366S_PORT_NUM_CPU;
smi->num_ports = RTL8366S_NUM_PORTS;