static void twl4030_usb_set_mode(struct twl4030_usb *twl, int mode) { unsigned char reg; twl->usb_mode = mode; switch (mode) { case T2_USB_MODE_ULPI: twl4030_usb_clear_bits(twl, ULPI_IFC_CTRL, ULPI_IFC_CTRL_CARKITMODE); twl4030_usb_set_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); twl4030_usb_clear_bits(twl, ULPI_FUNC_CTRL, ULPI_FUNC_CTRL_XCVRSEL_MASK | ULPI_FUNC_CTRL_OPMODE_MASK); //&*&*&*QY_20110706, fix low-speed otg reg = twl4030_usb_read(twl, FUNC_CTRL); printk("[OTG]OTG FUNC_CTRL=0x%x \n",reg); //&*&*&*QY_20110706 break; case -1: /* FIXME: power on defaults */ break; default: dev_err(twl->dev, "unsupported T2 transceiver mode %d\n", mode); break; }; }
int twl4030_set_usb_pullup(bool pullup) { TRACE_ENTRY; if (pullup) { twl4030_usb_clear_bits(OTG_CTRL, DPPULLDOWN); twl4030_usb_set_bits(FUNC_CTRL, TERMSELECT); } else { twl4030_usb_clear_bits(FUNC_CTRL, TERMSELECT); twl4030_usb_set_bits(OTG_CTRL, DPPULLDOWN); } return 0; }
static int twl4030_usb_remove(struct platform_device *pdev) { struct twl4030_usb *twl = platform_get_drvdata(pdev); int val; cancel_delayed_work(&twl->id_workaround_work); device_remove_file(twl->dev, &dev_attr_vbus); /* set transceiver mode to power on defaults */ twl4030_usb_set_mode(twl, -1); /* autogate 60MHz ULPI clock, * clear dpll clock request for i2c access, * disable 32KHz */ val = twl4030_usb_read(twl, PHY_CLK_CTRL); if (val >= 0) { val |= PHY_CLK_CTRL_CLOCKGATING_EN; val &= ~(PHY_CLK_CTRL_CLK32K_EN | REQ_PHY_DPLL_CLK); twl4030_usb_write(twl, PHY_CLK_CTRL, (u8)val); } /* disable complete OTG block */ twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); if (!twl->asleep) twl4030_phy_power(twl, 0); return 0; }
static int __exit twl4030_usb_remove(struct platform_device *pdev) { struct twl4030_usb *twl = platform_get_drvdata(pdev); int val; free_irq(twl->irq, twl); device_remove_file(twl->dev, &dev_attr_vbus); twl4030_usb_set_mode(twl, -1); val = twl4030_usb_read(twl, PHY_CLK_CTRL); if (val >= 0) { val |= PHY_CLK_CTRL_CLOCKGATING_EN; val &= ~(PHY_CLK_CTRL_CLK32K_EN | REQ_PHY_DPLL_CLK); twl4030_usb_write(twl, PHY_CLK_CTRL, (u8)val); } twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); if (!twl->asleep) twl4030_phy_power(twl, 0); regulator_put(twl->usb1v5); regulator_put(twl->usb1v8); regulator_put(twl->usb3v1); kfree(twl->phy.otg); kfree(twl); return 0; }
static void __exit twl4030_usb_exit(void) { struct twl4030_usb *twl = the_transceiver; int val; usb_irq_disable(); free_irq(twl->irq, twl); /* set transceiver mode to power on defaults */ twl4030_usb_set_mode(twl, -1); /* autogate 60MHz ULPI clock, * clear dpll clock request for i2c access, * disable 32KHz */ val = twl4030_usb_read(PHY_CLK_CTRL); if (val >= 0) { val |= PHY_CLK_CTRL_CLOCKGATING_EN; val &= ~(PHY_CLK_CTRL_CLK32K_EN | REQ_PHY_DPLL_CLK); twl4030_usb_write(PHY_CLK_CTRL, (u8)val); } /* disable complete OTG block */ twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); twl4030_phy_power(twl, 0); kfree(twl); }
static void twl4030_usb_set_mode(struct twl4030_usb *twl, int mode) { twl->usb_mode = mode; switch (mode) { case T2_USB_MODE_ULPI: twl4030_usb_clear_bits(twl, IFC_CTRL, IFC_CTRL_CARKITMODE); twl4030_usb_set_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); twl4030_usb_clear_bits(twl, FUNC_CTRL, FUNC_CTRL_XCVRSELECT_MASK | FUNC_CTRL_OPMODE_MASK); break; case -1: /* FIXME: power on defaults */ break; default: dev_err(twl->dev, "unsupported T2 transceiver mode %d\n", mode); break; }; }
static void twl4030_usb_set_mode(struct twl4030_usb *twl, int mode) { twl->usb_mode = mode; switch (mode) { case T2_USB_MODE_ULPI: twl4030_usb_clear_bits(twl, IFC_CTRL, IFC_CTRL_CARKITMODE); twl4030_usb_set_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); twl4030_usb_clear_bits(twl, FUNC_CTRL, FUNC_CTRL_XCVRSELECT_MASK | FUNC_CTRL_OPMODE_MASK); break; /* case T2_USB_MODE_CEA2011_3PIN: twl4030_cea2011_3_pin_FS_setup(twl); break; */ default: /* FIXME: power on defaults */ break; }; }
static int __exit twl4030_usb_remove(struct platform_device *pdev) { struct twl4030_usb *twl = platform_get_drvdata(pdev); int val; free_irq(twl->irq, twl); device_remove_file(twl->dev, &dev_attr_vbus); /* set transceiver mode to power on defaults */ twl4030_usb_set_mode(twl, -1); /* autogate 60MHz ULPI clock, * clear dpll clock request for i2c access, * disable 32KHz */ val = twl4030_usb_read(twl, PHY_CLK_CTRL); if (val >= 0) { val |= PHY_CLK_CTRL_CLOCKGATING_EN; val &= ~(PHY_CLK_CTRL_CLK32K_EN | REQ_PHY_DPLL_CLK); twl4030_usb_write(twl, PHY_CLK_CTRL, (u8)val); } /* disable complete OTG block */ twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); twl4030_phy_power(twl, 0); regulator_put(twl->usb1v5); regulator_put(twl->usb1v8); #if 0 /* LGE_CHANGE [HEAVEN: [email protected]] on 2009-10-14, for <25.12 USB interrupt fix> */ regulator_put(twl->usb3v1); #endif kfree(twl); #if 1 /* mbk_wake mbk_temp */ // LGE_CHANGE wake lock for usb connection wake_lock_destroy(&the_wlock.wake_lock); // LGE_CHANGE wake lock for usb connection #endif return 0; }
static int __exit twl4030_usb_remove(struct platform_device *pdev) { struct twl4030_usb *twl = platform_get_drvdata(pdev); int val; free_irq(twl->irq, twl); device_remove_file(twl->dev, &dev_attr_vbus); /* set transceiver mode to power on defaults */ twl4030_usb_set_mode(twl, -1); /* autogate 60MHz ULPI clock, * clear dpll clock request for i2c access, * disable 32KHz */ val = twl4030_usb_read(twl, PHY_CLK_CTRL); if (val >= 0) { val |= PHY_CLK_CTRL_CLOCKGATING_EN; val &= ~(PHY_CLK_CTRL_CLK32K_EN | REQ_PHY_DPLL_CLK); twl4030_usb_write(twl, PHY_CLK_CTRL, (u8)val); } /* disable complete OTG block */ twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); twl4030_phy_power(twl, 0); regulator_put(twl->usb1v5); regulator_put(twl->usb1v8); regulator_put(twl->usb3v1); wake_lock_destroy(&usb_lock); kfree(twl); return 0; }
static int twl4030_usb_remove(struct platform_device *pdev) { struct twl4030_usb *twl = platform_get_drvdata(pdev); int val; usb_remove_phy(&twl->phy); pm_runtime_get_sync(twl->dev); cancel_delayed_work(&twl->id_workaround_work); device_remove_file(twl->dev, &dev_attr_vbus); /* set transceiver mode to power on defaults */ twl4030_usb_set_mode(twl, -1); /* idle ulpi before powering off */ if (cable_present(twl->linkstat)) pm_runtime_put_noidle(twl->dev); pm_runtime_mark_last_busy(twl->dev); pm_runtime_put_sync_suspend(twl->dev); pm_runtime_disable(twl->dev); /* autogate 60MHz ULPI clock, * clear dpll clock request for i2c access, * disable 32KHz */ val = twl4030_usb_read(twl, PHY_CLK_CTRL); if (val >= 0) { val |= PHY_CLK_CTRL_CLOCKGATING_EN; val &= ~(PHY_CLK_CTRL_CLK32K_EN | REQ_PHY_DPLL_CLK); twl4030_usb_write(twl, PHY_CLK_CTRL, (u8)val); } /* disable complete OTG block */ twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB); return 0; }
int twl4030_usb_reset(void) { TRACE_ENTRY; #if 0 twl4030_usb_clear_bits(OTG_CTRL, DMPULLDOWN | DPPULLDOWN); twl4030_usb_clear_bits(USB_INT_EN_RISE, ~0); twl4030_usb_clear_bits(USB_INT_EN_FALL, ~0); twl4030_usb_clear_bits(MCPC_IO_CTRL, ~TXDTYP); twl4030_usb_set_bits(MCPC_IO_CTRL, TXDTYP); twl4030_usb_clear_bits(OTHER_FUNC_CTRL, (BDIS_ACON_EN | FIVEWIRE_MODE)); twl4030_usb_clear_bits(OTHER_IFC_CTRL, ~0); twl4030_usb_clear_bits(OTHER_INT_EN_RISE, ~0); twl4030_usb_clear_bits(OTHER_INT_EN_FALL, ~0); twl4030_usb_clear_bits(OTHER_IFC_CTRL2, ~0); twl4030_usb_clear_bits(REG_CTRL_EN, ULPI_I2C_CONFLICT_INTEN); twl4030_usb_clear_bits(OTHER_FUNC_CTRL2, VBAT_TIMER_EN); #endif /* Enable writing to power configuration registers */ i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, PROTECT_KEY, 0xC0); i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, PROTECT_KEY, 0x0C); /* put VUSB3V1 LDO in active state */ i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB_DEDICATED2, 0); /* input to VUSB3V1 LDO is from VBAT, not VBUS */ i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB_DEDICATED1, 0x14); /* turn on 3.1V regulator */ i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB3V1_DEV_GRP, 0x20); i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB3V1_TYPE, 0); /* turn on 1.5V regulator */ i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V5_DEV_GRP, 0x20); i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V5_TYPE, 0); /* turn on 1.8V regulator */ i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V8_DEV_GRP, 0x20); i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V8_TYPE, 0); /* disable access to power configuration registers */ i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, PROTECT_KEY, 0); /* turn on the phy */ uint8_t pwr = twl4030_usb_read(PHY_PWR_CTRL); pwr &= ~PHYPWD; twl4030_usb_write(PHY_PWR_CTRL, pwr); twl4030_usb_write(PHY_CLK_CTRL, twl4030_usb_read(PHY_CLK_CTRL) | (CLOCKGATING_EN | CLK32K_EN)); /* set DPLL i2c access mode */ twl4030_i2c_access(true); /* set ulpi mode */ twl4030_usb_clear_bits(IFC_CTRL, CARKITMODE); twl4030_usb_set_bits(POWER_CTRL, OTG_ENAB); twl4030_usb_write(FUNC_CTRL, XCVRSELECT_HS); // set high speed mode // twl4030_usb_write(FUNC_CTRL, XCVRSELECT_FS); // set full speed mode twl4030_i2c_access(false); return 0; }