]> git.sur5r.net Git - u-boot/blobdiff - board/freescale/mx51evk/mx51evk.c
pmic: Extend PMIC framework to support multiple instances of PMIC devices
[u-boot] / board / freescale / mx51evk / mx51evk.c
index 13c59413ecfddcd3c47d7928bb9b2c5b649a1dfb..5504636ddf411505664a623bcc1f987b96d1f2b2 100644 (file)
 #include <asm/errno.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/crm_regs.h>
+#include <asm/arch/clock.h>
 #include <i2c.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
-#include <pmic.h>
+#include <power/pmic.h>
 #include <fsl_pmic.h>
 #include <mc13892.h>
 #include <usb/ehci-fsl.h>
+#include <linux/fb.h>
+#include <ipu_pixfmt.h>
+
+#define MX51EVK_LCD_3V3                IMX_GPIO_NR(4, 9)
+#define MX51EVK_LCD_5V         IMX_GPIO_NR(4, 10)
+#define MX51EVK_LCD_BACKLIGHT  IMX_GPIO_NR(3, 4)
 
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_FSL_ESDHC
 struct fsl_esdhc_cfg esdhc_cfg[2] = {
-       {MMC_SDHC1_BASE_ADDR, 1},
-       {MMC_SDHC2_BASE_ADDR, 1},
+       {MMC_SDHC1_BASE_ADDR},
+       {MMC_SDHC2_BASE_ADDR},
 };
 #endif
 
@@ -54,6 +61,14 @@ int dram_init(void)
        return 0;
 }
 
+u32 get_board_rev(void)
+{
+       u32 rev = get_cpu_rev();
+       if (!gpio_get_value(IMX_GPIO_NR(1, 22)))
+               rev |= BOARD_REV_2_0 << BOARD_VER_OFFSET;
+       return rev;
+}
+
 static void setup_iomux_uart(void)
 {
        unsigned int pad = PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE |
@@ -203,7 +218,7 @@ static void setup_usb_h1(void)
        mxc_iomux_set_pad(MX51_PIN_EIM_D21, GPIO_PAD);
 }
 
-void board_ehci_hcd_init(int port)
+int board_ehci_hcd_init(int port)
 {
        /* Set USBH1_STP to GPIO and toggle it */
        mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_GPIO);
@@ -228,6 +243,7 @@ void board_ehci_hcd_init(int port)
        gpio_direction_output(MX51EVK_USBH1_HUB_RST, 0);
        mdelay(2);
        gpio_set_value(MX51EVK_USBH1_HUB_RST, 1);
+       return 0;
 }
 #endif
 
@@ -236,9 +252,15 @@ static void power_init(void)
        unsigned int val;
        struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
        struct pmic *p;
+       int ret;
+
+       ret = pmic_init(I2C_PMIC);
+       if (ret)
+               return;
 
-       pmic_init();
-       p = get_pmic();
+       p = pmic_get("FSL_PMIC");
+       if (!p)
+               return;
 
        /* Write needed to Power Gate 2 register */
        pmic_reg_read(p, REG_POWER_MISC, &val);
@@ -312,27 +334,30 @@ static void power_init(void)
        pmic_reg_write(p, REG_MODE_1, val);
 
        mxc_request_iomux(MX51_PIN_EIM_A20, IOMUX_CONFIG_ALT1);
-       gpio_direction_output(46, 0);
+       gpio_direction_output(IMX_GPIO_NR(2, 14), 0);
 
        udelay(500);
 
-       gpio_set_value(46, 1);
+       gpio_set_value(IMX_GPIO_NR(2, 14), 1);
 }
 
 #ifdef CONFIG_FSL_ESDHC
