iPod Classic: prepare i2c and PMU for bootloader

When the bootloader starts only IRAM is available, the first task is to
ask the PMU to verify if the iPod has previously been hibernated by OF.
Due to memory limitations, the kernel cannot be used on this stage.

This patch modifies I2C and PMU low level functions to not to depend
on kernel (removes mutexes, and uses HW timer instead of current_tick),
actual kernel functions are modified to be 'mutexed' wrappers of the new
functions.

Change-Id: I7cef9e95dedaf176dc0659315f3dc33166d5b116
This commit is contained in:
Cástor Muñoz 2016-02-04 20:12:02 +01:00
parent 44ce4eebd6
commit 469d645390
4 changed files with 73 additions and 53 deletions

View file

@ -142,3 +142,27 @@ void pmu_write_rtc(unsigned char* buffer)
{
pmu_write_multiple(0x59, 7, buffer);
}
#ifdef BOOTLOADER
int pmu_rd_multiple(int address, int count, unsigned char* buffer)
{
return i2c_rd(0, 0xe6, address, count, buffer);
}
int pmu_wr_multiple(int address, int count, unsigned char* buffer)
{
return i2c_wr(0, 0xe6, address, count, buffer);
}
unsigned char pmu_rd(int address)
{
unsigned char val;
pmu_rd_multiple(address, 1, &val);
return val;
}
int pmu_wr(int address, unsigned char val)
{
return pmu_wr_multiple(address, 1, &val);
}
#endif /* BOOTLOADER */

View file

@ -25,7 +25,7 @@
#include <stdbool.h>
#include "config.h"
#include <pcf5063x.h>
#include "pcf5063x.h"
/* undocummented PMU registers */
#define PCF50635_REG_INT6 0x85
@ -77,4 +77,11 @@ void pmu_read_rtc(unsigned char* buffer);
void pmu_write_rtc(unsigned char* buffer);
void pmu_hdd_power(bool on);
#ifdef BOOTLOADER
unsigned char pmu_rd(int address);
int pmu_wr(int address, unsigned char val);
int pmu_rd_multiple(int address, int count, unsigned char* buffer);
int pmu_wr_multiple(int address, int count, unsigned char* buffer);
#endif
#endif /* __PMU_TARGET_H__ */