Skip to contentSkip to conversation

MSM7630: USB Gadget support

PATCH New Srikanth Reddy Vintha 2 participants 2 messages Aug 13, 2012 – Sep 2, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 MSM7630: USB Gadget support

---
 arch/arm/include/asm/arch-msm7630/irqs.h |  162 +++++++++
 drivers/serial/usbtty.h                  |    2 +
 drivers/usb/gadget/Makefile              |    1 +
 drivers/usb/gadget/msm_udc.c             |  540 ++++++++++++++++++++++++++++++
 include/configs/msm7630_surf.h           |   11 +-
 include/usb/msm_udc.h                    |  178 ++++++++++
 6 files changed, 891 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-msm7630/irqs.h
 create mode 100644 drivers/usb/gadget/msm_udc.c
 create mode 100644 include/usb/msm_udc.h
arch/arm/include/asm/arch-msm7630/irqs.h new file +162 -0
new file mode 100644
index 0000000..b0c011f
@@ -0,0 +1,162 @@
+/*
+ * (C) Copyright 2012
+ * Larsen & Toubro Infotech Ltd. <www.lntinfotech.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef __ASM_ARCH_MSM_IRQS_7X30_H
+#define __ASM_ARCH_MSM_IRQS_7X30_H
+
+/* MSM ACPU Interrupt Numbers */
+
+#define INT_DEBUG_TIMER_EXP	0
+#define INT_GPT0_TIMER_EXP	1
+#define INT_GPT1_TIMER_EXP	2
+#define INT_WDT0_ACCSCSSBARK	3
+#define INT_WDT1_ACCSCSSBARK	4
+#define INT_AVS_SVIC		5
+#define INT_AVS_SVIC_SW_DONE	6
+#define INT_SC_DBG_RX_FULL	7
+#define INT_SC_DBG_TX_EMPTY	8
+#define INT_SC_PERF_MON		9
+#define INT_AVS_REQ_DOWN	10
+#define INT_AVS_REQ_UP		11
+#define INT_SC_ACG		12
+/* SCSS_VICFIQSTS1[13:15] are RESERVED */
+#define INT_L2_SVICCPUIRPTREQ	16
+#define INT_L2_SVICDMANSIRPTREQ 17
+#define INT_L2_SVICDMASIRPTREQ  18
+#define INT_L2_SVICSLVIRPTREQ	19
+#define INT_AD5A_MPROC_APPS_0	20
+#define INT_AD5A_MPROC_APPS_1	21
+#define INT_A9_M2A_0		22
+#define INT_A9_M2A_1		23
+#define INT_A9_M2A_2		24
+#define INT_A9_M2A_3		25
+#define INT_A9_M2A_4		26
+#define INT_A9_M2A_5		27
+#define INT_A9_M2A_6		28
+#define INT_A9_M2A_7		29
+#define INT_A9_M2A_8		30
+#define INT_A9_M2A_9		31
+
+#define INT_AXI_EBI1_SC		(32 + 0)
+#define INT_IMEM_ERR		(32 + 1)
+#define INT_AXI_EBI0_SC		(32 + 2)
+#define INT_PBUS_SC_IRQC	(32 + 3)
+#define INT_PERPH_BUS_BPM	(32 + 4)
+#define INT_CC_TEMP_SENSE	(32 + 5)
+#define INT_UXMC_EBI0		(32 + 6)
+#define INT_UXMC_EBI1		(32 + 7)
+#define INT_EBI2_OP_DONE	(32 + 8)
+#define INT_EBI2_WR_ER_DONE	(32 + 9)
+#define INT_TCSR_SPSS_CE	(32 + 10)
+#define INT_EMDH		(32 + 11)
+#define INT_PMDH		(32 + 12)
+#define INT_MDC			(32 + 13)
+#define INT_MIDI_TO_SUPSS	(32 + 14)
+#define INT_LPA_2		(32 + 15)
+#define INT_GPIO_GROUP1_SECURE	(32 + 16)
+#define INT_GPIO_GROUP2_SECURE	(32 + 17)
+#define INT_GPIO_GROUP1		(32 + 18)
+#define INT_GPIO_GROUP2		(32 + 19)
+#define INT_MPRPH_SOFTRESET	(32 + 20)
+#define INT_PWB_I2C		(32 + 21)
+#define INT_PWB_I2C_2		(32 + 22)
+#define INT_TSSC_SAMPLE		(32 + 23)
+#define INT_TSSC_PENUP		(32 + 24)
+#define INT_TCHSCRN_SSBI	(32 + 25)
+#define INT_FM_RDS		(32 + 26)
+#define INT_KEYSENSE		(32 + 27)
+#define INT_USB_OTG_HS		(32 + 28)
+#define INT_USB_OTG_HS2		(32 + 29)
+#define INT_USB_OTG_HS3		(32 + 30)
+#define INT_RESERVED_BIT31	(32 + 31)
+
+#define INT_SPI_OUTPUT		(64 + 0)
+#define INT_SPI_INPUT		(64 + 1)
+#define INT_SPI_ERROR		(64 + 2)
+#define INT_UART1		(64 + 3)
+#define INT_UART1_RX		(64 + 4)
+#define INT_UART2		(64 + 5)
+#define INT_UART2_RX		(64 + 6)
+#define INT_UART3		(64 + 7)
+#define INT_UART3_RX		(64 + 8)
+#define INT_UART1DM_IRQ		(64 + 9)
+#define INT_UART1DM_RX		(64 + 10)
+#define INT_UART2DM_IRQ		(64 + 11)
+#define INT_UART2DM_RX		(64 + 12)
+#define INT_TSIF		(64 + 13)
+#define INT_ADM_SC1		(64 + 14)
+#define INT_ADM_SC2		(64 + 15)
+#define INT_MDP			(64 + 16)
+#define INT_VPE			(64 + 17)
+#define INT_GRP_2D		(64 + 18)
+#define INT_GRP_3D		(64 + 19)
+#define INT_ROTATOR		(64 + 20)
+#define INT_MFC720		(64 + 21)
+#define INT_JPEG		(64 + 22)
+#define INT_VFE			(64 + 23)
+#define INT_TV_ENC		(64 + 24)
+#define INT_PMIC_SSBI		(64 + 25)
+#define INT_MPM_1		(64 + 26)
+#define INT_TCSR_SPSS_SAMPLE	(64 + 27)
+#define INT_TCSR_SPSS_PENUP	(64 + 28)
+#define INT_MPM_2		(64 + 29)
+#define INT_SDC1_0		(64 + 30)
+#define INT_SDC1_1		(64 + 31)
+
+#define INT_SDC3_0		(96 + 0)
+#define INT_SDC3_1		(96 + 1)
+#define INT_SDC2_0		(96 + 2)
+#define INT_SDC2_1		(96 + 3)
+#define INT_SDC4_0		(96 + 4)
+#define INT_SDC4_1		(96 + 5)
+#define INT_PWB_QUP_IN		(96 + 6)
+#define INT_PWB_QUP_OUT		(96 + 7)
+#define INT_PWB_QUP_ERR		(96 + 8)
+/* SCSS_VICFIQSTS3[6:31] are RESERVED */
+
+/* Retrofit universal macro names */
+#define INT_ADM_AARM		INT_ADM_SC2
+#define INT_USB_HS		INT_USB_OTG_HS
+#define INT_USB_OTG		INT_USB_OTG_HS
+#define INT_TCHSCRN1		INT_TSSC_SAMPLE
+#define INT_TCHSCRN2		INT_TSSC_PENUP
+#define INT_GP_TIMER_EXP	INT_GPT0_TIMER_EXP
+#define INT_ADSP_A11		INT_AD5A_MPROC_APPS_0
+#define INT_ADSP_A9_A11		INT_AD5A_MPROC_APPS_1
+#define INT_MDDI_EXT		INT_EMDH
+#define INT_MDDI_PRI		INT_PMDH
+#define INT_MDDI_CLIENT		INT_MDC
+#define INT_NAND_WR_ER_DONE	INT_EBI2_WR_ER_DONE
+#define INT_NAND_OP_DONE	INT_EBI2_OP_DONE
+
+#define NR_MSM_IRQS		128
+#define NR_GPIO_IRQS		182
+#define PMIC8058_IRQ_BASE	(NR_MSM_IRQS + NR_GPIO_IRQS)
+#define NR_PMIC8058_GPIO_IRQS	40
+#define NR_PMIC8058_MPP_IRQS	12
+#define NR_PMIC8058_MISC_IRQS	8
+#define NR_PMIC8058_IRQS	(NR_PMIC8058_GPIO_IRQS +\
+				NR_PMIC8058_MPP_IRQS +\
+				NR_PMIC8058_MISC_IRQS)
+#define NR_BOARD_IRQS		NR_PMIC8058_IRQS
+
+#define NR_IRQS (NR_MSM_IRQS + NR_GPIO_IRQS + NR_BOARD_IRQS)
+
+#endif	/* __ASM_ARCH_MSM_IRQS_7X30_H */
drivers/serial/usbtty.h +2 -0
index e449cd7..8321447 100644
@@ -35,6 +35,8 @@
 #include <usb/pxa27x_udc.h>
 #elif defined(CONFIG_SPEAR3XX) || defined(CONFIG_SPEAR600)
 #include <usb/spr_udc.h>
