diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-11-21 12:50:06 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-11-21 12:50:06 +0000 |
commit | c0b43a5ac2fcda473800b9c9a4036c5348ac5084 (patch) | |
tree | 0fdf827d5f65e26da35341c4a67a006e36ca5dc2 | |
parent | 0a61b71f73556592af6e1f127a42a27d48564b72 (diff) | |
download | rockbox-c0b43a5ac2fcda473800b9c9a4036c5348ac5084.tar.gz rockbox-c0b43a5ac2fcda473800b9c9a4036c5348ac5084.zip |
Commit some USB and ATA rework/refactoring (+ USB GPIO detection).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19165 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/export/config-ondavx747.h | 6 | ||||
-rw-r--r-- | firmware/export/jz4740.h | 18 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/ata-jz4740.c | 6 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | 44 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx747/ata-sd-target.h (renamed from firmware/target/mips/ingenic_jz47xx/ata-sd-target.h) | 22 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c | 3 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h (renamed from firmware/target/mips/ingenic_jz47xx/usb-target.h) | 25 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/ata-sd-target.h | 55 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h | 48 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/usb-jz4740.c | 49 | ||||
-rw-r--r-- | firmware/usb.c | 3 |
11 files changed, 219 insertions, 60 deletions
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h index 3d7628fa8f..e92e5a9829 100644 --- a/firmware/export/config-ondavx747.h +++ b/firmware/export/config-ondavx747.h | |||
@@ -33,8 +33,8 @@ | |||
33 | /* For Rolo and boot loader */ | 33 | /* For Rolo and boot loader */ |
34 | #define MODEL_NUMBER 35 | 34 | #define MODEL_NUMBER 35 |
35 | 35 | ||
36 | #define HAVE_ATA_SD | 36 | //#define HAVE_ATA_SD |
37 | #define HAVE_HOTSWAP | 37 | //#define HAVE_HOTSWAP |
38 | 38 | ||
39 | //#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD) | 39 | //#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD) |
40 | #define CONFIG_STORAGE STORAGE_RAMDISK /* Multivolume currently handled at firmware/target/ level */ | 40 | #define CONFIG_STORAGE STORAGE_RAMDISK /* Multivolume currently handled at firmware/target/ level */ |
@@ -156,7 +156,7 @@ | |||
156 | #define BOOTFILE "rockbox." BOOTFILE_EXT | 156 | #define BOOTFILE "rockbox." BOOTFILE_EXT |
157 | #define BOOTDIR "/.rockbox" | 157 | #define BOOTDIR "/.rockbox" |
158 | 158 | ||
159 | #define CONFIG_USBOTG USBOTG_INGENIC | 159 | #define CONFIG_USBOTG USBOTG_JZ4740 |
160 | #define HAVE_USBSTACK | 160 | #define HAVE_USBSTACK |
161 | #define USB_VENDOR_ID 0x041e | 161 | #define USB_VENDOR_ID 0x041e |
162 | #define USB_PRODUCT_ID 0x4133 | 162 | #define USB_PRODUCT_ID 0x4133 |
diff --git a/firmware/export/jz4740.h b/firmware/export/jz4740.h index 45767b26cc..55c0ac7b1d 100644 --- a/firmware/export/jz4740.h +++ b/firmware/export/jz4740.h | |||
@@ -383,7 +383,7 @@ | |||
383 | #define REG_TCU_TCNT4 REG16(TCU_TCNT4) | 383 | #define REG_TCU_TCNT4 REG16(TCU_TCNT4) |
384 | #define REG_TCU_TCSR4 REG16(TCU_TCSR4) | 384 | #define REG_TCU_TCSR4 REG16(TCU_TCSR4) |
385 | 385 | ||
386 | // n = 0,1,2,3,4,5 | 386 | // n = 0,1,2,3,4,5,6,7 |
387 | #define TCU_TDFR(n) (TCU_BASE + (0x40 + (n)*0x10)) /* Timer Data Full Reg */ | 387 | #define TCU_TDFR(n) (TCU_BASE + (0x40 + (n)*0x10)) /* Timer Data Full Reg */ |
388 | #define TCU_TDHR(n) (TCU_BASE + (0x44 + (n)*0x10)) /* Timer Data Half Reg */ | 388 | #define TCU_TDHR(n) (TCU_BASE + (0x44 + (n)*0x10)) /* Timer Data Half Reg */ |
389 | #define TCU_TCNT(n) (TCU_BASE + (0x48 + (n)*0x10)) /* Timer Counter Reg */ | 389 | #define TCU_TCNT(n) (TCU_BASE + (0x48 + (n)*0x10)) /* Timer Counter Reg */ |
@@ -2903,11 +2903,11 @@ do { \ | |||
2903 | /* | 2903 | /* |
2904 | * MSC_CMD, MSC_CLK, MSC_D0 ~ MSC_D3 | 2904 | * MSC_CMD, MSC_CLK, MSC_D0 ~ MSC_D3 |
2905 | */ | 2905 | */ |
2906 | #define __gpio_as_msc() \ | 2906 | #define __gpio_as_msc() \ |
2907 | do { \ | 2907 | do { \ |
2908 | REG_GPIO_PXFUNS(3) = 0x00003f00; \ | 2908 | REG_GPIO_PXFUNS(3) = 0x00003f00; \ |
2909 | REG_GPIO_PXSELC(3) = 0x00003f00; \ | 2909 | REG_GPIO_PXSELC(3) = 0x00003f00; \ |
2910 | REG_GPIO_PXPES(3) = 0x00003f00; \ | 2910 | REG_GPIO_PXPES(3) = 0x00003f00; \ |
2911 | } while (0) | 2911 | } while (0) |
2912 | 2912 | ||
2913 | /* | 2913 | /* |
@@ -3027,8 +3027,8 @@ do { \ | |||
3027 | REG_GPIO_PXDIRS(p) = (1 << (o)); \ | 3027 | REG_GPIO_PXDIRS(p) = (1 << (o)); \ |
3028 | } while (0) | 3028 | } while (0) |
3029 | 3029 | ||
3030 | #define __gpio_port_as_input(p, o) \ | 3030 | #define __gpio_port_as_input(p, o) \ |
3031 | do { \ | 3031 | do { \ |
3032 | REG_GPIO_PXFUNC(p) = (1 << (o)); \ | 3032 | REG_GPIO_PXFUNC(p) = (1 << (o)); \ |
3033 | REG_GPIO_PXSELC(p) = (1 << (o)); \ | 3033 | REG_GPIO_PXSELC(p) = (1 << (o)); \ |
3034 | REG_GPIO_PXDIRC(p) = (1 << (o)); \ | 3034 | REG_GPIO_PXDIRC(p) = (1 << (o)); \ |
@@ -4168,9 +4168,9 @@ do { \ | |||
4168 | #define __msc_rd_rxfifo() ( REG_MSC_RXFIFO ) | 4168 | #define __msc_rd_rxfifo() ( REG_MSC_RXFIFO ) |
4169 | #define __msc_wr_txfifo(v) ( REG_MSC_TXFIFO = v ) | 4169 | #define __msc_wr_txfifo(v) ( REG_MSC_TXFIFO = v ) |
4170 | 4170 | ||
4171 | #define __msc_reset() \ | 4171 | #define __msc_reset() \ |
4172 | do { \ | 4172 | do { \ |
4173 | REG_MSC_STRPCL = MSC_STRPCL_RESET; \ | 4173 | REG_MSC_STRPCL = MSC_STRPCL_RESET; \ |
4174 | while (REG_MSC_STAT & MSC_STAT_IS_RESETTING); \ | 4174 | while (REG_MSC_STAT & MSC_STAT_IS_RESETTING); \ |
4175 | } while (0) | 4175 | } while (0) |
4176 | 4176 | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c index dd14a4c651..4c177d8ded 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c | |||
@@ -32,7 +32,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* bu | |||
32 | case 0: | 32 | case 0: |
33 | return nand_read_sectors(start, count, buf); | 33 | return nand_read_sectors(start, count, buf); |
34 | case 1: | 34 | case 1: |
35 | return sd_read_sectors(start, count, buf); | 35 | return _sd_read_sectors(start, count, buf); |
36 | default: | 36 | default: |
37 | panicf("ata_read_sectors: Drive %d unhandled!", drive); | 37 | panicf("ata_read_sectors: Drive %d unhandled!", drive); |
38 | return -1; | 38 | return -1; |
@@ -46,7 +46,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v | |||
46 | case 0: | 46 | case 0: |
47 | return nand_write_sectors(start, count, buf); | 47 | return nand_write_sectors(start, count, buf); |
48 | case 1: | 48 | case 1: |
49 | return sd_write_sectors(start, count, buf); | 49 | return _sd_write_sectors(start, count, buf); |
50 | default: | 50 | default: |
51 | panicf("ata_write_sectors: Drive %d unhandled!", drive); | 51 | panicf("ata_write_sectors: Drive %d unhandled!", drive); |
52 | return -1; | 52 | return -1; |
@@ -55,7 +55,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v | |||
55 | 55 | ||
56 | int ata_init(void) | 56 | int ata_init(void) |
57 | { | 57 | { |
58 | if(sd_init() != 0) | 58 | if(_sd_init() != 0) |
59 | return -1; | 59 | return -1; |
60 | if(nand_init() != 0) | 60 | if(nand_init() != 0) |
61 | return -2; | 61 | return -2; |
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c index ccd71630a6..22e274b4d1 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "jz4740.h" | 23 | #include "jz4740.h" |
24 | #include "ata.h" | 24 | #include "ata.h" |
25 | #include "ata-sd-target.h" | 25 | #include "ata-sd-target.h" |
26 | #include "sd.h" | ||
26 | #include "system.h" | 27 | #include "system.h" |
27 | #include "kernel.h" | 28 | #include "kernel.h" |
28 | #include "panic.h" | 29 | #include "panic.h" |
@@ -36,10 +37,7 @@ static struct wakeup sd_wakeup; | |||
36 | //#define DEBUG(x...) DEBUGF(x); | 37 | //#define DEBUG(x...) DEBUGF(x); |
37 | #define DEBUG(x...) printf(x); | 38 | #define DEBUG(x...) printf(x); |
38 | 39 | ||
39 | #define MMC_CD_PIN (29 + 1 * 32) /* Pin to check card insertion */ | 40 | #ifdef MMC_POWER_PIN |
40 | #define MMC_POWER_PIN (30 + 1 * 32) /* Pin to enable/disable card power */ | ||
41 | //#define MMC_PW_PIN (14 + 3 * 32) /* Pin to check protect card */ | ||
42 | |||
43 | #define MMC_POWER_OFF() \ | 41 | #define MMC_POWER_OFF() \ |
44 | do { \ | 42 | do { \ |
45 | __gpio_set_pin(MMC_POWER_PIN); \ | 43 | __gpio_set_pin(MMC_POWER_PIN); \ |
@@ -49,8 +47,11 @@ do { \ | |||
49 | do { \ | 47 | do { \ |
50 | __gpio_clear_pin(MMC_POWER_PIN); \ | 48 | __gpio_clear_pin(MMC_POWER_PIN); \ |
51 | } while (0) | 49 | } while (0) |
50 | #endif | ||
52 | 51 | ||
52 | #ifdef MMC_CD_PIN | ||
53 | #define MMC_INSERT_STATUS() __gpio_get_pin(MMC_CD_PIN) | 53 | #define MMC_INSERT_STATUS() __gpio_get_pin(MMC_CD_PIN) |
54 | #endif | ||
54 | 55 | ||
55 | #define MMC_RESET() __msc_reset() | 56 | #define MMC_RESET() __msc_reset() |
56 | 57 | ||
@@ -60,24 +61,6 @@ do { \ | |||
60 | REG_MSC_IREG = 0xffff; \ | 61 | REG_MSC_IREG = 0xffff; \ |
61 | } while (0) | 62 | } while (0) |
62 | 63 | ||
63 | static inline void mmc_init_gpio(void) | ||
64 | { | ||
65 | __gpio_as_msc(); | ||
66 | #ifdef MMC_POWER_PIN | ||
67 | __gpio_as_output(MMC_POWER_PIN); | ||
68 | __gpio_disable_pull(MMC_POWER_PIN); | ||
69 | __gpio_set_pin(MMC_POWER_PIN); | ||
70 | #endif | ||
71 | #ifdef MMC_CD_PIN | ||
72 | __gpio_as_input(MMC_CD_PIN); | ||
73 | __gpio_disable_pull(MMC_CD_PIN); | ||
74 | #endif | ||
75 | #ifdef MMC_PW_PIN | ||
76 | __gpio_as_input(MMC_PW_PIN); | ||
77 | __gpio_disable_pull(MMC_PW_PIN); | ||
78 | #endif | ||
79 | } | ||
80 | |||
81 | /* Error codes */ | 64 | /* Error codes */ |
82 | enum mmc_result_t | 65 | enum mmc_result_t |
83 | { | 66 | { |
@@ -509,7 +492,7 @@ static void jz_mmc_get_response(struct mmc_request *request) | |||
509 | buf[i] = (data >> 8) & 0xff; | 492 | buf[i] = (data >> 8) & 0xff; |
510 | buf[i + 1] = data & 0xff; | 493 | buf[i + 1] = data & 0xff; |
511 | } | 494 | } |
512 | DEBUG("request %d, response [", request->rtype); | 495 | DEBUG("request %d, response []", request->rtype); |
513 | break; | 496 | break; |
514 | } | 497 | } |
515 | case RESPONSE_NONE: | 498 | case RESPONSE_NONE: |
@@ -768,12 +751,14 @@ static int jz_mmc_exec_cmd(struct mmc_request *request) | |||
768 | /* On reset, stop MMC clock */ | 751 | /* On reset, stop MMC clock */ |
769 | jz_mmc_stop_clock(); | 752 | jz_mmc_stop_clock(); |
770 | } | 753 | } |
754 | #if 0 | ||
771 | if (request->cmd == MMC_SEND_OP_COND) | 755 | if (request->cmd == MMC_SEND_OP_COND) |
772 | { | 756 | { |
773 | DEBUG("Have a MMC card"); | 757 | DEBUG("Have a MMC card"); |
774 | /* always use 1bit for MMC */ | 758 | /* always use 1bit for MMC */ |
775 | use_4bit = 0; | 759 | use_4bit = 0; |
776 | } | 760 | } |
761 | #endif | ||
777 | if (request->cmd == SET_BUS_WIDTH) | 762 | if (request->cmd == SET_BUS_WIDTH) |
778 | { | 763 | { |
779 | if (request->arg == 0x2) | 764 | if (request->arg == 0x2) |
@@ -1070,13 +1055,16 @@ void MSC(void) | |||
1070 | static void jz_mmc_hardware_init(void) | 1055 | static void jz_mmc_hardware_init(void) |
1071 | { | 1056 | { |
1072 | mmc_init_gpio(); /* init GPIO */ | 1057 | mmc_init_gpio(); /* init GPIO */ |
1058 | #ifdef MMC_POWER_ON | ||
1073 | MMC_POWER_ON(); /* turn on power of card */ | 1059 | MMC_POWER_ON(); /* turn on power of card */ |
1060 | #endif | ||
1074 | MMC_RESET(); /* reset mmc/sd controller */ | 1061 | MMC_RESET(); /* reset mmc/sd controller */ |
1075 | MMC_IRQ_MASK(); /* mask all IRQs */ | 1062 | MMC_IRQ_MASK(); /* mask all IRQs */ |
1076 | jz_mmc_stop_clock(); /* stop MMC/SD clock */ | 1063 | jz_mmc_stop_clock(); /* stop MMC/SD clock */ |
1064 | __cpm_start_msc(); | ||
1077 | #ifdef MMC_DMA_ENABLE | 1065 | #ifdef MMC_DMA_ENABLE |
1078 | __cpm_start_dmac(); | 1066 | // __cpm_start_dmac(); |
1079 | __dmac_enable_module(); | 1067 | // __dmac_enable_module(); |
1080 | // REG_DMAC_DMACR = DMAC_DMACR_DME; | 1068 | // REG_DMAC_DMACR = DMAC_DMACR_DME; |
1081 | #if MMC_DMA_INTERRUPT | 1069 | #if MMC_DMA_INTERRUPT |
1082 | mmc_dma_rx_sem = OSSemCreate(0); | 1070 | mmc_dma_rx_sem = OSSemCreate(0); |
@@ -1105,7 +1093,7 @@ static void mmc_send_cmd(struct mmc_request *request, int cmd, unsigned int arg, | |||
1105 | } | 1093 | } |
1106 | 1094 | ||
1107 | static bool inited = false; | 1095 | static bool inited = false; |
1108 | int sd_init(void) | 1096 | int _sd_init(void) |
1109 | { | 1097 | { |
1110 | if(!inited) | 1098 | if(!inited) |
1111 | { | 1099 | { |
@@ -1150,7 +1138,7 @@ tCardInfo* card_get_info_target(int card_no) | |||
1150 | } | 1138 | } |
1151 | 1139 | ||
1152 | /* TODO */ | 1140 | /* TODO */ |
1153 | int sd_read_sectors(unsigned long start, int count, void* buf) | 1141 | int _sd_read_sectors(unsigned long start, int count, void* buf) |
1154 | { | 1142 | { |
1155 | (void)start; | 1143 | (void)start; |
1156 | (void)count; | 1144 | (void)count; |
@@ -1159,7 +1147,7 @@ int sd_read_sectors(unsigned long start, int count, void* buf) | |||
1159 | } | 1147 | } |
1160 | 1148 | ||
1161 | /* TODO */ | 1149 | /* TODO */ |
1162 | int sd_write_sectors(unsigned long start, int count, const void* buf) | 1150 | int _sd_write_sectors(unsigned long start, int count, const void* buf) |
1163 | { | 1151 | { |
1164 | (void)start; | 1152 | (void)start; |
1165 | (void)count; | 1153 | (void)count; |
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/ata-sd-target.h index f788fd6a41..cc6bd8a773 100644 --- a/firmware/target/mips/ingenic_jz47xx/ata-sd-target.h +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/ata-sd-target.h | |||
@@ -18,11 +18,13 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | |||
21 | #ifndef ATA_SD_TARGET_H | 22 | #ifndef ATA_SD_TARGET_H |
22 | #define ATA_SD_TARGET_H | 23 | #define ATA_SD_TARGET_H |
23 | 24 | ||
24 | #include "inttypes.h" | 25 | #include "inttypes.h" |
25 | #include "hotswap.h" | 26 | #include "hotswap.h" |
27 | #include "jz4740.h" | ||
26 | 28 | ||
27 | tCardInfo *card_get_info_target(int card_no); | 29 | tCardInfo *card_get_info_target(int card_no); |
28 | bool card_detect_target(void); | 30 | bool card_detect_target(void); |
@@ -32,8 +34,22 @@ void card_enable_monitoring_target(bool on); | |||
32 | void microsd_int(void); /* ??? */ | 34 | void microsd_int(void); /* ??? */ |
33 | #endif | 35 | #endif |
34 | 36 | ||
35 | int sd_read_sectors(unsigned long start, int count, void* buf); | 37 | int _sd_read_sectors(unsigned long start, int count, void* buf); |
36 | int sd_write_sectors(unsigned long start, int count, const void* buf); | 38 | int _sd_write_sectors(unsigned long start, int count, const void* buf); |
37 | int sd_init(void); | 39 | int _sd_init(void); |
40 | |||
41 | #define MMC_CD_PIN (29 + 1 * 32) /* Pin to check card insertion */ | ||
42 | //#define MMC_POWER_PIN (30 + 1 * 32) /* Pin to enable/disable card power */ | ||
43 | //#define MMC_PW_PIN (14 + 3 * 32) /* Pin to check protect card */ | ||
44 | |||
45 | static inline void mmc_init_gpio(void) | ||
46 | { | ||
47 | __gpio_as_msc(); | ||
48 | __gpio_as_input(MMC_CD_PIN); | ||
49 | __gpio_enable_pull(32*3+29); | ||
50 | __gpio_enable_pull(32*3+10); | ||
51 | __gpio_enable_pull(32*3+11); | ||
52 | __gpio_enable_pull(32*3+12); | ||
53 | } | ||
38 | 54 | ||
39 | #endif | 55 | #endif |
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c index 598fa1a0eb..501a90551e 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c | |||
@@ -23,8 +23,7 @@ | |||
23 | #include "jz4740.h" | 23 | #include "jz4740.h" |
24 | #include "backlight-target.h" | 24 | #include "backlight-target.h" |
25 | 25 | ||
26 | #define GPIO_PWM (32*3)+31 | 26 | #define PWM_CHN 7 /* PWM_CHN7 == GPIO(32*3 + 31) */ |
27 | #define PWM_CHN 7 | ||
28 | #define __gpio_as_PWM_CHN __gpio_as_pwm7 | 27 | #define __gpio_as_PWM_CHN __gpio_as_pwm7 |
29 | 28 | ||
30 | static void set_backlight(int val) | 29 | static void set_backlight(int val) |
diff --git a/firmware/target/mips/ingenic_jz47xx/usb-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h index ec700de892..c681bdaa12 100644 --- a/firmware/target/mips/ingenic_jz47xx/usb-target.h +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h | |||
@@ -19,7 +19,30 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include <stdbool.h> | 22 | #ifndef __USB_TARGET_H |
23 | #define __USB_TARGET_H | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | #define __gpio_as_usb_detect() \ | ||
28 | do { \ | ||
29 | REG_GPIO_PXFUNS(3) = 0x10000000; \ | ||
30 | REG_GPIO_PXSELS(3) = 0x10000000; \ | ||
31 | REG_GPIO_PXPES(3) = 0x10000000; \ | ||
32 | } while (0) | ||
33 | |||
34 | #define GPIO_UDC_DETE (32 * 3 + 28) | ||
35 | #define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE) | ||
36 | |||
37 | static inline void usb_init_gpio(void) | ||
38 | { | ||
39 | __gpio_as_usb_detect(); | ||
40 | system_enable_irq(IRQ_UDC); | ||
41 | __gpio_as_input(GPIO_UDC_DETE); | ||
42 | } | ||
43 | |||
23 | int usb_detect(void); | 44 | int usb_detect(void); |
24 | void usb_init_device(void); | 45 | void usb_init_device(void); |
25 | bool usb_drv_connected(void); | 46 | bool usb_drv_connected(void); |
47 | |||
48 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/ata-sd-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx767/ata-sd-target.h new file mode 100644 index 0000000000..cc6bd8a773 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/ata-sd-target.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef ATA_SD_TARGET_H | ||
23 | #define ATA_SD_TARGET_H | ||
24 | |||
25 | #include "inttypes.h" | ||
26 | #include "hotswap.h" | ||
27 | #include "jz4740.h" | ||
28 | |||
29 | tCardInfo *card_get_info_target(int card_no); | ||
30 | bool card_detect_target(void); | ||
31 | |||
32 | #ifdef HAVE_HOTSWAP | ||
33 | void card_enable_monitoring_target(bool on); | ||
34 | void microsd_int(void); /* ??? */ | ||
35 | #endif | ||
36 | |||
37 | int _sd_read_sectors(unsigned long start, int count, void* buf); | ||
38 | int _sd_write_sectors(unsigned long start, int count, const void* buf); | ||
39 | int _sd_init(void); | ||
40 | |||
41 | #define MMC_CD_PIN (29 + 1 * 32) /* Pin to check card insertion */ | ||
42 | //#define MMC_POWER_PIN (30 + 1 * 32) /* Pin to enable/disable card power */ | ||
43 | //#define MMC_PW_PIN (14 + 3 * 32) /* Pin to check protect card */ | ||
44 | |||
45 | static inline void mmc_init_gpio(void) | ||
46 | { | ||
47 | __gpio_as_msc(); | ||
48 | __gpio_as_input(MMC_CD_PIN); | ||
49 | __gpio_enable_pull(32*3+29); | ||
50 | __gpio_enable_pull(32*3+10); | ||
51 | __gpio_enable_pull(32*3+11); | ||
52 | __gpio_enable_pull(32*3+12); | ||
53 | } | ||
54 | |||
55 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h new file mode 100644 index 0000000000..c681bdaa12 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __USB_TARGET_H | ||
23 | #define __USB_TARGET_H | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | #define __gpio_as_usb_detect() \ | ||
28 | do { \ | ||
29 | REG_GPIO_PXFUNS(3) = 0x10000000; \ | ||
30 | REG_GPIO_PXSELS(3) = 0x10000000; \ | ||
31 | REG_GPIO_PXPES(3) = 0x10000000; \ | ||
32 | } while (0) | ||
33 | |||
34 | #define GPIO_UDC_DETE (32 * 3 + 28) | ||
35 | #define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE) | ||
36 | |||
37 | static inline void usb_init_gpio(void) | ||
38 | { | ||
39 | __gpio_as_usb_detect(); | ||
40 | system_enable_irq(IRQ_UDC); | ||
41 | __gpio_as_input(GPIO_UDC_DETE); | ||
42 | } | ||
43 | |||
44 | int usb_detect(void); | ||
45 | void usb_init_device(void); | ||
46 | bool usb_drv_connected(void); | ||
47 | |||
48 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c index 7cefdadbe3..f0b4eb4694 100644 --- a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "usb_ch9.h" | 25 | #include "usb_ch9.h" |
26 | #include "usb_drv.h" | 26 | #include "usb_drv.h" |
27 | #include "usb_core.h" | 27 | #include "usb_core.h" |
28 | #include "usb-target.h" | ||
28 | #include "jz4740.h" | 29 | #include "jz4740.h" |
29 | #include "thread.h" | 30 | #include "thread.h" |
30 | 31 | ||
@@ -33,10 +34,6 @@ | |||
33 | #define EP1_INTR_BIT 2 | 34 | #define EP1_INTR_BIT 2 |
34 | #define EP_FIFO_NOEMPTY 2 | 35 | #define EP_FIFO_NOEMPTY 2 |
35 | 36 | ||
36 | #define GPIO_UDC_DETE_PIN (32 * 3 + 6) | ||
37 | #define GPIO_UDC_DETE GPIO_UDC_DETE_PIN | ||
38 | #define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE) | ||
39 | |||
40 | #define IS_CACHE(x) (x < 0xa0000000) | 37 | #define IS_CACHE(x) (x < 0xa0000000) |
41 | 38 | ||
42 | #define USB_EP0_IDLE 0 | 39 | #define USB_EP0_IDLE 0 |
@@ -81,7 +78,7 @@ static inline void select_endpoint(int ep) | |||
81 | } | 78 | } |
82 | 79 | ||
83 | static void readFIFO(struct usb_endpoint *ep, unsigned int size) | 80 | static void readFIFO(struct usb_endpoint *ep, unsigned int size) |
84 | { | 81 | { |
85 | unsigned int *d = (unsigned int *)ep->ptr; | 82 | unsigned int *d = (unsigned int *)ep->ptr; |
86 | unsigned int s; | 83 | unsigned int s; |
87 | s = (size + 3) >> 2; | 84 | s = (size + 3) >> 2; |
@@ -90,7 +87,7 @@ static void readFIFO(struct usb_endpoint *ep, unsigned int size) | |||
90 | } | 87 | } |
91 | 88 | ||
92 | static void writeFIFO(struct usb_endpoint *ep, unsigned int size) | 89 | static void writeFIFO(struct usb_endpoint *ep, unsigned int size) |
93 | { | 90 | { |
94 | unsigned int *d = (unsigned int *)ep->ptr; | 91 | unsigned int *d = (unsigned int *)ep->ptr; |
95 | unsigned char *c; | 92 | unsigned char *c; |
96 | int s, q; | 93 | int s, q; |
@@ -359,7 +356,7 @@ bool usb_drv_connected(void) | |||
359 | 356 | ||
360 | int usb_detect(void) | 357 | int usb_detect(void) |
361 | { | 358 | { |
362 | if(__gpio_get_pin(GPIO_UDC_DETE) == 1) | 359 | if(usb_drv_connected()) |
363 | return USB_INSERTED; | 360 | return USB_INSERTED; |
364 | else | 361 | else |
365 | return USB_EXTRACTED; | 362 | return USB_EXTRACTED; |
@@ -367,9 +364,7 @@ int usb_detect(void) | |||
367 | 364 | ||
368 | void usb_init_device(void) | 365 | void usb_init_device(void) |
369 | { | 366 | { |
370 | system_enable_irq(IRQ_UDC); | 367 | usb_init_gpio(); |
371 | __gpio_as_input(GPIO_UDC_DETE_PIN); | ||
372 | return; | ||
373 | } | 368 | } |
374 | 369 | ||
375 | void usb_enable(bool on) | 370 | void usb_enable(bool on) |
@@ -442,6 +437,40 @@ void usb_drv_set_address(int address) | |||
442 | REG_USB_REG_FADDR = address; | 437 | REG_USB_REG_FADDR = address; |
443 | } | 438 | } |
444 | 439 | ||
440 | int usb_drv_send(int endpoint, void* ptr, int length) | ||
441 | { | ||
442 | return 0; | ||
443 | } | ||
444 | |||
445 | int usb_drv_recv(int endpoint, void* ptr, int length) | ||
446 | { | ||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | void usb_drv_set_test_mode(int mode) | ||
451 | { | ||
452 | |||
453 | } | ||
454 | |||
455 | int usb_drv_port_speed(void) | ||
456 | { | ||
457 | return ((REG_USB_REG_POWER & USB_POWER_HSMODE) != 0) ? 1 : 0; | ||
458 | } | ||
459 | |||
460 | void usb_drv_cancel_all_transfers(void) | ||
461 | { | ||
462 | int i; | ||
463 | for(i=0; i<5; i++) | ||
464 | { | ||
465 | endpoints[i].ptr = endpoints[i].buf; | ||
466 | endpoints[i].length = 0; | ||
467 | } | ||
468 | } | ||
469 | |||
470 | void usb_drv_release_endpoint(int ep) | ||
471 | { | ||
472 | |||
473 | } | ||
445 | 474 | ||
446 | #else | 475 | #else |
447 | 476 | ||
diff --git a/firmware/usb.c b/firmware/usb.c index b37ef3c5a5..fe89d223d3 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -51,7 +51,8 @@ | |||
51 | #if !defined(BOOTLOADER) || (CONFIG_CPU == SH7034) || \ | 51 | #if !defined(BOOTLOADER) || (CONFIG_CPU == SH7034) || \ |
52 | (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \ | 52 | (defined(TOSHIBA_GIGABEAT_S) && defined(USE_ROCKBOX_USB) && defined(USB_STORAGE)) || \ |
53 | (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx) || \ | 53 | (defined(HAVE_USBSTACK) && (defined(CREATIVE_ZVx) || \ |
54 | defined(CPU_TCC77X) || defined(CPU_TCC780X))) | 54 | defined(CPU_TCC77X) || defined(CPU_TCC780X))) || \ |
55 | (CONFIG_USBOTG == USBOTG_JZ4740) | ||
55 | #define USB_FULL_INIT | 56 | #define USB_FULL_INIT |
56 | #endif | 57 | #endif |
57 | 58 | ||