+static int rtl8366s_reset_chip(struct rtl8366s *rtl)
+{
+ struct rtl8366_smi *smi = &rtl->smi;
+ int timeout = 10;
+ u32 data;
+
+ rtl8366_smi_write_reg(smi, RTL8366_RESET_CTRL_REG,
+ RTL8366_CHIP_CTRL_RESET_HW);
+ do {
+ msleep(1);
+ if (rtl8366_smi_read_reg(smi, RTL8366_RESET_CTRL_REG, &data))
+ return -EIO;
+
+ if (!(data & RTL8366_CHIP_CTRL_RESET_HW))
+ break;
+ } while (--timeout);
+
+ if (!timeout) {
+ printk("Timeout waiting for the switch to reset\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+