1 From 4656abc886843e162f5c2538baffe57135281480 Mon Sep 17 00:00:00 2001
2 From: Terry Lv <r65388@freescale.com>
3 Date: Mon, 19 Apr 2010 13:42:33 +0800
4 Subject: [PATCH] ENGR00122643: Integrate linear PMIC
8 Signed-off-by: Terry Lv <r65388@freescale.com>
10 board/freescale/mx51_bbg/mx51_bbg.c | 103 ++++++++++++++++++++++++++++++++++-
11 include/configs/mx51_bbg.h | 13 +++++
12 include/configs/mx51_bbg_android.h | 11 ++++
13 include/configs/mx51_bbg_mfg.h | 3 +
14 4 files changed, 128 insertions(+), 2 deletions(-)
16 diff --git a/board/freescale/mx51_bbg/mx51_bbg.c b/board/freescale/mx51_bbg/mx51_bbg.c
17 index 1d553c1..32bfde8 100644
18 --- a/board/freescale/mx51_bbg/mx51_bbg.c
19 +++ b/board/freescale/mx51_bbg/mx51_bbg.c
20 @@ -60,6 +60,7 @@ DECLARE_GLOBAL_DATA_PTR;
22 static u32 system_rev;
23 static enum boot_device boot_dev;
24 +static u32 voltage_setup;
25 u32 mx51_io_base_addr;
27 static inline void setup_boot_device(void)
28 @@ -306,6 +307,7 @@ static void setup_expio(void)
29 writew(reg, mx51_io_base_addr + PBC_SW_RESET);
32 +#ifdef CONFIG_IMX_ECSPI
33 void spi_io_init(struct imx_spi_dev_t *dev)
36 @@ -347,7 +349,9 @@ void spi_io_init(struct imx_spi_dev_t *dev)
42 +#ifdef CONFIG_MXC_FEC
43 static void setup_fec(void)
46 @@ -433,13 +437,93 @@ static void setup_fec(void)
47 writel(0x2180, IOMUXC_BASE_ADDR + 0x054C);
48 writel(0x0, IOMUXC_BASE_ADDR + 0x096C);
52 +#ifdef CONFIG_I2C_MXC
53 +static void setup_i2c(unsigned int module_base)
57 + switch (module_base) {
58 + case I2C1_BASE_ADDR:
59 + reg = IOMUXC_BASE_ADDR + 0x5c; /* i2c1 SDA */
61 + reg = IOMUXC_BASE_ADDR + 0x3f0;
63 + reg = IOMUXC_BASE_ADDR + 0x9B4;
66 + reg = IOMUXC_BASE_ADDR + 0x68; /* i2c2 SCL */
68 + reg = IOMUXC_BASE_ADDR + 0x3fc;
70 + reg = IOMUXC_BASE_ADDR + 0x9B0;
73 + case I2C2_BASE_ADDR:
77 + printf("Invalid I2C base: 0x%x\n", module_base);
82 +static void setup_core_voltage_i2c(void)
85 + unsigned char buf[1] = { 0 };
87 + puts("PMIC Mode: linear\n");
89 + writel(0x0, CCM_BASE_ADDR + CLKCTL_CACRR);
90 + reg = readl(GPIO2_BASE_ADDR + 0x0);
91 + reg &= ~0x4000; /* Lower reset line */
92 + writel(reg, GPIO2_BASE_ADDR + 0x0);
94 + reg = readl(GPIO2_BASE_ADDR + 0x4);
95 + reg |= 0x4000; /* configure GPIO lines as output */
96 + writel(reg, GPIO2_BASE_ADDR + 0x4);
98 + /* Reset the ethernet controller over GPIO */
99 + writel(0x1, IOMUXC_BASE_ADDR + 0x0AC);
102 + i2c_read(0x34, 0x12, 1, buf, 1);
103 + buf[0] = buf[0] | 0x40;
104 + if (i2c_write(0x34, 0x12, 1, buf, 1)) {
105 + puts("write to PMIC 0x12 failed!\n");
108 + i2c_read(0x34, 0x12, 1, buf, 1);
109 + printf("PMIC 0x12: 0x%x \n", buf[0]);
111 + i2c_read(0x34, 0x10, 1, buf, 1);
112 + buf[0] = buf[0] | 0x40;
113 + if (i2c_write(0x34, 0x10, 1, buf, 1)) {
114 + puts("write to PMIC 0x10 failed!\n");
117 + i2c_read(0x34, 0x10, 1, buf, 1);
118 + printf("PMIC 0x10: 0x%x \n", buf[0]);
122 + reg = readl(GPIO2_BASE_ADDR + 0x0);
124 + writel(reg, GPIO2_BASE_ADDR + 0x0);
128 -static void power_init(void)
129 +#ifdef CONFIG_IMX_ECSPI
130 +static void setup_core_voltage_spi(void)
132 struct spi_slave *slave;
136 + puts("PMIC Mode: SPI\n");
138 #define REV_ATLAS_LITE_1_0 0x8
139 #define REV_ATLAS_LITE_1_1 0x9
140 #define REV_ATLAS_LITE_2_0 0x10
141 @@ -554,6 +638,7 @@ static void power_init(void)
143 spi_pmic_free(slave);
147 #ifdef CONFIG_NET_MULTI
149 @@ -719,7 +804,13 @@ int board_init(void)
153 +#ifdef CONFIG_MXC_FEC
156 +#ifdef CONFIG_I2C_MXC
157 + setup_i2c(I2C1_BASE_ADDR);
163 @@ -916,7 +1007,15 @@ inline int check_recovery_cmd_file(void)
165 int board_late_init(void)
168 +#ifdef CONFIG_I2C_MXC
169 + i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
170 + if (!i2c_probe(0x34))
171 + setup_core_voltage_i2c();
174 +#ifdef CONFIG_IMX_ECSPI
175 + setup_core_voltage_spi();
178 #if defined(CONFIG_FSL_ANDROID) && defined(CONFIG_MXC_KPD)
179 if (waiting_for_func_key_pressing())
180 diff --git a/include/configs/mx51_bbg.h b/include/configs/mx51_bbg.h
181 index 121c7a1..117e506 100644
182 --- a/include/configs/mx51_bbg.h
183 +++ b/include/configs/mx51_bbg.h
185 #define CONFIG_CMD_SF
186 #define CONFIG_CMD_MMC
187 #define CONFIG_CMD_FUSE
188 +#define CONFIG_CMD_I2C
193 #define CONFIG_DOS_PARTITION 1
194 #define CONFIG_CMD_FAT 1
200 +#ifdef CONFIG_CMD_I2C
201 + #define CONFIG_HARD_I2C 1
202 + #define CONFIG_I2C_MXC 1
203 + #define CONFIG_SYS_I2C_PORT I2C1_BASE_ADDR
204 + #define CONFIG_SYS_I2C_SPEED 400000
205 + #define CONFIG_SYS_I2C_SLAVE 0xfe
211 diff --git a/include/configs/mx51_bbg_android.h b/include/configs/mx51_bbg_android.h
212 index a0bb39e..5f7435d 100644
213 --- a/include/configs/mx51_bbg_android.h
214 +++ b/include/configs/mx51_bbg_android.h
216 #define CONFIG_CMD_MII
217 #define CONFIG_CMD_NET
218 #define CONFIG_NET_RETRY_COUNT 100
219 +#define CONFIG_CMD_I2C
222 * Android support Configs
224 #define CONFIG_CMD_FAT 1
225 #define CONFIG_CMD_EXT2 1
231 +#define CONFIG_HARD_I2C 1
232 +#define CONFIG_I2C_MXC 1
233 +#define CONFIG_SYS_I2C_PORT I2C1_BASE_ADDR
234 +#define CONFIG_SYS_I2C_SPEED 400000
235 +#define CONFIG_SYS_I2C_SLAVE 0xfe
237 /*-----------------------------------------------------------------------
240 diff --git a/include/configs/mx51_bbg_mfg.h b/include/configs/mx51_bbg_mfg.h
241 index 4d35de2..becad73 100644
242 --- a/include/configs/mx51_bbg_mfg.h
243 +++ b/include/configs/mx51_bbg_mfg.h
245 #define CONFIG_DISPLAY_BOARDINFO
247 #define BOARD_LATE_INIT
250 * Disabled for now due to build problems under Debian and a significant
251 * increase in the final file size: 144260 vs. 109536 Bytes.
254 /* #define PHYS_SDRAM_1_SIZE (128 * 1024 * 1024) */
255 #define PHYS_SDRAM_1_SIZE (512 * 1024 * 1024)
256 +#define iomem_valid_addr(addr, size) \
257 + (addr >= PHYS_SDRAM_1 && addr <= (PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE))
259 /*-----------------------------------------------------------------------
260 * FLASH and environment organization