Commit 35e07b92f38436f04a0f8728cfc6a72f52aeddda
1 parent
cd7520d6af
Exists in
v2016.05-dlt
initial commit for delta touch board
Showing 5 changed files with 96 additions and 36 deletions Inline Diff
board/embedian/smarct335x/board.c
1 | /* | 1 | /* |
2 | * board.c | 2 | * board.c |
3 | * | 3 | * |
4 | * Board functions for TI AM335X based boards | 4 | * Board functions for TI AM335X based boards |
5 | * | 5 | * |
6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ | 6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
7 | * | 7 | * |
8 | * SPDX-License-Identifier: GPL-2.0+ | 8 | * SPDX-License-Identifier: GPL-2.0+ |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <common.h> | 11 | #include <common.h> |
12 | #include <errno.h> | 12 | #include <errno.h> |
13 | #include <spl.h> | 13 | #include <spl.h> |
14 | #include <asm/arch/cpu.h> | 14 | #include <asm/arch/cpu.h> |
15 | #include <asm/arch/hardware.h> | 15 | #include <asm/arch/hardware.h> |
16 | #include <asm/arch/omap.h> | 16 | #include <asm/arch/omap.h> |
17 | #include <asm/arch/ddr_defs.h> | 17 | #include <asm/arch/ddr_defs.h> |
18 | #include <asm/arch/clock.h> | 18 | #include <asm/arch/clock.h> |
19 | #include <asm/arch/gpio.h> | 19 | #include <asm/arch/gpio.h> |
20 | #include <asm/arch/mmc_host_def.h> | 20 | #include <asm/arch/mmc_host_def.h> |
21 | #include <asm/arch/sys_proto.h> | 21 | #include <asm/arch/sys_proto.h> |
22 | #include <asm/arch/mem.h> | 22 | #include <asm/arch/mem.h> |
23 | #include <asm/io.h> | 23 | #include <asm/io.h> |
24 | #include <asm/emif.h> | 24 | #include <asm/emif.h> |
25 | #include <asm/gpio.h> | 25 | #include <asm/gpio.h> |
26 | #include <i2c.h> | 26 | #include <i2c.h> |
27 | #include <miiphy.h> | 27 | #include <miiphy.h> |
28 | #include <cpsw.h> | 28 | #include <cpsw.h> |
29 | #include <power/tps65217.h> | 29 | #include <power/tps65217.h> |
30 | #include <power/tps65910.h> | 30 | #include <power/tps65910.h> |
31 | #include <environment.h> | 31 | #include <environment.h> |
32 | #include <watchdog.h> | 32 | #include <watchdog.h> |
33 | #include "board.h" | 33 | #include "board.h" |
34 | 34 | ||
35 | DECLARE_GLOBAL_DATA_PTR; | 35 | DECLARE_GLOBAL_DATA_PTR; |
36 | 36 | ||
37 | /* GPIO that controls power to DDR on EVM-SK */ | 37 | /* GPIO that controls power to DDR on EVM-SK */ |
38 | #define GPIO_DDR_VTT_EN 7 | 38 | #define GPIO_DDR_VTT_EN 7 |
39 | 39 | ||
40 | /* GPIO that controls power of LCD backlight */ | 40 | /* GPIO that controls power of LCD backlight */ |
41 | #define GPIO_LCD_BKLT_EN 54 | 41 | #define GPIO_LCD_BKLT_EN 54 |
42 | 42 | ||
43 | /* GPIO that controls LCD backlight PWM */ | 43 | /* GPIO that controls LCD backlight PWM */ |
44 | #define GPIO_LCD_PWM_EN 7 | 44 | #define GPIO_LCD_PWM_EN 7 |
45 | 45 | ||
46 | /* GPIO that controls WDT */ | ||
47 | #define GPIO_WDT_EN 66 | ||
48 | |||
49 | /* GPIO of SER_INT */ | ||
50 | #define GPIO_SER_INT 100 | ||
51 | |||
46 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; | 52 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
47 | 53 | ||
48 | /* | 54 | /* |
49 | * Read header information from EEPROM into global structure. | 55 | * Read header information from EEPROM into global structure. |
50 | */ | 56 | */ |
51 | static int read_eeprom(struct am335x_baseboard_id *header) | 57 | static int read_eeprom(struct am335x_baseboard_id *header) |
52 | { | 58 | { |
53 | /* Check if baseboard eeprom is available */ | 59 | /* Check if baseboard eeprom is available */ |
54 | if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) { | 60 | if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) { |
55 | puts("Could not probe the EEPROM; something fundamentally " | 61 | puts("Could not probe the EEPROM; something fundamentally " |
56 | "wrong on the I2C bus.\n"); | 62 | "wrong on the I2C bus.\n"); |
57 | return -ENODEV; | 63 | return -ENODEV; |
58 | } | 64 | } |
59 | 65 | ||
60 | /* read the eeprom using i2c */ | 66 | /* read the eeprom using i2c */ |
61 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header, | 67 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header, |
62 | sizeof(struct am335x_baseboard_id))) { | 68 | sizeof(struct am335x_baseboard_id))) { |
63 | puts("Could not read the EEPROM; something fundamentally" | 69 | puts("Could not read the EEPROM; something fundamentally" |
64 | " wrong on the I2C bus.\n"); | 70 | " wrong on the I2C bus.\n"); |
65 | return -EIO; | 71 | return -EIO; |
66 | } | 72 | } |
67 | 73 | ||
68 | if (header->magic != 0xEE3355AA) { | 74 | if (header->magic != 0xEE3355AA) { |
69 | /* | 75 | /* |
70 | * read the eeprom using i2c again, | 76 | * read the eeprom using i2c again, |
71 | * but use only a 1 byte address | 77 | * but use only a 1 byte address |
72 | */ | 78 | */ |
73 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header, | 79 | if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header, |
74 | sizeof(struct am335x_baseboard_id))) { | 80 | sizeof(struct am335x_baseboard_id))) { |
75 | puts("Could not read the EEPROM; something " | 81 | puts("Could not read the EEPROM; something " |
76 | "fundamentally wrong on the I2C bus.\n"); | 82 | "fundamentally wrong on the I2C bus.\n"); |
77 | return -EIO; | 83 | return -EIO; |
78 | } | 84 | } |
79 | 85 | ||
80 | if (header->magic != 0xEE3355AA) { | 86 | if (header->magic != 0xEE3355AA) { |
81 | printf("Incorrect magic number (0x%x) in EEPROM\n", | 87 | printf("Incorrect magic number (0x%x) in EEPROM\n", |
82 | header->magic); | 88 | header->magic); |
83 | return -EINVAL; | 89 | return -EINVAL; |
84 | } | 90 | } |
85 | } | 91 | } |
86 | 92 | ||
87 | return 0; | 93 | return 0; |
88 | } | 94 | } |
89 | 95 | ||
90 | /*#ifndef CONFIG_SKIP_LOWLEVEL_INIT*/ | 96 | /*#ifndef CONFIG_SKIP_LOWLEVEL_INIT*/ |
91 | #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT) | 97 | #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT) |
92 | static const struct ddr_data ddr2_data = { | 98 | static const struct ddr_data ddr2_data = { |
93 | .datardsratio0 = MT47H128M16RT25E_RD_DQS, | 99 | .datardsratio0 = MT47H128M16RT25E_RD_DQS, |
94 | .datafwsratio0 = MT47H128M16RT25E_PHY_FIFO_WE, | 100 | .datafwsratio0 = MT47H128M16RT25E_PHY_FIFO_WE, |
95 | .datawrsratio0 = MT47H128M16RT25E_PHY_WR_DATA, | 101 | .datawrsratio0 = MT47H128M16RT25E_PHY_WR_DATA, |
96 | }; | 102 | }; |
97 | 103 | ||
98 | static const struct cmd_control ddr2_cmd_ctrl_data = { | 104 | static const struct cmd_control ddr2_cmd_ctrl_data = { |
99 | .cmd0csratio = MT47H128M16RT25E_RATIO, | 105 | .cmd0csratio = MT47H128M16RT25E_RATIO, |
100 | 106 | ||
101 | .cmd1csratio = MT47H128M16RT25E_RATIO, | 107 | .cmd1csratio = MT47H128M16RT25E_RATIO, |
102 | 108 | ||
103 | .cmd2csratio = MT47H128M16RT25E_RATIO, | 109 | .cmd2csratio = MT47H128M16RT25E_RATIO, |
104 | }; | 110 | }; |
105 | 111 | ||
106 | static const struct emif_regs ddr2_emif_reg_data = { | 112 | static const struct emif_regs ddr2_emif_reg_data = { |
107 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, | 113 | .sdram_config = MT47H128M16RT25E_EMIF_SDCFG, |
108 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, | 114 | .ref_ctrl = MT47H128M16RT25E_EMIF_SDREF, |
109 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, | 115 | .sdram_tim1 = MT47H128M16RT25E_EMIF_TIM1, |
110 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, | 116 | .sdram_tim2 = MT47H128M16RT25E_EMIF_TIM2, |
111 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, | 117 | .sdram_tim3 = MT47H128M16RT25E_EMIF_TIM3, |
112 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, | 118 | .emif_ddr_phy_ctlr_1 = MT47H128M16RT25E_EMIF_READ_LATENCY, |
113 | }; | 119 | }; |
114 | 120 | ||
115 | static const struct ddr_data ddr3_data = { | 121 | static const struct ddr_data ddr3_data = { |
116 | .datardsratio0 = MT41J128MJT125_RD_DQS, | 122 | .datardsratio0 = MT41J128MJT125_RD_DQS, |
117 | .datawdsratio0 = MT41J128MJT125_WR_DQS, | 123 | .datawdsratio0 = MT41J128MJT125_WR_DQS, |
118 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE, | 124 | .datafwsratio0 = MT41J128MJT125_PHY_FIFO_WE, |
119 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA, | 125 | .datawrsratio0 = MT41J128MJT125_PHY_WR_DATA, |
120 | }; | 126 | }; |
121 | 127 | ||
122 | static const struct ddr_data ddr3_beagleblack_data = { | 128 | static const struct ddr_data ddr3_beagleblack_data = { |
123 | .datardsratio0 = MT41K256M16HA125E_RD_DQS, | 129 | .datardsratio0 = MT41K256M16HA125E_RD_DQS, |
124 | .datawdsratio0 = MT41K256M16HA125E_WR_DQS, | 130 | .datawdsratio0 = MT41K256M16HA125E_WR_DQS, |
125 | .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE, | 131 | .datafwsratio0 = MT41K256M16HA125E_PHY_FIFO_WE, |
126 | .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA, | 132 | .datawrsratio0 = MT41K256M16HA125E_PHY_WR_DATA, |
127 | }; | 133 | }; |
128 | 134 | ||
129 | static const struct ddr_data ddr3_smarct335x_data = { | 135 | static const struct ddr_data ddr3_smarct335x_data = { |
130 | .datardsratio0 = K4B4G1646EBYK0_RD_DQS, | 136 | .datardsratio0 = K4B4G1646EBYK0_RD_DQS, |
131 | .datawdsratio0 = K4B4G1646EBYK0_WR_DQS, | 137 | .datawdsratio0 = K4B4G1646EBYK0_WR_DQS, |
132 | .datafwsratio0 = K4B4G1646EBYK0_PHY_FIFO_WE, | 138 | .datafwsratio0 = K4B4G1646EBYK0_PHY_FIFO_WE, |
133 | .datawrsratio0 = K4B4G1646EBYK0_PHY_WR_DATA, | 139 | .datawrsratio0 = K4B4G1646EBYK0_PHY_WR_DATA, |
134 | }; | 140 | }; |
135 | 141 | ||
136 | static const struct ddr_data ddr3_smarct335x80_data = { | 142 | static const struct ddr_data ddr3_smarct335x80_data = { |
137 | .datardsratio0 = MT41K256M16HA125ITE_RD_DQS, | 143 | .datardsratio0 = MT41K256M16HA125ITE_RD_DQS, |
138 | .datawdsratio0 = MT41K256M16HA125ITE_WR_DQS, | 144 | .datawdsratio0 = MT41K256M16HA125ITE_WR_DQS, |
139 | .datafwsratio0 = MT41K256M16HA125ITE_PHY_FIFO_WE, | 145 | .datafwsratio0 = MT41K256M16HA125ITE_PHY_FIFO_WE, |
140 | .datawrsratio0 = MT41K256M16HA125ITE_PHY_WR_DATA, | 146 | .datawrsratio0 = MT41K256M16HA125ITE_PHY_WR_DATA, |
141 | }; | 147 | }; |
142 | 148 | ||
143 | static const struct ddr_data ddr3_evm_data = { | 149 | static const struct ddr_data ddr3_evm_data = { |
144 | .datardsratio0 = MT41J512M8RH125_RD_DQS, | 150 | .datardsratio0 = MT41J512M8RH125_RD_DQS, |
145 | .datawdsratio0 = MT41J512M8RH125_WR_DQS, | 151 | .datawdsratio0 = MT41J512M8RH125_WR_DQS, |
146 | .datafwsratio0 = MT41J512M8RH125_PHY_FIFO_WE, | 152 | .datafwsratio0 = MT41J512M8RH125_PHY_FIFO_WE, |
147 | .datawrsratio0 = MT41J512M8RH125_PHY_WR_DATA, | 153 | .datawrsratio0 = MT41J512M8RH125_PHY_WR_DATA, |
148 | }; | 154 | }; |
149 | 155 | ||
150 | static const struct cmd_control ddr3_cmd_ctrl_data = { | 156 | static const struct cmd_control ddr3_cmd_ctrl_data = { |
151 | .cmd0csratio = MT41J128MJT125_RATIO, | 157 | .cmd0csratio = MT41J128MJT125_RATIO, |
152 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT, | 158 | .cmd0iclkout = MT41J128MJT125_INVERT_CLKOUT, |
153 | 159 | ||
154 | .cmd1csratio = MT41J128MJT125_RATIO, | 160 | .cmd1csratio = MT41J128MJT125_RATIO, |
155 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT, | 161 | .cmd1iclkout = MT41J128MJT125_INVERT_CLKOUT, |
156 | 162 | ||
157 | .cmd2csratio = MT41J128MJT125_RATIO, | 163 | .cmd2csratio = MT41J128MJT125_RATIO, |
158 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT, | 164 | .cmd2iclkout = MT41J128MJT125_INVERT_CLKOUT, |
159 | }; | 165 | }; |
160 | 166 | ||
161 | static const struct cmd_control ddr3_beagleblack_cmd_ctrl_data = { | 167 | static const struct cmd_control ddr3_beagleblack_cmd_ctrl_data = { |
162 | .cmd0csratio = MT41K256M16HA125E_RATIO, | 168 | .cmd0csratio = MT41K256M16HA125E_RATIO, |
163 | .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 169 | .cmd0iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
164 | 170 | ||
165 | .cmd1csratio = MT41K256M16HA125E_RATIO, | 171 | .cmd1csratio = MT41K256M16HA125E_RATIO, |
166 | .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 172 | .cmd1iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
167 | 173 | ||
168 | .cmd2csratio = MT41K256M16HA125E_RATIO, | 174 | .cmd2csratio = MT41K256M16HA125E_RATIO, |
169 | .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT, | 175 | .cmd2iclkout = MT41K256M16HA125E_INVERT_CLKOUT, |
170 | }; | 176 | }; |
171 | 177 | ||
172 | static const struct cmd_control ddr3_smarct335x_cmd_ctrl_data = { | 178 | static const struct cmd_control ddr3_smarct335x_cmd_ctrl_data = { |
173 | .cmd0csratio = K4B4G1646EBYK0_RATIO, | 179 | .cmd0csratio = K4B4G1646EBYK0_RATIO, |
174 | .cmd0iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, | 180 | .cmd0iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, |
175 | 181 | ||
176 | .cmd1csratio = K4B4G1646EBYK0_RATIO, | 182 | .cmd1csratio = K4B4G1646EBYK0_RATIO, |
177 | .cmd1iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, | 183 | .cmd1iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, |
178 | 184 | ||
179 | .cmd2csratio = K4B4G1646EBYK0_RATIO, | 185 | .cmd2csratio = K4B4G1646EBYK0_RATIO, |
180 | .cmd2iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, | 186 | .cmd2iclkout = K4B4G1646EBYK0_INVERT_CLKOUT, |
181 | }; | 187 | }; |
182 | 188 | ||
183 | static const struct cmd_control ddr3_smarct335x80_cmd_ctrl_data = { | 189 | static const struct cmd_control ddr3_smarct335x80_cmd_ctrl_data = { |
184 | .cmd0csratio = MT41K256M16HA125ITE_RATIO, | 190 | .cmd0csratio = MT41K256M16HA125ITE_RATIO, |
185 | .cmd0iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, | 191 | .cmd0iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, |
186 | 192 | ||
187 | .cmd1csratio = MT41K256M16HA125ITE_RATIO, | 193 | .cmd1csratio = MT41K256M16HA125ITE_RATIO, |
188 | .cmd1iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, | 194 | .cmd1iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, |
189 | 195 | ||
190 | .cmd2csratio = MT41K256M16HA125ITE_RATIO, | 196 | .cmd2csratio = MT41K256M16HA125ITE_RATIO, |
191 | .cmd2iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, | 197 | .cmd2iclkout = MT41K256M16HA125ITE_INVERT_CLKOUT, |
192 | }; | 198 | }; |
193 | 199 | ||
194 | static const struct cmd_control ddr3_evm_cmd_ctrl_data = { | 200 | static const struct cmd_control ddr3_evm_cmd_ctrl_data = { |
195 | .cmd0csratio = MT41J512M8RH125_RATIO, | 201 | .cmd0csratio = MT41J512M8RH125_RATIO, |
196 | .cmd0iclkout = MT41J512M8RH125_INVERT_CLKOUT, | 202 | .cmd0iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
197 | 203 | ||
198 | .cmd1csratio = MT41J512M8RH125_RATIO, | 204 | .cmd1csratio = MT41J512M8RH125_RATIO, |
199 | .cmd1iclkout = MT41J512M8RH125_INVERT_CLKOUT, | 205 | .cmd1iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
200 | 206 | ||
201 | .cmd2csratio = MT41J512M8RH125_RATIO, | 207 | .cmd2csratio = MT41J512M8RH125_RATIO, |
202 | .cmd2iclkout = MT41J512M8RH125_INVERT_CLKOUT, | 208 | .cmd2iclkout = MT41J512M8RH125_INVERT_CLKOUT, |
203 | }; | 209 | }; |
204 | 210 | ||
205 | static struct emif_regs ddr3_emif_reg_data = { | 211 | static struct emif_regs ddr3_emif_reg_data = { |
206 | .sdram_config = MT41J128MJT125_EMIF_SDCFG, | 212 | .sdram_config = MT41J128MJT125_EMIF_SDCFG, |
207 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF, | 213 | .ref_ctrl = MT41J128MJT125_EMIF_SDREF, |
208 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1, | 214 | .sdram_tim1 = MT41J128MJT125_EMIF_TIM1, |
209 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2, | 215 | .sdram_tim2 = MT41J128MJT125_EMIF_TIM2, |
210 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3, | 216 | .sdram_tim3 = MT41J128MJT125_EMIF_TIM3, |
211 | .zq_config = MT41J128MJT125_ZQ_CFG, | 217 | .zq_config = MT41J128MJT125_ZQ_CFG, |
212 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY | | 218 | .emif_ddr_phy_ctlr_1 = MT41J128MJT125_EMIF_READ_LATENCY | |
213 | PHY_EN_DYN_PWRDN, | 219 | PHY_EN_DYN_PWRDN, |
214 | }; | 220 | }; |
215 | 221 | ||
216 | static struct emif_regs ddr3_beagleblack_emif_reg_data = { | 222 | static struct emif_regs ddr3_beagleblack_emif_reg_data = { |
217 | .sdram_config = MT41K256M16HA125E_EMIF_SDCFG, | 223 | .sdram_config = MT41K256M16HA125E_EMIF_SDCFG, |
218 | .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF, | 224 | .ref_ctrl = MT41K256M16HA125E_EMIF_SDREF, |
219 | .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1, | 225 | .sdram_tim1 = MT41K256M16HA125E_EMIF_TIM1, |
220 | .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2, | 226 | .sdram_tim2 = MT41K256M16HA125E_EMIF_TIM2, |
221 | .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3, | 227 | .sdram_tim3 = MT41K256M16HA125E_EMIF_TIM3, |
222 | .zq_config = MT41K256M16HA125E_ZQ_CFG, | 228 | .zq_config = MT41K256M16HA125E_ZQ_CFG, |
223 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY, | 229 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125E_EMIF_READ_LATENCY, |
224 | }; | 230 | }; |
225 | 231 | ||
226 | static struct emif_regs ddr3_smarct335x_emif_reg_data = { | 232 | static struct emif_regs ddr3_smarct335x_emif_reg_data = { |
227 | .sdram_config = K4B4G1646EBYK0_EMIF_SDCFG, | 233 | .sdram_config = K4B4G1646EBYK0_EMIF_SDCFG, |
228 | .ref_ctrl = K4B4G1646EBYK0_EMIF_SDREF, | 234 | .ref_ctrl = K4B4G1646EBYK0_EMIF_SDREF, |
229 | .sdram_tim1 = K4B4G1646EBYK0_EMIF_TIM1, | 235 | .sdram_tim1 = K4B4G1646EBYK0_EMIF_TIM1, |
230 | .sdram_tim2 = K4B4G1646EBYK0_EMIF_TIM2, | 236 | .sdram_tim2 = K4B4G1646EBYK0_EMIF_TIM2, |
231 | .sdram_tim3 = K4B4G1646EBYK0_EMIF_TIM3, | 237 | .sdram_tim3 = K4B4G1646EBYK0_EMIF_TIM3, |
232 | .zq_config = K4B4G1646EBYK0_ZQ_CFG, | 238 | .zq_config = K4B4G1646EBYK0_ZQ_CFG, |
233 | .emif_ddr_phy_ctlr_1 = K4B4G1646EBYK0_EMIF_READ_LATENCY, | 239 | .emif_ddr_phy_ctlr_1 = K4B4G1646EBYK0_EMIF_READ_LATENCY, |
234 | }; | 240 | }; |
235 | 241 | ||
236 | static struct emif_regs ddr3_smarct335x80_emif_reg_data = { | 242 | static struct emif_regs ddr3_smarct335x80_emif_reg_data = { |
237 | .sdram_config = MT41K256M16HA125ITE_EMIF_SDCFG, | 243 | .sdram_config = MT41K256M16HA125ITE_EMIF_SDCFG, |
238 | .ref_ctrl = MT41K256M16HA125ITE_EMIF_SDREF, | 244 | .ref_ctrl = MT41K256M16HA125ITE_EMIF_SDREF, |
239 | .sdram_tim1 = MT41K256M16HA125ITE_EMIF_TIM1, | 245 | .sdram_tim1 = MT41K256M16HA125ITE_EMIF_TIM1, |
240 | .sdram_tim2 = MT41K256M16HA125ITE_EMIF_TIM2, | 246 | .sdram_tim2 = MT41K256M16HA125ITE_EMIF_TIM2, |
241 | .sdram_tim3 = MT41K256M16HA125ITE_EMIF_TIM3, | 247 | .sdram_tim3 = MT41K256M16HA125ITE_EMIF_TIM3, |
242 | .zq_config = MT41K256M16HA125ITE_ZQ_CFG, | 248 | .zq_config = MT41K256M16HA125ITE_ZQ_CFG, |
243 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125ITE_EMIF_READ_LATENCY, | 249 | .emif_ddr_phy_ctlr_1 = MT41K256M16HA125ITE_EMIF_READ_LATENCY, |
244 | }; | 250 | }; |
245 | 251 | ||
246 | static struct emif_regs ddr3_evm_emif_reg_data = { | 252 | static struct emif_regs ddr3_evm_emif_reg_data = { |
247 | .sdram_config = MT41J512M8RH125_EMIF_SDCFG, | 253 | .sdram_config = MT41J512M8RH125_EMIF_SDCFG, |
248 | .ref_ctrl = MT41J512M8RH125_EMIF_SDREF, | 254 | .ref_ctrl = MT41J512M8RH125_EMIF_SDREF, |
249 | .sdram_tim1 = MT41J512M8RH125_EMIF_TIM1, | 255 | .sdram_tim1 = MT41J512M8RH125_EMIF_TIM1, |
250 | .sdram_tim2 = MT41J512M8RH125_EMIF_TIM2, | 256 | .sdram_tim2 = MT41J512M8RH125_EMIF_TIM2, |
251 | .sdram_tim3 = MT41J512M8RH125_EMIF_TIM3, | 257 | .sdram_tim3 = MT41J512M8RH125_EMIF_TIM3, |
252 | .zq_config = MT41J512M8RH125_ZQ_CFG, | 258 | .zq_config = MT41J512M8RH125_ZQ_CFG, |
253 | .emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY | | 259 | .emif_ddr_phy_ctlr_1 = MT41J512M8RH125_EMIF_READ_LATENCY | |
254 | PHY_EN_DYN_PWRDN, | 260 | PHY_EN_DYN_PWRDN, |
255 | }; | 261 | }; |
256 | 262 | ||
257 | #ifdef CONFIG_SPL_OS_BOOT | 263 | #ifdef CONFIG_SPL_OS_BOOT |
258 | int spl_start_uboot(void) | 264 | int spl_start_uboot(void) |
259 | { | 265 | { |
260 | /* break into full u-boot on 'c' */ | 266 | /* break into full u-boot on 'c' */ |
261 | if (serial_tstc() && serial_getc() == 'c') | 267 | if (serial_tstc() && serial_getc() == 'c') |
262 | return 1; | 268 | return 1; |
263 | 269 | ||
264 | #ifdef CONFIG_SPL_ENV_SUPPORT | 270 | #ifdef CONFIG_SPL_ENV_SUPPORT |
265 | env_init(); | 271 | env_init(); |
266 | env_relocate_spec(); | 272 | env_relocate_spec(); |
267 | if (getenv_yesno("boot_os") != 1) | 273 | if (getenv_yesno("boot_os") != 1) |
268 | return 1; | 274 | return 1; |
269 | #endif | 275 | #endif |
270 | 276 | ||
271 | return 0; | 277 | return 0; |
272 | } | 278 | } |
273 | #endif | 279 | #endif |
274 | 280 | ||
275 | #define OSC (V_OSCK/1000000) | 281 | #define OSC (V_OSCK/1000000) |
276 | const struct dpll_params dpll_ddr = { | 282 | const struct dpll_params dpll_ddr = { |
277 | 266, OSC-1, 1, -1, -1, -1, -1}; | 283 | 266, OSC-1, 1, -1, -1, -1, -1}; |
278 | const struct dpll_params dpll_ddr_evm_sk = { | 284 | const struct dpll_params dpll_ddr_evm_sk = { |
279 | 303, OSC-1, 1, -1, -1, -1, -1}; | 285 | 303, OSC-1, 1, -1, -1, -1, -1}; |
280 | const struct dpll_params dpll_ddr_bone_black = { | 286 | const struct dpll_params dpll_ddr_bone_black = { |
281 | 400, OSC-1, 1, -1, -1, -1, -1}; | 287 | 400, OSC-1, 1, -1, -1, -1, -1}; |
282 | const struct dpll_params dpll_ddr_smarc_t335x = { | 288 | const struct dpll_params dpll_ddr_smarc_t335x = { |
283 | 400, OSC-1, 1, -1, -1, -1, -1}; | 289 | 400, OSC-1, 1, -1, -1, -1, -1}; |
284 | 290 | ||
285 | void am33xx_spl_board_init(void) | 291 | void am33xx_spl_board_init(void) |
286 | { | 292 | { |
287 | struct am335x_baseboard_id header; | 293 | struct am335x_baseboard_id header; |
288 | int mpu_vdd; | 294 | int mpu_vdd; |
289 | 295 | ||
290 | if (read_eeprom(&header) < 0) | 296 | if (read_eeprom(&header) < 0) |
291 | puts("Could not get board ID.\n"); | 297 | puts("Could not get board ID.\n"); |
292 | 298 | ||
293 | /* Get the frequency */ | 299 | /* Get the frequency */ |
294 | dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev); | 300 | dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev); |
295 | 301 | ||
296 | if (board_is_bone(&header) || board_is_bone_lt(&header) || board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { | 302 | if (board_is_bone(&header) || board_is_bone_lt(&header) || board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { |
297 | /* BeagleBone PMIC Code */ | 303 | /* BeagleBone PMIC Code */ |
298 | int usb_cur_lim; | 304 | int usb_cur_lim; |
299 | 305 | ||
300 | /* | 306 | /* |
301 | * Only perform PMIC configurations if board rev > A1 | 307 | * Only perform PMIC configurations if board rev > A1 |
302 | * on Beaglebone White | 308 | * on Beaglebone White |
303 | */ | 309 | */ |
304 | if (board_is_bone(&header) && !strncmp(header.version, | 310 | if (board_is_bone(&header) && !strncmp(header.version, |
305 | "00A1", 4)) | 311 | "00A1", 4)) |
306 | return; | 312 | return; |
307 | 313 | ||
308 | if (i2c_probe(TPS65217_CHIP_PM)) | 314 | if (i2c_probe(TPS65217_CHIP_PM)) |
309 | return; | 315 | return; |
310 | 316 | ||
311 | /* | 317 | /* |
312 | * On Beaglebone White we need to ensure we have AC power | 318 | * On Beaglebone White we need to ensure we have AC power |
313 | * before increasing the frequency. | 319 | * before increasing the frequency. |
314 | */ | 320 | */ |
315 | if (board_is_bone(&header)) { | 321 | if (board_is_bone(&header)) { |
316 | uchar pmic_status_reg; | 322 | uchar pmic_status_reg; |
317 | if (tps65217_reg_read(TPS65217_STATUS, | 323 | if (tps65217_reg_read(TPS65217_STATUS, |
318 | &pmic_status_reg)) | 324 | &pmic_status_reg)) |
319 | return; | 325 | return; |
320 | if (!(pmic_status_reg & TPS65217_PWR_SRC_AC_BITMASK)) { | 326 | if (!(pmic_status_reg & TPS65217_PWR_SRC_AC_BITMASK)) { |
321 | puts("No AC power, disabling frequency switch\n"); | 327 | puts("No AC power, disabling frequency switch\n"); |
322 | return; | 328 | return; |
323 | } | 329 | } |
324 | } | 330 | } |
325 | 331 | ||
326 | /* | 332 | /* |
327 | * Override what we have detected since we know if we have | 333 | * Override what we have detected since we know if we have |
328 | * a Beaglebone Black it supports 1GHz. | 334 | * a Beaglebone Black it supports 1GHz. |
329 | */ | 335 | */ |
330 | if ((board_is_bone_lt(&header) || board_is_smarc_t335x_1g(&header))) | 336 | if ((board_is_bone_lt(&header) || board_is_smarc_t335x_1g(&header))) |
331 | dpll_mpu_opp100.m = MPUPLL_M_1000; | 337 | dpll_mpu_opp100.m = MPUPLL_M_1000; |
332 | 338 | ||
333 | /* | 339 | /* |
334 | * Increase USB current limit to 1300mA or 1800mA and set | 340 | * Increase USB current limit to 1300mA or 1800mA and set |
335 | * the MPU voltage controller as needed. | 341 | * the MPU voltage controller as needed. |
336 | */ | 342 | */ |
337 | if (dpll_mpu_opp100.m == MPUPLL_M_1000) { | 343 | if (dpll_mpu_opp100.m == MPUPLL_M_1000) { |
338 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA; | 344 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA; |
339 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV; | 345 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV; |
340 | } else { | 346 | } else { |
341 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; | 347 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
342 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV; | 348 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV; |
343 | } | 349 | } |
344 | 350 | ||
345 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, | 351 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, |
346 | TPS65217_POWER_PATH, | 352 | TPS65217_POWER_PATH, |
347 | usb_cur_lim, | 353 | usb_cur_lim, |
348 | TPS65217_USB_INPUT_CUR_LIMIT_MASK)) | 354 | TPS65217_USB_INPUT_CUR_LIMIT_MASK)) |
349 | puts("tps65217_reg_write failure\n"); | 355 | puts("tps65217_reg_write failure\n"); |
350 | 356 | ||
351 | /* Set DCDC3 (CORE) voltage to 1.125V */ | 357 | /* Set DCDC3 (CORE) voltage to 1.125V */ |
352 | if (tps65217_voltage_update(TPS65217_DEFDCDC3, | 358 | if (tps65217_voltage_update(TPS65217_DEFDCDC3, |
353 | TPS65217_DCDC_VOLT_SEL_1125MV)) { | 359 | TPS65217_DCDC_VOLT_SEL_1125MV)) { |
354 | puts("tps65217_voltage_update failure\n"); | 360 | puts("tps65217_voltage_update failure\n"); |
355 | return; | 361 | return; |
356 | } | 362 | } |
357 | 363 | ||
358 | /* Set CORE Frequencies to OPP100 */ | 364 | /* Set CORE Frequencies to OPP100 */ |
359 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); | 365 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); |
360 | 366 | ||
361 | /* Set DCDC2 (MPU) voltage */ | 367 | /* Set DCDC2 (MPU) voltage */ |
362 | if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) { | 368 | if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) { |
363 | puts("tps65217_voltage_update failure\n"); | 369 | puts("tps65217_voltage_update failure\n"); |
364 | return; | 370 | return; |
365 | } | 371 | } |
366 | 372 | ||
367 | /* | 373 | /* |
368 | * Set LDO3, LDO4 output voltage to 3.3V for Beaglebone. | 374 | * Set LDO3, LDO4 output voltage to 3.3V for Beaglebone. |
369 | * Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black. | 375 | * Set LDO3 to 1.8V and LDO4 to 3.3V for Beaglebone Black. |
370 | */ | 376 | */ |
371 | if (board_is_bone(&header)) { | 377 | if (board_is_bone(&header)) { |
372 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, | 378 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
373 | TPS65217_DEFLS1, | 379 | TPS65217_DEFLS1, |
374 | TPS65217_LDO_VOLTAGE_OUT_3_3, | 380 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
375 | TPS65217_LDO_MASK)) | 381 | TPS65217_LDO_MASK)) |
376 | puts("tps65217_reg_write failure\n"); | 382 | puts("tps65217_reg_write failure\n"); |
377 | } else { | 383 | } else { |
378 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, | 384 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
379 | TPS65217_DEFLS1, | 385 | TPS65217_DEFLS1, |
380 | TPS65217_LDO_VOLTAGE_OUT_1_8, | 386 | TPS65217_LDO_VOLTAGE_OUT_1_8, |
381 | TPS65217_LDO_MASK)) | 387 | TPS65217_LDO_MASK)) |
382 | puts("tps65217_reg_write failure\n"); | 388 | puts("tps65217_reg_write failure\n"); |
383 | } | 389 | } |
384 | 390 | ||
385 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, | 391 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
386 | TPS65217_DEFLS2, | 392 | TPS65217_DEFLS2, |
387 | TPS65217_LDO_VOLTAGE_OUT_3_3, | 393 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
388 | TPS65217_LDO_MASK)) | 394 | TPS65217_LDO_MASK)) |
389 | puts("tps65217_reg_write failure\n"); | 395 | puts("tps65217_reg_write failure\n"); |
390 | } else { | 396 | } else { |
391 | int sil_rev; | 397 | int sil_rev; |
392 | 398 | ||
393 | /* | 399 | /* |
394 | * The GP EVM, IDK and EVM SK use a TPS65910 PMIC. For all | 400 | * The GP EVM, IDK and EVM SK use a TPS65910 PMIC. For all |
395 | * MPU frequencies we support we use a CORE voltage of | 401 | * MPU frequencies we support we use a CORE voltage of |
396 | * 1.1375V. For MPU voltage we need to switch based on | 402 | * 1.1375V. For MPU voltage we need to switch based on |
397 | * the frequency we are running at. | 403 | * the frequency we are running at. |
398 | */ | 404 | */ |
399 | if (i2c_probe(TPS65910_CTRL_I2C_ADDR)) | 405 | if (i2c_probe(TPS65910_CTRL_I2C_ADDR)) |
400 | return; | 406 | return; |
401 | 407 | ||
402 | /* | 408 | /* |
403 | * Depending on MPU clock and PG we will need a different | 409 | * Depending on MPU clock and PG we will need a different |
404 | * VDD to drive at that speed. | 410 | * VDD to drive at that speed. |
405 | */ | 411 | */ |
406 | sil_rev = readl(&cdev->deviceid) >> 28; | 412 | sil_rev = readl(&cdev->deviceid) >> 28; |
407 | mpu_vdd = am335x_get_tps65910_mpu_vdd(sil_rev, | 413 | mpu_vdd = am335x_get_tps65910_mpu_vdd(sil_rev, |
408 | dpll_mpu_opp100.m); | 414 | dpll_mpu_opp100.m); |
409 | 415 | ||
410 | /* Tell the TPS65910 to use i2c */ | 416 | /* Tell the TPS65910 to use i2c */ |
411 | tps65910_set_i2c_control(); | 417 | tps65910_set_i2c_control(); |
412 | 418 | ||
413 | /* First update MPU voltage. */ | 419 | /* First update MPU voltage. */ |
414 | if (tps65910_voltage_update(MPU, mpu_vdd)) | 420 | if (tps65910_voltage_update(MPU, mpu_vdd)) |
415 | return; | 421 | return; |
416 | 422 | ||
417 | /* Second, update the CORE voltage. */ | 423 | /* Second, update the CORE voltage. */ |
418 | if (tps65910_voltage_update(CORE, TPS65910_OP_REG_SEL_1_1_3)) | 424 | if (tps65910_voltage_update(CORE, TPS65910_OP_REG_SEL_1_1_3)) |
419 | return; | 425 | return; |
420 | 426 | ||
421 | /* Set CORE Frequencies to OPP100 */ | 427 | /* Set CORE Frequencies to OPP100 */ |
422 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); | 428 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); |
423 | } | 429 | } |
424 | 430 | ||
425 | /* Set MPU Frequency to what we detected now that voltages are set */ | 431 | /* Set MPU Frequency to what we detected now that voltages are set */ |
426 | do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); | 432 | do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); |
427 | } | 433 | } |
428 | 434 | ||
429 | const struct dpll_params *get_dpll_ddr_params(void) | 435 | const struct dpll_params *get_dpll_ddr_params(void) |
430 | { | 436 | { |
431 | struct am335x_baseboard_id header; | 437 | struct am335x_baseboard_id header; |
432 | 438 | ||
433 | enable_i2c0_pin_mux(); | 439 | enable_i2c0_pin_mux(); |
434 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); | 440 | i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); |
435 | if (read_eeprom(&header) < 0) | 441 | if (read_eeprom(&header) < 0) |
436 | puts("Could not get board ID.\n"); | 442 | puts("Could not get board ID.\n"); |
437 | 443 | ||
438 | if (board_is_evm_sk(&header)) | 444 | if (board_is_evm_sk(&header)) |
439 | return &dpll_ddr_evm_sk; | 445 | return &dpll_ddr_evm_sk; |
440 | else if (board_is_bone_lt(&header)) | 446 | else if (board_is_bone_lt(&header)) |
441 | return &dpll_ddr_bone_black; | 447 | return &dpll_ddr_bone_black; |
442 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) | 448 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) |
443 | return &dpll_ddr_smarc_t335x; | 449 | return &dpll_ddr_smarc_t335x; |
444 | else if (board_is_evm_15_or_later(&header)) | 450 | else if (board_is_evm_15_or_later(&header)) |
445 | return &dpll_ddr_evm_sk; | 451 | return &dpll_ddr_evm_sk; |
446 | else | 452 | else |
447 | return &dpll_ddr; | 453 | return &dpll_ddr; |
448 | } | 454 | } |
449 | 455 | ||
450 | void set_uart_mux_conf(void) | 456 | void set_uart_mux_conf(void) |
451 | { | 457 | { |
452 | #if CONFIG_CONS_INDEX == 1 | 458 | #if CONFIG_CONS_INDEX == 1 |
453 | enable_uart0_pin_mux(); | 459 | enable_uart0_pin_mux(); |
454 | #elif CONFIG_CONS_INDEX == 2 | 460 | #elif CONFIG_CONS_INDEX == 2 |
455 | enable_uart1_pin_mux(); | 461 | enable_uart1_pin_mux(); |
456 | #elif CONFIG_CONS_INDEX == 3 | 462 | #elif CONFIG_CONS_INDEX == 3 |
457 | enable_uart2_pin_mux(); | 463 | enable_uart2_pin_mux(); |
458 | #elif CONFIG_CONS_INDEX == 4 | 464 | #elif CONFIG_CONS_INDEX == 4 |
459 | enable_uart3_pin_mux(); | 465 | enable_uart3_pin_mux(); |
460 | #elif CONFIG_CONS_INDEX == 5 | 466 | #elif CONFIG_CONS_INDEX == 5 |
461 | enable_uart4_pin_mux(); | 467 | enable_uart4_pin_mux(); |
462 | #elif CONFIG_CONS_INDEX == 6 | 468 | #elif CONFIG_CONS_INDEX == 6 |
463 | enable_uart5_pin_mux(); | 469 | enable_uart5_pin_mux(); |
464 | #endif | 470 | #endif |
465 | } | 471 | } |
466 | 472 | ||
467 | void set_mux_conf_regs(void) | 473 | void set_mux_conf_regs(void) |
468 | { | 474 | { |
469 | __maybe_unused struct am335x_baseboard_id header; | 475 | __maybe_unused struct am335x_baseboard_id header; |
470 | 476 | ||
471 | if (read_eeprom(&header) < 0) | 477 | if (read_eeprom(&header) < 0) |
472 | puts("Could not get board ID.\n"); | 478 | puts("Could not get board ID.\n"); |
473 | 479 | ||
474 | enable_board_pin_mux(&header); | 480 | enable_board_pin_mux(&header); |
475 | } | 481 | } |
476 | 482 | ||
477 | const struct ctrl_ioregs ioregs_evmsk = { | 483 | const struct ctrl_ioregs ioregs_evmsk = { |
478 | .cm0ioctl = MT41J128MJT125_IOCTRL_VALUE, | 484 | .cm0ioctl = MT41J128MJT125_IOCTRL_VALUE, |
479 | .cm1ioctl = MT41J128MJT125_IOCTRL_VALUE, | 485 | .cm1ioctl = MT41J128MJT125_IOCTRL_VALUE, |
480 | .cm2ioctl = MT41J128MJT125_IOCTRL_VALUE, | 486 | .cm2ioctl = MT41J128MJT125_IOCTRL_VALUE, |
481 | .dt0ioctl = MT41J128MJT125_IOCTRL_VALUE, | 487 | .dt0ioctl = MT41J128MJT125_IOCTRL_VALUE, |
482 | .dt1ioctl = MT41J128MJT125_IOCTRL_VALUE, | 488 | .dt1ioctl = MT41J128MJT125_IOCTRL_VALUE, |
483 | }; | 489 | }; |
484 | 490 | ||
485 | const struct ctrl_ioregs ioregs_bonelt = { | 491 | const struct ctrl_ioregs ioregs_bonelt = { |
486 | .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 492 | .cm0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
487 | .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 493 | .cm1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
488 | .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 494 | .cm2ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
489 | .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 495 | .dt0ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
490 | .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, | 496 | .dt1ioctl = MT41K256M16HA125E_IOCTRL_VALUE, |
491 | }; | 497 | }; |
492 | 498 | ||
493 | const struct ctrl_ioregs ioregs_smarct335x = { | 499 | const struct ctrl_ioregs ioregs_smarct335x = { |
494 | .cm0ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, | 500 | .cm0ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
495 | .cm1ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, | 501 | .cm1ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
496 | .cm2ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, | 502 | .cm2ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
497 | .dt0ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, | 503 | .dt0ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
498 | .dt1ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, | 504 | .dt1ioctl = K4B4G1646EBYK0_IOCTRL_VALUE, |
499 | }; | 505 | }; |
500 | 506 | ||
501 | const struct ctrl_ioregs ioregs_smarct335x80 = { | 507 | const struct ctrl_ioregs ioregs_smarct335x80 = { |
502 | .cm0ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | 508 | .cm0ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, |
503 | .cm1ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | 509 | .cm1ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, |
504 | .cm2ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | 510 | .cm2ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, |
505 | .dt0ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | 511 | .dt0ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, |
506 | .dt1ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, | 512 | .dt1ioctl = MT41K256M16HA125ITE_IOCTRL_VALUE, |
507 | }; | 513 | }; |
508 | 514 | ||
509 | const struct ctrl_ioregs ioregs_evm15 = { | 515 | const struct ctrl_ioregs ioregs_evm15 = { |
510 | .cm0ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 516 | .cm0ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
511 | .cm1ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 517 | .cm1ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
512 | .cm2ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 518 | .cm2ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
513 | .dt0ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 519 | .dt0ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
514 | .dt1ioctl = MT41J512M8RH125_IOCTRL_VALUE, | 520 | .dt1ioctl = MT41J512M8RH125_IOCTRL_VALUE, |
515 | }; | 521 | }; |
516 | 522 | ||
517 | const struct ctrl_ioregs ioregs = { | 523 | const struct ctrl_ioregs ioregs = { |
518 | .cm0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 524 | .cm0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
519 | .cm1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 525 | .cm1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
520 | .cm2ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 526 | .cm2ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
521 | .dt0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 527 | .dt0ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
522 | .dt1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, | 528 | .dt1ioctl = MT47H128M16RT25E_IOCTRL_VALUE, |
523 | }; | 529 | }; |
524 | 530 | ||
525 | void sdram_init(void) | 531 | void sdram_init(void) |
526 | { | 532 | { |
527 | __maybe_unused struct am335x_baseboard_id header; | 533 | __maybe_unused struct am335x_baseboard_id header; |
528 | 534 | ||
529 | if (read_eeprom(&header) < 0) | 535 | if (read_eeprom(&header) < 0) |
530 | puts("Could not get board ID.\n"); | 536 | puts("Could not get board ID.\n"); |
531 | 537 | ||
532 | if (board_is_evm_sk(&header)) { | 538 | if (board_is_evm_sk(&header)) { |
533 | /* | 539 | /* |
534 | * EVM SK 1.2A and later use gpio0_7 to enable DDR3. | 540 | * EVM SK 1.2A and later use gpio0_7 to enable DDR3. |
535 | * This is safe enough to do on older revs. | 541 | * This is safe enough to do on older revs. |
536 | */ | 542 | */ |
537 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); | 543 | gpio_request(GPIO_DDR_VTT_EN, "ddr_vtt_en"); |
538 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); | 544 | gpio_direction_output(GPIO_DDR_VTT_EN, 1); |
539 | } | 545 | } |
540 | 546 | ||
541 | if (board_is_evm_sk(&header)) | 547 | if (board_is_evm_sk(&header)) |
542 | config_ddr(303, &ioregs_evmsk, &ddr3_data, | 548 | config_ddr(303, &ioregs_evmsk, &ddr3_data, |
543 | &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); | 549 | &ddr3_cmd_ctrl_data, &ddr3_emif_reg_data, 0); |
544 | else if (board_is_bone_lt(&header)) | 550 | else if (board_is_bone_lt(&header)) |
545 | config_ddr(400, &ioregs_bonelt, | 551 | config_ddr(400, &ioregs_bonelt, |
546 | &ddr3_beagleblack_data, | 552 | &ddr3_beagleblack_data, |
547 | &ddr3_beagleblack_cmd_ctrl_data, | 553 | &ddr3_beagleblack_cmd_ctrl_data, |
548 | &ddr3_beagleblack_emif_reg_data, 0); | 554 | &ddr3_beagleblack_emif_reg_data, 0); |
549 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_1g(&header)) { | 555 | else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_1g(&header)) { |
550 | /* | 556 | /* |
551 | * SMARC T335X rev. 00B0 and later use gpio0_7 as LCD backlight PWM and gpio1_22 as LCD backlight enable. | 557 | * SMARC T335X rev. 00B0 and later use gpio0_7 as LCD backlight PWM and gpio1_22 as LCD backlight enable. |
552 | * This is safe enough to do on older revs. | 558 | * This is safe enough to do on older revs. |
553 | */ | 559 | */ |
554 | gpio_request(GPIO_LCD_BKLT_EN, "lcd_bklt_en"); | 560 | gpio_request(GPIO_WDT_EN, "wdt_en"); |
555 | gpio_direction_output(GPIO_LCD_BKLT_EN, 1); | 561 | gpio_direction_output(GPIO_WDT_EN, 0); |
556 | gpio_request(GPIO_LCD_PWM_EN, "lcd_pwm_en"); | 562 | gpio_request(GPIO_SER_INT, "ser_int"); |
557 | gpio_direction_output(GPIO_LCD_PWM_EN, 1); | 563 | gpio_direction_input(GPIO_SER_INT); |
558 | config_ddr(400, &ioregs_smarct335x, | 564 | config_ddr(400, &ioregs_smarct335x, |
559 | &ddr3_smarct335x_data, | 565 | &ddr3_smarct335x_data, |
560 | &ddr3_smarct335x_cmd_ctrl_data, | 566 | &ddr3_smarct335x_cmd_ctrl_data, |
561 | &ddr3_smarct335x_emif_reg_data, 0); | 567 | &ddr3_smarct335x_emif_reg_data, 0); |
562 | udelay(3600); | 568 | udelay(3600); |
563 | } | 569 | } |
564 | else if (board_is_smarc_t335x_80(&header)) { | 570 | else if (board_is_smarc_t335x_80(&header)) { |
565 | /* | 571 | /* |
566 | * SMARC T335X rev. 00B0 and later use gpio0_7 as LCD backlight PWM and gpio1_22 as LCD backlight enable. | 572 | * SMARC T335X rev. 00B0 and later use gpio0_7 as LCD backlight PWM and gpio1_22 as LCD backlight enable. |
567 | * This is safe enough to do on older revs. | 573 | * This is safe enough to do on older revs. |
568 | */ | 574 | */ |
569 | gpio_request(GPIO_LCD_BKLT_EN, "lcd_bklt_en"); | 575 | gpio_request(GPIO_LCD_BKLT_EN, "lcd_bklt_en"); |
570 | gpio_direction_output(GPIO_LCD_BKLT_EN, 1); | 576 | gpio_direction_output(GPIO_LCD_BKLT_EN, 1); |
571 | gpio_request(GPIO_LCD_PWM_EN, "lcd_pwm_en"); | 577 | gpio_request(GPIO_LCD_PWM_EN, "lcd_pwm_en"); |
572 | gpio_direction_output(GPIO_LCD_PWM_EN, 1); | 578 | gpio_direction_output(GPIO_LCD_PWM_EN, 1); |
573 | config_ddr(400, &ioregs_smarct335x80, | 579 | config_ddr(400, &ioregs_smarct335x80, |
574 | &ddr3_smarct335x80_data, | 580 | &ddr3_smarct335x80_data, |
575 | &ddr3_smarct335x80_cmd_ctrl_data, | 581 | &ddr3_smarct335x80_cmd_ctrl_data, |
576 | &ddr3_smarct335x80_emif_reg_data, 0); | 582 | &ddr3_smarct335x80_emif_reg_data, 0); |
577 | udelay(3600); | 583 | udelay(3600); |
578 | } | 584 | } |
579 | else if (board_is_evm_15_or_later(&header)) | 585 | else if (board_is_evm_15_or_later(&header)) |
580 | config_ddr(400, &ioregs_evm15, &ddr3_evm_data, | 586 | config_ddr(400, &ioregs_evm15, &ddr3_evm_data, |
581 | &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0); | 587 | &ddr3_evm_cmd_ctrl_data, &ddr3_evm_emif_reg_data, 0); |
582 | else | 588 | else |
583 | config_ddr(266, &ioregs, &ddr2_data, | 589 | config_ddr(266, &ioregs, &ddr2_data, |
584 | &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0); | 590 | &ddr2_cmd_ctrl_data, &ddr2_emif_reg_data, 0); |
585 | } | 591 | } |
586 | #endif | 592 | #endif |
587 | 593 | ||
588 | /* | 594 | /* |
589 | * Basic board specific setup. Pinmux has been handled already. | 595 | * Basic board specific setup. Pinmux has been handled already. |
590 | */ | 596 | */ |
591 | int board_init(void) | 597 | int board_init(void) |
592 | { | 598 | { |
593 | u32 sys_reboot; | 599 | u32 sys_reboot; |
594 | 600 | ||
595 | sys_reboot = readl(PRM_RSTST); | 601 | sys_reboot = readl(PRM_RSTST); |
596 | if (sys_reboot & (1 << 9)) | 602 | if (sys_reboot & (1 << 9)) |
597 | puts("Reset Source: IcePick reset has occurred.\n"); | 603 | puts("Reset Source: IcePick reset has occurred.\n"); |
598 | 604 | ||
599 | if (sys_reboot & (1 << 5)) | 605 | if (sys_reboot & (1 << 5)) |
600 | puts("Reset Source: Global external warm reset has occurred.\n"); | 606 | puts("Reset Source: Global external warm reset has occurred.\n"); |
601 | 607 | ||
602 | if (sys_reboot & (1 << 4)) | 608 | if (sys_reboot & (1 << 4)) |
603 | puts("Reset Source: watchdog reset has occurred.\n"); | 609 | puts("Reset Source: watchdog reset has occurred.\n"); |
604 | 610 | ||
605 | if (sys_reboot & (1 << 1)) | 611 | if (sys_reboot & (1 << 1)) |
606 | puts("Reset Source: Global warm SW reset has occurred.\n"); | 612 | puts("Reset Source: Global warm SW reset has occurred.\n"); |
607 | 613 | ||
608 | if (sys_reboot & (1 << 0)) | 614 | if (sys_reboot & (1 << 0)) |
609 | puts("Reset Source: Power-on reset has occurred.\n"); | 615 | puts("Reset Source: Power-on reset has occurred.\n"); |
610 | 616 | ||
611 | #if defined(CONFIG_HW_WATCHDOG) | 617 | #if defined(CONFIG_HW_WATCHDOG) |
612 | hw_watchdog_init(); | 618 | hw_watchdog_init(); |
613 | #endif | 619 | #endif |
614 | 620 | ||
615 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; | 621 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
616 | #if defined(CONFIG_NOR) || defined(CONFIG_NAND) | 622 | #if defined(CONFIG_NOR) || defined(CONFIG_NAND) |
617 | gpmc_init(); | 623 | gpmc_init(); |
618 | #endif | 624 | #endif |
619 | return 0; | 625 | return 0; |
620 | } | 626 | } |
621 | 627 | ||
622 | #ifdef CONFIG_BOARD_LATE_INIT | 628 | #ifdef CONFIG_BOARD_LATE_INIT |
623 | int board_late_init(void) | 629 | int board_late_init(void) |
624 | { | 630 | { |
625 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | 631 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
626 | char safe_string[HDR_NAME_LEN + 1]; | 632 | char safe_string[HDR_NAME_LEN + 1]; |
627 | struct am335x_baseboard_id header; | 633 | struct am335x_baseboard_id header; |
628 | 634 | ||
629 | if (read_eeprom(&header) < 0) | 635 | if (read_eeprom(&header) < 0) |
630 | puts("Could not get board ID.\n"); | 636 | puts("Could not get board ID.\n"); |
631 | 637 | ||
632 | /* Read Board Info from EEPROM */ | 638 | /* Read Board Info from EEPROM */ |
633 | puts("-----------------------------------------\n"); | 639 | puts("-----------------------------------------\n"); |
634 | printf("Board ID: %.*s\n", | 640 | printf("Board ID: %.*s\n", |
635 | sizeof(header.name), header.name); | 641 | sizeof(header.name), header.name); |
636 | printf("Board Revision: %.*s\n", | 642 | printf("Board Revision: %.*s\n", |
637 | sizeof(header.version), header.version); | 643 | sizeof(header.version), header.version); |
638 | printf("Board Serial#: %.*s\n", | 644 | printf("Board Serial#: %.*s\n", |
639 | sizeof(header.serial), header.serial); | 645 | sizeof(header.serial), header.serial); |
640 | puts("-----------------------------------------\n"); | 646 | puts("-----------------------------------------\n"); |
647 | |||
648 | gpio_request(69, "i2c_multiplexer_reset"); | ||
649 | /*gpio_direction_output(69, 0);*/ | ||
650 | gpio_direction_output(69, 1); | ||
651 | |||
652 | /* Turn on I2C switch PCA9546 channel */ | ||
653 | i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR); | ||
654 | uint8_t i2cbuf; | ||
655 | i2cbuf = CONFIG_SYS_I2C_PCA9546_ENABLE; | ||
656 | i2c_write(CONFIG_SYS_I2C_PCA9546_ADDR, 1, CONFIG_SYS_I2C_PCA9546_ADDR_LEN, &i2cbuf, 1); | ||
657 | |||
658 | /* Enable DS90UB925 I2C Pass Through */ | ||
659 | i2cbuf = CONFIG_SYS_I2C_SER_PASSTROUGH; | ||
660 | i2c_write(CONFIG_SYS_I2C_SER_ADDR, 0x03, 1, &i2cbuf, 1); | ||
661 | |||
662 | /* Enable DS90UB925 I2C Pass ALL */ | ||
663 | i2cbuf = CONFIG_SYS_I2C_SER_PASSALL; | ||
664 | i2c_write(CONFIG_SYS_I2C_SER_ADDR, 0x17, 1, &i2cbuf, 1); | ||
665 | |||
666 | /* Enable DS90UB925 IRQ */ | ||
667 | i2cbuf = CONFIG_SYS_I2C_SER_IRQ_ENABLE; | ||
668 | i2c_write(CONFIG_SYS_I2C_SER_ADDR, 0xc6, 1, &i2cbuf, 1); | ||
641 | 669 | ||
642 | /* Now set variables based on the header. */ | 670 | /* Now set variables based on the header. */ |
643 | strncpy(safe_string, (char *)header.name, sizeof(header.name)); | 671 | strncpy(safe_string, (char *)header.name, sizeof(header.name)); |
644 | safe_string[sizeof(header.name)] = 0; | 672 | safe_string[sizeof(header.name)] = 0; |
645 | setenv("board_name", safe_string); | 673 | setenv("board_name", safe_string); |
646 | 674 | ||
647 | /* BeagleBone Green has 0x1a at [0], they are free to increment 'a' */ | 675 | /* BeagleBone Green has 0x1a at [0], they are free to increment 'a' */ |
648 | if ( (header.version[0] != 0x30) && (header.version[0] & (1 << 4)) ) { | 676 | if ( (header.version[0] != 0x30) && (header.version[0] & (1 << 4)) ) { |
649 | setenv("board_rev", "BBG1"); | 677 | setenv("board_rev", "BBG1"); |
650 | } else { | 678 | } else { |
651 | strncpy(safe_string, (char *)header.version, sizeof(header.version)); | 679 | strncpy(safe_string, (char *)header.version, sizeof(header.version)); |
652 | safe_string[sizeof(header.version)] = 0; | 680 | safe_string[sizeof(header.version)] = 0; |
653 | setenv("board_rev", safe_string); | 681 | setenv("board_rev", safe_string); |
654 | } | 682 | } |
655 | #endif | 683 | #endif |
656 | 684 | ||
657 | return 0; | 685 | return 0; |
658 | } | 686 | } |
659 | #endif | 687 | #endif |
660 | 688 | ||
661 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ | 689 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ |
662 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) | 690 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
663 | static void cpsw_control(int enabled) | 691 | static void cpsw_control(int enabled) |
664 | { | 692 | { |
665 | /* VTP can be added here */ | 693 | /* VTP can be added here */ |
666 | 694 | ||
667 | return; | 695 | return; |
668 | } | 696 | } |
669 | 697 | ||
670 | static struct cpsw_slave_data cpsw_slaves[] = { | 698 | static struct cpsw_slave_data cpsw_slaves[] = { |
671 | { | 699 | { |
672 | .slave_reg_ofs = 0x208, | 700 | .slave_reg_ofs = 0x208, |
673 | .sliver_reg_ofs = 0xd80, | 701 | .sliver_reg_ofs = 0xd80, |
674 | .phy_addr = 0, | 702 | .phy_addr = 0, |
675 | }, | 703 | }, |
676 | { | 704 | { |
677 | .slave_reg_ofs = 0x308, | 705 | .slave_reg_ofs = 0x308, |
678 | .sliver_reg_ofs = 0xdc0, | 706 | .sliver_reg_ofs = 0xdc0, |
679 | .phy_addr = 1, | 707 | .phy_addr = 1, |
680 | }, | 708 | }, |
681 | }; | 709 | }; |
682 | 710 | ||
683 | static struct cpsw_platform_data cpsw_data = { | 711 | static struct cpsw_platform_data cpsw_data = { |
684 | .mdio_base = CPSW_MDIO_BASE, | 712 | .mdio_base = CPSW_MDIO_BASE, |
685 | .cpsw_base = CPSW_BASE, | 713 | .cpsw_base = CPSW_BASE, |
686 | .mdio_div = 0xff, | 714 | .mdio_div = 0xff, |
687 | .channels = 8, | 715 | .channels = 8, |
688 | .cpdma_reg_ofs = 0x800, | 716 | .cpdma_reg_ofs = 0x800, |
689 | .slaves = 1, | 717 | .slaves = 1, |
690 | .slave_data = cpsw_slaves, | 718 | .slave_data = cpsw_slaves, |
691 | .ale_reg_ofs = 0xd00, | 719 | .ale_reg_ofs = 0xd00, |
692 | .ale_entries = 1024, | 720 | .ale_entries = 1024, |
693 | .host_port_reg_ofs = 0x108, | 721 | .host_port_reg_ofs = 0x108, |
694 | .hw_stats_reg_ofs = 0x900, | 722 | .hw_stats_reg_ofs = 0x900, |
695 | .bd_ram_ofs = 0x2000, | 723 | .bd_ram_ofs = 0x2000, |
696 | .mac_control = (1 << 5), | 724 | .mac_control = (1 << 5), |
697 | .control = cpsw_control, | 725 | .control = cpsw_control, |
698 | .host_port_num = 0, | 726 | .host_port_num = 0, |
699 | .version = CPSW_CTRL_VERSION_2, | 727 | .version = CPSW_CTRL_VERSION_2, |
700 | }; | 728 | }; |
701 | #endif | 729 | #endif |
702 | 730 | ||
703 | /* | 731 | /* |
704 | * This function will: | 732 | * This function will: |
705 | * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr | 733 | * Read the eFuse for MAC addresses, and set ethaddr/eth1addr/usbnet_devaddr |
706 | * in the environment | 734 | * in the environment |
707 | * Perform fixups to the PHY present on certain boards. We only need this | 735 | * Perform fixups to the PHY present on certain boards. We only need this |
708 | * function in: | 736 | * function in: |
709 | * - SPL with either CPSW or USB ethernet support | 737 | * - SPL with either CPSW or USB ethernet support |
710 | * - Full U-Boot, with either CPSW or USB ethernet | 738 | * - Full U-Boot, with either CPSW or USB ethernet |
711 | * Build in only these cases to avoid warnings about unused variables | 739 | * Build in only these cases to avoid warnings about unused variables |
712 | * when we build an SPL that has neither option but full U-Boot will. | 740 | * when we build an SPL that has neither option but full U-Boot will. |
713 | */ | 741 | */ |
714 | #if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)) \ | 742 | #if ((defined(CONFIG_SPL_ETH_SUPPORT) || defined(CONFIG_SPL_USBETH_SUPPORT)) \ |
715 | && defined(CONFIG_SPL_BUILD)) || \ | 743 | && defined(CONFIG_SPL_BUILD)) || \ |
716 | ((defined(CONFIG_DRIVER_TI_CPSW) || \ | 744 | ((defined(CONFIG_DRIVER_TI_CPSW) || \ |
717 | defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \ | 745 | defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)) && \ |
718 | !defined(CONFIG_SPL_BUILD)) | 746 | !defined(CONFIG_SPL_BUILD)) |
719 | int board_eth_init(bd_t *bis) | 747 | int board_eth_init(bd_t *bis) |
720 | { | 748 | { |
721 | int rv, n = 0; | 749 | int rv, n = 0; |
722 | uint8_t mac_addr[6]; | 750 | uint8_t mac_addr[6]; |
723 | uint32_t mac_hi, mac_lo; | 751 | uint32_t mac_hi, mac_lo; |
724 | __maybe_unused struct am335x_baseboard_id header; | 752 | __maybe_unused struct am335x_baseboard_id header; |
725 | 753 | ||
726 | /* try reading mac address from efuse */ | 754 | /* try reading mac address from efuse */ |
727 | mac_lo = readl(&cdev->macid0l); | 755 | mac_lo = readl(&cdev->macid0l); |
728 | mac_hi = readl(&cdev->macid0h); | 756 | mac_hi = readl(&cdev->macid0h); |
729 | mac_addr[0] = mac_hi & 0xFF; | 757 | mac_addr[0] = mac_hi & 0xFF; |
730 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; | 758 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
731 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; | 759 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; |
732 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; | 760 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; |
733 | mac_addr[4] = mac_lo & 0xFF; | 761 | mac_addr[4] = mac_lo & 0xFF; |
734 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; | 762 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; |
735 | 763 | ||
736 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ | 764 | #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \ |
737 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) | 765 | (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD)) |
738 | if (!getenv("ethaddr")) { | 766 | if (!getenv("ethaddr")) { |
739 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); | 767 | printf("<ethaddr> not set. Validating first E-fuse MAC\n"); |
740 | 768 | ||
741 | if (is_valid_ethaddr(mac_addr)) | 769 | if (is_valid_ethaddr(mac_addr)) |
742 | eth_setenv_enetaddr("ethaddr", mac_addr); | 770 | eth_setenv_enetaddr("ethaddr", mac_addr); |
743 | } | 771 | } |
744 | 772 | ||
745 | #ifdef CONFIG_DRIVER_TI_CPSW | 773 | #ifdef CONFIG_DRIVER_TI_CPSW |
746 | 774 | ||
747 | mac_lo = readl(&cdev->macid1l); | 775 | mac_lo = readl(&cdev->macid1l); |
748 | mac_hi = readl(&cdev->macid1h); | 776 | mac_hi = readl(&cdev->macid1h); |
749 | mac_addr[0] = mac_hi & 0xFF; | 777 | mac_addr[0] = mac_hi & 0xFF; |
750 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; | 778 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
751 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; | 779 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; |
752 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; | 780 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; |
753 | mac_addr[4] = mac_lo & 0xFF; | 781 | mac_addr[4] = mac_lo & 0xFF; |
754 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; | 782 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; |
755 | 783 | ||
756 | if (!getenv("eth1addr")) { | 784 | if (!getenv("eth1addr")) { |
757 | if (is_valid_ethaddr(mac_addr)) | 785 | if (is_valid_ethaddr(mac_addr)) |
758 | eth_setenv_enetaddr("eth1addr", mac_addr); | 786 | eth_setenv_enetaddr("eth1addr", mac_addr); |
759 | } | 787 | } |
760 | 788 | ||
761 | if (read_eeprom(&header) < 0) | 789 | if (read_eeprom(&header) < 0) |
762 | puts("Could not get board ID.\n"); | 790 | puts("Could not get board ID.\n"); |
763 | 791 | ||
764 | if (board_is_bone(&header) || board_is_bone_lt(&header) || | 792 | if (board_is_bone(&header) || board_is_bone_lt(&header) || |
765 | board_is_idk(&header)) { | 793 | board_is_idk(&header)) { |
766 | writel(MII_MODE_ENABLE, &cdev->miisel); | 794 | writel(MII_MODE_ENABLE, &cdev->miisel); |
767 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = | 795 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = |
768 | PHY_INTERFACE_MODE_MII; | 796 | PHY_INTERFACE_MODE_MII; |
769 | } else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { | 797 | } else if (board_is_smarc_t335x(&header) || board_is_smarc_t335x_80(&header) || board_is_smarc_t335x_1g(&header)) { |
770 | writel((RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE), &cdev->miisel); | 798 | writel((RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE), &cdev->miisel); |
771 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = | 799 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = |
772 | PHY_INTERFACE_MODE_RMII; | 800 | PHY_INTERFACE_MODE_RMII; |
773 | } else { | 801 | } else { |
774 | writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel); | 802 | writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel); |
775 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = | 803 | cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = |
776 | PHY_INTERFACE_MODE_RGMII; | 804 | PHY_INTERFACE_MODE_RGMII; |
777 | } | 805 | } |
778 | 806 | ||
779 | rv = cpsw_register(&cpsw_data); | 807 | rv = cpsw_register(&cpsw_data); |
780 | if (rv < 0) | 808 | if (rv < 0) |
781 | printf("Error %d registering CPSW switch\n", rv); | 809 | printf("Error %d registering CPSW switch\n", rv); |
782 | else | 810 | else |
783 | n += rv; | 811 | n += rv; |
784 | #endif | 812 | #endif |
785 | 813 | ||
786 | /* | 814 | /* |
787 | * | 815 | * |
788 | * CPSW RGMII Internal Delay Mode is not supported in all PVT | 816 | * CPSW RGMII Internal Delay Mode is not supported in all PVT |
789 | * operating points. So we must set the TX clock delay feature | 817 | * operating points. So we must set the TX clock delay feature |
790 | * in the AR8051 PHY. Since we only support a single ethernet | 818 | * in the AR8051 PHY. Since we only support a single ethernet |
791 | * device in U-Boot, we only do this for the first instance. | 819 | * device in U-Boot, we only do this for the first instance. |
792 | */ | 820 | */ |
793 | #define AR8051_PHY_DEBUG_ADDR_REG 0x1d | 821 | #define AR8051_PHY_DEBUG_ADDR_REG 0x1d |
794 | #define AR8051_PHY_DEBUG_DATA_REG 0x1e | 822 | #define AR8051_PHY_DEBUG_DATA_REG 0x1e |
795 | #define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5 | 823 | #define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5 |
796 | #define AR8051_RGMII_TX_CLK_DLY 0x100 | 824 | #define AR8051_RGMII_TX_CLK_DLY 0x100 |
797 | 825 | ||
798 | if (board_is_evm_sk(&header) || board_is_gp_evm(&header)) { | 826 | if (board_is_evm_sk(&header) || board_is_gp_evm(&header)) { |
799 | const char *devname; | 827 | const char *devname; |
800 | devname = miiphy_get_current_dev(); | 828 | devname = miiphy_get_current_dev(); |
801 | 829 | ||
802 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_ADDR_REG, | 830 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_ADDR_REG, |
803 | AR8051_DEBUG_RGMII_CLK_DLY_REG); | 831 | AR8051_DEBUG_RGMII_CLK_DLY_REG); |
804 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_DATA_REG, | 832 | miiphy_write(devname, 0x0, AR8051_PHY_DEBUG_DATA_REG, |
805 | AR8051_RGMII_TX_CLK_DLY); | 833 | AR8051_RGMII_TX_CLK_DLY); |
806 | } | 834 | } |
807 | #endif | 835 | #endif |
808 | #if defined(CONFIG_USB_ETHER) && \ | 836 | #if defined(CONFIG_USB_ETHER) && \ |
809 | (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT)) | 837 | (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT)) |
810 | if (is_valid_ethaddr(mac_addr)) | 838 | if (is_valid_ethaddr(mac_addr)) |
811 | eth_setenv_enetaddr("usbnet_devaddr", mac_addr); | 839 | eth_setenv_enetaddr("usbnet_devaddr", mac_addr); |
812 | 840 | ||
813 | rv = usb_eth_initialize(bis); | 841 | rv = usb_eth_initialize(bis); |
814 | if (rv < 0) | 842 | if (rv < 0) |
815 | printf("Error %d registering USB_ETHER\n", rv); | 843 | printf("Error %d registering USB_ETHER\n", rv); |
816 | else | 844 | else |
817 | n += rv; | 845 | n += rv; |
818 | #endif | 846 | #endif |
819 | return n; | 847 | return n; |
820 | } | 848 | } |
821 | #endif | 849 | #endif |
822 | 850 | ||
823 | #ifdef CONFIG_SPL_LOAD_FIT | 851 | #ifdef CONFIG_SPL_LOAD_FIT |
824 | int board_fit_config_name_match(const char *name) | 852 | int board_fit_config_name_match(const char *name) |
825 | { | 853 | { |
826 | if (board_is_gp_evm(&header) && !strcmp(header->name, "A33515BB")) | 854 | if (board_is_gp_evm(&header) && !strcmp(header->name, "A33515BB")) |
827 | return 0; | 855 | return 0; |
828 | else if (board_is_bone(&header) && !strcmp(header->name, "A335BONE", 8)) | 856 | else if (board_is_bone(&header) && !strcmp(header->name, "A335BONE", 8)) |
829 | return 0; | 857 | return 0; |
830 | else if (board_is_bone_lt(&header) && !strcmp(header->name, "A335BNLT", 8)) | 858 | else if (board_is_bone_lt(&header) && !strcmp(header->name, "A335BNLT", 8)) |
831 | return 0; | 859 | return 0; |
832 | else if (board_is_evm_sk(&header) && !strcmp(header->name, "A335X_SK", 8)) | 860 | else if (board_is_evm_sk(&header) && !strcmp(header->name, "A335X_SK", 8)) |
833 | return 0; | 861 | return 0; |
834 | else if (board_is_bbg1(&header) && !strcmp(header->name, "BBG1", 4)) | 862 | else if (board_is_bbg1(&header) && !strcmp(header->name, "BBG1", 4)) |
835 | return 0; | 863 | return 0; |
836 | else if (board_is_icev2(&header) && !strcmp(header->name, "A335_ICE", 8)) | 864 | else if (board_is_icev2(&header) && !strcmp(header->name, "A335_ICE", 8)) |
837 | return 0; | 865 | return 0; |
838 | else if (board_is_smarc_t335x(&header) && !strcmp(header->name, "SMARCT33", 8)) | 866 | else if (board_is_smarc_t335x(&header) && !strcmp(header->name, "SMARCT33", 8)) |
839 | return 0; | 867 | return 0; |
840 | else if (board_is_smarc_t335x_80(&header) && !strcmp(header->name, "SMARCT80", 8)) | 868 | else if (board_is_smarc_t335x_80(&header) && !strcmp(header->name, "SMARCT80", 8)) |
841 | return 0; | 869 | return 0; |
842 | else if (board_is_smarc_t335x_1g(&header) && !strcmp(header->name, "SMARCT1G", 8)) | 870 | else if (board_is_smarc_t335x_1g(&header) && !strcmp(header->name, "SMARCT1G", 8)) |
843 | return 0; | 871 | return 0; |
844 | else | 872 | else |
845 | return -1; | 873 | return -1; |
846 | } | 874 | } |
847 | #endif | 875 | #endif |
848 | 876 | ||
849 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) | 877 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
850 | 878 | ||
851 | static const char cpsw_eth0_alias[] = "/ocp/ethernet@4a100000/slave@4a100200"; | 879 | static const char cpsw_eth0_alias[] = "/ocp/ethernet@4a100000/slave@4a100200"; |
852 | static const char cpsw_eth1_alias[] = "/ocp/ethernet@4a100000/slave@4a100300"; | 880 | static const char cpsw_eth1_alias[] = "/ocp/ethernet@4a100000/slave@4a100300"; |
853 | 881 | ||
854 | int ft_board_setup(void *fdt, bd_t *bd) | 882 | int ft_board_setup(void *fdt, bd_t *bd) |
855 | { | 883 | { |
856 | const char *path; | 884 | const char *path; |
857 | int offs; | 885 | int offs; |
858 | int ret; | 886 | int ret; |
859 | 887 | ||
860 | if (!board_is_icev2()) | 888 | if (!board_is_icev2()) |
861 | return 0; | 889 | return 0; |
862 | 890 | ||
863 | /* Board DT default is both ports are MII */ | 891 | /* Board DT default is both ports are MII */ |
864 | if (eth0_is_mii && eth1_is_mii) | 892 | if (eth0_is_mii && eth1_is_mii) |
865 | return 0; | 893 | return 0; |
866 | 894 | ||
867 | if (eth0_is_mii != eth1_is_mii) { | 895 | if (eth0_is_mii != eth1_is_mii) { |
868 | printf("Unsupported Ethernet port configuration\n"); | 896 | printf("Unsupported Ethernet port configuration\n"); |
869 | printf("Both ports must be set as RMII or MII\n"); | 897 | printf("Both ports must be set as RMII or MII\n"); |
870 | return 0; | 898 | return 0; |
871 | } | 899 | } |
872 | 900 | ||
873 | printf("Fixing up ETH0 & ETH1 to CPSW Ethernet\n"); | 901 | printf("Fixing up ETH0 & ETH1 to CPSW Ethernet\n"); |
874 | /* Disable PRUSS-MDIO */ | 902 | /* Disable PRUSS-MDIO */ |
875 | path = "/ocp/pruss@4a300000/mdio@4a332400"; | 903 | path = "/ocp/pruss@4a300000/mdio@4a332400"; |
876 | offs = fdt_path_offset(fdt, path); | 904 | offs = fdt_path_offset(fdt, path); |
877 | if (offs < 0) | 905 | if (offs < 0) |
878 | goto no_node; | 906 | goto no_node; |
879 | 907 | ||
880 | ret = fdt_status_disabled(fdt, offs); | 908 | ret = fdt_status_disabled(fdt, offs); |
881 | if (ret < 0) | 909 | if (ret < 0) |
882 | goto disable_failed; | 910 | goto disable_failed; |
883 | 911 | ||
884 | /* Disable PRU-ICSS Ethernet */ | 912 | /* Disable PRU-ICSS Ethernet */ |
885 | path = "/pruss_eth"; | 913 | path = "/pruss_eth"; |
886 | offs = fdt_path_offset(fdt, path); | 914 | offs = fdt_path_offset(fdt, path); |
887 | if (offs < 0) | 915 | if (offs < 0) |
888 | goto no_node; | 916 | goto no_node; |
889 | 917 | ||
890 | ret = fdt_status_disabled(fdt, offs); | 918 | ret = fdt_status_disabled(fdt, offs); |
891 | if (ret < 0) | 919 | if (ret < 0) |
892 | goto disable_failed; | 920 | goto disable_failed; |
893 | 921 | ||
894 | /* Enable CPSW Ethernet */ | 922 | /* Enable CPSW Ethernet */ |
895 | path = "/ocp/ethernet@4a100000"; | 923 | path = "/ocp/ethernet@4a100000"; |
896 | offs = fdt_path_offset(fdt, path); | 924 | offs = fdt_path_offset(fdt, path); |
897 | if (offs < 0) | 925 | if (offs < 0) |
898 | goto no_node; | 926 | goto no_node; |
899 | 927 | ||
900 | ret = fdt_status_okay(fdt, offs); | 928 | ret = fdt_status_okay(fdt, offs); |
901 | if (ret < 0) | 929 | if (ret < 0) |
902 | goto enable_failed; | 930 | goto enable_failed; |
903 | 931 | ||
904 | /* Enable CPSW-MDIO */ | 932 | /* Enable CPSW-MDIO */ |
905 | path = "/ocp/ethernet@4a100000/mdio@4a101000"; | 933 | path = "/ocp/ethernet@4a100000/mdio@4a101000"; |
906 | offs = fdt_path_offset(fdt, path); | 934 | offs = fdt_path_offset(fdt, path); |
907 | if (offs < 0) | 935 | if (offs < 0) |
908 | goto no_node; | 936 | goto no_node; |
909 | 937 | ||
910 | ret = fdt_status_okay(fdt, offs); | 938 | ret = fdt_status_okay(fdt, offs); |
911 | if (ret < 0) | 939 | if (ret < 0) |
912 | goto enable_failed; | 940 | goto enable_failed; |
913 | 941 | ||
914 | /* Set MUX_MII_CTL1 pin high */ | 942 | /* Set MUX_MII_CTL1 pin high */ |
915 | path = "/ocp/gpio@481ae000/p10"; | 943 | path = "/ocp/gpio@481ae000/p10"; |
916 | offs = fdt_path_offset(fdt, path); | 944 | offs = fdt_path_offset(fdt, path); |
917 | if (offs < 0) { | 945 | if (offs < 0) { |
918 | printf("Node %s not found.\n", path); | 946 | printf("Node %s not found.\n", path); |
919 | return offs; | 947 | return offs; |
920 | } | 948 | } |
921 | 949 | ||
922 | ret = fdt_delprop(fdt, offs, "output-low"); | 950 | ret = fdt_delprop(fdt, offs, "output-low"); |
923 | if (ret < 0) { | 951 | if (ret < 0) { |
924 | printf("Could not delete output-low property from node %s: %s\n", | 952 | printf("Could not delete output-low property from node %s: %s\n", |
925 | path, fdt_strerror(ret)); | 953 | path, fdt_strerror(ret)); |
926 | return ret; | 954 | return ret; |
927 | } | 955 | } |
928 | 956 | ||
929 | ret = fdt_setprop(fdt, offs, "output-high", NULL, 0); | 957 | ret = fdt_setprop(fdt, offs, "output-high", NULL, 0); |
930 | if (ret < 0) { | 958 | if (ret < 0) { |
931 | printf("Could not add output-high property to node %s: %s\n", | 959 | printf("Could not add output-high property to node %s: %s\n", |
932 | path, fdt_strerror(ret)); | 960 | path, fdt_strerror(ret)); |
933 | return ret; | 961 | return ret; |
934 | } | 962 | } |
935 | 963 | ||
936 | /* Fixup ethernet aliases */ | 964 | /* Fixup ethernet aliases */ |
937 | path = "/aliases"; | 965 | path = "/aliases"; |
938 | offs = fdt_path_offset(fdt, path); | 966 | offs = fdt_path_offset(fdt, path); |
939 | if (offs < 0) | 967 | if (offs < 0) |
940 | goto no_node; | 968 | goto no_node; |
941 | 969 | ||
942 | ret = fdt_setprop(fdt, offs, "ethernet0", cpsw_eth0_alias, | 970 | ret = fdt_setprop(fdt, offs, "ethernet0", cpsw_eth0_alias, |
943 | strlen(cpsw_eth0_alias) + 1); | 971 | strlen(cpsw_eth0_alias) + 1); |
944 | if (ret < 0) { | 972 | if (ret < 0) { |
945 | printf("Could not change ethernet0 alias: %s\n", | 973 | printf("Could not change ethernet0 alias: %s\n", |
946 | fdt_strerror(ret)); | 974 | fdt_strerror(ret)); |
947 | return ret; | 975 | return ret; |
948 | } | 976 | } |
949 | 977 | ||
950 | ret = fdt_setprop(fdt, offs, "ethernet1", cpsw_eth1_alias, | 978 | ret = fdt_setprop(fdt, offs, "ethernet1", cpsw_eth1_alias, |
951 | strlen(cpsw_eth0_alias) + 1); | 979 | strlen(cpsw_eth0_alias) + 1); |
952 | if (ret < 0) { | 980 | if (ret < 0) { |
953 | printf("Could not change ethernet0 alias: %s\n", | 981 | printf("Could not change ethernet0 alias: %s\n", |
954 | fdt_strerror(ret)); | 982 | fdt_strerror(ret)); |
955 | return ret; | 983 | return ret; |
956 | } | 984 | } |
957 | 985 | ||
958 | return 0; | 986 | return 0; |
959 | 987 | ||
960 | no_node: | 988 | no_node: |
961 | printf("Node %s not found. Please update DTB.\n", path); | 989 | printf("Node %s not found. Please update DTB.\n", path); |
962 | 990 | ||
963 | /* Return 0 as we don't want to prevent booting with older DTBs */ | 991 | /* Return 0 as we don't want to prevent booting with older DTBs */ |
964 | return 0; | 992 | return 0; |
965 | 993 | ||
966 | disable_failed: | 994 | disable_failed: |
967 | printf("Could not disable node %s: %s\n", | 995 | printf("Could not disable node %s: %s\n", |
968 | path, fdt_strerror(ret)); | 996 | path, fdt_strerror(ret)); |
969 | return ret; | 997 | return ret; |
970 | 998 | ||
971 | enable_failed: | 999 | enable_failed: |
972 | printf("Could not enable node %s: %s\n", | 1000 | printf("Could not enable node %s: %s\n", |
973 | path, fdt_strerror(ret)); | 1001 | path, fdt_strerror(ret)); |
974 | return ret; | 1002 | return ret; |
975 | } | 1003 | } |
976 | #endif | 1004 | #endif |
977 | 1005 |
board/embedian/smarct335x/mux.c
1 | /* | 1 | /* |
2 | * mux.c | 2 | * mux.c |
3 | * | 3 | * |
4 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | 4 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License as | 7 | * modify it under the terms of the GNU General Public License as |
8 | * published by the Free Software Foundation version 2. | 8 | * published by the Free Software Foundation version 2. |
9 | * | 9 | * |
10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | 10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any |
11 | * kind, whether express or implied; without even the implied warranty | 11 | * kind, whether express or implied; without even the implied warranty |
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <common.h> | 16 | #include <common.h> |
17 | #include <asm/arch/sys_proto.h> | 17 | #include <asm/arch/sys_proto.h> |
18 | #include <asm/arch/hardware.h> | 18 | #include <asm/arch/hardware.h> |
19 | #include <asm/arch/mux.h> | 19 | #include <asm/arch/mux.h> |
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
21 | #include <i2c.h> | 21 | #include <i2c.h> |
22 | #include "board.h" | 22 | #include "board.h" |
23 | 23 | ||
24 | static struct module_pin_mux uart0_pin_mux[] = { | 24 | static struct module_pin_mux uart0_pin_mux[] = { |
25 | {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART0_RXD */ | 25 | {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART0_RXD */ |
26 | {OFFSET(uart0_txd), (MODE(0) | PULLUDEN)}, /* UART0_TXD */ | 26 | {OFFSET(uart0_txd), (MODE(0) | PULLUDEN)}, /* UART0_TXD */ |
27 | {OFFSET(uart0_ctsn), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART0_CTSN */ | ||
28 | {OFFSET(uart0_rtsn), (MODE(0) | PULLUDEN)}, /* UART0_RTSN */ | ||
29 | |||
27 | {-1}, | 30 | {-1}, |
28 | }; | 31 | }; |
29 | 32 | ||
30 | static struct module_pin_mux uart1_pin_mux[] = { | 33 | static struct module_pin_mux uart1_pin_mux[] = { |
31 | {OFFSET(uart1_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART1_RXD */ | 34 | {OFFSET(uart1_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART1_RXD */ |
32 | {OFFSET(uart1_txd), (MODE(0) | PULLUDEN)}, /* UART1_TXD */ | 35 | {OFFSET(uart1_txd), (MODE(0) | PULLUDEN)}, /* UART1_TXD */ |
36 | {OFFSET(uart1_rtsn), (MODE(0) | PULLUDEN)}, /* UART1_RTSN */ | ||
33 | {-1}, | 37 | {-1}, |
34 | }; | 38 | }; |
35 | 39 | ||
36 | static struct module_pin_mux uart2_pin_mux[] = { | 40 | static struct module_pin_mux uart2_pin_mux[] = { |
37 | {OFFSET(mii1_txclk), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART2_RXD */ | 41 | {OFFSET(mii1_txclk), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART2_RXD */ |
38 | {OFFSET(mii1_rxclk), (MODE(1) | PULLUDEN)}, /* UART2_TXD */ | 42 | {OFFSET(mii1_rxclk), (MODE(1) | PULLUDEN)}, /* UART2_TXD */ |
39 | {-1}, | 43 | {-1}, |
40 | }; | 44 | }; |
41 | 45 | ||
42 | static struct module_pin_mux uart3_pin_mux[] = { | 46 | static struct module_pin_mux uart3_pin_mux[] = { |
43 | {OFFSET(mii1_rxd3), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART3_RXD */ | 47 | {OFFSET(mii1_rxd3), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART3_RXD */ |
44 | {OFFSET(mii1_rxd2), (MODE(1) | PULLUDEN)}, /* UART3_TXD */ | 48 | {OFFSET(mii1_rxd2), (MODE(1) | PULLUDEN)}, /* UART3_TXD */ |
45 | {-1}, | 49 | {-1}, |
46 | }; | 50 | }; |
47 | 51 | ||
48 | static struct module_pin_mux uart4_pin_mux[] = { | 52 | static struct module_pin_mux uart4_pin_mux[] = { |
49 | {OFFSET(gpmc_wait0), (MODE(6) | PULLUP_EN | RXACTIVE)}, /* UART4_RXD */ | 53 | {OFFSET(gpmc_wait0), (MODE(6) | PULLUP_EN | RXACTIVE)}, /* UART4_RXD */ |
50 | {OFFSET(gpmc_wpn), (MODE(6) | PULLUDEN)}, /* UART4_TXD */ | 54 | {OFFSET(gpmc_wpn), (MODE(6) | PULLUDEN)}, /* UART4_TXD */ |
51 | {-1}, | 55 | {-1}, |
52 | }; | 56 | }; |
53 | 57 | ||
54 | static struct module_pin_mux uart5_pin_mux[] = { | 58 | static struct module_pin_mux uart5_pin_mux[] = { |
55 | {OFFSET(lcd_data9), (MODE(4) | PULLUP_EN | RXACTIVE)}, /* UART5_RXD */ | 59 | {OFFSET(lcd_data9), (MODE(4) | PULLUP_EN | RXACTIVE)}, /* UART5_RXD */ |
56 | {OFFSET(lcd_data8), (MODE(4) | PULLUDEN)}, /* UART5_TXD */ | 60 | {OFFSET(lcd_data8), (MODE(4) | PULLUDEN)}, /* UART5_TXD */ |
57 | {-1}, | 61 | {-1}, |
58 | }; | 62 | }; |
59 | 63 | ||
60 | static struct module_pin_mux mmc0_pin_mux[] = { | 64 | static struct module_pin_mux mmc0_pin_mux[] = { |
61 | {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ | 65 | {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ |
62 | {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ | 66 | {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ |
63 | {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */ | 67 | {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */ |
64 | {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */ | 68 | {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */ |
65 | {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */ | 69 | {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */ |
66 | {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */ | 70 | {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */ |
67 | {OFFSET(gpmc_a2), (MODE(7) | RXACTIVE)}, /* MMC0_WP */ | 71 | {OFFSET(gpmc_a2), (MODE(7) | RXACTIVE)}, /* MMC0_WP */ |
68 | {OFFSET(gpmc_a1), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */ | 72 | {OFFSET(gpmc_a1), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */ |
69 | {-1}, | 73 | {-1}, |
70 | }; | 74 | }; |
71 | 75 | ||
72 | static struct module_pin_mux mmc0_no_cd_pin_mux[] = { | 76 | static struct module_pin_mux mmc0_no_cd_pin_mux[] = { |
73 | {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ | 77 | {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ |
74 | {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ | 78 | {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ |
75 | {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */ | 79 | {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */ |
76 | {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */ | 80 | {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */ |
77 | {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */ | 81 | {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */ |
78 | {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */ | 82 | {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */ |
79 | {OFFSET(mcasp0_aclkr), (MODE(4) | RXACTIVE)}, /* MMC0_WP */ | 83 | {OFFSET(mcasp0_aclkr), (MODE(4) | RXACTIVE)}, /* MMC0_WP */ |
80 | {-1}, | 84 | {-1}, |
81 | }; | 85 | }; |
82 | 86 | ||
83 | static struct module_pin_mux mmc0_pin_mux_sk_evm[] = { | 87 | static struct module_pin_mux mmc0_pin_mux_sk_evm[] = { |
84 | {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ | 88 | {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ |
85 | {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ | 89 | {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ |
86 | {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */ | 90 | {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */ |
87 | {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */ | 91 | {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */ |
88 | {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */ | 92 | {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */ |
89 | {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */ | 93 | {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */ |
90 | {OFFSET(spi0_cs1), (MODE(5) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */ | 94 | {OFFSET(spi0_cs1), (MODE(5) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */ |
91 | {-1}, | 95 | {-1}, |
92 | }; | 96 | }; |
93 | 97 | ||
94 | static struct module_pin_mux mmc1_pin_mux[] = { | 98 | static struct module_pin_mux mmc1_pin_mux[] = { |
95 | {OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT3 */ | 99 | {OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT3 */ |
96 | {OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT2 */ | 100 | {OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT2 */ |
97 | {OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT1 */ | 101 | {OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT1 */ |
98 | {OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT0 */ | 102 | {OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT0 */ |
99 | {OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CLK */ | 103 | {OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CLK */ |
100 | {OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CMD */ | 104 | {OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CMD */ |
101 | {-1}, | 105 | {-1}, |
102 | }; | 106 | }; |
103 | 107 | ||
104 | static struct module_pin_mux i2c0_pin_mux[] = { | 108 | static struct module_pin_mux i2c0_pin_mux[] = { |
105 | {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | | 109 | {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | |
106 | PULLUDEN | SLEWCTRL)}, /* I2C_DATA */ | 110 | PULLUDEN | SLEWCTRL)}, /* I2C_DATA */ |
107 | {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | | 111 | {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | |
108 | PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */ | 112 | PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */ |
109 | {-1}, | 113 | {-1}, |
110 | }; | 114 | }; |
111 | 115 | ||
112 | static struct module_pin_mux i2c1_pin_mux[] = { | ||
113 | {OFFSET(uart1_rxd), (MODE(3) | RXACTIVE | | ||
114 | PULLUDEN | SLEWCTRL)}, /* I2C_DATA */ | ||
115 | {OFFSET(uart1_txd), (MODE(3) | RXACTIVE | | ||
116 | PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */ | ||
117 | {-1}, | ||
118 | }; | ||
119 | |||
120 | static struct module_pin_mux spi0_pin_mux[] = { | 116 | static struct module_pin_mux spi0_pin_mux[] = { |
121 | {OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_SCLK */ | 117 | {OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_SCLK */ |
122 | {OFFSET(spi0_d0), (MODE(0) | RXACTIVE | | 118 | {OFFSET(spi0_d0), (MODE(0) | RXACTIVE | |
123 | PULLUDEN | PULLUP_EN)}, /* SPI0_D0 */ | 119 | PULLUDEN | PULLUP_EN)}, /* SPI0_D0 */ |
124 | {OFFSET(spi0_d1), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_D1 */ | 120 | {OFFSET(spi0_d1), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_D1 */ |
125 | {OFFSET(spi0_cs0), (MODE(0) | RXACTIVE | | 121 | {OFFSET(spi0_cs0), (MODE(0) | RXACTIVE | |
126 | PULLUDEN | PULLUP_EN)}, /* SPI0_CS0 */ | 122 | PULLUDEN | PULLUP_EN)}, /* SPI0_CS0 */ |
123 | {OFFSET(spi0_cs1), (MODE(0) | RXACTIVE | | ||
124 | PULLUDEN | PULLUP_EN)}, /* SPI0_CS1 */ | ||
127 | {-1}, | 125 | {-1}, |
128 | }; | 126 | }; |
129 | 127 | ||
128 | static struct module_pin_mux spi1_pin_mux[] = { | ||
129 | {OFFSET(mcasp0_aclkx), (MODE(3) | RXACTIVE | PULLUDEN)}, /* SPI1_SCLK */ | ||
130 | {OFFSET(mcasp0_fsx), (MODE(3) | RXACTIVE | | ||
131 | PULLUDEN | PULLUP_EN)}, /* SPI1_D0 */ | ||
132 | {OFFSET(mcasp0_axr0), (MODE(3) | RXACTIVE | PULLUDEN)}, /* SPI1_D1 */ | ||
133 | {OFFSET(mcasp0_ahclkr), (MODE(3) | RXACTIVE | | ||
134 | PULLUDEN | PULLUP_EN)}, /* SPI1_CS0 */ | ||
135 | {OFFSET(xdma_event_intr0), (MODE(4) | RXACTIVE | | ||
136 | PULLUDEN | PULLUP_EN)}, /* SPI1_CS1 */ | ||
137 | {-1}, | ||
138 | }; | ||
139 | |||
130 | static struct module_pin_mux gpio0_7_pin_mux[] = { | 140 | static struct module_pin_mux gpio0_7_pin_mux[] = { |
131 | {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN)}, /* GPIO0_7 */ | 141 | {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN)}, /* GPIO0_7 */ |
132 | {-1}, | 142 | {-1}, |
133 | }; | 143 | }; |
134 | 144 | ||
135 | static struct module_pin_mux smarc_gpio_pin_mux[] = { | 145 | static struct module_pin_mux smarc_gpio_pin_mux[] = { |
136 | {OFFSET(gpmc_a7), (MODE(7) | PULLUDEN | PULLUP_EN)}, /* GPIO1_23, LCD VDD_EN */ | 146 | {OFFSET(gpmc_a7), (MODE(7) | PULLUDEN | PULLUP_EN)}, /* GPIO1_23, LCD VDD_EN */ |
137 | {OFFSET(gpmc_a6), (MODE(7) | PULLUDEN | PULLUP_EN)}, /* GPIO1_22, LCD Backlight Enable */ | 147 | {OFFSET(gpmc_a6), (MODE(7) | PULLUDEN | PULLUP_EN)}, /* GPIO1_22, LCD Backlight Enable */ |
138 | {OFFSET(gpmc_a3), (MODE(7) | PULLUDEN | PULLUP_EN)}, /* GPIO1_19, MMC0_PWREN Enable*/ | 148 | {OFFSET(gpmc_a3), (MODE(7) | PULLUDEN | PULLUP_EN)}, /* GPIO1_19, MMC0_PWREN Enable*/ |
139 | {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN)}, /* GPIO0_7, LCD_BKLT_PWM */ | 149 | {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN)}, /* GPIO0_7, LCD_BKLT_PWM */ |
140 | /* By SMARC Spec. GPIO0-5 is recommended for use as outputs and GPIO6-11 is recommended for use of inputs */ | 150 | /* By SMARC Spec. GPIO0-5 is recommended for use as outputs and GPIO6-11 is recommended for use of inputs */ |
141 | {OFFSET(mii1_rxdv), MODE(7)}, /* GPIO3_4, GPIO0 */ | 151 | {OFFSET(mii1_rxdv), MODE(7) | RXACTIVE}, /* GPIO3_4, GPIO0 */ |
142 | {OFFSET(gpmc_be0n_cle), MODE(7)}, /* GPIO2_5, GPIO1 */ | ||
143 | {OFFSET(gpmc_a9), MODE(7)}, /* GPIO1_25, GPIO2 */ | 152 | {OFFSET(gpmc_a9), MODE(7)}, /* GPIO1_25, GPIO2 */ |
144 | {OFFSET(gpmc_a8), MODE(7)}, /* GPIO1_24, GPIO3 */ | 153 | {OFFSET(gpmc_a8), MODE(7) | RXACTIVE}, /* GPIO1_24, GPIO3 */ |
145 | {OFFSET(gpmc_wen), MODE(7)}, /* GPIO2_4, GPIO4 */ | 154 | {OFFSET(gpmc_wen), MODE(7) | RXACTIVE}, /* GPIO2_4, GPIO4 */ |
146 | {OFFSET(gpmc_oen_ren), MODE(7)}, /* GPIO2_3, GPIO5 */ | 155 | {OFFSET(gpmc_oen_ren), MODE(7) | RXACTIVE}, /* GPIO2_3, GPIO5 */ |
147 | {OFFSET(gpmc_be1n), MODE(7) | RXACTIVE}, /* GPIO1_28, GPIO6 */ | 156 | {OFFSET(gpmc_be1n), MODE(7) | RXACTIVE}, /* GPIO1_28, GPIO6 */ |
148 | {OFFSET(gpmc_csn0), MODE(7) | RXACTIVE}, /* GPIO1_29, GPIO7 */ | 157 | {OFFSET(gpmc_csn0), MODE(7) | RXACTIVE}, /* GPIO1_29, GPIO7 */ |
149 | {OFFSET(gpmc_csn3), MODE(7) | RXACTIVE}, /* GPIO2_0, GPIO8 */ | 158 | {OFFSET(gpmc_csn3), MODE(7) | RXACTIVE}, /* GPIO2_0, GPIO8 */ |
150 | {OFFSET(gpmc_clk), MODE(7) | RXACTIVE}, /* GPIO2_1, GPIO9 */ | 159 | {OFFSET(gpmc_clk), MODE(7)}, /* GPIO2_1, GPIO9 */ |
151 | {OFFSET(emu0), MODE(7)}, /* GPIO3_7, GPIO10 for Buzzer */ | 160 | {OFFSET(emu0), MODE(7) | PULLUDEN}, /* GPIO3_7, GPIO10 for Buzzer */ |
152 | {OFFSET(emu1), MODE(7) | RXACTIVE}, /* GPIO3_8, GPIO11 */ | 161 | {OFFSET(emu1), MODE(7) | RXACTIVE}, /* GPIO3_8, GPIO11 */ |
153 | /* i2c1 (pin37 and pin38 on P1 connector) in SBC-SMART-MEN is set as GPIOs*/ | 162 | {OFFSET(gpmc_advn_ale), MODE(7) | PULLDOWN_EN}, /* GPIO2_2 WDT_TIMEOUT */ |
154 | {OFFSET(uart1_txd), MODE(7)}, /* uart1_txd.gpio0_15 */ | 163 | {OFFSET(gpmc_be0n_cle), MODE(7) | PULLUP_EN}, /* I2C Mux Reset */ |
155 | {OFFSET(uart1_rxd), MODE(7)}, /* uart1_rxd.gpio0_14 */ | ||
156 | {-1}, | 164 | {-1}, |
157 | }; | 165 | }; |
158 | 166 | ||
159 | /* Module pin mux for LCDC */ | 167 | /* Module pin mux for LCDC */ |
160 | static struct module_pin_mux lcdc_pin_mux[] = { | 168 | static struct module_pin_mux lcdc_pin_mux[] = { |
161 | {OFFSET(lcd_data0), (MODE(0) | PULLUDDIS)}, /*lcd_data0", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT*/ | 169 | {OFFSET(lcd_data0), (MODE(0) | PULLUDDIS)}, /*lcd_data0", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT*/ |
162 | {OFFSET(lcd_data1), (MODE(0) | PULLUDDIS)}, | 170 | {OFFSET(lcd_data1), (MODE(0) | PULLUDDIS)}, |
163 | {OFFSET(lcd_data2), (MODE(0) | PULLUDDIS)}, | 171 | {OFFSET(lcd_data2), (MODE(0) | PULLUDDIS)}, |
164 | {OFFSET(lcd_data3), (MODE(0) | PULLUDDIS)}, | 172 | {OFFSET(lcd_data3), (MODE(0) | PULLUDDIS)}, |
165 | {OFFSET(lcd_data4), (MODE(0) | PULLUDDIS)}, | 173 | {OFFSET(lcd_data4), (MODE(0) | PULLUDDIS)}, |
166 | {OFFSET(lcd_data5), (MODE(0) | PULLUDDIS)}, | 174 | {OFFSET(lcd_data5), (MODE(0) | PULLUDDIS)}, |
167 | {OFFSET(lcd_data6), (MODE(0) | PULLUDDIS)}, | 175 | {OFFSET(lcd_data6), (MODE(0) | PULLUDDIS)}, |
168 | {OFFSET(lcd_data7), (MODE(0) | PULLUDDIS)}, | 176 | {OFFSET(lcd_data7), (MODE(0) | PULLUDDIS)}, |
169 | {OFFSET(lcd_data8), (MODE(0) | PULLUDDIS)}, | 177 | {OFFSET(lcd_data8), (MODE(0) | PULLUDDIS)}, |
170 | {OFFSET(lcd_data9), (MODE(0) | PULLUDDIS)}, | 178 | {OFFSET(lcd_data9), (MODE(0) | PULLUDDIS)}, |
171 | {OFFSET(lcd_data10), (MODE(0) | PULLUDDIS)}, | 179 | {OFFSET(lcd_data10), (MODE(0) | PULLUDDIS)}, |
172 | {OFFSET(lcd_data11), (MODE(0) | PULLUDDIS)}, | 180 | {OFFSET(lcd_data11), (MODE(0) | PULLUDDIS)}, |
173 | {OFFSET(lcd_data12), (MODE(0) | PULLUDDIS)}, | 181 | {OFFSET(lcd_data12), (MODE(0) | PULLUDDIS)}, |
174 | {OFFSET(lcd_data13), (MODE(0) | PULLUDDIS)}, | 182 | {OFFSET(lcd_data13), (MODE(0) | PULLUDDIS)}, |
175 | {OFFSET(lcd_data14), (MODE(0) | PULLUDDIS)}, | 183 | {OFFSET(lcd_data14), (MODE(0) | PULLUDDIS)}, |
176 | {OFFSET(lcd_data15), (MODE(0) | PULLUDDIS)}, | 184 | {OFFSET(lcd_data15), (MODE(0) | PULLUDDIS)}, |
177 | // new signals | 185 | // new signals |
178 | {OFFSET(gpmc_ad8), (MODE(1) | PULLUDDIS)}, | 186 | {OFFSET(gpmc_ad8), (MODE(1) | PULLUDDIS)}, |
179 | {OFFSET(gpmc_ad9), (MODE(1) | PULLUDDIS)}, | 187 | {OFFSET(gpmc_ad9), (MODE(1) | PULLUDDIS)}, |
180 | {OFFSET(gpmc_ad10), (MODE(1) | PULLUDDIS)}, | 188 | {OFFSET(gpmc_ad10), (MODE(1) | PULLUDDIS)}, |
181 | {OFFSET(gpmc_ad11), (MODE(1) | PULLUDDIS)}, | 189 | {OFFSET(gpmc_ad11), (MODE(1) | PULLUDDIS)}, |
182 | {OFFSET(gpmc_ad12), (MODE(1) | PULLUDDIS)}, | 190 | {OFFSET(gpmc_ad12), (MODE(1) | PULLUDDIS)}, |
183 | {OFFSET(gpmc_ad13), (MODE(1) | PULLUDDIS)}, | 191 | {OFFSET(gpmc_ad13), (MODE(1) | PULLUDDIS)}, |
184 | {OFFSET(gpmc_ad14), (MODE(1) | PULLUDDIS)}, | 192 | {OFFSET(gpmc_ad14), (MODE(1) | PULLUDDIS)}, |
185 | {OFFSET(gpmc_ad15), (MODE(1) | PULLUDDIS)}, | 193 | {OFFSET(gpmc_ad15), (MODE(1) | PULLUDDIS)}, |
186 | // | 194 | // |
187 | {OFFSET(lcd_vsync), (MODE(0) | PULLUDEN)}, | 195 | {OFFSET(lcd_vsync), (MODE(0) | PULLUDEN)}, |
188 | {OFFSET(lcd_hsync), (MODE(0) | PULLUDEN)}, | 196 | {OFFSET(lcd_hsync), (MODE(0) | PULLUDEN)}, |
189 | {OFFSET(lcd_pclk), (MODE(0) | PULLUDEN)}, | 197 | {OFFSET(lcd_pclk), (MODE(0) | PULLUDEN)}, |
190 | {OFFSET(lcd_ac_bias_en), (MODE(0) | PULLUDEN)}, | 198 | {OFFSET(lcd_ac_bias_en), (MODE(0) | PULLUDEN)}, |
191 | {-1}, | 199 | {-1}, |
192 | }; | 200 | }; |
193 | 201 | ||
194 | static struct module_pin_mux rgmii1_pin_mux[] = { | 202 | static struct module_pin_mux rgmii1_pin_mux[] = { |
195 | {OFFSET(mii1_txen), MODE(2)}, /* RGMII1_TCTL */ | 203 | {OFFSET(mii1_txen), MODE(2)}, /* RGMII1_TCTL */ |
196 | {OFFSET(mii1_rxdv), MODE(2) | RXACTIVE}, /* RGMII1_RCTL */ | 204 | {OFFSET(mii1_rxdv), MODE(2) | RXACTIVE}, /* RGMII1_RCTL */ |
197 | {OFFSET(mii1_txd3), MODE(2)}, /* RGMII1_TD3 */ | 205 | {OFFSET(mii1_txd3), MODE(2)}, /* RGMII1_TD3 */ |
198 | {OFFSET(mii1_txd2), MODE(2)}, /* RGMII1_TD2 */ | 206 | {OFFSET(mii1_txd2), MODE(2)}, /* RGMII1_TD2 */ |
199 | {OFFSET(mii1_txd1), MODE(2)}, /* RGMII1_TD1 */ | 207 | {OFFSET(mii1_txd1), MODE(2)}, /* RGMII1_TD1 */ |
200 | {OFFSET(mii1_txd0), MODE(2)}, /* RGMII1_TD0 */ | 208 | {OFFSET(mii1_txd0), MODE(2)}, /* RGMII1_TD0 */ |
201 | {OFFSET(mii1_txclk), MODE(2)}, /* RGMII1_TCLK */ | 209 | {OFFSET(mii1_txclk), MODE(2)}, /* RGMII1_TCLK */ |
202 | {OFFSET(mii1_rxclk), MODE(2) | RXACTIVE}, /* RGMII1_RCLK */ | 210 | {OFFSET(mii1_rxclk), MODE(2) | RXACTIVE}, /* RGMII1_RCLK */ |
203 | {OFFSET(mii1_rxd3), MODE(2) | RXACTIVE}, /* RGMII1_RD3 */ | 211 | {OFFSET(mii1_rxd3), MODE(2) | RXACTIVE}, /* RGMII1_RD3 */ |
204 | {OFFSET(mii1_rxd2), MODE(2) | RXACTIVE}, /* RGMII1_RD2 */ | 212 | {OFFSET(mii1_rxd2), MODE(2) | RXACTIVE}, /* RGMII1_RD2 */ |
205 | {OFFSET(mii1_rxd1), MODE(2) | RXACTIVE}, /* RGMII1_RD1 */ | 213 | {OFFSET(mii1_rxd1), MODE(2) | RXACTIVE}, /* RGMII1_RD1 */ |
206 | {OFFSET(mii1_rxd0), MODE(2) | RXACTIVE}, /* RGMII1_RD0 */ | 214 | {OFFSET(mii1_rxd0), MODE(2) | RXACTIVE}, /* RGMII1_RD0 */ |
207 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ | 215 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ |
208 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ | 216 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
209 | {-1}, | 217 | {-1}, |
210 | }; | 218 | }; |
211 | 219 | ||
212 | static struct module_pin_mux rmii1_pin_mux[] = { | 220 | static struct module_pin_mux rmii1_pin_mux[] = { |
213 | {OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* RMII1_CRS */ | 221 | {OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* RMII1_CRS */ |
214 | {OFFSET(mii1_rxerr), MODE(1) | RXACTIVE}, /* RMII1_RXERR */ | 222 | {OFFSET(mii1_rxerr), MODE(1) | RXACTIVE}, /* RMII1_RXERR */ |
215 | {OFFSET(mii1_txen), MODE(1)}, /* RMII1_TXEN */ | 223 | {OFFSET(mii1_txen), MODE(1)}, /* RMII1_TXEN */ |
216 | {OFFSET(mii1_txd1), MODE(1)}, /* RMII1_TXD1 */ | 224 | {OFFSET(mii1_txd1), MODE(1)}, /* RMII1_TXD1 */ |
217 | {OFFSET(mii1_txd0), MODE(1)}, /* RMII1_TXD0 */ | 225 | {OFFSET(mii1_txd0), MODE(1)}, /* RMII1_TXD0 */ |
218 | {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* RMII1_RXD1 */ | 226 | {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* RMII1_RXD1 */ |
219 | {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* RMII1_RXD0 */ | 227 | {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* RMII1_RXD0 */ |
220 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */ | 228 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */ |
221 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ | 229 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
222 | {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REFCLK */ | 230 | {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REFCLK */ |
223 | {-1}, | 231 | {-1}, |
224 | }; | 232 | }; |
225 | 233 | ||
226 | static struct module_pin_mux rmii2_pin_mux[] = { | 234 | static struct module_pin_mux rmii2_pin_mux[] = { |
227 | {OFFSET(gpmc_wait0), MODE(3) | RXACTIVE}, /* RMII2_CRS */ | 235 | {OFFSET(gpmc_wait0), MODE(3) | RXACTIVE}, /* RMII2_CRS */ |
228 | {OFFSET(gpmc_wpn), MODE(3) | RXACTIVE}, /* RMII2_RXERR */ | 236 | {OFFSET(gpmc_wpn), MODE(3) | RXACTIVE}, /* RMII2_RXERR */ |
229 | {OFFSET(gpmc_a0), MODE(3)}, /* RMII2_TXEN */ | 237 | {OFFSET(gpmc_a0), MODE(3)}, /* RMII2_TXEN */ |
230 | {OFFSET(gpmc_a4), MODE(3)}, /* RMII2_TXD1 */ | 238 | {OFFSET(gpmc_a4), MODE(3)}, /* RMII2_TXD1 */ |
231 | {OFFSET(gpmc_a5), MODE(3)}, /* RMII2_TXD0 */ | 239 | {OFFSET(gpmc_a5), MODE(3)}, /* RMII2_TXD0 */ |
232 | {OFFSET(gpmc_a10), MODE(3) | RXACTIVE}, /* RMII2_RXD1 */ | 240 | {OFFSET(gpmc_a10), MODE(3) | RXACTIVE}, /* RMII2_RXD1 */ |
233 | {OFFSET(gpmc_a11), MODE(3) | RXACTIVE}, /* RMII2_RXD0 */ | 241 | {OFFSET(gpmc_a11), MODE(3) | RXACTIVE}, /* RMII2_RXD0 */ |
234 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */ | 242 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */ |
235 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ | 243 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
236 | {OFFSET(mii1_col), MODE(1) | RXACTIVE}, /* RMII2_REFCLK */ | 244 | {OFFSET(mii1_col), MODE(1) | RXACTIVE}, /* RMII2_REFCLK */ |
237 | {-1}, | 245 | {-1}, |
238 | }; | 246 | }; |
239 | 247 | ||
240 | static struct module_pin_mux mii1_pin_mux[] = { | 248 | static struct module_pin_mux mii1_pin_mux[] = { |
241 | {OFFSET(mii1_rxerr), MODE(0) | RXACTIVE}, /* MII1_RXERR */ | 249 | {OFFSET(mii1_rxerr), MODE(0) | RXACTIVE}, /* MII1_RXERR */ |
242 | {OFFSET(mii1_txen), MODE(0)}, /* MII1_TXEN */ | 250 | {OFFSET(mii1_txen), MODE(0)}, /* MII1_TXEN */ |
243 | {OFFSET(mii1_rxdv), MODE(0) | RXACTIVE}, /* MII1_RXDV */ | 251 | {OFFSET(mii1_rxdv), MODE(0) | RXACTIVE}, /* MII1_RXDV */ |
244 | {OFFSET(mii1_txd3), MODE(0)}, /* MII1_TXD3 */ | 252 | {OFFSET(mii1_txd3), MODE(0)}, /* MII1_TXD3 */ |
245 | {OFFSET(mii1_txd2), MODE(0)}, /* MII1_TXD2 */ | 253 | {OFFSET(mii1_txd2), MODE(0)}, /* MII1_TXD2 */ |
246 | {OFFSET(mii1_txd1), MODE(0)}, /* MII1_TXD1 */ | 254 | {OFFSET(mii1_txd1), MODE(0)}, /* MII1_TXD1 */ |
247 | {OFFSET(mii1_txd0), MODE(0)}, /* MII1_TXD0 */ | 255 | {OFFSET(mii1_txd0), MODE(0)}, /* MII1_TXD0 */ |
248 | {OFFSET(mii1_txclk), MODE(0) | RXACTIVE}, /* MII1_TXCLK */ | 256 | {OFFSET(mii1_txclk), MODE(0) | RXACTIVE}, /* MII1_TXCLK */ |
249 | {OFFSET(mii1_rxclk), MODE(0) | RXACTIVE}, /* MII1_RXCLK */ | 257 | {OFFSET(mii1_rxclk), MODE(0) | RXACTIVE}, /* MII1_RXCLK */ |
250 | {OFFSET(mii1_rxd3), MODE(0) | RXACTIVE}, /* MII1_RXD3 */ | 258 | {OFFSET(mii1_rxd3), MODE(0) | RXACTIVE}, /* MII1_RXD3 */ |
251 | {OFFSET(mii1_rxd2), MODE(0) | RXACTIVE}, /* MII1_RXD2 */ | 259 | {OFFSET(mii1_rxd2), MODE(0) | RXACTIVE}, /* MII1_RXD2 */ |
252 | {OFFSET(mii1_rxd1), MODE(0) | RXACTIVE}, /* MII1_RXD1 */ | 260 | {OFFSET(mii1_rxd1), MODE(0) | RXACTIVE}, /* MII1_RXD1 */ |
253 | {OFFSET(mii1_rxd0), MODE(0) | RXACTIVE}, /* MII1_RXD0 */ | 261 | {OFFSET(mii1_rxd0), MODE(0) | RXACTIVE}, /* MII1_RXD0 */ |
254 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */ | 262 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */ |
255 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ | 263 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
256 | {-1}, | 264 | {-1}, |
257 | }; | 265 | }; |
258 | 266 | ||
259 | #ifdef CONFIG_NAND | 267 | #ifdef CONFIG_NAND |
260 | static struct module_pin_mux nand_pin_mux[] = { | 268 | static struct module_pin_mux nand_pin_mux[] = { |
261 | {OFFSET(gpmc_ad0), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD0 */ | 269 | {OFFSET(gpmc_ad0), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD0 */ |
262 | {OFFSET(gpmc_ad1), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD1 */ | 270 | {OFFSET(gpmc_ad1), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD1 */ |
263 | {OFFSET(gpmc_ad2), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD2 */ | 271 | {OFFSET(gpmc_ad2), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD2 */ |
264 | {OFFSET(gpmc_ad3), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD3 */ | 272 | {OFFSET(gpmc_ad3), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD3 */ |
265 | {OFFSET(gpmc_ad4), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD4 */ | 273 | {OFFSET(gpmc_ad4), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD4 */ |
266 | {OFFSET(gpmc_ad5), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD5 */ | 274 | {OFFSET(gpmc_ad5), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD5 */ |
267 | {OFFSET(gpmc_ad6), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD6 */ | 275 | {OFFSET(gpmc_ad6), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD6 */ |
268 | {OFFSET(gpmc_ad7), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD7 */ | 276 | {OFFSET(gpmc_ad7), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD7 */ |
269 | #ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT | 277 | #ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT |
270 | {OFFSET(gpmc_ad8), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD8 */ | 278 | {OFFSET(gpmc_ad8), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD8 */ |
271 | {OFFSET(gpmc_ad9), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD9 */ | 279 | {OFFSET(gpmc_ad9), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD9 */ |
272 | {OFFSET(gpmc_ad10), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD10 */ | 280 | {OFFSET(gpmc_ad10), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD10 */ |
273 | {OFFSET(gpmc_ad11), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD11 */ | 281 | {OFFSET(gpmc_ad11), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD11 */ |
274 | {OFFSET(gpmc_ad12), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD12 */ | 282 | {OFFSET(gpmc_ad12), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD12 */ |
275 | {OFFSET(gpmc_ad13), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD13 */ | 283 | {OFFSET(gpmc_ad13), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD13 */ |
276 | {OFFSET(gpmc_ad14), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD14 */ | 284 | {OFFSET(gpmc_ad14), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD14 */ |
277 | {OFFSET(gpmc_ad15), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD15 */ | 285 | {OFFSET(gpmc_ad15), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD15 */ |
278 | #endif | 286 | #endif |
279 | {OFFSET(gpmc_wait0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* nWAIT */ | 287 | {OFFSET(gpmc_wait0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* nWAIT */ |
280 | {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN)}, /* nWP */ | 288 | {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN)}, /* nWP */ |
281 | {OFFSET(gpmc_csn0), (MODE(0) | PULLUP_EN)}, /* nCS */ | 289 | {OFFSET(gpmc_csn0), (MODE(0) | PULLUP_EN)}, /* nCS */ |
282 | {OFFSET(gpmc_wen), (MODE(0) | PULLDOWN_EN)}, /* WEN */ | 290 | {OFFSET(gpmc_wen), (MODE(0) | PULLDOWN_EN)}, /* WEN */ |
283 | {OFFSET(gpmc_oen_ren), (MODE(0) | PULLDOWN_EN)}, /* OE */ | 291 | {OFFSET(gpmc_oen_ren), (MODE(0) | PULLDOWN_EN)}, /* OE */ |
284 | {OFFSET(gpmc_advn_ale), (MODE(0) | PULLDOWN_EN)}, /* ADV_ALE */ | 292 | {OFFSET(gpmc_advn_ale), (MODE(0) | PULLDOWN_EN)}, /* ADV_ALE */ |
285 | {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLDOWN_EN)}, /* BE_CLE */ | 293 | {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLDOWN_EN)}, /* BE_CLE */ |
286 | {-1}, | 294 | {-1}, |
287 | }; | 295 | }; |
288 | #elif defined(CONFIG_NOR) | 296 | #elif defined(CONFIG_NOR) |
289 | static struct module_pin_mux bone_norcape_pin_mux[] = { | 297 | static struct module_pin_mux bone_norcape_pin_mux[] = { |
290 | {OFFSET(gpmc_a0), MODE(0) | PULLUDDIS}, /* NOR_A0 */ | 298 | {OFFSET(gpmc_a0), MODE(0) | PULLUDDIS}, /* NOR_A0 */ |
291 | {OFFSET(gpmc_a1), MODE(0) | PULLUDDIS}, /* NOR_A1 */ | 299 | {OFFSET(gpmc_a1), MODE(0) | PULLUDDIS}, /* NOR_A1 */ |
292 | {OFFSET(gpmc_a2), MODE(0) | PULLUDDIS}, /* NOR_A2 */ | 300 | {OFFSET(gpmc_a2), MODE(0) | PULLUDDIS}, /* NOR_A2 */ |
293 | {OFFSET(gpmc_a3), MODE(0) | PULLUDDIS}, /* NOR_A3 */ | 301 | {OFFSET(gpmc_a3), MODE(0) | PULLUDDIS}, /* NOR_A3 */ |
294 | {OFFSET(gpmc_a4), MODE(0) | PULLUDDIS}, /* NOR_A4 */ | 302 | {OFFSET(gpmc_a4), MODE(0) | PULLUDDIS}, /* NOR_A4 */ |
295 | {OFFSET(gpmc_a5), MODE(0) | PULLUDDIS}, /* NOR_A5 */ | 303 | {OFFSET(gpmc_a5), MODE(0) | PULLUDDIS}, /* NOR_A5 */ |
296 | {OFFSET(gpmc_a6), MODE(0) | PULLUDDIS}, /* NOR_A6 */ | 304 | {OFFSET(gpmc_a6), MODE(0) | PULLUDDIS}, /* NOR_A6 */ |
297 | {OFFSET(gpmc_a7), MODE(0) | PULLUDDIS}, /* NOR_A7 */ | 305 | {OFFSET(gpmc_a7), MODE(0) | PULLUDDIS}, /* NOR_A7 */ |
298 | {OFFSET(gpmc_ad0), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD0 */ | 306 | {OFFSET(gpmc_ad0), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD0 */ |
299 | {OFFSET(gpmc_ad1), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD1 */ | 307 | {OFFSET(gpmc_ad1), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD1 */ |
300 | {OFFSET(gpmc_ad2), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD2 */ | 308 | {OFFSET(gpmc_ad2), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD2 */ |
301 | {OFFSET(gpmc_ad3), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD3 */ | 309 | {OFFSET(gpmc_ad3), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD3 */ |
302 | {OFFSET(gpmc_ad4), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD4 */ | 310 | {OFFSET(gpmc_ad4), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD4 */ |
303 | {OFFSET(gpmc_ad5), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD5 */ | 311 | {OFFSET(gpmc_ad5), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD5 */ |
304 | {OFFSET(gpmc_ad6), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD6 */ | 312 | {OFFSET(gpmc_ad6), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD6 */ |
305 | {OFFSET(gpmc_ad7), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD7 */ | 313 | {OFFSET(gpmc_ad7), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD7 */ |
306 | {OFFSET(gpmc_ad8), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD8 */ | 314 | {OFFSET(gpmc_ad8), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD8 */ |
307 | {OFFSET(gpmc_ad9), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD9 */ | 315 | {OFFSET(gpmc_ad9), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD9 */ |
308 | {OFFSET(gpmc_ad10), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD10 */ | 316 | {OFFSET(gpmc_ad10), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD10 */ |
309 | {OFFSET(gpmc_ad11), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD11 */ | 317 | {OFFSET(gpmc_ad11), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD11 */ |
310 | {OFFSET(gpmc_ad12), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD12 */ | 318 | {OFFSET(gpmc_ad12), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD12 */ |
311 | {OFFSET(gpmc_ad13), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD13 */ | 319 | {OFFSET(gpmc_ad13), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD13 */ |
312 | {OFFSET(gpmc_ad14), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD14 */ | 320 | {OFFSET(gpmc_ad14), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD14 */ |
313 | {OFFSET(gpmc_ad15), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD15 */ | 321 | {OFFSET(gpmc_ad15), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD15 */ |
314 | {OFFSET(gpmc_csn0), MODE(0) | PULLUDEN | PULLUP_EN}, /* CE */ | 322 | {OFFSET(gpmc_csn0), MODE(0) | PULLUDEN | PULLUP_EN}, /* CE */ |
315 | {OFFSET(gpmc_advn_ale), MODE(0) | PULLUDEN | PULLDOWN_EN}, /* ALE */ | 323 | {OFFSET(gpmc_advn_ale), MODE(0) | PULLUDEN | PULLDOWN_EN}, /* ALE */ |
316 | {OFFSET(gpmc_oen_ren), MODE(0) | PULLUDEN | PULLDOWN_EN},/* OEn_REN */ | 324 | {OFFSET(gpmc_oen_ren), MODE(0) | PULLUDEN | PULLDOWN_EN},/* OEn_REN */ |
317 | {OFFSET(gpmc_be0n_cle), MODE(0) | PULLUDEN | PULLDOWN_EN},/* unused */ | 325 | {OFFSET(gpmc_be0n_cle), MODE(0) | PULLUDEN | PULLDOWN_EN},/* unused */ |
318 | {OFFSET(gpmc_wen), MODE(0) | PULLUDEN | PULLDOWN_EN}, /* WEN */ | 326 | {OFFSET(gpmc_wen), MODE(0) | PULLUDEN | PULLDOWN_EN}, /* WEN */ |
319 | {OFFSET(gpmc_wait0), MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE},/*WAIT*/ | 327 | {OFFSET(gpmc_wait0), MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE},/*WAIT*/ |
320 | {-1}, | 328 | {-1}, |
321 | }; | 329 | }; |
322 | #endif | 330 | #endif |
323 | 331 | ||
324 | #if defined(CONFIG_NOR_BOOT) | 332 | #if defined(CONFIG_NOR_BOOT) |
325 | void enable_norboot_pin_mux(void) | 333 | void enable_norboot_pin_mux(void) |
326 | { | 334 | { |
327 | configure_module_pin_mux(bone_norcape_pin_mux); | 335 | configure_module_pin_mux(bone_norcape_pin_mux); |
328 | } | 336 | } |
329 | #endif | 337 | #endif |
330 | 338 | ||
331 | void enable_uart0_pin_mux(void) | 339 | void enable_uart0_pin_mux(void) |
332 | { | 340 | { |
333 | configure_module_pin_mux(uart0_pin_mux); | 341 | configure_module_pin_mux(uart0_pin_mux); |
334 | } | 342 | } |
335 | 343 | ||
336 | void enable_uart1_pin_mux(void) | 344 | void enable_uart1_pin_mux(void) |
337 | { | 345 | { |
338 | configure_module_pin_mux(uart1_pin_mux); | 346 | configure_module_pin_mux(uart1_pin_mux); |
339 | } | 347 | } |
340 | 348 | ||
341 | void enable_uart2_pin_mux(void) | 349 | void enable_uart2_pin_mux(void) |
342 | { | 350 | { |
343 | configure_module_pin_mux(uart2_pin_mux); | 351 | configure_module_pin_mux(uart2_pin_mux); |
344 | } | 352 | } |
345 | 353 | ||
346 | void enable_uart3_pin_mux(void) | 354 | void enable_uart3_pin_mux(void) |
347 | { | 355 | { |
348 | configure_module_pin_mux(uart3_pin_mux); | 356 | configure_module_pin_mux(uart3_pin_mux); |
349 | } | 357 | } |
350 | 358 | ||
351 | void enable_uart4_pin_mux(void) | 359 | void enable_uart4_pin_mux(void) |
352 | { | 360 | { |
353 | configure_module_pin_mux(uart4_pin_mux); | 361 | configure_module_pin_mux(uart4_pin_mux); |
354 | } | 362 | } |
355 | 363 | ||
356 | void enable_uart5_pin_mux(void) | 364 | void enable_uart5_pin_mux(void) |
357 | { | 365 | { |
358 | configure_module_pin_mux(uart5_pin_mux); | 366 | configure_module_pin_mux(uart5_pin_mux); |
359 | } | 367 | } |
360 | 368 | ||
361 | void enable_i2c0_pin_mux(void) | 369 | void enable_i2c0_pin_mux(void) |
362 | { | 370 | { |
363 | configure_module_pin_mux(i2c0_pin_mux); | 371 | configure_module_pin_mux(i2c0_pin_mux); |
364 | } | 372 | } |
365 | 373 | ||
366 | /* | 374 | /* |
367 | * The AM335x GP EVM, if daughter card(s) are connected, can have 8 | 375 | * The AM335x GP EVM, if daughter card(s) are connected, can have 8 |
368 | * different profiles. These profiles determine what peripherals are | 376 | * different profiles. These profiles determine what peripherals are |
369 | * valid and need pinmux to be configured. | 377 | * valid and need pinmux to be configured. |
370 | */ | 378 | */ |
371 | #define PROFILE_NONE 0x0 | 379 | #define PROFILE_NONE 0x0 |
372 | #define PROFILE_0 (1 << 0) | 380 | #define PROFILE_0 (1 << 0) |
373 | #define PROFILE_1 (1 << 1) | 381 | #define PROFILE_1 (1 << 1) |
374 | #define PROFILE_2 (1 << 2) | 382 | #define PROFILE_2 (1 << 2) |
375 | #define PROFILE_3 (1 << 3) | 383 | #define PROFILE_3 (1 << 3) |
376 | #define PROFILE_4 (1 << 4) | 384 | #define PROFILE_4 (1 << 4) |
377 | #define PROFILE_5 (1 << 5) | 385 | #define PROFILE_5 (1 << 5) |
378 | #define PROFILE_6 (1 << 6) | 386 | #define PROFILE_6 (1 << 6) |
379 | #define PROFILE_7 (1 << 7) | 387 | #define PROFILE_7 (1 << 7) |
380 | #define PROFILE_MASK 0x7 | 388 | #define PROFILE_MASK 0x7 |
381 | #define PROFILE_ALL 0xFF | 389 | #define PROFILE_ALL 0xFF |
382 | 390 | ||
383 | /* CPLD registers */ | 391 | /* CPLD registers */ |
384 | #define I2C_CPLD_ADDR 0x35 | 392 | #define I2C_CPLD_ADDR 0x35 |
385 | #define CFG_REG 0x10 | 393 | #define CFG_REG 0x10 |
386 | 394 | ||
387 | static unsigned short detect_daughter_board_profile(void) | 395 | static unsigned short detect_daughter_board_profile(void) |
388 | { | 396 | { |
389 | unsigned short val; | 397 | unsigned short val; |
390 | 398 | ||
391 | if (i2c_probe(I2C_CPLD_ADDR)) | 399 | if (i2c_probe(I2C_CPLD_ADDR)) |
392 | return PROFILE_NONE; | 400 | return PROFILE_NONE; |
393 | 401 | ||
394 | if (i2c_read(I2C_CPLD_ADDR, CFG_REG, 1, (unsigned char *)(&val), 2)) | 402 | if (i2c_read(I2C_CPLD_ADDR, CFG_REG, 1, (unsigned char *)(&val), 2)) |
395 | return PROFILE_NONE; | 403 | return PROFILE_NONE; |
396 | 404 | ||
397 | return (1 << (val & PROFILE_MASK)); | 405 | return (1 << (val & PROFILE_MASK)); |
398 | } | 406 | } |
399 | 407 | ||
400 | void enable_board_pin_mux(struct am335x_baseboard_id *header) | 408 | void enable_board_pin_mux(struct am335x_baseboard_id *header) |
401 | { | 409 | { |
402 | /* Do board-specific muxes. */ | 410 | /* Do board-specific muxes. */ |
403 | if (board_is_bone(header)) { | 411 | if (board_is_bone(header)) { |
404 | /* Beaglebone pinmux */ | 412 | /* Beaglebone pinmux */ |
405 | configure_module_pin_mux(i2c1_pin_mux); | ||
406 | configure_module_pin_mux(mii1_pin_mux); | 413 | configure_module_pin_mux(mii1_pin_mux); |
407 | configure_module_pin_mux(mmc0_pin_mux); | 414 | configure_module_pin_mux(mmc0_pin_mux); |
408 | #if defined(CONFIG_NAND) | 415 | #if defined(CONFIG_NAND) |
409 | configure_module_pin_mux(nand_pin_mux); | 416 | configure_module_pin_mux(nand_pin_mux); |
410 | #elif defined(CONFIG_NOR) | 417 | #elif defined(CONFIG_NOR) |
411 | configure_module_pin_mux(bone_norcape_pin_mux); | 418 | configure_module_pin_mux(bone_norcape_pin_mux); |
412 | #else | 419 | #else |
413 | configure_module_pin_mux(mmc1_pin_mux); | 420 | configure_module_pin_mux(mmc1_pin_mux); |
414 | #endif | 421 | #endif |
415 | } else if (board_is_gp_evm(header)) { | 422 | } else if (board_is_gp_evm(header)) { |
416 | /* General Purpose EVM */ | 423 | /* General Purpose EVM */ |
417 | unsigned short profile = detect_daughter_board_profile(); | 424 | unsigned short profile = detect_daughter_board_profile(); |
418 | configure_module_pin_mux(rgmii1_pin_mux); | 425 | configure_module_pin_mux(rgmii1_pin_mux); |
419 | configure_module_pin_mux(mmc0_pin_mux); | 426 | configure_module_pin_mux(mmc0_pin_mux); |
420 | /* In profile #2 i2c1 and spi0 conflict. */ | ||
421 | if (profile & ~PROFILE_2) | ||
422 | configure_module_pin_mux(i2c1_pin_mux); | ||
423 | /* Profiles 2 & 3 don't have NAND */ | 427 | /* Profiles 2 & 3 don't have NAND */ |
424 | #ifdef CONFIG_NAND | 428 | #ifdef CONFIG_NAND |
425 | if (profile & ~(PROFILE_2 | PROFILE_3)) | 429 | if (profile & ~(PROFILE_2 | PROFILE_3)) |
426 | configure_module_pin_mux(nand_pin_mux); | 430 | configure_module_pin_mux(nand_pin_mux); |
427 | #endif | 431 | #endif |
428 | else if (profile == PROFILE_2) { | 432 | if (profile == PROFILE_2) { |
429 | configure_module_pin_mux(mmc1_pin_mux); | 433 | configure_module_pin_mux(mmc1_pin_mux); |
430 | configure_module_pin_mux(spi0_pin_mux); | 434 | configure_module_pin_mux(spi0_pin_mux); |
431 | } | 435 | } |
432 | } else if (board_is_idk(header)) { | 436 | } else if (board_is_idk(header)) { |
433 | /* Industrial Motor Control (IDK) */ | 437 | /* Industrial Motor Control (IDK) */ |
434 | configure_module_pin_mux(mii1_pin_mux); | 438 | configure_module_pin_mux(mii1_pin_mux); |
435 | configure_module_pin_mux(mmc0_no_cd_pin_mux); | 439 | configure_module_pin_mux(mmc0_no_cd_pin_mux); |
436 | } else if (board_is_evm_sk(header)) { | 440 | } else if (board_is_evm_sk(header)) { |
437 | /* Starter Kit EVM */ | 441 | /* Starter Kit EVM */ |
438 | configure_module_pin_mux(i2c1_pin_mux); | ||
439 | configure_module_pin_mux(gpio0_7_pin_mux); | 442 | configure_module_pin_mux(gpio0_7_pin_mux); |
440 | configure_module_pin_mux(rgmii1_pin_mux); | 443 | configure_module_pin_mux(rgmii1_pin_mux); |
441 | configure_module_pin_mux(mmc0_pin_mux_sk_evm); | 444 | configure_module_pin_mux(mmc0_pin_mux_sk_evm); |
442 | } else if (board_is_bone_lt(header)) { | 445 | } else if (board_is_bone_lt(header)) { |
443 | /* Beaglebone LT pinmux */ | 446 | /* Beaglebone LT pinmux */ |
444 | configure_module_pin_mux(i2c1_pin_mux); | ||
445 | configure_module_pin_mux(mii1_pin_mux); | 447 | configure_module_pin_mux(mii1_pin_mux); |
446 | configure_module_pin_mux(mmc0_pin_mux); | 448 | configure_module_pin_mux(mmc0_pin_mux); |
447 | #if defined(CONFIG_NAND) && defined(CONFIG_EMMC_BOOT) | 449 | #if defined(CONFIG_NAND) && defined(CONFIG_EMMC_BOOT) |
448 | configure_module_pin_mux(nand_pin_mux); | 450 | configure_module_pin_mux(nand_pin_mux); |
449 | #elif defined(CONFIG_NOR) && defined(CONFIG_EMMC_BOOT) | 451 | #elif defined(CONFIG_NOR) && defined(CONFIG_EMMC_BOOT) |
450 | configure_module_pin_mux(bone_norcape_pin_mux); | 452 | configure_module_pin_mux(bone_norcape_pin_mux); |
451 | #else | 453 | #else |
452 | configure_module_pin_mux(mmc1_pin_mux); | 454 | configure_module_pin_mux(mmc1_pin_mux); |
453 | #endif | 455 | #endif |
454 | } else if (!strncmp(header->name, "SMARCT33", HDR_NAME_LEN)) { | 456 | } else if (!strncmp(header->name, "SMARCT33", HDR_NAME_LEN)) { |
455 | /* SMARC T335X pinmux */ | 457 | /* SMARC T335X pinmux */ |
456 | /* i2c1 (pin37 and pin38 on P1 connector) in SBC-SMART-MEN is set as GPIOs*/ | ||
457 | /* configure_module_pin_mux(i2c1_pin_mux);*/ | ||
458 | configure_module_pin_mux(mmc0_pin_mux); | 458 | configure_module_pin_mux(mmc0_pin_mux); |
459 | configure_module_pin_mux(mmc1_pin_mux); | 459 | configure_module_pin_mux(mmc1_pin_mux); |
460 | configure_module_pin_mux(uart0_pin_mux); | ||
461 | configure_module_pin_mux(uart1_pin_mux); | ||
460 | configure_module_pin_mux(uart3_pin_mux); | 462 | configure_module_pin_mux(uart3_pin_mux); |
461 | configure_module_pin_mux(rmii1_pin_mux); | 463 | configure_module_pin_mux(rmii1_pin_mux); |
462 | configure_module_pin_mux(rmii2_pin_mux); | 464 | configure_module_pin_mux(rmii2_pin_mux); |
463 | configure_module_pin_mux(smarc_gpio_pin_mux); | 465 | configure_module_pin_mux(smarc_gpio_pin_mux); |
464 | configure_module_pin_mux(spi0_pin_mux); | 466 | configure_module_pin_mux(spi0_pin_mux); |
467 | configure_module_pin_mux(spi1_pin_mux); | ||
465 | configure_module_pin_mux(lcdc_pin_mux); | 468 | configure_module_pin_mux(lcdc_pin_mux); |
466 | } else if (!strncmp(header->name, "SMARCT80", HDR_NAME_LEN)) { | 469 | } else if (!strncmp(header->name, "SMARCT80", HDR_NAME_LEN)) { |
467 | /* SMARC T335X 800MHz pinmux */ | 470 | /* SMARC T335X 800MHz pinmux */ |
468 | configure_module_pin_mux(i2c1_pin_mux); | ||
469 | configure_module_pin_mux(mmc0_pin_mux); | 471 | configure_module_pin_mux(mmc0_pin_mux); |
470 | configure_module_pin_mux(mmc1_pin_mux); | 472 | configure_module_pin_mux(mmc1_pin_mux); |
473 | configure_module_pin_mux(uart0_pin_mux); | ||
474 | configure_module_pin_mux(uart1_pin_mux); | ||
471 | configure_module_pin_mux(uart3_pin_mux); | 475 | configure_module_pin_mux(uart3_pin_mux); |
472 | configure_module_pin_mux(rmii1_pin_mux); | 476 | configure_module_pin_mux(rmii1_pin_mux); |
473 | configure_module_pin_mux(rmii2_pin_mux); | 477 | configure_module_pin_mux(rmii2_pin_mux); |
474 | configure_module_pin_mux(smarc_gpio_pin_mux); | 478 | configure_module_pin_mux(smarc_gpio_pin_mux); |
475 | configure_module_pin_mux(spi0_pin_mux); | 479 | configure_module_pin_mux(spi0_pin_mux); |
480 | configure_module_pin_mux(spi1_pin_mux); | ||
476 | configure_module_pin_mux(lcdc_pin_mux); | 481 | configure_module_pin_mux(lcdc_pin_mux); |
drivers/i2c/i2c_core.c
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net> | 2 | * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net> |
3 | * | 3 | * |
4 | * (C) Copyright 2012 | 4 | * (C) Copyright 2012 |
5 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. | 5 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. |
6 | * | 6 | * |
7 | * Multibus/multiadapter I2C core functions (wrappers) | 7 | * Multibus/multiadapter I2C core functions (wrappers) |
8 | * | 8 | * |
9 | * SPDX-License-Identifier: GPL-2.0+ | 9 | * SPDX-License-Identifier: GPL-2.0+ |
10 | */ | 10 | */ |
11 | #include <common.h> | 11 | #include <common.h> |
12 | #include <i2c.h> | 12 | #include <i2c.h> |
13 | 13 | ||
14 | struct i2c_adapter *i2c_get_adapter(int index) | 14 | struct i2c_adapter *i2c_get_adapter(int index) |
15 | { | 15 | { |
16 | struct i2c_adapter *i2c_adap_p = ll_entry_start(struct i2c_adapter, | 16 | struct i2c_adapter *i2c_adap_p = ll_entry_start(struct i2c_adapter, |
17 | i2c); | 17 | i2c); |
18 | int max = ll_entry_count(struct i2c_adapter, i2c); | 18 | int max = ll_entry_count(struct i2c_adapter, i2c); |
19 | int i; | 19 | int i; |
20 | 20 | ||
21 | if (index >= max) { | 21 | if (index >= max) { |
22 | printf("Error, wrong i2c adapter %d max %d possible\n", | 22 | printf("Error, wrong i2c adapter %d max %d possible\n", |
23 | index, max); | 23 | index, max); |
24 | return i2c_adap_p; | 24 | return i2c_adap_p; |
25 | } | 25 | } |
26 | if (index == 0) | 26 | if (index == 0) |
27 | return i2c_adap_p; | 27 | return i2c_adap_p; |
28 | 28 | ||
29 | for (i = 0; i < index; i++) | 29 | for (i = 0; i < index; i++) |
30 | i2c_adap_p++; | 30 | i2c_adap_p++; |
31 | 31 | ||
32 | return i2c_adap_p; | 32 | return i2c_adap_p; |
33 | } | 33 | } |
34 | 34 | ||
35 | #if !defined(CONFIG_SYS_I2C_DIRECT_BUS) | 35 | #if !defined(CONFIG_SYS_I2C_DIRECT_BUS) |
36 | struct i2c_bus_hose i2c_bus[CONFIG_SYS_NUM_I2C_BUSES] = | 36 | struct i2c_bus_hose i2c_bus[CONFIG_SYS_NUM_I2C_BUSES] = |
37 | CONFIG_SYS_I2C_BUSES; | 37 | CONFIG_SYS_I2C_BUSES; |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | DECLARE_GLOBAL_DATA_PTR; | 40 | DECLARE_GLOBAL_DATA_PTR; |
41 | 41 | ||
42 | void i2c_reloc_fixup(void) | 42 | void i2c_reloc_fixup(void) |
43 | { | 43 | { |
44 | #if defined(CONFIG_NEEDS_MANUAL_RELOC) | 44 | #if defined(CONFIG_NEEDS_MANUAL_RELOC) |
45 | struct i2c_adapter *i2c_adap_p = ll_entry_start(struct i2c_adapter, | 45 | struct i2c_adapter *i2c_adap_p = ll_entry_start(struct i2c_adapter, |
46 | i2c); | 46 | i2c); |
47 | struct i2c_adapter *tmp = i2c_adap_p; | 47 | struct i2c_adapter *tmp = i2c_adap_p; |
48 | int max = ll_entry_count(struct i2c_adapter, i2c); | 48 | int max = ll_entry_count(struct i2c_adapter, i2c); |
49 | int i; | 49 | int i; |
50 | unsigned long addr; | 50 | unsigned long addr; |
51 | 51 | ||
52 | if (gd->reloc_off == 0) | 52 | if (gd->reloc_off == 0) |
53 | return; | 53 | return; |
54 | 54 | ||
55 | for (i = 0; i < max; i++) { | 55 | for (i = 0; i < max; i++) { |
56 | /* i2c_init() */ | 56 | /* i2c_init() */ |
57 | addr = (unsigned long)i2c_adap_p->init; | 57 | addr = (unsigned long)i2c_adap_p->init; |
58 | addr += gd->reloc_off; | 58 | addr += gd->reloc_off; |
59 | i2c_adap_p->init = (void *)addr; | 59 | i2c_adap_p->init = (void *)addr; |
60 | /* i2c_probe() */ | 60 | /* i2c_probe() */ |
61 | addr = (unsigned long)i2c_adap_p->probe; | 61 | addr = (unsigned long)i2c_adap_p->probe; |
62 | addr += gd->reloc_off; | 62 | addr += gd->reloc_off; |
63 | i2c_adap_p->probe = (void *)addr; | 63 | i2c_adap_p->probe = (void *)addr; |
64 | /* i2c_read() */ | 64 | /* i2c_read() */ |
65 | addr = (unsigned long)i2c_adap_p->read; | 65 | addr = (unsigned long)i2c_adap_p->read; |
66 | addr += gd->reloc_off; | 66 | addr += gd->reloc_off; |
67 | i2c_adap_p->read = (void *)addr; | 67 | i2c_adap_p->read = (void *)addr; |
68 | /* i2c_write() */ | 68 | /* i2c_write() */ |
69 | addr = (unsigned long)i2c_adap_p->write; | 69 | addr = (unsigned long)i2c_adap_p->write; |
70 | addr += gd->reloc_off; | 70 | addr += gd->reloc_off; |
71 | i2c_adap_p->write = (void *)addr; | 71 | i2c_adap_p->write = (void *)addr; |
72 | /* i2c_set_bus_speed() */ | 72 | /* i2c_set_bus_speed() */ |
73 | addr = (unsigned long)i2c_adap_p->set_bus_speed; | 73 | addr = (unsigned long)i2c_adap_p->set_bus_speed; |
74 | addr += gd->reloc_off; | 74 | addr += gd->reloc_off; |
75 | i2c_adap_p->set_bus_speed = (void *)addr; | 75 | i2c_adap_p->set_bus_speed = (void *)addr; |
76 | /* name */ | 76 | /* name */ |
77 | addr = (unsigned long)i2c_adap_p->name; | 77 | addr = (unsigned long)i2c_adap_p->name; |
78 | addr += gd->reloc_off; | 78 | addr += gd->reloc_off; |
79 | i2c_adap_p->name = (char *)addr; | 79 | i2c_adap_p->name = (char *)addr; |
80 | tmp++; | 80 | tmp++; |
81 | i2c_adap_p = tmp; | 81 | i2c_adap_p = tmp; |
82 | } | 82 | } |
83 | #endif | 83 | #endif |
84 | } | 84 | } |
85 | 85 | ||
86 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS | 86 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS |
87 | /* | 87 | /* |
88 | * i2c_mux_set() | 88 | * i2c_mux_set() |
89 | * ------------- | 89 | * ------------- |
90 | * | 90 | * |
91 | * This turns on the given channel on I2C multiplexer chip connected to | 91 | * This turns on the given channel on I2C multiplexer chip connected to |
92 | * a given I2C adapter directly or via other multiplexers. In the latter | 92 | * a given I2C adapter directly or via other multiplexers. In the latter |
93 | * case the entire multiplexer chain must be initialized first starting | 93 | * case the entire multiplexer chain must be initialized first starting |
94 | * with the one connected directly to the adapter. When disabling a chain | 94 | * with the one connected directly to the adapter. When disabling a chain |
95 | * muxes must be programmed in reverse order, starting with the one | 95 | * muxes must be programmed in reverse order, starting with the one |
96 | * farthest from the adapter. | 96 | * farthest from the adapter. |
97 | * | 97 | * |
98 | * mux_id is the multiplexer chip type from defined in i2c.h. So far only | 98 | * mux_id is the multiplexer chip type from defined in i2c.h. So far only |
99 | * NXP (Philips) PCA954x multiplexers are supported. Switches are NOT | 99 | * NXP (Philips) PCA954x multiplexers are supported. Switches are NOT |
100 | * supported (anybody uses them?) | 100 | * supported (anybody uses them?) |
101 | */ | 101 | */ |
102 | 102 | ||
103 | static int i2c_mux_set(struct i2c_adapter *adap, int mux_id, int chip, | 103 | static int i2c_mux_set(struct i2c_adapter *adap, int mux_id, int chip, |
104 | int channel) | 104 | int channel) |
105 | { | 105 | { |
106 | uint8_t buf; | 106 | uint8_t buf; |
107 | int ret; | 107 | int ret; |
108 | 108 | ||
109 | /* channel < 0 - turn off the mux */ | 109 | /* channel < 0 - turn off the mux */ |
110 | if (channel < 0) { | 110 | if (channel < 0) { |
111 | buf = 0; | 111 | buf = 0; |
112 | ret = adap->write(adap, chip, 0, 0, &buf, 1); | 112 | ret = adap->write(adap, chip, 0, 0, &buf, 1); |
113 | if (ret) | 113 | if (ret) |
114 | printf("%s: Could not turn off the mux.\n", __func__); | 114 | printf("%s: Could not turn off the mux.\n", __func__); |
115 | return ret; | 115 | return ret; |
116 | } | 116 | } |
117 | 117 | ||
118 | switch (mux_id) { | 118 | switch (mux_id) { |
119 | case I2C_MUX_PCA9540_ID: | 119 | case I2C_MUX_PCA9540_ID: |
120 | case I2C_MUX_PCA9542_ID: | 120 | case I2C_MUX_PCA9542_ID: |
121 | if (channel > 1) | 121 | if (channel > 1) |
122 | return -1; | 122 | return -1; |
123 | buf = (uint8_t)((channel & 0x01) | (1 << 2)); | 123 | buf = (uint8_t)((channel & 0x01) | (1 << 2)); |
124 | break; | 124 | break; |
125 | case I2C_MUX_PCA9544_ID: | 125 | case I2C_MUX_PCA9544_ID: |
126 | if (channel > 3) | 126 | if (channel > 3) |
127 | return -1; | 127 | return -1; |
128 | buf = (uint8_t)((channel & 0x03) | (1 << 2)); | 128 | buf = (uint8_t)((channel & 0x03) | (1 << 2)); |
129 | break; | 129 | break; |
130 | case I2C_MUX_PCA9546_ID: | ||
131 | if (channel > 4) | ||
132 | return -1; | ||
133 | buf = (uint8_t)((channel & 0x04) | (1 << 3)); | ||
134 | break; | ||
130 | case I2C_MUX_PCA9547_ID: | 135 | case I2C_MUX_PCA9547_ID: |
131 | if (channel > 7) | 136 | if (channel > 7) |
132 | return -1; | 137 | return -1; |
133 | buf = (uint8_t)((channel & 0x07) | (1 << 3)); | 138 | buf = (uint8_t)((channel & 0x07) | (1 << 3)); |
134 | break; | 139 | break; |
135 | case I2C_MUX_PCA9548_ID: | 140 | case I2C_MUX_PCA9548_ID: |
136 | if (channel > 7) | 141 | if (channel > 7) |
137 | return -1; | 142 | return -1; |
138 | buf = (uint8_t)(0x01 << channel); | 143 | buf = (uint8_t)(0x01 << channel); |
139 | break; | 144 | break; |
140 | default: | 145 | default: |
141 | printf("%s: wrong mux id: %d\n", __func__, mux_id); | 146 | printf("%s: wrong mux id: %d\n", __func__, mux_id); |
142 | return -1; | 147 | return -1; |
143 | } | 148 | } |
144 | 149 | ||
145 | ret = adap->write(adap, chip, 0, 0, &buf, 1); | 150 | ret = adap->write(adap, chip, 0, 0, &buf, 1); |
146 | if (ret) | 151 | if (ret) |
147 | printf("%s: could not set mux: id: %d chip: %x channel: %d\n", | 152 | printf("%s: could not set mux: id: %d chip: %x channel: %d\n", |
148 | __func__, mux_id, chip, channel); | 153 | __func__, mux_id, chip, channel); |
149 | return ret; | 154 | return ret; |
150 | } | 155 | } |
151 | 156 | ||
152 | static int i2c_mux_set_all(void) | 157 | static int i2c_mux_set_all(void) |
153 | { | 158 | { |
154 | struct i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS]; | 159 | struct i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS]; |
155 | int i; | 160 | int i; |
156 | 161 | ||
157 | /* Connect requested bus if behind muxes */ | 162 | /* Connect requested bus if behind muxes */ |
158 | if (i2c_bus_tmp->next_hop[0].chip != 0) { | 163 | if (i2c_bus_tmp->next_hop[0].chip != 0) { |
159 | /* Set all muxes along the path to that bus */ | 164 | /* Set all muxes along the path to that bus */ |
160 | for (i = 0; i < CONFIG_SYS_I2C_MAX_HOPS; i++) { | 165 | for (i = 0; i < CONFIG_SYS_I2C_MAX_HOPS; i++) { |
161 | int ret; | 166 | int ret; |
162 | 167 | ||
163 | if (i2c_bus_tmp->next_hop[i].chip == 0) | 168 | if (i2c_bus_tmp->next_hop[i].chip == 0) |
164 | break; | 169 | break; |
165 | 170 | ||
166 | ret = i2c_mux_set(I2C_ADAP, | 171 | ret = i2c_mux_set(I2C_ADAP, |
167 | i2c_bus_tmp->next_hop[i].mux.id, | 172 | i2c_bus_tmp->next_hop[i].mux.id, |
168 | i2c_bus_tmp->next_hop[i].chip, | 173 | i2c_bus_tmp->next_hop[i].chip, |
169 | i2c_bus_tmp->next_hop[i].channel); | 174 | i2c_bus_tmp->next_hop[i].channel); |
170 | if (ret != 0) | 175 | if (ret != 0) |
171 | return ret; | 176 | return ret; |
172 | } | 177 | } |
173 | } | 178 | } |
174 | return 0; | 179 | return 0; |
175 | } | 180 | } |
176 | 181 | ||
177 | static int i2c_mux_disconnect_all(void) | 182 | static int i2c_mux_disconnect_all(void) |
178 | { | 183 | { |
179 | struct i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS]; | 184 | struct i2c_bus_hose *i2c_bus_tmp = &i2c_bus[I2C_BUS]; |
180 | int i; | 185 | int i; |
181 | uint8_t buf = 0; | 186 | uint8_t buf = 0; |
182 | 187 | ||
183 | if (I2C_ADAP->init_done == 0) | 188 | if (I2C_ADAP->init_done == 0) |
184 | return 0; | 189 | return 0; |
185 | 190 | ||
186 | /* Disconnect current bus (turn off muxes if any) */ | 191 | /* Disconnect current bus (turn off muxes if any) */ |
187 | if ((i2c_bus_tmp->next_hop[0].chip != 0) && | 192 | if ((i2c_bus_tmp->next_hop[0].chip != 0) && |
188 | (I2C_ADAP->init_done != 0)) { | 193 | (I2C_ADAP->init_done != 0)) { |
189 | i = CONFIG_SYS_I2C_MAX_HOPS; | 194 | i = CONFIG_SYS_I2C_MAX_HOPS; |
190 | do { | 195 | do { |
191 | uint8_t chip; | 196 | uint8_t chip; |
192 | int ret; | 197 | int ret; |
193 | 198 | ||
194 | chip = i2c_bus_tmp->next_hop[--i].chip; | 199 | chip = i2c_bus_tmp->next_hop[--i].chip; |
195 | if (chip == 0) | 200 | if (chip == 0) |
196 | continue; | 201 | continue; |
197 | 202 | ||
198 | ret = I2C_ADAP->write(I2C_ADAP, chip, 0, 0, &buf, 1); | 203 | ret = I2C_ADAP->write(I2C_ADAP, chip, 0, 0, &buf, 1); |
199 | if (ret != 0) { | 204 | if (ret != 0) { |
200 | printf("i2c: mux disconnect error\n"); | 205 | printf("i2c: mux disconnect error\n"); |
201 | return ret; | 206 | return ret; |
202 | } | 207 | } |
203 | } while (i > 0); | 208 | } while (i > 0); |
204 | } | 209 | } |
205 | 210 | ||
206 | return 0; | 211 | return 0; |
207 | } | 212 | } |
208 | #endif | 213 | #endif |
209 | 214 | ||
210 | /* | 215 | /* |
211 | * i2c_init_bus(): | 216 | * i2c_init_bus(): |
212 | * --------------- | 217 | * --------------- |
213 | * | 218 | * |
214 | * Initializes one bus. Will initialize the parent adapter. No current bus | 219 | * Initializes one bus. Will initialize the parent adapter. No current bus |
215 | * changes, no mux (if any) setup. | 220 | * changes, no mux (if any) setup. |
216 | */ | 221 | */ |
217 | static void i2c_init_bus(unsigned int bus_no, int speed, int slaveaddr) | 222 | static void i2c_init_bus(unsigned int bus_no, int speed, int slaveaddr) |
218 | { | 223 | { |
219 | if (bus_no >= CONFIG_SYS_NUM_I2C_BUSES) | 224 | if (bus_no >= CONFIG_SYS_NUM_I2C_BUSES) |
220 | return; | 225 | return; |
221 | 226 | ||
222 | I2C_ADAP->init(I2C_ADAP, speed, slaveaddr); | 227 | I2C_ADAP->init(I2C_ADAP, speed, slaveaddr); |
223 | 228 | ||
224 | if (gd->flags & GD_FLG_RELOC) { | 229 | if (gd->flags & GD_FLG_RELOC) { |
225 | I2C_ADAP->init_done = 1; | 230 | I2C_ADAP->init_done = 1; |
226 | I2C_ADAP->speed = speed; | 231 | I2C_ADAP->speed = speed; |
227 | I2C_ADAP->slaveaddr = slaveaddr; | 232 | I2C_ADAP->slaveaddr = slaveaddr; |
228 | } | 233 | } |
229 | } | 234 | } |
230 | 235 | ||
231 | /* implement possible board specific board init */ | 236 | /* implement possible board specific board init */ |
232 | __weak void i2c_init_board(void) | 237 | __weak void i2c_init_board(void) |
233 | { | 238 | { |
234 | } | 239 | } |
235 | 240 | ||
236 | /* | 241 | /* |
237 | * i2c_init_all(): | 242 | * i2c_init_all(): |
238 | * | 243 | * |
239 | * not longer needed, will deleted. Actual init the SPD_BUS | 244 | * not longer needed, will deleted. Actual init the SPD_BUS |
240 | * for compatibility. | 245 | * for compatibility. |
241 | * i2c_adap[] must be initialized beforehead with function pointers and | 246 | * i2c_adap[] must be initialized beforehead with function pointers and |
242 | * data, including speed and slaveaddr. | 247 | * data, including speed and slaveaddr. |
243 | */ | 248 | */ |
244 | void i2c_init_all(void) | 249 | void i2c_init_all(void) |
245 | { | 250 | { |
246 | i2c_init_board(); | 251 | i2c_init_board(); |
247 | i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM); | 252 | i2c_set_bus_num(CONFIG_SYS_SPD_BUS_NUM); |
248 | return; | 253 | return; |
249 | } | 254 | } |
250 | 255 | ||
251 | /* | 256 | /* |
252 | * i2c_get_bus_num(): | 257 | * i2c_get_bus_num(): |
253 | * ------------------ | 258 | * ------------------ |
254 | * | 259 | * |
255 | * Returns index of currently active I2C bus. Zero-based. | 260 | * Returns index of currently active I2C bus. Zero-based. |
256 | */ | 261 | */ |
257 | unsigned int i2c_get_bus_num(void) | 262 | unsigned int i2c_get_bus_num(void) |
258 | { | 263 | { |
259 | return gd->cur_i2c_bus; | 264 | return gd->cur_i2c_bus; |
260 | } | 265 | } |
261 | 266 | ||
262 | /* | 267 | /* |
263 | * i2c_set_bus_num(): | 268 | * i2c_set_bus_num(): |
264 | * ------------------ | 269 | * ------------------ |
265 | * | 270 | * |
266 | * Change the active I2C bus. Subsequent read/write calls will | 271 | * Change the active I2C bus. Subsequent read/write calls will |
267 | * go to this one. Sets all of the muxes in a proper condition | 272 | * go to this one. Sets all of the muxes in a proper condition |
268 | * if that bus is behind muxes. | 273 | * if that bus is behind muxes. |
269 | * If previously selected bus is behind the muxes turns off all the | 274 | * If previously selected bus is behind the muxes turns off all the |
270 | * muxes along the path to that bus. | 275 | * muxes along the path to that bus. |
271 | * | 276 | * |
272 | * bus - bus index, zero based | 277 | * bus - bus index, zero based |
273 | * | 278 | * |
274 | * Returns: 0 on success, not 0 on failure | 279 | * Returns: 0 on success, not 0 on failure |
275 | */ | 280 | */ |
276 | int i2c_set_bus_num(unsigned int bus) | 281 | int i2c_set_bus_num(unsigned int bus) |
277 | { | 282 | { |
278 | int max; | 283 | int max; |
279 | 284 | ||
280 | if ((bus == I2C_BUS) && (I2C_ADAP->init_done > 0)) | 285 | if ((bus == I2C_BUS) && (I2C_ADAP->init_done > 0)) |
281 | return 0; | 286 | return 0; |
282 | 287 | ||
283 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS | 288 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS |
284 | if (bus >= CONFIG_SYS_NUM_I2C_BUSES) | 289 | if (bus >= CONFIG_SYS_NUM_I2C_BUSES) |
285 | return -1; | 290 | return -1; |
286 | #endif | 291 | #endif |
287 | 292 | ||
288 | max = ll_entry_count(struct i2c_adapter, i2c); | 293 | max = ll_entry_count(struct i2c_adapter, i2c); |
289 | if (I2C_ADAPTER(bus) >= max) { | 294 | if (I2C_ADAPTER(bus) >= max) { |
290 | printf("Error, wrong i2c adapter %d max %d possible\n", | 295 | printf("Error, wrong i2c adapter %d max %d possible\n", |
291 | I2C_ADAPTER(bus), max); | 296 | I2C_ADAPTER(bus), max); |
292 | return -2; | 297 | return -2; |
293 | } | 298 | } |
294 | 299 | ||
295 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS | 300 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS |
296 | i2c_mux_disconnect_all(); | 301 | i2c_mux_disconnect_all(); |
297 | #endif | 302 | #endif |
298 | 303 | ||
299 | gd->cur_i2c_bus = bus; | 304 | gd->cur_i2c_bus = bus; |
300 | if (I2C_ADAP->init_done == 0) | 305 | if (I2C_ADAP->init_done == 0) |
301 | i2c_init_bus(bus, I2C_ADAP->speed, I2C_ADAP->slaveaddr); | 306 | i2c_init_bus(bus, I2C_ADAP->speed, I2C_ADAP->slaveaddr); |
302 | 307 | ||
303 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS | 308 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS |
304 | i2c_mux_set_all(); | 309 | i2c_mux_set_all(); |
305 | #endif | 310 | #endif |
306 | return 0; | 311 | return 0; |
307 | } | 312 | } |
308 | 313 | ||
309 | /* | 314 | /* |
310 | * Probe the given I2C chip address. Returns 0 if a chip responded, | 315 | * Probe the given I2C chip address. Returns 0 if a chip responded, |
311 | * not 0 on failure. | 316 | * not 0 on failure. |
312 | */ | 317 | */ |
313 | int i2c_probe(uint8_t chip) | 318 | int i2c_probe(uint8_t chip) |
314 | { | 319 | { |
315 | return I2C_ADAP->probe(I2C_ADAP, chip); | 320 | return I2C_ADAP->probe(I2C_ADAP, chip); |
316 | } | 321 | } |
317 | 322 | ||
318 | /* | 323 | /* |
319 | * Read/Write interface: | 324 | * Read/Write interface: |
320 | * chip: I2C chip address, range 0..127 | 325 | * chip: I2C chip address, range 0..127 |
321 | * addr: Memory (register) address within the chip | 326 | * addr: Memory (register) address within the chip |
322 | * alen: Number of bytes to use for addr (typically 1, 2 for larger | 327 | * alen: Number of bytes to use for addr (typically 1, 2 for larger |
323 | * memories, 0 for register type devices with only one | 328 | * memories, 0 for register type devices with only one |
324 | * register) | 329 | * register) |
325 | * buffer: Where to read/write the data | 330 | * buffer: Where to read/write the data |
326 | * len: How many bytes to read/write | 331 | * len: How many bytes to read/write |
327 | * | 332 | * |
328 | * Returns: 0 on success, not 0 on failure | 333 | * Returns: 0 on success, not 0 on failure |
329 | */ | 334 | */ |
330 | int i2c_read(uint8_t chip, unsigned int addr, int alen, | 335 | int i2c_read(uint8_t chip, unsigned int addr, int alen, |
331 | uint8_t *buffer, int len) | 336 | uint8_t *buffer, int len) |
332 | { | 337 | { |
333 | return I2C_ADAP->read(I2C_ADAP, chip, addr, alen, buffer, len); | 338 | return I2C_ADAP->read(I2C_ADAP, chip, addr, alen, buffer, len); |
334 | } | 339 | } |
335 | 340 | ||
336 | int i2c_write(uint8_t chip, unsigned int addr, int alen, | 341 | int i2c_write(uint8_t chip, unsigned int addr, int alen, |
337 | uint8_t *buffer, int len) | 342 | uint8_t *buffer, int len) |
338 | { | 343 | { |
339 | return I2C_ADAP->write(I2C_ADAP, chip, addr, alen, buffer, len); | 344 | return I2C_ADAP->write(I2C_ADAP, chip, addr, alen, buffer, len); |
340 | } | 345 | } |
341 | 346 | ||
342 | unsigned int i2c_set_bus_speed(unsigned int speed) | 347 | unsigned int i2c_set_bus_speed(unsigned int speed) |
343 | { | 348 | { |
344 | unsigned int ret; | 349 | unsigned int ret; |
345 | 350 | ||
346 | if (I2C_ADAP->set_bus_speed == NULL) | 351 | if (I2C_ADAP->set_bus_speed == NULL) |
347 | return 0; | 352 | return 0; |
348 | ret = I2C_ADAP->set_bus_speed(I2C_ADAP, speed); | 353 | ret = I2C_ADAP->set_bus_speed(I2C_ADAP, speed); |
349 | if (gd->flags & GD_FLG_RELOC) | 354 | if (gd->flags & GD_FLG_RELOC) |
350 | I2C_ADAP->speed = (ret == 0) ? speed : 0; | 355 | I2C_ADAP->speed = (ret == 0) ? speed : 0; |
351 | 356 | ||
352 | return ret; | 357 | return ret; |
353 | } | 358 | } |
354 | 359 | ||
355 | unsigned int i2c_get_bus_speed(void) | 360 | unsigned int i2c_get_bus_speed(void) |
356 | { | 361 | { |
357 | struct i2c_adapter *cur = I2C_ADAP; | 362 | struct i2c_adapter *cur = I2C_ADAP; |
358 | return cur->speed; | 363 | return cur->speed; |
359 | } | 364 | } |
360 | 365 | ||
361 | uint8_t i2c_reg_read(uint8_t addr, uint8_t reg) | 366 | uint8_t i2c_reg_read(uint8_t addr, uint8_t reg) |
362 | { | 367 | { |
363 | uint8_t buf; | 368 | uint8_t buf; |
364 | 369 | ||
365 | #ifdef CONFIG_8xx | 370 | #ifdef CONFIG_8xx |
366 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ | 371 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ |
367 | /* maybe it is now the time for it ... */ | 372 | /* maybe it is now the time for it ... */ |
368 | i2c_set_bus_num(i2c_get_bus_num()); | 373 | i2c_set_bus_num(i2c_get_bus_num()); |
369 | #endif | 374 | #endif |
370 | i2c_read(addr, reg, 1, &buf, 1); | 375 | i2c_read(addr, reg, 1, &buf, 1); |
371 | 376 | ||
372 | #ifdef DEBUG | 377 | #ifdef DEBUG |
373 | printf("%s: bus=%d addr=0x%02x, reg=0x%02x, val=0x%02x\n", | 378 | printf("%s: bus=%d addr=0x%02x, reg=0x%02x, val=0x%02x\n", |
374 | __func__, i2c_get_bus_num(), addr, reg, buf); | 379 | __func__, i2c_get_bus_num(), addr, reg, buf); |
375 | #endif | 380 | #endif |
376 | 381 | ||
377 | return buf; | 382 | return buf; |
378 | } | 383 | } |
379 | 384 | ||
380 | void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val) | 385 | void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val) |
381 | { | 386 | { |
382 | #ifdef CONFIG_8xx | 387 | #ifdef CONFIG_8xx |
383 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ | 388 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ |
384 | /* maybe it is now the time for it ... */ | 389 | /* maybe it is now the time for it ... */ |
385 | i2c_set_bus_num(i2c_get_bus_num()); | 390 | i2c_set_bus_num(i2c_get_bus_num()); |
386 | #endif | 391 | #endif |
387 | 392 | ||
388 | #ifdef DEBUG | 393 | #ifdef DEBUG |
389 | printf("%s: bus=%d addr=0x%02x, reg=0x%02x, val=0x%02x\n", | 394 | printf("%s: bus=%d addr=0x%02x, reg=0x%02x, val=0x%02x\n", |
390 | __func__, i2c_get_bus_num(), addr, reg, val); | 395 | __func__, i2c_get_bus_num(), addr, reg, val); |
391 | #endif | 396 | #endif |
392 | 397 | ||
393 | i2c_write(addr, reg, 1, &val, 1); | 398 | i2c_write(addr, reg, 1, &val, 1); |
394 | } | 399 | } |
395 | 400 | ||
396 | __weak void i2c_init(int speed, int slaveaddr) | 401 | __weak void i2c_init(int speed, int slaveaddr) |
397 | { | 402 | { |
398 | i2c_init_bus(i2c_get_bus_num(), speed, slaveaddr); | 403 | i2c_init_bus(i2c_get_bus_num(), speed, slaveaddr); |
399 | } | 404 | } |
400 | 405 |
include/configs/smarct335x_evm.h
1 | /* | 1 | /* |
2 | * am335x_evm.h | 2 | * am335x_evm.h |
3 | * | 3 | * |
4 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ | 4 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or | 6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License as | 7 | * modify it under the terms of the GNU General Public License as |
8 | * published by the Free Software Foundation version 2. | 8 | * published by the Free Software Foundation version 2. |
9 | * | 9 | * |
10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | 10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any |
11 | * kind, whether express or implied; without even the implied warranty | 11 | * kind, whether express or implied; without even the implied warranty |
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #ifndef __CONFIG_SMARCT335X_EVM_H | 16 | #ifndef __CONFIG_SMARCT335X_EVM_H |
17 | #define __CONFIG_SMARCT335X_EVM_H | 17 | #define __CONFIG_SMARCT335X_EVM_H |
18 | 18 | ||
19 | #include <configs/embedian_am335x_common.h> | 19 | #include <configs/embedian_am335x_common.h> |
20 | #define CONFIG_ENV_IS_NOWHERE | 20 | #define CONFIG_ENV_IS_NOWHERE |
21 | 21 | ||
22 | #ifndef CONFIG_SPL_BUILD | 22 | #ifndef CONFIG_SPL_BUILD |
23 | # define CONFIG_TIMESTAMP | 23 | # define CONFIG_TIMESTAMP |
24 | # define CONFIG_LZO | 24 | # define CONFIG_LZO |
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | #define CONFIG_SYS_BOOTM_LEN (16 << 20) | 27 | #define CONFIG_SYS_BOOTM_LEN (16 << 20) |
28 | 28 | ||
29 | #define MACH_TYPE_SMARCT335XEVM 3600 /* Until the next sync */ | 29 | #define MACH_TYPE_SMARCT335XEVM 3600 /* Until the next sync */ |
30 | #define CONFIG_MACH_TYPE MACH_TYPE_SMARCT335XEVM | 30 | #define CONFIG_MACH_TYPE MACH_TYPE_SMARCT335XEVM |
31 | #define CONFIG_BOARD_LATE_INIT | 31 | #define CONFIG_BOARD_LATE_INIT |
32 | 32 | ||
33 | /* Clock Defines */ | 33 | /* Clock Defines */ |
34 | #define V_OSCK 24000000 /* Clock output from T2 */ | 34 | #define V_OSCK 24000000 /* Clock output from T2 */ |
35 | #define V_SCLK (V_OSCK) | 35 | #define V_SCLK (V_OSCK) |
36 | 36 | ||
37 | /* Custom script for NOR */ | 37 | /* Custom script for NOR */ |
38 | #define CONFIG_SYS_LDSCRIPT "board/embedian/smarct335x/u-boot.lds" | 38 | #define CONFIG_SYS_LDSCRIPT "board/embedian/smarct335x/u-boot.lds" |
39 | 39 | ||
40 | /* Always 128 KiB env size */ | 40 | /* Always 128 KiB env size */ |
41 | #define CONFIG_ENV_SIZE (128 << 10) | 41 | #define CONFIG_ENV_SIZE (128 << 10) |
42 | 42 | ||
43 | /* Enhance our eMMC support / experience. */ | 43 | /* Enhance our eMMC support / experience. */ |
44 | #define CONFIG_CMD_GPT | 44 | #define CONFIG_CMD_GPT |
45 | #define CONFIG_EFI_PARTITION | 45 | #define CONFIG_EFI_PARTITION |
46 | 46 | ||
47 | /* Enable Atheros phy driver */ | 47 | /* Enable Atheros phy driver */ |
48 | /* #define CONFIG_PHY_ATHEROS */ | 48 | /* #define CONFIG_PHY_ATHEROS */ |
49 | 49 | ||
50 | #ifdef CONFIG_NAND | 50 | #ifdef CONFIG_NAND |
51 | #define NANDARGS \ | 51 | #define NANDARGS \ |
52 | "mtdids=" MTDIDS_DEFAULT "\0" \ | 52 | "mtdids=" MTDIDS_DEFAULT "\0" \ |
53 | "mtdparts=" MTDPARTS_DEFAULT "\0" \ | 53 | "mtdparts=" MTDPARTS_DEFAULT "\0" \ |
54 | "nandargs=setenv bootargs console=${console} " \ | 54 | "nandargs=setenv bootargs console=${console} " \ |
55 | "${optargs} " \ | 55 | "${optargs} " \ |
56 | "root=${nandroot} " \ | 56 | "root=${nandroot} " \ |
57 | "rootfstype=${nandrootfstype}\0" \ | 57 | "rootfstype=${nandrootfstype}\0" \ |
58 | "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048\0" \ | 58 | "nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048\0" \ |
59 | "nandrootfstype=ubifs rootwait=1\0" \ | 59 | "nandrootfstype=ubifs rootwait=1\0" \ |
60 | "nandboot=echo Booting from nand ...; " \ | 60 | "nandboot=echo Booting from nand ...; " \ |
61 | "run nandargs; " \ | 61 | "run nandargs; " \ |
62 | "nand read ${fdtaddr} NAND.u-boot-spl-os; " \ | 62 | "nand read ${fdtaddr} NAND.u-boot-spl-os; " \ |
63 | "nand read ${loadaddr} NAND.kernel; " \ | 63 | "nand read ${loadaddr} NAND.kernel; " \ |
64 | "bootz ${loadaddr} - ${fdtaddr}\0" | 64 | "bootz ${loadaddr} - ${fdtaddr}\0" |
65 | #else | 65 | #else |
66 | #define NANDARGS "" | 66 | #define NANDARGS "" |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | 69 | #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
70 | 70 | ||
71 | #define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \ | 71 | #define BOOTENV_DEV_LEGACY_MMC(devtypeu, devtypel, instance) \ |
72 | "bootcmd_" #devtypel #instance "=" \ | 72 | "bootcmd_" #devtypel #instance "=" \ |
73 | "setenv mmcdev " #instance"; "\ | 73 | "setenv mmcdev " #instance"; "\ |
74 | "setenv bootpart " #instance":2 ; "\ | 74 | "setenv bootpart " #instance":2 ; "\ |
75 | "run mmcboot\0" | 75 | "run mmcboot\0" |
76 | 76 | ||
77 | #define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \ | 77 | #define BOOTENV_DEV_NAME_LEGACY_MMC(devtypeu, devtypel, instance) \ |
78 | #devtypel #instance " " | 78 | #devtypel #instance " " |
79 | 79 | ||
80 | #define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \ | 80 | #define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \ |
81 | "bootcmd_" #devtypel "=" \ | 81 | "bootcmd_" #devtypel "=" \ |
82 | "run nandboot\0" | 82 | "run nandboot\0" |
83 | 83 | ||
84 | #define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance) \ | 84 | #define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance) \ |
85 | #devtypel #instance " " | 85 | #devtypel #instance " " |
86 | 86 | ||
87 | #define BOOT_TARGET_DEVICES(func) \ | 87 | #define BOOT_TARGET_DEVICES(func) \ |
88 | func(MMC, mmc, 0) \ | 88 | func(MMC, mmc, 0) \ |
89 | func(LEGACY_MMC, legacy_mmc, 0) \ | 89 | func(LEGACY_MMC, legacy_mmc, 0) \ |
90 | func(MMC, mmc, 1) \ | 90 | func(MMC, mmc, 1) \ |
91 | func(LEGACY_MMC, legacy_mmc, 1) \ | 91 | func(LEGACY_MMC, legacy_mmc, 1) \ |
92 | func(NAND, nand, 0) \ | 92 | func(NAND, nand, 0) \ |
93 | func(PXE, pxe, na) \ | 93 | func(PXE, pxe, na) \ |
94 | func(DHCP, dhcp, na) | 94 | func(DHCP, dhcp, na) |
95 | 95 | ||
96 | #define CONFIG_BOOTCOMMAND \ | 96 | #define CONFIG_BOOTCOMMAND \ |
97 | "i2c mw 0x24 1 0x3e;" \ | ||
97 | "setenv umsmedia 0; "\ | 98 | "setenv umsmedia 0; "\ |
98 | "i2c mw 0x24 1 0x3e; " \ | ||
99 | "run findfdt; " \ | 99 | "run findfdt; " \ |
100 | "run finduuid; " \ | 100 | "run finduuid; " \ |
101 | "run mmcboot;" \ | 101 | "run mmcboot;" \ |
102 | "run failumsboot;" | 102 | "run failumsboot;" |
103 | 103 | ||
104 | #include <config_distro_bootcmd.h> | 104 | #include <config_distro_bootcmd.h> |
105 | 105 | ||
106 | #ifndef CONFIG_SPL_BUILD | 106 | #ifndef CONFIG_SPL_BUILD |
107 | #define CONFIG_EXTRA_ENV_SETTINGS \ | 107 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
108 | DEFAULT_LINUX_BOOT_ENV \ | 108 | DEFAULT_LINUX_BOOT_ENV \ |
109 | DEFAULT_MMC_TI_ARGS \ | 109 | DEFAULT_MMC_TI_ARGS \ |
110 | "boot_fdt=try\0" \ | 110 | "boot_fdt=try\0" \ |
111 | "mmcdev=0\0" \ | 111 | "mmcdev=0\0" \ |
112 | "bootpart=${mmcdev}:1\0" \ | 112 | "bootpart=${mmcdev}:1\0" \ |
113 | "bootdir=\0" \ | 113 | "bootdir=\0" \ |
114 | "fdtdir=/dtbs\0" \ | 114 | "fdtdir=/dtbs\0" \ |
115 | "bootfile=zImage\0" \ | 115 | "bootfile=zImage\0" \ |
116 | "fdtfile=undefined\0" \ | 116 | "fdtfile=undefined\0" \ |
117 | "console=ttyO3,115200n8\0" \ | 117 | "console=ttyO3,115200n8\0" \ |
118 | "partitions=" \ | 118 | "partitions=" \ |
119 | "uuid_disk=${uuid_gpt_disk};" \ | 119 | "uuid_disk=${uuid_gpt_disk};" \ |
120 | "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \ | 120 | "name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}\0" \ |
121 | "optargs=\0" \ | 121 | "optargs=\0" \ |
122 | "cape_disable=\0" \ | 122 | "cape_disable=\0" \ |
123 | "cape_enable=\0" \ | 123 | "cape_enable=\0" \ |
124 | "cmdline=\0" \ | 124 | "cmdline=\0" \ |
125 | "mmcpart=1\0" \ | 125 | "mmcpart=1\0" \ |
126 | "ramroot=/dev/ram0 rw\0" \ | 126 | "ramroot=/dev/ram0 rw\0" \ |
127 | "ramrootfstype=ext2\0" \ | 127 | "ramrootfstype=ext2\0" \ |
128 | "spiroot=/dev/mtdblock4 rw\0" \ | 128 | "spiroot=/dev/mtdblock4 rw\0" \ |
129 | "spirootfstype=jffs2\0" \ | 129 | "spirootfstype=jffs2\0" \ |
130 | "spisrcaddr=0xe0000\0" \ | 130 | "spisrcaddr=0xe0000\0" \ |
131 | "spiimgsize=0x362000\0" \ | 131 | "spiimgsize=0x362000\0" \ |
132 | "spibusno=0\0" \ | 132 | "spibusno=0\0" \ |
133 | "spiargs=setenv bootargs console=${console} " \ | 133 | "spiargs=setenv bootargs console=${console} " \ |
134 | "${optargs} " \ | 134 | "${optargs} " \ |
135 | "root=${spiroot} " \ | 135 | "root=${spiroot} " \ |
136 | "rootfstype=${spirootfstype}\0" \ | 136 | "rootfstype=${spirootfstype}\0" \ |
137 | "bootenv=uEnv.txt\0" \ | 137 | "bootenv=uEnv.txt\0" \ |
138 | "server_ip=192.168.1.110\0" \ | 138 | "server_ip=192.168.1.110\0" \ |
139 | "gw_ip=192.168.1.254\0" \ | 139 | "gw_ip=192.168.1.254\0" \ |
140 | "netmask=255.255.255.0\0" \ | 140 | "netmask=255.255.255.0\0" \ |
141 | "hostname=smarct335x\0" \ | 141 | "hostname=smarct335x\0" \ |
142 | "device=eth0\0" \ | 142 | "device=eth0\0" \ |
143 | "autoconf=off\0" \ | 143 | "autoconf=off\0" \ |
144 | "root_dir=/home/userid/targetNFS\0" \ | 144 | "root_dir=/home/userid/targetNFS\0" \ |
145 | "tftp_dir=\0" \ | 145 | "tftp_dir=\0" \ |
146 | "nfs_options=,vers=3\0" \ | 146 | "nfs_options=,vers=3\0" \ |
147 | "nfsrootfstype=ext4 rootwait fixrtc\0" \ | 147 | "nfsrootfstype=ext4 rootwait fixrtc\0" \ |
148 | "nfsargs=setenv bootargs console=${console} " \ | 148 | "nfsargs=setenv bootargs console=${console} " \ |
149 | "${optargs} " \ | 149 | "${optargs} " \ |
150 | "${cape_disable} " \ | 150 | "${cape_disable} " \ |
151 | "${cape_enable} " \ | 151 | "${cape_enable} " \ |
152 | "root=/dev/nfs rw " \ | 152 | "root=/dev/nfs rw " \ |
153 | "rootfstype=${nfsrootfstype} " \ | 153 | "rootfstype=${nfsrootfstype} " \ |
154 | "nfsroot=${nfsroot} " \ | 154 | "nfsroot=${nfsroot} " \ |
155 | "ip=${ip} " \ | 155 | "ip=${ip} " \ |
156 | "${cmdline}\0" \ | 156 | "${cmdline}\0" \ |
157 | "spiroot=/dev/mtdblock4 rw\0" \ | 157 | "spiroot=/dev/mtdblock4 rw\0" \ |
158 | "spirootfstype=jffs2\0" \ | 158 | "spirootfstype=jffs2\0" \ |
159 | "spisrcaddr=0xe0000\0" \ | 159 | "spisrcaddr=0xe0000\0" \ |
160 | "spiimgsize=0x362000\0" \ | 160 | "spiimgsize=0x362000\0" \ |
161 | "spibusno=0\0" \ | 161 | "spibusno=0\0" \ |
162 | "root=${spiroot} " \ | 162 | "root=${spiroot} " \ |
163 | "rootfstype=${spirootfstype}\0" \ | 163 | "rootfstype=${spirootfstype}\0" \ |
164 | "bootenv=uEnv.txt\0" \ | 164 | "bootenv=uEnv.txt\0" \ |
165 | "script=boot.scr\0" \ | 165 | "script=boot.scr\0" \ |
166 | "scriptfile=${script}\0" \ | 166 | "scriptfile=${script}\0" \ |
167 | "loadbootscript=load mmc ${bootpart} ${loadaddr} ${scriptfile};\0" \ | 167 | "loadbootscript=load mmc ${bootpart} ${loadaddr} ${scriptfile};\0" \ |
168 | "bootscript=echo Running bootscript from mmc${bootpart} ...; " \ | 168 | "bootscript=echo Running bootscript from mmc${bootpart} ...; " \ |
169 | "source ${loadaddr}\0" \ | 169 | "source ${loadaddr}\0" \ |
170 | "loadbootenv=load mmc ${bootpart} ${loadaddr} ${bootenv}\0" \ | 170 | "loadbootenv=load mmc ${bootpart} ${loadaddr} ${bootenv}\0" \ |
171 | "importbootenv=echo Importing environment from mmc ...; " \ | 171 | "importbootenv=echo Importing environment from mmc ...; " \ |
172 | "env import -t -r $loadaddr $filesize\0" \ | 172 | "env import -t -r $loadaddr $filesize\0" \ |
173 | "ramargs=setenv bootargs console=${console} " \ | 173 | "ramargs=setenv bootargs console=${console} " \ |
174 | "${optargs} " \ | 174 | "${optargs} " \ |
175 | "root=${ramroot} " \ | 175 | "root=${ramroot} " \ |
176 | "rootfstype=${ramrootfstype}\0" \ | 176 | "rootfstype=${ramrootfstype}\0" \ |
177 | "loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \ | 177 | "loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz\0" \ |
178 | "loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \ | 178 | "loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \ |
179 | "loadrd=load mmc ${bootpart} ${rdaddr} ${bootdir}/${rdfile}; setenv rdsize ${filesize}\0" \ | 179 | "loadrd=load mmc ${bootpart} ${rdaddr} ${bootdir}/${rdfile}; setenv rdsize ${filesize}\0" \ |
180 | "loadfdt=echo loading ${fdtdir}/${fdtfile} ...; load mmc ${bootpart} ${fdtaddr} ${fdtdir}/${fdtfile}\0" \ | 180 | "loadfdt=echo loading ${fdtdir}/${fdtfile} ...; load mmc ${bootpart} ${fdtaddr} ${fdtdir}/${fdtfile}\0" \ |
181 | "failumsboot=echo; echo FAILSAFE: U-Boot UMS (USB Mass Storage) enabled, media now available over the usb slave port ...; " \ | 181 | "failumsboot=echo; echo FAILSAFE: U-Boot UMS (USB Mass Storage) enabled, media now available over the usb slave port ...; " \ |
182 | "ums 0 mmc ${umsmedia};\0" \ | 182 | "ums 0 mmc ${umsmedia};\0" \ |
183 | "mmcloados=run args_mmc; " \ | 183 | "mmcloados=run args_mmc; " \ |
184 | "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ | 184 | "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \ |
185 | "if run loadfdt; then " \ | 185 | "if run loadfdt; then " \ |
186 | "bootz ${loadaddr} - ${fdtaddr}; " \ | 186 | "bootz ${loadaddr} - ${fdtaddr}; " \ |
187 | "else " \ | 187 | "else " \ |
188 | "if test ${boot_fdt} = try; then " \ | 188 | "if test ${boot_fdt} = try; then " \ |
189 | "bootz; " \ | 189 | "bootz; " \ |
190 | "else " \ | 190 | "else " \ |
191 | "echo WARN: Cannot load the DT; " \ | 191 | "echo WARN: Cannot load the DT; " \ |
192 | "fi; " \ | 192 | "fi; " \ |
193 | "fi; " \ | 193 | "fi; " \ |
194 | "else " \ | 194 | "else " \ |
195 | "bootz; " \ | 195 | "bootz; " \ |
196 | "fi;\0" \ | 196 | "fi;\0" \ |
197 | "mmcboot=mmc dev ${mmcdev}; " \ | 197 | "mmcboot=mmc dev ${mmcdev}; " \ |
198 | "if mmc rescan; then " \ | 198 | "if mmc rescan; then " \ |
199 | "gpio set 51;" \ | 199 | "gpio set 51;" \ |
200 | "setenv bootpart ${mmcdev}:1; " \ | 200 | "setenv bootpart ${mmcdev}:1; " \ |
201 | "if test -e mmc ${bootpart} /etc/fstab; then " \ | 201 | "if test -e mmc ${bootpart} /etc/fstab; then " \ |
202 | "setenv mmcpart 1;" \ | 202 | "setenv mmcpart 1;" \ |
203 | "fi; " \ | 203 | "fi; " \ |
204 | "echo Checking for: /uEnv.txt ...;" \ | 204 | "echo Checking for: /uEnv.txt ...;" \ |
205 | "if test -e mmc ${bootpart} /uEnv.txt; then " \ | 205 | "if test -e mmc ${bootpart} /uEnv.txt; then " \ |
206 | "if run loadbootenv; then " \ | 206 | "if run loadbootenv; then " \ |
207 | "gpio set 54;" \ | 207 | "gpio set 54;" \ |
208 | "gpio set 55;" \ | 208 | "gpio set 55;" \ |
209 | "echo Loaded environment from ${bootenv};" \ | 209 | "echo Loaded environment from ${bootenv};" \ |
210 | "run importbootenv;" \ | 210 | "run importbootenv;" \ |
211 | "gpio set 7;" \ | 211 | "gpio set 7;" \ |
212 | "fi;" \ | 212 | "fi;" \ |
213 | "if test -n ${cape}; then " \ | 213 | "if test -n ${cape}; then " \ |
214 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtbase}-${cape}.dtb; then " \ | 214 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtbase}-${cape}.dtb; then " \ |
215 | "setenv fdtfile ${fdtbase}-${cape}.dtb; " \ | 215 | "setenv fdtfile ${fdtbase}-${cape}.dtb; " \ |
216 | "fi; " \ | 216 | "fi; " \ |
217 | "echo using: $fdtfile...; " \ | 217 | "echo using: $fdtfile...; " \ |
218 | "fi; " \ | 218 | "fi; " \ |
219 | "echo Checking if uenvcmd is set ...;" \ | 219 | "echo Checking if uenvcmd is set ...;" \ |
220 | "if test -n ${uenvcmd}; then " \ | 220 | "if test -n ${uenvcmd}; then " \ |
221 | "echo Running uenvcmd ...;" \ | 221 | "echo Running uenvcmd ...;" \ |
222 | "run uenvcmd;" \ | 222 | "run uenvcmd;" \ |
223 | "fi;" \ | 223 | "fi;" \ |
224 | "echo Checking if client_ip is set ...;" \ | 224 | "echo Checking if client_ip is set ...;" \ |
225 | "if test -n ${client_ip}; then " \ | 225 | "if test -n ${client_ip}; then " \ |
226 | "if test -n ${dtb}; then " \ | 226 | "if test -n ${dtb}; then " \ |
227 | "setenv fdtfile ${dtb};" \ | 227 | "setenv fdtfile ${dtb};" \ |
228 | "echo using ${fdtfile} ...;" \ | 228 | "echo using ${fdtfile} ...;" \ |
229 | "fi;" \ | 229 | "fi;" \ |
230 | "if test -n ${uname_r}; then " \ | 230 | "if test -n ${uname_r}; then " \ |
231 | "echo Running nfsboot_uname_r ...;" \ | 231 | "echo Running nfsboot_uname_r ...;" \ |
232 | "run nfsboot_uname_r;" \ | 232 | "run nfsboot_uname_r;" \ |
233 | "fi;" \ | 233 | "fi;" \ |
234 | "echo Running nfsboot ...;" \ | 234 | "echo Running nfsboot ...;" \ |
235 | "run nfsboot;" \ | 235 | "run nfsboot;" \ |
236 | "fi;" \ | 236 | "fi;" \ |
237 | "fi; " \ | 237 | "fi; " \ |
238 | "echo Checking for: /${script} ...;" \ | 238 | "echo Checking for: /${script} ...;" \ |
239 | "if test -e mmc ${bootpart} /${script}; then " \ | 239 | "if test -e mmc ${bootpart} /${script}; then " \ |
240 | "gpio set 54;" \ | 240 | "gpio set 54;" \ |
241 | "gpio set 55;" \ | 241 | "gpio set 55;" \ |
242 | "setenv scriptfile ${script};" \ | 242 | "setenv scriptfile ${script};" \ |
243 | "run loadbootscript;" \ | 243 | "run loadbootscript;" \ |
244 | "echo Loaded script from ${scriptfile};" \ | 244 | "echo Loaded script from ${scriptfile};" \ |
245 | "gpio set 7; " \ | 245 | "gpio set 7; " \ |
246 | "run bootscript;" \ | 246 | "run bootscript;" \ |
247 | "fi; " \ | 247 | "fi; " \ |
248 | "echo Checking for: /boot/${script} ...;" \ | 248 | "echo Checking for: /boot/${script} ...;" \ |
249 | "if test -e mmc ${bootpart} /boot/${script}; then " \ | 249 | "if test -e mmc ${bootpart} /boot/${script}; then " \ |
250 | "gpio set 54;" \ | 250 | "gpio set 54;" \ |
251 | "gpio set 55;" \ | 251 | "gpio set 55;" \ |
252 | "setenv scriptfile /boot/${script};" \ | 252 | "setenv scriptfile /boot/${script};" \ |
253 | "run loadbootscript;" \ | 253 | "run loadbootscript;" \ |
254 | "echo Loaded script from ${scriptfile};" \ | 254 | "echo Loaded script from ${scriptfile};" \ |
255 | "gpio set 7; " \ | 255 | "gpio set 7; " \ |
256 | "run bootscript;" \ | 256 | "run bootscript;" \ |
257 | "fi; " \ | 257 | "fi; " \ |
258 | "echo Checking for: /boot/uEnv.txt ...;" \ | 258 | "echo Checking for: /boot/uEnv.txt ...;" \ |
259 | "for i in 1 2 3 4 5 6 7 ; do " \ | 259 | "for i in 1 2 3 4 5 6 7 ; do " \ |
260 | "setenv mmcpart ${i};" \ | 260 | "setenv mmcpart ${i};" \ |
261 | "setenv bootpart ${mmcdev}:${mmcpart};" \ | 261 | "setenv bootpart ${mmcdev}:${mmcpart};" \ |
262 | "if test -e mmc ${bootpart} /boot/uEnv.txt; then " \ | 262 | "if test -e mmc ${bootpart} /boot/uEnv.txt; then " \ |
263 | "gpio set 54;" \ | 263 | "gpio set 54;" \ |
264 | "gpio set 55;" \ | 264 | "gpio set 55;" \ |
265 | "load mmc ${bootpart} ${loadaddr} /boot/uEnv.txt;" \ | 265 | "load mmc ${bootpart} ${loadaddr} /boot/uEnv.txt;" \ |
266 | "env import -t ${loadaddr} ${filesize};" \ | 266 | "env import -t ${loadaddr} ${filesize};" \ |
267 | "echo Loaded environment from /boot/uEnv.txt;" \ | 267 | "echo Loaded environment from /boot/uEnv.txt;" \ |
268 | "if test -n ${dtb}; then " \ | 268 | "if test -n ${dtb}; then " \ |
269 | "setenv fdtfile ${dtb};" \ | 269 | "setenv fdtfile ${dtb};" \ |
270 | "echo Using: dtb=${fdtfile} ...;" \ | 270 | "echo Using: dtb=${fdtfile} ...;" \ |
271 | "fi;" \ | 271 | "fi;" \ |
272 | "echo Checking if uname_r is set in /boot/uEnv.txt...;" \ | 272 | "echo Checking if uname_r is set in /boot/uEnv.txt...;" \ |
273 | "if test -n ${uname_r}; then " \ | 273 | "if test -n ${uname_r}; then " \ |
274 | "gpio set 7; " \ | 274 | "gpio set 7; " \ |
275 | "echo Running uname_boot ...;" \ | 275 | "echo Running uname_boot ...;" \ |
276 | "setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart} ro;" \ | 276 | "setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart} ro;" \ |
277 | "run uname_boot;" \ | 277 | "run uname_boot;" \ |
278 | "fi;" \ | 278 | "fi;" \ |
279 | "fi;" \ | 279 | "fi;" \ |
280 | "done;" \ | 280 | "done;" \ |
281 | "fi;\0" \ | 281 | "fi;\0" \ |
282 | "spiboot=echo Booting from spi ...; " \ | 282 | "spiboot=echo Booting from spi ...; " \ |
283 | "run spiargs; " \ | 283 | "run spiargs; " \ |
284 | "sf probe ${spibusno}:0; " \ | 284 | "sf probe ${spibusno}:0; " \ |
285 | "sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; " \ | 285 | "sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; " \ |
286 | "bootz ${loadaddr}\0" \ | 286 | "bootz ${loadaddr}\0" \ |
287 | "nfsboot=echo Booting from ${server_ip} ...; " \ | 287 | "nfsboot=echo Booting from ${server_ip} ...; " \ |
288 | "setenv nfsroot ${server_ip}:${root_dir}${nfs_options}; " \ | 288 | "setenv nfsroot ${server_ip}:${root_dir}${nfs_options}; " \ |
289 | "setenv ip ${client_ip}:${server_ip}:${gw_ip}:${netmask}:${hostname}:${device}:${autoconf}; " \ | 289 | "setenv ip ${client_ip}:${server_ip}:${gw_ip}:${netmask}:${hostname}:${device}:${autoconf}; " \ |
290 | "setenv autoload no; " \ | 290 | "setenv autoload no; " \ |
291 | "setenv serverip ${server_ip}; " \ | 291 | "setenv serverip ${server_ip}; " \ |
292 | "setenv ipaddr ${client_ip}; " \ | 292 | "setenv ipaddr ${client_ip}; " \ |
293 | "tftp ${loadaddr} ${tftp_dir}${bootfile}; " \ | 293 | "tftp ${loadaddr} ${tftp_dir}${bootfile}; " \ |
294 | "tftp ${fdtaddr} ${tftp_dir}dtbs/${fdtfile}; " \ | 294 | "tftp ${fdtaddr} ${tftp_dir}dtbs/${fdtfile}; " \ |
295 | "run nfsargs; " \ | 295 | "run nfsargs; " \ |
296 | "bootz ${loadaddr} - ${fdtaddr}\0" \ | 296 | "bootz ${loadaddr} - ${fdtaddr}\0" \ |
297 | "nfsboot_uname_r=echo Booting from ${server_ip} ...; " \ | 297 | "nfsboot_uname_r=echo Booting from ${server_ip} ...; " \ |
298 | "setenv nfsroot ${server_ip}:${root_dir}${nfs_options}; " \ | 298 | "setenv nfsroot ${server_ip}:${root_dir}${nfs_options}; " \ |
299 | "setenv ip ${client_ip}:${server_ip}:${gw_ip}:${netmask}:${hostname}:${device}:${autoconf}; " \ | 299 | "setenv ip ${client_ip}:${server_ip}:${gw_ip}:${netmask}:${hostname}:${device}:${autoconf}; " \ |
300 | "setenv autoload no; " \ | 300 | "setenv autoload no; " \ |
301 | "setenv serverip ${server_ip}; " \ | 301 | "setenv serverip ${server_ip}; " \ |
302 | "setenv ipaddr ${client_ip}; " \ | 302 | "setenv ipaddr ${client_ip}; " \ |
303 | "tftp ${loadaddr} ${tftp_dir}vmlinuz-${uname_r}; " \ | 303 | "tftp ${loadaddr} ${tftp_dir}vmlinuz-${uname_r}; " \ |
304 | "tftp ${fdtaddr} ${tftp_dir}dtbs/${uname_r}/${fdtfile}; " \ | 304 | "tftp ${fdtaddr} ${tftp_dir}dtbs/${uname_r}/${fdtfile}; " \ |
305 | "run nfsargs; " \ | 305 | "run nfsargs; " \ |
306 | "bootz ${loadaddr} - ${fdtaddr}\0" \ | 306 | "bootz ${loadaddr} - ${fdtaddr}\0" \ |
307 | "ramboot=echo Booting from ramdisk ...; " \ | 307 | "ramboot=echo Booting from ramdisk ...; " \ |
308 | "run ramargs; " \ | 308 | "run ramargs; " \ |
309 | "bootz ${loadaddr} ${rdaddr} ${fdtaddr}\0" \ | 309 | "bootz ${loadaddr} ${rdaddr} ${fdtaddr}\0" \ |
310 | "findfdt="\ | 310 | "findfdt="\ |
311 | "if test $board_name = A335BONE; then " \ | 311 | "if test $board_name = A335BONE; then " \ |
312 | "setenv fdtfile am335x-bone.dtb; fi; " \ | 312 | "setenv fdtfile am335x-bone.dtb; fi; " \ |
313 | "if test $board_name = A335BNLT; then " \ | 313 | "if test $board_name = A335BNLT; then " \ |
314 | "setenv fdtfile am335x-boneblack.dtb; fi; " \ | 314 | "setenv fdtfile am335x-boneblack.dtb; fi; " \ |
315 | "if test $board_name = BBG1; then " \ | 315 | "if test $board_name = BBG1; then " \ |
316 | "setenv fdtfile am335x-bonegreen.dtb; fi; " \ | 316 | "setenv fdtfile am335x-bonegreen.dtb; fi; " \ |
317 | "if test $board_name = A33515BB; then " \ | 317 | "if test $board_name = A33515BB; then " \ |
318 | "setenv fdtfile am335x-evm.dtb; fi; " \ | 318 | "setenv fdtfile am335x-evm.dtb; fi; " \ |
319 | "if test $board_name = A335X_SK; then " \ | 319 | "if test $board_name = A335X_SK; then " \ |
320 | "setenv fdtfile am335x-evmsk.dtb; fi; " \ | 320 | "setenv fdtfile am335x-evmsk.dtb; fi; " \ |
321 | "if test $board_name = A335_ICE; then " \ | 321 | "if test $board_name = A335_ICE; then " \ |
322 | "setenv fdtfile am335x-icev2.dtb; fi; " \ | 322 | "setenv fdtfile am335x-icev2.dtb; fi; " \ |
323 | "if test $board_name = SMARCT33; then " \ | 323 | "if test $board_name = SMARCT33; then " \ |
324 | "setenv fdtfile am335x-smarct335x.dtb; setenv fdtbase am335x-smarct335x; fi; " \ | 324 | "setenv fdtfile am335x-smarct335x.dtb; setenv fdtbase am335x-smarct335x; fi; " \ |
325 | "if test $board_name = SMARCT80; then " \ | 325 | "if test $board_name = SMARCT80; then " \ |
326 | "setenv fdtfile am335x-smarct335x.dtb; setenv fdtbase am335x-smarct335x; fi; " \ | 326 | "setenv fdtfile am335x-smarct335x.dtb; setenv fdtbase am335x-smarct335x; fi; " \ |
327 | "if test $board_name = SMARCT1G; then " \ | 327 | "if test $board_name = SMARCT1G; then " \ |
328 | "setenv fdtfile am335x-smarct335x.dtb; setenv fdtbase am335x-smarct335x; fi; " \ | 328 | "setenv fdtfile am335x-smarct335x.dtb; setenv fdtbase am335x-smarct335x; fi; " \ |
329 | "if test $fdtfile = undefined; then " \ | 329 | "if test $fdtfile = undefined; then " \ |
330 | "echo WARNING: Could not determine device tree to use; fi; \0" \ | 330 | "echo WARNING: Could not determine device tree to use; fi; \0" \ |
331 | "init_console=" \ | 331 | "init_console=" \ |
332 | "if test $board_name = A335_ICE; then "\ | 332 | "if test $board_name = A335_ICE; then "\ |
333 | "setenv console ttyO3,115200n8;" \ | 333 | "setenv console ttyO3,115200n8;" \ |
334 | "else " \ | 334 | "else " \ |
335 | "setenv console ttyS3,115200n8;" \ | 335 | "setenv console ttyS3,115200n8;" \ |
336 | "fi;\0" \ | 336 | "fi;\0" \ |
337 | "uname_boot="\ | 337 | "uname_boot="\ |
338 | "if test -e mmc ${bootpart} ${bootdir}/${bootfile}; then " \ | 338 | "if test -e mmc ${bootpart} ${bootdir}/${bootfile}; then " \ |
339 | "echo loading ${bootdir}/${bootfile} ...; "\ | 339 | "echo loading ${bootdir}/${bootfile} ...; "\ |
340 | "run loadimage;" \ | 340 | "run loadimage;" \ |
341 | "setenv fdtdir /boot/dtbs/${uname_r}; " \ | 341 | "setenv fdtdir /boot/dtbs/${uname_r}; " \ |
342 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ | 342 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ |
343 | "run loadfdt;" \ | 343 | "run loadfdt;" \ |
344 | "else " \ | 344 | "else " \ |
345 | "setenv fdtdir /usr/lib/linux-image-${uname_r}; " \ | 345 | "setenv fdtdir /usr/lib/linux-image-${uname_r}; " \ |
346 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ | 346 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ |
347 | "run loadfdt;" \ | 347 | "run loadfdt;" \ |
348 | "else " \ | 348 | "else " \ |
349 | "setenv fdtdir /lib/firmware/${uname_r}/device-tree; " \ | 349 | "setenv fdtdir /lib/firmware/${uname_r}/device-tree; " \ |
350 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ | 350 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ |
351 | "run loadfdt;" \ | 351 | "run loadfdt;" \ |
352 | "else " \ | 352 | "else " \ |
353 | "setenv fdtdir /boot/dtb-${uname_r}; " \ | 353 | "setenv fdtdir /boot/dtb-${uname_r}; " \ |
354 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ | 354 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ |
355 | "run loadfdt;" \ | 355 | "run loadfdt;" \ |
356 | "else " \ | 356 | "else " \ |
357 | "setenv fdtdir /boot/dtbs; " \ | 357 | "setenv fdtdir /boot/dtbs; " \ |
358 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ | 358 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ |
359 | "run loadfdt;" \ | 359 | "run loadfdt;" \ |
360 | "else " \ | 360 | "else " \ |
361 | "setenv fdtdir /boot/dtb; " \ | 361 | "setenv fdtdir /boot/dtb; " \ |
362 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ | 362 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ |
363 | "run loadfdt;" \ | 363 | "run loadfdt;" \ |
364 | "else " \ | 364 | "else " \ |
365 | "setenv fdtdir /boot; " \ | 365 | "setenv fdtdir /boot; " \ |
366 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ | 366 | "if test -e mmc ${bootpart} ${fdtdir}/${fdtfile}; then " \ |
367 | "run loadfdt;" \ | 367 | "run loadfdt;" \ |
368 | "else " \ | 368 | "else " \ |
369 | "if test -e mmc ${bootpart} ${fdtfile}; then " \ | 369 | "if test -e mmc ${bootpart} ${fdtfile}; then " \ |
370 | "run loadfdt;" \ | 370 | "run loadfdt;" \ |
371 | "else " \ | 371 | "else " \ |
372 | "echo; echo unable to find [dtb=${fdtfile}] did you name it correctly? ...; " \ | 372 | "echo; echo unable to find [dtb=${fdtfile}] did you name it correctly? ...; " \ |
373 | "run failumsboot;" \ | 373 | "run failumsboot;" \ |
374 | "fi;" \ | 374 | "fi;" \ |
375 | "fi;" \ | 375 | "fi;" \ |
376 | "fi;" \ | 376 | "fi;" \ |
377 | "fi;" \ | 377 | "fi;" \ |
378 | "fi;" \ | 378 | "fi;" \ |
379 | "fi;" \ | 379 | "fi;" \ |
380 | "fi;" \ | 380 | "fi;" \ |
381 | "fi; " \ | 381 | "fi; " \ |
382 | "setenv rdfile initrd.img-${uname_r}; " \ | 382 | "setenv rdfile initrd.img-${uname_r}; " \ |
383 | "if test -e mmc ${bootpart} ${bootdir}/${rdfile}; then " \ | 383 | "if test -e mmc ${bootpart} ${bootdir}/${rdfile}; then " \ |
384 | "echo loading ${bootdir}/${rdfile} ...; "\ | 384 | "echo loading ${bootdir}/${rdfile} ...; "\ |
385 | "run loadrd;" \ | 385 | "run loadrd;" \ |
386 | "if test -n ${uuid}; then " \ | 386 | "if test -n ${uuid}; then " \ |
387 | "setenv mmcroot UUID=${uuid} ro;" \ | 387 | "setenv mmcroot UUID=${uuid} ro;" \ |
388 | "fi;" \ | 388 | "fi;" \ |
389 | "run args_mmc;" \ | 389 | "run args_mmc;" \ |
390 | "echo debug: [${bootargs}] ... ;" \ | 390 | "echo debug: [${bootargs}] ... ;" \ |
391 | "echo debug: [bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}] ... ;" \ | 391 | "echo debug: [bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}] ... ;" \ |
392 | "bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}; " \ | 392 | "bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}; " \ |
393 | "bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}; " \ | 393 | "bootz ${loadaddr} ${rdaddr}:${rdsize} ${fdtaddr}; " \ |
394 | "else " \ | 394 | "else " \ |
395 | "run args_mmc;" \ | 395 | "run args_mmc;" \ |
396 | "echo debug: [${bootargs}] ... ;" \ | 396 | "echo debug: [${bootargs}] ... ;" \ |
397 | "echo debug: [bootz ${loadaddr} - ${fdtaddr}] ... ;" \ | 397 | "echo debug: [bootz ${loadaddr} - ${fdtaddr}] ... ;" \ |
398 | "bootz ${loadaddr} - ${fdtaddr}; " \ | 398 | "bootz ${loadaddr} - ${fdtaddr}; " \ |
399 | "fi;" \ | 399 | "fi;" \ |
400 | "fi;\0" \ | 400 | "fi;\0" \ |
401 | NANDARGS \ | 401 | NANDARGS \ |
402 | NETARGS \ | 402 | NETARGS \ |
403 | DFUARGS \ | 403 | DFUARGS \ |
404 | BOOTENV | 404 | BOOTENV |
405 | #endif | 405 | #endif |
406 | 406 | ||
407 | /* NS16550 Configuration */ | 407 | /* NS16550 Configuration */ |
408 | #define CONFIG_SYS_NS16550_COM1 0x44e09000 /* Base EVM has UART0 */ | 408 | #define CONFIG_SYS_NS16550_COM1 0x44e09000 /* Base EVM has UART0 */ |
409 | #define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1 */ | 409 | #define CONFIG_SYS_NS16550_COM2 0x48022000 /* UART1 */ |
410 | #define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2 */ | 410 | #define CONFIG_SYS_NS16550_COM3 0x48024000 /* UART2 */ |
411 | #define CONFIG_SYS_NS16550_COM4 0x481a6000 /* UART3 */ | 411 | #define CONFIG_SYS_NS16550_COM4 0x481a6000 /* UART3 */ |
412 | #define CONFIG_SYS_NS16550_COM5 0x481a8000 /* UART4 */ | 412 | #define CONFIG_SYS_NS16550_COM5 0x481a8000 /* UART4 */ |
413 | #define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */ | 413 | #define CONFIG_SYS_NS16550_COM6 0x481aa000 /* UART5 */ |
414 | #define CONFIG_BAUDRATE 115200 | 414 | #define CONFIG_BAUDRATE 115200 |
415 | 415 | ||
416 | #define CONFIG_CMD_EEPROM | 416 | #define CONFIG_CMD_EEPROM |
417 | #define CONFIG_ENV_EEPROM_IS_ON_I2C | 417 | #define CONFIG_ENV_EEPROM_IS_ON_I2C |
418 | #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* Main EEPROM */ | 418 | #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 /* Main EEPROM */ |
419 | #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 | 419 | #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 2 |
420 | #define CONFIG_SYS_I2C_MULTI_EEPROMS | 420 | #define CONFIG_SYS_I2C_MULTI_EEPROMS |
421 | |||
422 | /* I2C SER definitions for DS90UH925 chip */ | ||
423 | #define CONFIG_SYS_I2C_SER_ADDR 0x0e | ||
424 | #define CONFIG_SYS_I2C_SER_PASSTROUGH 0xda /* Enable SER I2C Pass Through */ | ||
425 | #define CONFIG_SYS_I2C_SER_PASSALL 0xde /* Enable SER I2C Pass All */ | ||
426 | #define CONFIG_SYS_I2C_SER_IRQ_ENABLE 0x21 /* Enable SER IRQ REQUEST */ | ||
427 | |||
428 | /* I2C switch definitions for PCA9546 chip */ | ||
429 | #define CONFIG_SYS_I2C_PCA9546_ADDR 0x70 | ||
430 | #define CONFIG_SYS_I2C_PCA9546_ADDR_LEN 0 /* Single register. */ | ||
431 | #define CONFIG_SYS_I2C_PCA9546_ENABLE 0x07 /* Enable channel 0,1,2. */ | ||
432 | #define CONFIG_SYS_NUM_I2C_BUSES 4 | ||
433 | #define CONFIG_SYS_I2C_MAX_HOPS 1 | ||
434 | #define CONFIG_SYS_I2C_BUSES { {0, {I2C_NULL_HOP}}, \ | ||
435 | {0, {{I2C_MUX_PCA9546, 0x70, 1}}}, \ | ||
436 | {0, {{I2C_MUX_PCA9546, 0x70, 2}}}, \ | ||
437 | {0, {{I2C_MUX_PCA9546, 0x70, 3}}}, \ | ||
438 | } | ||
421 | 439 | ||
422 | /* PMIC support */ | 440 | /* PMIC support */ |
423 | #define CONFIG_POWER_TPS65217 | 441 | #define CONFIG_POWER_TPS65217 |
424 | #define CONFIG_POWER_TPS65910 | 442 | #define CONFIG_POWER_TPS65910 |
425 | 443 | ||
426 | /* SPL */ | 444 | /* SPL */ |
427 | #ifndef CONFIG_NOR_BOOT | 445 | #ifndef CONFIG_NOR_BOOT |
428 | #define CONFIG_SPL_POWER_SUPPORT | 446 | #define CONFIG_SPL_POWER_SUPPORT |
429 | #define CONFIG_SPL_YMODEM_SUPPORT | 447 | #define CONFIG_SPL_YMODEM_SUPPORT |
430 | 448 | ||
431 | /* Bootcount using the RTC block */ | 449 | /* Bootcount using the RTC block */ |
432 | #define CONFIG_BOOTCOUNT_LIMIT | 450 | #define CONFIG_BOOTCOUNT_LIMIT |
433 | #define CONFIG_BOOTCOUNT_AM33XX | 451 | #define CONFIG_BOOTCOUNT_AM33XX |
434 | #define CONFIG_SYS_BOOTCOUNT_BE | 452 | #define CONFIG_SYS_BOOTCOUNT_BE |
435 | 453 | ||
436 | /* USB gadget RNDIS */ | 454 | /* USB gadget RNDIS */ |
437 | #define CONFIG_SPL_MUSB_NEW_SUPPORT | 455 | #define CONFIG_SPL_MUSB_NEW_SUPPORT |
438 | 456 | ||
439 | #define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/am33xx/u-boot-spl.lds" | 457 | #define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/am33xx/u-boot-spl.lds" |
440 | #endif | 458 | #endif |
441 | 459 | ||
442 | #ifdef CONFIG_NAND | 460 | #ifdef CONFIG_NAND |
443 | /* NAND: device related configs */ | 461 | /* NAND: device related configs */ |
444 | #define CONFIG_SYS_NAND_5_ADDR_CYCLE | 462 | #define CONFIG_SYS_NAND_5_ADDR_CYCLE |
445 | #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ | 463 | #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ |
446 | CONFIG_SYS_NAND_PAGE_SIZE) | 464 | CONFIG_SYS_NAND_PAGE_SIZE) |
447 | #define CONFIG_SYS_NAND_PAGE_SIZE 2048 | 465 | #define CONFIG_SYS_NAND_PAGE_SIZE 2048 |
448 | #define CONFIG_SYS_NAND_OOBSIZE 64 | 466 | #define CONFIG_SYS_NAND_OOBSIZE 64 |
449 | #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) | 467 | #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) |
450 | /* NAND: driver related configs */ | 468 | /* NAND: driver related configs */ |
451 | #define CONFIG_NAND_OMAP_GPMC | 469 | #define CONFIG_NAND_OMAP_GPMC |
452 | #define CONFIG_NAND_OMAP_GPMC_PREFETCH | 470 | #define CONFIG_NAND_OMAP_GPMC_PREFETCH |
453 | #define CONFIG_NAND_OMAP_ELM | 471 | #define CONFIG_NAND_OMAP_ELM |
454 | #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS | 472 | #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS |
455 | #define CONFIG_SYS_NAND_ECCPOS { 2, 3, 4, 5, 6, 7, 8, 9, \ | 473 | #define CONFIG_SYS_NAND_ECCPOS { 2, 3, 4, 5, 6, 7, 8, 9, \ |
456 | 10, 11, 12, 13, 14, 15, 16, 17, \ | 474 | 10, 11, 12, 13, 14, 15, 16, 17, \ |
457 | 18, 19, 20, 21, 22, 23, 24, 25, \ | 475 | 18, 19, 20, 21, 22, 23, 24, 25, \ |
458 | 26, 27, 28, 29, 30, 31, 32, 33, \ | 476 | 26, 27, 28, 29, 30, 31, 32, 33, \ |
459 | 34, 35, 36, 37, 38, 39, 40, 41, \ | 477 | 34, 35, 36, 37, 38, 39, 40, 41, \ |
460 | 42, 43, 44, 45, 46, 47, 48, 49, \ | 478 | 42, 43, 44, 45, 46, 47, 48, 49, \ |
461 | 50, 51, 52, 53, 54, 55, 56, 57, } | 479 | 50, 51, 52, 53, 54, 55, 56, 57, } |
462 | 480 | ||
463 | #define CONFIG_SYS_NAND_ECCSIZE 512 | 481 | #define CONFIG_SYS_NAND_ECCSIZE 512 |
464 | #define CONFIG_SYS_NAND_ECCBYTES 14 | 482 | #define CONFIG_SYS_NAND_ECCBYTES 14 |
465 | #define CONFIG_SYS_NAND_ONFI_DETECTION | 483 | #define CONFIG_SYS_NAND_ONFI_DETECTION |
466 | #define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW | 484 | #define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW |
467 | #define MTDIDS_DEFAULT "nand0=nand.0" | 485 | #define MTDIDS_DEFAULT "nand0=nand.0" |
468 | #define MTDPARTS_DEFAULT "mtdparts=nand.0:" \ | 486 | #define MTDPARTS_DEFAULT "mtdparts=nand.0:" \ |
469 | "128k(NAND.SPL)," \ | 487 | "128k(NAND.SPL)," \ |
470 | "128k(NAND.SPL.backup1)," \ | 488 | "128k(NAND.SPL.backup1)," \ |
471 | "128k(NAND.SPL.backup2)," \ | 489 | "128k(NAND.SPL.backup2)," \ |
472 | "128k(NAND.SPL.backup3)," \ | 490 | "128k(NAND.SPL.backup3)," \ |
473 | "256k(NAND.u-boot-spl-os)," \ | 491 | "256k(NAND.u-boot-spl-os)," \ |
474 | "1m(NAND.u-boot)," \ | 492 | "1m(NAND.u-boot)," \ |
475 | "128k(NAND.u-boot-env)," \ | 493 | "128k(NAND.u-boot-env)," \ |
476 | "128k(NAND.u-boot-env.backup1)," \ | 494 | "128k(NAND.u-boot-env.backup1)," \ |
477 | "8m(NAND.kernel)," \ | 495 | "8m(NAND.kernel)," \ |
478 | "-(NAND.file-system)" | 496 | "-(NAND.file-system)" |
479 | #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x000c0000 | 497 | #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x000c0000 |
480 | /* NAND: SPL related configs */ | 498 | /* NAND: SPL related configs */ |
481 | #ifdef CONFIG_SPL_NAND_SUPPORT | 499 | #ifdef CONFIG_SPL_NAND_SUPPORT |
482 | #define CONFIG_SPL_NAND_AM33XX_BCH | 500 | #define CONFIG_SPL_NAND_AM33XX_BCH |
483 | #endif | 501 | #endif |
484 | #ifdef CONFIG_SPL_OS_BOOT | 502 | #ifdef CONFIG_SPL_OS_BOOT |
485 | #define CONFIG_CMD_SPL_NAND_OFS 0x00080000 /* os parameters */ | 503 | #define CONFIG_CMD_SPL_NAND_OFS 0x00080000 /* os parameters */ |
486 | #define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x00200000 /* kernel offset */ | 504 | #define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x00200000 /* kernel offset */ |
487 | #define CONFIG_CMD_SPL_WRITE_SIZE 0x2000 | 505 | #define CONFIG_CMD_SPL_WRITE_SIZE 0x2000 |
488 | #endif | 506 | #endif |
489 | #endif /* !CONFIG_NAND */ | 507 | #endif /* !CONFIG_NAND */ |
490 | 508 | ||
491 | /* | 509 | /* |
492 | * For NOR boot, we must set this to the start of where NOR is mapped | 510 | * For NOR boot, we must set this to the start of where NOR is mapped |
493 | * in memory. | 511 | * in memory. |
494 | */ | 512 | */ |
495 | #ifdef CONFIG_NOR_BOOT | 513 | #ifdef CONFIG_NOR_BOOT |
496 | #define CONFIG_SYS_TEXT_BASE 0x08000000 | 514 | #define CONFIG_SYS_TEXT_BASE 0x08000000 |
497 | #endif | 515 | #endif |
498 | 516 | ||
499 | /* | 517 | /* |
500 | * USB configuration. We enable MUSB support, both for host and for | 518 | * USB configuration. We enable MUSB support, both for host and for |
501 | * gadget. We set USB0 as peripheral and USB1 as host, based on the | 519 | * gadget. We set USB0 as peripheral and USB1 as host, based on the |
502 | * board schematic and physical port wired to each. Then for host we | 520 | * board schematic and physical port wired to each. Then for host we |
503 | * add mass storage support and for gadget we add both RNDIS ethernet | 521 | * add mass storage support and for gadget we add both RNDIS ethernet |
504 | * and DFU. | 522 | * and DFU. |
505 | */ | 523 | */ |
506 | #define CONFIG_USB_MUSB_DSPS | 524 | #define CONFIG_USB_MUSB_DSPS |
507 | #define CONFIG_ARCH_MISC_INIT | 525 | #define CONFIG_ARCH_MISC_INIT |
508 | #define CONFIG_USB_MUSB_PIO_ONLY | 526 | #define CONFIG_USB_MUSB_PIO_ONLY |
509 | #define CONFIG_USB_MUSB_DISABLE_BULK_COMBINE_SPLIT | 527 | #define CONFIG_USB_MUSB_DISABLE_BULK_COMBINE_SPLIT |
510 | #define CONFIG_USBDOWNLOAD_GADGET | 528 | #define CONFIG_USBDOWNLOAD_GADGET |
511 | #define CONFIG_USB_GADGET_VBUS_DRAW 2 | 529 | #define CONFIG_USB_GADGET_VBUS_DRAW 2 |
512 | #define CONFIG_AM335X_USB0 | 530 | #define CONFIG_AM335X_USB0 |
513 | #define CONFIG_AM335X_USB0_MODE MUSB_PERIPHERAL | 531 | #define CONFIG_AM335X_USB0_MODE MUSB_PERIPHERAL |
514 | #define CONFIG_AM335X_USB1 | 532 | #define CONFIG_AM335X_USB1 |
515 | #define CONFIG_AM335X_USB1_MODE MUSB_HOST | 533 | #define CONFIG_AM335X_USB1_MODE MUSB_HOST |
516 | 534 | ||
517 | #ifndef CONFIG_SPL_USBETH_SUPPORT | 535 | #ifndef CONFIG_SPL_USBETH_SUPPORT |
518 | /* Fastboot */ | 536 | /* Fastboot */ |
519 | #define CONFIG_USB_FUNCTION_FASTBOOT | 537 | #define CONFIG_USB_FUNCTION_FASTBOOT |
520 | #define CONFIG_CMD_FASTBOOT | 538 | #define CONFIG_CMD_FASTBOOT |
521 | #define CONFIG_ANDROID_BOOT_IMAGE | 539 | #define CONFIG_ANDROID_BOOT_IMAGE |
522 | #define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR | 540 | #define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR |
523 | #define CONFIG_FASTBOOT_BUF_SIZE 0x07000000 | 541 | #define CONFIG_FASTBOOT_BUF_SIZE 0x07000000 |
524 | 542 | ||
525 | /* To support eMMC booting */ | 543 | /* To support eMMC booting */ |
526 | #define CONFIG_STORAGE_EMMC | 544 | #define CONFIG_STORAGE_EMMC |
527 | #define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 | 545 | #define CONFIG_FASTBOOT_FLASH_MMC_DEV 1 |
528 | #endif | 546 | #endif |
529 | 547 | ||
530 | #ifdef CONFIG_USB_MUSB_HOST | 548 | #ifdef CONFIG_USB_MUSB_HOST |
531 | #define CONFIG_USB_STORAGE | 549 | #define CONFIG_USB_STORAGE |
532 | #endif | 550 | #endif |
533 | 551 | ||
534 | #ifdef CONFIG_USB_MUSB_GADGET | 552 | #ifdef CONFIG_USB_MUSB_GADGET |
535 | #define CONFIG_USB_ETHER | 553 | #define CONFIG_USB_ETHER |
536 | #define CONFIG_USB_ETH_RNDIS | 554 | #define CONFIG_USB_ETH_RNDIS |
537 | #define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00" | 555 | #define CONFIG_USBNET_HOST_ADDR "de:ad:be:af:00:00" |
538 | #endif /* CONFIG_USB_MUSB_GADGET */ | 556 | #endif /* CONFIG_USB_MUSB_GADGET */ |
539 | 557 | ||
540 | /* | 558 | /* |
541 | * Disable MMC DM for SPL build and can be re-enabled after adding | 559 | * Disable MMC DM for SPL build and can be re-enabled after adding |
542 | * DM support in SPL | 560 | * DM support in SPL |
543 | */ | 561 | */ |
544 | #ifdef CONFIG_SPL_BUILD | 562 | #ifdef CONFIG_SPL_BUILD |
545 | #undef CONFIG_DM_MMC | 563 | #undef CONFIG_DM_MMC |
546 | #undef CONFIG_TIMER | 564 | #undef CONFIG_TIMER |
547 | #undef CONFIG_DM_NAND | 565 | #undef CONFIG_DM_NAND |
548 | #undef CONFIG_DM_USB | 566 | #undef CONFIG_DM_USB |
549 | #endif | 567 | #endif |
550 | 568 | ||
551 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USBETH_SUPPORT) | 569 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USBETH_SUPPORT) |
552 | /* Remove other SPL modes. */ | 570 | /* Remove other SPL modes. */ |
553 | #undef CONFIG_SPL_YMODEM_SUPPORT | 571 | #undef CONFIG_SPL_YMODEM_SUPPORT |
554 | #undef CONFIG_SPL_NAND_SUPPORT | 572 | #undef CONFIG_SPL_NAND_SUPPORT |
555 | #undef CONFIG_SPL_MMC_SUPPORT | 573 | #undef CONFIG_SPL_MMC_SUPPORT |
556 | #define CONFIG_ENV_IS_NOWHERE | 574 | #define CONFIG_ENV_IS_NOWHERE |
557 | #undef CONFIG_ENV_IS_IN_NAND | 575 | #undef CONFIG_ENV_IS_IN_NAND |
558 | /* disable host part of MUSB in SPL */ | 576 | /* disable host part of MUSB in SPL */ |
559 | /* disable EFI partitions and partition UUID support */ | 577 | /* disable EFI partitions and partition UUID support */ |
560 | #undef CONFIG_PARTITION_UUIDS | 578 | #undef CONFIG_PARTITION_UUIDS |
561 | #undef CONFIG_EFI_PARTITION | 579 | #undef CONFIG_EFI_PARTITION |
562 | /* General network SPL */ | 580 | /* General network SPL */ |
563 | #define CONFIG_SPL_NET_SUPPORT | 581 | #define CONFIG_SPL_NET_SUPPORT |
564 | #define CONFIG_SPL_ENV_SUPPORT | 582 | #define CONFIG_SPL_ENV_SUPPORT |
565 | #define CONFIG_SPL_NET_VCI_STRING "AM335x U-Boot SPL" | 583 | #define CONFIG_SPL_NET_VCI_STRING "AM335x U-Boot SPL" |
566 | #endif | 584 | #endif |
567 | 585 | ||
568 | /* USB Device Firmware Update support */ | 586 | /* USB Device Firmware Update support */ |
569 | #ifndef CONFIG_SPL_BUILD | 587 | #ifndef CONFIG_SPL_BUILD |
570 | #define CONFIG_USB_FUNCTION_DFU | 588 | #define CONFIG_USB_FUNCTION_DFU |
571 | #define CONFIG_DFU_MMC | 589 | #define CONFIG_DFU_MMC |
572 | #define DFU_ALT_INFO_MMC \ | 590 | #define DFU_ALT_INFO_MMC \ |
573 | "dfu_alt_info_mmc=" \ | 591 | "dfu_alt_info_mmc=" \ |
574 | "boot part 0 1;" \ | 592 | "boot part 0 1;" \ |
575 | "rootfs part 0 2;" \ | 593 | "rootfs part 0 2;" \ |
576 | "MLO fat 0 1;" \ | 594 | "MLO fat 0 1;" \ |
577 | "MLO.raw raw 0x100 0x100;" \ | 595 | "MLO.raw raw 0x100 0x100;" \ |
578 | "u-boot.img.raw raw 0x300 0x400;" \ | 596 | "u-boot.img.raw raw 0x300 0x400;" \ |
579 | "spl-os-args.raw raw 0x80 0x80;" \ | 597 | "spl-os-args.raw raw 0x80 0x80;" \ |
580 | "spl-os-image.raw raw 0x900 0x2000;" \ | 598 | "spl-os-image.raw raw 0x900 0x2000;" \ |
581 | "spl-os-args fat 0 1;" \ | 599 | "spl-os-args fat 0 1;" \ |
582 | "spl-os-image fat 0 1;" \ | 600 | "spl-os-image fat 0 1;" \ |
583 | "u-boot.img fat 0 1;" \ | 601 | "u-boot.img fat 0 1;" \ |
584 | "uEnv.txt fat 0 1\0" | 602 | "uEnv.txt fat 0 1\0" |
585 | #ifdef CONFIG_NAND | 603 | #ifdef CONFIG_NAND |
586 | #define CONFIG_DFU_NAND | 604 | #define CONFIG_DFU_NAND |
587 | #define DFU_ALT_INFO_NAND \ | 605 | #define DFU_ALT_INFO_NAND \ |
588 | "dfu_alt_info_nand=" \ | 606 | "dfu_alt_info_nand=" \ |
589 | "SPL part 0 1;" \ | 607 | "SPL part 0 1;" \ |
590 | "SPL.backup1 part 0 2;" \ | 608 | "SPL.backup1 part 0 2;" \ |
591 | "SPL.backup2 part 0 3;" \ | 609 | "SPL.backup2 part 0 3;" \ |
592 | "SPL.backup3 part 0 4;" \ | 610 | "SPL.backup3 part 0 4;" \ |
593 | "u-boot part 0 5;" \ | 611 | "u-boot part 0 5;" \ |
594 | "u-boot-spl-os part 0 6;" \ | 612 | "u-boot-spl-os part 0 6;" \ |
595 | "kernel part 0 8;" \ | 613 | "kernel part 0 8;" \ |
596 | "rootfs part 0 9\0" | 614 | "rootfs part 0 9\0" |
597 | #else | 615 | #else |
598 | #define DFU_ALT_INFO_NAND "" | 616 | #define DFU_ALT_INFO_NAND "" |
599 | #endif | 617 | #endif |
600 | #define CONFIG_DFU_RAM | 618 | #define CONFIG_DFU_RAM |
601 | #define DFU_ALT_INFO_RAM \ | 619 | #define DFU_ALT_INFO_RAM \ |
602 | "dfu_alt_info_ram=" \ | 620 | "dfu_alt_info_ram=" \ |
603 | "kernel ram 0x80200000 0xD80000;" \ | 621 | "kernel ram 0x80200000 0xD80000;" \ |
604 | "fdt ram 0x80F80000 0x80000;" \ | 622 | "fdt ram 0x80F80000 0x80000;" \ |
605 | "ramdisk ram 0x81000000 0x4000000\0" | 623 | "ramdisk ram 0x81000000 0x4000000\0" |
606 | #define DFUARGS \ | 624 | #define DFUARGS \ |
607 | "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \ | 625 | "dfu_alt_info_emmc=rawemmc raw 0 3751936\0" \ |
608 | DFU_ALT_INFO_MMC \ | 626 | DFU_ALT_INFO_MMC \ |
609 | DFU_ALT_INFO_RAM \ | 627 | DFU_ALT_INFO_RAM \ |
610 | DFU_ALT_INFO_NAND | 628 | DFU_ALT_INFO_NAND |
611 | #endif | 629 | #endif |
612 | 630 | ||
613 | /* | 631 | /* |
614 | * Default to using SPI for environment, etc. | 632 | * Default to using SPI for environment, etc. |
615 | * 0x000000 - 0x020000 : SPL (128KiB) | 633 | * 0x000000 - 0x020000 : SPL (128KiB) |
616 | * 0x020000 - 0x0A0000 : U-Boot (512KiB) | 634 | * 0x020000 - 0x0A0000 : U-Boot (512KiB) |
617 | * 0x0A0000 - 0x0BFFFF : First copy of U-Boot Environment (128KiB) | 635 | * 0x0A0000 - 0x0BFFFF : First copy of U-Boot Environment (128KiB) |
618 | * 0x0C0000 - 0x0DFFFF : Second copy of U-Boot Environment (128KiB) | 636 | * 0x0C0000 - 0x0DFFFF : Second copy of U-Boot Environment (128KiB) |
619 | * 0x0E0000 - 0x442000 : Linux Kernel | 637 | * 0x0E0000 - 0x442000 : Linux Kernel |
620 | * 0x442000 - 0x800000 : Userland | 638 | * 0x442000 - 0x800000 : Userland |
621 | */ | 639 | */ |
622 | #if defined(CONFIG_SPI_BOOT) | 640 | #if defined(CONFIG_SPI_BOOT) |
623 | /* SPL related */ | 641 | /* SPL related */ |
624 | #undef CONFIG_SPL_OS_BOOT /* Not supported by existing map */ | 642 | #undef CONFIG_SPL_OS_BOOT /* Not supported by existing map */ |
625 | #define CONFIG_SPL_SPI_SUPPORT | 643 | #define CONFIG_SPL_SPI_SUPPORT |
626 | #define CONFIG_SPL_SPI_FLASH_SUPPORT | 644 | #define CONFIG_SPL_SPI_FLASH_SUPPORT |
627 | #define CONFIG_SPL_SPI_LOAD | 645 | #define CONFIG_SPL_SPI_LOAD |
628 | #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000 | 646 | #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000 |
629 | 647 | ||
630 | #define CONFIG_ENV_IS_IN_SPI_FLASH | 648 | #define CONFIG_ENV_IS_IN_SPI_FLASH |
631 | #define CONFIG_SYS_REDUNDAND_ENVIRONMENT | 649 | #define CONFIG_SYS_REDUNDAND_ENVIRONMENT |
632 | #define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED | 650 | #define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED |
633 | #define CONFIG_ENV_SECT_SIZE (4 << 10) /* 4 KB sectors */ | 651 | #define CONFIG_ENV_SECT_SIZE (4 << 10) /* 4 KB sectors */ |
634 | #define CONFIG_ENV_OFFSET (768 << 10) /* 768 KiB in */ | 652 | #define CONFIG_ENV_OFFSET (768 << 10) /* 768 KiB in */ |
635 | #define CONFIG_ENV_OFFSET_REDUND (896 << 10) /* 896 KiB in */ | 653 | #define CONFIG_ENV_OFFSET_REDUND (896 << 10) /* 896 KiB in */ |
636 | #define MTDIDS_DEFAULT "nor0=m25p80-flash.0" | 654 | #define MTDIDS_DEFAULT "nor0=m25p80-flash.0" |
637 | #define MTDPARTS_DEFAULT "mtdparts=m25p80-flash.0:128k(SPL)," \ | 655 | #define MTDPARTS_DEFAULT "mtdparts=m25p80-flash.0:128k(SPL)," \ |
638 | "512k(u-boot),128k(u-boot-env1)," \ | 656 | "512k(u-boot),128k(u-boot-env1)," \ |
639 | "128k(u-boot-env2),3464k(kernel)," \ | 657 | "128k(u-boot-env2),3464k(kernel)," \ |
640 | "-(rootfs)" | 658 | "-(rootfs)" |
641 | #elif defined(CONFIG_EMMC_BOOT) | 659 | #elif defined(CONFIG_EMMC_BOOT) |
642 | #undef CONFIG_SPL_OS_BOOT | 660 | #undef CONFIG_SPL_OS_BOOT |
643 | #undef CONFIG_ENV_IS_NOWHERE | 661 | #undef CONFIG_ENV_IS_NOWHERE |
644 | #define CONFIG_ENV_IS_IN_MMC | 662 | #define CONFIG_ENV_IS_IN_MMC |
645 | #define CONFIG_SPL_ENV_SUPPORT | 663 | #define CONFIG_SPL_ENV_SUPPORT |
646 | #define CONFIG_SYS_MMC_ENV_DEV 1 | 664 | #define CONFIG_SYS_MMC_ENV_DEV 1 |
647 | #define CONFIG_SYS_MMC_ENV_PART 2 | 665 | #define CONFIG_SYS_MMC_ENV_PART 2 |
648 | #define CONFIG_ENV_OFFSET 0x0 | 666 | #define CONFIG_ENV_OFFSET 0x0 |
649 | #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) | 667 | #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) |
650 | #define CONFIG_SYS_REDUNDAND_ENVIRONMENT | 668 | #define CONFIG_SYS_REDUNDAND_ENVIRONMENT |
651 | #elif defined(CONFIG_NOR_BOOT) | 669 | #elif defined(CONFIG_NOR_BOOT) |
652 | #define CONFIG_ENV_IS_IN_FLASH | 670 | #define CONFIG_ENV_IS_IN_FLASH |
653 | #define CONFIG_ENV_SECT_SIZE (128 << 10) /* 128 KiB */ | 671 | #define CONFIG_ENV_SECT_SIZE (128 << 10) /* 128 KiB */ |
654 | #define CONFIG_ENV_OFFSET (512 << 10) /* 512 KiB */ | 672 | #define CONFIG_ENV_OFFSET (512 << 10) /* 512 KiB */ |
655 | #define CONFIG_ENV_OFFSET_REDUND (768 << 10) /* 768 KiB */ | 673 | #define CONFIG_ENV_OFFSET_REDUND (768 << 10) /* 768 KiB */ |
656 | #define MTDIDS_DEFAULT "nor0=physmap-flash.0" | 674 | #define MTDIDS_DEFAULT "nor0=physmap-flash.0" |
657 | #define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:" \ | 675 | #define MTDPARTS_DEFAULT "mtdparts=physmap-flash.0:" \ |
658 | "512k(u-boot)," \ | 676 | "512k(u-boot)," \ |
659 | "128k(u-boot-env1)," \ | 677 | "128k(u-boot-env1)," \ |
660 | "128k(u-boot-env2)," \ | 678 | "128k(u-boot-env2)," \ |
661 | "4m(kernel),-(rootfs)" | 679 | "4m(kernel),-(rootfs)" |
662 | #elif defined(CONFIG_ENV_IS_IN_NAND) | 680 | #elif defined(CONFIG_ENV_IS_IN_NAND) |
663 | #define CONFIG_ENV_OFFSET 0x001c0000 | 681 | #define CONFIG_ENV_OFFSET 0x001c0000 |
664 | #define CONFIG_ENV_OFFSET_REDUND 0x001e0000 | 682 | #define CONFIG_ENV_OFFSET_REDUND 0x001e0000 |
665 | #define CONFIG_SYS_ENV_SECT_SIZE CONFIG_SYS_NAND_BLOCK_SIZE | 683 | #define CONFIG_SYS_ENV_SECT_SIZE CONFIG_SYS_NAND_BLOCK_SIZE |
666 | #elif !defined(CONFIG_ENV_IS_NOWHERE) | 684 | #elif !defined(CONFIG_ENV_IS_NOWHERE) |
667 | /* Not NAND, SPI, NOR or eMMC env, so put ENV in a file on FAT */ | 685 | /* Not NAND, SPI, NOR or eMMC env, so put ENV in a file on FAT */ |
668 | #define CONFIG_ENV_IS_IN_FAT | 686 | #define CONFIG_ENV_IS_IN_FAT |
669 | #define FAT_ENV_INTERFACE "mmc" | 687 | #define FAT_ENV_INTERFACE "mmc" |
670 | #define FAT_ENV_DEVICE_AND_PART "0:1" | 688 | #define FAT_ENV_DEVICE_AND_PART "0:1" |
671 | #define FAT_ENV_FILE "uboot.env" | 689 | #define FAT_ENV_FILE "uboot.env" |
672 | #endif | 690 | #endif |
673 | 691 | ||
674 | /* SPI flash. */ | 692 | /* SPI flash. */ |
675 | #define CONFIG_SPI_FLASH_MACRONIX | 693 | #define CONFIG_SPI_FLASH_MACRONIX |
676 | #define CONFIG_SF_DEFAULT_SPEED 24000000 | 694 | #define CONFIG_SF_DEFAULT_SPEED 24000000 |
677 | 695 | ||
678 | /* Network. */ | 696 | /* Network. */ |
679 | #define CONFIG_PHY_GIGE | 697 | #define CONFIG_PHY_GIGE |
680 | #define CONFIG_PHYLIB | 698 | #define CONFIG_PHYLIB |
681 | #define CONFIG_PHY_SMSC | 699 | #define CONFIG_PHY_SMSC |
682 | 700 | ||
683 | /* | 701 | /* |
684 | * NOR Size = 16 MiB | 702 | * NOR Size = 16 MiB |
685 | * Number of Sectors/Blocks = 128 | 703 | * Number of Sectors/Blocks = 128 |
686 | * Sector Size = 128 KiB | 704 | * Sector Size = 128 KiB |
687 | * Word length = 16 bits | 705 | * Word length = 16 bits |
688 | * Default layout: | 706 | * Default layout: |
689 | * 0x000000 - 0x07FFFF : U-Boot (512 KiB) | 707 | * 0x000000 - 0x07FFFF : U-Boot (512 KiB) |
690 | * 0x080000 - 0x09FFFF : First copy of U-Boot Environment (128 KiB) | 708 | * 0x080000 - 0x09FFFF : First copy of U-Boot Environment (128 KiB) |
691 | * 0x0A0000 - 0x0BFFFF : Second copy of U-Boot Environment (128 KiB) | 709 | * 0x0A0000 - 0x0BFFFF : Second copy of U-Boot Environment (128 KiB) |
692 | * 0x0C0000 - 0x4BFFFF : Linux Kernel (4 MiB) | 710 | * 0x0C0000 - 0x4BFFFF : Linux Kernel (4 MiB) |
693 | * 0x4C0000 - 0xFFFFFF : Userland (11 MiB + 256 KiB) | 711 | * 0x4C0000 - 0xFFFFFF : Userland (11 MiB + 256 KiB) |
694 | */ | 712 | */ |
695 | #if defined(CONFIG_NOR) | 713 | #if defined(CONFIG_NOR) |
696 | #undef CONFIG_SYS_NO_FLASH | 714 | #undef CONFIG_SYS_NO_FLASH |
697 | #define CONFIG_SYS_FLASH_USE_BUFFER_WRITE | 715 | #define CONFIG_SYS_FLASH_USE_BUFFER_WRITE |
698 | #define CONFIG_SYS_FLASH_PROTECTION | 716 | #define CONFIG_SYS_FLASH_PROTECTION |
699 | #define CONFIG_SYS_FLASH_CFI | 717 | #define CONFIG_SYS_FLASH_CFI |
700 | #define CONFIG_FLASH_CFI_DRIVER | 718 | #define CONFIG_FLASH_CFI_DRIVER |
701 | #define CONFIG_FLASH_CFI_MTD | 719 | #define CONFIG_FLASH_CFI_MTD |
702 | #define CONFIG_SYS_MAX_FLASH_SECT 128 | 720 | #define CONFIG_SYS_MAX_FLASH_SECT 128 |
703 | #define CONFIG_SYS_MAX_FLASH_BANKS 1 | 721 | #define CONFIG_SYS_MAX_FLASH_BANKS 1 |
704 | #define CONFIG_SYS_FLASH_BASE (0x08000000) | 722 | #define CONFIG_SYS_FLASH_BASE (0x08000000) |
705 | #define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT | 723 | #define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT |
706 | #define CONFIG_SYS_FLASH_SIZE 0x01000000 | 724 | #define CONFIG_SYS_FLASH_SIZE 0x01000000 |
707 | #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE | 725 | #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE |
708 | #endif /* NOR support */ | 726 | #endif /* NOR support */ |
709 | 727 | ||
710 | #ifdef CONFIG_DRIVER_TI_CPSW | 728 | #ifdef CONFIG_DRIVER_TI_CPSW |
711 | #define CONFIG_CLOCK_SYNTHESIZER | 729 | #define CONFIG_CLOCK_SYNTHESIZER |
712 | #define CLK_SYNTHESIZER_I2C_ADDR 0x65 | 730 | #define CLK_SYNTHESIZER_I2C_ADDR 0x65 |
713 | #endif | 731 | #endif |
714 | 732 | ||
715 | #endif /* ! __CONFIG_SMARCT335X_EVM_H */ | 733 | #endif /* ! __CONFIG_SMARCT335X_EVM_H */ |
include/i2c.h
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net> | 2 | * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net> |
3 | * Copyright (C) 2009 - 2013 Heiko Schocher <hs@denx.de> | 3 | * Copyright (C) 2009 - 2013 Heiko Schocher <hs@denx.de> |
4 | * Changes for multibus/multiadapter I2C support. | 4 | * Changes for multibus/multiadapter I2C support. |
5 | * | 5 | * |
6 | * (C) Copyright 2001 | 6 | * (C) Copyright 2001 |
7 | * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com. | 7 | * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com. |
8 | * | 8 | * |
9 | * SPDX-License-Identifier: GPL-2.0+ | 9 | * SPDX-License-Identifier: GPL-2.0+ |
10 | * | 10 | * |
11 | * The original I2C interface was | 11 | * The original I2C interface was |
12 | * (C) 2000 by Paolo Scaffardi (arsenio@tin.it) | 12 | * (C) 2000 by Paolo Scaffardi (arsenio@tin.it) |
13 | * AIRVENT SAM s.p.a - RIMINI(ITALY) | 13 | * AIRVENT SAM s.p.a - RIMINI(ITALY) |
14 | * but has been changed substantially. | 14 | * but has been changed substantially. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #ifndef _I2C_H_ | 17 | #ifndef _I2C_H_ |
18 | #define _I2C_H_ | 18 | #define _I2C_H_ |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * For now there are essentially two parts to this file - driver model | 21 | * For now there are essentially two parts to this file - driver model |
22 | * here at the top, and the older code below (with CONFIG_SYS_I2C being | 22 | * here at the top, and the older code below (with CONFIG_SYS_I2C being |
23 | * most recent). The plan is to migrate everything to driver model. | 23 | * most recent). The plan is to migrate everything to driver model. |
24 | * The driver model structures and API are separate as they are different | 24 | * The driver model structures and API are separate as they are different |
25 | * enough as to be incompatible for compilation purposes. | 25 | * enough as to be incompatible for compilation purposes. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | enum dm_i2c_chip_flags { | 28 | enum dm_i2c_chip_flags { |
29 | DM_I2C_CHIP_10BIT = 1 << 0, /* Use 10-bit addressing */ | 29 | DM_I2C_CHIP_10BIT = 1 << 0, /* Use 10-bit addressing */ |
30 | DM_I2C_CHIP_RD_ADDRESS = 1 << 1, /* Send address for each read byte */ | 30 | DM_I2C_CHIP_RD_ADDRESS = 1 << 1, /* Send address for each read byte */ |
31 | DM_I2C_CHIP_WR_ADDRESS = 1 << 2, /* Send address for each write byte */ | 31 | DM_I2C_CHIP_WR_ADDRESS = 1 << 2, /* Send address for each write byte */ |
32 | }; | 32 | }; |
33 | 33 | ||
34 | struct udevice; | 34 | struct udevice; |
35 | /** | 35 | /** |
36 | * struct dm_i2c_chip - information about an i2c chip | 36 | * struct dm_i2c_chip - information about an i2c chip |
37 | * | 37 | * |
38 | * An I2C chip is a device on the I2C bus. It sits at a particular address | 38 | * An I2C chip is a device on the I2C bus. It sits at a particular address |
39 | * and normally supports 7-bit or 10-bit addressing. | 39 | * and normally supports 7-bit or 10-bit addressing. |
40 | * | 40 | * |
41 | * To obtain this structure, use dev_get_parent_platdata(dev) where dev is | 41 | * To obtain this structure, use dev_get_parent_platdata(dev) where dev is |
42 | * the chip to examine. | 42 | * the chip to examine. |
43 | * | 43 | * |
44 | * @chip_addr: Chip address on bus | 44 | * @chip_addr: Chip address on bus |
45 | * @offset_len: Length of offset in bytes. A single byte offset can | 45 | * @offset_len: Length of offset in bytes. A single byte offset can |
46 | * represent up to 256 bytes. A value larger than 1 may be | 46 | * represent up to 256 bytes. A value larger than 1 may be |
47 | * needed for larger devices. | 47 | * needed for larger devices. |
48 | * @flags: Flags for this chip (dm_i2c_chip_flags) | 48 | * @flags: Flags for this chip (dm_i2c_chip_flags) |
49 | * @emul: Emulator for this chip address (only used for emulation) | 49 | * @emul: Emulator for this chip address (only used for emulation) |
50 | */ | 50 | */ |
51 | struct dm_i2c_chip { | 51 | struct dm_i2c_chip { |
52 | uint chip_addr; | 52 | uint chip_addr; |
53 | uint offset_len; | 53 | uint offset_len; |
54 | uint flags; | 54 | uint flags; |
55 | #ifdef CONFIG_SANDBOX | 55 | #ifdef CONFIG_SANDBOX |
56 | struct udevice *emul; | 56 | struct udevice *emul; |
57 | bool test_mode; | 57 | bool test_mode; |
58 | #endif | 58 | #endif |
59 | }; | 59 | }; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * struct dm_i2c_bus- information about an i2c bus | 62 | * struct dm_i2c_bus- information about an i2c bus |
63 | * | 63 | * |
64 | * An I2C bus contains 0 or more chips on it, each at its own address. The | 64 | * An I2C bus contains 0 or more chips on it, each at its own address. The |
65 | * bus can operate at different speeds (measured in Hz, typically 100KHz | 65 | * bus can operate at different speeds (measured in Hz, typically 100KHz |
66 | * or 400KHz). | 66 | * or 400KHz). |
67 | * | 67 | * |
68 | * To obtain this structure, use dev_get_uclass_priv(bus) where bus is the | 68 | * To obtain this structure, use dev_get_uclass_priv(bus) where bus is the |
69 | * I2C bus udevice. | 69 | * I2C bus udevice. |
70 | * | 70 | * |
71 | * @speed_hz: Bus speed in hertz (typically 100000) | 71 | * @speed_hz: Bus speed in hertz (typically 100000) |
72 | */ | 72 | */ |
73 | struct dm_i2c_bus { | 73 | struct dm_i2c_bus { |
74 | int speed_hz; | 74 | int speed_hz; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | /* | 77 | /* |
78 | * Not all of these flags are implemented in the U-Boot API | 78 | * Not all of these flags are implemented in the U-Boot API |
79 | */ | 79 | */ |
80 | enum dm_i2c_msg_flags { | 80 | enum dm_i2c_msg_flags { |
81 | I2C_M_TEN = 0x0010, /* ten-bit chip address */ | 81 | I2C_M_TEN = 0x0010, /* ten-bit chip address */ |
82 | I2C_M_RD = 0x0001, /* read data, from slave to master */ | 82 | I2C_M_RD = 0x0001, /* read data, from slave to master */ |
83 | I2C_M_STOP = 0x8000, /* send stop after this message */ | 83 | I2C_M_STOP = 0x8000, /* send stop after this message */ |
84 | I2C_M_NOSTART = 0x4000, /* no start before this message */ | 84 | I2C_M_NOSTART = 0x4000, /* no start before this message */ |
85 | I2C_M_REV_DIR_ADDR = 0x2000, /* invert polarity of R/W bit */ | 85 | I2C_M_REV_DIR_ADDR = 0x2000, /* invert polarity of R/W bit */ |
86 | I2C_M_IGNORE_NAK = 0x1000, /* continue after NAK */ | 86 | I2C_M_IGNORE_NAK = 0x1000, /* continue after NAK */ |
87 | I2C_M_NO_RD_ACK = 0x0800, /* skip the Ack bit on reads */ | 87 | I2C_M_NO_RD_ACK = 0x0800, /* skip the Ack bit on reads */ |
88 | I2C_M_RECV_LEN = 0x0400, /* length is first received byte */ | 88 | I2C_M_RECV_LEN = 0x0400, /* length is first received byte */ |
89 | }; | 89 | }; |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * struct i2c_msg - an I2C message | 92 | * struct i2c_msg - an I2C message |
93 | * | 93 | * |
94 | * @addr: Slave address | 94 | * @addr: Slave address |
95 | * @flags: Flags (see enum dm_i2c_msg_flags) | 95 | * @flags: Flags (see enum dm_i2c_msg_flags) |
96 | * @len: Length of buffer in bytes, may be 0 for a probe | 96 | * @len: Length of buffer in bytes, may be 0 for a probe |
97 | * @buf: Buffer to send/receive, or NULL if no data | 97 | * @buf: Buffer to send/receive, or NULL if no data |
98 | */ | 98 | */ |
99 | struct i2c_msg { | 99 | struct i2c_msg { |
100 | uint addr; | 100 | uint addr; |
101 | uint flags; | 101 | uint flags; |
102 | uint len; | 102 | uint len; |
103 | u8 *buf; | 103 | u8 *buf; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * struct i2c_msg_list - a list of I2C messages | 107 | * struct i2c_msg_list - a list of I2C messages |
108 | * | 108 | * |
109 | * This is called i2c_rdwr_ioctl_data in Linux but the name does not seem | 109 | * This is called i2c_rdwr_ioctl_data in Linux but the name does not seem |
110 | * appropriate in U-Boot. | 110 | * appropriate in U-Boot. |
111 | * | 111 | * |
112 | * @msg: Pointer to i2c_msg array | 112 | * @msg: Pointer to i2c_msg array |
113 | * @nmsgs: Number of elements in the array | 113 | * @nmsgs: Number of elements in the array |
114 | */ | 114 | */ |
115 | struct i2c_msg_list { | 115 | struct i2c_msg_list { |
116 | struct i2c_msg *msgs; | 116 | struct i2c_msg *msgs; |
117 | uint nmsgs; | 117 | uint nmsgs; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * dm_i2c_read() - read bytes from an I2C chip | 121 | * dm_i2c_read() - read bytes from an I2C chip |
122 | * | 122 | * |
123 | * To obtain an I2C device (called a 'chip') given the I2C bus address you | 123 | * To obtain an I2C device (called a 'chip') given the I2C bus address you |
124 | * can use i2c_get_chip(). To obtain a bus by bus number use | 124 | * can use i2c_get_chip(). To obtain a bus by bus number use |
125 | * uclass_get_device_by_seq(UCLASS_I2C, <bus number>). | 125 | * uclass_get_device_by_seq(UCLASS_I2C, <bus number>). |
126 | * | 126 | * |
127 | * To set the address length of a devce use i2c_set_addr_len(). It | 127 | * To set the address length of a devce use i2c_set_addr_len(). It |
128 | * defaults to 1. | 128 | * defaults to 1. |
129 | * | 129 | * |
130 | * @dev: Chip to read from | 130 | * @dev: Chip to read from |
131 | * @offset: Offset within chip to start reading | 131 | * @offset: Offset within chip to start reading |
132 | * @buffer: Place to put data | 132 | * @buffer: Place to put data |
133 | * @len: Number of bytes to read | 133 | * @len: Number of bytes to read |
134 | * | 134 | * |
135 | * @return 0 on success, -ve on failure | 135 | * @return 0 on success, -ve on failure |
136 | */ | 136 | */ |
137 | int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len); | 137 | int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len); |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * dm_i2c_write() - write bytes to an I2C chip | 140 | * dm_i2c_write() - write bytes to an I2C chip |
141 | * | 141 | * |
142 | * See notes for dm_i2c_read() above. | 142 | * See notes for dm_i2c_read() above. |
143 | * | 143 | * |
144 | * @dev: Chip to write to | 144 | * @dev: Chip to write to |
145 | * @offset: Offset within chip to start writing | 145 | * @offset: Offset within chip to start writing |
146 | * @buffer: Buffer containing data to write | 146 | * @buffer: Buffer containing data to write |
147 | * @len: Number of bytes to write | 147 | * @len: Number of bytes to write |
148 | * | 148 | * |
149 | * @return 0 on success, -ve on failure | 149 | * @return 0 on success, -ve on failure |
150 | */ | 150 | */ |
151 | int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, | 151 | int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, |
152 | int len); | 152 | int len); |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * dm_i2c_probe() - probe a particular chip address | 155 | * dm_i2c_probe() - probe a particular chip address |
156 | * | 156 | * |
157 | * This can be useful to check for the existence of a chip on the bus. | 157 | * This can be useful to check for the existence of a chip on the bus. |
158 | * It is typically implemented by writing the chip address to the bus | 158 | * It is typically implemented by writing the chip address to the bus |
159 | * and checking that the chip replies with an ACK. | 159 | * and checking that the chip replies with an ACK. |
160 | * | 160 | * |
161 | * @bus: Bus to probe | 161 | * @bus: Bus to probe |
162 | * @chip_addr: 7-bit address to probe (10-bit and others are not supported) | 162 | * @chip_addr: 7-bit address to probe (10-bit and others are not supported) |
163 | * @chip_flags: Flags for the probe (see enum dm_i2c_chip_flags) | 163 | * @chip_flags: Flags for the probe (see enum dm_i2c_chip_flags) |
164 | * @devp: Returns the device found, or NULL if none | 164 | * @devp: Returns the device found, or NULL if none |
165 | * @return 0 if a chip was found at that address, -ve if not | 165 | * @return 0 if a chip was found at that address, -ve if not |
166 | */ | 166 | */ |
167 | int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags, | 167 | int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags, |
168 | struct udevice **devp); | 168 | struct udevice **devp); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * dm_i2c_reg_read() - Read a value from an I2C register | 171 | * dm_i2c_reg_read() - Read a value from an I2C register |
172 | * | 172 | * |
173 | * This reads a single value from the given address in an I2C chip | 173 | * This reads a single value from the given address in an I2C chip |
174 | * | 174 | * |
175 | * @dev: Device to use for transfer | 175 | * @dev: Device to use for transfer |
176 | * @addr: Address to read from | 176 | * @addr: Address to read from |
177 | * @return value read, or -ve on error | 177 | * @return value read, or -ve on error |
178 | */ | 178 | */ |
179 | int dm_i2c_reg_read(struct udevice *dev, uint offset); | 179 | int dm_i2c_reg_read(struct udevice *dev, uint offset); |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * dm_i2c_reg_write() - Write a value to an I2C register | 182 | * dm_i2c_reg_write() - Write a value to an I2C register |
183 | * | 183 | * |
184 | * This writes a single value to the given address in an I2C chip | 184 | * This writes a single value to the given address in an I2C chip |
185 | * | 185 | * |
186 | * @dev: Device to use for transfer | 186 | * @dev: Device to use for transfer |
187 | * @addr: Address to write to | 187 | * @addr: Address to write to |
188 | * @val: Value to write (normally a byte) | 188 | * @val: Value to write (normally a byte) |
189 | * @return 0 on success, -ve on error | 189 | * @return 0 on success, -ve on error |
190 | */ | 190 | */ |
191 | int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val); | 191 | int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * dm_i2c_xfer() - Transfer messages over I2C | 194 | * dm_i2c_xfer() - Transfer messages over I2C |
195 | * | 195 | * |
196 | * This transfers a raw message. It is best to use dm_i2c_reg_read/write() | 196 | * This transfers a raw message. It is best to use dm_i2c_reg_read/write() |
197 | * instead. | 197 | * instead. |
198 | * | 198 | * |
199 | * @dev: Device to use for transfer | 199 | * @dev: Device to use for transfer |
200 | * @msg: List of messages to transfer | 200 | * @msg: List of messages to transfer |
201 | * @nmsgs: Number of messages to transfer | 201 | * @nmsgs: Number of messages to transfer |
202 | * @return 0 on success, -ve on error | 202 | * @return 0 on success, -ve on error |
203 | */ | 203 | */ |
204 | int dm_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs); | 204 | int dm_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs); |
205 | 205 | ||
206 | /** | 206 | /** |
207 | * dm_i2c_set_bus_speed() - set the speed of a bus | 207 | * dm_i2c_set_bus_speed() - set the speed of a bus |
208 | * | 208 | * |
209 | * @bus: Bus to adjust | 209 | * @bus: Bus to adjust |
210 | * @speed: Requested speed in Hz | 210 | * @speed: Requested speed in Hz |
211 | * @return 0 if OK, -EINVAL for invalid values | 211 | * @return 0 if OK, -EINVAL for invalid values |
212 | */ | 212 | */ |
213 | int dm_i2c_set_bus_speed(struct udevice *bus, unsigned int speed); | 213 | int dm_i2c_set_bus_speed(struct udevice *bus, unsigned int speed); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * dm_i2c_get_bus_speed() - get the speed of a bus | 216 | * dm_i2c_get_bus_speed() - get the speed of a bus |
217 | * | 217 | * |
218 | * @bus: Bus to check | 218 | * @bus: Bus to check |
219 | * @return speed of selected I2C bus in Hz, -ve on error | 219 | * @return speed of selected I2C bus in Hz, -ve on error |
220 | */ | 220 | */ |
221 | int dm_i2c_get_bus_speed(struct udevice *bus); | 221 | int dm_i2c_get_bus_speed(struct udevice *bus); |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * i2c_set_chip_flags() - set flags for a chip | 224 | * i2c_set_chip_flags() - set flags for a chip |
225 | * | 225 | * |
226 | * Typically addresses are 7 bits, but for 10-bit addresses you should set | 226 | * Typically addresses are 7 bits, but for 10-bit addresses you should set |
227 | * flags to DM_I2C_CHIP_10BIT. All accesses will then use 10-bit addressing. | 227 | * flags to DM_I2C_CHIP_10BIT. All accesses will then use 10-bit addressing. |
228 | * | 228 | * |
229 | * @dev: Chip to adjust | 229 | * @dev: Chip to adjust |
230 | * @flags: New flags | 230 | * @flags: New flags |
231 | * @return 0 if OK, -EINVAL if value is unsupported, other -ve value on error | 231 | * @return 0 if OK, -EINVAL if value is unsupported, other -ve value on error |
232 | */ | 232 | */ |
233 | int i2c_set_chip_flags(struct udevice *dev, uint flags); | 233 | int i2c_set_chip_flags(struct udevice *dev, uint flags); |
234 | 234 | ||
235 | /** | 235 | /** |
236 | * i2c_get_chip_flags() - get flags for a chip | 236 | * i2c_get_chip_flags() - get flags for a chip |
237 | * | 237 | * |
238 | * @dev: Chip to check | 238 | * @dev: Chip to check |
239 | * @flagsp: Place to put flags | 239 | * @flagsp: Place to put flags |
240 | * @return 0 if OK, other -ve value on error | 240 | * @return 0 if OK, other -ve value on error |
241 | */ | 241 | */ |
242 | int i2c_get_chip_flags(struct udevice *dev, uint *flagsp); | 242 | int i2c_get_chip_flags(struct udevice *dev, uint *flagsp); |
243 | 243 | ||
244 | /** | 244 | /** |
245 | * i2c_set_offset_len() - set the offset length for a chip | 245 | * i2c_set_offset_len() - set the offset length for a chip |
246 | * | 246 | * |
247 | * The offset used to access a chip may be up to 4 bytes long. Typically it | 247 | * The offset used to access a chip may be up to 4 bytes long. Typically it |
248 | * is only 1 byte, which is enough for chips with 256 bytes of memory or | 248 | * is only 1 byte, which is enough for chips with 256 bytes of memory or |
249 | * registers. The default value is 1, but you can call this function to | 249 | * registers. The default value is 1, but you can call this function to |
250 | * change it. | 250 | * change it. |
251 | * | 251 | * |
252 | * @offset_len: New offset length value (typically 1 or 2) | 252 | * @offset_len: New offset length value (typically 1 or 2) |
253 | */ | 253 | */ |
254 | int i2c_set_chip_offset_len(struct udevice *dev, uint offset_len); | 254 | int i2c_set_chip_offset_len(struct udevice *dev, uint offset_len); |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * i2c_get_offset_len() - get the offset length for a chip | 257 | * i2c_get_offset_len() - get the offset length for a chip |
258 | * | 258 | * |
259 | * @return: Current offset length value (typically 1 or 2) | 259 | * @return: Current offset length value (typically 1 or 2) |
260 | */ | 260 | */ |
261 | int i2c_get_chip_offset_len(struct udevice *dev); | 261 | int i2c_get_chip_offset_len(struct udevice *dev); |
262 | 262 | ||
263 | /** | 263 | /** |
264 | * i2c_deblock() - recover a bus that is in an unknown state | 264 | * i2c_deblock() - recover a bus that is in an unknown state |
265 | * | 265 | * |
266 | * See the deblock() method in 'struct dm_i2c_ops' for full information | 266 | * See the deblock() method in 'struct dm_i2c_ops' for full information |
267 | * | 267 | * |
268 | * @bus: Bus to recover | 268 | * @bus: Bus to recover |
269 | * @return 0 if OK, -ve on error | 269 | * @return 0 if OK, -ve on error |
270 | */ | 270 | */ |
271 | int i2c_deblock(struct udevice *bus); | 271 | int i2c_deblock(struct udevice *bus); |
272 | 272 | ||
273 | #ifdef CONFIG_DM_I2C_COMPAT | 273 | #ifdef CONFIG_DM_I2C_COMPAT |
274 | /** | 274 | /** |
275 | * i2c_probe() - Compatibility function for driver model | 275 | * i2c_probe() - Compatibility function for driver model |
276 | * | 276 | * |
277 | * Calls dm_i2c_probe() on the current bus | 277 | * Calls dm_i2c_probe() on the current bus |
278 | */ | 278 | */ |
279 | int i2c_probe(uint8_t chip_addr); | 279 | int i2c_probe(uint8_t chip_addr); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | * i2c_read() - Compatibility function for driver model | 282 | * i2c_read() - Compatibility function for driver model |
283 | * | 283 | * |
284 | * Calls dm_i2c_read() with the device corresponding to @chip_addr, and offset | 284 | * Calls dm_i2c_read() with the device corresponding to @chip_addr, and offset |
285 | * set to @addr. @alen must match the current setting for the device. | 285 | * set to @addr. @alen must match the current setting for the device. |
286 | */ | 286 | */ |
287 | int i2c_read(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer, | 287 | int i2c_read(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer, |
288 | int len); | 288 | int len); |
289 | 289 | ||
290 | /** | 290 | /** |
291 | * i2c_write() - Compatibility function for driver model | 291 | * i2c_write() - Compatibility function for driver model |
292 | * | 292 | * |
293 | * Calls dm_i2c_write() with the device corresponding to @chip_addr, and offset | 293 | * Calls dm_i2c_write() with the device corresponding to @chip_addr, and offset |
294 | * set to @addr. @alen must match the current setting for the device. | 294 | * set to @addr. @alen must match the current setting for the device. |
295 | */ | 295 | */ |
296 | int i2c_write(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer, | 296 | int i2c_write(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer, |
297 | int len); | 297 | int len); |
298 | 298 | ||
299 | /** | 299 | /** |
300 | * i2c_get_bus_num_fdt() - Compatibility function for driver model | 300 | * i2c_get_bus_num_fdt() - Compatibility function for driver model |
301 | * | 301 | * |
302 | * @return the bus number associated with the given device tree node | 302 | * @return the bus number associated with the given device tree node |
303 | */ | 303 | */ |
304 | int i2c_get_bus_num_fdt(int node); | 304 | int i2c_get_bus_num_fdt(int node); |
305 | 305 | ||
306 | /** | 306 | /** |
307 | * i2c_get_bus_num() - Compatibility function for driver model | 307 | * i2c_get_bus_num() - Compatibility function for driver model |
308 | * | 308 | * |
309 | * @return the 'current' bus number | 309 | * @return the 'current' bus number |
310 | */ | 310 | */ |
311 | unsigned int i2c_get_bus_num(void); | 311 | unsigned int i2c_get_bus_num(void); |
312 | 312 | ||
313 | /** | 313 | /** |
314 | * i2c_set_bus_num() - Compatibility function for driver model | 314 | * i2c_set_bus_num() - Compatibility function for driver model |
315 | * | 315 | * |
316 | * Sets the 'current' bus | 316 | * Sets the 'current' bus |
317 | */ | 317 | */ |
318 | int i2c_set_bus_num(unsigned int bus); | 318 | int i2c_set_bus_num(unsigned int bus); |
319 | 319 | ||
320 | static inline void I2C_SET_BUS(unsigned int bus) | 320 | static inline void I2C_SET_BUS(unsigned int bus) |
321 | { | 321 | { |
322 | i2c_set_bus_num(bus); | 322 | i2c_set_bus_num(bus); |
323 | } | 323 | } |
324 | 324 | ||
325 | static inline unsigned int I2C_GET_BUS(void) | 325 | static inline unsigned int I2C_GET_BUS(void) |
326 | { | 326 | { |
327 | return i2c_get_bus_num(); | 327 | return i2c_get_bus_num(); |
328 | } | 328 | } |
329 | 329 | ||
330 | /** | 330 | /** |
331 | * i2c_init() - Compatibility function for driver model | 331 | * i2c_init() - Compatibility function for driver model |
332 | * | 332 | * |
333 | * This function does nothing. | 333 | * This function does nothing. |
334 | */ | 334 | */ |
335 | void i2c_init(int speed, int slaveaddr); | 335 | void i2c_init(int speed, int slaveaddr); |
336 | 336 | ||
337 | /** | 337 | /** |
338 | * board_i2c_init() - Compatibility function for driver model | 338 | * board_i2c_init() - Compatibility function for driver model |
339 | * | 339 | * |
340 | * @param blob Device tree blbo | 340 | * @param blob Device tree blbo |
341 | * @return the number of I2C bus | 341 | * @return the number of I2C bus |
342 | */ | 342 | */ |
343 | void board_i2c_init(const void *blob); | 343 | void board_i2c_init(const void *blob); |
344 | 344 | ||
345 | /* | 345 | /* |
346 | * Compatibility functions for driver model. | 346 | * Compatibility functions for driver model. |
347 | */ | 347 | */ |
348 | uint8_t i2c_reg_read(uint8_t addr, uint8_t reg); | 348 | uint8_t i2c_reg_read(uint8_t addr, uint8_t reg); |
349 | void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val); | 349 | void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val); |
350 | 350 | ||
351 | #endif | 351 | #endif |
352 | 352 | ||
353 | /** | 353 | /** |
354 | * struct dm_i2c_ops - driver operations for I2C uclass | 354 | * struct dm_i2c_ops - driver operations for I2C uclass |
355 | * | 355 | * |
356 | * Drivers should support these operations unless otherwise noted. These | 356 | * Drivers should support these operations unless otherwise noted. These |
357 | * operations are intended to be used by uclass code, not directly from | 357 | * operations are intended to be used by uclass code, not directly from |
358 | * other code. | 358 | * other code. |
359 | */ | 359 | */ |
360 | struct dm_i2c_ops { | 360 | struct dm_i2c_ops { |
361 | /** | 361 | /** |
362 | * xfer() - transfer a list of I2C messages | 362 | * xfer() - transfer a list of I2C messages |
363 | * | 363 | * |
364 | * @bus: Bus to read from | 364 | * @bus: Bus to read from |
365 | * @msg: List of messages to transfer | 365 | * @msg: List of messages to transfer |
366 | * @nmsgs: Number of messages in the list | 366 | * @nmsgs: Number of messages in the list |
367 | * @return 0 if OK, -EREMOTEIO if the slave did not ACK a byte, | 367 | * @return 0 if OK, -EREMOTEIO if the slave did not ACK a byte, |
368 | * -ECOMM if the speed cannot be supported, -EPROTO if the chip | 368 | * -ECOMM if the speed cannot be supported, -EPROTO if the chip |
369 | * flags cannot be supported, other -ve value on some other error | 369 | * flags cannot be supported, other -ve value on some other error |
370 | */ | 370 | */ |
371 | int (*xfer)(struct udevice *bus, struct i2c_msg *msg, int nmsgs); | 371 | int (*xfer)(struct udevice *bus, struct i2c_msg *msg, int nmsgs); |
372 | 372 | ||
373 | /** | 373 | /** |
374 | * probe_chip() - probe for the presense of a chip address | 374 | * probe_chip() - probe for the presense of a chip address |
375 | * | 375 | * |
376 | * This function is optional. If omitted, the uclass will send a zero | 376 | * This function is optional. If omitted, the uclass will send a zero |
377 | * length message instead. | 377 | * length message instead. |
378 | * | 378 | * |
379 | * @bus: Bus to probe | 379 | * @bus: Bus to probe |
380 | * @chip_addr: Chip address to probe | 380 | * @chip_addr: Chip address to probe |
381 | * @chip_flags: Probe flags (enum dm_i2c_chip_flags) | 381 | * @chip_flags: Probe flags (enum dm_i2c_chip_flags) |
382 | * @return 0 if chip was found, -EREMOTEIO if not, -ENOSYS to fall back | 382 | * @return 0 if chip was found, -EREMOTEIO if not, -ENOSYS to fall back |
383 | * to default probem other -ve value on error | 383 | * to default probem other -ve value on error |
384 | */ | 384 | */ |
385 | int (*probe_chip)(struct udevice *bus, uint chip_addr, uint chip_flags); | 385 | int (*probe_chip)(struct udevice *bus, uint chip_addr, uint chip_flags); |
386 | 386 | ||
387 | /** | 387 | /** |
388 | * set_bus_speed() - set the speed of a bus (optional) | 388 | * set_bus_speed() - set the speed of a bus (optional) |
389 | * | 389 | * |
390 | * The bus speed value will be updated by the uclass if this function | 390 | * The bus speed value will be updated by the uclass if this function |
391 | * does not return an error. This method is optional - if it is not | 391 | * does not return an error. This method is optional - if it is not |
392 | * provided then the driver can read the speed from | 392 | * provided then the driver can read the speed from |
393 | * dev_get_uclass_priv(bus)->speed_hz | 393 | * dev_get_uclass_priv(bus)->speed_hz |
394 | * | 394 | * |
395 | * @bus: Bus to adjust | 395 | * @bus: Bus to adjust |
396 | * @speed: Requested speed in Hz | 396 | * @speed: Requested speed in Hz |
397 | * @return 0 if OK, -EINVAL for invalid values | 397 | * @return 0 if OK, -EINVAL for invalid values |
398 | */ | 398 | */ |
399 | int (*set_bus_speed)(struct udevice *bus, unsigned int speed); | 399 | int (*set_bus_speed)(struct udevice *bus, unsigned int speed); |
400 | 400 | ||
401 | /** | 401 | /** |
402 | * get_bus_speed() - get the speed of a bus (optional) | 402 | * get_bus_speed() - get the speed of a bus (optional) |
403 | * | 403 | * |
404 | * Normally this can be provided by the uclass, but if you want your | 404 | * Normally this can be provided by the uclass, but if you want your |
405 | * driver to check the bus speed by looking at the hardware, you can | 405 | * driver to check the bus speed by looking at the hardware, you can |
406 | * implement that here. This method is optional. This method would | 406 | * implement that here. This method is optional. This method would |
407 | * normally be expected to return dev_get_uclass_priv(bus)->speed_hz. | 407 | * normally be expected to return dev_get_uclass_priv(bus)->speed_hz. |
408 | * | 408 | * |
409 | * @bus: Bus to check | 409 | * @bus: Bus to check |
410 | * @return speed of selected I2C bus in Hz, -ve on error | 410 | * @return speed of selected I2C bus in Hz, -ve on error |
411 | */ | 411 | */ |
412 | int (*get_bus_speed)(struct udevice *bus); | 412 | int (*get_bus_speed)(struct udevice *bus); |
413 | 413 | ||
414 | /** | 414 | /** |
415 | * set_flags() - set the flags for a chip (optional) | 415 | * set_flags() - set the flags for a chip (optional) |
416 | * | 416 | * |
417 | * This is generally implemented by the uclass, but drivers can | 417 | * This is generally implemented by the uclass, but drivers can |
418 | * check the value to ensure that unsupported options are not used. | 418 | * check the value to ensure that unsupported options are not used. |
419 | * This method is optional. If provided, this method will always be | 419 | * This method is optional. If provided, this method will always be |
420 | * called when the flags change. | 420 | * called when the flags change. |
421 | * | 421 | * |
422 | * @dev: Chip to adjust | 422 | * @dev: Chip to adjust |
423 | * @flags: New flags value | 423 | * @flags: New flags value |
424 | * @return 0 if OK, -EINVAL if value is unsupported | 424 | * @return 0 if OK, -EINVAL if value is unsupported |
425 | */ | 425 | */ |
426 | int (*set_flags)(struct udevice *dev, uint flags); | 426 | int (*set_flags)(struct udevice *dev, uint flags); |
427 | 427 | ||
428 | /** | 428 | /** |
429 | * deblock() - recover a bus that is in an unknown state | 429 | * deblock() - recover a bus that is in an unknown state |
430 | * | 430 | * |
431 | * I2C is a synchronous protocol and resets of the processor in the | 431 | * I2C is a synchronous protocol and resets of the processor in the |
432 | * middle of an access can block the I2C Bus until a powerdown of | 432 | * middle of an access can block the I2C Bus until a powerdown of |
433 | * the full unit is done. This is because slaves can be stuck | 433 | * the full unit is done. This is because slaves can be stuck |
434 | * waiting for addition bus transitions for a transaction that will | 434 | * waiting for addition bus transitions for a transaction that will |
435 | * never complete. Resetting the I2C master does not help. The only | 435 | * never complete. Resetting the I2C master does not help. The only |
436 | * way is to force the bus through a series of transitions to make | 436 | * way is to force the bus through a series of transitions to make |
437 | * sure that all slaves are done with the transaction. This method | 437 | * sure that all slaves are done with the transaction. This method |
438 | * performs this 'deblocking' if support by the driver. | 438 | * performs this 'deblocking' if support by the driver. |
439 | * | 439 | * |
440 | * This method is optional. | 440 | * This method is optional. |
441 | */ | 441 | */ |
442 | int (*deblock)(struct udevice *bus); | 442 | int (*deblock)(struct udevice *bus); |
443 | }; | 443 | }; |
444 | 444 | ||
445 | #define i2c_get_ops(dev) ((struct dm_i2c_ops *)(dev)->driver->ops) | 445 | #define i2c_get_ops(dev) ((struct dm_i2c_ops *)(dev)->driver->ops) |
446 | 446 | ||
447 | /** | 447 | /** |
448 | * struct i2c_mux_ops - operations for an I2C mux | 448 | * struct i2c_mux_ops - operations for an I2C mux |
449 | * | 449 | * |
450 | * The current mux state is expected to be stored in the mux itself since | 450 | * The current mux state is expected to be stored in the mux itself since |
451 | * it is the only thing that knows how to make things work. The mux can | 451 | * it is the only thing that knows how to make things work. The mux can |
452 | * record the current state and then avoid switching unless it is necessary. | 452 | * record the current state and then avoid switching unless it is necessary. |
453 | * So select() can be skipped if the mux is already in the correct state. | 453 | * So select() can be skipped if the mux is already in the correct state. |
454 | * Also deselect() can be made a nop if required. | 454 | * Also deselect() can be made a nop if required. |
455 | */ | 455 | */ |
456 | struct i2c_mux_ops { | 456 | struct i2c_mux_ops { |
457 | /** | 457 | /** |
458 | * select() - select one of of I2C buses attached to a mux | 458 | * select() - select one of of I2C buses attached to a mux |
459 | * | 459 | * |
460 | * This will be called when there is no bus currently selected by the | 460 | * This will be called when there is no bus currently selected by the |
461 | * mux. This method does not need to deselect the old bus since | 461 | * mux. This method does not need to deselect the old bus since |
462 | * deselect() will be already have been called if necessary. | 462 | * deselect() will be already have been called if necessary. |
463 | * | 463 | * |
464 | * @mux: Mux device | 464 | * @mux: Mux device |
465 | * @bus: I2C bus to select | 465 | * @bus: I2C bus to select |
466 | * @channel: Channel number correponding to the bus to select | 466 | * @channel: Channel number correponding to the bus to select |
467 | * @return 0 if OK, -ve on error | 467 | * @return 0 if OK, -ve on error |
468 | */ | 468 | */ |
469 | int (*select)(struct udevice *mux, struct udevice *bus, uint channel); | 469 | int (*select)(struct udevice *mux, struct udevice *bus, uint channel); |
470 | 470 | ||
471 | /** | 471 | /** |
472 | * deselect() - select one of of I2C buses attached to a mux | 472 | * deselect() - select one of of I2C buses attached to a mux |
473 | * | 473 | * |
474 | * This is used to deselect the currently selected I2C bus. | 474 | * This is used to deselect the currently selected I2C bus. |
475 | * | 475 | * |
476 | * @mux: Mux device | 476 | * @mux: Mux device |
477 | * @bus: I2C bus to deselect | 477 | * @bus: I2C bus to deselect |
478 | * @channel: Channel number correponding to the bus to deselect | 478 | * @channel: Channel number correponding to the bus to deselect |
479 | * @return 0 if OK, -ve on error | 479 | * @return 0 if OK, -ve on error |
480 | */ | 480 | */ |
481 | int (*deselect)(struct udevice *mux, struct udevice *bus, uint channel); | 481 | int (*deselect)(struct udevice *mux, struct udevice *bus, uint channel); |
482 | }; | 482 | }; |
483 | 483 | ||
484 | #define i2c_mux_get_ops(dev) ((struct i2c_mux_ops *)(dev)->driver->ops) | 484 | #define i2c_mux_get_ops(dev) ((struct i2c_mux_ops *)(dev)->driver->ops) |
485 | 485 | ||
486 | /** | 486 | /** |
487 | * i2c_get_chip() - get a device to use to access a chip on a bus | 487 | * i2c_get_chip() - get a device to use to access a chip on a bus |
488 | * | 488 | * |
489 | * This returns the device for the given chip address. The device can then | 489 | * This returns the device for the given chip address. The device can then |
490 | * be used with calls to i2c_read(), i2c_write(), i2c_probe(), etc. | 490 | * be used with calls to i2c_read(), i2c_write(), i2c_probe(), etc. |
491 | * | 491 | * |
492 | * @bus: Bus to examine | 492 | * @bus: Bus to examine |
493 | * @chip_addr: Chip address for the new device | 493 | * @chip_addr: Chip address for the new device |
494 | * @offset_len: Length of a register offset in bytes (normally 1) | 494 | * @offset_len: Length of a register offset in bytes (normally 1) |
495 | * @devp: Returns pointer to new device if found or -ENODEV if not | 495 | * @devp: Returns pointer to new device if found or -ENODEV if not |
496 | * found | 496 | * found |
497 | */ | 497 | */ |
498 | int i2c_get_chip(struct udevice *bus, uint chip_addr, uint offset_len, | 498 | int i2c_get_chip(struct udevice *bus, uint chip_addr, uint offset_len, |
499 | struct udevice **devp); | 499 | struct udevice **devp); |
500 | 500 | ||
501 | /** | 501 | /** |
502 | * i2c_get_chip_for_busnum() - get a device to use to access a chip on | 502 | * i2c_get_chip_for_busnum() - get a device to use to access a chip on |
503 | * a bus number | 503 | * a bus number |
504 | * | 504 | * |
505 | * This returns the device for the given chip address on a particular bus | 505 | * This returns the device for the given chip address on a particular bus |
506 | * number. | 506 | * number. |
507 | * | 507 | * |
508 | * @busnum: Bus number to examine | 508 | * @busnum: Bus number to examine |
509 | * @chip_addr: Chip address for the new device | 509 | * @chip_addr: Chip address for the new device |
510 | * @offset_len: Length of a register offset in bytes (normally 1) | 510 | * @offset_len: Length of a register offset in bytes (normally 1) |
511 | * @devp: Returns pointer to new device if found or -ENODEV if not | 511 | * @devp: Returns pointer to new device if found or -ENODEV if not |
512 | * found | 512 | * found |
513 | */ | 513 | */ |
514 | int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, | 514 | int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, |
515 | struct udevice **devp); | 515 | struct udevice **devp); |
516 | 516 | ||
517 | /** | 517 | /** |
518 | * i2c_chip_ofdata_to_platdata() - Decode standard I2C platform data | 518 | * i2c_chip_ofdata_to_platdata() - Decode standard I2C platform data |
519 | * | 519 | * |
520 | * This decodes the chip address from a device tree node and puts it into | 520 | * This decodes the chip address from a device tree node and puts it into |
521 | * its dm_i2c_chip structure. This should be called in your driver's | 521 | * its dm_i2c_chip structure. This should be called in your driver's |
522 | * ofdata_to_platdata() method. | 522 | * ofdata_to_platdata() method. |
523 | * | 523 | * |
524 | * @blob: Device tree blob | 524 | * @blob: Device tree blob |
525 | * @node: Node offset to read from | 525 | * @node: Node offset to read from |
526 | * @spi: Place to put the decoded information | 526 | * @spi: Place to put the decoded information |
527 | */ | 527 | */ |
528 | int i2c_chip_ofdata_to_platdata(const void *blob, int node, | 528 | int i2c_chip_ofdata_to_platdata(const void *blob, int node, |
529 | struct dm_i2c_chip *chip); | 529 | struct dm_i2c_chip *chip); |
530 | 530 | ||
531 | /** | 531 | /** |
532 | * i2c_dump_msgs() - Dump a list of I2C messages | 532 | * i2c_dump_msgs() - Dump a list of I2C messages |
533 | * | 533 | * |
534 | * This may be useful for debugging. | 534 | * This may be useful for debugging. |
535 | * | 535 | * |
536 | * @msg: Message list to dump | 536 | * @msg: Message list to dump |
537 | * @nmsgs: Number of messages | 537 | * @nmsgs: Number of messages |
538 | */ | 538 | */ |
539 | void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs); | 539 | void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs); |
540 | 540 | ||
541 | #ifndef CONFIG_DM_I2C | 541 | #ifndef CONFIG_DM_I2C |
542 | 542 | ||
543 | /* | 543 | /* |
544 | * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 544 | * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
545 | * | 545 | * |
546 | * The implementation MUST NOT use static or global variables if the | 546 | * The implementation MUST NOT use static or global variables if the |
547 | * I2C routines are used to read SDRAM configuration information | 547 | * I2C routines are used to read SDRAM configuration information |
548 | * because this is done before the memories are initialized. Limited | 548 | * because this is done before the memories are initialized. Limited |
549 | * use of stack-based variables are OK (the initial stack size is | 549 | * use of stack-based variables are OK (the initial stack size is |
550 | * limited). | 550 | * limited). |
551 | * | 551 | * |
552 | * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | 552 | * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |
553 | */ | 553 | */ |
554 | 554 | ||
555 | /* | 555 | /* |
556 | * Configuration items. | 556 | * Configuration items. |
557 | */ | 557 | */ |
558 | #define I2C_RXTX_LEN 128 /* maximum tx/rx buffer length */ | 558 | #define I2C_RXTX_LEN 128 /* maximum tx/rx buffer length */ |
559 | 559 | ||
560 | #if !defined(CONFIG_SYS_I2C_MAX_HOPS) | 560 | #if !defined(CONFIG_SYS_I2C_MAX_HOPS) |
561 | /* no muxes used bus = i2c adapters */ | 561 | /* no muxes used bus = i2c adapters */ |
562 | #define CONFIG_SYS_I2C_DIRECT_BUS 1 | 562 | #define CONFIG_SYS_I2C_DIRECT_BUS 1 |
563 | #define CONFIG_SYS_I2C_MAX_HOPS 0 | 563 | #define CONFIG_SYS_I2C_MAX_HOPS 0 |
564 | #define CONFIG_SYS_NUM_I2C_BUSES ll_entry_count(struct i2c_adapter, i2c) | 564 | #define CONFIG_SYS_NUM_I2C_BUSES ll_entry_count(struct i2c_adapter, i2c) |
565 | #else | 565 | #else |
566 | /* we use i2c muxes */ | 566 | /* we use i2c muxes */ |
567 | #undef CONFIG_SYS_I2C_DIRECT_BUS | 567 | #undef CONFIG_SYS_I2C_DIRECT_BUS |
568 | #endif | 568 | #endif |
569 | 569 | ||
570 | /* define the I2C bus number for RTC and DTT if not already done */ | 570 | /* define the I2C bus number for RTC and DTT if not already done */ |
571 | #if !defined(CONFIG_SYS_RTC_BUS_NUM) | 571 | #if !defined(CONFIG_SYS_RTC_BUS_NUM) |
572 | #define CONFIG_SYS_RTC_BUS_NUM 0 | 572 | #define CONFIG_SYS_RTC_BUS_NUM 0 |
573 | #endif | 573 | #endif |
574 | #if !defined(CONFIG_SYS_DTT_BUS_NUM) | 574 | #if !defined(CONFIG_SYS_DTT_BUS_NUM) |
575 | #define CONFIG_SYS_DTT_BUS_NUM 0 | 575 | #define CONFIG_SYS_DTT_BUS_NUM 0 |
576 | #endif | 576 | #endif |
577 | #if !defined(CONFIG_SYS_SPD_BUS_NUM) | 577 | #if !defined(CONFIG_SYS_SPD_BUS_NUM) |
578 | #define CONFIG_SYS_SPD_BUS_NUM 0 | 578 | #define CONFIG_SYS_SPD_BUS_NUM 0 |
579 | #endif | 579 | #endif |
580 | 580 | ||
581 | struct i2c_adapter { | 581 | struct i2c_adapter { |
582 | void (*init)(struct i2c_adapter *adap, int speed, | 582 | void (*init)(struct i2c_adapter *adap, int speed, |
583 | int slaveaddr); | 583 | int slaveaddr); |
584 | int (*probe)(struct i2c_adapter *adap, uint8_t chip); | 584 | int (*probe)(struct i2c_adapter *adap, uint8_t chip); |
585 | int (*read)(struct i2c_adapter *adap, uint8_t chip, | 585 | int (*read)(struct i2c_adapter *adap, uint8_t chip, |
586 | uint addr, int alen, uint8_t *buffer, | 586 | uint addr, int alen, uint8_t *buffer, |
587 | int len); | 587 | int len); |
588 | int (*write)(struct i2c_adapter *adap, uint8_t chip, | 588 | int (*write)(struct i2c_adapter *adap, uint8_t chip, |
589 | uint addr, int alen, uint8_t *buffer, | 589 | uint addr, int alen, uint8_t *buffer, |
590 | int len); | 590 | int len); |
591 | uint (*set_bus_speed)(struct i2c_adapter *adap, | 591 | uint (*set_bus_speed)(struct i2c_adapter *adap, |
592 | uint speed); | 592 | uint speed); |
593 | int speed; | 593 | int speed; |
594 | int waitdelay; | 594 | int waitdelay; |
595 | int slaveaddr; | 595 | int slaveaddr; |
596 | int init_done; | 596 | int init_done; |
597 | int hwadapnr; | 597 | int hwadapnr; |
598 | char *name; | 598 | char *name; |
599 | }; | 599 | }; |
600 | 600 | ||
601 | #define U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \ | 601 | #define U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \ |
602 | _set_speed, _speed, _slaveaddr, _hwadapnr, _name) \ | 602 | _set_speed, _speed, _slaveaddr, _hwadapnr, _name) \ |
603 | { \ | 603 | { \ |
604 | .init = _init, \ | 604 | .init = _init, \ |
605 | .probe = _probe, \ | 605 | .probe = _probe, \ |
606 | .read = _read, \ | 606 | .read = _read, \ |
607 | .write = _write, \ | 607 | .write = _write, \ |
608 | .set_bus_speed = _set_speed, \ | 608 | .set_bus_speed = _set_speed, \ |
609 | .speed = _speed, \ | 609 | .speed = _speed, \ |
610 | .slaveaddr = _slaveaddr, \ | 610 | .slaveaddr = _slaveaddr, \ |
611 | .init_done = 0, \ | 611 | .init_done = 0, \ |
612 | .hwadapnr = _hwadapnr, \ | 612 | .hwadapnr = _hwadapnr, \ |
613 | .name = #_name \ | 613 | .name = #_name \ |
614 | }; | 614 | }; |
615 | 615 | ||
616 | #define U_BOOT_I2C_ADAP_COMPLETE(_name, _init, _probe, _read, _write, \ | 616 | #define U_BOOT_I2C_ADAP_COMPLETE(_name, _init, _probe, _read, _write, \ |
617 | _set_speed, _speed, _slaveaddr, _hwadapnr) \ | 617 | _set_speed, _speed, _slaveaddr, _hwadapnr) \ |
618 | ll_entry_declare(struct i2c_adapter, _name, i2c) = \ | 618 | ll_entry_declare(struct i2c_adapter, _name, i2c) = \ |
619 | U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \ | 619 | U_BOOT_I2C_MKENT_COMPLETE(_init, _probe, _read, _write, \ |
620 | _set_speed, _speed, _slaveaddr, _hwadapnr, _name); | 620 | _set_speed, _speed, _slaveaddr, _hwadapnr, _name); |
621 | 621 | ||
622 | struct i2c_adapter *i2c_get_adapter(int index); | 622 | struct i2c_adapter *i2c_get_adapter(int index); |
623 | 623 | ||
624 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS | 624 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS |
625 | struct i2c_mux { | 625 | struct i2c_mux { |
626 | int id; | 626 | int id; |
627 | char name[16]; | 627 | char name[16]; |
628 | }; | 628 | }; |
629 | 629 | ||
630 | struct i2c_next_hop { | 630 | struct i2c_next_hop { |
631 | struct i2c_mux mux; | 631 | struct i2c_mux mux; |
632 | uint8_t chip; | 632 | uint8_t chip; |
633 | uint8_t channel; | 633 | uint8_t channel; |
634 | }; | 634 | }; |
635 | 635 | ||
636 | struct i2c_bus_hose { | 636 | struct i2c_bus_hose { |
637 | int adapter; | 637 | int adapter; |
638 | struct i2c_next_hop next_hop[CONFIG_SYS_I2C_MAX_HOPS]; | 638 | struct i2c_next_hop next_hop[CONFIG_SYS_I2C_MAX_HOPS]; |
639 | }; | 639 | }; |
640 | #define I2C_NULL_HOP {{-1, ""}, 0, 0} | 640 | #define I2C_NULL_HOP {{-1, ""}, 0, 0} |
641 | extern struct i2c_bus_hose i2c_bus[]; | 641 | extern struct i2c_bus_hose i2c_bus[]; |
642 | 642 | ||
643 | #define I2C_ADAPTER(bus) i2c_bus[bus].adapter | 643 | #define I2C_ADAPTER(bus) i2c_bus[bus].adapter |
644 | #else | 644 | #else |
645 | #define I2C_ADAPTER(bus) bus | 645 | #define I2C_ADAPTER(bus) bus |
646 | #endif | 646 | #endif |
647 | #define I2C_BUS gd->cur_i2c_bus | 647 | #define I2C_BUS gd->cur_i2c_bus |
648 | 648 | ||
649 | #define I2C_ADAP_NR(bus) i2c_get_adapter(I2C_ADAPTER(bus)) | 649 | #define I2C_ADAP_NR(bus) i2c_get_adapter(I2C_ADAPTER(bus)) |
650 | #define I2C_ADAP I2C_ADAP_NR(gd->cur_i2c_bus) | 650 | #define I2C_ADAP I2C_ADAP_NR(gd->cur_i2c_bus) |
651 | #define I2C_ADAP_HWNR (I2C_ADAP->hwadapnr) | 651 | #define I2C_ADAP_HWNR (I2C_ADAP->hwadapnr) |
652 | 652 | ||
653 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS | 653 | #ifndef CONFIG_SYS_I2C_DIRECT_BUS |
654 | #define I2C_MUX_PCA9540_ID 1 | 654 | #define I2C_MUX_PCA9540_ID 1 |
655 | #define I2C_MUX_PCA9540 {I2C_MUX_PCA9540_ID, "PCA9540B"} | 655 | #define I2C_MUX_PCA9540 {I2C_MUX_PCA9540_ID, "PCA9540B"} |
656 | #define I2C_MUX_PCA9542_ID 2 | 656 | #define I2C_MUX_PCA9542_ID 2 |
657 | #define I2C_MUX_PCA9542 {I2C_MUX_PCA9542_ID, "PCA9542A"} | 657 | #define I2C_MUX_PCA9542 {I2C_MUX_PCA9542_ID, "PCA9542A"} |
658 | #define I2C_MUX_PCA9544_ID 3 | 658 | #define I2C_MUX_PCA9544_ID 3 |
659 | #define I2C_MUX_PCA9544 {I2C_MUX_PCA9544_ID, "PCA9544A"} | 659 | #define I2C_MUX_PCA9544 {I2C_MUX_PCA9544_ID, "PCA9544A"} |
660 | #define I2C_MUX_PCA9546_ID 6 | ||
661 | #define I2C_MUX_PCA9546 {I2C_MUX_PCA9546_ID, "PCA9546A"} | ||
660 | #define I2C_MUX_PCA9547_ID 4 | 662 | #define I2C_MUX_PCA9547_ID 4 |
661 | #define I2C_MUX_PCA9547 {I2C_MUX_PCA9547_ID, "PCA9547A"} | 663 | #define I2C_MUX_PCA9547 {I2C_MUX_PCA9547_ID, "PCA9547A"} |
662 | #define I2C_MUX_PCA9548_ID 5 | 664 | #define I2C_MUX_PCA9548_ID 5 |
663 | #define I2C_MUX_PCA9548 {I2C_MUX_PCA9548_ID, "PCA9548"} | 665 | #define I2C_MUX_PCA9548 {I2C_MUX_PCA9548_ID, "PCA9548"} |
664 | #endif | 666 | #endif |
665 | 667 | ||
666 | #ifndef I2C_SOFT_DECLARATIONS | 668 | #ifndef I2C_SOFT_DECLARATIONS |
667 | # if defined(CONFIG_MPC8260) | 669 | # if defined(CONFIG_MPC8260) |
668 | # define I2C_SOFT_DECLARATIONS volatile ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT); | 670 | # define I2C_SOFT_DECLARATIONS volatile ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT); |
669 | # elif defined(CONFIG_8xx) | 671 | # elif defined(CONFIG_8xx) |
670 | # define I2C_SOFT_DECLARATIONS volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; | 672 | # define I2C_SOFT_DECLARATIONS volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
671 | 673 | ||
672 | # elif (defined(CONFIG_AT91RM9200) || \ | 674 | # elif (defined(CONFIG_AT91RM9200) || \ |
673 | defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9261) || \ | 675 | defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9261) || \ |
674 | defined(CONFIG_AT91SAM9263)) | 676 | defined(CONFIG_AT91SAM9263)) |
675 | # define I2C_SOFT_DECLARATIONS at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA; | 677 | # define I2C_SOFT_DECLARATIONS at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA; |
676 | # else | 678 | # else |
677 | # define I2C_SOFT_DECLARATIONS | 679 | # define I2C_SOFT_DECLARATIONS |
678 | # endif | 680 | # endif |
679 | #endif | 681 | #endif |
680 | 682 | ||
681 | #ifdef CONFIG_8xx | 683 | #ifdef CONFIG_8xx |
682 | /* Set default value for the I2C bus speed on 8xx. In the | 684 | /* Set default value for the I2C bus speed on 8xx. In the |
683 | * future, we'll define these in all 8xx board config files. | 685 | * future, we'll define these in all 8xx board config files. |
684 | */ | 686 | */ |
685 | #ifndef CONFIG_SYS_I2C_SPEED | 687 | #ifndef CONFIG_SYS_I2C_SPEED |
686 | #define CONFIG_SYS_I2C_SPEED 50000 | 688 | #define CONFIG_SYS_I2C_SPEED 50000 |
687 | #endif | 689 | #endif |
688 | #endif | 690 | #endif |
689 | 691 | ||
690 | /* | 692 | /* |
691 | * Many boards/controllers/drivers don't support an I2C slave interface so | 693 | * Many boards/controllers/drivers don't support an I2C slave interface so |
692 | * provide a default slave address for them for use in common code. A real | 694 | * provide a default slave address for them for use in common code. A real |
693 | * value for CONFIG_SYS_I2C_SLAVE should be defined for any board which does | 695 | * value for CONFIG_SYS_I2C_SLAVE should be defined for any board which does |
694 | * support a slave interface. | 696 | * support a slave interface. |
695 | */ | 697 | */ |
696 | #ifndef CONFIG_SYS_I2C_SLAVE | 698 | #ifndef CONFIG_SYS_I2C_SLAVE |
697 | #define CONFIG_SYS_I2C_SLAVE 0xfe | 699 | #define CONFIG_SYS_I2C_SLAVE 0xfe |
698 | #endif | 700 | #endif |
699 | 701 | ||
700 | /* | 702 | /* |
701 | * Initialization, must be called once on start up, may be called | 703 | * Initialization, must be called once on start up, may be called |
702 | * repeatedly to change the speed and slave addresses. | 704 | * repeatedly to change the speed and slave addresses. |
703 | */ | 705 | */ |
704 | void i2c_init(int speed, int slaveaddr); | 706 | void i2c_init(int speed, int slaveaddr); |
705 | void i2c_init_board(void); | 707 | void i2c_init_board(void); |
706 | #ifdef CONFIG_SYS_I2C_BOARD_LATE_INIT | 708 | #ifdef CONFIG_SYS_I2C_BOARD_LATE_INIT |
707 | void i2c_board_late_init(void); | 709 | void i2c_board_late_init(void); |
708 | #endif | 710 | #endif |
709 | 711 | ||
710 | #ifdef CONFIG_SYS_I2C | 712 | #ifdef CONFIG_SYS_I2C |
711 | /* | 713 | /* |
712 | * i2c_get_bus_num: | 714 | * i2c_get_bus_num: |
713 | * | 715 | * |
714 | * Returns index of currently active I2C bus. Zero-based. | 716 | * Returns index of currently active I2C bus. Zero-based. |
715 | */ | 717 | */ |
716 | unsigned int i2c_get_bus_num(void); | 718 | unsigned int i2c_get_bus_num(void); |
717 | 719 | ||
718 | /* | 720 | /* |
719 | * i2c_set_bus_num: | 721 | * i2c_set_bus_num: |
720 | * | 722 | * |
721 | * Change the active I2C bus. Subsequent read/write calls will | 723 | * Change the active I2C bus. Subsequent read/write calls will |
722 | * go to this one. | 724 | * go to this one. |
723 | * | 725 | * |
724 | * bus - bus index, zero based | 726 | * bus - bus index, zero based |
725 | * | 727 | * |
726 | * Returns: 0 on success, not 0 on failure | 728 | * Returns: 0 on success, not 0 on failure |
727 | * | 729 | * |
728 | */ | 730 | */ |
729 | int i2c_set_bus_num(unsigned int bus); | 731 | int i2c_set_bus_num(unsigned int bus); |
730 | 732 | ||
731 | /* | 733 | /* |
732 | * i2c_init_all(): | 734 | * i2c_init_all(): |
733 | * | 735 | * |
734 | * Initializes all I2C adapters in the system. All i2c_adap structures must | 736 | * Initializes all I2C adapters in the system. All i2c_adap structures must |
735 | * be initialized beforehead with function pointers and data, including | 737 | * be initialized beforehead with function pointers and data, including |
736 | * speed and slaveaddr. Returns 0 on success, non-0 on failure. | 738 | * speed and slaveaddr. Returns 0 on success, non-0 on failure. |
737 | */ | 739 | */ |
738 | void i2c_init_all(void); | 740 | void i2c_init_all(void); |
739 | 741 | ||
740 | /* | 742 | /* |
741 | * Probe the given I2C chip address. Returns 0 if a chip responded, | 743 | * Probe the given I2C chip address. Returns 0 if a chip responded, |
742 | * not 0 on failure. | 744 | * not 0 on failure. |
743 | */ | 745 | */ |
744 | int i2c_probe(uint8_t chip); | 746 | int i2c_probe(uint8_t chip); |
745 | 747 | ||
746 | /* | 748 | /* |
747 | * Read/Write interface: | 749 | * Read/Write interface: |
748 | * chip: I2C chip address, range 0..127 | 750 | * chip: I2C chip address, range 0..127 |
749 | * addr: Memory (register) address within the chip | 751 | * addr: Memory (register) address within the chip |
750 | * alen: Number of bytes to use for addr (typically 1, 2 for larger | 752 | * alen: Number of bytes to use for addr (typically 1, 2 for larger |
751 | * memories, 0 for register type devices with only one | 753 | * memories, 0 for register type devices with only one |
752 | * register) | 754 | * register) |
753 | * buffer: Where to read/write the data | 755 | * buffer: Where to read/write the data |
754 | * len: How many bytes to read/write | 756 | * len: How many bytes to read/write |
755 | * | 757 | * |
756 | * Returns: 0 on success, not 0 on failure | 758 | * Returns: 0 on success, not 0 on failure |
757 | */ | 759 | */ |
758 | int i2c_read(uint8_t chip, unsigned int addr, int alen, | 760 | int i2c_read(uint8_t chip, unsigned int addr, int alen, |
759 | uint8_t *buffer, int len); | 761 | uint8_t *buffer, int len); |
760 | 762 | ||
761 | int i2c_write(uint8_t chip, unsigned int addr, int alen, | 763 | int i2c_write(uint8_t chip, unsigned int addr, int alen, |
762 | uint8_t *buffer, int len); | 764 | uint8_t *buffer, int len); |
763 | 765 | ||
764 | /* | 766 | /* |
765 | * Utility routines to read/write registers. | 767 | * Utility routines to read/write registers. |
766 | */ | 768 | */ |
767 | uint8_t i2c_reg_read(uint8_t addr, uint8_t reg); | 769 | uint8_t i2c_reg_read(uint8_t addr, uint8_t reg); |
768 | 770 | ||
769 | void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val); | 771 | void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val); |
770 | 772 | ||
771 | /* | 773 | /* |
772 | * i2c_set_bus_speed: | 774 | * i2c_set_bus_speed: |
773 | * | 775 | * |
774 | * Change the speed of the active I2C bus | 776 | * Change the speed of the active I2C bus |
775 | * | 777 | * |
776 | * speed - bus speed in Hz | 778 | * speed - bus speed in Hz |
777 | * | 779 | * |
778 | * Returns: new bus speed | 780 | * Returns: new bus speed |
779 | * | 781 | * |
780 | */ | 782 | */ |
781 | unsigned int i2c_set_bus_speed(unsigned int speed); | 783 | unsigned int i2c_set_bus_speed(unsigned int speed); |
782 | 784 | ||
783 | /* | 785 | /* |
784 | * i2c_get_bus_speed: | 786 | * i2c_get_bus_speed: |
785 | * | 787 | * |
786 | * Returns speed of currently active I2C bus in Hz | 788 | * Returns speed of currently active I2C bus in Hz |
787 | */ | 789 | */ |
788 | 790 | ||
789 | unsigned int i2c_get_bus_speed(void); | 791 | unsigned int i2c_get_bus_speed(void); |
790 | 792 | ||
791 | /* | 793 | /* |
792 | * i2c_reloc_fixup: | 794 | * i2c_reloc_fixup: |
793 | * | 795 | * |
794 | * Adjusts I2C pointers after U-Boot is relocated to DRAM | 796 | * Adjusts I2C pointers after U-Boot is relocated to DRAM |
795 | */ | 797 | */ |
796 | void i2c_reloc_fixup(void); | 798 | void i2c_reloc_fixup(void); |
797 | #if defined(CONFIG_SYS_I2C_SOFT) | 799 | #if defined(CONFIG_SYS_I2C_SOFT) |
798 | void i2c_soft_init(void); | 800 | void i2c_soft_init(void); |
799 | void i2c_soft_active(void); | 801 | void i2c_soft_active(void); |
800 | void i2c_soft_tristate(void); | 802 | void i2c_soft_tristate(void); |
801 | int i2c_soft_read(void); | 803 | int i2c_soft_read(void); |
802 | void i2c_soft_sda(int bit); | 804 | void i2c_soft_sda(int bit); |
803 | void i2c_soft_scl(int bit); | 805 | void i2c_soft_scl(int bit); |
804 | void i2c_soft_delay(void); | 806 | void i2c_soft_delay(void); |
805 | #endif | 807 | #endif |
806 | #else | 808 | #else |
807 | 809 | ||
808 | /* | 810 | /* |
809 | * Probe the given I2C chip address. Returns 0 if a chip responded, | 811 | * Probe the given I2C chip address. Returns 0 if a chip responded, |
810 | * not 0 on failure. | 812 | * not 0 on failure. |
811 | */ | 813 | */ |
812 | int i2c_probe(uchar chip); | 814 | int i2c_probe(uchar chip); |
813 | 815 | ||
814 | /* | 816 | /* |
815 | * Read/Write interface: | 817 | * Read/Write interface: |
816 | * chip: I2C chip address, range 0..127 | 818 | * chip: I2C chip address, range 0..127 |
817 | * addr: Memory (register) address within the chip | 819 | * addr: Memory (register) address within the chip |
818 | * alen: Number of bytes to use for addr (typically 1, 2 for larger | 820 | * alen: Number of bytes to use for addr (typically 1, 2 for larger |
819 | * memories, 0 for register type devices with only one | 821 | * memories, 0 for register type devices with only one |
820 | * register) | 822 | * register) |
821 | * buffer: Where to read/write the data | 823 | * buffer: Where to read/write the data |
822 | * len: How many bytes to read/write | 824 | * len: How many bytes to read/write |
823 | * | 825 | * |
824 | * Returns: 0 on success, not 0 on failure | 826 | * Returns: 0 on success, not 0 on failure |
825 | */ | 827 | */ |
826 | int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len); | 828 | int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len); |
827 | int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len); | 829 | int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len); |
828 | 830 | ||
829 | /* | 831 | /* |
830 | * Utility routines to read/write registers. | 832 | * Utility routines to read/write registers. |
831 | */ | 833 | */ |
832 | static inline u8 i2c_reg_read(u8 addr, u8 reg) | 834 | static inline u8 i2c_reg_read(u8 addr, u8 reg) |
833 | { | 835 | { |
834 | u8 buf; | 836 | u8 buf; |
835 | 837 | ||
836 | #ifdef CONFIG_8xx | 838 | #ifdef CONFIG_8xx |
837 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ | 839 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ |
838 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); | 840 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
839 | #endif | 841 | #endif |
840 | 842 | ||
841 | #ifdef DEBUG | 843 | #ifdef DEBUG |
842 | printf("%s: addr=0x%02x, reg=0x%02x\n", __func__, addr, reg); | 844 | printf("%s: addr=0x%02x, reg=0x%02x\n", __func__, addr, reg); |
843 | #endif | 845 | #endif |
844 | 846 | ||
845 | i2c_read(addr, reg, 1, &buf, 1); | 847 | i2c_read(addr, reg, 1, &buf, 1); |
846 | 848 | ||
847 | return buf; | 849 | return buf; |
848 | } | 850 | } |
849 | 851 | ||
850 | static inline void i2c_reg_write(u8 addr, u8 reg, u8 val) | 852 | static inline void i2c_reg_write(u8 addr, u8 reg, u8 val) |
851 | { | 853 | { |
852 | #ifdef CONFIG_8xx | 854 | #ifdef CONFIG_8xx |
853 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ | 855 | /* MPC8xx needs this. Maybe one day we can get rid of it. */ |
854 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); | 856 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
855 | #endif | 857 | #endif |
856 | 858 | ||
857 | #ifdef DEBUG | 859 | #ifdef DEBUG |
858 | printf("%s: addr=0x%02x, reg=0x%02x, val=0x%02x\n", | 860 | printf("%s: addr=0x%02x, reg=0x%02x, val=0x%02x\n", |
859 | __func__, addr, reg, val); | 861 | __func__, addr, reg, val); |
860 | #endif | 862 | #endif |
861 | 863 | ||
862 | i2c_write(addr, reg, 1, &val, 1); | 864 | i2c_write(addr, reg, 1, &val, 1); |
863 | } | 865 | } |
864 | 866 | ||
865 | /* | 867 | /* |
866 | * Functions for setting the current I2C bus and its speed | 868 | * Functions for setting the current I2C bus and its speed |
867 | */ | 869 | */ |
868 | 870 | ||
869 | /* | 871 | /* |
870 | * i2c_set_bus_num: | 872 | * i2c_set_bus_num: |
871 | * | 873 | * |
872 | * Change the active I2C bus. Subsequent read/write calls will | 874 | * Change the active I2C bus. Subsequent read/write calls will |
873 | * go to this one. | 875 | * go to this one. |
874 | * | 876 | * |
875 | * bus - bus index, zero based | 877 | * bus - bus index, zero based |
876 | * | 878 | * |
877 | * Returns: 0 on success, not 0 on failure | 879 | * Returns: 0 on success, not 0 on failure |
878 | * | 880 | * |
879 | */ | 881 | */ |
880 | int i2c_set_bus_num(unsigned int bus); | 882 | int i2c_set_bus_num(unsigned int bus); |
881 | 883 | ||
882 | /* | 884 | /* |
883 | * i2c_get_bus_num: | 885 | * i2c_get_bus_num: |
884 | * | 886 | * |
885 | * Returns index of currently active I2C bus. Zero-based. | 887 | * Returns index of currently active I2C bus. Zero-based. |
886 | */ | 888 | */ |
887 | 889 | ||
888 | unsigned int i2c_get_bus_num(void); | 890 | unsigned int i2c_get_bus_num(void); |
889 | 891 | ||
890 | /* | 892 | /* |
891 | * i2c_set_bus_speed: | 893 | * i2c_set_bus_speed: |
892 | * | 894 | * |
893 | * Change the speed of the active I2C bus | 895 | * Change the speed of the active I2C bus |
894 | * | 896 | * |
895 | * speed - bus speed in Hz | 897 | * speed - bus speed in Hz |
896 | * | 898 | * |
897 | * Returns: 0 on success, not 0 on failure | 899 | * Returns: 0 on success, not 0 on failure |
898 | * | 900 | * |
899 | */ | 901 | */ |
900 | int i2c_set_bus_speed(unsigned int); | 902 | int i2c_set_bus_speed(unsigned int); |
901 | 903 | ||
902 | /* | 904 | /* |
903 | * i2c_get_bus_speed: | 905 | * i2c_get_bus_speed: |
904 | * | 906 | * |
905 | * Returns speed of currently active I2C bus in Hz | 907 | * Returns speed of currently active I2C bus in Hz |
906 | */ | 908 | */ |
907 | 909 | ||
908 | unsigned int i2c_get_bus_speed(void); | 910 | unsigned int i2c_get_bus_speed(void); |
909 | #endif /* CONFIG_SYS_I2C */ | 911 | #endif /* CONFIG_SYS_I2C */ |
910 | 912 | ||
911 | /* | 913 | /* |
912 | * only for backwardcompatibility, should go away if we switched | 914 | * only for backwardcompatibility, should go away if we switched |
913 | * completely to new multibus support. | 915 | * completely to new multibus support. |
914 | */ | 916 | */ |
915 | #if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS) | 917 | #if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS) |
916 | # if !defined(CONFIG_SYS_MAX_I2C_BUS) | 918 | # if !defined(CONFIG_SYS_MAX_I2C_BUS) |
917 | # define CONFIG_SYS_MAX_I2C_BUS 2 | 919 | # define CONFIG_SYS_MAX_I2C_BUS 2 |
918 | # endif | 920 | # endif |
919 | # define I2C_MULTI_BUS 1 | 921 | # define I2C_MULTI_BUS 1 |
920 | #else | 922 | #else |
921 | # define CONFIG_SYS_MAX_I2C_BUS 1 | 923 | # define CONFIG_SYS_MAX_I2C_BUS 1 |
922 | # define I2C_MULTI_BUS 0 | 924 | # define I2C_MULTI_BUS 0 |
923 | #endif | 925 | #endif |
924 | 926 | ||
925 | /* NOTE: These two functions MUST be always_inline to avoid code growth! */ | 927 | /* NOTE: These two functions MUST be always_inline to avoid code growth! */ |
926 | static inline unsigned int I2C_GET_BUS(void) __attribute__((always_inline)); | 928 | static inline unsigned int I2C_GET_BUS(void) __attribute__((always_inline)); |
927 | static inline unsigned int I2C_GET_BUS(void) | 929 | static inline unsigned int I2C_GET_BUS(void) |
928 | { | 930 | { |
929 | return I2C_MULTI_BUS ? i2c_get_bus_num() : 0; | 931 | return I2C_MULTI_BUS ? i2c_get_bus_num() : 0; |
930 | } | 932 | } |
931 | 933 | ||
932 | static inline void I2C_SET_BUS(unsigned int bus) __attribute__((always_inline)); | 934 | static inline void I2C_SET_BUS(unsigned int bus) __attribute__((always_inline)); |
933 | static inline void I2C_SET_BUS(unsigned int bus) | 935 | static inline void I2C_SET_BUS(unsigned int bus) |
934 | { | 936 | { |
935 | if (I2C_MULTI_BUS) | 937 | if (I2C_MULTI_BUS) |
936 | i2c_set_bus_num(bus); | 938 | i2c_set_bus_num(bus); |
937 | } | 939 | } |
938 | 940 | ||
939 | /* Multi I2C definitions */ | 941 | /* Multi I2C definitions */ |
940 | enum { | 942 | enum { |
941 | I2C_0, I2C_1, I2C_2, I2C_3, I2C_4, I2C_5, I2C_6, I2C_7, | 943 | I2C_0, I2C_1, I2C_2, I2C_3, I2C_4, I2C_5, I2C_6, I2C_7, |
942 | I2C_8, I2C_9, I2C_10, | 944 | I2C_8, I2C_9, I2C_10, |
943 | }; | 945 | }; |
944 | 946 | ||
945 | /* Multi I2C busses handling */ | 947 | /* Multi I2C busses handling */ |
946 | #ifdef CONFIG_SOFT_I2C_MULTI_BUS | 948 | #ifdef CONFIG_SOFT_I2C_MULTI_BUS |
947 | extern int get_multi_scl_pin(void); | 949 | extern int get_multi_scl_pin(void); |
948 | extern int get_multi_sda_pin(void); | 950 | extern int get_multi_sda_pin(void); |
949 | extern int multi_i2c_init(void); | 951 | extern int multi_i2c_init(void); |
950 | #endif | 952 | #endif |
951 | 953 | ||
952 | /** | 954 | /** |
953 | * Get FDT values for i2c bus. | 955 | * Get FDT values for i2c bus. |
954 | * | 956 | * |
955 | * @param blob Device tree blbo | 957 | * @param blob Device tree blbo |
956 | * @return the number of I2C bus | 958 | * @return the number of I2C bus |
957 | */ | 959 | */ |
958 | void board_i2c_init(const void *blob); | 960 | void board_i2c_init(const void *blob); |
959 | 961 | ||
960 | /** | 962 | /** |
961 | * Find the I2C bus number by given a FDT I2C node. | 963 | * Find the I2C bus number by given a FDT I2C node. |
962 | * | 964 | * |
963 | * @param blob Device tree blbo | 965 | * @param blob Device tree blbo |
964 | * @param node FDT I2C node to find | 966 | * @param node FDT I2C node to find |
965 | * @return the number of I2C bus (zero based), or -1 on error | 967 | * @return the number of I2C bus (zero based), or -1 on error |
966 | */ | 968 | */ |
967 | int i2c_get_bus_num_fdt(int node); | 969 | int i2c_get_bus_num_fdt(int node); |
968 | 970 | ||
969 | /** | 971 | /** |
970 | * Reset the I2C bus represented by the given a FDT I2C node. | 972 | * Reset the I2C bus represented by the given a FDT I2C node. |
971 | * | 973 | * |
972 | * @param blob Device tree blbo | 974 | * @param blob Device tree blbo |
973 | * @param node FDT I2C node to find | 975 | * @param node FDT I2C node to find |
974 | * @return 0 if port was reset, -1 if not found | 976 | * @return 0 if port was reset, -1 if not found |
975 | */ | 977 | */ |
976 | int i2c_reset_port_fdt(const void *blob, int node); | 978 | int i2c_reset_port_fdt(const void *blob, int node); |
977 | 979 | ||
978 | #endif /* !CONFIG_DM_I2C */ | 980 | #endif /* !CONFIG_DM_I2C */ |
979 | 981 | ||
980 | #endif /* _I2C_H_ */ | 982 | #endif /* _I2C_H_ */ |
981 | 983 |