diff options
Diffstat (limited to 'roms/u-boot/board/k+p/kp_imx53')
-rw-r--r-- | roms/u-boot/board/k+p/kp_imx53/Kconfig | 15 | ||||
-rw-r--r-- | roms/u-boot/board/k+p/kp_imx53/MAINTAINERS | 6 | ||||
-rw-r--r-- | roms/u-boot/board/k+p/kp_imx53/Makefile | 8 | ||||
-rw-r--r-- | roms/u-boot/board/k+p/kp_imx53/kp_id_rev.c | 121 | ||||
-rw-r--r-- | roms/u-boot/board/k+p/kp_imx53/kp_id_rev.h | 27 | ||||
-rw-r--r-- | roms/u-boot/board/k+p/kp_imx53/kp_imx53.c | 205 |
6 files changed, 382 insertions, 0 deletions
diff --git a/roms/u-boot/board/k+p/kp_imx53/Kconfig b/roms/u-boot/board/k+p/kp_imx53/Kconfig new file mode 100644 index 000000000..017c1e30d --- /dev/null +++ b/roms/u-boot/board/k+p/kp_imx53/Kconfig @@ -0,0 +1,15 @@ +if TARGET_KP_IMX53 + +config SYS_BOARD + default "kp_imx53" + +config SYS_VENDOR + default "k+p" + +config SYS_SOC + default "mx5" + +config SYS_CONFIG_NAME + default "kp_imx53" + +endif diff --git a/roms/u-boot/board/k+p/kp_imx53/MAINTAINERS b/roms/u-boot/board/k+p/kp_imx53/MAINTAINERS new file mode 100644 index 000000000..c105a93e7 --- /dev/null +++ b/roms/u-boot/board/k+p/kp_imx53/MAINTAINERS @@ -0,0 +1,6 @@ +KP_IMX53_HSC BOARD +M: Lukasz Majewski <lukma@denx.de> +S: Maintained +F: board/k+p/kp_imx53/ +F: include/configs/kp_imx53.h +F: configs/kp_imx53_defconfig diff --git a/roms/u-boot/board/k+p/kp_imx53/Makefile b/roms/u-boot/board/k+p/kp_imx53/Makefile new file mode 100644 index 000000000..66629c98a --- /dev/null +++ b/roms/u-boot/board/k+p/kp_imx53/Makefile @@ -0,0 +1,8 @@ +# +# Copyright (C) 2018, DENX Software Engineering +# Lukasz Majewski <lukma@denx.de> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += kp_imx53.o kp_id_rev.o diff --git a/roms/u-boot/board/k+p/kp_imx53/kp_id_rev.c b/roms/u-boot/board/k+p/kp_imx53/kp_id_rev.c new file mode 100644 index 000000000..7103a3e0f --- /dev/null +++ b/roms/u-boot/board/k+p/kp_imx53/kp_id_rev.c @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 + * Lukasz Majewski, DENX Software Engineering, lukma@denx.de + * + * Based on code developed by: + * + * Copyright (C) 2012 TQ-Systems GmbH + * Daniel Gericke <daniel.gericke@tqs.de> + */ + +#include <common.h> +#include <env.h> +#include <i2c.h> +#include "kp_id_rev.h" +#include <net.h> + +static int eeprom_has_been_read; +static struct id_eeprom eeprom; + +void show_eeprom(void) +{ + char safe_string[33]; + int i; + u8 *p; + + puts("Module EEPROM:\n"); + /* ID */ + for (i = 0; i <= sizeof(eeprom.id) && 0xff != eeprom.id[i]; ++i) + safe_string[i] = eeprom.id[i]; + safe_string[i] = '\0'; + + if (!strncmp(safe_string, "TQM", 3)) { + printf(" ID: %s\n", safe_string); + env_set("boardtype", safe_string); + } else { + puts(" unknown hardware variant\n"); + } + + /* Serial number */ + for (i = 0; (sizeof(eeprom.serial) >= i) && + (eeprom.serial[i] >= 0x30) && + (eeprom.serial[i] <= 0x39); ++i) + safe_string[i] = eeprom.serial[i]; + safe_string[i] = '\0'; + + if (strlen(safe_string) == 8) { + printf(" SN: %s\n", safe_string); + env_set("serial#", safe_string); + } else { + puts(" unknown serial number\n"); + } + + /* MAC address */ + p = eeprom.mac; + if (!is_valid_ethaddr(p)) { + printf(" Not valid ETH EEPROM addr!\n"); + return; + } + + printf(" MAC: %02x:%02x:%02x:%02x:%02x:%02x\n", + p[0], p[1], p[2], p[3], p[4], p[5]); + + eth_env_set_enetaddr("ethaddr", p); +} + +int read_eeprom(void) +{ + struct udevice *dev; + int ret; + + if (eeprom_has_been_read) + return 0; + + ret = i2c_get_chip_for_busnum(CONFIG_SYS_EEPROM_BUS_NUM, + CONFIG_SYS_I2C_EEPROM_ADDR, + CONFIG_SYS_I2C_EEPROM_ADDR_LEN, &dev); + if (ret) { + printf("Cannot find EEPROM !\n"); + return ret; + } + + ret = dm_i2c_read(dev, 0x0, (uchar *)&eeprom, sizeof(eeprom)); + + eeprom_has_been_read = (ret == 0) ? 1 : 0; + return ret; +} + +int read_board_id(void) +{ + unsigned char rev_id = 0x42; + char rev_str[32], buf[8]; + struct udevice *dev; + int ret; + + ret = i2c_get_chip_for_busnum(2, 0x22, 1, &dev); + if (ret) { + printf("Cannot find pcf8574 IO expander !\n"); + return ret; + } + + dm_i2c_read(dev, 0x0, &rev_id, sizeof(rev_id)); + + sprintf(rev_str, "%02X", rev_id); + if (rev_id & 0x80) { + printf("BBoard:4x00 Rev:%s\n", rev_str); + env_set("boardtype", "ddc"); + env_set("fit_config", "imx53_kb_conf"); + } else { + printf("BBoard:40x0 Rev:%s\n", rev_str); + env_set("boardtype", "hsc"); + env_set("fit_config", "imx53_kb_40x0_conf"); + } + + sprintf(buf, "kp-%s", env_get("boardtype")); + env_set("boardname", buf); + env_set("boardsoc", "imx53"); + env_set("kb53_rev", rev_str); + + return 0; +} diff --git a/roms/u-boot/board/k+p/kp_imx53/kp_id_rev.h b/roms/u-boot/board/k+p/kp_imx53/kp_id_rev.h new file mode 100644 index 000000000..aa6417392 --- /dev/null +++ b/roms/u-boot/board/k+p/kp_imx53/kp_id_rev.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2018 + * Lukasz Majewski, DENX Software Engineering, lukma@denx.de + * + * Based on code developed by: + * + * Copyright (C) 2012 TQ-Systems GmbH + * Daniel Gericke <daniel.gericke@tqs.de> + */ + +#ifndef __KP_ID_REV_H_ +#define __KP_ID_REV_H_ + +struct id_eeprom { + u8 hrcw_primary[0x20]; + u8 mac[6]; /* 0x20 ... 0x25 */ + u8 rsv1[10]; + u8 serial[8]; /* 0x30 ... 0x37 */ + u8 rsv2[8]; + u8 id[0x40]; /* 0x40 ... 0x7f */ +} __packed; + +void show_eeprom(void); +int read_eeprom(void); +int read_board_id(void); +#endif /* __KP_ID_REV_H_ */ diff --git a/roms/u-boot/board/k+p/kp_imx53/kp_imx53.c b/roms/u-boot/board/k+p/kp_imx53/kp_imx53.c new file mode 100644 index 000000000..cc8118b4a --- /dev/null +++ b/roms/u-boot/board/k+p/kp_imx53/kp_imx53.c @@ -0,0 +1,205 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 + * Lukasz Majewski, DENX Software Engineering, lukma@denx.de + */ + +#include <common.h> +#include <init.h> +#include <asm/global_data.h> +#include <asm/io.h> +#include <asm/arch/imx-regs.h> +#include <asm/arch/sys_proto.h> +#include <asm/arch/crm_regs.h> +#include <asm/arch/clock.h> +#include <asm/arch/iomux-mx53.h> +#include <asm/arch/clock.h> +#include <asm/gpio.h> +#include <env.h> +#include <power/pmic.h> +#include <fsl_pmic.h> +#include <bootstage.h> +#include "kp_id_rev.h" + +#define BOOSTER_OFF IMX_GPIO_NR(2, 23) +#define LCD_BACKLIGHT IMX_GPIO_NR(1, 1) +#define KEY1 IMX_GPIO_NR(2, 26) +#define LED_RED IMX_GPIO_NR(3, 28) + +DECLARE_GLOBAL_DATA_PTR; + +int dram_init(void) +{ + u32 size; + + size = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); + gd->ram_size = size; + + return 0; +} + +int dram_init_banksize(void) +{ + gd->bd->bi_dram[0].start = PHYS_SDRAM_1; + gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; + + return 0; +} + +static int power_init(void) +{ + struct udevice *dev; + int ret; + + ret = pmic_get("mc34708@8", &dev); + if (ret) { + printf("%s: mc34708 not found !\n", __func__); + return ret; + } + + /* Set VDDGP to 1.110V for 800 MHz on SW1 */ + pmic_clrsetbits(dev, REG_SW_0, SWx_VOLT_MASK_MC34708, + SWx_1_110V_MC34708); + + /* Set VCC as 1.30V on SW2 */ + pmic_clrsetbits(dev, REG_SW_1, SWx_VOLT_MASK_MC34708, + SWx_1_300V_MC34708); + + /* Set global reset timer to 4s */ + pmic_clrsetbits(dev, REG_POWER_CTL2, TIMER_MASK_MC34708, + TIMER_4S_MC34708); + + return ret; +} + +static void setup_clocks(void) +{ + int ret; + u32 ref_clk = MXC_HCLK; + /* + * CPU clock set to 800MHz and DDR to 400MHz + */ + ret = mxc_set_clock(ref_clk, 800, MXC_ARM_CLK); + if (ret) + printf("CPU: Switch CPU clock to 800MHZ failed\n"); + + ret = mxc_set_clock(ref_clk, 400, MXC_PERIPH_CLK); + ret |= mxc_set_clock(ref_clk, 400, MXC_DDR_CLK); + if (ret) + printf("CPU: Switch DDR clock to 400MHz failed\n"); +} + +static void setup_ups(void) +{ + gpio_request(BOOSTER_OFF, "BOOSTER_OFF"); + gpio_direction_output(BOOSTER_OFF, 0); +} + +int board_early_init_f(void) +{ + return 0; +} + +/* + * Do not overwrite the console + * Use always serial for U-Boot console + */ +int overwrite_console(void) +{ + return 1; +} + +int board_init(void) +{ + gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; + + return 0; +} + +void board_disable_display(void) +{ + gpio_request(LCD_BACKLIGHT, "LCD_BACKLIGHT"); + gpio_direction_output(LCD_BACKLIGHT, 0); +} + +void board_misc_setup(void) +{ + gpio_request(KEY1, "KEY1_GPIO"); + gpio_direction_input(KEY1); + + if (gpio_get_value(KEY1)) + env_set("key1", "off"); + else + env_set("key1", "on"); +} + +int board_late_init(void) +{ + int ret = 0; + + board_disable_display(); + setup_ups(); + + if (!power_init()) + setup_clocks(); + + ret = read_eeprom(); + if (ret) + printf("Error %d reading EEPROM content!\n", ret); + + show_eeprom(); + read_board_id(); + + board_misc_setup(); + + return ret; +} + +#define GPIO_DR 0x0 +#define GPIO_GDIR 0x4 +#define GPIO_ALT1 0x1 +#define GPIO5_BASE 0x53FDC000 +#define IOMUXC_EIM_WAIT 0x53FA81E4 +/* Green LED: GPIO5_0 */ +#define GPIO_GREEN BIT(0) + +void show_boot_progress(int status) +{ + /* + * This BOOTSTAGE_ID is called at very early stage of execution. DM gpio + * is not yet initialized. + */ + if (status == BOOTSTAGE_ID_START_UBOOT_F) { + /* + * After ROM execution the EIM_WAIT PAD is set as ALT0 + * (according to RM it shall be ALT1 after reset). To use it as + * GPIO we need to set it to ALT1. + */ + setbits_le32(((uint32_t *)(IOMUXC_EIM_WAIT)), GPIO_ALT1); + + /* Configure green LED GPIO pin direction */ + setbits_le32(((uint32_t *)(GPIO5_BASE + GPIO_GDIR)), + GPIO_GREEN); + /* Turn on green LED */ + setbits_le32(((uint32_t *)(GPIO5_BASE + GPIO_DR)), GPIO_GREEN); + } + + /* + * This BOOTSTAGE_ID is called just before handling execution to kernel + * - i.e. gpio subsystem is already initialized + */ + if (status == BOOTSTAGE_ID_BOOTM_HANDOFF) { + /* + * Off green LED - the same approach - i.e. non dm gpio + * (*bits_le32) is used as in the very early stage. + */ + clrbits_le32(((uint32_t *)(GPIO5_BASE + GPIO_DR)), + GPIO_GREEN); + + /* + * On red LED + */ + gpio_request(LED_RED, "LED_RED_ERROR"); + gpio_direction_output(LED_RED, 1); + } +} |