/*
* Copyright (C) 2012-2015 Lothar Waßmann <LW@KARO-electronics.de>
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * SPDX-License-Identifier: GPL-2.0+
*
*/
#include <common.h>
#define MUX_CFG_SION IOMUX_PAD(0, 0, IOMUX_CONFIG_SION, 0, 0, 0)
-enum {
- MX6_PAD_DECL(GARBAGE, 0, 0, 0, 0, 0, 0)
-};
-
char __uboot_img_end[0] __attribute__((section(".__uboot_img_end")));
#ifdef CONFIG_SECURE_BOOT
char __csf_data[0] __attribute__((section(".__csf_data")));
/* placed in section '.data' to prevent overwriting relocation info
* overlayed with bss
*/
-static u32 wrsr __attribute__((section(".data")));
+static u32 wrsr __data;
#define WRSR_POR (1 << 4)
#define WRSR_TOUT (1 << 1)
static const char __data *tx6_mod_suffix;
+#ifdef CONFIG_IMX6_THERMAL
+#include <thermal.h>
+#include <imx_thermal.h>
+#include <fuse.h>
+
+static void print_temperature(void)
+{
+ struct udevice *thermal_dev;
+ int cpu_tmp, minc, maxc, ret;
+ char const *grade_str;
+ static u32 __data thermal_calib;
+
+ puts("Temperature: ");
+ switch (get_cpu_temp_grade(&minc, &maxc)) {
+ case TEMP_AUTOMOTIVE:
+ grade_str = "Automotive";
+ break;
+ case TEMP_INDUSTRIAL:
+ grade_str = "Industrial";
+ break;
+ case TEMP_EXTCOMMERCIAL:
+ grade_str = "Extended Commercial";
+ break;
+ default:
+ grade_str = "Commercial";
+ }
+ printf("%s grade (%dC to %dC)", grade_str, minc, maxc);
+ ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev);
+ if (ret == 0) {
+ ret = thermal_get_temp(thermal_dev, &cpu_tmp);
+
+ if (ret == 0)
+ printf(" at %dC", cpu_tmp);
+ else
+ puts(" - failed to read sensor data");
+ } else {
+ puts(" - no sensor device found");
+ }
+
+ if (fuse_read(1, 6, &thermal_calib) == 0) {
+ printf(" - calibration data 0x%08x\n", thermal_calib);
+ } else {
+ puts(" - Failed to read thermal calib fuse\n");
+ }
+}
+#else
+static inline void print_temperature(void)
+{
+}
+#endif
+
int checkboard(void)
{
u32 cpurev = get_cpu_rev();
char *cpu_str = "?";
- switch ((cpurev >> 12) & 0xff) {
- case MXC_CPU_MX6SL:
+ if (is_cpu_type(MXC_CPU_MX6SL)) {
cpu_str = "SL";
tx6_mod_suffix = "?";
- break;
- case MXC_CPU_MX6DL:
+ } else if (is_cpu_type(MXC_CPU_MX6DL)) {
cpu_str = "DL";
tx6_mod_suffix = "U";
- break;
- case MXC_CPU_MX6SOLO:
+ } else if (is_cpu_type(MXC_CPU_MX6SOLO)) {
cpu_str = "SOLO";
tx6_mod_suffix = "S";
- break;
- case MXC_CPU_MX6Q:
+ } else if (is_cpu_type(MXC_CPU_MX6Q)) {
cpu_str = "Q";
tx6_mod_suffix = "Q";
- break;
+ } else if (is_cpu_type(MXC_CPU_MX6QP)) {
+ cpu_str = "QP";
+ tx6_mod_suffix = "QP";
}
- printf("CPU: Freescale i.MX6%s rev%d.%d at %d MHz\n",
+ printf("CPU: Freescale i.MX6%s rev%d.%d at %d MHz\n",
cpu_str,
(cpurev & 0x000F0) >> 4,
(cpurev & 0x0000F) >> 0,
mxc_get_clock(MXC_ARM_CLK) / 1000000);
+ print_temperature();
print_reset_cause();
#ifdef CONFIG_MX6_TEMPERATURE_HOT
check_cpu_temperature(1);
return 0;
}
+/* serial port not initialized at this point */
int board_early_init_f(void)
{
- debug("%s@%d: \n", __func__, __LINE__);
-
return 0;
}
#endif
#endif /* CONFIG_TX6_NAND */
-#define TX6_DDR_SZ (ffs(PHYS_SDRAM_1_WIDTH / 16) - 1)
+#define TX6_DDR_SZ (ffs(CONFIG_SYS_SDRAM_BUS_WIDTH / 16) - 1)
static char tx6_mem_table[] = {
- '4', /* 256MiB SDRAM 16bit; 128MiB NAND */
- '1', /* 512MiB SDRAM 32bit; 128MiB NAND */
- '0', /* 1GiB SDRAM 64bit; 128MiB NAND */
- '?', /* 256MiB SDRAM 16bit; 256MiB NAND */
- '?', /* 512MiB SDRAM 32bit; 256MiB NAND */
- '2', /* 1GiB SDRAM 64bit; 256MiB NAND */
- '?', /* 256MiB SDRAM 16bit; 4GiB eMMC */
- '5', /* 512MiB SDRAM 32bit; 4GiB eMMC */
- '3', /* 1GiB SDRAM 64bit; 4GiB eMMC */
- '?', /* 256MiB SDRAM 16bit; 8GiB eMMC */
- '?', /* 512MiB SDRAM 32bit; 8GiB eMMC */
- '0', /* 1GiB SDRAM 64bit; 8GiB eMMC */
+ '4', /* TX6S-8034 256MiB SDRAM 16bit; 128MiB NAND */
+ '1', /* TX6U-8011 512MiB SDRAM 32bit; 128MiB NAND */
+ '0', /* TX6Q-1030/TX6U-8030 1GiB SDRAM 64bit; 128MiB NAND */
+ '?', /* N/A 256MiB SDRAM 16bit; 256MiB NAND */
+ '?', /* N/A 512MiB SDRAM 32bit; 256MiB NAND */
+ '2', /* TX6U-8012 1GiB SDRAM 64bit; 256MiB NAND */
+ '?', /* N/A 256MiB SDRAM 16bit; 4GiB eMMC */
+ '5', /* TX6S-8035 512MiB SDRAM 32bit; 4GiB eMMC */
+ '3', /* TX6U-8033 1GiB SDRAM 64bit; 4GiB eMMC */
+ '?', /* N/A 256MiB SDRAM 16bit; 8GiB eMMC */
+ '?', /* N/A 512MiB SDRAM 32bit; 8GiB eMMC */
+#if defined(CONFIG_TX6_REV) && CONFIG_TX6_REV == 2
+ '0', /* TX6Q-1020 (legacy) 1GiB SDRAM 64bit; 8GiB eMMC */
+#else
+ '6', /* TX6Q-1036 1GiB SDRAM 64bit; 8GiB eMMC */
+#endif
};
static struct {
if (mem_idx >= ARRAY_SIZE(tx6_mem_table))
return '?';
-
+ if (CONFIG_SYS_SDRAM_CHIP_SIZE > 512)
+ return '7';
+ if (mem_idx == 8)
+ return is_cpu_type(MXC_CPU_MX6Q) ? '6' : '3';
return tx6_mem_table[mem_idx];
};
debug("%s@%d: \n", __func__, __LINE__);
-// i2c_init_all();
-
for (i = 0; i < ARRAY_SIZE(tx6_mod_revs); i++) {
u8 i2c_addr = tx6_mod_revs[i].addr;
int ret = i2c_probe(i2c_addr);
return -EINVAL;
}
-static inline int __checkboard(void)
-{
- u32 cpurev = get_cpu_rev();
- int cpu_variant = (cpurev >> 12) & 0xff;
- int pmic_id;
-
- debug("%s@%d: \n", __func__, __LINE__);
-
- pmic_id = tx6_pmic_probe();
- if (pmic_id >= 0)
- pmic_addr = tx6_mod_revs[pmic_id].addr;
-
- printf("Board: Ka-Ro TX6%s-%d%d%d%c\n",
- tx6_mod_suffix,
- cpu_variant == MXC_CPU_MX6Q ? 1 : 8,
- is_lvds(), tx6_get_mod_rev(pmic_id),
- tx6_mem_suffix());
-
- get_hab_status();
-
- debug("%s@%d: done\n", __func__, __LINE__);
- return 0;
-}
-
int board_init(void)
{
int ret;
- u32 cpurev = get_cpu_rev();
- int cpu_variant = (cpurev >> 12) & 0xff;
int pmic_id;
debug("%s@%d: \n", __func__, __LINE__);
pmic_id = tx6_pmic_probe();
- if (pmic_id >= 0)
+ if (pmic_id >= 0 && pmic_id < ARRAY_SIZE(tx6_mod_revs))
pmic_addr = tx6_mod_revs[pmic_id].addr;
printf("Board: Ka-Ro TX6%s-%d%d%d%c\n",
tx6_mod_suffix,
- cpu_variant == MXC_CPU_MX6Q ? 1 : 8,
+ is_cpu_type(MXC_CPU_MX6Q) ? 1 : 8,
is_lvds(), tx6_get_mod_rev(pmic_id),
tx6_mem_suffix());
return 0;
}
- ret = tx6_pmic_init(pmic_addr);
+ ret = tx6_pmic_init(pmic_addr, NULL, 0);
if (ret) {
printf("Failed to setup PMIC voltages: %d\n", ret);
hang();
void dram_init_banksize(void)
{
- debug("%s@%d: \n", __func__, __LINE__);
-
+ debug("%s@%d: chip_size=%u (%u bit bus width)\n", __func__, __LINE__,
+ CONFIG_SYS_SDRAM_CHIP_SIZE, CONFIG_SYS_SDRAM_BUS_WIDTH);
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
gd->bd->bi_dram[0].size = get_ram_size((void *)PHYS_SDRAM_1,
PHYS_SDRAM_1_SIZE);
{
u8 mac[ETH_ALEN];
- imx_get_mac_from_fuse(-1, mac);
+ imx_get_mac_from_fuse(0, mac);
if (!is_valid_ethaddr(mac)) {
printf("No valid MAC address programmed\n");
return;
};
#ifdef CONFIG_LCD
-static u16 tx6_cmap[256];
vidinfo_t panel_info = {
/* set to max. size supported by SoC */
.vl_col = 1920,
.vl_row = 1080,
.vl_bpix = LCD_COLOR32, /* Bits per pixel, 0: 1bpp, 1: 2bpp, 2: 4bpp, 3: 8bpp ... */
- .cmap = tx6_cmap,
};
static struct fb_videomode tx6_fb_modes[] = {
if (!lcd_enabled) {
debug("LCD disabled\n");
+ goto disable;
return;
}
debug("Disabling LCD\n");
lcd_enabled = 0;
setenv("splashimage", NULL);
+ goto disable;
return;
}
if (video_mode == NULL) {
debug("Disabling LCD\n");
lcd_enabled = 0;
+ goto disable;
return;
}
vm = video_mode;
fb_mode.xres, fb_mode.yres,
panel_info.vl_col, panel_info.vl_row);
lcd_enabled = 0;
+ goto disable;
return;
}
}
printf(" %s", p->name);
}
printf("\n");
+ goto disable;
return;
}
if (p->xres > panel_info.vl_col || p->yres > panel_info.vl_row) {
printf("video resolution: %dx%d exceeds hardware limits: %dx%d\n",
p->xres, p->yres, panel_info.vl_col, panel_info.vl_row);
lcd_enabled = 0;
+ goto disable;
return;
}
panel_info.vl_col = p->xres;
lcd_enabled = 0;
printf("Invalid %s bus width: %d\n", is_lvds() ? "LVDS" : "LCD",
lcd_bus_width);
+ goto disable;
return;
}
if (is_lvds()) {
if (lvds_chan_mask == 0) {
printf("No LVDS channel active\n");
lcd_enabled = 0;
+ goto disable;
return;
}
} else {
debug("Skipping initialization of LCD controller\n");
}
+ return;
+
+disable:
+ lcd_enabled = 0;
+ panel_info.vl_col = 0;
+ panel_info.vl_row = 0;
+
}
#else
#define lcd_enabled 0
int board_late_init(void)
{
- int ret = 0;
const char *baseboard;
-#if 1
- /* override secure_boot fuse */
- struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
- struct fuse_bank0_regs *fuse = (void *)ocotp->bank[0].fuse_regs;
-
- writel(0x12, &fuse->cfg5);
-#endif
debug("%s@%d: \n", __func__, __LINE__);
} else {
printf("WARNING: Unsupported baseboard: '%s'\n",
baseboard);
- ret = -EINVAL;
+ if (!had_ctrlc())
+ return -EINVAL;
}
exit:
gpio_set_value(TX6_RESET_OUT_GPIO, 1);
clear_ctrlc();
- return ret;
+ return 0;
}
#ifdef CONFIG_SERIAL_TAG
karo_fdt_enable_node(blob, "stk5led", 0);
fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
- fdt_fixup_ethernet(blob);
karo_fdt_fixup_touchpanel(blob, tx6_touchpanels,
ARRAY_SIZE(tx6_touchpanels));