1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
8 #include <power/pmic.h>
9 #include <power/pfuze100_pmic.h>
11 #ifndef CONFIG_DM_PMIC_PFUZE100
12 int pfuze_mode_init(struct pmic *p, u32 mode)
14 unsigned char offset, i, switch_num;
18 pmic_reg_read(p, PFUZE100_DEVICEID, &id);
23 offset = PFUZE100_SW1CMODE;
26 offset = PFUZE100_SW2MODE;
28 printf("Not supported, id=%d\n", id);
32 ret = pmic_reg_write(p, PFUZE100_SW1ABMODE, mode);
34 printf("Set SW1AB mode error!\n");
38 for (i = 0; i < switch_num - 1; i++) {
39 ret = pmic_reg_write(p, offset + i * SWITCH_SIZE, mode);
41 printf("Set switch 0x%x mode error!\n",
42 offset + i * SWITCH_SIZE);
50 struct pmic *pfuze_common_init(unsigned char i2cbus)
56 ret = power_pfuze100_init(i2cbus);
60 p = pmic_get("PFUZE100");
65 pmic_reg_read(p, PFUZE100_DEVICEID, ®);
66 printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
68 /* Set SW1AB stanby volage to 0.975V */
69 pmic_reg_read(p, PFUZE100_SW1ABSTBY, ®);
70 reg &= ~SW1x_STBY_MASK;
72 pmic_reg_write(p, PFUZE100_SW1ABSTBY, reg);
74 /* Set SW1AB/VDDARM step ramp up time from 16us to 4us/25mV */
75 pmic_reg_read(p, PFUZE100_SW1ABCONF, ®);
76 reg &= ~SW1xCONF_DVSSPEED_MASK;
77 reg |= SW1xCONF_DVSSPEED_4US;
78 pmic_reg_write(p, PFUZE100_SW1ABCONF, reg);
80 /* Set SW1C standby voltage to 0.975V */
81 pmic_reg_read(p, PFUZE100_SW1CSTBY, ®);
82 reg &= ~SW1x_STBY_MASK;
84 pmic_reg_write(p, PFUZE100_SW1CSTBY, reg);
86 /* Set SW1C/VDDSOC step ramp up time from 16us to 4us/25mV */
87 pmic_reg_read(p, PFUZE100_SW1CCONF, ®);
88 reg &= ~SW1xCONF_DVSSPEED_MASK;
89 reg |= SW1xCONF_DVSSPEED_4US;
90 pmic_reg_write(p, PFUZE100_SW1CCONF, reg);
95 int pfuze_mode_init(struct udevice *dev, u32 mode)
97 unsigned char offset, i, switch_num;
101 id = pmic_reg_read(dev, PFUZE100_DEVICEID);
106 offset = PFUZE100_SW1CMODE;
107 } else if (id == 1) {
109 offset = PFUZE100_SW2MODE;
111 printf("Not supported, id=%d\n", id);
115 ret = pmic_reg_write(dev, PFUZE100_SW1ABMODE, mode);
117 printf("Set SW1AB mode error!\n");
121 for (i = 0; i < switch_num - 1; i++) {
122 ret = pmic_reg_write(dev, offset + i * SWITCH_SIZE, mode);
124 printf("Set switch 0x%x mode error!\n",
125 offset + i * SWITCH_SIZE);
133 struct udevice *pfuze_common_init(void)
137 unsigned int reg, dev_id, rev_id;
139 ret = pmic_get("pfuze100", &dev);
143 dev_id = pmic_reg_read(dev, PFUZE100_DEVICEID);
144 rev_id = pmic_reg_read(dev, PFUZE100_REVID);
145 printf("PMIC: PFUZE100! DEV_ID=0x%x REV_ID=0x%x\n", dev_id, rev_id);
147 /* Set SW1AB stanby volage to 0.975V */
148 reg = pmic_reg_read(dev, PFUZE100_SW1ABSTBY);
149 reg &= ~SW1x_STBY_MASK;
151 pmic_reg_write(dev, PFUZE100_SW1ABSTBY, reg);
153 /* Set SW1AB/VDDARM step ramp up time from 16us to 4us/25mV */
154 reg = pmic_reg_read(dev, PFUZE100_SW1ABCONF);
155 reg &= ~SW1xCONF_DVSSPEED_MASK;
156 reg |= SW1xCONF_DVSSPEED_4US;
157 pmic_reg_write(dev, PFUZE100_SW1ABCONF, reg);
159 /* Set SW1C standby voltage to 0.975V */
160 reg = pmic_reg_read(dev, PFUZE100_SW1CSTBY);
161 reg &= ~SW1x_STBY_MASK;
163 pmic_reg_write(dev, PFUZE100_SW1CSTBY, reg);
165 /* Set SW1C/VDDSOC step ramp up time from 16us to 4us/25mV */
166 reg = pmic_reg_read(dev, PFUZE100_SW1CCONF);
167 reg &= ~SW1xCONF_DVSSPEED_MASK;
168 reg |= SW1xCONF_DVSSPEED_4US;
169 pmic_reg_write(dev, PFUZE100_SW1CCONF, reg);