1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2983e3700STom Rini /*
3983e3700STom Rini *
4983e3700STom Rini * Functions for omap5 based boards.
5983e3700STom Rini *
6983e3700STom Rini * (C) Copyright 2011
7983e3700STom Rini * Texas Instruments, <www.ti.com>
8983e3700STom Rini *
9983e3700STom Rini * Author :
10983e3700STom Rini * Aneesh V <aneesh@ti.com>
11983e3700STom Rini * Steve Sakoman <steve@sakoman.com>
12983e3700STom Rini * Sricharan <r.sricharan@ti.com>
13983e3700STom Rini */
14983e3700STom Rini #include <common.h>
15b4b06006SLokesh Vutla #include <palmas.h>
16983e3700STom Rini #include <asm/armv7.h>
17983e3700STom Rini #include <asm/arch/cpu.h>
18983e3700STom Rini #include <asm/arch/sys_proto.h>
19983e3700STom Rini #include <asm/arch/clock.h>
20983e3700STom Rini #include <linux/sizes.h>
21983e3700STom Rini #include <asm/utils.h>
22983e3700STom Rini #include <asm/arch/gpio.h>
23983e3700STom Rini #include <asm/emif.h>
24983e3700STom Rini #include <asm/omap_common.h>
25983e3700STom Rini
26983e3700STom Rini u32 *const omap_si_rev = (u32 *)OMAP_SRAM_SCRATCH_OMAP_REV;
27983e3700STom Rini
28983e3700STom Rini #ifndef CONFIG_DM_GPIO
29983e3700STom Rini static struct gpio_bank gpio_bank_54xx[8] = {
30983e3700STom Rini { (void *)OMAP54XX_GPIO1_BASE },
31983e3700STom Rini { (void *)OMAP54XX_GPIO2_BASE },
32983e3700STom Rini { (void *)OMAP54XX_GPIO3_BASE },
33983e3700STom Rini { (void *)OMAP54XX_GPIO4_BASE },
34983e3700STom Rini { (void *)OMAP54XX_GPIO5_BASE },
35983e3700STom Rini { (void *)OMAP54XX_GPIO6_BASE },
36983e3700STom Rini { (void *)OMAP54XX_GPIO7_BASE },
37983e3700STom Rini { (void *)OMAP54XX_GPIO8_BASE },
38983e3700STom Rini };
39983e3700STom Rini
40983e3700STom Rini const struct gpio_bank *const omap_gpio_bank = gpio_bank_54xx;
41983e3700STom Rini #endif
42983e3700STom Rini
do_set_mux32(u32 base,struct pad_conf_entry const * array,int size)43983e3700STom Rini void do_set_mux32(u32 base, struct pad_conf_entry const *array, int size)
44983e3700STom Rini {
45983e3700STom Rini int i;
46983e3700STom Rini struct pad_conf_entry *pad = (struct pad_conf_entry *)array;
47983e3700STom Rini
48983e3700STom Rini for (i = 0; i < size; i++, pad++)
49983e3700STom Rini writel(pad->val, base + pad->offset);
50983e3700STom Rini }
51983e3700STom Rini
52983e3700STom Rini #ifdef CONFIG_SPL_BUILD
53983e3700STom Rini /* LPDDR2 specific IO settings */
io_settings_lpddr2(void)54983e3700STom Rini static void io_settings_lpddr2(void)
55983e3700STom Rini {
56983e3700STom Rini const struct ctrl_ioregs *ioregs;
57983e3700STom Rini
58983e3700STom Rini get_ioregs(&ioregs);
59983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_0);
60983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_1);
61983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_0);
62983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_1);
63983e3700STom Rini writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_0);
64983e3700STom Rini writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_1);
65983e3700STom Rini writel(ioregs->ctrl_ddrio_0, (*ctrl)->control_ddrio_0);
66983e3700STom Rini writel(ioregs->ctrl_ddrio_1, (*ctrl)->control_ddrio_1);
67983e3700STom Rini writel(ioregs->ctrl_ddrio_2, (*ctrl)->control_ddrio_2);
68983e3700STom Rini }
69983e3700STom Rini
70983e3700STom Rini /* DDR3 specific IO settings */
io_settings_ddr3(void)71983e3700STom Rini static void io_settings_ddr3(void)
72983e3700STom Rini {
73983e3700STom Rini u32 io_settings = 0;
74983e3700STom Rini const struct ctrl_ioregs *ioregs;
75983e3700STom Rini
76983e3700STom Rini get_ioregs(&ioregs);
77983e3700STom Rini writel(ioregs->ctrl_ddr3ch, (*ctrl)->control_ddr3ch1_0);
78983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_0);
79983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch1_1);
80983e3700STom Rini
81983e3700STom Rini writel(ioregs->ctrl_ddr3ch, (*ctrl)->control_ddr3ch2_0);
82983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_0);
83983e3700STom Rini writel(ioregs->ctrl_ddrch, (*ctrl)->control_ddrch2_1);
84983e3700STom Rini
85983e3700STom Rini writel(ioregs->ctrl_ddrio_0, (*ctrl)->control_ddrio_0);
86983e3700STom Rini writel(ioregs->ctrl_ddrio_1, (*ctrl)->control_ddrio_1);
87983e3700STom Rini
88983e3700STom Rini if (!is_dra7xx()) {
89983e3700STom Rini writel(ioregs->ctrl_ddrio_2, (*ctrl)->control_ddrio_2);
90983e3700STom Rini writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_1);
91983e3700STom Rini }
92983e3700STom Rini
93983e3700STom Rini /* omap5432 does not use lpddr2 */
94983e3700STom Rini writel(ioregs->ctrl_lpddr2ch, (*ctrl)->control_lpddr2ch1_0);
95983e3700STom Rini
96983e3700STom Rini writel(ioregs->ctrl_emif_sdram_config_ext,
97983e3700STom Rini (*ctrl)->control_emif1_sdram_config_ext);
98983e3700STom Rini if (!is_dra72x())
99983e3700STom Rini writel(ioregs->ctrl_emif_sdram_config_ext,
100983e3700STom Rini (*ctrl)->control_emif2_sdram_config_ext);
101983e3700STom Rini
102983e3700STom Rini if (is_omap54xx()) {
103983e3700STom Rini /* Disable DLL select */
104983e3700STom Rini io_settings = (readl((*ctrl)->control_port_emif1_sdram_config)
105983e3700STom Rini & 0xFFEFFFFF);
106983e3700STom Rini writel(io_settings,
107983e3700STom Rini (*ctrl)->control_port_emif1_sdram_config);
108983e3700STom Rini
109983e3700STom Rini io_settings = (readl((*ctrl)->control_port_emif2_sdram_config)
110983e3700STom Rini & 0xFFEFFFFF);
111983e3700STom Rini writel(io_settings,
112983e3700STom Rini (*ctrl)->control_port_emif2_sdram_config);
113983e3700STom Rini } else {
114983e3700STom Rini writel(ioregs->ctrl_ddr_ctrl_ext_0,
115983e3700STom Rini (*ctrl)->control_ddr_control_ext_0);
116983e3700STom Rini }
117983e3700STom Rini }
118983e3700STom Rini
119983e3700STom Rini /*
120983e3700STom Rini * Some tuning of IOs for optimal power and performance
121983e3700STom Rini */
do_io_settings(void)122983e3700STom Rini void do_io_settings(void)
123983e3700STom Rini {
124983e3700STom Rini u32 io_settings = 0, mask = 0;
125983e3700STom Rini struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
126983e3700STom Rini
127983e3700STom Rini /* Impedance settings EMMC, C2C 1,2, hsi2 */
128983e3700STom Rini mask = (ds_mask << 2) | (ds_mask << 8) |
129983e3700STom Rini (ds_mask << 16) | (ds_mask << 18);
130983e3700STom Rini io_settings = readl((*ctrl)->control_smart1io_padconf_0) &
131983e3700STom Rini (~mask);
132983e3700STom Rini io_settings |= (ds_60_ohm << 8) | (ds_45_ohm << 16) |
133983e3700STom Rini (ds_45_ohm << 18) | (ds_60_ohm << 2);
134983e3700STom Rini writel(io_settings, (*ctrl)->control_smart1io_padconf_0);
135983e3700STom Rini
136983e3700STom Rini /* Impedance settings Mcspi2 */
137983e3700STom Rini mask = (ds_mask << 30);
138983e3700STom Rini io_settings = readl((*ctrl)->control_smart1io_padconf_1) &
139983e3700STom Rini (~mask);
140983e3700STom Rini io_settings |= (ds_60_ohm << 30);
141983e3700STom Rini writel(io_settings, (*ctrl)->control_smart1io_padconf_1);
142983e3700STom Rini
143983e3700STom Rini /* Impedance settings C2C 3,4 */
144983e3700STom Rini mask = (ds_mask << 14) | (ds_mask << 16);
145983e3700STom Rini io_settings = readl((*ctrl)->control_smart1io_padconf_2) &
146983e3700STom Rini (~mask);
147983e3700STom Rini io_settings |= (ds_45_ohm << 14) | (ds_45_ohm << 16);
148983e3700STom Rini writel(io_settings, (*ctrl)->control_smart1io_padconf_2);
149983e3700STom Rini
150983e3700STom Rini /* Slew rate settings EMMC, C2C 1,2 */
151983e3700STom Rini mask = (sc_mask << 8) | (sc_mask << 16) | (sc_mask << 18);
152983e3700STom Rini io_settings = readl((*ctrl)->control_smart2io_padconf_0) &
153983e3700STom Rini (~mask);
154983e3700STom Rini io_settings |= (sc_fast << 8) | (sc_na << 16) | (sc_na << 18);
155983e3700STom Rini writel(io_settings, (*ctrl)->control_smart2io_padconf_0);
156983e3700STom Rini
157983e3700STom Rini /* Slew rate settings hsi2, Mcspi2 */
158983e3700STom Rini mask = (sc_mask << 24) | (sc_mask << 28);
159983e3700STom Rini io_settings = readl((*ctrl)->control_smart2io_padconf_1) &
160983e3700STom Rini (~mask);
161983e3700STom Rini io_settings |= (sc_fast << 28) | (sc_fast << 24);
162983e3700STom Rini writel(io_settings, (*ctrl)->control_smart2io_padconf_1);
163983e3700STom Rini
164983e3700STom Rini /* Slew rate settings C2C 3,4 */
165983e3700STom Rini mask = (sc_mask << 16) | (sc_mask << 18);
166983e3700STom Rini io_settings = readl((*ctrl)->control_smart2io_padconf_2) &
167983e3700STom Rini (~mask);
168983e3700STom Rini io_settings |= (sc_na << 16) | (sc_na << 18);
169983e3700STom Rini writel(io_settings, (*ctrl)->control_smart2io_padconf_2);
170983e3700STom Rini
171983e3700STom Rini /* impedance and slew rate settings for usb */
172983e3700STom Rini mask = (usb_i_mask << 29) | (usb_i_mask << 26) | (usb_i_mask << 23) |
173983e3700STom Rini (usb_i_mask << 20) | (usb_i_mask << 17) | (usb_i_mask << 14);
174983e3700STom Rini io_settings = readl((*ctrl)->control_smart3io_padconf_1) &
175983e3700STom Rini (~mask);
176983e3700STom Rini io_settings |= (ds_60_ohm << 29) | (ds_60_ohm << 26) |
177983e3700STom Rini (ds_60_ohm << 23) | (sc_fast << 20) |
178983e3700STom Rini (sc_fast << 17) | (sc_fast << 14);
179983e3700STom Rini writel(io_settings, (*ctrl)->control_smart3io_padconf_1);
180983e3700STom Rini
181983e3700STom Rini if (emif_sdram_type(emif->emif_sdram_config) == EMIF_SDRAM_TYPE_LPDDR2)
182983e3700STom Rini io_settings_lpddr2();
183983e3700STom Rini else
184983e3700STom Rini io_settings_ddr3();
185983e3700STom Rini }
186983e3700STom Rini
187983e3700STom Rini static const struct srcomp_params srcomp_parameters[NUM_SYS_CLKS] = {
188983e3700STom Rini {0x45, 0x1}, /* 12 MHz */
189983e3700STom Rini {-1, -1}, /* 13 MHz */
190983e3700STom Rini {0x63, 0x2}, /* 16.8 MHz */
191983e3700STom Rini {0x57, 0x2}, /* 19.2 MHz */
192983e3700STom Rini {0x20, 0x1}, /* 26 MHz */
193983e3700STom Rini {-1, -1}, /* 27 MHz */
194983e3700STom Rini {0x41, 0x3} /* 38.4 MHz */
195983e3700STom Rini };
196983e3700STom Rini
srcomp_enable(void)197983e3700STom Rini void srcomp_enable(void)
198983e3700STom Rini {
199983e3700STom Rini u32 srcomp_value, mul_factor, div_factor, clk_val, i;
200983e3700STom Rini u32 sysclk_ind = get_sys_clk_index();
201983e3700STom Rini u32 omap_rev = omap_revision();
202983e3700STom Rini
203983e3700STom Rini if (!is_omap54xx())
204983e3700STom Rini return;
205983e3700STom Rini
206983e3700STom Rini mul_factor = srcomp_parameters[sysclk_ind].multiply_factor;
207983e3700STom Rini div_factor = srcomp_parameters[sysclk_ind].divide_factor;
208983e3700STom Rini
209983e3700STom Rini for (i = 0; i < 4; i++) {
210983e3700STom Rini srcomp_value = readl((*ctrl)->control_srcomp_north_side + i*4);
211983e3700STom Rini srcomp_value &=
212983e3700STom Rini ~(MULTIPLY_FACTOR_XS_MASK | DIVIDE_FACTOR_XS_MASK);
213983e3700STom Rini srcomp_value |= (mul_factor << MULTIPLY_FACTOR_XS_SHIFT) |
214983e3700STom Rini (div_factor << DIVIDE_FACTOR_XS_SHIFT);
215983e3700STom Rini writel(srcomp_value, (*ctrl)->control_srcomp_north_side + i*4);
216983e3700STom Rini }
217983e3700STom Rini
218983e3700STom Rini if ((omap_rev == OMAP5430_ES1_0) || (omap_rev == OMAP5432_ES1_0)) {
219983e3700STom Rini clk_val = readl((*prcm)->cm_coreaon_io_srcomp_clkctrl);
220983e3700STom Rini clk_val |= OPTFCLKEN_SRCOMP_FCLK_MASK;
221983e3700STom Rini writel(clk_val, (*prcm)->cm_coreaon_io_srcomp_clkctrl);
222983e3700STom Rini
223983e3700STom Rini for (i = 0; i < 4; i++) {
224983e3700STom Rini srcomp_value =
225983e3700STom Rini readl((*ctrl)->control_srcomp_north_side + i*4);
226983e3700STom Rini srcomp_value &= ~PWRDWN_XS_MASK;
227983e3700STom Rini writel(srcomp_value,
228983e3700STom Rini (*ctrl)->control_srcomp_north_side + i*4);
229983e3700STom Rini
230983e3700STom Rini while (((readl((*ctrl)->control_srcomp_north_side + i*4)
231983e3700STom Rini & SRCODE_READ_XS_MASK) >>
232983e3700STom Rini SRCODE_READ_XS_SHIFT) == 0)
233983e3700STom Rini ;
234983e3700STom Rini
235983e3700STom Rini srcomp_value =
236983e3700STom Rini readl((*ctrl)->control_srcomp_north_side + i*4);
237983e3700STom Rini srcomp_value &= ~OVERRIDE_XS_MASK;
238983e3700STom Rini writel(srcomp_value,
239983e3700STom Rini (*ctrl)->control_srcomp_north_side + i*4);
240983e3700STom Rini }
241983e3700STom Rini } else {
242983e3700STom Rini srcomp_value = readl((*ctrl)->control_srcomp_east_side_wkup);
243983e3700STom Rini srcomp_value &= ~(MULTIPLY_FACTOR_XS_MASK |
244983e3700STom Rini DIVIDE_FACTOR_XS_MASK);
245983e3700STom Rini srcomp_value |= (mul_factor << MULTIPLY_FACTOR_XS_SHIFT) |
246983e3700STom Rini (div_factor << DIVIDE_FACTOR_XS_SHIFT);
247983e3700STom Rini writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup);
248983e3700STom Rini
249983e3700STom Rini for (i = 0; i < 4; i++) {
250983e3700STom Rini srcomp_value =
251983e3700STom Rini readl((*ctrl)->control_srcomp_north_side + i*4);
252983e3700STom Rini srcomp_value |= SRCODE_OVERRIDE_SEL_XS_MASK;
253983e3700STom Rini writel(srcomp_value,
254983e3700STom Rini (*ctrl)->control_srcomp_north_side + i*4);
255983e3700STom Rini
256983e3700STom Rini srcomp_value =
257983e3700STom Rini readl((*ctrl)->control_srcomp_north_side + i*4);
258983e3700STom Rini srcomp_value &= ~OVERRIDE_XS_MASK;
259983e3700STom Rini writel(srcomp_value,
260983e3700STom Rini (*ctrl)->control_srcomp_north_side + i*4);
261983e3700STom Rini }
262983e3700STom Rini
263983e3700STom Rini srcomp_value =
264983e3700STom Rini readl((*ctrl)->control_srcomp_east_side_wkup);
265983e3700STom Rini srcomp_value |= SRCODE_OVERRIDE_SEL_XS_MASK;
266983e3700STom Rini writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup);
267983e3700STom Rini
268983e3700STom Rini srcomp_value =
269983e3700STom Rini readl((*ctrl)->control_srcomp_east_side_wkup);
270983e3700STom Rini srcomp_value &= ~OVERRIDE_XS_MASK;
271983e3700STom Rini writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup);
272983e3700STom Rini
273983e3700STom Rini clk_val = readl((*prcm)->cm_coreaon_io_srcomp_clkctrl);
274983e3700STom Rini clk_val |= OPTFCLKEN_SRCOMP_FCLK_MASK;
275983e3700STom Rini writel(clk_val, (*prcm)->cm_coreaon_io_srcomp_clkctrl);
276983e3700STom Rini
277983e3700STom Rini clk_val = readl((*prcm)->cm_wkupaon_io_srcomp_clkctrl);
278983e3700STom Rini clk_val |= OPTFCLKEN_SRCOMP_FCLK_MASK;
279983e3700STom Rini writel(clk_val, (*prcm)->cm_wkupaon_io_srcomp_clkctrl);
280983e3700STom Rini
281983e3700STom Rini for (i = 0; i < 4; i++) {
282983e3700STom Rini while (((readl((*ctrl)->control_srcomp_north_side + i*4)
283983e3700STom Rini & SRCODE_READ_XS_MASK) >>
284983e3700STom Rini SRCODE_READ_XS_SHIFT) == 0)
285983e3700STom Rini ;
286983e3700STom Rini
287983e3700STom Rini srcomp_value =
288983e3700STom Rini readl((*ctrl)->control_srcomp_north_side + i*4);
289983e3700STom Rini srcomp_value &= ~SRCODE_OVERRIDE_SEL_XS_MASK;
290983e3700STom Rini writel(srcomp_value,
291983e3700STom Rini (*ctrl)->control_srcomp_north_side + i*4);
292983e3700STom Rini }
293983e3700STom Rini
294983e3700STom Rini while (((readl((*ctrl)->control_srcomp_east_side_wkup) &
295983e3700STom Rini SRCODE_READ_XS_MASK) >> SRCODE_READ_XS_SHIFT) == 0)
296983e3700STom Rini ;
297983e3700STom Rini
298983e3700STom Rini srcomp_value =
299983e3700STom Rini readl((*ctrl)->control_srcomp_east_side_wkup);
300983e3700STom Rini srcomp_value &= ~SRCODE_OVERRIDE_SEL_XS_MASK;
301983e3700STom Rini writel(srcomp_value, (*ctrl)->control_srcomp_east_side_wkup);
302983e3700STom Rini }
303983e3700STom Rini }
304983e3700STom Rini #endif
305983e3700STom Rini
config_data_eye_leveling_samples(u32 emif_base)306983e3700STom Rini void config_data_eye_leveling_samples(u32 emif_base)
307983e3700STom Rini {
308983e3700STom Rini const struct ctrl_ioregs *ioregs;
309983e3700STom Rini
310983e3700STom Rini get_ioregs(&ioregs);
311983e3700STom Rini
312983e3700STom Rini /*EMIF_SDRAM_CONFIG_EXT-Read data eye leveling no of samples =4*/
313983e3700STom Rini if (emif_base == EMIF1_BASE)
314983e3700STom Rini writel(ioregs->ctrl_emif_sdram_config_ext_final,
315983e3700STom Rini (*ctrl)->control_emif1_sdram_config_ext);
316983e3700STom Rini else if (emif_base == EMIF2_BASE)
317983e3700STom Rini writel(ioregs->ctrl_emif_sdram_config_ext_final,
318983e3700STom Rini (*ctrl)->control_emif2_sdram_config_ext);
319983e3700STom Rini }
320983e3700STom Rini
init_cpu_configuration(void)321983e3700STom Rini void init_cpu_configuration(void)
322983e3700STom Rini {
323983e3700STom Rini u32 l2actlr;
324983e3700STom Rini
325983e3700STom Rini asm volatile("mrc p15, 1, %0, c15, c0, 0" : "=r"(l2actlr));
326983e3700STom Rini /*
327983e3700STom Rini * L2ACTLR: Ensure to enable the following:
328983e3700STom Rini * 3: Disable clean/evict push to external
329983e3700STom Rini * 4: Disable WriteUnique and WriteLineUnique transactions from master
330983e3700STom Rini * 8: Disable DVM/CMO message broadcast
331983e3700STom Rini */
332983e3700STom Rini l2actlr |= 0x118;
333983e3700STom Rini omap_smc1(OMAP5_SERVICE_L2ACTLR_SET, l2actlr);
334983e3700STom Rini }
335983e3700STom Rini
init_omap_revision(void)336983e3700STom Rini void init_omap_revision(void)
337983e3700STom Rini {
338983e3700STom Rini /*
339983e3700STom Rini * For some of the ES2/ES1 boards ID_CODE is not reliable:
340983e3700STom Rini * Also, ES1 and ES2 have different ARM revisions
341983e3700STom Rini * So use ARM revision for identification
342983e3700STom Rini */
343983e3700STom Rini unsigned int rev = cortex_rev();
344983e3700STom Rini
345983e3700STom Rini switch (readl(CONTROL_ID_CODE)) {
346983e3700STom Rini case OMAP5430_CONTROL_ID_CODE_ES1_0:
347983e3700STom Rini *omap_si_rev = OMAP5430_ES1_0;
348983e3700STom Rini if (rev == MIDR_CORTEX_A15_R2P2)
349983e3700STom Rini *omap_si_rev = OMAP5430_ES2_0;
350983e3700STom Rini break;
351983e3700STom Rini case OMAP5432_CONTROL_ID_CODE_ES1_0:
352983e3700STom Rini *omap_si_rev = OMAP5432_ES1_0;
353983e3700STom Rini if (rev == MIDR_CORTEX_A15_R2P2)
354983e3700STom Rini *omap_si_rev = OMAP5432_ES2_0;
355983e3700STom Rini break;
356983e3700STom Rini case OMAP5430_CONTROL_ID_CODE_ES2_0:
357983e3700STom Rini *omap_si_rev = OMAP5430_ES2_0;
358983e3700STom Rini break;
359983e3700STom Rini case OMAP5432_CONTROL_ID_CODE_ES2_0:
360983e3700STom Rini *omap_si_rev = OMAP5432_ES2_0;
361983e3700STom Rini break;
3620f9e6aeeSPraneeth Bajjuri case DRA762_CONTROL_ID_CODE_ES1_0:
3630f9e6aeeSPraneeth Bajjuri *omap_si_rev = DRA762_ES1_0;
3640f9e6aeeSPraneeth Bajjuri break;
365983e3700STom Rini case DRA752_CONTROL_ID_CODE_ES1_0:
366983e3700STom Rini *omap_si_rev = DRA752_ES1_0;
367983e3700STom Rini break;
368983e3700STom Rini case DRA752_CONTROL_ID_CODE_ES1_1:
369983e3700STom Rini *omap_si_rev = DRA752_ES1_1;
370983e3700STom Rini break;
371983e3700STom Rini case DRA752_CONTROL_ID_CODE_ES2_0:
372983e3700STom Rini *omap_si_rev = DRA752_ES2_0;
373983e3700STom Rini break;
374983e3700STom Rini case DRA722_CONTROL_ID_CODE_ES1_0:
375983e3700STom Rini *omap_si_rev = DRA722_ES1_0;
376983e3700STom Rini break;
377983e3700STom Rini case DRA722_CONTROL_ID_CODE_ES2_0:
378983e3700STom Rini *omap_si_rev = DRA722_ES2_0;
379983e3700STom Rini break;
380ba396081SVishal Mahaveer case DRA722_CONTROL_ID_CODE_ES2_1:
381ba396081SVishal Mahaveer *omap_si_rev = DRA722_ES2_1;
382ba396081SVishal Mahaveer break;
383983e3700STom Rini default:
384983e3700STom Rini *omap_si_rev = OMAP5430_SILICON_ID_INVALID;
385983e3700STom Rini }
386983e3700STom Rini init_cpu_configuration();
387983e3700STom Rini }
388983e3700STom Rini
init_package_revision(void)389941f2fccSLokesh Vutla void init_package_revision(void)
390941f2fccSLokesh Vutla {
391941f2fccSLokesh Vutla unsigned int die_id[4] = { 0 };
392941f2fccSLokesh Vutla u8 package;
393941f2fccSLokesh Vutla
394941f2fccSLokesh Vutla omap_die_id(die_id);
395941f2fccSLokesh Vutla package = (die_id[2] >> 16) & 0x3;
396941f2fccSLokesh Vutla
397941f2fccSLokesh Vutla if (is_dra76x()) {
398941f2fccSLokesh Vutla switch (package) {
399941f2fccSLokesh Vutla case DRA762_ABZ_PACKAGE:
400941f2fccSLokesh Vutla *omap_si_rev = DRA762_ABZ_ES1_0;
401941f2fccSLokesh Vutla break;
402941f2fccSLokesh Vutla case DRA762_ACD_PACKAGE:
403941f2fccSLokesh Vutla default:
404941f2fccSLokesh Vutla *omap_si_rev = DRA762_ACD_ES1_0;
405941f2fccSLokesh Vutla break;
406941f2fccSLokesh Vutla }
407941f2fccSLokesh Vutla }
408941f2fccSLokesh Vutla }
409941f2fccSLokesh Vutla
omap_die_id(unsigned int * die_id)410983e3700STom Rini void omap_die_id(unsigned int *die_id)
411983e3700STom Rini {
412983e3700STom Rini die_id[0] = readl((*ctrl)->control_std_fuse_die_id_0);
413983e3700STom Rini die_id[1] = readl((*ctrl)->control_std_fuse_die_id_1);
414983e3700STom Rini die_id[2] = readl((*ctrl)->control_std_fuse_die_id_2);
415983e3700STom Rini die_id[3] = readl((*ctrl)->control_std_fuse_die_id_3);
416983e3700STom Rini }
417983e3700STom Rini
reset_cpu(ulong ignored)418983e3700STom Rini void reset_cpu(ulong ignored)
419983e3700STom Rini {
420983e3700STom Rini u32 omap_rev = omap_revision();
421983e3700STom Rini
422983e3700STom Rini /*
423983e3700STom Rini * WARM reset is not functional in case of OMAP5430 ES1.0 soc.
424983e3700STom Rini * So use cold reset in case instead.
425983e3700STom Rini */
426983e3700STom Rini if (omap_rev == OMAP5430_ES1_0)
427983e3700STom Rini writel(PRM_RSTCTRL_RESET << 0x1, (*prcm)->prm_rstctrl);
428983e3700STom Rini else
429983e3700STom Rini writel(PRM_RSTCTRL_RESET, (*prcm)->prm_rstctrl);
430983e3700STom Rini }
431983e3700STom Rini
warm_reset(void)432983e3700STom Rini u32 warm_reset(void)
433983e3700STom Rini {
434983e3700STom Rini return readl((*prcm)->prm_rstst) & PRM_RSTST_WARM_RESET_MASK;
435983e3700STom Rini }
436983e3700STom Rini
setup_warmreset_time(void)437983e3700STom Rini void setup_warmreset_time(void)
438983e3700STom Rini {
439983e3700STom Rini u32 rst_time, rst_val;
440983e3700STom Rini
441d87f8296STom Rini /*
442d87f8296STom Rini * MAX value for PRM_RSTTIME[9:0]RSTTIME1 stored is 0x3ff.
443d87f8296STom Rini * 0x3ff is in the no of FUNC_32K_CLK cycles. Converting cycles
444d87f8296STom Rini * into microsec and passing the value.
445d87f8296STom Rini */
446d87f8296STom Rini rst_time = usec_to_32k(CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC)
447d87f8296STom Rini << RSTTIME1_SHIFT;
448983e3700STom Rini
449983e3700STom Rini if (rst_time > RSTTIME1_MASK)
450983e3700STom Rini rst_time = RSTTIME1_MASK;
451983e3700STom Rini
452983e3700STom Rini rst_val = readl((*prcm)->prm_rsttime) & ~RSTTIME1_MASK;
453983e3700STom Rini rst_val |= rst_time;
454983e3700STom Rini writel(rst_val, (*prcm)->prm_rsttime);
455983e3700STom Rini }
456983e3700STom Rini
v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl,u32 cpu_midr,u32 cpu_rev_comb,u32 cpu_variant,u32 cpu_rev)457983e3700STom Rini void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr,
458983e3700STom Rini u32 cpu_rev_comb, u32 cpu_variant,
459983e3700STom Rini u32 cpu_rev)
460983e3700STom Rini {
461983e3700STom Rini omap_smc1(OMAP5_SERVICE_L2ACTLR_SET, l2auxctrl);
462983e3700STom Rini }
463983e3700STom Rini
v7_arch_cp15_set_acr(u32 acr,u32 cpu_midr,u32 cpu_rev_comb,u32 cpu_variant,u32 cpu_rev)464983e3700STom Rini void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb,
465983e3700STom Rini u32 cpu_variant, u32 cpu_rev)
466983e3700STom Rini {
467983e3700STom Rini
468983e3700STom Rini #ifdef CONFIG_ARM_ERRATA_801819
469983e3700STom Rini /*
470983e3700STom Rini * DRA72x processors are uniprocessors and DONOT have
471983e3700STom Rini * ACP (Accelerator Coherency Port) hooked to ACE (AXI Coherency
472983e3700STom Rini * Extensions) Hence the erratum workaround is not applicable for
473983e3700STom Rini * DRA72x processors.
474983e3700STom Rini */
475983e3700STom Rini if (is_dra72x())
476983e3700STom Rini acr &= ~((0x3 << 23) | (0x3 << 25));
477983e3700STom Rini #endif
478983e3700STom Rini omap_smc1(OMAP5_SERVICE_ACR_SET, acr);
479983e3700STom Rini }
480b4b06006SLokesh Vutla
481b4b06006SLokesh Vutla #if defined(CONFIG_PALMAS_POWER)
board_mmc_poweron_ldo(uint voltage)48291d3e906SLokesh Vutla __weak void board_mmc_poweron_ldo(uint voltage)
48391d3e906SLokesh Vutla {
484db4fce8fSLokesh Vutla palmas_mmc1_poweron_ldo(LDO1_VOLTAGE, LDO1_CTRL, voltage);
48591d3e906SLokesh Vutla }
48691d3e906SLokesh Vutla
vmmc_pbias_config(uint voltage)487b4b06006SLokesh Vutla void vmmc_pbias_config(uint voltage)
488b4b06006SLokesh Vutla {
489b4b06006SLokesh Vutla u32 value = 0;
490b4b06006SLokesh Vutla
491b4b06006SLokesh Vutla value = readl((*ctrl)->control_pbias);
492b4b06006SLokesh Vutla value &= ~SDCARD_PWRDNZ;
493b4b06006SLokesh Vutla writel(value, (*ctrl)->control_pbias);
494b4b06006SLokesh Vutla udelay(10); /* wait 10 us */
495b4b06006SLokesh Vutla value &= ~SDCARD_BIAS_PWRDNZ;
496b4b06006SLokesh Vutla writel(value, (*ctrl)->control_pbias);
497b4b06006SLokesh Vutla
49891d3e906SLokesh Vutla board_mmc_poweron_ldo(voltage);
499b4b06006SLokesh Vutla
500b4b06006SLokesh Vutla value = readl((*ctrl)->control_pbias);
501b4b06006SLokesh Vutla value |= SDCARD_BIAS_PWRDNZ;
502b4b06006SLokesh Vutla writel(value, (*ctrl)->control_pbias);
503b4b06006SLokesh Vutla udelay(150); /* wait 150 us */
504b4b06006SLokesh Vutla value |= SDCARD_PWRDNZ;
505b4b06006SLokesh Vutla writel(value, (*ctrl)->control_pbias);
506b4b06006SLokesh Vutla udelay(150); /* wait 150 us */
507b4b06006SLokesh Vutla }
508b4b06006SLokesh Vutla #endif
509