]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/karo/tx6/pmic.c
karo: tx6: remove obsolete TX6Q-1020
[karo-tx-uboot.git] / board / karo / tx6 / pmic.c
1 /*
2  * Copyright (C) 2015 Lothar Waßmann <LW@KARO-electronics.de>
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  */
17 #include <common.h>
18 #include <errno.h>
19 #include <i2c.h>
20
21 #include "pmic.h"
22
23 #ifdef CONFIG_SYS_I2C
24 static struct {
25         uchar addr;
26         pmic_setup_func *init;
27         const char *name;
28 } i2c_addrs[] = {
29 #ifdef CONFIG_LTC3676
30         { 0x3c, ltc3676_pmic_setup, "LTC3676", },
31 #endif
32 #ifdef CONFIG_RN5T567
33         { 0x33, rn5t567_pmic_setup, "RN5T567", },
34 #endif
35 };
36
37 int tx6_pmic_init(int i2c_addr, struct pmic_regs *regs, size_t num_regs)
38 {
39         int ret = -ENODEV;
40         int i;
41         const char *pmic = "N/A";
42
43         printf("PMIC: ");
44
45         for (i = 0; i < ARRAY_SIZE(i2c_addrs); i++) {
46
47                 if (i2c_addrs[i].addr == i2c_addr) {
48                         pmic = i2c_addrs[i].name;
49                         break;
50                 }
51         }
52         printf("%s\n", pmic);
53
54         debug("Probing for I2C dev 0x%02x\n", i2c_addr);
55         ret = i2c_probe(i2c_addr);
56         if (ret == 0) {
57                 debug("Initializing PMIC at I2C addr 0x%02x\n", i2c_addr);
58                 ret = i2c_addrs[i].init(i2c_addr, regs, num_regs);
59         }
60         return ret;
61 }
62 #else
63 int tx6_pmic_init(int i2c_addr, struct pmic_regs *regs, size_t num_regs)
64 {
65         printf("PMIC: N/A\n");
66         return 0;
67 }
68 #endif