Blame view
drivers/regulator/isl9305.c
5.03 KB
2874c5fd2 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
dec38b5ce regulator: isl930... |
2 3 4 5 6 7 |
/* * isl9305 - Intersil ISL9305 DCDC regulator * * Copyright 2014 Linaro Ltd * * Author: Mark Brown <broonie@kernel.org> |
dec38b5ce regulator: isl930... |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
*/ #include <linux/module.h> #include <linux/err.h> #include <linux/i2c.h> #include <linux/of.h> #include <linux/platform_data/isl9305.h> #include <linux/regmap.h> #include <linux/regulator/driver.h> #include <linux/regulator/of_regulator.h> #include <linux/slab.h> /* * Registers */ #define ISL9305_DCD1OUT 0x0 #define ISL9305_DCD2OUT 0x1 #define ISL9305_LDO1OUT 0x2 #define ISL9305_LDO2OUT 0x3 #define ISL9305_DCD_PARAMETER 0x4 #define ISL9305_SYSTEM_PARAMETER 0x5 #define ISL9305_DCD_SRCTL 0x6 #define ISL9305_MAX_REG ISL9305_DCD_SRCTL /* * DCD_PARAMETER */ #define ISL9305_DCD_PHASE 0x40 #define ISL9305_DCD2_ULTRA 0x20 #define ISL9305_DCD1_ULTRA 0x10 #define ISL9305_DCD2_BLD 0x08 #define ISL9305_DCD1_BLD 0x04 #define ISL9305_DCD2_MODE 0x02 #define ISL9305_DCD1_MODE 0x01 /* * SYSTEM_PARAMETER */ #define ISL9305_I2C_EN 0x40 #define ISL9305_DCDPOR_MASK 0x30 #define ISL9305_LDO2_EN 0x08 #define ISL9305_LDO1_EN 0x04 #define ISL9305_DCD2_EN 0x02 #define ISL9305_DCD1_EN 0x01 /* * DCD_SRCTL */ #define ISL9305_DCD2SR_MASK 0xc0 #define ISL9305_DCD1SR_MASK 0x07 static const struct regulator_ops isl9305_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap, .list_voltage = regulator_list_voltage_linear, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, }; static const struct regulator_desc isl9305_regulators[] = { [ISL9305_DCD1] = { .name = "DCD1", |
93a127b11 regulator: isl930... |
72 73 |
.of_match = of_match_ptr("dcd1"), .regulators_node = of_match_ptr("regulators"), |
dec38b5ce regulator: isl930... |
74 75 76 77 78 79 80 81 82 |
.n_voltages = 0x70, .min_uV = 825000, .uV_step = 25000, .vsel_reg = ISL9305_DCD1OUT, .vsel_mask = 0x7f, .enable_reg = ISL9305_SYSTEM_PARAMETER, .enable_mask = ISL9305_DCD1_EN, .supply_name = "VINDCD1", .ops = &isl9305_ops, |
46942b21a regulator: isl930... |
83 |
.owner = THIS_MODULE, |
dec38b5ce regulator: isl930... |
84 85 86 |
}, [ISL9305_DCD2] = { .name = "DCD2", |
93a127b11 regulator: isl930... |
87 88 |
.of_match = of_match_ptr("dcd2"), .regulators_node = of_match_ptr("regulators"), |
dec38b5ce regulator: isl930... |
89 90 91 92 93 94 95 96 97 |
.n_voltages = 0x70, .min_uV = 825000, .uV_step = 25000, .vsel_reg = ISL9305_DCD2OUT, .vsel_mask = 0x7f, .enable_reg = ISL9305_SYSTEM_PARAMETER, .enable_mask = ISL9305_DCD2_EN, .supply_name = "VINDCD2", .ops = &isl9305_ops, |
46942b21a regulator: isl930... |
98 |
.owner = THIS_MODULE, |
dec38b5ce regulator: isl930... |
99 100 101 |
}, [ISL9305_LDO1] = { .name = "LDO1", |
93a127b11 regulator: isl930... |
102 103 |
.of_match = of_match_ptr("ldo1"), .regulators_node = of_match_ptr("regulators"), |
dec38b5ce regulator: isl930... |
104 105 106 107 108 109 110 111 112 |
.n_voltages = 0x37, .min_uV = 900000, .uV_step = 50000, .vsel_reg = ISL9305_LDO1OUT, .vsel_mask = 0x3f, .enable_reg = ISL9305_SYSTEM_PARAMETER, .enable_mask = ISL9305_LDO1_EN, .supply_name = "VINLDO1", .ops = &isl9305_ops, |
46942b21a regulator: isl930... |
113 |
.owner = THIS_MODULE, |
dec38b5ce regulator: isl930... |
114 115 116 |
}, [ISL9305_LDO2] = { .name = "LDO2", |
93a127b11 regulator: isl930... |
117 118 |
.of_match = of_match_ptr("ldo2"), .regulators_node = of_match_ptr("regulators"), |
dec38b5ce regulator: isl930... |
119 120 121 122 123 124 125 126 127 |
.n_voltages = 0x37, .min_uV = 900000, .uV_step = 50000, .vsel_reg = ISL9305_LDO2OUT, .vsel_mask = 0x3f, .enable_reg = ISL9305_SYSTEM_PARAMETER, .enable_mask = ISL9305_LDO2_EN, .supply_name = "VINLDO2", .ops = &isl9305_ops, |
46942b21a regulator: isl930... |
128 |
.owner = THIS_MODULE, |
dec38b5ce regulator: isl930... |
129 130 |
}, }; |
dec38b5ce regulator: isl930... |
131 132 133 134 135 136 137 |
static const struct regmap_config isl9305_regmap = { .reg_bits = 8, .val_bits = 8, .max_register = ISL9305_MAX_REG, .cache_type = REGCACHE_RBTREE, }; |
77e29598c regulator: Conver... |
138 |
static int isl9305_i2c_probe(struct i2c_client *i2c) |
dec38b5ce regulator: isl930... |
139 140 141 |
{ struct regulator_config config = { }; struct isl9305_pdata *pdata = i2c->dev.platform_data; |
dec38b5ce regulator: isl930... |
142 143 144 |
struct regulator_dev *rdev; struct regmap *regmap; int i, ret; |
dec38b5ce regulator: isl930... |
145 146 147 148 149 150 151 152 153 154 155 |
regmap = devm_regmap_init_i2c(i2c, &isl9305_regmap); if (IS_ERR(regmap)) { ret = PTR_ERR(regmap); dev_err(&i2c->dev, "Failed to create regmap: %d ", ret); return ret; } config.dev = &i2c->dev; for (i = 0; i < ARRAY_SIZE(isl9305_regulators); i++) { |
93a127b11 regulator: isl930... |
156 |
if (pdata) |
dec38b5ce regulator: isl930... |
157 |
config.init_data = pdata->init_data[i]; |
93a127b11 regulator: isl930... |
158 159 |
else config.init_data = NULL; |
dec38b5ce regulator: isl930... |
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
rdev = devm_regulator_register(&i2c->dev, &isl9305_regulators[i], &config); if (IS_ERR(rdev)) { ret = PTR_ERR(rdev); dev_err(&i2c->dev, "Failed to register %s: %d ", isl9305_regulators[i].name, ret); return ret; } } return 0; } #ifdef CONFIG_OF static const struct of_device_id isl9305_dt_ids[] = { |
6fd753572 regulator: isl930... |
178 179 180 181 |
{ .compatible = "isl,isl9305" }, /* for backward compat., don't use */ { .compatible = "isil,isl9305" }, { .compatible = "isl,isl9305h" }, /* for backward compat., don't use */ { .compatible = "isil,isl9305h" }, |
dec38b5ce regulator: isl930... |
182 183 |
{}, }; |
5b87af4cc regulator: isl930... |
184 |
MODULE_DEVICE_TABLE(of, isl9305_dt_ids); |
dec38b5ce regulator: isl930... |
185 186 187 188 189 190 191 192 193 194 195 196 |
#endif static const struct i2c_device_id isl9305_i2c_id[] = { { "isl9305", }, { "isl9305h", }, { } }; MODULE_DEVICE_TABLE(i2c, isl9305_i2c_id); static struct i2c_driver isl9305_regulator_driver = { .driver = { .name = "isl9305", |
dec38b5ce regulator: isl930... |
197 198 |
.of_match_table = of_match_ptr(isl9305_dt_ids), }, |
77e29598c regulator: Conver... |
199 |
.probe_new = isl9305_i2c_probe, |
dec38b5ce regulator: isl930... |
200 201 202 203 204 205 206 207 |
.id_table = isl9305_i2c_id, }; module_i2c_driver(isl9305_regulator_driver); MODULE_AUTHOR("Mark Brown"); MODULE_DESCRIPTION("Intersil ISL9305 DCDC regulator"); MODULE_LICENSE("GPL"); |