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) @@ -92,15 +92,15 @@ } 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 */ outl(0xffffffff, 0x7000c120); outl(0xffffffff, 0x7000c124); outl(0xc00a1f00, 0x7000c100); - outl(0x1000000, 0x7000c104); + outl(0x01000000, 0x7000c104); } static inline int ipod_4g_button_read(void) @@ -122,13 +122,13 @@ 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; @@ -342,7 +342,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