pmic: Extend PMIC framework to support multiple instances of PMIC devices
[oweals/u-boot.git] / board / samsung / trats / trats.c
index a8b2b11c4cb445613482d3049eb826c64716b015..e0a98901f733029e5621813b4a13e3d343401c36 100644 (file)
@@ -34,9 +34,9 @@
 #include <asm/arch/mipi_dsim.h>
 #include <asm/arch/watchdog.h>
 #include <asm/arch/power.h>
-#include <pmic.h>
+#include <power/pmic.h>
 #include <usb/s3c_udc.h>
-#include <max8997_pmic.h>
+#include <power/max8997_pmic.h>
 #include <libtizen.h>
 
 #include "setup.h"
@@ -59,6 +59,8 @@ static int hwrevision(int rev)
        return (board_rev & 0xf) == rev;
 }
 
+struct s3c_plat_otg_data s5pc210_otg_data;
+
 int board_init(void)
 {
        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
@@ -67,12 +69,27 @@ int board_init(void)
        printf("HW Revision:\t0x%x\n", board_rev);
 
 #if defined(CONFIG_PMIC)
-       pmic_init();
+       pmic_init(I2C_5);
 #endif
 
        return 0;
 }
 
+void i2c_init_board(void)
+{
+       struct exynos4_gpio_part1 *gpio1 =
+               (struct exynos4_gpio_part1 *)samsung_get_base_gpio_part1();
+       struct exynos4_gpio_part2 *gpio2 =
+               (struct exynos4_gpio_part2 *)samsung_get_base_gpio_part2();
+
+       /* I2C_5 -> PMIC */
+       s5p_gpio_direction_output(&gpio1->b, 7, 1);
+       s5p_gpio_direction_output(&gpio1->b, 6, 1);
+       /* I2C_9 -> FG */
+       s5p_gpio_direction_output(&gpio2->y4, 0, 1);
+       s5p_gpio_direction_output(&gpio2->y4, 1, 1);
+}
+
 int dram_init(void)
 {
        gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
@@ -221,7 +238,9 @@ static int s5pc210_phy_control(int on)
 {
        int ret = 0;
        u32 val = 0;
-       struct pmic *p = get_pmic();
+       struct pmic *p = pmic_get("MAX8997_PMIC");
+       if (!p)
+               return -ENODEV;
 
        if (pmic_probe(p))
                return -1;
@@ -259,6 +278,12 @@ struct s3c_plat_otg_data s5pc210_otg_data = {
        .usb_phy_ctrl   = EXYNOS4_USBPHY_CONTROL,
        .usb_flags      = PHY0_SLEEP,
 };
+
+void board_usb_init(void)
+{
+       debug("USB_udc_probe\n");
+       s3c_udc_probe(&s5pc210_otg_data);
+}
 #endif
 
 static void pmic_reset(void)
@@ -390,7 +415,9 @@ static void lcd_reset(void)
 static int lcd_power(void)
 {
        int ret = 0;
-       struct pmic *p = get_pmic();
+       struct pmic *p = pmic_get("MAX8997_PMIC");
+       if (!p)
+               return -ENODEV;
 
        if (pmic_probe(p))
                return 0;
@@ -450,7 +477,9 @@ static struct mipi_dsim_lcd_device mipi_lcd_device = {
 static int mipi_power(void)
 {
        int ret = 0;
-       struct pmic *p = get_pmic();
+       struct pmic *p = pmic_get("MAX8997_PMIC");
+       if (!p)
+               return -ENODEV;
 
        if (pmic_probe(p))
                return 0;