+static int robo_switch_enable(void)
+{
+ unsigned int i, last_port;
+ u16 val;
+
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
+ if (!(val & (1 << 1))) {
+ /* Unmanaged mode */
+ val &= ~(1 << 0);
+ /* With forwarding */
+ val |= (1 << 1);
+ robo_write16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE, val);
+ val = robo_read16(ROBO_CTRL_PAGE, ROBO_SWITCH_MODE);
+ if (!(val & (1 << 1))) {
+ printk("Failed to enable switch\n");
+ return -EBUSY;
+ }
+
+ last_port = (robo.devid == ROBO_DEVICE_ID_5398) ?
+ ROBO_PORT6_CTRL : ROBO_PORT3_CTRL;
+ for (i = ROBO_PORT0_CTRL; i < last_port + 1; i++)
+ robo_write16(ROBO_CTRL_PAGE, i, 0);
+ }