1ed09a554Srev13@wp.pl /*
2ed09a554Srev13@wp.pl * (C) Copyright 2011, 2012, 2013
3ed09a554Srev13@wp.pl * Yuri Tikhonov, Emcraft Systems, yur@emcraft.com
4ed09a554Srev13@wp.pl * Alexander Potashev, Emcraft Systems, aspotashev@emcraft.com
5ed09a554Srev13@wp.pl * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
6ed09a554Srev13@wp.pl * Pavel Boldin, Emcraft Systems, paboldin@emcraft.com
7ed09a554Srev13@wp.pl *
8ed09a554Srev13@wp.pl * (C) Copyright 2015
966562414SKamil Lulko * Kamil Lulko, <kamil.lulko@gmail.com>
10ed09a554Srev13@wp.pl *
11ed09a554Srev13@wp.pl * SPDX-License-Identifier: GPL-2.0+
12ed09a554Srev13@wp.pl */
13ed09a554Srev13@wp.pl
14ed09a554Srev13@wp.pl #include <common.h>
159d922450SSimon Glass #include <dm.h>
16ed09a554Srev13@wp.pl #include <asm/io.h>
17ed09a554Srev13@wp.pl #include <asm/armv7m.h>
18ed09a554Srev13@wp.pl #include <asm/arch/stm32.h>
19ed09a554Srev13@wp.pl #include <asm/arch/gpio.h>
20ed09a554Srev13@wp.pl #include <asm/arch/fmc.h>
2166562414SKamil Lulko #include <dm/platform_data/serial_stm32.h>
22dffceb4bSVikas Manocha #include <asm/arch/stm32_periph.h>
23dffceb4bSVikas Manocha #include <asm/arch/stm32_defs.h>
24ed09a554Srev13@wp.pl
25ed09a554Srev13@wp.pl DECLARE_GLOBAL_DATA_PTR;
26ed09a554Srev13@wp.pl
27ed09a554Srev13@wp.pl const struct stm32_gpio_ctl gpio_ctl_gpout = {
28ed09a554Srev13@wp.pl .mode = STM32_GPIO_MODE_OUT,
29ed09a554Srev13@wp.pl .otype = STM32_GPIO_OTYPE_PP,
30ed09a554Srev13@wp.pl .speed = STM32_GPIO_SPEED_50M,
31ed09a554Srev13@wp.pl .pupd = STM32_GPIO_PUPD_NO,
32ed09a554Srev13@wp.pl .af = STM32_GPIO_AF0
33ed09a554Srev13@wp.pl };
34ed09a554Srev13@wp.pl
35ed09a554Srev13@wp.pl const struct stm32_gpio_ctl gpio_ctl_usart = {
36ed09a554Srev13@wp.pl .mode = STM32_GPIO_MODE_AF,
37ed09a554Srev13@wp.pl .otype = STM32_GPIO_OTYPE_PP,
38ed09a554Srev13@wp.pl .speed = STM32_GPIO_SPEED_50M,
39ed09a554Srev13@wp.pl .pupd = STM32_GPIO_PUPD_UP,
4060570df1Skunhuahuang .af = STM32_GPIO_USART
41ed09a554Srev13@wp.pl };
42ed09a554Srev13@wp.pl
4360570df1Skunhuahuang static const struct stm32_gpio_dsc usart_gpio[] = {
4460570df1Skunhuahuang {STM32_GPIO_PORT_X, STM32_GPIO_PIN_TX}, /* TX */
4560570df1Skunhuahuang {STM32_GPIO_PORT_X, STM32_GPIO_PIN_RX}, /* RX */
46ed09a554Srev13@wp.pl };
47ed09a554Srev13@wp.pl
uart_setup_gpio(void)4860570df1Skunhuahuang int uart_setup_gpio(void)
49ed09a554Srev13@wp.pl {
50ed09a554Srev13@wp.pl int i;
51ed09a554Srev13@wp.pl int rv = 0;
52ed09a554Srev13@wp.pl
5314cec061SVikas Manocha clock_setup(GPIO_A_CLOCK_CFG);
5460570df1Skunhuahuang for (i = 0; i < ARRAY_SIZE(usart_gpio); i++) {
5560570df1Skunhuahuang rv = stm32_gpio_config(&usart_gpio[i], &gpio_ctl_usart);
56ed09a554Srev13@wp.pl if (rv)
57ed09a554Srev13@wp.pl goto out;
58ed09a554Srev13@wp.pl }
59ed09a554Srev13@wp.pl
60ed09a554Srev13@wp.pl out:
61ed09a554Srev13@wp.pl return rv;
62ed09a554Srev13@wp.pl }
63ed09a554Srev13@wp.pl
64ed09a554Srev13@wp.pl const struct stm32_gpio_ctl gpio_ctl_fmc = {
65ed09a554Srev13@wp.pl .mode = STM32_GPIO_MODE_AF,
66ed09a554Srev13@wp.pl .otype = STM32_GPIO_OTYPE_PP,
67ed09a554Srev13@wp.pl .speed = STM32_GPIO_SPEED_100M,
68ed09a554Srev13@wp.pl .pupd = STM32_GPIO_PUPD_NO,
69ed09a554Srev13@wp.pl .af = STM32_GPIO_AF12
70ed09a554Srev13@wp.pl };
71ed09a554Srev13@wp.pl
72ed09a554Srev13@wp.pl static const struct stm32_gpio_dsc ext_ram_fmc_gpio[] = {
73ed09a554Srev13@wp.pl /* Chip is LQFP144, see DM00077036.pdf for details */
74ed09a554Srev13@wp.pl {STM32_GPIO_PORT_D, STM32_GPIO_PIN_10}, /* 79, FMC_D15 */
75ed09a554Srev13@wp.pl {STM32_GPIO_PORT_D, STM32_GPIO_PIN_9}, /* 78, FMC_D14 */
76ed09a554Srev13@wp.pl {STM32_GPIO_PORT_D, STM32_GPIO_PIN_8}, /* 77, FMC_D13 */
77ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_15}, /* 68, FMC_D12 */
78ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_14}, /* 67, FMC_D11 */
79ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_13}, /* 66, FMC_D10 */
80ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_12}, /* 65, FMC_D9 */
81ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_11}, /* 64, FMC_D8 */
82ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_10}, /* 63, FMC_D7 */
83ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_9}, /* 60, FMC_D6 */
84ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_8}, /* 59, FMC_D5 */
85ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_7}, /* 58, FMC_D4 */
86ed09a554Srev13@wp.pl {STM32_GPIO_PORT_D, STM32_GPIO_PIN_1}, /* 115, FMC_D3 */
87ed09a554Srev13@wp.pl {STM32_GPIO_PORT_D, STM32_GPIO_PIN_0}, /* 114, FMC_D2 */
88ed09a554Srev13@wp.pl {STM32_GPIO_PORT_D, STM32_GPIO_PIN_15}, /* 86, FMC_D1 */
89ed09a554Srev13@wp.pl {STM32_GPIO_PORT_D, STM32_GPIO_PIN_14}, /* 85, FMC_D0 */
90ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_1}, /* 142, FMC_NBL1 */
91ed09a554Srev13@wp.pl {STM32_GPIO_PORT_E, STM32_GPIO_PIN_0}, /* 141, FMC_NBL0 */
92ed09a554Srev13@wp.pl {STM32_GPIO_PORT_G, STM32_GPIO_PIN_5}, /* 90, FMC_A15, BA1 */
93ed09a554Srev13@wp.pl {STM32_GPIO_PORT_G, STM32_GPIO_PIN_4}, /* 89, FMC_A14, BA0 */
94ed09a554Srev13@wp.pl {STM32_GPIO_PORT_G, STM32_GPIO_PIN_1}, /* 57, FMC_A11 */
95ed09a554Srev13@wp.pl {STM32_GPIO_PORT_G, STM32_GPIO_PIN_0}, /* 56, FMC_A10 */
96ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_15}, /* 55, FMC_A9 */
97ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_14}, /* 54, FMC_A8 */
98ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_13}, /* 53, FMC_A7 */
99ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_12}, /* 50, FMC_A6 */
100ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_5}, /* 15, FMC_A5 */
101ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_4}, /* 14, FMC_A4 */
102ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_3}, /* 13, FMC_A3 */
103ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_2}, /* 12, FMC_A2 */
104ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_1}, /* 11, FMC_A1 */
105ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_0}, /* 10, FMC_A0 */
106ed09a554Srev13@wp.pl {STM32_GPIO_PORT_B, STM32_GPIO_PIN_6}, /* 136, SDRAM_NE */
107ed09a554Srev13@wp.pl {STM32_GPIO_PORT_F, STM32_GPIO_PIN_11}, /* 49, SDRAM_NRAS */
108ed09a554Srev13@wp.pl {STM32_GPIO_PORT_G, STM32_GPIO_PIN_15}, /* 132, SDRAM_NCAS */
109ed09a554Srev13@wp.pl {STM32_GPIO_PORT_C, STM32_GPIO_PIN_0}, /* 26, SDRAM_NWE */
110ed09a554Srev13@wp.pl {STM32_GPIO_PORT_B, STM32_GPIO_PIN_5}, /* 135, SDRAM_CKE */
111ed09a554Srev13@wp.pl {STM32_GPIO_PORT_G, STM32_GPIO_PIN_8}, /* 93, SDRAM_CLK */
112ed09a554Srev13@wp.pl };
113ed09a554Srev13@wp.pl
fmc_setup_gpio(void)114ed09a554Srev13@wp.pl static int fmc_setup_gpio(void)
115ed09a554Srev13@wp.pl {
116ed09a554Srev13@wp.pl int rv = 0;
117ed09a554Srev13@wp.pl int i;
118ed09a554Srev13@wp.pl
11914cec061SVikas Manocha clock_setup(GPIO_B_CLOCK_CFG);
12014cec061SVikas Manocha clock_setup(GPIO_C_CLOCK_CFG);
12114cec061SVikas Manocha clock_setup(GPIO_D_CLOCK_CFG);
12214cec061SVikas Manocha clock_setup(GPIO_E_CLOCK_CFG);
12314cec061SVikas Manocha clock_setup(GPIO_F_CLOCK_CFG);
12414cec061SVikas Manocha clock_setup(GPIO_G_CLOCK_CFG);
12514cec061SVikas Manocha
126ed09a554Srev13@wp.pl for (i = 0; i < ARRAY_SIZE(ext_ram_fmc_gpio); i++) {
127ed09a554Srev13@wp.pl rv = stm32_gpio_config(&ext_ram_fmc_gpio[i],
128ed09a554Srev13@wp.pl &gpio_ctl_fmc);
129ed09a554Srev13@wp.pl if (rv)
130ed09a554Srev13@wp.pl goto out;
131ed09a554Srev13@wp.pl }
132ed09a554Srev13@wp.pl
133ed09a554Srev13@wp.pl out:
134ed09a554Srev13@wp.pl return rv;
135ed09a554Srev13@wp.pl }
136ed09a554Srev13@wp.pl
137ed09a554Srev13@wp.pl /*
138ed09a554Srev13@wp.pl * STM32 RCC FMC specific definitions
139ed09a554Srev13@wp.pl */
140ed09a554Srev13@wp.pl #define STM32_RCC_ENR_FMC (1 << 0) /* FMC module clock */
141ed09a554Srev13@wp.pl
_ns2clk(u32 ns,u32 freq)142ed09a554Srev13@wp.pl static inline u32 _ns2clk(u32 ns, u32 freq)
143ed09a554Srev13@wp.pl {
144ed09a554Srev13@wp.pl u32 tmp = freq/1000000;
145ed09a554Srev13@wp.pl return (tmp * ns) / 1000;
146ed09a554Srev13@wp.pl }
147ed09a554Srev13@wp.pl
148ed09a554Srev13@wp.pl #define NS2CLK(ns) (_ns2clk(ns, freq))
149ed09a554Srev13@wp.pl
150ed09a554Srev13@wp.pl /*
151ed09a554Srev13@wp.pl * Following are timings for IS42S16400J, from corresponding datasheet
152ed09a554Srev13@wp.pl */
153ed09a554Srev13@wp.pl #define SDRAM_CAS 3 /* 3 cycles */
154ed09a554Srev13@wp.pl #define SDRAM_NB 1 /* Number of banks */
155ed09a554Srev13@wp.pl #define SDRAM_MWID 1 /* 16 bit memory */
156ed09a554Srev13@wp.pl
157ed09a554Srev13@wp.pl #define SDRAM_NR 0x1 /* 12-bit row */
158ed09a554Srev13@wp.pl #define SDRAM_NC 0x0 /* 8-bit col */
159ed09a554Srev13@wp.pl #define SDRAM_RBURST 0x1 /* Single read requests always as bursts */
160ed09a554Srev13@wp.pl #define SDRAM_RPIPE 0x0 /* No HCLK clock cycle delay */
161ed09a554Srev13@wp.pl
162ed09a554Srev13@wp.pl #define SDRAM_TRRD (NS2CLK(14) - 1)
163ed09a554Srev13@wp.pl #define SDRAM_TRCD (NS2CLK(15) - 1)
164ed09a554Srev13@wp.pl #define SDRAM_TRP (NS2CLK(15) - 1)
165ed09a554Srev13@wp.pl #define SDRAM_TRAS (NS2CLK(42) - 1)
166ed09a554Srev13@wp.pl #define SDRAM_TRC (NS2CLK(63) - 1)
167ed09a554Srev13@wp.pl #define SDRAM_TRFC (NS2CLK(63) - 1)
168ed09a554Srev13@wp.pl #define SDRAM_TCDL (1 - 1)
169ed09a554Srev13@wp.pl #define SDRAM_TRDL (2 - 1)
170ed09a554Srev13@wp.pl #define SDRAM_TBDL (1 - 1)
171ed09a554Srev13@wp.pl #define SDRAM_TREF 1386
172ed09a554Srev13@wp.pl #define SDRAM_TCCD (1 - 1)
173ed09a554Srev13@wp.pl
174ed09a554Srev13@wp.pl #define SDRAM_TXSR (NS2CLK(70) - 1)/* Row cycle time after precharge */
175ed09a554Srev13@wp.pl #define SDRAM_TMRD (3 - 1) /* Page 10, Mode Register Set */
176ed09a554Srev13@wp.pl
177ed09a554Srev13@wp.pl /* Last data-in to row precharge, need also comply ineq from RM 37.7.5 */
178ed09a554Srev13@wp.pl #define SDRAM_TWR max(\
179ed09a554Srev13@wp.pl (int)max((int)SDRAM_TRDL, (int)(SDRAM_TRAS - SDRAM_TRCD - 1)), \
180ed09a554Srev13@wp.pl (int)(SDRAM_TRC - SDRAM_TRCD - SDRAM_TRP - 2)\
181ed09a554Srev13@wp.pl )
182ed09a554Srev13@wp.pl
183ed09a554Srev13@wp.pl #define SDRAM_MODE_BL_SHIFT 0
184ed09a554Srev13@wp.pl #define SDRAM_MODE_CAS_SHIFT 4
185ed09a554Srev13@wp.pl #define SDRAM_MODE_BL 0
186ed09a554Srev13@wp.pl #define SDRAM_MODE_CAS SDRAM_CAS
187ed09a554Srev13@wp.pl
dram_init(void)188ed09a554Srev13@wp.pl int dram_init(void)
189ed09a554Srev13@wp.pl {
190ed09a554Srev13@wp.pl u32 freq;
191ed09a554Srev13@wp.pl int rv;
192ed09a554Srev13@wp.pl
193ed09a554Srev13@wp.pl rv = fmc_setup_gpio();
194ed09a554Srev13@wp.pl if (rv)
195ed09a554Srev13@wp.pl return rv;
196ed09a554Srev13@wp.pl
197ed09a554Srev13@wp.pl setbits_le32(&STM32_RCC->ahb3enr, STM32_RCC_ENR_FMC);
198ed09a554Srev13@wp.pl
199ed09a554Srev13@wp.pl /*
200ed09a554Srev13@wp.pl * Get frequency for NS2CLK calculation.
201ed09a554Srev13@wp.pl */
202ed09a554Srev13@wp.pl freq = clock_get(CLOCK_AHB) / CONFIG_SYS_RAM_FREQ_DIV;
203ed09a554Srev13@wp.pl
204ed09a554Srev13@wp.pl writel(CONFIG_SYS_RAM_FREQ_DIV << FMC_SDCR_SDCLK_SHIFT
205ed09a554Srev13@wp.pl | SDRAM_RPIPE << FMC_SDCR_RPIPE_SHIFT
206ed09a554Srev13@wp.pl | SDRAM_RBURST << FMC_SDCR_RBURST_SHIFT,
207ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdcr1);
208ed09a554Srev13@wp.pl
209ed09a554Srev13@wp.pl writel(CONFIG_SYS_RAM_FREQ_DIV << FMC_SDCR_SDCLK_SHIFT
210ed09a554Srev13@wp.pl | SDRAM_CAS << FMC_SDCR_CAS_SHIFT
211ed09a554Srev13@wp.pl | SDRAM_NB << FMC_SDCR_NB_SHIFT
212ed09a554Srev13@wp.pl | SDRAM_MWID << FMC_SDCR_MWID_SHIFT
213ed09a554Srev13@wp.pl | SDRAM_NR << FMC_SDCR_NR_SHIFT
214ed09a554Srev13@wp.pl | SDRAM_NC << FMC_SDCR_NC_SHIFT
215ed09a554Srev13@wp.pl | SDRAM_RPIPE << FMC_SDCR_RPIPE_SHIFT
216ed09a554Srev13@wp.pl | SDRAM_RBURST << FMC_SDCR_RBURST_SHIFT,
217ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdcr2);
218ed09a554Srev13@wp.pl
219ed09a554Srev13@wp.pl writel(SDRAM_TRP << FMC_SDTR_TRP_SHIFT
220ed09a554Srev13@wp.pl | SDRAM_TRC << FMC_SDTR_TRC_SHIFT,
221ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdtr1);
222ed09a554Srev13@wp.pl
223ed09a554Srev13@wp.pl writel(SDRAM_TRCD << FMC_SDTR_TRCD_SHIFT
224ed09a554Srev13@wp.pl | SDRAM_TRP << FMC_SDTR_TRP_SHIFT
225ed09a554Srev13@wp.pl | SDRAM_TWR << FMC_SDTR_TWR_SHIFT
226ed09a554Srev13@wp.pl | SDRAM_TRC << FMC_SDTR_TRC_SHIFT
227ed09a554Srev13@wp.pl | SDRAM_TRAS << FMC_SDTR_TRAS_SHIFT
228ed09a554Srev13@wp.pl | SDRAM_TXSR << FMC_SDTR_TXSR_SHIFT
229ed09a554Srev13@wp.pl | SDRAM_TMRD << FMC_SDTR_TMRD_SHIFT,
230ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdtr2);
231ed09a554Srev13@wp.pl
232ed09a554Srev13@wp.pl writel(FMC_SDCMR_BANK_2 | FMC_SDCMR_MODE_START_CLOCK,
233ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdcmr);
234ed09a554Srev13@wp.pl
235ed09a554Srev13@wp.pl udelay(200); /* 200 us delay, page 10, "Power-Up" */
236ed09a554Srev13@wp.pl FMC_BUSY_WAIT();
237ed09a554Srev13@wp.pl
238ed09a554Srev13@wp.pl writel(FMC_SDCMR_BANK_2 | FMC_SDCMR_MODE_PRECHARGE,
239ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdcmr);
240ed09a554Srev13@wp.pl
241ed09a554Srev13@wp.pl udelay(100);
242ed09a554Srev13@wp.pl FMC_BUSY_WAIT();
243ed09a554Srev13@wp.pl
244ed09a554Srev13@wp.pl writel((FMC_SDCMR_BANK_2 | FMC_SDCMR_MODE_AUTOREFRESH
245ed09a554Srev13@wp.pl | 7 << FMC_SDCMR_NRFS_SHIFT), &STM32_SDRAM_FMC->sdcmr);
246ed09a554Srev13@wp.pl
247ed09a554Srev13@wp.pl udelay(100);
248ed09a554Srev13@wp.pl FMC_BUSY_WAIT();
249ed09a554Srev13@wp.pl
250ed09a554Srev13@wp.pl writel(FMC_SDCMR_BANK_2 | (SDRAM_MODE_BL << SDRAM_MODE_BL_SHIFT
251ed09a554Srev13@wp.pl | SDRAM_MODE_CAS << SDRAM_MODE_CAS_SHIFT)
252ed09a554Srev13@wp.pl << FMC_SDCMR_MODE_REGISTER_SHIFT | FMC_SDCMR_MODE_WRITE_MODE,
253ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdcmr);
254ed09a554Srev13@wp.pl
255ed09a554Srev13@wp.pl udelay(100);
256ed09a554Srev13@wp.pl
257ed09a554Srev13@wp.pl FMC_BUSY_WAIT();
258ed09a554Srev13@wp.pl
259ed09a554Srev13@wp.pl writel(FMC_SDCMR_BANK_2 | FMC_SDCMR_MODE_NORMAL,
260ed09a554Srev13@wp.pl &STM32_SDRAM_FMC->sdcmr);
261ed09a554Srev13@wp.pl
262ed09a554Srev13@wp.pl FMC_BUSY_WAIT();
263ed09a554Srev13@wp.pl
264ed09a554Srev13@wp.pl /* Refresh timer */
265ed09a554Srev13@wp.pl writel(SDRAM_TREF, &STM32_SDRAM_FMC->sdrtr);
266ed09a554Srev13@wp.pl
267ed09a554Srev13@wp.pl /*
268ed09a554Srev13@wp.pl * Fill in global info with description of SRAM configuration
269ed09a554Srev13@wp.pl */
270ed09a554Srev13@wp.pl gd->bd->bi_dram[0].start = CONFIG_SYS_RAM_BASE;
271ed09a554Srev13@wp.pl gd->bd->bi_dram[0].size = CONFIG_SYS_RAM_SIZE;
272ed09a554Srev13@wp.pl
273ed09a554Srev13@wp.pl gd->ram_size = CONFIG_SYS_RAM_SIZE;
274ed09a554Srev13@wp.pl
275ed09a554Srev13@wp.pl return rv;
276ed09a554Srev13@wp.pl }
277ed09a554Srev13@wp.pl
27866562414SKamil Lulko static const struct stm32_serial_platdata serial_platdata = {
27966562414SKamil Lulko .base = (struct stm32_usart *)STM32_USART1_BASE,
28066562414SKamil Lulko };
28166562414SKamil Lulko
28266562414SKamil Lulko U_BOOT_DEVICE(stm32_serials) = {
28366562414SKamil Lulko .name = "serial_stm32",
28466562414SKamil Lulko .platdata = &serial_platdata,
28566562414SKamil Lulko };
28666562414SKamil Lulko
get_board_rev(void)287ed09a554Srev13@wp.pl u32 get_board_rev(void)
288ed09a554Srev13@wp.pl {
289ed09a554Srev13@wp.pl return 0;
290ed09a554Srev13@wp.pl }
291ed09a554Srev13@wp.pl
board_early_init_f(void)292ed09a554Srev13@wp.pl int board_early_init_f(void)
293ed09a554Srev13@wp.pl {
294ed09a554Srev13@wp.pl int res;
295ed09a554Srev13@wp.pl
29660570df1Skunhuahuang res = uart_setup_gpio();
297ed09a554Srev13@wp.pl if (res)
298ed09a554Srev13@wp.pl return res;
299dffceb4bSVikas Manocha clock_setup(USART1_CLOCK_CFG);
300ed09a554Srev13@wp.pl
301ed09a554Srev13@wp.pl return 0;
302ed09a554Srev13@wp.pl }
303ed09a554Srev13@wp.pl
board_init(void)304ed09a554Srev13@wp.pl int board_init(void)
305ed09a554Srev13@wp.pl {
306ed09a554Srev13@wp.pl gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
307ed09a554Srev13@wp.pl
308ed09a554Srev13@wp.pl return 0;
309ed09a554Srev13@wp.pl }
310089fddfdSAntonio Borneo
311089fddfdSAntonio Borneo #ifdef CONFIG_MISC_INIT_R
misc_init_r(void)312089fddfdSAntonio Borneo int misc_init_r(void)
313089fddfdSAntonio Borneo {
314089fddfdSAntonio Borneo char serialno[25];
315089fddfdSAntonio Borneo uint32_t u_id_low, u_id_mid, u_id_high;
316089fddfdSAntonio Borneo
317*00caae6dSSimon Glass if (!env_get("serial#")) {
318089fddfdSAntonio Borneo u_id_low = readl(&STM32_U_ID->u_id_low);
319089fddfdSAntonio Borneo u_id_mid = readl(&STM32_U_ID->u_id_mid);
320089fddfdSAntonio Borneo u_id_high = readl(&STM32_U_ID->u_id_high);
321089fddfdSAntonio Borneo sprintf(serialno, "%08x%08x%08x",
322089fddfdSAntonio Borneo u_id_high, u_id_mid, u_id_low);
323382bee57SSimon Glass env_set("serial#", serialno);
324089fddfdSAntonio Borneo }
325089fddfdSAntonio Borneo
326089fddfdSAntonio Borneo return 0;
327089fddfdSAntonio Borneo }
328089fddfdSAntonio Borneo #endif
329