190e7d52627960e751da4fb2076ce79c51da82163Keerthy/* 290e7d52627960e751da4fb2076ce79c51da82163Keerthy * tps65218-regulator.c 390e7d52627960e751da4fb2076ce79c51da82163Keerthy * 490e7d52627960e751da4fb2076ce79c51da82163Keerthy * Regulator driver for TPS65218 PMIC 590e7d52627960e751da4fb2076ce79c51da82163Keerthy * 690e7d52627960e751da4fb2076ce79c51da82163Keerthy * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 790e7d52627960e751da4fb2076ce79c51da82163Keerthy * 890e7d52627960e751da4fb2076ce79c51da82163Keerthy * This program is free software; you can redistribute it and/or 990e7d52627960e751da4fb2076ce79c51da82163Keerthy * modify it under the terms of the GNU General Public License version 2 as 1090e7d52627960e751da4fb2076ce79c51da82163Keerthy * published by the Free Software Foundation. 1190e7d52627960e751da4fb2076ce79c51da82163Keerthy * 1290e7d52627960e751da4fb2076ce79c51da82163Keerthy * This program is distributed "as is" WITHOUT ANY WARRANTY of any 1390e7d52627960e751da4fb2076ce79c51da82163Keerthy * kind, whether expressed or implied; without even the implied warranty 1490e7d52627960e751da4fb2076ce79c51da82163Keerthy * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1590e7d52627960e751da4fb2076ce79c51da82163Keerthy * GNU General Public License version 2 for more details. 1690e7d52627960e751da4fb2076ce79c51da82163Keerthy */ 1790e7d52627960e751da4fb2076ce79c51da82163Keerthy 1890e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/kernel.h> 1990e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/module.h> 2090e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/device.h> 2190e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/init.h> 2290e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/err.h> 2390e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/platform_device.h> 2490e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/of_device.h> 2590e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/regulator/of_regulator.h> 2690e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/regulator/driver.h> 2790e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/regulator/machine.h> 2890e7d52627960e751da4fb2076ce79c51da82163Keerthy#include <linux/mfd/tps65218.h> 2990e7d52627960e751da4fb2076ce79c51da82163Keerthy 3090e7d52627960e751da4fb2076ce79c51da82163Keerthyenum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; 3190e7d52627960e751da4fb2076ce79c51da82163Keerthy 32dd648ef2471602d5fc1ec80a546eb0c3f57ca172Felipe Balbi#define TPS65218_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _er, _em, \ 337753d2d41f658fe42de148732173e35999fd5e39Keerthy _lr, _nlr, _delay, _fuv) \ 3490e7d52627960e751da4fb2076ce79c51da82163Keerthy { \ 3590e7d52627960e751da4fb2076ce79c51da82163Keerthy .name = _name, \ 3690e7d52627960e751da4fb2076ce79c51da82163Keerthy .id = _id, \ 3790e7d52627960e751da4fb2076ce79c51da82163Keerthy .ops = &_ops, \ 3890e7d52627960e751da4fb2076ce79c51da82163Keerthy .n_voltages = _n, \ 3990e7d52627960e751da4fb2076ce79c51da82163Keerthy .type = REGULATOR_VOLTAGE, \ 4090e7d52627960e751da4fb2076ce79c51da82163Keerthy .owner = THIS_MODULE, \ 4190e7d52627960e751da4fb2076ce79c51da82163Keerthy .vsel_reg = _vr, \ 4290e7d52627960e751da4fb2076ce79c51da82163Keerthy .vsel_mask = _vm, \ 4390e7d52627960e751da4fb2076ce79c51da82163Keerthy .enable_reg = _er, \ 4490e7d52627960e751da4fb2076ce79c51da82163Keerthy .enable_mask = _em, \ 45dd648ef2471602d5fc1ec80a546eb0c3f57ca172Felipe Balbi .volt_table = NULL, \ 4690e7d52627960e751da4fb2076ce79c51da82163Keerthy .linear_ranges = _lr, \ 4790e7d52627960e751da4fb2076ce79c51da82163Keerthy .n_linear_ranges = _nlr, \ 485ab9be4274a12ef56fbf8cd965516f7d1f7868c6Axel Lin .ramp_delay = _delay, \ 497753d2d41f658fe42de148732173e35999fd5e39Keerthy .fixed_uV = _fuv \ 5090e7d52627960e751da4fb2076ce79c51da82163Keerthy } \ 5190e7d52627960e751da4fb2076ce79c51da82163Keerthy 5290e7d52627960e751da4fb2076ce79c51da82163Keerthy#define TPS65218_INFO(_id, _nm, _min, _max) \ 536a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi [_id] = { \ 5490e7d52627960e751da4fb2076ce79c51da82163Keerthy .id = _id, \ 5590e7d52627960e751da4fb2076ce79c51da82163Keerthy .name = _nm, \ 5690e7d52627960e751da4fb2076ce79c51da82163Keerthy .min_uV = _min, \ 5790e7d52627960e751da4fb2076ce79c51da82163Keerthy .max_uV = _max, \ 5890e7d52627960e751da4fb2076ce79c51da82163Keerthy } 5990e7d52627960e751da4fb2076ce79c51da82163Keerthy 6090e7d52627960e751da4fb2076ce79c51da82163Keerthystatic const struct regulator_linear_range dcdc1_dcdc2_ranges[] = { 6190e7d52627960e751da4fb2076ce79c51da82163Keerthy REGULATOR_LINEAR_RANGE(850000, 0x0, 0x32, 10000), 6290e7d52627960e751da4fb2076ce79c51da82163Keerthy REGULATOR_LINEAR_RANGE(1375000, 0x33, 0x3f, 25000), 6390e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 6490e7d52627960e751da4fb2076ce79c51da82163Keerthy 6590e7d52627960e751da4fb2076ce79c51da82163Keerthystatic const struct regulator_linear_range ldo1_dcdc3_ranges[] = { 6690e7d52627960e751da4fb2076ce79c51da82163Keerthy REGULATOR_LINEAR_RANGE(900000, 0x0, 0x1a, 25000), 6790e7d52627960e751da4fb2076ce79c51da82163Keerthy REGULATOR_LINEAR_RANGE(1600000, 0x1b, 0x3f, 50000), 6890e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 6990e7d52627960e751da4fb2076ce79c51da82163Keerthy 7090e7d52627960e751da4fb2076ce79c51da82163Keerthystatic const struct regulator_linear_range dcdc4_ranges[] = { 7190e7d52627960e751da4fb2076ce79c51da82163Keerthy REGULATOR_LINEAR_RANGE(1175000, 0x0, 0xf, 25000), 7242ab0f3915f22728f54bb1f3c0dcf38ab2335b5bFelipe Balbi REGULATOR_LINEAR_RANGE(1600000, 0x10, 0x34, 50000), 7390e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 7490e7d52627960e751da4fb2076ce79c51da82163Keerthy 7590e7d52627960e751da4fb2076ce79c51da82163Keerthystatic struct tps_info tps65218_pmic_regs[] = { 766a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi TPS65218_INFO(DCDC1, "DCDC1", 850000, 167500), 776a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi TPS65218_INFO(DCDC2, "DCDC2", 850000, 1675000), 786a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi TPS65218_INFO(DCDC3, "DCDC3", 900000, 3400000), 796a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi TPS65218_INFO(DCDC4, "DCDC4", 1175000, 3400000), 806a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi TPS65218_INFO(DCDC5, "DCDC5", 1000000, 1000000), 816a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi TPS65218_INFO(DCDC6, "DCDC6", 1800000, 1800000), 826a5e06d9f4443c6f967ea7352cf30abdd681accfFelipe Balbi TPS65218_INFO(LDO1, "LDO1", 900000, 3400000), 8390e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 8490e7d52627960e751da4fb2076ce79c51da82163Keerthy 8590e7d52627960e751da4fb2076ce79c51da82163Keerthy#define TPS65218_OF_MATCH(comp, label) \ 8690e7d52627960e751da4fb2076ce79c51da82163Keerthy { \ 8790e7d52627960e751da4fb2076ce79c51da82163Keerthy .compatible = comp, \ 8890e7d52627960e751da4fb2076ce79c51da82163Keerthy .data = &label, \ 8990e7d52627960e751da4fb2076ce79c51da82163Keerthy } 9090e7d52627960e751da4fb2076ce79c51da82163Keerthy 9190e7d52627960e751da4fb2076ce79c51da82163Keerthystatic const struct of_device_id tps65218_of_match[] = { 9290e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_OF_MATCH("ti,tps65218-dcdc1", tps65218_pmic_regs[DCDC1]), 9390e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_OF_MATCH("ti,tps65218-dcdc2", tps65218_pmic_regs[DCDC2]), 9490e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_OF_MATCH("ti,tps65218-dcdc3", tps65218_pmic_regs[DCDC3]), 9590e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_OF_MATCH("ti,tps65218-dcdc4", tps65218_pmic_regs[DCDC4]), 9690e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_OF_MATCH("ti,tps65218-dcdc5", tps65218_pmic_regs[DCDC5]), 9790e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_OF_MATCH("ti,tps65218-dcdc6", tps65218_pmic_regs[DCDC6]), 9890e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_OF_MATCH("ti,tps65218-ldo1", tps65218_pmic_regs[LDO1]), 99c46b5295ac3db8ac20e8970ce668b8e784833eeeAxel Lin { } 10090e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 10190e7d52627960e751da4fb2076ce79c51da82163KeerthyMODULE_DEVICE_TABLE(of, tps65218_of_match); 10290e7d52627960e751da4fb2076ce79c51da82163Keerthy 10390e7d52627960e751da4fb2076ce79c51da82163Keerthystatic int tps65218_pmic_set_voltage_sel(struct regulator_dev *dev, 10490e7d52627960e751da4fb2076ce79c51da82163Keerthy unsigned selector) 10590e7d52627960e751da4fb2076ce79c51da82163Keerthy{ 10690e7d52627960e751da4fb2076ce79c51da82163Keerthy int ret; 10790e7d52627960e751da4fb2076ce79c51da82163Keerthy struct tps65218 *tps = rdev_get_drvdata(dev); 10890e7d52627960e751da4fb2076ce79c51da82163Keerthy unsigned int rid = rdev_get_id(dev); 10990e7d52627960e751da4fb2076ce79c51da82163Keerthy 11090e7d52627960e751da4fb2076ce79c51da82163Keerthy /* Set the voltage based on vsel value and write protect level is 2 */ 11190e7d52627960e751da4fb2076ce79c51da82163Keerthy ret = tps65218_set_bits(tps, dev->desc->vsel_reg, dev->desc->vsel_mask, 11290e7d52627960e751da4fb2076ce79c51da82163Keerthy selector, TPS65218_PROTECT_L1); 11390e7d52627960e751da4fb2076ce79c51da82163Keerthy 11490e7d52627960e751da4fb2076ce79c51da82163Keerthy /* Set GO bit for DCDC1/2 to initiate voltage transistion */ 11590e7d52627960e751da4fb2076ce79c51da82163Keerthy switch (rid) { 11690e7d52627960e751da4fb2076ce79c51da82163Keerthy case TPS65218_DCDC_1: 11790e7d52627960e751da4fb2076ce79c51da82163Keerthy case TPS65218_DCDC_2: 11890e7d52627960e751da4fb2076ce79c51da82163Keerthy ret = tps65218_set_bits(tps, TPS65218_REG_CONTRL_SLEW_RATE, 11990e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_SLEW_RATE_GO, 12090e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_SLEW_RATE_GO, 12190e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_PROTECT_L1); 12290e7d52627960e751da4fb2076ce79c51da82163Keerthy break; 12390e7d52627960e751da4fb2076ce79c51da82163Keerthy } 12490e7d52627960e751da4fb2076ce79c51da82163Keerthy 12590e7d52627960e751da4fb2076ce79c51da82163Keerthy return ret; 12690e7d52627960e751da4fb2076ce79c51da82163Keerthy} 12790e7d52627960e751da4fb2076ce79c51da82163Keerthy 12890e7d52627960e751da4fb2076ce79c51da82163Keerthystatic int tps65218_pmic_enable(struct regulator_dev *dev) 12990e7d52627960e751da4fb2076ce79c51da82163Keerthy{ 13090e7d52627960e751da4fb2076ce79c51da82163Keerthy struct tps65218 *tps = rdev_get_drvdata(dev); 1315f986f7c2b878142f80cc23391631a71772692a8Sachin Kamat int rid = rdev_get_id(dev); 13290e7d52627960e751da4fb2076ce79c51da82163Keerthy 13390e7d52627960e751da4fb2076ce79c51da82163Keerthy if (rid < TPS65218_DCDC_1 || rid > TPS65218_LDO_1) 13490e7d52627960e751da4fb2076ce79c51da82163Keerthy return -EINVAL; 13590e7d52627960e751da4fb2076ce79c51da82163Keerthy 13690e7d52627960e751da4fb2076ce79c51da82163Keerthy /* Enable the regulator and password protection is level 1 */ 13790e7d52627960e751da4fb2076ce79c51da82163Keerthy return tps65218_set_bits(tps, dev->desc->enable_reg, 13890e7d52627960e751da4fb2076ce79c51da82163Keerthy dev->desc->enable_mask, dev->desc->enable_mask, 13990e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_PROTECT_L1); 14090e7d52627960e751da4fb2076ce79c51da82163Keerthy} 14190e7d52627960e751da4fb2076ce79c51da82163Keerthy 14290e7d52627960e751da4fb2076ce79c51da82163Keerthystatic int tps65218_pmic_disable(struct regulator_dev *dev) 14390e7d52627960e751da4fb2076ce79c51da82163Keerthy{ 14490e7d52627960e751da4fb2076ce79c51da82163Keerthy struct tps65218 *tps = rdev_get_drvdata(dev); 1455f986f7c2b878142f80cc23391631a71772692a8Sachin Kamat int rid = rdev_get_id(dev); 14690e7d52627960e751da4fb2076ce79c51da82163Keerthy 14790e7d52627960e751da4fb2076ce79c51da82163Keerthy if (rid < TPS65218_DCDC_1 || rid > TPS65218_LDO_1) 14890e7d52627960e751da4fb2076ce79c51da82163Keerthy return -EINVAL; 14990e7d52627960e751da4fb2076ce79c51da82163Keerthy 15090e7d52627960e751da4fb2076ce79c51da82163Keerthy /* Disable the regulator and password protection is level 1 */ 15190e7d52627960e751da4fb2076ce79c51da82163Keerthy return tps65218_clear_bits(tps, dev->desc->enable_reg, 15290e7d52627960e751da4fb2076ce79c51da82163Keerthy dev->desc->enable_mask, TPS65218_PROTECT_L1); 15390e7d52627960e751da4fb2076ce79c51da82163Keerthy} 15490e7d52627960e751da4fb2076ce79c51da82163Keerthy 15590e7d52627960e751da4fb2076ce79c51da82163Keerthy/* Operations permitted on DCDC1, DCDC2 */ 15690e7d52627960e751da4fb2076ce79c51da82163Keerthystatic struct regulator_ops tps65218_dcdc12_ops = { 15790e7d52627960e751da4fb2076ce79c51da82163Keerthy .is_enabled = regulator_is_enabled_regmap, 15890e7d52627960e751da4fb2076ce79c51da82163Keerthy .enable = tps65218_pmic_enable, 15990e7d52627960e751da4fb2076ce79c51da82163Keerthy .disable = tps65218_pmic_disable, 16090e7d52627960e751da4fb2076ce79c51da82163Keerthy .get_voltage_sel = regulator_get_voltage_sel_regmap, 16190e7d52627960e751da4fb2076ce79c51da82163Keerthy .set_voltage_sel = tps65218_pmic_set_voltage_sel, 16290e7d52627960e751da4fb2076ce79c51da82163Keerthy .list_voltage = regulator_list_voltage_linear_range, 16390e7d52627960e751da4fb2076ce79c51da82163Keerthy .map_voltage = regulator_map_voltage_linear_range, 1645ab9be4274a12ef56fbf8cd965516f7d1f7868c6Axel Lin .set_voltage_time_sel = regulator_set_voltage_time_sel, 16590e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 16690e7d52627960e751da4fb2076ce79c51da82163Keerthy 16790e7d52627960e751da4fb2076ce79c51da82163Keerthy/* Operations permitted on DCDC3, DCDC4 and LDO1 */ 16890e7d52627960e751da4fb2076ce79c51da82163Keerthystatic struct regulator_ops tps65218_ldo1_dcdc34_ops = { 16990e7d52627960e751da4fb2076ce79c51da82163Keerthy .is_enabled = regulator_is_enabled_regmap, 17090e7d52627960e751da4fb2076ce79c51da82163Keerthy .enable = tps65218_pmic_enable, 17190e7d52627960e751da4fb2076ce79c51da82163Keerthy .disable = tps65218_pmic_disable, 17290e7d52627960e751da4fb2076ce79c51da82163Keerthy .get_voltage_sel = regulator_get_voltage_sel_regmap, 17390e7d52627960e751da4fb2076ce79c51da82163Keerthy .set_voltage_sel = tps65218_pmic_set_voltage_sel, 17490e7d52627960e751da4fb2076ce79c51da82163Keerthy .list_voltage = regulator_list_voltage_linear_range, 17590e7d52627960e751da4fb2076ce79c51da82163Keerthy .map_voltage = regulator_map_voltage_linear_range, 17690e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 17790e7d52627960e751da4fb2076ce79c51da82163Keerthy 17890e7d52627960e751da4fb2076ce79c51da82163Keerthy/* Operations permitted on DCDC5, DCDC6 */ 17990e7d52627960e751da4fb2076ce79c51da82163Keerthystatic struct regulator_ops tps65218_dcdc56_pmic_ops = { 18090e7d52627960e751da4fb2076ce79c51da82163Keerthy .is_enabled = regulator_is_enabled_regmap, 18190e7d52627960e751da4fb2076ce79c51da82163Keerthy .enable = tps65218_pmic_enable, 18290e7d52627960e751da4fb2076ce79c51da82163Keerthy .disable = tps65218_pmic_disable, 18390e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 18490e7d52627960e751da4fb2076ce79c51da82163Keerthy 18590e7d52627960e751da4fb2076ce79c51da82163Keerthystatic const struct regulator_desc regulators[] = { 18690e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REGULATOR("DCDC1", TPS65218_DCDC_1, tps65218_dcdc12_ops, 64, 18790e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REG_CONTROL_DCDC1, 18890e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_CONTROL_DCDC1_MASK, 189dd648ef2471602d5fc1ec80a546eb0c3f57ca172Felipe Balbi TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC1_EN, 1907753d2d41f658fe42de148732173e35999fd5e39Keerthy dcdc1_dcdc2_ranges, 2, 4000, 0), 19190e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, tps65218_dcdc12_ops, 64, 19290e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REG_CONTROL_DCDC2, 19390e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_CONTROL_DCDC2_MASK, 194dd648ef2471602d5fc1ec80a546eb0c3f57ca172Felipe Balbi TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC2_EN, 1957753d2d41f658fe42de148732173e35999fd5e39Keerthy dcdc1_dcdc2_ranges, 2, 4000, 0), 19690e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, tps65218_ldo1_dcdc34_ops, 19790e7d52627960e751da4fb2076ce79c51da82163Keerthy 64, TPS65218_REG_CONTROL_DCDC3, 19890e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, 1997753d2d41f658fe42de148732173e35999fd5e39Keerthy TPS65218_ENABLE1_DC3_EN, ldo1_dcdc3_ranges, 2, 0, 0), 20090e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, tps65218_ldo1_dcdc34_ops, 20190e7d52627960e751da4fb2076ce79c51da82163Keerthy 53, TPS65218_REG_CONTROL_DCDC4, 20290e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_CONTROL_DCDC4_MASK, 203dd648ef2471602d5fc1ec80a546eb0c3f57ca172Felipe Balbi TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC4_EN, 2047753d2d41f658fe42de148732173e35999fd5e39Keerthy dcdc4_ranges, 2, 0, 0), 20590e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, tps65218_dcdc56_pmic_ops, 20690e7d52627960e751da4fb2076ce79c51da82163Keerthy 1, -1, -1, TPS65218_REG_ENABLE1, 2077753d2d41f658fe42de148732173e35999fd5e39Keerthy TPS65218_ENABLE1_DC5_EN, NULL, 0, 0, 1000000), 20890e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, tps65218_dcdc56_pmic_ops, 20990e7d52627960e751da4fb2076ce79c51da82163Keerthy 1, -1, -1, TPS65218_REG_ENABLE1, 2107753d2d41f658fe42de148732173e35999fd5e39Keerthy TPS65218_ENABLE1_DC6_EN, NULL, 0, 0, 1800000), 21190e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, tps65218_ldo1_dcdc34_ops, 64, 2120eada6a1fc85a98ce69a199e46925abd6a7001c2Keerthy TPS65218_REG_CONTROL_LDO1, 21390e7d52627960e751da4fb2076ce79c51da82163Keerthy TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, 214dd648ef2471602d5fc1ec80a546eb0c3f57ca172Felipe Balbi TPS65218_ENABLE2_LDO1_EN, ldo1_dcdc3_ranges, 2157753d2d41f658fe42de148732173e35999fd5e39Keerthy 2, 0, 0), 21690e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 21790e7d52627960e751da4fb2076ce79c51da82163Keerthy 21890e7d52627960e751da4fb2076ce79c51da82163Keerthystatic int tps65218_regulator_probe(struct platform_device *pdev) 21990e7d52627960e751da4fb2076ce79c51da82163Keerthy{ 22090e7d52627960e751da4fb2076ce79c51da82163Keerthy struct tps65218 *tps = dev_get_drvdata(pdev->dev.parent); 22190e7d52627960e751da4fb2076ce79c51da82163Keerthy struct regulator_init_data *init_data; 22290e7d52627960e751da4fb2076ce79c51da82163Keerthy const struct tps_info *template; 22390e7d52627960e751da4fb2076ce79c51da82163Keerthy struct regulator_dev *rdev; 22490e7d52627960e751da4fb2076ce79c51da82163Keerthy const struct of_device_id *match; 22590e7d52627960e751da4fb2076ce79c51da82163Keerthy struct regulator_config config = { }; 22690e7d52627960e751da4fb2076ce79c51da82163Keerthy int id; 22790e7d52627960e751da4fb2076ce79c51da82163Keerthy 22890e7d52627960e751da4fb2076ce79c51da82163Keerthy match = of_match_device(tps65218_of_match, &pdev->dev); 229948838a10ad24afea3229957b6f02f8587a569e0Axel Lin if (!match) 23090e7d52627960e751da4fb2076ce79c51da82163Keerthy return -ENODEV; 231948838a10ad24afea3229957b6f02f8587a569e0Axel Lin 232948838a10ad24afea3229957b6f02f8587a569e0Axel Lin template = match->data; 233948838a10ad24afea3229957b6f02f8587a569e0Axel Lin id = template->id; 234948838a10ad24afea3229957b6f02f8587a569e0Axel Lin init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); 23590e7d52627960e751da4fb2076ce79c51da82163Keerthy 23690e7d52627960e751da4fb2076ce79c51da82163Keerthy platform_set_drvdata(pdev, tps); 23790e7d52627960e751da4fb2076ce79c51da82163Keerthy 23890e7d52627960e751da4fb2076ce79c51da82163Keerthy tps->info[id] = &tps65218_pmic_regs[id]; 23990e7d52627960e751da4fb2076ce79c51da82163Keerthy config.dev = &pdev->dev; 24090e7d52627960e751da4fb2076ce79c51da82163Keerthy config.init_data = init_data; 24190e7d52627960e751da4fb2076ce79c51da82163Keerthy config.driver_data = tps; 24290e7d52627960e751da4fb2076ce79c51da82163Keerthy config.regmap = tps->regmap; 243d2fa87c3af0df7ed10463afc588affdab954fa92Keerthy config.of_node = pdev->dev.of_node; 24490e7d52627960e751da4fb2076ce79c51da82163Keerthy 24590e7d52627960e751da4fb2076ce79c51da82163Keerthy rdev = devm_regulator_register(&pdev->dev, ®ulators[id], &config); 24690e7d52627960e751da4fb2076ce79c51da82163Keerthy if (IS_ERR(rdev)) { 24790e7d52627960e751da4fb2076ce79c51da82163Keerthy dev_err(tps->dev, "failed to register %s regulator\n", 24890e7d52627960e751da4fb2076ce79c51da82163Keerthy pdev->name); 24990e7d52627960e751da4fb2076ce79c51da82163Keerthy return PTR_ERR(rdev); 25090e7d52627960e751da4fb2076ce79c51da82163Keerthy } 25190e7d52627960e751da4fb2076ce79c51da82163Keerthy 25290e7d52627960e751da4fb2076ce79c51da82163Keerthy return 0; 25390e7d52627960e751da4fb2076ce79c51da82163Keerthy} 25490e7d52627960e751da4fb2076ce79c51da82163Keerthy 25590e7d52627960e751da4fb2076ce79c51da82163Keerthystatic struct platform_driver tps65218_regulator_driver = { 25690e7d52627960e751da4fb2076ce79c51da82163Keerthy .driver = { 25790e7d52627960e751da4fb2076ce79c51da82163Keerthy .name = "tps65218-pmic", 25890e7d52627960e751da4fb2076ce79c51da82163Keerthy .owner = THIS_MODULE, 259948838a10ad24afea3229957b6f02f8587a569e0Axel Lin .of_match_table = tps65218_of_match, 26090e7d52627960e751da4fb2076ce79c51da82163Keerthy }, 26190e7d52627960e751da4fb2076ce79c51da82163Keerthy .probe = tps65218_regulator_probe, 26290e7d52627960e751da4fb2076ce79c51da82163Keerthy}; 26390e7d52627960e751da4fb2076ce79c51da82163Keerthy 26490e7d52627960e751da4fb2076ce79c51da82163Keerthymodule_platform_driver(tps65218_regulator_driver); 26590e7d52627960e751da4fb2076ce79c51da82163Keerthy 26690e7d52627960e751da4fb2076ce79c51da82163KeerthyMODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>"); 26790e7d52627960e751da4fb2076ce79c51da82163KeerthyMODULE_DESCRIPTION("TPS65218 voltage regulator driver"); 26890e7d52627960e751da4fb2076ce79c51da82163KeerthyMODULE_ALIAS("platform:tps65218-pmic"); 26990e7d52627960e751da4fb2076ce79c51da82163KeerthyMODULE_LICENSE("GPL v2"); 270