From 0a72b19c3fec92ec6aeaeb943811b52760c927f1 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 28 Nov 2008 10:16:39 +0000 Subject: [PATCH] qi-return-i2c-to-peripheral.patch Return IO to peripheral mode for i2c at end of init Signed-off-by: Andy Green --- qiboot/include/qi.h | 1 + qiboot/src/gta02/gta02.c | 16 ++++++++++++++++ qiboot/src/phase2.c | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/qiboot/include/qi.h b/qiboot/include/qi.h index 3429e9b..1db3248 100644 --- a/qiboot/include/qi.h +++ b/qiboot/include/qi.h @@ -74,6 +74,7 @@ struct board_api { int (*is_this_board)(void); void (*port_init)(void); void (*putc)(char); + void (*close)(void); struct kernel_source kernel_source[8]; }; diff --git a/qiboot/src/gta02/gta02.c b/qiboot/src/gta02/gta02.c index dd586d1..5b569fe 100644 --- a/qiboot/src/gta02/gta02.c +++ b/qiboot/src/gta02/gta02.c @@ -324,6 +324,21 @@ static void putc_gta02(char c) serial_putc_s3c24xx(GTA02_DEBUG_UART, c); } +static void close_gta02(void) +{ + /* clear any pending timeouts by reading interrupts */ + + i2c_read_sync(&bb_s3c24xx, PCF50633_I2C_ADS, PCF50633_REG_INT1); + i2c_read_sync(&bb_s3c24xx, PCF50633_I2C_ADS, PCF50633_REG_INT2); + i2c_read_sync(&bb_s3c24xx, PCF50633_I2C_ADS, PCF50633_REG_INT3); + i2c_read_sync(&bb_s3c24xx, PCF50633_I2C_ADS, PCF50633_REG_INT4); + i2c_read_sync(&bb_s3c24xx, PCF50633_I2C_ADS, PCF50633_REG_INT5); + + /* set I2C GPIO back to peripheral unit */ + + (bb_s3c24xx.close)(); +} + /* * our API for bootloader on this machine */ @@ -338,6 +353,7 @@ const struct board_api board_api_gta02 = { .is_this_board = is_this_board_gta02, .port_init = port_init_gta02, .putc = putc_gta02, + .close = close_gta02, /* these are the ways we could boot GTA02 in order to try */ .kernel_source = { [0] = { diff --git a/qiboot/src/phase2.c b/qiboot/src/phase2.c index c3f4e44..8284541 100644 --- a/qiboot/src/phase2.c +++ b/qiboot/src/phase2.c @@ -252,6 +252,12 @@ void bootloader_second_phase(void) params->hdr.tag = ATAG_NONE; params->hdr.size = 0; + /* give board implementation a chance to shut down + * anything it may have going on, leave GPIO set for Linux + */ + if (this_board->close) + (this_board->close)(); + puts ("Starting --->\n\n"); /*