From 3a6d4791d70fc9f4adad7a0cbc1b808b7c942652 Mon Sep 17 00:00:00 2001 From: Barry Wardell Date: Fri, 16 Feb 2007 22:13:21 +0000 Subject: No functional changes, just reorganising code: 1) Move ARC OTG USB (used in PP502x) driver code into it's own file, drivers/arcotg_udc.c. Hopefully in the future we will be able to adapt more of the Linux driver and add it to this file. 2) Rename mx31.h to arcotg_udc.h to reflect the file the code came from. It's also a more accurate name for the USB controller. 3) Get rid of one more inl()/outl() in usb-pp.c and use the relevant #define instead. 4) Add dr_controller_stop(). Not used yet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12340 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/usb-pp.c | 103 +++++++------------------------------------ 1 file changed, 16 insertions(+), 87 deletions(-) (limited to 'firmware/target/arm/usb-pp.c') diff --git a/firmware/target/arm/usb-pp.c b/firmware/target/arm/usb-pp.c index 983457b924..042fb5bda5 100644 --- a/firmware/target/arm/usb-pp.c +++ b/firmware/target/arm/usb-pp.c @@ -40,7 +40,7 @@ #include "hwcompat.h" #include "usb-target.h" -#include "mx31.h" +#include "arcotg_udc.h" void usb_init_device(void) { @@ -56,30 +56,30 @@ void usb_init_device(void) DEV_INIT |= INIT_USB; while ((inl(0x70000028) & 0x80) == 0); - UOG_PORTSC1 |= PORTSCX_PORT_RESET; - while ((UOG_PORTSC1 & PORTSCX_PORT_RESET) != 0); + UDC_PORTSC1 |= PORTSCX_PORT_RESET; + while ((UDC_PORTSC1 & PORTSCX_PORT_RESET) != 0); - UOG_OTGSC |= 0x5F000000; - if( (UOG_OTGSC & 0x100) == 0) { - UOG_USBMODE &=~ USB_MODE_CTRL_MODE_HOST; - UOG_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; + UDC_OTGSC |= 0x5F000000; + if( (UDC_OTGSC & 0x100) == 0) { + UDC_USBMODE &=~ USB_MODE_CTRL_MODE_HOST; + UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; outl(inl(0x70000028) | 0x4000, 0x70000028); outl(inl(0x70000028) | 0x2, 0x70000028); } else { - UOG_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; + UDC_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; outl(inl(0x70000028) &~0x4000, 0x70000028); outl(inl(0x70000028) | 0x2, 0x70000028); } - UOG_USBCMD |= USB_CMD_CTRL_RESET; - while((UOG_USBCMD & USB_CMD_CTRL_RESET) != 0); + UDC_USBCMD |= USB_CMD_CTRL_RESET; + while((UDC_USBCMD & USB_CMD_CTRL_RESET) != 0); - r0 = UOG_PORTSC1; + r0 = UDC_PORTSC1; /* Note from IPL source (referring to next 5 lines of code: THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */ - outl(inl(0x70000020) | 0x80000000, 0x70000020); + DEV_INIT |= INIT_USB; DEV_EN |= DEV_USB; while ((inl(0x70000028) & 0x80) == 0); outl(inl(0x70000028) | 0x2, 0x70000028); @@ -120,100 +120,29 @@ void usb_enable(bool on) } } -/*------------------------------------------------------------------ - Internal Hardware related function - ------------------------------------------------------------------*/ - -/* @qh_addr is the aligned virt addr of ep QH addr - * it is used to set endpointlistaddr Reg */ -static int dr_controller_setup(void/* *qh_addr, struct device *dev*/) -{ - int timeout = 0; -/* struct arc_usb_config *config; - - config = udc_controller->config; -*/ - /* before here, make sure usb_slave_regs has been initialized */ -/* if (!qh_addr) - return -EINVAL; -*/ - /* Stop and reset the usb controller */ - UOG_USBCMD &= ~USB_CMD_RUN_STOP; - - UOG_USBCMD |= USB_CMD_CTRL_RESET; - - /* Wait for reset to complete */ - timeout = 10000000; - while ((UOG_USBCMD & USB_CMD_CTRL_RESET) && - --timeout) { - continue; - } - if (timeout == 0) { - //logf("%s: TIMEOUT", __FUNCTION__); - return 1; - } - - /* Set the controller as device mode and disable setup lockout */ - UOG_USBMODE |= (USB_MODE_CTRL_MODE_DEVICE | USB_MODE_SETUP_LOCK_OFF); - - /* Clear the setup status */ - UOG_USBSTS = 0; - -/* tmp = virt_to_phys(qh_addr); - tmp &= USB_EP_LIST_ADDRESS_MASK; - usb_slave_regs->endpointlistaddr = cpu_to_le32(tmp); -*/ - UOG_PORTSC1 = (UOG_PORTSC1 & ~PORTSCX_PHY_TYPE_SEL) | PORTSCX_PTS_UTMI; - -/* if (config->set_vbus_power) - config->set_vbus_power(0); -*/ - return 0; -} - -/* just Enable DR irq reg and Set Dr controller Run */ -static void dr_controller_run(void/*struct arcotg_udc *udc*/) -{ - /*Enable DR irq reg */ - UOG_USBINTR = USB_INTR_INT_EN | USB_INTR_ERR_INT_EN | - USB_INTR_PTC_DETECT_EN | USB_INTR_RESET_EN | - USB_INTR_DEVICE_SUSPEND | USB_INTR_SYS_ERR_EN; - - /* Clear stopped bit */ - /*udc->stopped = 0;*/ - - /* Set the controller as device mode */ - UOG_USBMODE |= USB_MODE_CTRL_MODE_DEVICE; - - /* Set controller to Run */ - UOG_USBCMD |= USB_CMD_RUN_STOP; - - return; -} - bool usb_detect(void) { static bool prev_usbstatus1 = false; bool usbstatus1,usbstatus2; - /* UOG_ID should have the bit format: + /* UDC_ID should have the bit format: [31:24] = 0x0 [23:16] = 0x22 (Revision number) [15:14] = 0x3 (Reserved) [13:8] = 0x3a (NID - 1's compliment of ID) [7:6] = 0x0 (Reserved) [5:0] = 0x05 (ID) */ - if (UOG_ID != 0x22FA05) { + if (UDC_ID != 0x22FA05) { return false; } - usbstatus1 = (UOG_OTGSC & 0x800) ? true : false; + usbstatus1 = (UDC_OTGSC & 0x800) ? true : false; if ((usbstatus1 == true) && (prev_usbstatus1 == false)) { dr_controller_setup(); dr_controller_run(); } prev_usbstatus1 = usbstatus1; - usbstatus2 = (UOG_PORTSC1 & PORTSCX_CURRENT_CONNECT_STATUS) ? true : false; + usbstatus2 = (UDC_PORTSC1 & PORTSCX_CURRENT_CONNECT_STATUS) ? true : false; if (usbstatus1 && usbstatus2) { return true; -- cgit v1.2.3