From 1adfd9dd3fc1bacc3c3a1fe8790f258916483fce Mon Sep 17 00:00:00 2001 From: Holger Brunck Date: Sun, 5 Jun 2011 22:22:20 +0000 Subject: [PATCH] powerpc/km82xx: remove 82xx specific functions from common.c Common code should be valid for more than one architecture, therefore the km82xx specific code was removed from common.c. Signed-off-by: Holger Brunck Signed-off-by: Valentin Longchamp cc: Heiko Schocher cc: Wolfgang Denk --- board/keymile/common/common.c | 69 +----------------------------- board/keymile/common/common.h | 1 - board/keymile/km82xx/km82xx.c | 60 ++++++++++++++++++++++++++ include/configs/km/km82xx-common.h | 7 +++ 4 files changed, 69 insertions(+), 68 deletions(-) diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 814968dd80..841bdeee21 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -25,9 +25,6 @@ */ #include -#if defined(CONFIG_KM82XX) -#include -#endif #include #include #include @@ -44,6 +41,7 @@ #include "common.h" #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) #include +#endif static void i2c_write_start_seq(void); DECLARE_GLOBAL_DATA_PTR; @@ -83,70 +81,9 @@ int set_km_env(void) return 0; } -#if defined(CONFIG_SYS_I2C_INIT_BOARD) #define DELAY_ABORT_SEQ 62 /* @200kHz 9 clocks = 44us, 62us is ok */ #define DELAY_HALF_PERIOD (500 / (CONFIG_SYS_I2C_SPEED / 1000)) -#if defined(CONFIG_KM_82XX) -#define SDA_MASK 0x00010000 -#define SCL_MASK 0x00020000 -void set_pin(int state, unsigned long mask) -{ - ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); - - if (state) - setbits_be32(&iop->pdat, mask); - else - clrbits_be32(&iop->pdat, mask); - - setbits_be32(&iop->pdir, mask); -} - -static int get_pin(unsigned long mask) -{ - ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); - - clrbits_be32(&iop->pdir, mask); - return 0 != (in_be32(&iop->pdat) & mask); -} - -static void set_sda(int state) -{ - set_pin(state, SDA_MASK); -} - -static void set_scl(int state) -{ - set_pin(state, SCL_MASK); -} - -static int get_sda(void) -{ - return get_pin(SDA_MASK); -} - -static int get_scl(void) -{ - return get_pin(SCL_MASK); -} - -#if defined(CONFIG_HARD_I2C) -static void setports(int gpio) -{ - ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); - - if (gpio) { - clrbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); - clrbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); - } else { - setbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); - clrbits_be32(&iop->pdir, (SDA_MASK | SCL_MASK)); - setbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); - } -} -#endif -#endif - #if !defined(CONFIG_MPC83xx) static void i2c_write_start_seq(void) { @@ -223,7 +160,7 @@ int i2c_make_abort(void) #endif return ret; } -#endif +#endif /* !MPC83xx */ #if defined(CONFIG_MPC83xx) static void i2c_write_start_seq(void) @@ -296,8 +233,6 @@ void i2c_init_board(void) /* Now run the AbortSequence() */ i2c_make_abort(); } -#endif -#endif #if !defined(MACH_TYPE_KM_KIRKWOOD) int ethernet_present(void) diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h index edf6e3aa63..0fb19cf331 100644 --- a/board/keymile/common/common.h +++ b/board/keymile/common/common.h @@ -124,7 +124,6 @@ struct bfticu_iomap { int ethernet_present(void); int ivm_read_eeprom(void); -void set_pin(int state, unsigned long mask); int set_km_env(void); int fdt_set_node_and_value(void *blob, diff --git a/board/keymile/km82xx/km82xx.c b/board/keymile/km82xx/km82xx.c index d453d25ac3..0e50b0bfa0 100644 --- a/board/keymile/km82xx/km82xx.c +++ b/board/keymile/km82xx/km82xx.c @@ -315,6 +315,8 @@ int last_stage_init(void) } #ifdef CONFIG_MGCOGE3NE +static void set_pin(int state, unsigned long mask); + /* * For mgcoge3ne boards, the mgcoge3un control is controlled from * a GPIO line on the PPC CPU. If bobcatreset is set the line @@ -363,6 +365,64 @@ int hush_init_var(void) return 0; } +#define SDA_MASK 0x00010000 +#define SCL_MASK 0x00020000 + +static void set_pin(int state, unsigned long mask) +{ + ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); + + if (state) + setbits_be32(&iop->pdat, mask); + else + clrbits_be32(&iop->pdat, mask); + + setbits_be32(&iop->pdir, mask); +} + +static int get_pin(unsigned long mask) +{ + ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); + + clrbits_be32(&iop->pdir, mask); + return 0 != (in_be32(&iop->pdat) & mask); +} + +void set_sda(int state) +{ + set_pin(state, SDA_MASK); +} + +void set_scl(int state) +{ + set_pin(state, SCL_MASK); +} + +int get_sda(void) +{ + return get_pin(SDA_MASK); +} + +int get_scl(void) +{ + return get_pin(SCL_MASK); +} + +#if defined(CONFIG_HARD_I2C) +static void setports(int gpio) +{ + ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); + + if (gpio) { + clrbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); + clrbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); + } else { + setbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); + clrbits_be32(&iop->pdir, (SDA_MASK | SCL_MASK)); + setbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); + } +} +#endif #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) void ft_board_setup(void *blob, bd_t *bd) { diff --git a/include/configs/km/km82xx-common.h b/include/configs/km/km82xx-common.h index b89631c806..0360cd31ce 100644 --- a/include/configs/km/km82xx-common.h +++ b/include/configs/km/km82xx-common.h @@ -139,6 +139,13 @@ } while (0) #define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ +#ifndef __ASSEMBLY__ +void set_sda(int state); +void set_scl(int state); +int get_sda(void); +int get_scl(void); +#endif + /* I2C SYSMON (LM75, AD7414 is almost compatible) */ #define CONFIG_DTT_LM75 /* ON Semi's LM75 */ #define CONFIG_DTT_SENSORS {0} /* Sensor addresses */ -- 2.30.2