]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/karo/tx6/tx6qdl.c
karo: tx6: use GP1 fuse for MIPI variant detection
[karo-tx-uboot.git] / board / karo / tx6 / tx6qdl.c
index dcc6f175de6ff05a82c0d6ac0fec08ee4ac3ce93..bb57a796e15e3c2adb909b906a4dacdeb978cde0 100644 (file)
@@ -430,20 +430,65 @@ static char tx6_mem_table[] = {
        '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
 };
 
+#ifdef CONFIG_RN5T567
+/* PMIC settings */
+#define VDD_RTC_VAL            rn5t_mV_to_regval_rtc(3000)
+#define VDD_CORE_VAL           rn5t_mV_to_regval(1400)         /* DCDC1 */
+#define VDD_CORE_VAL_LP                rn5t_mV_to_regval(900)
+#define VDD_SOC_VAL            rn5t_mV_to_regval(1400)         /* DCDC2 */
+#define VDD_SOC_VAL_LP         rn5t_mV_to_regval(1400)
+#define VDD_DDR_VAL            rn5t_mV_to_regval(1350)         /* DCDC3 */
+#define VDD_DDR_VAL_LP         rn5t_mV_to_regval(1350)
+#define VDD_HIGH_VAL           rn5t_mV_to_regval(3000)         /* DCDC4 */
+#define VDD_HIGH_VAL_LP                rn5t_mV_to_regval(3000)
+#define VDD_IO_INT_VAL         rn5t_mV_to_regval2(3300)        /* LDO1 */
+#define VDD_IO_INT_VAL_LP      rn5t_mV_to_regval2(3300)
+#define VDD_IO_EXT_VAL         rn5t_mV_to_regval2(3300)        /* LDO2 */
+#define VDD_IO_EXT_VAL_LP      rn5t_mV_to_regval2(3300)
+
+static struct pmic_regs rn5t567_regs[] = {
+       { RN5T567_NOETIMSET, 0x5, },
+       { RN5T567_DC1DAC, VDD_CORE_VAL, },
+       { RN5T567_DC2DAC, VDD_SOC_VAL, },
+       { RN5T567_DC3DAC, VDD_DDR_VAL, },
+       { RN5T567_DC4DAC, VDD_HIGH_VAL, },
+       { RN5T567_DC1DAC_SLP, VDD_CORE_VAL_LP, },
+       { RN5T567_DC2DAC_SLP, VDD_SOC_VAL_LP, },
+       { RN5T567_DC3DAC_SLP, VDD_DDR_VAL_LP, },
+       { RN5T567_DC4DAC_SLP, VDD_HIGH_VAL_LP, },
+       { RN5T567_DC1CTL, DCnCTL_DCnEN | DCnMODE_SLP(DCnMODE_PSM), },
+       { RN5T567_DC2CTL, DCnCTL_DCnEN | DCnMODE_SLP(DCnMODE_PSM), },
+       { RN5T567_DC3CTL, DCnCTL_DCnEN | DCnMODE_SLP(DCnMODE_PSM), },
+       { RN5T567_DC4CTL, DCnCTL_DCnEN | DCnMODE_SLP(DCnMODE_PSM), },
+       { RN5T567_LDORTC1DAC, VDD_RTC_VAL, },
+       { RN5T567_LDORTC1_SLOT, 0x0f, ~0x3f, },
+       { RN5T567_LDO1DAC, VDD_IO_INT_VAL, },
+       { RN5T567_LDO2DAC, VDD_IO_EXT_VAL, },
+       { RN5T567_LDOEN1, 0x03, ~0x1f, },
+       { RN5T567_LDOEN2, 0x10, ~0x30, },
+       { RN5T567_LDODIS, 0x1c, ~0x1f, },
+       { RN5T567_INTPOL, 0, },
+       { RN5T567_INTEN, 0x3, },
+       { RN5T567_IREN, 0xf, },
+       { RN5T567_EN_GPIR, 0, },
+};
+#endif
+
 static struct {
        uchar addr;
        uchar rev;
+       struct pmic_regs *regs;
+       size_t num_regs;
 } tx6_mod_revs[] = {
-       { 0x3c, 1, },
-       { 0x32, 2, },
-       { 0x33, 3, },
+#ifdef CONFIG_LTC3676
+       { 0x3c, 1, NULL, 0, },
+#endif
+#ifdef CONFIG_RN5T567
+       { 0x33, 3, rn5t567_regs, ARRAY_SIZE(rn5t567_regs), },
+#endif
 };
 
 static inline char tx6_mem_suffix(void)
