blob: 6bfaaed666a6fca6b0dd7b973bad585d417a3c8c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Heiko Schocherf853c6c2014-07-18 06:07:22 +02002/*
3 * (C) Copyright 2014
4 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 *
6 * Based on:
7 * Copyright (C) 2012 Freescale Semiconductor, Inc.
8 *
9 * Author: Fabio Estevam <fabio.estevam@freescale.com>
Heiko Schocherf853c6c2014-07-18 06:07:22 +020010 */
11
Simon Glassed38aef2020-05-10 11:40:03 -060012#include <command.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060013#include <image.h>
Simon Glass97589732020-05-10 11:40:02 -060014#include <init.h>
Heiko Schocherf853c6c2014-07-18 06:07:22 +020015#include <asm/arch/clock.h>
16#include <asm/arch/imx-regs.h>
17#include <asm/arch/iomux.h>
18#include <asm/arch/mx6-pins.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090019#include <linux/errno.h>
Heiko Schocherf853c6c2014-07-18 06:07:22 +020020#include <asm/gpio.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020021#include <asm/mach-imx/iomux-v3.h>
22#include <asm/mach-imx/boot_mode.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020023#include <asm/mach-imx/video.h>
Heiko Schocherf853c6c2014-07-18 06:07:22 +020024#include <asm/arch/crm_regs.h>
Heiko Schocherf853c6c2014-07-18 06:07:22 +020025#include <asm/io.h>
26#include <asm/arch/sys_proto.h>
Heiko Schocher8f4a1b92019-12-01 11:23:19 +010027#include <bmp_logo.h>
Heiko Schocher54333792019-12-01 11:23:12 +010028#include <dm/root.h>
Heiko Schochera051ee92019-12-01 11:23:11 +010029#include <env.h>
Heiko Schocherc6729682019-12-01 11:23:23 +010030#include <i2c_eeprom.h>
31#include <i2c.h>
Heiko Schochera051ee92019-12-01 11:23:11 +010032#include <micrel.h>
Heiko Schocher441b0542019-12-01 11:23:18 +010033#include <miiphy.h>
Heiko Schocher8f4a1b92019-12-01 11:23:19 +010034#include <lcd.h>
Heiko Schocher495956b2019-12-01 11:23:15 +010035#include <led.h>
Heiko Schocherf5210a92020-03-02 09:44:03 +010036#include <power/pmic.h>
37#include <power/regulator.h>
38#include <power/da9063_pmic.h>
Heiko Schocher8f4a1b92019-12-01 11:23:19 +010039#include <splash.h>
40#include <video_fb.h>
Heiko Schocherf853c6c2014-07-18 06:07:22 +020041
42DECLARE_GLOBAL_DATA_PTR;
43
Heiko Schocher54333792019-12-01 11:23:12 +010044enum {
45 BOARD_TYPE_4 = 4,
46 BOARD_TYPE_7 = 7,
47};
48
49#define ARI_BT_4 "aristainetos2_4@2"
50#define ARI_BT_7 "aristainetos2_7@1"
51
Heiko Schochera051ee92019-12-01 11:23:11 +010052int board_phy_config(struct phy_device *phydev)
53{
54 /* control data pad skew - devaddr = 0x02, register = 0x04 */
55 ksz9031_phy_extended_write(phydev, 0x02,
56 MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW,
57 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
58 /* rx data pad skew - devaddr = 0x02, register = 0x05 */
59 ksz9031_phy_extended_write(phydev, 0x02,
60 MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW,
61 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
62 /* tx data pad skew - devaddr = 0x02, register = 0x06 */
63 ksz9031_phy_extended_write(phydev, 0x02,
64 MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW,
65 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
66 /* gtx and rx clock pad skew - devaddr = 0x02, register = 0x08 */
67 ksz9031_phy_extended_write(phydev, 0x02,
68 MII_KSZ9031_EXT_RGMII_CLOCK_SKEW,
69 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x03FF);
70
71 if (phydev->drv->config)
72 phydev->drv->config(phydev);
73
74 return 0;
75}
76
Heiko Schochera051ee92019-12-01 11:23:11 +010077static int rotate_logo_one(unsigned char *out, unsigned char *in)
78{
79 int i, j;
80
81 for (i = 0; i < BMP_LOGO_WIDTH; i++)
82 for (j = 0; j < BMP_LOGO_HEIGHT; j++)
83 out[j * BMP_LOGO_WIDTH + BMP_LOGO_HEIGHT - 1 - i] =
84 in[i * BMP_LOGO_WIDTH + j];
85 return 0;
86}
87
88/*
89 * Rotate the BMP_LOGO (only)
90 * Will only work, if the logo is square, as
91 * BMP_LOGO_HEIGHT and BMP_LOGO_WIDTH are defines, not variables
92 */
93void rotate_logo(int rotations)
94{
95 unsigned char out_logo[BMP_LOGO_WIDTH * BMP_LOGO_HEIGHT];
Heiko Schocher8f4a1b92019-12-01 11:23:19 +010096 struct bmp_header *header;
Heiko Schochera051ee92019-12-01 11:23:11 +010097 unsigned char *in_logo;
98 int i, j;
99
100 if (BMP_LOGO_WIDTH != BMP_LOGO_HEIGHT)
101 return;
102
Heiko Schocher8f4a1b92019-12-01 11:23:19 +0100103 header = (struct bmp_header *)bmp_logo_bitmap;
104 in_logo = bmp_logo_bitmap + header->data_offset;
Heiko Schochera051ee92019-12-01 11:23:11 +0100105
106 /* one 90 degree rotation */
107 if (rotations == 1 || rotations == 2 || rotations == 3)
108 rotate_logo_one(out_logo, in_logo);
109
110 /* second 90 degree rotation */
111 if (rotations == 2 || rotations == 3)
112 rotate_logo_one(in_logo, out_logo);
113
114 /* third 90 degree rotation */
115 if (rotations == 3)
116 rotate_logo_one(out_logo, in_logo);
117
118 /* copy result back to original array */
119 if (rotations == 1 || rotations == 3)
120 for (i = 0; i < BMP_LOGO_WIDTH; i++)
121 for (j = 0; j < BMP_LOGO_HEIGHT; j++)
122 in_logo[i * BMP_LOGO_WIDTH + j] =
123 out_logo[i * BMP_LOGO_WIDTH + j];
124}
125
Heiko Schochera051ee92019-12-01 11:23:11 +0100126static void enable_lvds(struct display_info_t const *dev)
127{
128 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
129 struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
130 int reg;
131 s32 timeout = 100000;
132
133 /* set PLL5 clock */
134 reg = readl(&ccm->analog_pll_video);
135 reg |= BM_ANADIG_PLL_VIDEO_POWERDOWN;
136 writel(reg, &ccm->analog_pll_video);
137
138 /* set PLL5 to 232720000Hz */
139 reg &= ~BM_ANADIG_PLL_VIDEO_DIV_SELECT;
140 reg |= BF_ANADIG_PLL_VIDEO_DIV_SELECT(0x26);
141 reg &= ~BM_ANADIG_PLL_VIDEO_POST_DIV_SELECT;
142 reg |= BF_ANADIG_PLL_VIDEO_POST_DIV_SELECT(0);
143 writel(reg, &ccm->analog_pll_video);
144
145 writel(BF_ANADIG_PLL_VIDEO_NUM_A(0xC0238),
146 &ccm->analog_pll_video_num);
147 writel(BF_ANADIG_PLL_VIDEO_DENOM_B(0xF4240),
148 &ccm->analog_pll_video_denom);
149
150 reg &= ~BM_ANADIG_PLL_VIDEO_POWERDOWN;
151 writel(reg, &ccm->analog_pll_video);
152
153 while (timeout--)
154 if (readl(&ccm->analog_pll_video) & BM_ANADIG_PLL_VIDEO_LOCK)
155 break;
156 if (timeout < 0)
157 printf("Warning: video pll lock timeout!\n");
158
159 reg = readl(&ccm->analog_pll_video);
160 reg |= BM_ANADIG_PLL_VIDEO_ENABLE;
161 reg &= ~BM_ANADIG_PLL_VIDEO_BYPASS;
162 writel(reg, &ccm->analog_pll_video);
163
164 /* set LDB0, LDB1 clk select to 000/000 (PLL5 clock) */
165 reg = readl(&ccm->cs2cdr);
166 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
167 | MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
168 reg |= (0 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET)
169 | (0 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
170 writel(reg, &ccm->cs2cdr);
171
172 reg = readl(&ccm->cscmr2);
173 reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV;
174 writel(reg, &ccm->cscmr2);
175
176 reg = readl(&ccm->chsccdr);
177 reg |= (CHSCCDR_CLK_SEL_LDB_DI0
178 << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
179 writel(reg, &ccm->chsccdr);
180
181 reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES
182 | IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH
183 | IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_HIGH
184 | IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG
185 | IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT
186 | IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED
187 | IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0;
188 writel(reg, &iomux->gpr[2]);
189
190 reg = readl(&iomux->gpr[3]);
191 reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK)
192 | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
193 << IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
194 writel(reg, &iomux->gpr[3]);
195}
196
Heiko Schochera051ee92019-12-01 11:23:11 +0100197static void setup_display(void)
198{
199 enable_ipu_clock();
Heiko Schochera051ee92019-12-01 11:23:11 +0100200}
201
Heiko Schochera051ee92019-12-01 11:23:11 +0100202static void set_gpr_register(void)
203{
204 struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
205
206 writel(IOMUXC_GPR1_APP_CLK_REQ_N | IOMUXC_GPR1_PCIE_RDY_L23 |
207 IOMUXC_GPR1_EXC_MON_SLVE |
208 (2 << IOMUXC_GPR1_ADDRS0_OFFSET) |
209 IOMUXC_GPR1_ACT_CS0,
210 &iomuxc_regs->gpr[1]);
211 writel(0x0, &iomuxc_regs->gpr[8]);
212 writel(IOMUXC_GPR12_ARMP_IPG_CLK_EN | IOMUXC_GPR12_ARMP_AHB_CLK_EN |
213 IOMUXC_GPR12_ARMP_ATB_CLK_EN | IOMUXC_GPR12_ARMP_APB_CLK_EN,
214 &iomuxc_regs->gpr[12]);
215}
216
Heiko Schocher54333792019-12-01 11:23:12 +0100217extern char __bss_start[], __bss_end[];
Heiko Schochera051ee92019-12-01 11:23:11 +0100218int board_early_init_f(void)
219{
Heiko Schocher8f4a1b92019-12-01 11:23:19 +0100220 select_ldb_di_clock_source(MXC_PLL5_CLK);
Heiko Schochera051ee92019-12-01 11:23:11 +0100221 set_gpr_register();
Heiko Schocher54333792019-12-01 11:23:12 +0100222
223 /*
224 * clear bss here, so we can use spi driver
225 * before relocation and read Environment
226 * from spi flash.
227 */
228 memset(__bss_start, 0x00, __bss_end - __bss_start);
229
Heiko Schochera051ee92019-12-01 11:23:11 +0100230 return 0;
231}
232
Heiko Schocher495956b2019-12-01 11:23:15 +0100233static void setup_one_led(char *label, int state)
Heiko Schochera051ee92019-12-01 11:23:11 +0100234{
Heiko Schocher495956b2019-12-01 11:23:15 +0100235 struct udevice *dev;
236 int ret;
Heiko Schochera051ee92019-12-01 11:23:11 +0100237
Heiko Schocher495956b2019-12-01 11:23:15 +0100238 ret = led_get_by_label(label, &dev);
239 if (ret == 0)
240 led_set_state(dev, state);
241}
242
243static void setup_board_gpio(void)
244{
245 setup_one_led("led_ena", LEDST_ON);
Heiko Schochera051ee92019-12-01 11:23:11 +0100246 /* switch off Status LEDs */
Heiko Schocher495956b2019-12-01 11:23:15 +0100247 setup_one_led("led_yellow", LEDST_OFF);
248 setup_one_led("led_red", LEDST_OFF);
249 setup_one_led("led_green", LEDST_OFF);
250 setup_one_led("led_blue", LEDST_OFF);
Heiko Schochera051ee92019-12-01 11:23:11 +0100251}
252
Heiko Schocherc6729682019-12-01 11:23:23 +0100253static void aristainetos_run_rescue_command(int reason)
254{
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100255 char rescue_reason_command[20];
Heiko Schocherc6729682019-12-01 11:23:23 +0100256
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100257 sprintf(rescue_reason_command, "setenv rreason %d", reason);
Heiko Schocherc6729682019-12-01 11:23:23 +0100258 run_command(rescue_reason_command, 0);
259}
260
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100261static int aristainetos_bootmode_settings(void)
Heiko Schocherc6729682019-12-01 11:23:23 +0100262{
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100263 struct gpio_desc *desc;
264 struct src *psrc = (struct src *)SRC_BASE_ADDR;
265 unsigned int sbmr1 = readl(&psrc->sbmr1);
266 char *my_bootdelay;
267 char bootmode = 0;
268 int ret;
Heiko Schocherc6729682019-12-01 11:23:23 +0100269 struct udevice *dev;
270 int off;
Heiko Schocherc6729682019-12-01 11:23:23 +0100271 u8 data[0x10];
272 u8 rescue_reason;
273
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100274 /* jumper controlled reset of the environment */
275 ret = gpio_hog_lookup_name("env_reset", &desc);
276 if (!ret) {
277 if (dm_gpio_get_value(desc)) {
278 printf("\nReset u-boot environment (jumper)\n");
279 run_command("run default_env; saveenv; saveenv", 0);
280 }
281 }
282
Heiko Schocherc6729682019-12-01 11:23:23 +0100283 off = fdt_path_offset(gd->fdt_blob, "eeprom0");
284 if (off < 0) {
285 printf("%s: No eeprom0 path offset\n", __func__);
286 return off;
287 }
288
289 ret = uclass_get_device_by_of_offset(UCLASS_I2C_EEPROM, off, &dev);
290 if (ret) {
291 printf("%s: Could not find EEPROM\n", __func__);
292 return ret;
293 }
294
295 ret = i2c_set_chip_offset_len(dev, 2);
296 if (ret)
297 return ret;
298
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100299 ret = i2c_eeprom_read(dev, 0x1ff0, (uint8_t *)data, sizeof(data));
Heiko Schocherc6729682019-12-01 11:23:23 +0100300 if (ret) {
301 printf("%s: Could not read EEPROM\n", __func__);
302 return ret;
303 }
304
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100305 /* software controlled reset of the environment (EEPROM magic) */
306 if (strncmp((char *)data, "DeF", 3) == 0) {
Heiko Schocherc6729682019-12-01 11:23:23 +0100307 memset(data, 0xff, 3);
308 i2c_eeprom_write(dev, 0x1ff0, (uint8_t *)data, 3);
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100309 printf("\nReset u-boot environment (EEPROM)\n");
Heiko Schocherc6729682019-12-01 11:23:23 +0100310 run_command("run default_env; saveenv; saveenv", 0);
311 }
312
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100313 if (sbmr1 & 0x40) {
314 env_set("bootmode", "1");
315 printf("SD bootmode jumper set!\n");
316 } else {
317 env_set("bootmode", "0");
318 }
Heiko Schochera051ee92019-12-01 11:23:11 +0100319
320 /*
321 * Check the boot-source. If booting from NOR Flash,
322 * disable bootdelay
323 */
Heiko Schochere3379da2019-12-01 11:23:26 +0100324 ret = gpio_hog_lookup_name("bootsel0", &desc);
325 if (!ret)
Heiko Schocher495956b2019-12-01 11:23:15 +0100326 bootmode |= (dm_gpio_get_value(desc) ? 1 : 0) << 0;
Heiko Schochere3379da2019-12-01 11:23:26 +0100327 ret = gpio_hog_lookup_name("bootsel1", &desc);
328 if (!ret)
Heiko Schocher495956b2019-12-01 11:23:15 +0100329 bootmode |= (dm_gpio_get_value(desc) ? 1 : 0) << 1;
Heiko Schochere3379da2019-12-01 11:23:26 +0100330 ret = gpio_hog_lookup_name("bootsel2", &desc);
331 if (!ret)
Heiko Schocher495956b2019-12-01 11:23:15 +0100332 bootmode |= (dm_gpio_get_value(desc) ? 1 : 0) << 2;
Heiko Schochera051ee92019-12-01 11:23:11 +0100333
334 if (bootmode == 7) {
335 my_bootdelay = env_get("nor_bootdelay");
Heiko Schochere3379da2019-12-01 11:23:26 +0100336 if (my_bootdelay)
Heiko Schochera051ee92019-12-01 11:23:11 +0100337 env_set("bootdelay", my_bootdelay);
338 else
339 env_set("bootdelay", "-2");
340 }
341
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100342 /* jumper controlled boot of the rescue system */
Heiko Schocher495956b2019-12-01 11:23:15 +0100343 ret = gpio_hog_lookup_name("boot_rescue", &desc);
344 if (!ret) {
345 if (dm_gpio_get_value(desc)) {
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100346 printf("\nBooting into Rescue System (jumper)\n");
Heiko Schocher495956b2019-12-01 11:23:15 +0100347 aristainetos_run_rescue_command(16);
348 run_command("run rescue_xload_boot", 0);
349 }
350 }
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100351
352 /* software controlled boot of the rescue system (EEPROM magic) */
353 if (strncmp((char *)&data[3], "ReScUe", 6) == 0) {
354 rescue_reason = *(uint8_t *)&data[9];
355 memset(&data[3], 0xff, 7);
356 i2c_eeprom_write(dev, 0x1ff0, (uint8_t *)&data[3], 7);
357 printf("\nBooting into Rescue System (EEPROM)\n");
358 aristainetos_run_rescue_command(rescue_reason);
359 run_command("run rescue_xload_boot", 0);
360 }
361
362 return 0;
Heiko Schochere3379da2019-12-01 11:23:26 +0100363}
364
Heiko Schocherf5210a92020-03-02 09:44:03 +0100365#if defined(CONFIG_DM_PMIC_DA9063)
366/*
367 * On the aristainetos2c boards the PMIC needs to be initialized,
368 * because the Ethernet PHY uses a different regulator that is not
369 * setup per hardware default. This does not influence the other versions
370 * as this regulator isn't used there at all.
371 *
372 * Unfortunately we have not yet a interface to setup all
373 * values we need.
374 */
375static int setup_pmic_voltages(void)
376{
377 struct udevice *dev;
378 int off;
379 int ret;
380
381 off = fdt_path_offset(gd->fdt_blob, "pmic0");
382 if (off < 0) {
383 printf("%s: No pmic path offset\n", __func__);
384 return off;
385 }
386
387 ret = uclass_get_device_by_of_offset(UCLASS_PMIC, off, &dev);
388 if (ret) {
389 printf("%s: Could not find PMIC\n", __func__);
390 return ret;
391 }
392
393 pmic_reg_write(dev, DA9063_REG_PAGE_CON, 0x01);
394 pmic_reg_write(dev, DA9063_REG_BPRO_CFG, 0xc1);
395 ret = pmic_reg_read(dev, DA9063_REG_BUCK_ILIM_B);
396 if (ret < 0) {
397 printf("%s: error %d get register\n", __func__, ret);
398 return ret;
399 }
400 ret &= 0xf0;
401 ret |= 0x09;
402 pmic_reg_write(dev, DA9063_REG_BUCK_ILIM_B, ret);
403 pmic_reg_write(dev, DA9063_REG_VBPRO_A, 0x43);
404 pmic_reg_write(dev, DA9063_REG_VBPRO_B, 0xc3);
405
406 return 0;
407}
408#else
409static int setup_pmic_voltages(void)
410{
411 return 0;
412}
413#endif
414
Heiko Schochere3379da2019-12-01 11:23:26 +0100415int board_late_init(void)
416{
417 int x, y;
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100418 int ret;
Heiko Schochere3379da2019-12-01 11:23:26 +0100419
420 led_default_state();
421 splash_get_pos(&x, &y);
422 bmp_display((ulong)&bmp_logo_bitmap[0], x, y);
423
Heiko Schocher5a0baf42020-11-30 20:46:02 +0100424 ret = aristainetos_bootmode_settings();
425 if (ret)
426 return ret;
Heiko Schocherc6729682019-12-01 11:23:23 +0100427
Heiko Schocher54333792019-12-01 11:23:12 +0100428 /* set board_type */
429 if (gd->board_type == BOARD_TYPE_4)
430 env_set("board_type", ARI_BT_4);
431 else
432 env_set("board_type", ARI_BT_7);
Heiko Schochere3379da2019-12-01 11:23:26 +0100433
Heiko Schocherf5210a92020-03-02 09:44:03 +0100434 if (setup_pmic_voltages())
435 printf("Error setup PMIC\n");
436
Heiko Schochera051ee92019-12-01 11:23:11 +0100437 return 0;
438}
Heiko Schocher05729822015-05-18 13:32:31 +0200439
Heiko Schocher05729822015-05-18 13:32:31 +0200440int dram_init(void)
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200441{
Fabio Estevam1b23fe52016-07-23 13:23:39 -0300442 gd->ram_size = imx_ddr_size();
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200443
Heiko Schocher05729822015-05-18 13:32:31 +0200444 return 0;
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200445}
446
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200447struct display_info_t const displays[] = {
448 {
449 .bus = -1,
450 .addr = 0,
451 .pixfmt = IPU_PIX_FMT_RGB24,
452 .detect = NULL,
453 .enable = enable_lvds,
454 .mode = {
455 .name = "lb07wv8",
456 .refresh = 60,
457 .xres = 800,
458 .yres = 480,
Heiko Schocher27813292015-08-11 08:09:44 +0200459 .pixclock = 30066,
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200460 .left_margin = 88,
461 .right_margin = 88,
Heiko Schocher27813292015-08-11 08:09:44 +0200462 .upper_margin = 20,
463 .lower_margin = 20,
Heiko Schocher69f0e442015-01-20 10:06:18 +0100464 .hsync_len = 80,
Heiko Schocher27813292015-08-11 08:09:44 +0200465 .vsync_len = 5,
466 .sync = FB_SYNC_EXT,
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200467 .vmode = FB_VMODE_NONINTERLACED
468 }
469 }
470};
471size_t display_count = ARRAY_SIZE(displays);
472
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200473int board_init(void)
474{
475 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
476
477 /* address of boot parameters */
478 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
479
Heiko Schocher05729822015-05-18 13:32:31 +0200480 setup_board_gpio();
Heiko Schocher8f4a1b92019-12-01 11:23:19 +0100481 setup_display();
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200482
483 /* GPIO_1 for USB_OTG_ID */
Heiko Schocher05729822015-05-18 13:32:31 +0200484 clrsetbits_le32(&iomux->gpr[1], IOMUXC_GPR1_USB_OTG_ID_SEL_MASK, 0);
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200485 return 0;
486}
487
Heiko Schocher54333792019-12-01 11:23:12 +0100488int board_fit_config_name_match(const char *name)
489{
490 if (gd->board_type == BOARD_TYPE_4 &&
491 strchr(name, 0x34))
492 return 0;
493
494 if (gd->board_type == BOARD_TYPE_7 &&
495 strchr(name, 0x37))
496 return 0;
497
498 return -1;
499}
500
501static void do_board_detect(void)
502{
503 int ret;
504 char s[30];
505
506 /* default use board type 7 */
507 gd->board_type = BOARD_TYPE_7;
508 if (env_init())
509 return;
510
511 ret = env_get_f("panel", s, sizeof(s));
512 if (ret < 0)
513 return;
514
515 if (!strncmp("lg4573", s, 6))
516 gd->board_type = BOARD_TYPE_4;
517}
518
519#ifdef CONFIG_DTB_RESELECT
520int embedded_dtb_select(void)
521{
522 int rescan;
523
524 do_board_detect();
525 fdtdec_resetup(&rescan);
526
Heiko Schocherf853c6c2014-07-18 06:07:22 +0200527 return 0;
528}
529#endif