Commit 19f0e93041dbfe22f8d39b98e4f7f9ea87b77803
Committed by
Kim Phillips
1 parent
db1d72afd7
Exists in
master
and in
54 other branches
83xx, 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. Signed-off-by: Heiko Schocher <hs@denx.de> Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Showing 4 changed files with 69 additions and 8 deletions Side-by-side Diff
board/keymile/common/common.c
... | ... | @@ -318,7 +318,7 @@ |
318 | 318 | if (buf != NULL) |
319 | 319 | dev_addr = simple_strtoul ((char *)buf, NULL, 16); |
320 | 320 | |
321 | - if (eeprom_read (dev_addr, 0, i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN) != 0) { | |
321 | + if (i2c_read(dev_addr, 0, 1, i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN) != 0) { | |
322 | 322 | printf ("Error reading EEprom\n"); |
323 | 323 | return -2; |
324 | 324 | } |
board/keymile/kmeter1/kmeter1.c
... | ... | @@ -59,6 +59,23 @@ |
59 | 59 | {0, 0, 0, 0, QE_IOP_TAB_END}, |
60 | 60 | }; |
61 | 61 | |
62 | +static int board_init_i2c_busses (void) | |
63 | +{ | |
64 | + I2C_MUX_DEVICE *dev = NULL; | |
65 | + uchar *buf; | |
66 | + | |
67 | + /* Set up the Bus for the DTTs */ | |
68 | + buf = (unsigned char *) getenv ("dtt_bus"); | |
69 | + if (buf != NULL) | |
70 | + dev = i2c_mux_ident_muxstring (buf); | |
71 | + if (dev == NULL) { | |
72 | + printf ("Error couldn't add Bus for DTT\n"); | |
73 | + printf ("please setup dtt_bus to where your\n"); | |
74 | + printf ("DTT is found.\n"); | |
75 | + } | |
76 | + return 0; | |
77 | +} | |
78 | + | |
62 | 79 | int board_early_init_r (void) |
63 | 80 | { |
64 | 81 | void *reg = (void *)(CONFIG_SYS_IMMR + 0x14a8); |
... | ... | @@ -80,6 +97,13 @@ |
80 | 97 | return 0; |
81 | 98 | } |
82 | 99 | |
100 | +int misc_init_r (void) | |
101 | +{ | |
102 | + /* add board specific i2c busses */ | |
103 | + board_init_i2c_busses (); | |
104 | + return 0; | |
105 | +} | |
106 | + | |
83 | 107 | int fixed_sdram(void) |
84 | 108 | { |
85 | 109 | volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; |
... | ... | @@ -154,6 +178,15 @@ |
154 | 178 | void ft_board_setup (void *blob, bd_t *bd) |
155 | 179 | { |
156 | 180 | ft_cpu_setup (blob, bd); |
181 | +} | |
182 | +#endif | |
183 | + | |
184 | +#if defined(CONFIG_HUSH_INIT_VAR) | |
185 | +extern int ivm_read_eeprom (void); | |
186 | +int hush_init_var (void) | |
187 | +{ | |
188 | + ivm_read_eeprom (); | |
189 | + return 0; | |
157 | 190 | } |
158 | 191 | #endif |
include/configs/keymile-common.h
... | ... | @@ -42,13 +42,9 @@ |
42 | 42 | #define CONFIG_CMD_IMMAP |
43 | 43 | #define CONFIG_CMD_MII |
44 | 44 | #define CONFIG_CMD_PING |
45 | - | |
46 | -/* should go away, if kmeter I2C support is enabled */ | |
47 | -#if defined(CONFIG_MGCOGE) || defined(CONFIG_MGSUVD) | |
48 | 45 | #define CONFIG_CMD_DTT |
49 | 46 | #define CONFIG_CMD_EEPROM |
50 | 47 | #define CONFIG_CMD_I2C |
51 | -#endif | |
52 | 48 | |
53 | 49 | #undef CONFIG_WATCHDOG /* disable platform specific watchdog */ |
54 | 50 | |
55 | 51 | |
... | ... | @@ -73,10 +69,7 @@ |
73 | 69 | #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE /* Boot Argument Buffer Size */ |
74 | 70 | #define CONFIG_CMDLINE_EDITING 1 /* add command line history */ |
75 | 71 | |
76 | -/* should go away, if kmeter I2C support is enabled */ | |
77 | -#if defined(CONFIG_MGCOGE) || defined(CONFIG_MGSUVD) | |
78 | 72 | #define CONFIG_HUSH_INIT_VAR 1 |
79 | -#endif | |
80 | 73 | |
81 | 74 | #define CONFIG_SYS_ALT_MEMTEST /* memory test, takes time */ |
82 | 75 | #define CONFIG_SYS_MEMTEST_START 0x00100000 /* memtest works on */ |
include/configs/kmeter1.h
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | /* include common defines/options for all Keymile boards */ |
33 | 33 | #include "keymile-common.h" |
34 | 34 | |
35 | +#define CONFIG_MISC_INIT_R 1 | |
35 | 36 | /* |
36 | 37 | * System Clock Setup |
37 | 38 | */ |
... | ... | @@ -300,6 +301,38 @@ |
300 | 301 | #define CONFIG_ENV_SIZE 0x2000 |
301 | 302 | #endif /* CFG_RAMBOOT */ |
302 | 303 | |
304 | +/* I2C */ | |
305 | +#define CONFIG_HARD_I2C /* I2C with hardware support */ | |
306 | +#undef CONFIG_SOFT_I2C /* I2C bit-banged */ | |
307 | +#define CONFIG_FSL_I2C | |
308 | +#define CONFIG_SYS_I2C_SPEED 200000 /* I2C speed and slave address */ | |
309 | +#define CONFIG_SYS_I2C_SLAVE 0x7F | |
310 | +#define CONFIG_SYS_I2C_OFFSET 0x3000 | |
311 | +#define CONFIG_I2C_MULTI_BUS 1 | |
312 | +#define CONFIG_I2C_CMD_TREE 1 | |
313 | +#define CONFIG_SYS_MAX_I2C_BUS 2 | |
314 | +#define CONFIG_I2C_MUX 1 | |
315 | + | |
316 | +/* EEprom support */ | |
317 | +#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 | |
318 | +#define CONFIG_SYS_I2C_MULTI_EEPROMS 1 | |
319 | +#define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE | |
320 | +#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3 | |
321 | +#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10 | |
322 | + | |
323 | +/* Support the IVM EEprom */ | |
324 | +#define CONFIG_SYS_IVM_EEPROM_ADR 0x50 | |
325 | +#define CONFIG_SYS_IVM_EEPROM_MAX_LEN 0x400 | |
326 | +#define CONFIG_SYS_IVM_EEPROM_PAGE_LEN 0x100 | |
327 | + | |
328 | +/* I2C SYSMON (LM75, AD7414 is almost compatible) */ | |
329 | +#define CONFIG_DTT_LM75 1 /* ON Semi's LM75 */ | |
330 | +#define CONFIG_DTT_SENSORS {0, 1, 2, 3} /* Sensor addresses */ | |
331 | +#define CONFIG_SYS_DTT_MAX_TEMP 70 | |
332 | +#define CONFIG_SYS_DTT_LOW_TEMP -30 | |
333 | +#define CONFIG_SYS_DTT_HYSTERESIS 3 | |
334 | +#define CONFIG_SYS_DTT_BUS_NUM (2) | |
335 | + | |
303 | 336 | #if defined(CONFIG_PCI) |
304 | 337 | #define CONFIG_CMD_PCI |
305 | 338 | #endif |
... | ... | @@ -452,6 +485,8 @@ |
452 | 485 | "loadfdt=tftp ${fdt_addr_r} ${fdt_file}\0" \ |
453 | 486 | "loadkernel=tftp ${kernel_addr_r} ${boot_file}\0" \ |
454 | 487 | "unlock=yes\0" \ |
488 | + "EEprom_ivm=pca9547:70:9\0" \ | |
489 | + "dtt_bus=pca9547:70:a\0" \ | |
455 | 490 | "" |
456 | 491 | |
457 | 492 | #endif /* __CONFIG_H */ |