Lines Matching +full:chip +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 // max20086-regulator.c - MAX20086-MAX20089 camera power protector driver
49 u8 id; member
80 .id = (n) - 1, \
85 .enable_mask = 1 << ((n) - 1), \
86 .enable_val = 1 << ((n) - 1), \
104 static int max20086_regulators_register(struct max20086 *chip) in max20086_regulators_register() argument
108 for (i = 0; i < chip->info->num_outputs; i++) { in max20086_regulators_register()
109 struct max20086_regulator *reg = &chip->regulators[i]; in max20086_regulators_register()
113 config.dev = chip->dev; in max20086_regulators_register()
114 config.init_data = reg->init_data; in max20086_regulators_register()
115 config.driver_data = chip; in max20086_regulators_register()
116 config.of_node = reg->of_node; in max20086_regulators_register()
117 config.regmap = chip->regmap; in max20086_regulators_register()
118 config.ena_gpiod = chip->ena_gpiod; in max20086_regulators_register()
120 rdev = devm_regulator_register(chip->dev, reg->desc, &config); in max20086_regulators_register()
122 dev_err(chip->dev, in max20086_regulators_register()
124 reg->desc->name); in max20086_regulators_register()
128 reg->rdev = rdev; in max20086_regulators_register()
134 static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on) in max20086_parse_regulators_dt() argument
141 of_get_child_by_name(chip->dev->of_node, "regulators"); in max20086_parse_regulators_dt()
143 dev_err(chip->dev, "regulators node not found\n"); in max20086_parse_regulators_dt()
144 return -ENODEV; in max20086_parse_regulators_dt()
147 matches = devm_kcalloc(chip->dev, chip->info->num_outputs, in max20086_parse_regulators_dt()
150 return -ENOMEM; in max20086_parse_regulators_dt()
152 for (i = 0; i < chip->info->num_outputs; ++i) in max20086_parse_regulators_dt()
155 ret = of_regulator_match(chip->dev, node, matches, in max20086_parse_regulators_dt()
156 chip->info->num_outputs); in max20086_parse_regulators_dt()
158 dev_err(chip->dev, "Failed to match regulators\n"); in max20086_parse_regulators_dt()
159 return -EINVAL; in max20086_parse_regulators_dt()
164 for (i = 0; i < chip->info->num_outputs; i++) { in max20086_parse_regulators_dt()
165 struct max20086_regulator *reg = &chip->regulators[i]; in max20086_parse_regulators_dt()
167 reg->init_data = matches[i].init_data; in max20086_parse_regulators_dt()
168 reg->of_node = matches[i].of_node; in max20086_parse_regulators_dt()
169 reg->desc = &max20086_regulators[i]; in max20086_parse_regulators_dt()
171 if (reg->init_data) { in max20086_parse_regulators_dt()
172 if (reg->init_data->constraints.always_on || in max20086_parse_regulators_dt()
173 reg->init_data->constraints.boot_on) in max20086_parse_regulators_dt()
181 static int max20086_detect(struct max20086 *chip) in max20086_detect() argument
186 ret = regmap_read(chip->regmap, MAX20086_REG_ID, &data); in max20086_detect()
188 dev_err(chip->dev, "Failed to read DEVICE_ID reg: %d\n", ret); in max20086_detect()
192 if ((data & DEVICE_ID_MASK) != chip->info->id) { in max20086_detect()
193 dev_err(chip->dev, "Invalid device ID 0x%02x\n", data); in max20086_detect()
194 return -ENXIO; in max20086_detect()
221 struct max20086 *chip; in max20086_i2c_probe() local
226 chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); in max20086_i2c_probe()
227 if (!chip) in max20086_i2c_probe()
228 return -ENOMEM; in max20086_i2c_probe()
230 chip->dev = &i2c->dev; in max20086_i2c_probe()
231 chip->info = i2c_get_match_data(i2c); in max20086_i2c_probe()
233 i2c_set_clientdata(i2c, chip); in max20086_i2c_probe()
235 chip->regmap = devm_regmap_init_i2c(i2c, &max20086_regmap_config); in max20086_i2c_probe()
236 if (IS_ERR(chip->regmap)) { in max20086_i2c_probe()
237 ret = PTR_ERR(chip->regmap); in max20086_i2c_probe()
238 dev_err(chip->dev, "Failed to allocate register map: %d\n", ret); in max20086_i2c_probe()
242 ret = max20086_parse_regulators_dt(chip, &boot_on); in max20086_i2c_probe()
246 ret = max20086_detect(chip); in max20086_i2c_probe()
251 ret = regmap_update_bits(chip->regmap, MAX20086_REG_MASK, in max20086_i2c_probe()
255 dev_err(chip->dev, "Failed to disable interrupts: %d\n", ret); in max20086_i2c_probe()
263 * loader. Otherwise, request it with a low state to enter lower-power in max20086_i2c_probe()
267 chip->ena_gpiod = devm_gpiod_get_optional(chip->dev, "enable", flags); in max20086_i2c_probe()
268 if (IS_ERR(chip->ena_gpiod)) { in max20086_i2c_probe()
269 ret = PTR_ERR(chip->ena_gpiod); in max20086_i2c_probe()
270 dev_err(chip->dev, "Failed to get enable GPIO: %d\n", ret); in max20086_i2c_probe()
274 ret = max20086_regulators_register(chip); in max20086_i2c_probe()
276 dev_err(chip->dev, "Failed to register regulators: %d\n", ret); in max20086_i2c_probe()
284 .id = MAX20086_DEVICE_ID_MAX20086,
289 .id = MAX20086_DEVICE_ID_MAX20087,
294 .id = MAX20086_DEVICE_ID_MAX20088,
299 .id = MAX20086_DEVICE_ID_MAX20089,
334 MODULE_DESCRIPTION("MAX20086-MAX20089 Camera Power Protector Driver");