Commit 2c45f804 authored by Tom Rini's avatar Tom Rini
parents bfd07670 3296eeff
...@@ -10,6 +10,17 @@ ...@@ -10,6 +10,17 @@
#include "skeleton.dtsi" #include "skeleton.dtsi"
/ { / {
aliases {
i2c0 = &i2c_0;
i2c1 = &i2c_1;
i2c2 = &i2c_2;
i2c3 = &i2c_3;
i2c4 = &i2c_4;
i2c5 = &i2c_5;
i2c6 = &i2c_6;
i2c7 = &i2c_7;
};
combiner: interrupt-controller@10440000 { combiner: interrupt-controller@10440000 {
compatible = "samsung,exynos4210-combiner"; compatible = "samsung,exynos4210-combiner";
#interrupt-cells = <2>; #interrupt-cells = <2>;
...@@ -47,7 +58,7 @@ ...@@ -47,7 +58,7 @@
id = <4>; id = <4>;
}; };
i2c@13860000 { i2c_0: i2c@13860000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
...@@ -55,7 +66,7 @@ ...@@ -55,7 +66,7 @@
interrupts = <0 56 0>; interrupts = <0 56 0>;
}; };
i2c@13870000 { i2c_1: i2c@13870000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
...@@ -63,7 +74,7 @@ ...@@ -63,7 +74,7 @@
interrupts = <1 57 0>; interrupts = <1 57 0>;
}; };
i2c@13880000 { i2c_2: i2c@13880000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
...@@ -71,7 +82,7 @@ ...@@ -71,7 +82,7 @@
interrupts = <2 58 0>; interrupts = <2 58 0>;
}; };
i2c@13890000 { i2c_3: i2c@13890000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
...@@ -79,7 +90,7 @@ ...@@ -79,7 +90,7 @@
interrupts = <3 59 0>; interrupts = <3 59 0>;
}; };
i2c@138a0000 { i2c_4: i2c@138a0000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
...@@ -87,7 +98,7 @@ ...@@ -87,7 +98,7 @@
interrupts = <4 60 0>; interrupts = <4 60 0>;
}; };
i2c@138b0000 { i2c_5: i2c@138b0000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
...@@ -95,7 +106,7 @@ ...@@ -95,7 +106,7 @@
interrupts = <5 61 0>; interrupts = <5 61 0>;
}; };
i2c@138c0000 { i2c_6: i2c@138c0000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
...@@ -103,7 +114,7 @@ ...@@ -103,7 +114,7 @@
interrupts = <6 62 0>; interrupts = <6 62 0>;
}; };
i2c@138d0000 { i2c_7: i2c@138d0000 {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
compatible = "samsung,s3c2440-i2c"; compatible = "samsung,s3c2440-i2c";
......
...@@ -94,3 +94,167 @@ ...@@ -94,3 +94,167 @@
samsung,rgb-mode = <0>; samsung,rgb-mode = <0>;
}; };
}; };
&i2c_5 {
clock-frequency = <100000>;
status = "okay";
max8998-pmic@66 {
compatible = "maxim,max8998";
reg = <0x66 0 0>;
voltage-regulators {
ldo2_reg: LDO2 {
regulator-name = "VALIVE_1.2V";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
regulator-always-on;
};
ldo3_reg: LDO3 {
regulator-name = "VUSB+MIPI_1.1V";
regulator-min-microvolt = <1100000>;
regulator-max-microvolt = <1100000>;
regulator-always-on;
};
ldo4_reg: LDO4 {
regulator-name = "VADC_3.3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
ldo5_reg: LDO5 {
regulator-name = "VTF_2.8V";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
};
ldo6_reg: LDO6 {
regulator-name = "LDO6";
regulator-min-microvolt = <2000000>;
regulator-max-microvolt = <2000000>;
};
ldo7_reg: LDO7 {
regulator-name = "VLCD+VMIPI_1.8V";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
};
ldo8_reg: LDO8 {
regulator-name = "VUSB+VDAC_3.3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
ldo9_reg: LDO9 {
regulator-name = "VCC_2.8V";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
regulator-always-on;
};
ldo10_reg: LDO10 {
regulator-name = "VPLL_1.1V";
regulator-min-microvolt = <1100000>;
regulator-max-microvolt = <1100000>;
regulator-boot-on;
regulator-always-on;
};
ldo11_reg: LDO11 {
regulator-name = "CAM_AF_3.3V";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
ldo12_reg: LDO12 {
regulator-name = "PS_2.8V";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
};
ldo13_reg: LDO13 {
regulator-name = "VHIC_1.2V";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
};
ldo14_reg: LDO14 {
regulator-name = "CAM_I_HOST_1.8V";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
};
ldo15_reg: LDO15 {
regulator-name = "CAM_S_DIG+FM33_CORE_1.2V";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
};
ldo16_reg: LDO16 {
regulator-name = "CAM_S_ANA_2.8V";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
};
ldo17_reg: LDO17 {
regulator-name = "VCC_3.0V_LCD";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
};
buck1_reg: BUCK1 {
regulator-name = "VINT_1.1V";
regulator-min-microvolt = <750000>;
regulator-max-microvolt = <1500000>;
regulator-boot-on;
regulator-always-on;
};
buck2_reg: BUCK2 {
regulator-name = "VG3D_1.1V";
regulator-min-microvolt = <750000>;
regulator-max-microvolt = <1500000>;
regulator-boot-on;
};
buck3_reg: BUCK3 {
regulator-name = "VCC_1.8V";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-always-on;
};
buck4_reg: BUCK4 {
regulator-name = "VMEM_1.2V";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
regulator-always-on;
};
ap32khz_reg: EN32KHz-AP {
regulator-name = "32KHz AP";
regulator-always-on;
};
cp32khz_reg: EN32KHz-CP {
regulator-name = "32KHz CP";
};
vichg_reg: ENVICHG {
regulator-name = "VICHG";
};
safeout1_reg: ESAFEOUT1 {
regulator-name = "SAFEOUT1";
};
safeout2_reg: ESAFEOUT2 {
regulator-name = "SAFEOUT2";
regulator-boot-on;
};
};
};
};
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#size-cells = <0>; #size-cells = <0>;
status = "okay"; status = "okay";
pmic@66 { max8998-pmic@66 {
compatible = "maxim,max8998"; compatible = "maxim,max8998";
reg = <0x66 0 0>; reg = <0x66 0 0>;
......
...@@ -123,13 +123,7 @@ int exynos_power_init(void) ...@@ -123,13 +123,7 @@ int exynos_power_init(void)
if (ret) if (ret)
return ret; return ret;
/* ret = exynos_set_regulator("vdd_arm", 1300000);
* This would normally be 1.3V, but since we are running slowly 1.1V
* is enough. For spring it helps reduce CPU temperature and avoid
* hangs with the case open. 1.1V is minimum voltage borderline for
* chained bootloaders.
*/
ret = exynos_set_regulator("vdd_arm", 1100000);
if (ret) if (ret)
return ret; return ret;
ret = exynos_set_regulator("vdd_int", 1012500); ret = exynos_set_regulator("vdd_int", 1012500);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <common.h> #include <common.h>
#include <asm/gpio.h> #include <asm/gpio.h>
#include <asm/arch/mmc.h> #include <asm/arch/mmc.h>
#include <dm.h>
#include <power/pmic.h> #include <power/pmic.h>
#include <usb/dwc2_udc.h> #include <usb/dwc2_udc.h>
#include <asm/arch/cpu.h> #include <asm/arch/cpu.h>
...@@ -43,19 +44,6 @@ void i2c_init_board(void) ...@@ -43,19 +44,6 @@ void i2c_init_board(void)
} }
#endif #endif
int power_init_board(void)
{
#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */
/*
* For PMIC the I2C bus is named as I2C5, but it is connected
* to logical I2C adapter 0
*/
return pmic_init(I2C_0);
#else
return 0;
#endif
}
int dram_init(void) int dram_init(void)
{ {
gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE + gd->ram_size = PHYS_SDRAM_1_SIZE + PHYS_SDRAM_2_SIZE +
...@@ -146,39 +134,50 @@ int board_mmc_init(bd_t *bis) ...@@ -146,39 +134,50 @@ int board_mmc_init(bd_t *bis)
#ifdef CONFIG_USB_GADGET #ifdef CONFIG_USB_GADGET
static int s5pc1xx_phy_control(int on) static int s5pc1xx_phy_control(int on)
{ {
#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ struct udevice *dev;
int ret;
static int status; static int status;
struct pmic *p = pmic_get("MAX8998_PMIC"); int reg, ret;
if (!p)
return -ENODEV;
if (pmic_probe(p)) ret = pmic_get("max8998-pmic", &dev);
return -1; if (ret)
return ret;
if (on && !status) { if (on && !status) {
ret = pmic_set_output(p, MAX8998_REG_ONOFF1, reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
MAX8998_LDO3, LDO_ON); reg |= MAX8998_LDO3;
ret = pmic_set_output(p, MAX8998_REG_ONOFF2, ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
MAX8998_LDO8, LDO_ON);
if (ret) { if (ret) {
puts("MAX8998 LDO setting error!\n"); puts("MAX8998 LDO setting error!\n");
return -1; return -EINVAL;
}
reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
reg |= MAX8998_LDO8;
ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
if (ret) {
puts("MAX8998 LDO setting error!\n");
return -EINVAL;
} }
status = 1; status = 1;
} else if (!on && status) { } else if (!on && status) {
ret = pmic_set_output(p, MAX8998_REG_ONOFF1, reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
MAX8998_LDO3, LDO_OFF); reg &= ~MAX8998_LDO3;
ret = pmic_set_output(p, MAX8998_REG_ONOFF2, ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
MAX8998_LDO8, LDO_OFF); if (ret) {
puts("MAX8998 LDO setting error!\n");
return -EINVAL;
}
reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
reg &= ~MAX8998_LDO8;
ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
if (ret) { if (ret) {
puts("MAX8998 LDO setting error!\n"); puts("MAX8998 LDO setting error!\n");
return -1; return -EINVAL;
} }
status = 0; status = 0;
} }
udelay(10000); udelay(10000);
#endif
return 0; return 0;
} }
......
...@@ -27,33 +27,21 @@ ...@@ -27,33 +27,21 @@
DECLARE_GLOBAL_DATA_PTR; DECLARE_GLOBAL_DATA_PTR;
unsigned int board_rev; unsigned int board_rev;
static int init_pmic_lcd(void);
u32 get_board_rev(void) u32 get_board_rev(void)
{ {
return board_rev; return board_rev;
} }
static int get_hwrev(void) int exynos_power_init(void)
{ {
return board_rev & 0xFF; return init_pmic_lcd();
} }
int exynos_power_init(void) static int get_hwrev(void)
{ {
#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ return board_rev & 0xFF;
int ret;
/*
* For PMIC the I2C bus is named as I2C5, but it is connected
* to logical I2C adapter 0
*/
ret = pmic_init(I2C_0);
if (ret)
return ret;
init_pmic_lcd();
#endif
return 0;
} }
static unsigned short get_adc_value(int channel) static unsigned short get_adc_value(int channel)
...@@ -83,23 +71,29 @@ static unsigned short get_adc_value(int channel) ...@@ -83,23 +71,29 @@ static unsigned short get_adc_value(int channel)
static int adc_power_control(int on) static int adc_power_control(int on)
{ {
#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ struct udevice *dev;
int ret; int ret;
struct pmic *p = pmic_get("MAX8998_PMIC"); u8 reg;
if (!p)
return -ENODEV;
if (pmic_probe(p)) ret = pmic_get("max8998-pmic", &dev);
return -1; if (ret) {
puts("Failed to get MAX8998!\n");
return ret;
}
ret = pmic_set_output(p, reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
MAX8998_REG_ONOFF1, if (on)
MAX8998_LDO4, !!on); reg |= MAX8998_LDO4;
else
reg &= ~MAX8998_LDO4;
ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
if (ret) {
puts("MAX8998 LDO setting error\n");
return -EINVAL;
}
return ret;
#else
return 0; return 0;
#endif
} }
static unsigned int get_hw_revision(void) static unsigned int get_hw_revision(void)
...@@ -147,39 +141,50 @@ static void check_hw_revision(void) ...@@ -147,39 +141,50 @@ static void check_hw_revision(void)
#ifdef CONFIG_USB_GADGET #ifdef CONFIG_USB_GADGET
static int s5pc210_phy_control(int on) static int s5pc210_phy_control(int on)
{ {
#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ struct udevice *dev;
int ret = 0; int ret;
struct pmic *p = pmic_get("MAX8998_PMIC"); u8 reg;
if (!p)
return -ENODEV;
if (pmic_probe(p)) ret = pmic_get("max8998-pmic", &dev);
return -1; if (ret) {
puts("Failed to get MAX8998!\n");
return ret;
}
if (on) { if (on) {
ret |= pmic_set_output(p, reg = pmic_reg_read(dev, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3);
MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg |= MAX8998_SAFEOUT1;
MAX8998_SAFEOUT1, LDO_ON); ret |= pmic_reg_write(dev,
ret |= pmic_set_output(p, MAX8998_REG_ONOFF1, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg);
MAX8998_LDO3, LDO_ON);
ret |= pmic_set_output(p, MAX8998_REG_ONOFF2, reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
MAX8998_LDO8, LDO_ON); reg |= MAX8998_LDO3;
ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
reg |= MAX8998_LDO8;
ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
} else { } else {
ret |= pmic_set_output(p, MAX8998_REG_ONOFF2, reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2);
MAX8998_LDO8, LDO_OFF); reg &= ~MAX8998_LDO8;
ret |= pmic_set_output(p, MAX8998_REG_ONOFF1, ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg);
MAX8998_LDO3, LDO_OFF);
ret |= pmic_set_output(p, reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1);
MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg &= ~MAX8998_LDO3;
MAX8998_SAFEOUT1, LDO_OFF); ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg);
reg = pmic_reg_read(dev, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3);
reg &= ~MAX8998_SAFEOUT1;
ret |= pmic_reg_write(dev,
MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg);
} }
if (ret) { if (ret) {
puts("MAX8998 LDO setting error!\n"); puts("MAX8998 LDO setting error!\n");
return -1; return -EINVAL;
} }
#endif
return 0; return 0;
} }
...@@ -205,27 +210,25 @@ int exynos_early_init_f(void) ...@@ -205,27 +210,25 @@ int exynos_early_init_f(void)
return 0; return 0;
} }
#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ static int init_pmic_lcd(void)
static void init_pmic_lcd(void)
{ {
struct udevice *dev;
unsigned char val; unsigned char val;
int ret = 0; int ret = 0;
struct pmic *p = pmic_get("MAX8998_PMIC"); ret = pmic_get("max8998-pmic", &dev);
if (ret) {
if (!p) puts("Failed to get MAX8998 for init_pmic_lcd()!\n");
return; return ret;
}
if (pmic_probe(p))
return;
/* LDO7 1.8V */ /* LDO7 1.8V */
val = 0x02; /* (1800 - 1600) / 100; */ val = 0x02; /* (1800 - 1600) / 100; */
ret |= pmic_reg_write(p, MAX8998_REG_LDO7, val); ret |= pmic_reg_write(dev, MAX8998_REG_LDO7, val);
/* LDO17 3.0V */ /* LDO17 3.0V */
val = 0xe; /* (3000 - 1600) / 100; */ val = 0xe; /* (3000 - 1600) / 100; */
ret |= pmic_reg_write(p, MAX8998_REG_LDO17, val); ret |= pmic_reg_write(dev, MAX8998_REG_LDO17, val);
/* Disable unneeded regulators */ /* Disable unneeded regulators */
/* /*
...@@ -234,26 +237,29 @@ static void init_pmic_lcd(void) ...@@ -234,26 +237,29 @@ static void init_pmic_lcd(void)
* LDO2 ON, LDO3 OFF, LDO4 OFF, LDO5 ON * LDO2 ON, LDO3 OFF, LDO4 OFF, LDO5 ON
*/ */
val = 0xB9; val = 0xB9;
ret |= pmic_reg_write(p, MAX8998_REG_ONOFF1, val); ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, val);
/* ONOFF2 /* ONOFF2
* LDO6 OFF, LDO7 ON, LDO8 OFF, LDO9 ON, * LDO6 OFF, LDO7 ON, LDO8 OFF, LDO9 ON,
* LDO10 OFF, LDO11 OFF, LDO12 OFF, LDO13 OFF * LDO10 OFF, LDO11 OFF, LDO12 OFF, LDO13 OFF
*/ */
val = 0x50; val = 0x50;
ret |= pmic_reg_write(p, MAX8998_REG_ONOFF2, val); ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, val);
/* ONOFF3 /* ONOFF3
* LDO14 OFF, LDO15 OFF, LGO16 OFF, LDO17 OFF * LDO14 OFF, LDO15 OFF, LGO16 OFF, LDO17 OFF
* EPWRHOLD OFF, EBATTMON OFF, ELBCNFG2 OFF, ELBCNFG1 OFF * EPWRHOLD OFF, EBATTMON OFF, ELBCNFG2 OFF, ELBCNFG1 OFF
*/ */
val = 0x00; val = 0x00;
ret |= pmic_reg_write(p, MAX8998_REG_ONOFF3, val); ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF3, val);
if (ret) if (ret) {
puts("LCD pmic initialisation error!\n"); puts("LCD pmic initialisation error!\n");
return -EINVAL;
}
return 0;
} }
#endif
void exynos_cfg_lcd_gpio(void) void exynos_cfg_lcd_gpio(void)
{ {
...@@ -310,18 +316,31 @@ void exynos_reset_lcd(void) ...@@ -310,18 +316,31 @@ void exynos_reset_lcd(void)
void exynos_lcd_power_on(void) void exynos_lcd_power_on(void)
{ {
#ifndef CONFIG_DM_I2C /* TODO(maintainer): Convert to driver model */ struct udevice *dev;
struct pmic *p = pmic_get("MAX8998_PMIC"); int ret;
u8 reg;
if (!p) ret = pmic_get("max8998-pmic", &dev);
if (ret) {
puts("Failed to get MAX8998!\n");
return; return;
}
if (pmic_probe(p)) reg = pmic_reg_read(dev, MAX8998_REG_ONOFF3);
reg |= MAX8998_LDO17;
ret = pmic_reg_write(dev, MAX8998_REG_ONOFF3, reg);
if (ret) {
puts("MAX8998 LDO setting error\n