]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/karo/tx6/pmic.c
Merge tag 'KARO-TX6-2015-03-24' into uboot-merge
[karo-tx-uboot.git] / board / karo / tx6 / pmic.c
diff --git a/board/karo/tx6/pmic.c b/board/karo/tx6/pmic.c
new file mode 100644 (file)
index 0000000..2743dad
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2015 Lothar Waßmann <LW@KARO-electronics.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <i2c.h>
+
+#include "pmic.h"
+
+static struct {
+       uchar addr;
+       int (*init)(uchar addr);
+} i2c_addrs[] = {
+#ifdef CONFIG_LTC3676
+       { 0x3c, ltc3676_pmic_setup, },
+#endif
+#ifdef CONFIG_RN5T618
+       { 0x32, rn5t618_pmic_setup, },
+#endif
+#ifdef CONFIG_RN5T567
+       { 0x33, rn5t567_pmic_setup, },
+#endif
+};
+
+int tx6_pmic_init(void)
+{
+       int ret = -ENODEV;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(i2c_addrs); i++) {
+               ret = i2c_probe(i2c_addrs[i].addr);
+               if (ret == 0) {
+                       i2c_addrs[i].init(i2c_addrs[i].addr);
+                       break;
+               }
+       }
+       return ret;
+}