+#elif defined(CONFIG_MSM_UDC)
+#include <usb/msm_udc.h>
 #endif
 
 #include <version.h>
drivers/usb/gadget/Makefile +1 -0
index 64b091f..44ffa8a 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_OMAP1610) += omap1510_udc.o
 COBJS-$(CONFIG_MPC885_FAMILY) += mpc8xx_udc.o
 COBJS-$(CONFIG_CPU_PXA27X) += pxa27x_udc.o
 COBJS-$(CONFIG_SPEARUDC) += spr_udc.o
+COBJS-$(CONFIG_MSM_UDC) += msm_udc.o
 endif
 endif
 
drivers/usb/gadget/msm_udc.c new file +540 -0

540 lines not on this page · raw message

include/configs/msm7630_surf.h +8 -3
index 5aa6be0..0539748 100644
@@ -36,8 +36,12 @@
 /*
  * Size of malloc() pool
  */
-#define CONFIG_SYS_MALLOC_LEN           (4 * 1024)	/* 4KB  */
-#define CONFIG_MSM7630
+#define CONFIG_SYS_MALLOC_LEN           (4 * 1024)     /* 4KB  */
+
+/* Enable USB */
+#define CONFIG_MSM_UDC
+#define CONFIG_USB_TTY
+#define CONFIG_USB_DEVICE
 
 /*
  * select serial console configuration
@@ -62,8 +66,9 @@
 #undef CONFIG_SYS_MAX_FLASH_SECT
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"console=ttyS0,115200n8\0" \
+	"usbtty=cdc_acm\0"
 
-#define CONFIG_BOOTDELAY        2	/* -1 to disable auto boot */
+#define CONFIG_BOOTDELAY	-1	/* -1 to disable auto boot */
 
 /*
  * Miscellaneous configurable options
include/usb/msm_udc.h new file +178 -0

178 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/5 MSM7630: USB Gadget support

Dear Srikanth Reddy Vintha,

Quoted 12 lines · In message <[email protected]>…
---
 arch/arm/include/asm/arch-msm7630/irqs.h |  162 +++++++++
 drivers/serial/usbtty.h                  |    2 +
 drivers/usb/gadget/Makefile              |    1 +
 drivers/usb/gadget/msm_udc.c             |  540 ++++++++++++++++++++++++++++++
 include/configs/msm7630_surf.h           |   11 +-
 include/usb/msm_udc.h                    |  178 ++++++++++
 6 files changed, 891 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-msm7630/irqs.h
 create mode 100644 drivers/usb/gadget/msm_udc.c
 create mode 100644 include/usb/msm_udc.h

...

drivers/serial/usbtty.h line 40

Quoted 11 lines
drivers/serial/usbtty.h +2 -0
index e449cd7..8321447 100644
@@ -35,6 +35,8 @@
 #include <usb/pxa27x_udc.h>
 #elif defined(CONFIG_SPEAR3XX) || defined(CONFIG_SPEAR600)
 #include <usb/spr_udc.h>
+#elif defined(CONFIG_MSM_UDC)
+#include <usb/msm_udc.h>
 #endif

Please keep list sorted.

drivers/usb/gadget/Makefile COBJS-$(CONFIG_OMAP1610) += omap1510_udc.o · line 47

Quoted 10 lines
drivers/serial/usbtty.h +0 -0
 #include <version.h>
drivers/usb/gadget/Makefile +1 -0
index 64b091f..44ffa8a 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_OMAP1610) += omap1510_udc.o
 COBJS-$(CONFIG_MPC885_FAMILY) += mpc8xx_udc.o
 COBJS-$(CONFIG_CPU_PXA27X) += pxa27x_udc.o
 COBJS-$(CONFIG_SPEARUDC) += spr_udc.o
+COBJS-$(CONFIG_MSM_UDC) += msm_udc.o

Ditto.

...

drivers/usb/gadget/Makefile COBJS-$(CONFIG_OMAP1610) += omap1510_udc.o · line 50

Quoted 3 lines
drivers/usb/gadget/Makefile +3 -0
+#ifdef DEBUG
+/* Debug output must not use stdout as that can cause an infinite loop when
+ * stdout is usbtty */