-int board_mmc_getcd(u8 *cd, struct mmc *mmc)
+int board_mmc_getcd(struct mmc *mmc)
 {
        struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
+       int ret;
 
        mxc_request_iomux(MX51_PIN_GPIO1_0, IOMUX_CONFIG_ALT1);
+       gpio_direction_input(IMX_GPIO_NR(1, 0));
        mxc_request_iomux(MX51_PIN_GPIO1_6, IOMUX_CONFIG_ALT0);
+       gpio_direction_input(IMX_GPIO_NR(1, 6));
 
        if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
-               *cd = gpio_get_value(0);
+               ret = !gpio_get_value(IMX_GPIO_NR(1, 0));
        else
-               *cd = gpio_get_value(6);
+               ret = !gpio_get_value(IMX_GPIO_NR(1, 6));
 
-       return 0;
+       return ret;
 }
 
 int board_mmc_init(bd_t *bis)
@@ -340,6 +365,9 @@ int board_mmc_init(bd_t *bis)
        u32 index;
        s32 status = 0;
 
+       esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+       esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
+
        for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM;
                        index++) {
                switch (index) {
@@ -449,6 +477,54 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+static struct fb_videomode const claa_wvga = {
+       .name           = "CLAA07LC0ACW",
+       .refresh        = 57,
+       .xres           = 800,
+       .yres           = 480,
+       .pixclock       = 37037,
+       .left_margin    = 40,
+       .right_margin   = 60,
+       .upper_margin   = 10,
+       .lower_margin   = 10,
+       .hsync_len      = 20,
+       .vsync_len      = 10,
+       .sync           = 0,
+       .vmode          = FB_VMODE_NONINTERLACED
+};
+
+void lcd_iomux(void)
+{
+       /* DI2_PIN15 */
+       mxc_request_iomux(MX51_PIN_DI_GP4, IOMUX_CONFIG_ALT4);
+
+       /* Pad settings for MX51_PIN_DI2_DISP_CLK */
+       mxc_iomux_set_pad(MX51_PIN_DI2_DISP_CLK, PAD_CTL_HYS_NONE |
+                         PAD_CTL_PKE_ENABLE | PAD_CTL_PUE_KEEPER |
+                         PAD_CTL_DRV_MAX | PAD_CTL_SRE_SLOW);
+
+       /* Turn on 3.3V voltage for LCD */
+       mxc_request_iomux(MX51_PIN_CSI2_D12, IOMUX_CONFIG_ALT3);
+       gpio_direction_output(MX51EVK_LCD_3V3, 1);
+
+       /* Turn on 5V voltage for LCD */
+       mxc_request_iomux(MX51_PIN_CSI2_D13, IOMUX_CONFIG_ALT3);
+       gpio_direction_output(MX51EVK_LCD_5V, 1);
+
+       /* Turn on GPIO backlight */
+       mxc_request_iomux(MX51_PIN_DI1_D1_CS, IOMUX_CONFIG_ALT4);
+       mxc_iomux_set_input(MX51_GPIO3_IPP_IND_G_IN_4_SELECT_INPUT,
+                                                       INPUT_CTL_PATH1);
+       gpio_direction_output(MX51EVK_LCD_BACKLIGHT, 1);
+}
+
+void lcd_enable(void)
+{
+       int ret = ipuv3_fb_init(&claa_wvga, 1, IPU_PIX_FMT_RGB565);
+       if (ret)
+               printf("LCD cannot be configured: %d\n", ret);
+}
+
 int board_early_init_f(void)
 {
        setup_iomux_uart();
@@ -456,6 +532,7 @@ int board_early_init_f(void)
 #ifdef CONFIG_USB_EHCI_MX5
        setup_usb_h1();
 #endif
+       lcd_iomux();
 
        return 0;
 }
@@ -465,6 +542,8 @@ int board_init(void)
        /* address of boot parameters */
        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
 
+       lcd_enable();
+
        return 0;
 }
 
@@ -475,10 +554,20 @@ int board_late_init(void)
        setup_iomux_spi();
        power_init();
 #endif
+
        return 0;
 }
 #endif
 
+/*
+ * Do not overwrite the console
+ * Use always serial for U-Boot console
+ */
+int overwrite_console(void)
+{
+       return 1;
+}
+
 int checkboard(void)
 {
        puts("Board: MX51EVK\n");