diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-04-18 16:42:50 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-04-18 16:42:50 +0000 |
commit | 94f7d0f29095e056de281b2159a85e0f4c73d61a (patch) | |
tree | 65c9b8476cee034848cab13e5f73561e6fc35254 /firmware/target/arm/imx31 | |
parent | 689d207bfbfe0cbc3d9cc840748ab9f07cc6a721 (diff) |
UMS for the Gigabeat S. Bootloader USB mode. Has a couple quirks 1) First plug has problems if cold. Replug if it doesn't connect or not at high speed 2) Linux doesn't like the odd bootable flag value used in the partitions so it won't mount but Windows works. Fix minor OTG driver bugs and clean up device memory handling. Generic name for ARC controller driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17154 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31')
-rw-r--r-- | firmware/target/arm/imx31/app.lds | 10 | ||||
-rw-r--r-- | firmware/target/arm/imx31/boot.lds | 8 | ||||
-rw-r--r-- | firmware/target/arm/imx31/crt0.S | 9 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c | 7 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/usb-imx31.c | 39 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/usb-target.h | 3 |
6 files changed, 71 insertions, 5 deletions
diff --git a/firmware/target/arm/imx31/app.lds b/firmware/target/arm/imx31/app.lds index d814a976be..7a7bd550d1 100644 --- a/firmware/target/arm/imx31/app.lds +++ b/firmware/target/arm/imx31/app.lds @@ -23,7 +23,7 @@ INPUT(target/arm/imx31/crt0.o) /* #define IRAMORIG 0x1FFFC000 */ #define IRAMORIG DRAMORIG #define IRAM DRAM -#define IRAMSIZE 0x4000 +#define IRAMSIZE IRAM_SIZE /* End of the audio buffer, where the codec buffer starts */ #define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) @@ -34,6 +34,7 @@ INPUT(target/arm/imx31/crt0.o) MEMORY { DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + DEVBSS : ORIGIN = 0x80100000 + FRAME_SIZE, LENGTH = 0x100000 - FRAME_SIZE - TTB_SIZE } SECTIONS @@ -147,5 +148,12 @@ SECTIONS _pluginbuf = .; pluginbuf = .; } + + .devbss (NOLOAD) : + { + _devbssdata = .; + *(.devbss*) + _devbssend = .; + } > DEVBSS } diff --git a/firmware/target/arm/imx31/boot.lds b/firmware/target/arm/imx31/boot.lds index 84597d5ad1..7110264c1b 100644 --- a/firmware/target/arm/imx31/boot.lds +++ b/firmware/target/arm/imx31/boot.lds @@ -17,6 +17,7 @@ INPUT(target/arm/imx31/crt0.o) MEMORY { DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + DEVBSS : ORIGIN = 0x80100000 + FRAME_SIZE, LENGTH = 0x100000 - FRAME_SIZE - TTB_SIZE } SECTIONS @@ -81,4 +82,11 @@ SECTIONS _vectorsend = .; } AT > DRAM _vectorscopy = LOADADDR(.vectors); + + .devbss (NOLOAD) : + { + _devbssdata = .; + *(.devbss*) + _devbssend = .; + } > DEVBSS } diff --git a/firmware/target/arm/imx31/crt0.S b/firmware/target/arm/imx31/crt0.S index 4e79cd1352..ab8e5199e2 100644 --- a/firmware/target/arm/imx31/crt0.S +++ b/firmware/target/arm/imx31/crt0.S @@ -259,6 +259,15 @@ remap_end: strhi r4, [r2], #4 bhi 1b + /* Initialise the device bss section to zero */ + ldr r2, =_devbssdata + ldr r3, =_devbssend + mov r4, #0 +1: + cmp r3, r2 + strhi r4, [r2], #4 + bhi 1b + /* Set up some stack and munge it with 0xdeadbeef */ ldr sp, =stackend ldr r2, =stackbegin diff --git a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c index d62df92ac5..8f504746c3 100644 --- a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c @@ -27,6 +27,7 @@ #include "power-imx31.h" #include "button-target.h" #include "adc-target.h" +#include "usb-target.h" /* This is all based on communicating with the MC13783 PMU which is on * CSPI2 with the chip select at 0. The LCD controller resides on @@ -67,6 +68,7 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) /* Check initial states for events with a sense bit */ value = mc13783_read(MC13783_INTERRUPT_SENSE0); + usb_set_status(value & MC13783_USB4V4); set_charger_inserted(value & MC13783_CHGDET); value = mc13783_read(MC13783_INTERRUPT_SENSE1); @@ -98,12 +100,15 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) /* Handle interrupts that have a sense bit that needs to * be checked */ - if (pending[0] & MC13783_CHGDET) + if (pending[0] & (MC13783_CHGDET | MC13783_USB4V4)) { value = mc13783_read(MC13783_INTERRUPT_SENSE0); if (pending[0] & MC13783_CHGDET) set_charger_inserted(value & MC13783_CHGDET); + + if (pending[0] & MC13783_USB4V4) + usb_set_status(value & MC13783_USB4V4); } } diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c index 130e884d70..2ef0bc6f6e 100644 --- a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c @@ -22,17 +22,50 @@ #include "kernel.h" #include "ata.h" #include "usb.h" +#include "usb_core.h" +#include "clkctl-imx31.h" +#include "mc13783.h" -inline int usb_detect(void) +static int usb_status = USB_EXTRACTED; + +void usb_set_status(bool plugged) +{ + usb_status = plugged ? USB_INSERTED : USB_EXTRACTED; +} + +int usb_detect(void) +{ + return usb_status; +} + +/* Read the immediate state of the cable from the PMIC */ +bool usb_plugged(void) { - return USB_EXTRACTED; + return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4; } void usb_init_device(void) { + mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_USB4V4); } void usb_enable(bool on) { - (void)on; + if (on) + { + imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL); + GPIO3_DR &= ~(1 << 16); /* Reset ISP1504 */ + GPIO3_DR |= (1 << 16); + GPIO1_DR &= ~(1 << 30); /* Select ISP1504 */ + usb_core_init(); + } + else + { + /* Module clock should be on since this could be called first */ + imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_ON_ALL); + GPIO1_DR &= ~(1 << 30); /* Select ISP1504 */ + usb_core_exit(); + GPIO1_DR |= (1 << 30); /* Deselect ISP1504 */ + imx31_clkctl_module_clock_gating(CG_USBOTG, CGM_OFF); + } } diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-target.h b/firmware/target/arm/imx31/gigabeat-s/usb-target.h index de5bdac52b..8c9dcfc65f 100644 --- a/firmware/target/arm/imx31/gigabeat-s/usb-target.h +++ b/firmware/target/arm/imx31/gigabeat-s/usb-target.h @@ -19,8 +19,11 @@ #ifndef USB_TARGET_H #define USB_TARGET_H +void usb_set_status(bool plugged); bool usb_init_device(void); int usb_detect(void); +/* Read the immediate state of the cable from the PMIC */ +bool usb_plugged(void); void usb_enable(bool on); #endif |