Incorrect multiline comment style. Please fix globally.

drivers/usb/gadget/Makefile COBJS-$(CONFIG_OMAP1610) += omap1510_udc.o

Quoted 4 lines
drivers/usb/gadget/Makefile +4 -0
+#define udcdbg serial_printf
+#else
+#define udcdbg(fmt, args...)
+#endif

Why cannot you use the generic debug() facilities?

...

Quoted 1 line
drivers/usb/gadget/Makefile +1 -0
+	writel(EPT_RX(0), USB_ENDPTSETUPSTAT);

...

drivers/usb/gadget/Makefile

Quoted 1 line
drivers/usb/gadget/Makefile +1 -0
+			writel(0, USB_ENDPTCTRL(1));

...

This looks very much as if you weren't using I/O accessors correctly.

...

drivers/usb/gadget/Makefile

Quoted 9 lines
drivers/usb/gadget/Makefile +9 -0
+	if ((dQH->next != TERMINATE) && (dQH->next != 0))
+		udcdbg(",dQH busy\n");
+	else {
+		int bit = direction ? EPT_TX(num) : EPT_RX(num);
+		dQH->next = (unsigned) dTD;
+		dQH->info = 0;
+		udcdbg(",bit=%x,dQH=%p\n", bit, dQH);
+		writel(bit, USB_ENDPTPRIME);
+	}

