iPod Classic: HW preliminary initialization for bootloader

When the bootloader starts, most of HW never has been initialized.
This patch includes all code needed to perform the preliminary
initialization on SYSCON, GPIO, i2c, and MIU.

The code is based on emCORE and OF reverse engineering, ported to
C for readability.

Change-Id: I9ecf2c3e8b1b636241a211dbba8735137accd05c
This commit is contained in:
Cástor Muñoz 2016-02-04 22:49:01 +01:00
parent c31fcddd98
commit 1aefd9ea41
10 changed files with 429 additions and 4 deletions

View file

@ -179,3 +179,31 @@ int i2c_read(int bus, unsigned char slave, int address, int len, unsigned char *
mutex_unlock(&i2c_mtx[bus]);
return ret;
}
#ifdef BOOTLOADER
#include "clocking-s5l8702.h"
static void wait_rdy(int bus)
{
while (IICUNK10(bus));
}
void i2c_preinit(int bus)
{
clockgate_enable(I2CCLKGATE(bus), true);
wait_rdy(bus);
IICADD(bus) = 0x40; /* own slave address */
wait_rdy(bus);
IICUNK14(bus) = 0;
wait_rdy(bus);
IICUNK18(bus) = 0;
wait_rdy(bus);
IICSTAT(bus) = 0x80; /* master Rx mode, Tx/Rx off */
wait_rdy(bus);
IICCON(bus) = 0;
wait_rdy(bus);
IICSTAT(bus) = 0; /* slave Rx mode, Tx/Rx off */
wait_rdy(bus);
clockgate_enable(I2CCLKGATE(bus), false);
}
#endif