}
};
-static void tl_wr1043nd_rtl8366rb_hw_reset(bool active)
+static void tl_wr1043nd_rtl8366rb_hw_reset(struct rtl8366_smi *smi, bool active)
{
if (active)
ath79_device_reset_set(AR71XX_RESET_GE0_PHY);
u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
- tl_wr1043nd_rtl8366rb_hw_reset(true);
+ tl_wr1043nd_rtl8366rb_hw_reset(NULL, true);
ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
ath79_eth0_data.mii_bus_dev = &tl_wr1043nd_rtl8366rb_device.dev;
static int rtl8366_reset(struct rtl8366_smi *smi)
{
if (smi->hw_reset) {
- smi->hw_reset(true);
+ smi->hw_reset(smi, true);
msleep(RTL8366_SMI_HW_STOP_DELAY);
- smi->hw_reset(false);
+ smi->hw_reset(smi, false);
msleep(RTL8366_SMI_HW_START_DELAY);
return 0;
}
/* start the switch */
if (smi->hw_reset) {
- smi->hw_reset(false);
+ smi->hw_reset(smi, false);
msleep(RTL8366_SMI_HW_START_DELAY);
}
static void __rtl8366_smi_cleanup(struct rtl8366_smi *smi)
{
if (smi->hw_reset)
- smi->hw_reset(true);
+ smi->hw_reset(smi, true);
gpio_free(smi->gpio_sck);
gpio_free(smi->gpio_sda);
EXPORT_SYMBOL_GPL(rtl8366_smi_cleanup);
#ifdef CONFIG_OF
+static void rtl8366_smi_reset(struct rtl8366_smi *smi, bool active)
+{
+ if (active)
+ reset_control_assert(smi->reset);
+ else
+ reset_control_deassert(smi->reset);
+}
+
int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
{
int sck = of_get_named_gpio(pdev->dev.of_node, "gpio-sck", 0);
smi->gpio_sda = sda;
smi->gpio_sck = sck;
+ smi->reset = devm_reset_control_get(&pdev->dev, "switch");
+ if (!IS_ERR(smi->reset))
+ smi->hw_reset = rtl8366_smi_reset;
return 0;
}
#include <linux/phy.h>
#include <linux/switch.h>
#include <linux/platform_device.h>
+#include <linux/reset.h>
struct rtl8366_smi_ops;
struct rtl8366_vlan_ops;
struct device *parent;
unsigned int gpio_sda;
unsigned int gpio_sck;
- void (*hw_reset)(bool active);
+ void (*hw_reset)(struct rtl8366_smi *smi, bool active);
unsigned int clk_delay; /* ns */
u8 cmd_read;
u8 cmd_write;
int vlan4k_enabled;
char buf[4096];
+
+ struct reset_control *reset;
+
#ifdef CONFIG_RTL8366_SMI_DEBUG_FS
struct dentry *debugfs_root;
u16 dbg_reg;
#define RTL8366S_DRIVER_NAME "rtl8366s"
#define RTL8366RB_DRIVER_NAME "rtl8366rb"
+struct rtl8366_smi;
+
enum rtl8366_type {
RTL8366_TYPE_UNKNOWN,
RTL8366_TYPE_S,
struct rtl8366_platform_data {
unsigned gpio_sda;
unsigned gpio_sck;
- void (*hw_reset)(bool active);
+ void (*hw_reset)(struct rtl8366_smi *smi, bool active);
unsigned num_initvals;
struct rtl8366_initval *initvals;