@@ -489,6 +534,16 @@ static int tx6_pmic_probe(void)
        return -EINVAL;
 }
 
+static int tx6_mipi(void)
+{
+       struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+       struct fuse_bank4_regs *fuse = (void *)ocotp->bank[4].fuse_regs;
+       u32 gp1 = readl(&fuse->gp1);
+
+       debug("Fuse gp1 @ %p = %08x\n", &fuse->gp1, gp1);
+       return gp1 & 1;
+}
+
 int board_init(void)
 {
        int ret;
@@ -503,7 +558,7 @@ int board_init(void)
        printf("Board: Ka-Ro TX6%s-%d%d%d%c\n",
                tx6_mod_suffix,
                is_cpu_type(MXC_CPU_MX6Q) ? 1 : 8,
-               is_lvds(), tx6_get_mod_rev(pmic_id),
+               tx6_mipi() ? 2 : is_lvds(), tx6_get_mod_rev(pmic_id),
                tx6_mem_suffix());
 
        get_hab_status();
@@ -529,7 +584,8 @@ int board_init(void)
                return 0;
        }
 
-       ret = tx6_pmic_init(pmic_addr, NULL, 0);
+       ret = tx6_pmic_init(pmic_addr, tx6_mod_revs[pmic_id].regs,
+                       tx6_mod_revs[pmic_id].num_regs);
        if (ret) {
                printf("Failed to setup PMIC voltages: %d\n", ret);
                hang();
@@ -1111,7 +1167,6 @@ void lcd_ctrl_init(void *lcdbase)
        if (!lcd_enabled) {
                debug("LCD disabled\n");
                goto disable;
-               return;
        }
 
        if (had_ctrlc() || (wrsr & WRSR_TOUT)) {
@@ -1119,7 +1174,6 @@ void lcd_ctrl_init(void *lcdbase)
                lcd_enabled = 0;
                setenv("splashimage", NULL);
                goto disable;
-               return;
        }
 
        karo_fdt_move_fdt();
@@ -1129,7 +1183,6 @@ void lcd_ctrl_init(void *lcdbase)
                debug("Disabling LCD\n");
                lcd_enabled = 0;
                goto disable;
-               return;
        }
        vm = video_mode;
        if (karo_fdt_get_fb_mode(working_fdt, video_mode, &fb_mode) == 0) {
@@ -1143,7 +1196,6 @@ void lcd_ctrl_init(void *lcdbase)
                                panel_info.vl_col, panel_info.vl_row);
                        lcd_enabled = 0;
                        goto disable;
-                       return;
                }
        }
        if (p->name != NULL)
@@ -1235,14 +1287,12 @@ void lcd_ctrl_init(void *lcdbase)
                }
                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;
        panel_info.vl_row = p->yres;
@@ -1301,7 +1351,6 @@ void lcd_ctrl_init(void *lcdbase)
                printf("Invalid %s bus width: %d\n", is_lvds() ? "LVDS" : "LCD",
                        lcd_bus_width);
                goto disable;
-               return;
        }
        if (is_lvds()) {
                int lvds_mapping = karo_fdt_get_lvds_mapping(working_fdt, 0);
@@ -1313,7 +1362,6 @@ void lcd_ctrl_init(void *lcdbase)
                        printf("No LVDS channel active\n");
                        lcd_enabled = 0;
                        goto disable;
-                       return;
                }
 
                gpr2 = (lvds_mapping << 6) | (lvds_mapping << 8);