summaryrefslogtreecommitdiff
path: root/drivers/power/sy8106a.c
diff options
context:
space:
mode:
authorJelle van der Waa <jelle@vdwaa.nl>2016-02-23 18:47:19 +0100
committerHans de Goede <hdegoede@redhat.com>2016-02-23 20:50:07 +0100
commit0d8382ae70e7559eba873b4d8b2cf9a15aeccf20 (patch)
tree1197454051f70f8bb0de9c1b105b0f408ed43e8b /drivers/power/sy8106a.c
parent595af9db2422fa5ae734cfe615415b17a5098f34 (diff)
downloadu-boot-0d8382ae70e7559eba873b4d8b2cf9a15aeccf20.tar.gz
sunxi: power: add support for sy8106a driver
SY8106A is a PMIC which is used on the Allwinner H3 Orange Pi Pc and Plus board. The VOUT1_SEL register is implemented to set the default V-CPU voltage to 1200 mV. This driver is required to ensure the SY8106A V-CPU voltage is set to 1200 mV after a software reset. On cold boot the default SY8106A output voltage is selected to be 1200 mV by a pair of resistors on the Orange Pi PC and Plus. Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl> Tested-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/power/sy8106a.c')
-rw-r--r--drivers/power/sy8106a.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/power/sy8106a.c b/drivers/power/sy8106a.c
new file mode 100644
index 0000000000..bbf116f655
--- /dev/null
+++ b/drivers/power/sy8106a.c
@@ -0,0 +1,29 @@
+/*
+ * (C) Copyright 2016
+ * Jelle van der Waa <jelle@vdwaa.nl>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include <common.h>
+#include <i2c.h>
+#include <sy8106a.h>
+
+#define SY8106A_I2C_ADDR 0x65
+#define SY8106A_VOUT1_SEL 1
+#define SY8106A_VOUT1_SEL_ENABLE (1 << 7)
+
+static u8 sy8106a_mvolt_to_cfg(int mvolt, int min, int max, int div)
+{
+ if (mvolt < min)
+ mvolt = min;
+ else if (mvolt > max)
+ mvolt = max;
+
+ return (mvolt - min) / div;
+}
+
+int sy8106a_set_vout1(unsigned int mvolt)
+{
+ u8 data = sy8106a_mvolt_to_cfg(mvolt, 680, 1950, 10) | SY8106A_VOUT1_SEL_ENABLE;
+ return i2c_write(SY8106A_I2C_ADDR, SY8106A_VOUT1_SEL, 1, &data, 1);
+}