diff options
Diffstat (limited to 'drivers/usb/otg')
-rw-r--r-- | drivers/usb/otg/isp1301_omap.c | 2 | ||||
-rw-r--r-- | drivers/usb/otg/twl4030-usb.c | 108 | ||||
-rw-r--r-- | drivers/usb/otg/ulpi.c | 50 |
3 files changed, 23 insertions, 137 deletions
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c index 78a20970926..45696949241 100644 --- a/drivers/usb/otg/isp1301_omap.c +++ b/drivers/usb/otg/isp1301_omap.c @@ -1654,7 +1654,7 @@ static int __init isp_init(void) { return i2c_add_driver(&isp1301_driver); } -module_init(isp_init); +subsys_initcall(isp_init); static void __exit isp_exit(void) { diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index 223cdf46ccb..0e8888588d4 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c @@ -33,6 +33,7 @@ #include <linux/io.h> #include <linux/delay.h> #include <linux/usb/otg.h> +#include <linux/usb/ulpi.h> #include <linux/i2c/twl.h> #include <linux/regulator/consumer.h> #include <linux/err.h> @@ -41,81 +42,7 @@ /* Register defines */ -#define VENDOR_ID_LO 0x00 -#define VENDOR_ID_HI 0x01 -#define PRODUCT_ID_LO 0x02 -#define PRODUCT_ID_HI 0x03 - -#define FUNC_CTRL 0x04 -#define FUNC_CTRL_SET 0x05 -#define FUNC_CTRL_CLR 0x06 -#define FUNC_CTRL_SUSPENDM (1 << 6) -#define FUNC_CTRL_RESET (1 << 5) -#define FUNC_CTRL_OPMODE_MASK (3 << 3) /* bits 3 and 4 */ -#define FUNC_CTRL_OPMODE_NORMAL (0 << 3) -#define FUNC_CTRL_OPMODE_NONDRIVING (1 << 3) -#define FUNC_CTRL_OPMODE_DISABLE_BIT_NRZI (2 << 3) -#define FUNC_CTRL_TERMSELECT (1 << 2) -#define FUNC_CTRL_XCVRSELECT_MASK (3 << 0) /* bits 0 and 1 */ -#define FUNC_CTRL_XCVRSELECT_HS (0 << 0) -#define FUNC_CTRL_XCVRSELECT_FS (1 << 0) -#define FUNC_CTRL_XCVRSELECT_LS (2 << 0) -#define FUNC_CTRL_XCVRSELECT_FS4LS (3 << 0) - -#define IFC_CTRL 0x07 -#define IFC_CTRL_SET 0x08 -#define IFC_CTRL_CLR 0x09 -#define IFC_CTRL_INTERFACE_PROTECT_DISABLE (1 << 7) -#define IFC_CTRL_AUTORESUME (1 << 4) -#define IFC_CTRL_CLOCKSUSPENDM (1 << 3) -#define IFC_CTRL_CARKITMODE (1 << 2) -#define IFC_CTRL_FSLSSERIALMODE_3PIN (1 << 1) - -#define TWL4030_OTG_CTRL 0x0A -#define TWL4030_OTG_CTRL_SET 0x0B -#define TWL4030_OTG_CTRL_CLR 0x0C -#define TWL4030_OTG_CTRL_DRVVBUS (1 << 5) -#define TWL4030_OTG_CTRL_CHRGVBUS (1 << 4) -#define TWL4030_OTG_CTRL_DISCHRGVBUS (1 << 3) -#define TWL4030_OTG_CTRL_DMPULLDOWN (1 << 2) -#define TWL4030_OTG_CTRL_DPPULLDOWN (1 << 1) -#define TWL4030_OTG_CTRL_IDPULLUP (1 << 0) - -#define USB_INT_EN_RISE 0x0D -#define USB_INT_EN_RISE_SET 0x0E -#define USB_INT_EN_RISE_CLR 0x0F -#define USB_INT_EN_FALL 0x10 -#define USB_INT_EN_FALL_SET 0x11 -#define USB_INT_EN_FALL_CLR 0x12 -#define USB_INT_STS 0x13 -#define USB_INT_LATCH 0x14 -#define USB_INT_IDGND (1 << 4) -#define USB_INT_SESSEND (1 << 3) -#define USB_INT_SESSVALID (1 << 2) -#define USB_INT_VBUSVALID (1 << 1) -#define USB_INT_HOSTDISCONNECT (1 << 0) - -#define CARKIT_CTRL 0x19 -#define CARKIT_CTRL_SET 0x1A -#define CARKIT_CTRL_CLR 0x1B -#define CARKIT_CTRL_MICEN (1 << 6) -#define CARKIT_CTRL_SPKRIGHTEN (1 << 5) -#define CARKIT_CTRL_SPKLEFTEN (1 << 4) -#define CARKIT_CTRL_RXDEN (1 << 3) -#define CARKIT_CTRL_TXDEN (1 << 2) -#define CARKIT_CTRL_IDGNDDRV (1 << 1) -#define CARKIT_CTRL_CARKITPWR (1 << 0) -#define CARKIT_PLS_CTRL 0x22 -#define CARKIT_PLS_CTRL_SET 0x23 -#define CARKIT_PLS_CTRL_CLR 0x24 -#define CARKIT_PLS_CTRL_SPKRRIGHT_BIASEN (1 << 3) -#define CARKIT_PLS_CTRL_SPKRLEFT_BIASEN (1 << 2) -#define CARKIT_PLS_CTRL_RXPLSEN (1 << 1) -#define CARKIT_PLS_CTRL_TXPLSEN (1 << 0) - #define MCPC_CTRL 0x30 -#define MCPC_CTRL_SET 0x31 -#define MCPC_CTRL_CLR 0x32 #define MCPC_CTRL_RTSOL (1 << 7) #define MCPC_CTRL_EXTSWR (1 << 6) #define MCPC_CTRL_EXTSWC (1 << 5) @@ -125,8 +52,6 @@ #define MCPC_CTRL_HS_UART (1 << 0) #define MCPC_IO_CTRL 0x33 -#define MCPC_IO_CTRL_SET 0x34 -#define MCPC_IO_CTRL_CLR 0x35 #define MCPC_IO_CTRL_MICBIASEN (1 << 5) #define MCPC_IO_CTRL_CTS_NPU (1 << 4) #define MCPC_IO_CTRL_RXD_PU (1 << 3) @@ -135,19 +60,13 @@ #define MCPC_IO_CTRL_RTSTYP (1 << 0) #define MCPC_CTRL2 0x36 -#define MCPC_CTRL2_SET 0x37 -#define MCPC_CTRL2_CLR 0x38 #define MCPC_CTRL2_MCPC_CK_EN (1 << 0) #define OTHER_FUNC_CTRL 0x80 -#define OTHER_FUNC_CTRL_SET 0x81 -#define OTHER_FUNC_CTRL_CLR 0x82 #define OTHER_FUNC_CTRL_BDIS_ACON_EN (1 << 4) #define OTHER_FUNC_CTRL_FIVEWIRE_MODE (1 << 2) #define OTHER_IFC_CTRL 0x83 -#define OTHER_IFC_CTRL_SET 0x84 -#define OTHER_IFC_CTRL_CLR 0x85 #define OTHER_IFC_CTRL_OE_INT_EN (1 << 6) #define OTHER_IFC_CTRL_CEA2011_MODE (1 << 5) #define OTHER_IFC_CTRL_FSLSSERIALMODE_4PIN (1 << 4) @@ -156,11 +75,7 @@ #define OTHER_IFC_CTRL_ALT_INT_REROUTE (1 << 0) #define OTHER_INT_EN_RISE 0x86 -#define OTHER_INT_EN_RISE_SET 0x87 -#define OTHER_INT_EN_RISE_CLR 0x88 #define OTHER_INT_EN_FALL 0x89 -#define OTHER_INT_EN_FALL_SET 0x8A -#define OTHER_INT_EN_FALL_CLR 0x8B #define OTHER_INT_STS 0x8C #define OTHER_INT_LATCH 0x8D #define OTHER_INT_VB_SESS_VLD (1 << 7) @@ -178,13 +93,9 @@ #define ID_RES_GND (1 << 0) #define POWER_CTRL 0xAC -#define POWER_CTRL_SET 0xAD -#define POWER_CTRL_CLR 0xAE #define POWER_CTRL_OTG_ENAB (1 << 5) #define OTHER_IFC_CTRL2 0xAF -#define OTHER_IFC_CTRL2_SET 0xB0 -#define OTHER_IFC_CTRL2_CLR 0xB1 #define OTHER_IFC_CTRL2_ULPI_STP_LOW (1 << 4) #define OTHER_IFC_CTRL2_ULPI_TXEN_POL (1 << 3) #define OTHER_IFC_CTRL2_ULPI_4PIN_2430 (1 << 2) @@ -193,14 +104,10 @@ #define OTHER_IFC_CTRL2_USB_INT_OUTSEL_INT2N (1 << 0) #define REG_CTRL_EN 0xB2 -#define REG_CTRL_EN_SET 0xB3 -#define REG_CTRL_EN_CLR 0xB4 #define REG_CTRL_ERROR 0xB5 #define ULPI_I2C_CONFLICT_INTEN (1 << 0) #define OTHER_FUNC_CTRL2 0xB8 -#define OTHER_FUNC_CTRL2_SET 0xB9 -#define OTHER_FUNC_CTRL2_CLR 0xBA #define OTHER_FUNC_CTRL2_VBAT_TIMER_EN (1 << 0) /* following registers do not have separate _clr and _set registers */ @@ -328,13 +235,13 @@ static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address) static inline int twl4030_usb_set_bits(struct twl4030_usb *twl, u8 reg, u8 bits) { - return twl4030_usb_write(twl, reg + 1, bits); + return twl4030_usb_write(twl, ULPI_SET(reg), bits); } static inline int twl4030_usb_clear_bits(struct twl4030_usb *twl, u8 reg, u8 bits) { - return twl4030_usb_write(twl, reg + 2, bits); + return twl4030_usb_write(twl, ULPI_CLR(reg), bits); } /*-------------------------------------------------------------------------*/ @@ -393,11 +300,12 @@ static void twl4030_usb_set_mode(struct twl4030_usb *twl, int mode) switch (mode) { case T2_USB_MODE_ULPI: - twl4030_usb_clear_bits(twl, IFC_CTRL, IFC_CTRL_CARKITMODE); + 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, FUNC_CTRL, - FUNC_CTRL_XCVRSELECT_MASK | - FUNC_CTRL_OPMODE_MASK); + twl4030_usb_clear_bits(twl, ULPI_FUNC_CTRL, + ULPI_FUNC_CTRL_XCVRSEL_MASK | + ULPI_FUNC_CTRL_OPMODE_MASK); break; case -1: /* FIXME: power on defaults */ diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c index 9010225e0d0..b1b34693294 100644 --- a/drivers/usb/otg/ulpi.c +++ b/drivers/usb/otg/ulpi.c @@ -29,28 +29,6 @@ #include <linux/usb/otg.h> #include <linux/usb/ulpi.h> -/* ULPI register addresses */ -#define ULPI_VID_LOW 0x00 /* Vendor ID low */ -#define ULPI_VID_HIGH 0x01 /* Vendor ID high */ -#define ULPI_PID_LOW 0x02 /* Product ID low */ -#define ULPI_PID_HIGH 0x03 /* Product ID high */ -#define ULPI_ITFCTL 0x07 /* Interface Control */ -#define ULPI_OTGCTL 0x0A /* OTG Control */ - -/* add to above register address to access Set/Clear functions */ -#define ULPI_REG_SET 0x01 -#define ULPI_REG_CLEAR 0x02 - -/* ULPI OTG Control Register bits */ -#define ID_PULL_UP (1 << 0) /* enable ID Pull Up */ -#define DP_PULL_DOWN (1 << 1) /* enable DP Pull Down */ -#define DM_PULL_DOWN (1 << 2) /* enable DM Pull Down */ -#define DISCHRG_VBUS (1 << 3) /* Discharge Vbus */ -#define CHRG_VBUS (1 << 4) /* Charge Vbus */ -#define DRV_VBUS (1 << 5) /* Drive Vbus */ -#define DRV_VBUS_EXT (1 << 6) /* Drive Vbus external */ -#define USE_EXT_VBUS_IND (1 << 7) /* Use ext. Vbus indicator */ - #define ULPI_ID(vendor, product) (((vendor) << 16) | (product)) #define TR_FLAG(flags, a, b) (((flags) & a) ? b : 0) @@ -65,28 +43,28 @@ static int ulpi_set_flags(struct otg_transceiver *otg) unsigned int flags = 0; if (otg->flags & USB_OTG_PULLUP_ID) - flags |= ID_PULL_UP; + flags |= ULPI_OTG_CTRL_ID_PULLUP; if (otg->flags & USB_OTG_PULLDOWN_DM) - flags |= DM_PULL_DOWN; + flags |= ULPI_OTG_CTRL_DM_PULLDOWN; if (otg->flags & USB_OTG_PULLDOWN_DP) - flags |= DP_PULL_DOWN; + flags |= ULPI_OTG_CTRL_DP_PULLDOWN; if (otg->flags & USB_OTG_EXT_VBUS_INDICATOR) - flags |= USE_EXT_VBUS_IND; + flags |= ULPI_OTG_CTRL_EXTVBUSIND; - return otg_io_write(otg, flags, ULPI_OTGCTL + ULPI_REG_SET); + return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL)); } static int ulpi_init(struct otg_transceiver *otg) { int i, vid, pid; - vid = (otg_io_read(otg, ULPI_VID_HIGH) << 8) | - otg_io_read(otg, ULPI_VID_LOW); - pid = (otg_io_read(otg, ULPI_PID_HIGH) << 8) | - otg_io_read(otg, ULPI_PID_LOW); + vid = (otg_io_read(otg, ULPI_VENDOR_ID_HIGH) << 8) | + otg_io_read(otg, ULPI_VENDOR_ID_LOW); + pid = (otg_io_read(otg, ULPI_PRODUCT_ID_HIGH) << 8) | + otg_io_read(otg, ULPI_PRODUCT_ID_LOW); pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid); @@ -100,19 +78,19 @@ static int ulpi_init(struct otg_transceiver *otg) static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) { - unsigned int flags = otg_io_read(otg, ULPI_OTGCTL); + unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL); - flags &= ~(DRV_VBUS | DRV_VBUS_EXT); + flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); if (on) { if (otg->flags & USB_OTG_DRV_VBUS) - flags |= DRV_VBUS; + flags |= ULPI_OTG_CTRL_DRVVBUS; if (otg->flags & USB_OTG_DRV_VBUS_EXT) - flags |= DRV_VBUS_EXT; + flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; } - return otg_io_write(otg, flags, ULPI_OTGCTL + ULPI_REG_SET); + return otg_io_write(otg, flags, ULPI_SET(ULPI_OTG_CTRL)); } struct otg_transceiver * |