]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/freescale/mx6sabresd/mx6sabresd.c
Merge branch 'master' of git://git.denx.de/u-boot-mpc85xx
[karo-tx-uboot.git] / board / freescale / mx6sabresd / mx6sabresd.c
index 12d8c5664ed7a102234059e11b7e473d8deeb263..81dcd6e5ddb879ae3aa4ed9e8a0e800b63929459 100644 (file)
 #include <asm/arch/mx6-pins.h>
 #include <asm/errno.h>
 #include <asm/gpio.h>
+#include <asm/imx-common/mxc_i2c.h>
 #include <asm/imx-common/iomux-v3.h>
 #include <asm/imx-common/boot_mode.h>
+#include <asm/imx-common/video.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
 #include <miiphy.h>
 #include <netdev.h>
 #include <asm/arch/mxc_hdmi.h>
 #include <asm/arch/crm_regs.h>
-#include <linux/fb.h>
-#include <ipu_pixfmt.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
+#include <i2c.h>
+#include <power/pmic.h>
+#include <power/pfuze100_pmic.h>
 DECLARE_GLOBAL_DATA_PTR;
 
 #define UART_PAD_CTRL  (PAD_CTL_PUS_100K_UP |                  \
@@ -40,6 +43,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED | \
                      PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
 
