Index: firmware/target/arm/usb-fw-pp502x.c =================================================================== --- firmware/target/arm/usb-fw-pp502x.c (revision 15973) +++ firmware/target/arm/usb-fw-pp502x.c (working copy) @@ -33,18 +33,23 @@ void usb_init_device(void) { /* enable usb module */ - GPO32_ENABLE |= 0x200; +//AB GPO32_ENABLE |= 0x200; //not needed by testing on ipod 5G? outl(inl(0x7000002C) | 0x3000000, 0x7000002C); DEV_EN |= DEV_USB; + DEV_EN |= 0x8; DEV_RS |= DEV_USB; /* reset usb start */ - DEV_RS &=~DEV_USB;/* reset usb end */ + DEV_RS &=~DEV_USB; /* reset usb end */ - DEV_INIT2 |= INIT_USB; +//AB DEV_INIT2 |= INIT_USB; //not needed by testing on ipod 5G? while ((inl(0x70000028) & 0x80) == 0); outl(inl(0x70000028) | 0x2, 0x70000028); udelay(0x186A0); + + /* disable USB-device until USB is detected via GPIO */ + DEV_EN &= ~DEV_USB; + DEV_EN &= ~0x8; #if defined(IPOD_COLOR) || defined(IPOD_4G) \ || defined(IPOD_MINI) || defined(IPOD_MINI2G) @@ -85,33 +90,43 @@ static bool usb_pin_detect(void) { + bool retval = false; + #if defined(IPOD_4G) || defined(IPOD_COLOR) \ || defined(IPOD_MINI) || defined(IPOD_MINI2G) /* GPIO D bit 3 is usb detect */ if (GPIOD_INPUT_VAL & 0x08) - return true; + retval = true; #elif defined(IPOD_NANO) || defined(IPOD_VIDEO) /* GPIO L bit 4 is usb detect */ if (GPIOL_INPUT_VAL & 0x10) - return true; + retval = true; #elif defined(SANSA_C200) /* GPIO H bit 1 is usb detect */ if (GPIOH_INPUT_VAL & 0x02) - return true; + retval = true; #elif defined(SANSA_E200) /* GPIO B bit 4 is usb detect */ if (GPIOB_INPUT_VAL & 0x10) - return true; + retval = true; #elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) /* GPIO L bit 2 is usb detect */ if (GPIOL_INPUT_VAL & 0x4) - return true; + retval = true; #endif - return false; + + /* if USB is detected, re-enable the USB-device */ + if (retval) + { + DEV_EN |= DEV_USB; + DEV_EN |= 0x8; + } + + return retval; } /* detect host or charger (INSERTED or POWERED) */ Index: firmware/target/arm/ipod/button-clickwheel.c =================================================================== --- firmware/target/arm/ipod/button-clickwheel.c (revision 15973) +++ firmware/target/arm/ipod/button-clickwheel.c (working copy) @@ -73,62 +73,36 @@ static void opto_i2c_init(void) { - int i, curr_value; - - /* wait for value to settle */ - i = 1000; - curr_value = (inl(0x7000c104) << 16) >> 24; - while (i > 0) - { - int new_value = (inl(0x7000c104) << 16) >> 24; - - if (new_value != curr_value) { - i = 10000; - curr_value = new_value; - } - else { - i--; - } - } - - GPIOB_OUTPUT_VAL |= 0x10; - DEV_EN |= 0x10000; - DEV_RS |= 0x10000; + DEV_EN |= DEV_OPTO; + DEV_RS |= DEV_OPTO; udelay(5); - DEV_RS &= ~0x10000; /* finish reset */ + DEV_RS &= ~DEV_OPTO; /* finish reset */ + DEV_INIT1 |= 0x00040000; - outl(0xffffffff, 0x7000c120); - outl(0xffffffff, 0x7000c124); outl(0xc00a1f00, 0x7000c100); - outl(0x1000000, 0x7000c104); + outl(0x01000000, 0x7000c104); } static inline int ipod_4g_button_read(void) { int whl = -1; - - /* The ipodlinux source had a udelay(250) here, but testing has shown that - it is not needed - tested on Nano, Color/Photo and Video. */ - /* udelay(250);*/ - int btn = BUTTON_NONE; - unsigned reg = 0x7000c104; + if ((inl(0x7000c104) & 0x4000000) != 0) { unsigned status = inl(0x7000c140); - reg = reg + 0x3C; /* 0x7000c140 */ outl(0x0, 0x7000c140); /* clear interrupt status? */ if ((status & 0x800000ff) == 0x8000001a) { - if (status & 0x100) + if (status & 0x0100) btn |= BUTTON_SELECT; - if (status & 0x200) + if (status & 0x0200) btn |= BUTTON_RIGHT; - if (status & 0x400) + if (status & 0x0400) btn |= BUTTON_LEFT; - if (status & 0x800) + if (status & 0x0800) btn |= BUTTON_PLAY; if (status & 0x1000) btn |= BUTTON_MENU; @@ -263,17 +237,8 @@ } } - else if (status == 0xffffffff) - { - opto_i2c_init(); - } } - if ((inl(reg) & 0x8000000) != 0) - { - outl(0xffffffff, 0x7000c120); - outl(0xffffffff, 0x7000c124); - } /* Save the new absolute wheel position */ #ifdef HAVE_WHEEL_POSITION wheel_position = whl; @@ -304,7 +269,6 @@ outl(inl(0x7000c104) | 0xC000000, 0x7000c104); outl(0x400a1f00, 0x7000c100); - GPIOB_OUTPUT_VAL |= 0x10; CPU_INT_EN = 0x40000000; CPU_HI_INT_EN = I2C_MASK; } @@ -342,7 +306,20 @@ hold_button = button_hold(); if (hold_button != hold_button_old) + { backlight_hold_changed(hold_button); + + if (hold_button) + { + /* lock -> disable wheel sensor */ + DEV_EN &= ~DEV_OPTO; + } + else + { + /* unlock -> enable wheel sensor */ + DEV_EN |= DEV_OPTO; + } + } /* The int_btn variable is set in the button interrupt handler */ return int_btn; Index: firmware/target/arm/ipod/power-ipod.c =================================================================== --- firmware/target/arm/ipod/power-ipod.c (revision 15973) +++ firmware/target/arm/ipod/power-ipod.c (working copy) @@ -71,9 +71,15 @@ GPIO_SET_BITWISE(GPIOJ_OUTPUT_VAL, 0x04); #elif defined(IPOD_VIDEO) if (on) + { GPO32_VAL &= ~0x40000000; + DEV_EN |= DEV_IDE0; + } else + { + DEV_EN &= ~DEV_IDE0; GPO32_VAL |= 0x40000000; + } #else /* Nano */ (void)on; /* Do nothing. */ #endif Index: firmware/target/arm/system-pp502x.c =================================================================== --- firmware/target/arm/system-pp502x.c (revision 15973) +++ firmware/target/arm/system-pp502x.c (working copy) @@ -192,7 +192,8 @@ scale_suspend_core(false); udelay(500); /* wait for relock */ #elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) - PLL_CONTROL = 0x8a121403; /* (20/3 * 24MHz) / 2 */ + PLL_CONTROL = 0x8a121403; /* 80 MHz = (20/3 * 24MHz) / 2 */ + //PLL_CONTROL = 0x8a121903; /* 100 MHz = (25/3 * 24MHz) / 2 */ scale_suspend_core(false); udelay(250); while (!(PLL_STATUS & 0x80000000)); /* wait for relock */ @@ -214,7 +215,8 @@ scale_suspend_core(false); udelay(500); /* wait for relock */ #elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) - PLL_CONTROL = 0x8a220501; /* (5/1 * 24MHz) / 4 */ + //PLL_CONTROL = 0x8a220501; /* 30 MHz = (5/1 * 24MHz) / 4 */ + PLL_CONTROL = 0x8a221403; /* 40 MHz = (20/3 * 24MHz) / 4 */ scale_suspend_core(false); udelay(250); while (!(PLL_STATUS & 0x80000000)); /* wait for relock */ @@ -276,6 +278,27 @@ outl(inl(0x70000024) | 0xc0, 0x70000024); DEV_RS = 0; DEV_RS2 = 0; +#elif defined (IPOD_VIDEO) + //DEV_EN = 0xc2c1197f; /* DEV_EN1 from svn */ + //DEV_EN2 = 0x00000000; /* DEV_EN2 from svn */ + //CACHE_PRIORITY = 0x0007003f; /* DEV_EN3 from svn */ + //GPO32_ENABLE = 0xfe80feff; /* GPO32_EN from svn */ + //GPO32_VAL = 0x00804000; /* GPO32_VAL from svn */ + //DEV_INIT1 = 0x00040000; /* INIT1 from svn 0x00040000 = wheel? */ + //DEV_INIT2 = 0x40000000; /* INIT2 from svn 0x40000000 = need for boot */ + + //DEV_EN = 0xc241192e; /* DEV_EN1 from own tests */ + DEV_EN = 0xc2011926; /* DEV_EN1 from own tests (w/o USB) */ + DEV_EN2 = 0x00000000; /* DEV_EN2 same as svn */ + CACHE_PRIORITY = 0x0000003f; /* DEV_EN3 from own tests */ + GPO32_ENABLE = 0x40004000; /* GPO32_EN from own tests */ + GPO32_VAL = 0x00004000; /* GPO32_VAL from own tests */ + DEV_INIT1 = 0x00000000; /* INIT1 from own tests */ + DEV_INIT2 = 0x40000000; /* INIT2 same as svn */ + DEV_RS = 0x3ffffef8; /* reset all allowed DEVs */ + DEV_RS2 = 0xffffffff; /* reset all allowed DEV2s */ + DEV_RS = 0x00000000; /* finish reset of DEV */ + DEV_RS2 = 0x00000000; /* finish reset of DEV2 */ #endif #if !defined(SANSA_E200) && !defined(SANSA_C200)