Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipod6g: Move pmu_is_hibernated() from bootloader to PMU driver, misc fixes

Added better comments about the PMU registers, added pmu_set_cpu_voltage() (still unused).

Credit: Cástor Muñoz <cmvidal@gmail.com>
Change-Id: I0ca21a49ece007c913c1b199952009e4dcae80e5

authored by

Vencislav Atanasov and committed by
Solomon Peachy
9b4bab7e 6b348d7f

+59 -32
-7
bootloader/ipod-s5l87xx.c
··· 279 279 return rc; 280 280 } 281 281 282 - static bool pmu_is_hibernated(void) 283 - { 284 - /* OF sets GPIO3 to low when SDRAM is hibernated */ 285 - return !(pmu_rd(PCF5063X_REG_GPIO3CFG) & 7) && 286 - !(pmu_rd(PCF5063X_REG_OOCSHDWN) & PCF5063X_OOCSHDWN_COLDBOOT); 287 - } 288 - 289 282 /* The boot sequence is executed on power-on or reset. After power-up 290 283 * the device could come from a state of hibernation, OF hibernates 291 284 * the iPod after an inactive period of ~30 minutes (FW 1.1.2), on
+23
firmware/target/arm/s5l8702/ipod6g/pmu-6g.c
··· 102 102 pmu_write(0xc, 1); 103 103 } 104 104 105 + #ifdef HAVE_ADJUSTABLE_CPU_FREQ 106 + void pmu_set_cpu_voltage(bool high) 107 + { 108 + pmu_write(PCF5063X_REG_DOWN1OUT, 109 + high ? 0x13 /*1100mV*/ : 0xf /*1000mV*/); 110 + } 111 + #endif 112 + 113 + #if (CONFIG_RTC == RTC_NANO2G) 105 114 void pmu_read_rtc(unsigned char* buffer) 106 115 { 107 116 pmu_read_multiple(0x59, 7, buffer); ··· 111 120 { 112 121 pmu_write_multiple(0x59, 7, buffer); 113 122 } 123 + #endif 114 124 115 125 /* 116 126 * ADC ··· 467 477 pmu_rd_multiple(PCF5063X_REG_INT1, 5, rd_buf); 468 478 pmu_rd(PCF50635_REG_INT6); 469 479 } 480 + 481 + #ifdef BOOTLOADER 482 + bool pmu_is_hibernated(void) 483 + { 484 + /* OF sets GPIO3 to low when SDRAM is hibernated */ 485 + bool gpio3out, coldboot; 486 + /* get (previously) configured output selection for GPIO3 */ 487 + gpio3out = (pmu_rd(PCF5063X_REG_GPIO3CFG) & 7); 488 + /* coldboot: when set, device has been in NoPower state */ 489 + coldboot = (pmu_rd(PCF5063X_REG_OOCSHDWN) & PCF5063X_OOCSHDWN_COLDBOOT); 490 + return !coldboot && !gpio3out; 491 + } 492 + #endif
+36 -25
firmware/target/arm/s5l8702/ipod6g/pmu-target.h
··· 29 29 #include "pcf5063x.h" 30 30 31 31 /* undocummented PMU registers */ 32 - #define PCF50635_REG_INT6 0x85 33 - #define PCF50635_REG_INT6M 0x86 34 - #define PCF50635_REG_GPIOSTAT 0x87 32 + #define PCF50635_REG_INT6 0x85 33 + #define PCF50635_REG_INT6M 0x86 34 + #define PCF50635_REG_GPIOSTAT 0x87 35 35 36 36 enum pcf50635_reg_int6 { 37 37 PCF50635_INT6_GPIO1 = 0x01, /* TBC */ 38 38 PCF50635_INT6_GPIO2 = 0x02, 39 + PCF50635_INT6_GPIO3 = 0x04, /* TBC */ 39 40 }; 40 41 41 42 enum pcf50635_reg_gpiostat { 42 43 PCF50635_GPIOSTAT_GPIO1 = 0x01, /* TBC */ 43 44 PCF50635_GPIOSTAT_GPIO2 = 0x02, 45 + PCF50635_GPIOSTAT_GPIO3 = 0x04, /* TBC */ 44 46 }; 45 47 46 48 47 49 /* GPIO for external PMU interrupt */ 48 50 #define GPIO_EINT_PMU 0x7b 49 51 50 - /* LDOs */ 51 - #define LDO_UNK1 1 /* TBC: SoC voltage (USB) */ 52 - #define LDO_UNK2 2 /* TBC: SoC voltage (I/O) */ 52 + /* LDOs - enumeration starts at 1 as pcf50635 DS does */ 53 + #define LDO_UNK1 1 /* SoC voltage (USB+TBC section) */ 54 + #define LDO_UNK2 2 /* SoC voltage (I/O+TBC section) */ 53 55 #define LDO_LCD 3 54 56 #define LDO_CODEC 4 55 - #define LDO_UNK5 5 /* TBC: nano3g NAND */ 57 + #define LDO_UNK5 5 /* not used */ 56 58 #define LDO_CWHEEL 6 57 59 #define LDO_ACCY 7 /* HCLDO */ 58 60 /* 59 61 * Other LDOs: 60 62 * AUTOLDO: Hard Disk 61 - * DOWN1: CPU 62 - * DOWN2: SDRAM 63 - * MEMLDO: SDRAM self-refresh (TBC) 63 + * DOWN1: Vcore 64 + * DOWN2: SDRAM 65 + * MEMLDO: SDRAM self-refresh (TBC) 64 66 * 65 67 * EXTON inputs: 66 68 * EXTON1: button/holdswitch related (TBC) ··· 68 70 * EXTON3: ACCESSORY (Low when present) 69 71 * 70 72 * PMU GPIO: 71 - * GPIO1: input, Mikey (jack remote ctrl) interrupt (TBC) 73 + * GPIO1: input, Mikey (jack remote ctrl) interrupt 72 74 * GPIO2: input, hold switch (TBC) 73 - * GPIO3: output, unknown 75 + * GPIO3: output, OF uses it as a flag to detect hibernation state, 76 + * it is unknown where/if this output is connected. 74 77 */ 78 + 75 79 76 80 struct pmu_adc_channel 77 81 { ··· 82 86 uint8_t bias_dly; /* RB ticks */ 83 87 }; 84 88 89 + void pmu_preinit(void); 90 + void pmu_init(void); 85 91 unsigned char pmu_read(int address); 86 92 int pmu_write(int address, unsigned char val); 87 93 int pmu_read_multiple(int address, int count, unsigned char* buffer); 88 94 int pmu_write_multiple(int address, int count, unsigned char* buffer); 89 - unsigned short pmu_read_adc(const struct pmu_adc_channel *ch); 90 - unsigned short pmu_adc_raw2mv( 91 - const struct pmu_adc_channel *ch, unsigned short raw); 92 - void pmu_init(void); 95 + #ifdef BOOTLOADER 96 + unsigned char pmu_rd(int address); 97 + int pmu_wr(int address, unsigned char val); 98 + int pmu_rd_multiple(int address, int count, unsigned char* buffer); 99 + int pmu_wr_multiple(int address, int count, unsigned char* buffer); 100 + bool pmu_is_hibernated(void); 101 + #endif 102 + 93 103 void pmu_ldo_on_in_standby(unsigned int ldo, int onoff); 94 104 void pmu_ldo_set_voltage(unsigned int ldo, unsigned char voltage); 95 105 void pmu_ldo_power_on(unsigned int ldo); 96 106 void pmu_ldo_power_off(unsigned int ldo); 97 107 void pmu_set_wake_condition(unsigned char condition); 98 108 void pmu_enter_standby(void); 109 + void pmu_hdd_power(bool on); 110 + #ifdef HAVE_ADJUSTABLE_CPU_FREQ 111 + void pmu_set_cpu_voltage(bool high); 112 + #endif 113 + #if (CONFIG_RTC == RTC_NANO2G) 99 114 void pmu_read_rtc(unsigned char* buffer); 100 115 void pmu_write_rtc(unsigned char* buffer); 101 - void pmu_hdd_power(bool on); 116 + #endif 117 + 118 + unsigned short pmu_read_adc(const struct pmu_adc_channel *ch); 119 + unsigned short pmu_adc_raw2mv( 120 + const struct pmu_adc_channel *ch, unsigned short raw); 102 121 103 122 int pmu_holdswitch_locked(void); 104 123 #if CONFIG_CHARGING ··· 106 125 #endif 107 126 #ifdef IPOD_ACCESSORY_PROTOCOL 108 127 int pmu_accessory_present(void); 109 - #endif 110 - 111 - void pmu_preinit(void); 112 - #ifdef BOOTLOADER 113 - unsigned char pmu_rd(int address); 114 - int pmu_wr(int address, unsigned char val); 115 - int pmu_rd_multiple(int address, int count, unsigned char* buffer); 116 - int pmu_wr_multiple(int address, int count, unsigned char* buffer); 117 128 #endif 118 129 119 130 #endif /* __PMU_TARGET_H__ */