mpc83xx, kmeter1: add I2C, dtt, eeprom support
PATCH 18/31 mpc83xx, kmeter1: add I2C, dtt, eeprom support
This patch adds I2C support for the Keymile kmeter1 board. It uses the First I2C Controller from the CPU, for accessing 4 temperature sensors, an eeprom with IVM data and the booteeprom over a pca9547 mux.
--- board/keymile/common/common.c | 4 +++- board/keymile/kmeter1/kmeter1.c | 32 ++++++++++++++++++++++++++++++++ include/configs/keymile-common.h | 5 ----- include/configs/kmeter1.h | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 6 deletions(-)
board/keymile/common/common.c +3 -1
@@ -40,6 +40,7 @@extern int i2c_soft_read_pin (void ); +#if defined(CONFIG_HUSH_INIT_VAR) int ivm_calc_crc (unsigned char *buf, int len) { const unsigned short crc_tab[16] = {
@@ -318,13 +319,14 @@ int ivm_read_eeprom (void)if (buf !=NULL ) dev_addr =simple_strtoul ((char *)buf,NULL ,16 ); -if (eeprom_read (dev_addr,0 , i2c_buffer,CONFIG_SYS_IVM_EEPROM_MAX_LEN ) !=0 ) { +if (i2c_read (dev_addr,0 ,1 , i2c_buffer,CONFIG_SYS_IVM_EEPROM_MAX_LEN ) !=0 ) {printf ("Error reading EEprom\n" );return -2 ; } return ivm_analyze_eeprom (i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN); } +#endif #if defined(CONFIG_SYS_I2C_INIT_BOARD )#define DELAY_ABORT_SEQ 62
board/keymile/kmeter1/kmeter1.c +32 -0
@@ -26,6 +26,7 @@#include <asm/mmu.h> #include <pci.h> #include <libfdt.h> +#include <dtt.h> #include "../common/common.h"
@@ -59,6 +60,22 @@ const qe_iop_conf_t qe_iop_conf_tab[] = { {0, 0, 0, 0, QE_IOP_TAB_END}, }; +static int board_init_i2c_busses (void ) +{ +I2C_MUX_DEVICE *dev =NULL ; +uchar *buf; + +/* Set up the Bus for the DTTs */ + buf = (unsigned char *)getenv ("DTT_bus" ); +if (buf !=NULL ) + dev =i2c_mux_ident_muxstring (buf); +if (dev ==NULL ) { +printf ("Error couldnt add Bus for DTT\n" ); +return 0 ; + } +return 0 ; +} +int board_early_init_r (void ) {void *reg = (void *)(CONFIG_SYS_IMMR +0x14a8 );
@@ -76,7 +93,13 @@ int board_early_init_r (void)out_be32 (reg, val);/* enable the PHY on the PIGGY */ setbits (8 , (void *)(CONFIG_SYS_PIGGY_BASE +0x10003 ),0x01 ); +return 0 ; +} +int misc_init_r (void ) +{ +board_init_i2c_busses (); +dtt_init ();return 0 ; }
@@ -156,3 +179,12 @@ void ft_board_setup (void *blob, bd_t *bd) ft_cpu_setup (blob, bd); }#endif + +#if defined(CONFIG_HUSH_INIT_VAR ) +extern int ivm_read_eeprom (void ); +int hush_init_var (void ) +{ +ivm_read_eeprom (); +return 0 ; +} +#endif
include/configs/keymile-common.h +0 -5
@@ -44,13 +44,11 @@#define CONFIG_CMD_PING /* should go away, if kmeter I2C support is enabled */ -#if defined(CONFIG_MGCOGE ) || defined(CONFIG_MGSUVD )#define CONFIG_CMD_DTT #define CONFIG_CMD_EEPROM #define CONFIG_CMD_I2C #define CONFIG_CMD_JFFS2 #define CONFIG_JFFS2_CMDLINE -#endif #undef CONFIG_WATCHDOG/* disable platform specific watchdog */
@@ -77,10 +75,7 @@#define CONFIG_COMMAND_HISTORY 1#define CONFIG_AUTO_COMPLETE /* add autocompletion support */ -/* should go away, if kmeter I2C support is enabled */ -#if defined(CONFIG_MGCOGE ) || defined(CONFIG_MGSUVD )#define CONFIG_HUSH_INIT_VAR 1 -#endif #define CONFIG_SYS_ALT_MEMTEST /* memory test, takes time */ #define CONFIG_SYS_MEMTEST_START 0x00100000/* memtest works on */
include/configs/kmeter1.h +38 -0
@@ -33,6 +33,7 @@/* include common defines/options for all Keymile boards */ #include "keymile-common.h" +#define CONFIG_MISC_INIT_R 1/* * System Clock Setup */
@@ -304,6 +305,41 @@#define CONFIG_ENV_SIZE 0x2000#endif /* CFG_RAMBOOT */ +/* I2C */ +#define CONFIG_HARD_I2C /* I2C with hardware support */ +#undef CONFIG_SOFT_I2C/* I2C bit-banged */ +#define CONFIG_FSL_I2C +#define CONFIG_I2C_MULTI_BUS +#define CONFIG_I2C_CMD_TREE +#define CONFIG_SYS_I2C_SPEED 200000/* I2C speed and slave address */ +#define CONFIG_SYS_I2C_SLAVE 0x7F +#define CONFIG_SYS_I2C_OFFSET 0x3000 + +#define CONFIG_SYS_MAX_I2C_BUS 2 +#define CONFIG_I2C_MUX 1 + +/* EEprom support */ +#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 +#define CONFIG_SYS_I2C_MULTI_EEPROMS 1 +#define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE +#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3 +#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10 + +#define CONFIG_HUSH_INIT_VAR 1 +/* Support the IVM EEprom */ +#define CONFIG_SYS_IVM_EEPROM_ADR 0x50 +#define CONFIG_SYS_IVM_EEPROM_MAX_LEN 0x400 +#define CONFIG_SYS_IVM_EEPROM_PAGE_LEN 0x100 + +/* I2C SYSMON (LM75, AD7414 is almost compatible) */ +#define CONFIG_DTT_LM75 1/* ON Semi's LM75 */ +#define CONFIG_DTT_SENSORS {0, 1, 2, 3}/* Sensor addresses */ +#define CONFIG_SYS_DTT_MAX_TEMP 70 +#define CONFIG_SYS_DTT_LOW_TEMP -30 +#define CONFIG_SYS_DTT_HYSTERESIS 3 +#define CONFIG_SYS_DTT_BUS_NUM (2) +#define CONFIG_SYS_DTT_BOARD_INIT 1 +#if defined(CONFIG_PCI )#define CONFIG_CMD_PCI #endif
@@ -428,6 +464,8 @@"kernel_addr=F00a0000\0" \"ramdisk_addr=F03a0000\0" \"ramdisk_addr_r=F10000\0" \ +"EEprom_ivm=pca9547:70:9\0" \ +"DTT_bus=pca9547:70:a\0" \""
Signature · 5 lines
1.6.0.6 -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 18/31 mpc83xx, kmeter1: add I2C, dtt, eeprom support
board/keymile/kmeter1/kmeter1.c const qe_iop_conf_t qe_iop_conf_tab[] = { · line 69
Quoted 7 lines · On Wed, 28 Jan 2009 10:40:04 +0100 Heiko Schocher <[email protected]> wrote:
board/keymile/kmeter1/kmeter1.c +7
-0+static int board_init_i2c_busses (void ) +{ +I2C_MUX_DEVICE *dev =NULL ; +uchar *buf; + +/* Set up the Bus for the DTTs */ + buf = (unsigned char *)getenv ("DTT_bus" );
the environment is case sensitive; can we be more case-consistent with names we expect from it?
board/keymile/kmeter1/kmeter1.c const qe_iop_conf_t qe_iop_conf_tab[] = { · line 73
Quoted 4 lines
board/keymile/kmeter1/kmeter1.c +4
-0+if (buf !=NULL ) + dev =i2c_mux_ident_muxstring (buf); +if (dev ==NULL ) { +printf ("Error couldnt add Bus for DTT\n" );
s/couldnt/couldn't/, add something like "please setenv dtt_bus <insert something reasonable here>"
Review
Quoted 1 line
(quoted diff) +1
-0+ return 0;
are you sure you shouldn't be returning an error code? otherwise this line is not necessary.
board/keymile/kmeter1/kmeter1.c const qe_iop_conf_t qe_iop_conf_tab[] = { · line 78
Quoted 4 lines
board/keymile/kmeter1/kmeter1.c +4
-0+ } +return 0 ; +} +
Kim
PATCH 18/31 mpc83xx, kmeter1: add I2C, dtt, eeprom support
Hello Kim,
Quoted 13 lines · Kim Phillips
board/keymile/kmeter1/kmeter1.c const qe_iop_conf_t qe_iop_conf_tab[] = { · line 69
Quoted 7 lines · On Wed, 28 Jan 2009 10:40:04 +0100 Heiko Schocher <[email protected]> wrote:
board/keymile/kmeter1/kmeter1.c +7
-0+static int board_init_i2c_busses (void ) +{ +I2C_MUX_DEVICE *dev =NULL ; +uchar *buf; + +/* Set up the Bus for the DTTs */ + buf = (unsigned char *)getenv ("DTT_bus" );the environment is case sensitive; can we be more case-consistent with names we expect from it?
Ok.
Quoted 7 lines
board/keymile/kmeter1/kmeter1.c const qe_iop_conf_t qe_iop_conf_tab[] = { · line 73
Quoted 4 lines
board/keymile/kmeter1/kmeter1.c +4
-0+if (buf !=NULL ) + dev =i2c_mux_ident_muxstring (buf); +if (dev ==NULL ) { +printf ("Error couldnt add Bus for DTT\n" );s/couldnt/couldn't/, add something like "please setenv
dtt_bus<insert something reasonable here>"
Ok.
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ return 0;are you sure you shouldn't be returning an error code? otherwise this line is not necessary.
thanks,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany