[PATCH 3/7] qi-return-i2c-to-peripheral.patch
Andy Green
andy at openmoko.com
Fri Oct 10 12:51:37 CEST 2008
Return IO to peripheral mode for i2c at end of init
Signed-off-by: Andy Green <andy at openmoko.com>
---
include/qi.h | 1 +
src/gta02/gta02.c | 16 ++++++++++++++++
src/phase2.c | 6 ++++++
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/include/qi.h b/include/qi.h
index 3429e9b..1db3248 100644
--- a/include/qi.h
+++ b/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/src/gta02/gta02.c b/src/gta02/gta02.c
index dd586d1..5b569fe 100644
--- a/src/gta02/gta02.c
+++ b/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/src/phase2.c b/src/phase2.c
index c3f4e44..8284541 100644
--- a/src/phase2.c
+++ b/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");
/*
More information about the openmoko-kernel
mailing list