msm_shared: usb: fix overwriting of command register
- read modify write instead direct write
- moved target specific initialization after usb reset
- added some new registers in header file
Change-Id: I651966e098e55fa5f0e430f26166918d4a901029
diff --git a/platform/msm_shared/hsusb.c b/platform/msm_shared/hsusb.c
index bfceeff..e5bd7b5 100644
--- a/platform/msm_shared/hsusb.c
+++ b/platform/msm_shared/hsusb.c
@@ -666,11 +666,6 @@
hsusb_clock_init();
- /* Do any target specific intialization like GPIO settings,
- * LDO, PHY configuration etc. needed before USB port can be used.
- */
- target_usb_init();
-
/* RESET */
writel(0x00080000, USB_USBCMD);
@@ -681,7 +676,12 @@
/* select ULPI phy */
writel(0x80000000, USB_PORTSC);
- /* USB_OTG_HS_AHB_BURST */
+ /* Do any target specific intialization like GPIO settings,
+ * LDO, PHY configuration etc. needed before USB port can be used.
+ */
+ target_usb_init();
+
+ /* USB_OTG_HS_AHB_BURST */
writel(0x0, USB_SBUSCFG);
/* USB_OTG_HS_AHB_MODE: HPROT_MODE */
@@ -858,6 +858,7 @@
struct udc_descriptor *desc;
unsigned char *data;
unsigned size;
+ uint32_t val;
dprintf(ALWAYS, "udc_start()\n");
@@ -908,7 +909,9 @@
unmask_interrupt(INT_USB_HS);
/* go to RUN mode (D+ pullup enable) */
- writel(0x00080001, USB_USBCMD);
+ val = readl(USB_USBCMD);
+
+ writel(val | 0x00080001, USB_USBCMD);
return 0;
}
diff --git a/platform/msm_shared/hsusb.h b/platform/msm_shared/hsusb.h
index c26748a..f914ec6 100644
--- a/platform/msm_shared/hsusb.h
+++ b/platform/msm_shared/hsusb.h
@@ -44,6 +44,8 @@
#define USB_SBUSCFG (MSM_USB_BASE + 0x0090)
#define USB_AHB_MODE (MSM_USB_BASE + 0x0098)
+#define USB_GENCONFIG_2 (MSM_USB_BASE + 0x00A0)
+
#define USB_CAPLENGTH (MSM_USB_BASE + 0x0100) /* 8 bit */
#define USB_HCIVERSION (MSM_USB_BASE + 0x0102) /* 16 bit */
#define USB_HCSPARAMS (MSM_USB_BASE + 0x0104)
@@ -72,6 +74,11 @@
#define USB_OTG_HS_PHY_CTRL (MSM_USB_BASE + 0x0240)
#define USB_OTG_HS_PHY_SEC_CTRL (MSM_USB_BASE + 0x0278)
+/* ULPI registers */
+#define ULPI_MISC_A_READ 0x96
+#define ULPI_MISC_A_SET 0x97
+#define ULPI_MISC_A_CLEAR 0x98
+
#define USBCMD_RESET 2
#define USBCMD_ATTACH 1
@@ -157,6 +164,11 @@
#define CTRL_RXT_BULK (2 << 2)
#define CTRL_RXT_INT (3 << 2)
+#define GEN2_SESS_VLD_CTRL_EN (1 << 7)
+#define SESS_VLD_CTRL (1 << 25)
+
+
+/* ULPI bit map */
#define ULPI_WAKEUP (1 << 31)
#define ULPI_RUN (1 << 30)
#define ULPI_WRITE (1 << 29)
@@ -166,4 +178,7 @@
#define ULPI_DATA(n) ((n) & 255)
#define ULPI_DATA_READ(n) (((n) >> 8) & 255)
+#define ULPI_MISC_A_VBUSVLDEXTSEL (1 << 1)
+#define ULPI_MISC_A_VBUSVLDEXT (1 << 0)
+
#endif