aboutsummaryrefslogtreecommitdiff
path: root/src/soc/rockchip
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2015-01-12 13:13:30 -0800
committerStefan Reinauer <stefan.reinauer@coreboot.org>2015-04-15 16:46:37 +0200
commit4d244214ce56dc89abd74a5d0ee45e77ca61c279 (patch)
tree0a92a93586675b4ce3fd31edd193a212f7caf9f2 /src/soc/rockchip
parent33df49519eb19556497bb3fdf442b058be324895 (diff)
veyron_*: Move PMIC_BUS to a Kconfig variable
This moves PMIC_BUS from each mainboard's board.h file to a per- mainboard Kconfig variable. To prevent humans from forgetting to set a valid value, an invalid default is set in the rk3288 Kconfig and checked in rk808.c so that compilation will fail if the mainboard Kconfig does not override it. Originally, PMIC_BUS was only used by mainboard code as an argument to RK808 PMIC functions. To conform to the generic RTC API, however, the RK808 code needs to have the bus number globally defined somewhere since the rtc_get() and rtc_set() functions don't take any args. Since CONFIG_PMIC_BUS is globally visible, we no longer need to pass bus number to the PMIC functions. BUG=chrome-os-partner:34436 BRANCH=none TEST=built and booted on Pinky Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: I73783878e507b2e7b1526dd2f81cfbdf8f1e2a55 Reviewed-on: https://chromium-review.googlesource.com/240203 Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-on: http://review.coreboot.org/9642 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones <marc.jones@se-eng.com>
Diffstat (limited to 'src/soc/rockchip')
-rw-r--r--src/soc/rockchip/rk3288/Kconfig4
-rw-r--r--src/soc/rockchip/rk3288/include/soc/rk808.h6
-rw-r--r--src/soc/rockchip/rk3288/rk808.c51
3 files changed, 39 insertions, 22 deletions
diff --git a/src/soc/rockchip/rk3288/Kconfig b/src/soc/rockchip/rk3288/Kconfig
index 95113f38cb..48ea7fc5d5 100644
--- a/src/soc/rockchip/rk3288/Kconfig
+++ b/src/soc/rockchip/rk3288/Kconfig
@@ -37,4 +37,8 @@ config BOOTBLOCK_CPU_INIT
string
default "soc/rockchip/rk3288/bootblock.c"
+config PMIC_BUS
+ int
+ default -1
+
endif
diff --git a/src/soc/rockchip/rk3288/include/soc/rk808.h b/src/soc/rockchip/rk3288/include/soc/rk808.h
index e03ace844e..ceddc52974 100644
--- a/src/soc/rockchip/rk3288/include/soc/rk808.h
+++ b/src/soc/rockchip/rk3288/include/soc/rk808.h
@@ -20,8 +20,8 @@
#ifndef __SOC_ROCKCHIP_RK3288_PMIC_H__
#define __SOC_ROCKCHIP_RK3288_PMIC_H__
-void rk808_configure_switch(uint8_t bus, int sw, int enabled);
-void rk808_configure_ldo(uint8_t bus, int ldo, int millivolts);
-void rk808_configure_buck(uint8_t bus, int buck, int millivolts);
+void rk808_configure_switch(int sw, int enabled);
+void rk808_configure_ldo(int ldo, int millivolts);
+void rk808_configure_buck(int buck, int millivolts);
#endif
diff --git a/src/soc/rockchip/rk3288/rk808.c b/src/soc/rockchip/rk3288/rk808.c
index 9713a9292f..de19a55135 100644
--- a/src/soc/rockchip/rk3288/rk808.c
+++ b/src/soc/rockchip/rk3288/rk808.c
@@ -25,36 +25,49 @@
#include <stdint.h>
#include <stdlib.h>
-#define RK808_ADDR 0x1b
+#if CONFIG_PMIC_BUS < 0
+#error "PMIC_BUS must be set in mainboard's Kconfig."
+#endif
-#define DCDC_EN 0x23
-#define LDO_EN 0x24
-#define BUCK1SEL 0x2f
-#define BUCK4SEL 0x38
-#define LDO_ONSEL(i) (0x39 + 2 * i)
-#define LDO_SLPSEL(i) (0x3a + 2 * i)
+#define RK808_ADDR 0x1b
-static void rk808_clrsetbits(uint8_t bus, uint8_t reg, uint8_t clr, uint8_t set)
+#define DCDC_EN 0x23
+#define LDO_EN 0x24
+#define BUCK1SEL 0x2f
+#define BUCK4SEL 0x38
+#define LDO_ONSEL(i) (0x39 + 2 * i)
+#define LDO_SLPSEL(i) (0x3a + 2 * i)
+
+static int rk808_read(uint8_t reg, uint8_t *value)
+{
+ return i2c_readb(CONFIG_PMIC_BUS, RK808_ADDR, reg, value);
+}
+
+static int rk808_write(uint8_t reg, uint8_t value)
+{
+ return i2c_writeb(CONFIG_PMIC_BUS, RK808_ADDR, reg, value);
+}
+
+static void rk808_clrsetbits(uint8_t reg, uint8_t clr, uint8_t set)
{
uint8_t value;
- if (i2c_readb(bus, RK808_ADDR, reg, &value) ||
- i2c_writeb(bus, RK808_ADDR, reg, (value & ~clr) | set))
+ if (rk808_read(reg, &value) || rk808_write(reg, (value & ~clr) | set))
printk(BIOS_ERR, "ERROR: Cannot set Rk808[%#x]!\n", reg);
}
-void rk808_configure_switch(uint8_t bus, int sw, int enabled)
+void rk808_configure_switch(int sw, int enabled)
{
assert(sw == 1 || sw == 2);
- rk808_clrsetbits(bus, DCDC_EN, 1 << (sw + 4), !!enabled << (sw + 4));
+ rk808_clrsetbits(DCDC_EN, 1 << (sw + 4), !!enabled << (sw + 4));
}
-void rk808_configure_ldo(uint8_t bus, int ldo, int millivolts)
+void rk808_configure_ldo(int ldo, int millivolts)
{
uint8_t vsel;
if (!millivolts) {
- rk808_clrsetbits(bus, LDO_EN, 1 << (ldo - 1), 0);
+ rk808_clrsetbits(LDO_EN, 1 << (ldo - 1), 0);
return;
}
@@ -77,11 +90,11 @@ void rk808_configure_ldo(uint8_t bus, int ldo, int millivolts)
die("Unknown LDO index!");
}
- rk808_clrsetbits(bus, LDO_ONSEL(ldo), 0x1f, vsel);
- rk808_clrsetbits(bus, LDO_EN, 0, 1 << (ldo - 1));
+ rk808_clrsetbits(LDO_ONSEL(ldo), 0x1f, vsel);
+ rk808_clrsetbits(LDO_EN, 0, 1 << (ldo - 1));
}
-void rk808_configure_buck(uint8_t bus, int buck, int millivolts)
+void rk808_configure_buck(int buck, int millivolts)
{
uint8_t vsel;
uint8_t buck_reg;
@@ -102,6 +115,6 @@ void rk808_configure_buck(uint8_t bus, int buck, int millivolts)
default:
die("fault buck index!");
}
- rk808_clrsetbits(bus, buck_reg, 0x3f, vsel);
- rk808_clrsetbits(bus, DCDC_EN, 0, 1 << (buck - 1));
+ rk808_clrsetbits(buck_reg, 0x3f, vsel);
+ rk808_clrsetbits(DCDC_EN, 0, 1 << (buck - 1));
}