+#define I2C_PAD_CTRL  (PAD_CTL_PUS_100K_UP |                   \
+       PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
+       PAD_CTL_ODE | PAD_CTL_SRE_FAST)
+
+#define I2C_PMIC       1
+
+#define I2C_PAD MUX_PAD_CTRL(I2C_PAD_CTRL)
+
 int dram_init(void)
 {
        gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
@@ -130,11 +141,34 @@ iomux_v3_cfg_t const ecspi1_pads[] = {
        MX6_PAD_KEY_ROW1__GPIO4_IO09 | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
 
+static struct i2c_pads_info i2c_pad_info1 = {
+       .scl = {
+               .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL | I2C_PAD,
+               .gpio_mode = MX6_PAD_KEY_COL3__GPIO4_IO12 | I2C_PAD,
+               .gp = IMX_GPIO_NR(4, 12)
+       },
+       .sda = {
+               .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA | I2C_PAD,
+               .gpio_mode = MX6_PAD_KEY_ROW3__GPIO4_IO13 | I2C_PAD,
+               .gp = IMX_GPIO_NR(4, 13)
+       }
+};
+
 static void setup_spi(void)
 {
        imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
 }
 
+iomux_v3_cfg_t const pcie_pads[] = {
+       MX6_PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL),        /* POWER */
+       MX6_PAD_GPIO_17__GPIO7_IO12 | MUX_PAD_CTRL(NO_PAD_CTRL),        /* RESET */
+};
+
+static void setup_pcie(void)
+{
+       imx_iomux_v3_setup_multiple_pads(pcie_pads, ARRAY_SIZE(pcie_pads));
+}
+
 iomux_v3_cfg_t const di0_pads[] = {
        MX6_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK,        /* DISP0_CLK */
        MX6_PAD_DI0_PIN2__IPU1_DI0_PIN02,               /* DISP0_HSYNC */
@@ -255,22 +289,6 @@ int board_phy_config(struct phy_device *phydev)
 }
 
 #if defined(CONFIG_VIDEO_IPUV3)
-struct display_info_t {
-       int     bus;
-       int     addr;
-       int     pixfmt;
-       int     (*detect)(struct display_info_t const *dev);
-       void    (*enable)(struct display_info_t const *dev);
-       struct  fb_videomode mode;
-};
-
-static int detect_hdmi(struct display_info_t const *dev)
-{
-       struct hdmi_regs *hdmi  = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR;
-       return readb(&hdmi->phy_stat0) & HDMI_DVI_STAT;
-}
-
-
 static void disable_lvds(struct display_info_t const *dev)
 {
        struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
@@ -299,7 +317,7 @@ static void enable_lvds(struct display_info_t const *dev)
        writel(reg, &iomux->gpr[2]);
 }
 
-static struct display_info_t const displays[] = {{
+struct display_info_t const displays[] = {{
        .bus    = -1,
        .addr   = 0,
        .pixfmt = IPU_PIX_FMT_RGB666,
@@ -340,51 +358,7 @@ static struct display_info_t const displays[] = {{
                .sync           = FB_SYNC_EXT,
                .vmode          = FB_VMODE_NONINTERLACED
 } } };
-
-int board_video_skip(void)
-{
-       int i;
-       int ret;
-       char const *panel = getenv("panel");
-       if (!panel) {
-               for (i = 0; i < ARRAY_SIZE(displays); i++) {
-                       struct display_info_t const *dev = displays+i;
-                       if (dev->detect && dev->detect(dev)) {
-                               panel = dev->mode.name;
-                               printf("auto-detected panel %s\n", panel);
-                               break;
-                       }
-               }
-               if (!panel) {
-                       panel = displays[0].mode.name;
-                       printf("No panel detected: default to %s\n", panel);
-                       i = 0;
-               }
-       } else {
-               for (i = 0; i < ARRAY_SIZE(displays); i++) {
-                       if (!strcmp(panel, displays[i].mode.name))
-                               break;
-               }
-       }
-       if (i < ARRAY_SIZE(displays)) {
-               ret = ipuv3_fb_init(&displays[i].mode, 0,
-                                   displays[i].pixfmt);
-               if (!ret) {
-                       displays[i].enable(displays+i);
-                       printf("Display: %s (%ux%u)\n",
-                              displays[i].mode.name,
-                              displays[i].mode.xres,
-                              displays[i].mode.yres);
-               } else
-                       printf("LCD %s cannot be configured: %d\n",
-                              displays[i].mode.name, ret);
-       } else {
-               printf("unsupported panel %s\n", panel);
-               return -EINVAL;
-       }
-
-       return 0;
-}
+size_t display_count = ARRAY_SIZE(displays);
 
 static void setup_display(void)
 {
@@ -454,6 +428,7 @@ int overwrite_console(void)
 int board_eth_init(bd_t *bis)
 {
        setup_iomux_enet();
+       setup_pcie();
 
        return cpu_eth_init(bis);
 }
@@ -476,10 +451,75 @@ int board_init(void)
 #ifdef CONFIG_MXC_SPI
        setup_spi();
 #endif
+       setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
+
+       return 0;
+}
+
+static int pfuze_init(void)
+{
+       struct pmic *p;
+       int ret;
+       unsigned int reg;
+
+       ret = power_pfuze100_init(I2C_PMIC);
+       if (ret)
+               return ret;
+
+       p = pmic_get("PFUZE100");
+       ret = pmic_probe(p);
+       if (ret)
+               return ret;
+
+       pmic_reg_read(p, PFUZE100_DEVICEID, &reg);
+       printf("PMIC:  PFUZE100 ID=0x%02x\n", reg);
+
+       /* Increase VGEN3 from 2.5 to 2.8V */
+       pmic_reg_read(p, PFUZE100_VGEN3VOL, &reg);
+       reg &= ~0xf;
+       reg |= 0xa;
+       pmic_reg_write(p, PFUZE100_VGEN3VOL, reg);
+
+       /* Increase VGEN5 from 2.8 to 3V */
+       pmic_reg_read(p, PFUZE100_VGEN5VOL, &reg);
+       reg &= ~0xf;
+       reg |= 0xc;
+       pmic_reg_write(p, PFUZE100_VGEN5VOL, reg);
+
+       /* Set SW1AB stanby volage to 0.975V */
+       pmic_reg_read(p, PFUZE100_SW1ABSTBY, &reg);
+       reg &= ~0x3f;
+       reg |= 0x1b;
+       pmic_reg_write(p, PFUZE100_SW1ABSTBY, reg);
+
+       /* Set SW1AB/VDDARM step ramp up time from 16us to 4us/25mV */
+       pmic_reg_read(p, PUZE_100_SW1ABCONF, &reg);
+       reg &= ~0xc0;
+       reg |= 0x40;
+       pmic_reg_write(p, PUZE_100_SW1ABCONF, reg);
+
+       /* Set SW1C standby voltage to 0.975V */
+       pmic_reg_read(p, PFUZE100_SW1CSTBY, &reg);
+       reg &= ~0x3f;
+       reg |= 0x1b;
+       pmic_reg_write(p, PFUZE100_SW1CSTBY, reg);
+
+       /* Set SW1C/VDDSOC step ramp up time from 16us to 4us/25mV */
+       pmic_reg_read(p, PFUZE100_SW1CCONF, &reg);
+       reg &= ~0xc0;
+       reg |= 0x40;
+       pmic_reg_write(p, PFUZE100_SW1CCONF, reg);
 
        return 0;
 }
 
+#ifdef CONFIG_MXC_SPI
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+       return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(4, 9)) : -1;
+}
+#endif
+
 #ifdef CONFIG_CMD_BMODE
 static const struct boot_mode board_boot_modes[] = {
        /* 4 bit bus width */
@@ -496,6 +536,7 @@ int board_late_init(void)
 #ifdef CONFIG_CMD_BMODE
        add_board_boot_modes(board_boot_modes);
 #endif
+       pfuze_init();
 
        return 0;
 }