Lines Matching +full:charger +full:- +full:detector
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Maxim MAX14656 / AL32 USB Charger Detector driver
8 * Components from Maxim AL32 Charger detection Driver for MX50 Yoshi Board
21 #include <linux/devm-helpers.h>
95 dev_err(&client->dev, in max14656_read_reg()
110 dev_err(&client->dev, in max14656_write_reg()
125 dev_err(&client->dev, "failed to block read reg 0x%x: %d\n", in max14656_read_block_reg()
142 max14656_read_block_reg(chip->client, MAX14656_DEVICE_ID, in max14656_irq_worker()
149 chip->psy_desc.type = chg_type_props[chg_type].type; in max14656_irq_worker()
151 chip->psy_desc.type = POWER_SUPPLY_TYPE_UNKNOWN; in max14656_irq_worker()
152 chip->online = 1; in max14656_irq_worker()
154 chip->online = 0; in max14656_irq_worker()
155 chip->psy_desc.type = POWER_SUPPLY_TYPE_UNKNOWN; in max14656_irq_worker()
158 power_supply_changed(chip->detect_psy); in max14656_irq_worker()
165 schedule_delayed_work(&chip->irq_work, msecs_to_jiffies(100)); in max14656_irq()
174 struct i2c_client *client = chip->client; in max14656_hw_init()
177 return -ENODEV; in max14656_hw_init()
180 dev_err(&client->dev, "wrong vendor ID %d\n", in max14656_hw_init()
182 return -ENODEV; in max14656_hw_init()
188 return -EINVAL; in max14656_hw_init()
196 return -EINVAL; in max14656_hw_init()
199 return -EINVAL; in max14656_hw_init()
202 return -EINVAL; in max14656_hw_init()
204 dev_info(&client->dev, "detected revision %d\n", rev); in max14656_hw_init()
216 val->intval = chip->online; in max14656_get_property()
219 val->strval = MAX14656_NAME; in max14656_get_property()
222 val->strval = MAX14656_MANUFACTURER; in max14656_get_property()
225 return -EINVAL; in max14656_get_property()
239 struct i2c_adapter *adapter = client->adapter; in max14656_probe()
240 struct device *dev = &client->dev; in max14656_probe()
243 int irq = client->irq; in max14656_probe()
248 return -ENODEV; in max14656_probe()
253 return -ENODEV; in max14656_probe()
258 return -ENOMEM; in max14656_probe()
261 chip->client = client; in max14656_probe()
262 chip->online = 0; in max14656_probe()
263 chip->psy_desc.name = MAX14656_NAME; in max14656_probe()
264 chip->psy_desc.type = POWER_SUPPLY_TYPE_UNKNOWN; in max14656_probe()
265 chip->psy_desc.properties = max14656_battery_props; in max14656_probe()
266 chip->psy_desc.num_properties = ARRAY_SIZE(max14656_battery_props); in max14656_probe()
267 chip->psy_desc.get_property = max14656_get_property; in max14656_probe()
268 chip->irq = irq; in max14656_probe()
272 return -ENODEV; in max14656_probe()
274 chip->detect_psy = devm_power_supply_register(dev, in max14656_probe()
275 &chip->psy_desc, &psy_cfg); in max14656_probe()
276 if (IS_ERR(chip->detect_psy)) { in max14656_probe()
278 return -EINVAL; in max14656_probe()
281 ret = devm_delayed_work_autocancel(dev, &chip->irq_work, in max14656_probe()
288 ret = devm_request_irq(dev, chip->irq, max14656_irq, in max14656_probe()
292 dev_err(dev, "request_irq %d failed\n", chip->irq); in max14656_probe()
293 return -EINVAL; in max14656_probe()
295 enable_irq_wake(chip->irq); in max14656_probe()
297 schedule_delayed_work(&chip->irq_work, msecs_to_jiffies(2000)); in max14656_probe()
324 MODULE_DESCRIPTION("MAX14656 USB charger detector");