See CodingStyle: if one branch of a conditional statement needs braces, then braces shall be used for both branches. Please fix globally.

drivers/usb/gadget/Makefile

Quoted 4 lines
drivers/usb/gadget/Makefile +4 -0
+void udc_disconnect(void)
+{
+	udcdbg("Disconnect USB\n");
+	writel(0x00080000, USB_USBCMD); /* disable pullup */

Please define nice, readable symbolic constants for such magioc numbers. Please fix globally.

drivers/usb/gadget/Makefile

Quoted 1 line
drivers/usb/gadget/Makefile +1 -0
+	mdelay(10);

Add a comment why this delay is needed, and why it has to be 10 ms.

...

Quoted 25 lines
drivers/usb/gadget/Makefile +25 -0
+#define USB_ID               (MSM_USB_BASE + 0x0000)
+#define USB_HWGENERAL        (MSM_USB_BASE + 0x0004)
+#define USB_HWHOST           (MSM_USB_BASE + 0x0008)
+#define USB_HWDEVICE         (MSM_USB_BASE + 0x000C)
+#define USB_HWTXBUF          (MSM_USB_BASE + 0x0010)
+#define USB_HWRXBUF          (MSM_USB_BASE + 0x0014)
+#define USB_SBUSCFG          (MSM_USB_BASE + 0x0090)
+
+#define USB_AHB_BURST        (MSM_USB_BASE + 0x0090)
+#define USB_AHB_MODE         (MSM_USB_BASE + 0x0098)
+#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)
+#define USB_HCCPARAMS        (MSM_USB_BASE + 0x0108)
+#define USB_DCIVERSION       (MSM_USB_BASE + 0x0120)    /* 16 bit */
+#define USB_USBCMD           (MSM_USB_BASE + 0x0140)
+#define USB_USBSTS           (MSM_USB_BASE + 0x0144)
+#define USB_USBINTR          (MSM_USB_BASE + 0x0148)
+#define USB_FRINDEX          (MSM_USB_BASE + 0x014C)
+#define USB_DEVICEADDR       (MSM_USB_BASE + 0x0154)
+#define USB_ENDPOINTLISTADDR (MSM_USB_BASE + 0x0158)
+#define USB_BURSTSIZE        (MSM_USB_BASE + 0x0160)
+#define USB_TXFILLTUNING     (MSM_USB_BASE + 0x0164)
+#define USB_ULPI_VIEWPORT    (MSM_USB_BASE + 0x0170)
+#define USB_ENDPTNAK         (MSM_USB_BASE + 0x0178)

drivers/usb/gadget/Makefile

Quoted 10 lines
drivers/usb/gadget/Makefile +10 -0
+#define USB_ENDPTNAKEN       (MSM_USB_BASE + 0x017C)
+#define USB_PORTSC           (MSM_USB_BASE + 0x0184)
+#define USB_OTGSC            (MSM_USB_BASE + 0x01A4)
+#define USB_USBMODE          (MSM_USB_BASE + 0x01A8)
+#define USB_ENDPTSETUPSTAT   (MSM_USB_BASE + 0x01AC)
+#define USB_ENDPTPRIME       (MSM_USB_BASE + 0x01B0)
+#define USB_ENDPTFLUSH       (MSM_USB_BASE + 0x01B4)
+#define USB_ENDPTSTAT        (MSM_USB_BASE + 0x01B8)
+#define USB_ENDPTCOMPLETE    (MSM_USB_BASE + 0x01BC)
+#define USB_ENDPTCTRL(n)     (MSM_USB_BASE + 0x01C0 + (4 * (n)))

I expected this to be coming. We don;t allow access to device registers through base address plus offset notations. Please define C structs to describe your peripherals, and uses porper I/O accessors with these.

Please fix globally.

I stop my review here. There are too many global changes needed; please fix these, then resubmit.

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Keep your eyes wide open before marriage, half shut afterwards.
                                                 -- Benjamin Franklin