summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-08-01 22:44:02 +0000
committerJens Arnold <amiconn@rockbox.org>2007-08-01 22:44:02 +0000
commitcb896cdd04ae04cbf9cb59990c920e579ea6887a (patch)
tree27fa4213a221e5b3827321d25d1c8c0d8dd06419
parenta049fa7c82cf155314c7e141f72ac8f8a7cf92fb (diff)
downloadrockbox-cb896cdd04ae04cbf9cb59990c920e579ea6887a.tar.gz
rockbox-cb896cdd04ae04cbf9cb59990c920e579ea6887a.zip
Firewire detection with reboot into diskmode for all iPods that support it (all but Nano and Video). * Hack for compiling iPod G3 removed. * Code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14131 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/bitmaps/native/SOURCES4
-rw-r--r--apps/bitmaps/native/usblogo.fw.128x39x2.bmpbin0 -> 5062 bytes
-rw-r--r--firmware/SOURCES23
-rw-r--r--firmware/export/config-ipod1g2g.h3
-rw-r--r--firmware/export/config-ipod3g.h3
-rw-r--r--firmware/export/pp5002.h5
-rw-r--r--firmware/target/arm/usb-fw-pp5002.c70
-rw-r--r--firmware/target/arm/usb-fw-pp502x.c (renamed from firmware/target/arm/usb-pp.c)35
8 files changed, 113 insertions, 30 deletions
diff --git a/apps/bitmaps/native/SOURCES b/apps/bitmaps/native/SOURCES
index 62deb0afac..094b2d61b1 100644
--- a/apps/bitmaps/native/SOURCES
+++ b/apps/bitmaps/native/SOURCES
@@ -31,7 +31,11 @@ usblogo.176x48x16.bmp
31usblogo.128x37x16.bmp 31usblogo.128x37x16.bmp
32#endif 32#endif
33#elif LCD_DEPTH > 1 /* greyscale */ 33#elif LCD_DEPTH > 1 /* greyscale */
34#ifdef IPOD_1G2G /* use firewire logo */
35usblogo.fw.128x39x2.bmp
36#else
34usblogo.128x33x2.bmp 37usblogo.128x33x2.bmp
38#endif
35#else /* monochrome */ 39#else /* monochrome */
36#if LCD_WIDTH == 112 40#if LCD_WIDTH == 112
37usblogo.100x20x1.bmp 41usblogo.100x20x1.bmp
diff --git a/apps/bitmaps/native/usblogo.fw.128x39x2.bmp b/apps/bitmaps/native/usblogo.fw.128x39x2.bmp
new file mode 100644
index 0000000000..bdf7af52b7
--- /dev/null
+++ b/apps/bitmaps/native/usblogo.fw.128x39x2.bmp
Binary files differ
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 91cead088d..ccd6f11570 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -382,7 +382,7 @@ target/arm/sandisk/sansa-e200/lcd-e200.c
382target/arm/sandisk/sansa-e200/lcd-as-e200.S 382target/arm/sandisk/sansa-e200/lcd-as-e200.S
383target/arm/sandisk/sansa-e200/adc-e200.c 383target/arm/sandisk/sansa-e200/adc-e200.c
384target/arm/sandisk/sansa-e200/backlight-e200.c 384target/arm/sandisk/sansa-e200/backlight-e200.c
385target/arm/usb-pp.c 385target/arm/usb-fw-pp502x.c
386target/arm/sandisk/sansa-e200/button-e200.c 386target/arm/sandisk/sansa-e200/button-e200.c
387target/arm/sandisk/sansa-e200/power-e200.c 387target/arm/sandisk/sansa-e200/power-e200.c
388target/arm/i2s-pp.c 388target/arm/i2s-pp.c
@@ -497,7 +497,7 @@ target/arm/iriver/h10/backlight-h10.c
497target/arm/iriver/h10/button-h10.c 497target/arm/iriver/h10/button-h10.c
498target/arm/iriver/h10/lcd-h10_20gb.c 498target/arm/iriver/h10/lcd-h10_20gb.c
499target/arm/iriver/h10/power-h10.c 499target/arm/iriver/h10/power-h10.c
500target/arm/usb-pp.c 500target/arm/usb-fw-pp502x.c
501#endif /* SIMULATOR */ 501#endif /* SIMULATOR */
502#endif /* IRIVER_H10 */ 502#endif /* IRIVER_H10 */
503 503
@@ -512,7 +512,7 @@ target/arm/iriver/h10/backlight-h10.c
512target/arm/iriver/h10/button-h10.c 512target/arm/iriver/h10/button-h10.c
513target/arm/iriver/h10/lcd-h10_5gb.c 513target/arm/iriver/h10/lcd-h10_5gb.c
514target/arm/iriver/h10/power-h10.c 514target/arm/iriver/h10/power-h10.c
515target/arm/usb-pp.c 515target/arm/usb-fw-pp502x.c
516#endif /* SIMULATOR */ 516#endif /* SIMULATOR */
517#endif /* IRIVER_H10_5GB */ 517#endif /* IRIVER_H10_5GB */
518 518
@@ -551,7 +551,7 @@ target/arm/tatung/tpj1022/backlight-tpj1022.c
551target/arm/tatung/tpj1022/button-tpj1022.c 551target/arm/tatung/tpj1022/button-tpj1022.c
552target/arm/tatung/tpj1022/lcd-tpj1022.c 552target/arm/tatung/tpj1022/lcd-tpj1022.c
553target/arm/tatung/tpj1022/power-tpj1022.c 553target/arm/tatung/tpj1022/power-tpj1022.c
554target/arm/usb-pp.c 554target/arm/usb-fw-pp502x.c
555#endif /* SIMULATOR */ 555#endif /* SIMULATOR */
556#endif /* ELIO_TPJ1022 */ 556#endif /* ELIO_TPJ1022 */
557 557
@@ -567,7 +567,7 @@ target/arm/ipod/backlight-4g_color.c
567target/arm/ipod/button-clickwheel.c 567target/arm/ipod/button-clickwheel.c
568target/arm/ipod/lcd-gray.c 568target/arm/ipod/lcd-gray.c
569target/arm/ipod/power-ipod.c 569target/arm/ipod/power-ipod.c
570target/arm/usb-pp.c 570target/arm/usb-fw-pp502x.c
571#endif /* SIMULATOR */ 571#endif /* SIMULATOR */
572#endif /* IPOD_4G */ 572#endif /* IPOD_4G */
573 573
@@ -583,7 +583,7 @@ target/arm/ipod/backlight-4g_color.c
583target/arm/ipod/button-clickwheel.c 583target/arm/ipod/button-clickwheel.c
584target/arm/ipod/lcd-color_nano.c 584target/arm/ipod/lcd-color_nano.c
585target/arm/ipod/power-ipod.c 585target/arm/ipod/power-ipod.c
586target/arm/usb-pp.c 586target/arm/usb-fw-pp502x.c
587#endif /* SIMULATOR */ 587#endif /* SIMULATOR */
588#endif /* IPOD_COLOR */ 588#endif /* IPOD_COLOR */
589 589
@@ -599,7 +599,7 @@ target/arm/ipod/backlight-nano_video.c
599target/arm/ipod/button-clickwheel.c 599target/arm/ipod/button-clickwheel.c
600target/arm/ipod/lcd-color_nano.c 600target/arm/ipod/lcd-color_nano.c
601target/arm/ipod/power-ipod.c 601target/arm/ipod/power-ipod.c
602target/arm/usb-pp.c 602target/arm/usb-fw-pp502x.c
603#endif /* SIMULATOR */ 603#endif /* SIMULATOR */
604#endif /* IPOD_NANO */ 604#endif /* IPOD_NANO */
605 605
@@ -615,7 +615,7 @@ target/arm/ipod/backlight-nano_video.c
615target/arm/ipod/button-clickwheel.c 615target/arm/ipod/button-clickwheel.c
616target/arm/ipod/power-ipod.c 616target/arm/ipod/power-ipod.c
617target/arm/ipod/video/lcd-video.c 617target/arm/ipod/video/lcd-video.c
618target/arm/usb-pp.c 618target/arm/usb-fw-pp502x.c
619#endif /* SIMULATOR */ 619#endif /* SIMULATOR */
620#endif /* IPOD_VIDEO */ 620#endif /* IPOD_VIDEO */
621 621
@@ -630,7 +630,7 @@ target/arm/ipod/3g/backlight-3g.c
630target/arm/ipod/button-1g-3g.c 630target/arm/ipod/button-1g-3g.c
631target/arm/ipod/lcd-gray.c 631target/arm/ipod/lcd-gray.c
632target/arm/ipod/power-ipod.c 632target/arm/ipod/power-ipod.c
633target/arm/usb-pp.c 633target/arm/usb-fw-pp5002.c
634#endif /* SIMULATOR */ 634#endif /* SIMULATOR */
635#endif /* IPOD_3G */ 635#endif /* IPOD_3G */
636 636
@@ -644,6 +644,7 @@ target/arm/ipod/1g2g/backlight-1g2g.c
644target/arm/ipod/button-1g-3g.c 644target/arm/ipod/button-1g-3g.c
645target/arm/ipod/lcd-gray.c 645target/arm/ipod/lcd-gray.c
646target/arm/ipod/power-ipod.c 646target/arm/ipod/power-ipod.c
647target/arm/usb-fw-pp5002.c
647#endif /* SIMULATOR */ 648#endif /* SIMULATOR */
648#endif /* IPOD_1G2G */ 649#endif /* IPOD_1G2G */
649 650
@@ -659,7 +660,7 @@ target/arm/ipod/backlight-mini1g_mini2g.c
659target/arm/ipod/button-mini1g.c 660target/arm/ipod/button-mini1g.c
660target/arm/ipod/lcd-gray.c 661target/arm/ipod/lcd-gray.c
661target/arm/ipod/power-ipod.c 662target/arm/ipod/power-ipod.c
662target/arm/usb-pp.c 663target/arm/usb-fw-pp502x.c
663#endif /* SIMULATOR */ 664#endif /* SIMULATOR */
664#endif /* IPOD_MINI */ 665#endif /* IPOD_MINI */
665 666
@@ -675,7 +676,7 @@ target/arm/ipod/backlight-mini1g_mini2g.c
675target/arm/ipod/button-clickwheel.c 676target/arm/ipod/button-clickwheel.c
676target/arm/ipod/lcd-gray.c 677target/arm/ipod/lcd-gray.c
677target/arm/ipod/power-ipod.c 678target/arm/ipod/power-ipod.c
678target/arm/usb-pp.c 679target/arm/usb-fw-pp502x.c
679#endif /* SIMULATOR */ 680#endif /* SIMULATOR */
680#endif /* IPOD_MINI2G */ 681#endif /* IPOD_MINI2G */
681 682
diff --git a/firmware/export/config-ipod1g2g.h b/firmware/export/config-ipod1g2g.h
index 0eb3614dd6..37ebb32f86 100644
--- a/firmware/export/config-ipod1g2g.h
+++ b/firmware/export/config-ipod1g2g.h
@@ -110,7 +110,8 @@
110/* Offset ( in the firmware file's header ) to the real data */ 110/* Offset ( in the firmware file's header ) to the real data */
111#define FIRMWARE_OFFSET_FILE_DATA 8 111#define FIRMWARE_OFFSET_FILE_DATA 8
112 112
113#define USB_NONE 113#define USB_IPODSTYLE
114/* actually firewire only, but handled like USB */
114 115
115/* Virtual LED (icon) */ 116/* Virtual LED (icon) */
116#define CONFIG_LED LED_VIRTUAL 117#define CONFIG_LED LED_VIRTUAL
diff --git a/firmware/export/config-ipod3g.h b/firmware/export/config-ipod3g.h
index c3e63e87e3..466fb19601 100644
--- a/firmware/export/config-ipod3g.h
+++ b/firmware/export/config-ipod3g.h
@@ -110,7 +110,8 @@
110/* Offset ( in the firmware file's header ) to the real data */ 110/* Offset ( in the firmware file's header ) to the real data */
111#define FIRMWARE_OFFSET_FILE_DATA 8 111#define FIRMWARE_OFFSET_FILE_DATA 8
112 112
113#define USB_NONE 113#define USB_IPODSTYLE
114/* actually both firewire and USB, USB isn't handled yet */
114 115
115/* Virtual LED (icon) */ 116/* Virtual LED (icon) */
116#define CONFIG_LED LED_VIRTUAL 117#define CONFIG_LED LED_VIRTUAL
diff --git a/firmware/export/pp5002.h b/firmware/export/pp5002.h
index 83f8456bf0..9d757ead7d 100644
--- a/firmware/export/pp5002.h
+++ b/firmware/export/pp5002.h
@@ -141,9 +141,4 @@
141#define MMAP3_LOGICAL (*(volatile unsigned long *)(0xf000f018)) 141#define MMAP3_LOGICAL (*(volatile unsigned long *)(0xf000f018))
142#define MMAP3_PHYSICAL (*(volatile unsigned long *)(0xf000f01c)) 142#define MMAP3_PHYSICAL (*(volatile unsigned long *)(0xf000f01c))
143 143
144/* FIXME: These are PP502x definitions, but without them, iPod 3rd gen
145 * doesn't compile. The correct values for 3rd gen are not yet known. */
146#define DEV_INIT (*(volatile unsigned long *)(0x70000020))
147#define INIT_USB 0x80000000
148
149#endif 144#endif
diff --git a/firmware/target/arm/usb-fw-pp5002.c b/firmware/target/arm/usb-fw-pp5002.c
new file mode 100644
index 0000000000..e64d4f8f81
--- /dev/null
+++ b/firmware/target/arm/usb-fw-pp5002.c
@@ -0,0 +1,70 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "config.h"
21#include "ata.h"
22#include "cpu.h"
23#include "string.h"
24#include "system.h"
25#include "usb.h"
26#include "usb-target.h"
27
28void usb_init_device(void)
29{
30 /* TODO: add USB init for iPod 3rd gen */
31
32#if defined(IPOD_1G2G) || defined(IPOD_3G)
33 /* GPIO C bit 7 is firewire detect */
34 GPIOC_ENABLE |= 0x80;
35 GPIOC_OUTPUT_EN &= ~0x80;
36#endif
37}
38
39void usb_enable(bool on)
40{
41 /* This device specific code will eventually give way to proper USB
42 handling, which should be the same for all PP5002 targets. */
43 if (on)
44 {
45#ifdef IPOD_ARCH
46 /* For iPod, we can only do one thing with USB mode atm - reboot
47 into the flash-based disk-mode. This does not return. */
48
49 ata_sleepnow(); /* Immediately spindown the disk. */
50 sleep(HZ*2);
51
52 memcpy((void *)0x40017f00, "diskmodehotstuff\1", 17);
53
54 system_reboot(); /* Reboot */
55#endif
56 }
57}
58
59bool usb_detect(void)
60{
61#if defined(IPOD_1G2G) || defined(IPOD_3G)
62 /* GPIO C bit 7 is firewire detect */
63 if (!(GPIOC_INPUT_VAL & 0x80))
64 return true;
65#endif
66
67 /* TODO: add USB detection for iPod 3rd gen */
68
69 return false;
70}
diff --git a/firmware/target/arm/usb-pp.c b/firmware/target/arm/usb-fw-pp502x.c
index b497e86804..92e3dee562 100644
--- a/firmware/target/arm/usb-pp.c
+++ b/firmware/target/arm/usb-fw-pp502x.c
@@ -86,27 +86,25 @@ void usb_init_device(void)
86 86
87 udelay(0x186A0); 87 udelay(0x186A0);
88 88
89
90 dr_controller_setup(); 89 dr_controller_setup();
90
91#if defined(IPOD_COLOR) || defined(IPOD_4G) \
92 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
93 /* GPIO C bit 1 is firewire detect */
94 GPIOC_ENABLE |= 0x02;
95 GPIOC_OUTPUT_EN &= ~0x02;
96#endif
91} 97}
92 98
93void usb_enable(bool on) 99void usb_enable(bool on)
94{ 100{
95 /* This device specific code will eventually give way to proper USB 101 /* This device specific code will eventually give way to proper USB
96 handling, which should be the same for all PortalPlayer targets. */ 102 handling, which should be the same for all PP502x targets. */
97 if (on) 103 if (on)
98 { 104 {
99#if defined(IPOD_ARCH) || defined(IRIVER_H10) || defined (IRIVER_H10_5GB) 105#if defined(IPOD_ARCH) || defined(IRIVER_H10) || defined (IRIVER_H10_5GB)
100 /* For the H10 and iPod, we can only do one thing with USB mode - reboot 106 /* For the H10 and iPod, we can only do one thing with USB mode - reboot
101 into the flash-based disk-mode. This does not return. */ 107 into the flash-based disk-mode. This does not return. */
102
103 /* The following code is copied from ipodlinux */
104#if defined(IPOD_COLOR) || defined(IPOD_3G) || \
105 defined(IPOD_4G) || defined(IPOD_MINI)
106 unsigned char* storage_ptr = (unsigned char *)0x40017F00;
107#elif defined(IPOD_NANO) || defined(IPOD_VIDEO) || defined(IPOD_MINI2G)
108 unsigned char* storage_ptr = (unsigned char *)0x4001FF00;
109#endif
110 108
111#if defined(IRIVER_H10) || defined (IRIVER_H10_5GB) 109#if defined(IRIVER_H10) || defined (IRIVER_H10_5GB)
112 if(button_status()==BUTTON_RIGHT) 110 if(button_status()==BUTTON_RIGHT)
@@ -114,9 +112,15 @@ void usb_enable(bool on)
114 { 112 {
115 ata_sleepnow(); /* Immediately spindown the disk. */ 113 ata_sleepnow(); /* Immediately spindown the disk. */
116 sleep(HZ*2); 114 sleep(HZ*2);
117#ifdef IPOD_ARCH 115
118 memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21); 116#ifdef IPOD_ARCH /* The following code is based on ipodlinux */
117#if CONFIG_CPU == PP5020
118 memcpy((void *)0x40017f00, "diskmode\0\0hotstuff\0\0\1", 21);
119#elif CONFIG_CPU == PP5022
120 memcpy((void *)0x4001ff00, "diskmode\0\0hotstuff\0\0\1", 21);
119#endif 121#endif
122#endif
123
120 system_reboot(); /* Reboot */ 124 system_reboot(); /* Reboot */
121 } 125 }
122#endif 126#endif
@@ -128,6 +132,13 @@ bool usb_detect(void)
128 static bool prev_usbstatus1 = false; 132 static bool prev_usbstatus1 = false;
129 bool usbstatus1,usbstatus2; 133 bool usbstatus1,usbstatus2;
130 134
135#if defined(IPOD_COLOR) || defined(IPOD_4G) \
136 || defined(IPOD_MINI) || defined(IPOD_MINI2G)
137 /* GPIO C bit 1 is firewire detect */
138 if (!(GPIOC_INPUT_VAL & 0x02))
139 return true;
140#endif
141
131 /* UDC_ID should have the bit format: 142 /* UDC_ID should have the bit format:
132 [31:24] = 0x0 143 [31:24] = 0x0
133 [23:16] = 0x22 (Revision number) 144 [23:16] = 0x22 (Revision number)