Lines Matching full:max8952
3 * max8952.c - Voltage and current regulation for the Maxim 8952
15 #include <linux/regulator/max8952.h>
44 static int max8952_read_reg(struct max8952_data *max8952, u8 reg) in max8952_read_reg() argument
46 int ret = i2c_smbus_read_byte_data(max8952->client, reg); in max8952_read_reg()
54 static int max8952_write_reg(struct max8952_data *max8952, in max8952_write_reg() argument
57 return i2c_smbus_write_byte_data(max8952->client, reg, value); in max8952_write_reg()
63 struct max8952_data *max8952 = rdev_get_drvdata(rdev); in max8952_list_voltage() local
68 return (max8952->pdata->dvs_mode[selector] * 10 + 770) * 1000; in max8952_list_voltage()
73 struct max8952_data *max8952 = rdev_get_drvdata(rdev); in max8952_get_voltage_sel() local
76 if (max8952->vid0) in max8952_get_voltage_sel()
78 if (max8952->vid1) in max8952_get_voltage_sel()
87 struct max8952_data *max8952 = rdev_get_drvdata(rdev); in max8952_set_voltage_sel() local
89 if (!max8952->vid0_gpiod || !max8952->vid1_gpiod) { in max8952_set_voltage_sel()
94 max8952->vid0 = selector & 0x1; in max8952_set_voltage_sel()
95 max8952->vid1 = (selector >> 1) & 0x1; in max8952_set_voltage_sel()
96 gpiod_set_value(max8952->vid0_gpiod, max8952->vid0); in max8952_set_voltage_sel()
97 gpiod_set_value(max8952->vid1_gpiod, max8952->vid1); in max8952_set_voltage_sel()
119 { .compatible = "maxim,max8952" },
135 if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode)) in max8952_parse_dt()
138 ret = of_property_read_u32_array(np, "max8952,dvs-mode-microvolt", in max8952_parse_dt()
141 dev_err(dev, "max8952,dvs-mode-microvolt property not specified"); in max8952_parse_dt()
153 if (of_property_read_u32(np, "max8952,sync-freq", &pd->sync_freq)) in max8952_parse_dt()
154 dev_warn(dev, "max8952,sync-freq property not specified, defaulting to 26MHz\n"); in max8952_parse_dt()
156 if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed)) in max8952_parse_dt()
157 dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n"); in max8952_parse_dt()
179 struct max8952_data *max8952; in max8952_pmic_probe() local
197 max8952 = devm_kzalloc(&client->dev, sizeof(struct max8952_data), in max8952_pmic_probe()
199 if (!max8952) in max8952_pmic_probe()
202 max8952->client = client; in max8952_pmic_probe()
203 max8952->pdata = pdata; in max8952_pmic_probe()
207 config.driver_data = max8952; in max8952_pmic_probe()
220 "max8952,en", in max8952_pmic_probe()
234 max8952->vid0 = pdata->default_mode & 0x1; in max8952_pmic_probe()
235 max8952->vid1 = (pdata->default_mode >> 1) & 0x1; in max8952_pmic_probe()
238 gflags = max8952->vid0 ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; in max8952_pmic_probe()
239 max8952->vid0_gpiod = devm_gpiod_get_index_optional(&client->dev, in max8952_pmic_probe()
240 "max8952,vid", in max8952_pmic_probe()
242 if (IS_ERR(max8952->vid0_gpiod)) in max8952_pmic_probe()
243 return PTR_ERR(max8952->vid0_gpiod); in max8952_pmic_probe()
244 gflags = max8952->vid1 ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; in max8952_pmic_probe()
245 max8952->vid1_gpiod = devm_gpiod_get_index_optional(&client->dev, in max8952_pmic_probe()
246 "max8952,vid", in max8952_pmic_probe()
248 if (IS_ERR(max8952->vid1_gpiod)) in max8952_pmic_probe()
249 return PTR_ERR(max8952->vid1_gpiod); in max8952_pmic_probe()
252 if (!max8952->vid0_gpiod || !max8952->vid1_gpiod) { in max8952_pmic_probe()
255 max8952->vid0 = 0; in max8952_pmic_probe()
256 max8952->vid1 = 0; in max8952_pmic_probe()
258 if (max8952->vid0_gpiod) in max8952_pmic_probe()
259 gpiod_set_value(max8952->vid0_gpiod, 0); in max8952_pmic_probe()
260 if (max8952->vid1_gpiod) in max8952_pmic_probe()
261 gpiod_set_value(max8952->vid1_gpiod, 0); in max8952_pmic_probe()
264 max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x60); in max8952_pmic_probe()
271 * leakage current of MAX8952 assuming that MAX8952 in max8952_pmic_probe()
277 max8952_write_reg(max8952, MAX8952_REG_CONTROL, 0x0); in max8952_pmic_probe()
280 max8952_write_reg(max8952, MAX8952_REG_MODE0, in max8952_pmic_probe()
281 (max8952_read_reg(max8952, in max8952_pmic_probe()
284 max8952_write_reg(max8952, MAX8952_REG_MODE1, in max8952_pmic_probe()
285 (max8952_read_reg(max8952, in max8952_pmic_probe()
288 max8952_write_reg(max8952, MAX8952_REG_MODE2, in max8952_pmic_probe()
289 (max8952_read_reg(max8952, in max8952_pmic_probe()
292 max8952_write_reg(max8952, MAX8952_REG_MODE3, in max8952_pmic_probe()
293 (max8952_read_reg(max8952, in max8952_pmic_probe()
297 max8952_write_reg(max8952, MAX8952_REG_SYNC, in max8952_pmic_probe()
298 (max8952_read_reg(max8952, MAX8952_REG_SYNC) & 0x3F) | in max8952_pmic_probe()
300 max8952_write_reg(max8952, MAX8952_REG_RAMP, in max8952_pmic_probe()
301 (max8952_read_reg(max8952, MAX8952_REG_RAMP) & 0x1F) | in max8952_pmic_probe()
304 i2c_set_clientdata(client, max8952); in max8952_pmic_probe()
310 { "max8952" },
318 .name = "max8952",