1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-25 10:15:11 +02:00

generic: rtl836x: add hw_reset field to struct rtl8366_smi

It will be used to start/stop the switch if that is
supported by the given board.

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32943 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2012-08-02 09:54:21 +00:00
parent 7f000ed40c
commit 08700f9817
7 changed files with 35 additions and 2 deletions

View File

@ -308,6 +308,19 @@ int rtl8366_smi_rmwr(struct rtl8366_smi *smi, u32 addr, u32 mask, u32 data)
} }
EXPORT_SYMBOL_GPL(rtl8366_smi_rmwr); EXPORT_SYMBOL_GPL(rtl8366_smi_rmwr);
static int rtl8366_reset(struct rtl8366_smi *smi)
{
if (smi->hw_reset) {
smi->hw_reset(true);
msleep(25);
smi->hw_reset(false);
msleep(25);
return 0;
}
return smi->ops->reset_chip(smi);
}
static int rtl8366_mc_is_used(struct rtl8366_smi *smi, int mc_index, int *used) static int rtl8366_mc_is_used(struct rtl8366_smi *smi, int mc_index, int *used)
{ {
int err; int err;
@ -938,7 +951,7 @@ int rtl8366_sw_reset_switch(struct switch_dev *dev)
struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev); struct rtl8366_smi *smi = sw_to_rtl8366_smi(dev);
int err; int err;
err = smi->ops->reset_chip(smi); err = rtl8366_reset(smi);
if (err) if (err)
return err; return err;
@ -1227,6 +1240,13 @@ static int __rtl8366_smi_init(struct rtl8366_smi *smi, const char *name)
} }
spin_lock_init(&smi->lock); spin_lock_init(&smi->lock);
/* start the switch */
if (smi->hw_reset) {
smi->hw_reset(false);
msleep(25);
}
return 0; return 0;
err_free_sda: err_free_sda:
@ -1237,6 +1257,9 @@ static int __rtl8366_smi_init(struct rtl8366_smi *smi, const char *name)
static void __rtl8366_smi_cleanup(struct rtl8366_smi *smi) static void __rtl8366_smi_cleanup(struct rtl8366_smi *smi)
{ {
if (smi->hw_reset)
smi->hw_reset(true);
gpio_free(smi->gpio_sck); gpio_free(smi->gpio_sck);
gpio_free(smi->gpio_sda); gpio_free(smi->gpio_sda);
} }
@ -1300,7 +1323,7 @@ int rtl8366_smi_init(struct rtl8366_smi *smi)
goto err_free_sck; goto err_free_sck;
} }
err = smi->ops->reset_chip(smi); err = rtl8366_reset(smi);
if (err) if (err)
goto err_free_sck; goto err_free_sck;

View File

@ -32,6 +32,7 @@ struct rtl8366_smi {
struct device *parent; struct device *parent;
unsigned int gpio_sda; unsigned int gpio_sda;
unsigned int gpio_sck; unsigned int gpio_sck;
void (*hw_reset)(bool active);
unsigned int clk_delay; /* ns */ unsigned int clk_delay; /* ns */
u8 cmd_read; u8 cmd_read;
u8 cmd_write; u8 cmd_write;

View File

@ -1194,6 +1194,8 @@ static int __devinit rtl8366rb_probe(struct platform_device *pdev)
smi->gpio_sda = pdata->gpio_sda; smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck; smi->gpio_sck = pdata->gpio_sck;
smi->hw_reset = pdata->hw_reset;
smi->clk_delay = 10; smi->clk_delay = 10;
smi->cmd_read = 0xa9; smi->cmd_read = 0xa9;
smi->cmd_write = 0xa8; smi->cmd_write = 0xa8;

View File

@ -1074,6 +1074,8 @@ static int __devinit rtl8366s_probe(struct platform_device *pdev)
smi->gpio_sda = pdata->gpio_sda; smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck; smi->gpio_sck = pdata->gpio_sck;
smi->hw_reset = pdata->hw_reset;
smi->clk_delay = 10; smi->clk_delay = 10;
smi->cmd_read = 0xa9; smi->cmd_read = 0xa9;
smi->cmd_write = 0xa8; smi->cmd_write = 0xa8;

View File

@ -1692,6 +1692,8 @@ static int __devinit rtl8367_probe(struct platform_device *pdev)
smi->gpio_sda = pdata->gpio_sda; smi->gpio_sda = pdata->gpio_sda;
smi->gpio_sck = pdata->gpio_sck; smi->gpio_sck = pdata->gpio_sck;
smi->hw_reset = pdata->hw_reset;
smi->clk_delay = 1500; smi->clk_delay = 1500;
smi->cmd_read = 0xb9; smi->cmd_read = 0xb9;
smi->cmd_write = 0xb8; smi->cmd_write = 0xb8;

View File

@ -29,6 +29,8 @@ struct rtl8366_initval {
struct rtl8366_platform_data { struct rtl8366_platform_data {
unsigned gpio_sda; unsigned gpio_sda;
unsigned gpio_sck; unsigned gpio_sck;
void (*hw_reset)(bool active);
unsigned num_initvals; unsigned num_initvals;
struct rtl8366_initval *initvals; struct rtl8366_initval *initvals;
}; };

View File

@ -50,6 +50,7 @@ struct rtl8367_extif_config {
struct rtl8367_platform_data { struct rtl8367_platform_data {
unsigned gpio_sda; unsigned gpio_sda;
unsigned gpio_sck; unsigned gpio_sck;
void (*hw_reset)(bool active);
struct rtl8367_extif_config *extif0_cfg; struct rtl8367_extif_config *extif0_cfg;
struct rtl8367_extif_config *extif1_cfg; struct rtl8367_extif_config *extif1_cfg;