Lines Matching +full:ilim +full:- +full:ma
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (C) 2011 - 2014 Intel Corporation. All rights reserved.
62 mutex_lock(&adap->adap_lock); in cht_wc_i2c_adap_thread_handler()
65 ret = regmap_read(adap->regmap, CHT_WC_EXTCHGRIRQ, ®); in cht_wc_i2c_adap_thread_handler()
67 dev_err(&adap->adapter.dev, "Error reading extchgrirq reg\n"); in cht_wc_i2c_adap_thread_handler()
68 mutex_unlock(&adap->adap_lock); in cht_wc_i2c_adap_thread_handler()
72 reg &= ~adap->irq_mask; in cht_wc_i2c_adap_thread_handler()
75 ret = regmap_read(adap->regmap, CHT_WC_I2C_RDDATA, &adap->read_data); in cht_wc_i2c_adap_thread_handler()
77 adap->io_error = true; in cht_wc_i2c_adap_thread_handler()
81 * handling the previous ones our irq will re-trigger when we're done. in cht_wc_i2c_adap_thread_handler()
83 ret = regmap_write(adap->regmap, CHT_WC_EXTCHGRIRQ, reg); in cht_wc_i2c_adap_thread_handler()
85 dev_err(&adap->adapter.dev, "Error writing extchgrirq reg\n"); in cht_wc_i2c_adap_thread_handler()
88 adap->io_error |= !!(reg & CHT_WC_EXTCHGRIRQ_NACK_IRQ); in cht_wc_i2c_adap_thread_handler()
89 adap->done = true; in cht_wc_i2c_adap_thread_handler()
92 mutex_unlock(&adap->adap_lock); in cht_wc_i2c_adap_thread_handler()
95 wake_up(&adap->wait); in cht_wc_i2c_adap_thread_handler()
104 generic_handle_irq_safe(adap->client_irq); in cht_wc_i2c_adap_thread_handler()
123 mutex_lock(&adap->adap_lock); in cht_wc_i2c_adap_smbus_xfer()
124 adap->io_error = false; in cht_wc_i2c_adap_smbus_xfer()
125 adap->done = false; in cht_wc_i2c_adap_smbus_xfer()
126 mutex_unlock(&adap->adap_lock); in cht_wc_i2c_adap_smbus_xfer()
128 ret = regmap_write(adap->regmap, CHT_WC_I2C_CLIENT_ADDR, addr); in cht_wc_i2c_adap_smbus_xfer()
133 ret = regmap_write(adap->regmap, CHT_WC_I2C_WRDATA, data->byte); in cht_wc_i2c_adap_smbus_xfer()
138 ret = regmap_write(adap->regmap, CHT_WC_I2C_REG_OFFSET, command); in cht_wc_i2c_adap_smbus_xfer()
142 ret = regmap_write(adap->regmap, CHT_WC_I2C_CTRL, in cht_wc_i2c_adap_smbus_xfer()
148 ret = wait_event_timeout(adap->wait, adap->done, msecs_to_jiffies(30)); in cht_wc_i2c_adap_smbus_xfer()
155 if (!adap->done) in cht_wc_i2c_adap_smbus_xfer()
156 return -ETIMEDOUT; in cht_wc_i2c_adap_smbus_xfer()
160 mutex_lock(&adap->adap_lock); in cht_wc_i2c_adap_smbus_xfer()
161 if (adap->io_error) in cht_wc_i2c_adap_smbus_xfer()
162 ret = -EIO; in cht_wc_i2c_adap_smbus_xfer()
164 data->byte = adap->read_data; in cht_wc_i2c_adap_smbus_xfer()
165 mutex_unlock(&adap->adap_lock); in cht_wc_i2c_adap_smbus_xfer()
176 * We are an i2c-adapter which itself is part of an i2c-client. This means that
177 * transfers done through us take adapter->bus_lock twice, once for our parent
178 * i2c-adapter and once to take our own bus_lock. Lockdep does not like this
180 * i2c-core's i2c_adapter_lock_bus function calls:
181 * rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter));
185 * i2c-client and MFD instantiated platform_device in the parent->child chain
192 * break things again since the i2c-mux code expects the root-adapter to have
199 rt_mutex_lock_nested(&adapter->bus_lock, 1); in cht_wc_i2c_adap_lock_bus()
205 return rt_mutex_trylock(&adapter->bus_lock); in cht_wc_i2c_adap_trylock_bus()
211 rt_mutex_unlock(&adapter->bus_lock); in cht_wc_i2c_adap_unlock_bus()
225 mutex_lock(&adap->irqchip_lock); in cht_wc_i2c_irq_lock()
233 if (adap->irq_mask != adap->old_irq_mask) { in cht_wc_i2c_irq_sync_unlock()
234 ret = regmap_write(adap->regmap, CHT_WC_EXTCHGRIRQ_MSK, in cht_wc_i2c_irq_sync_unlock()
235 adap->irq_mask); in cht_wc_i2c_irq_sync_unlock()
237 adap->old_irq_mask = adap->irq_mask; in cht_wc_i2c_irq_sync_unlock()
239 dev_err(&adap->adapter.dev, "Error writing EXTCHGRIRQ_MSK\n"); in cht_wc_i2c_irq_sync_unlock()
242 mutex_unlock(&adap->irqchip_lock); in cht_wc_i2c_irq_sync_unlock()
249 adap->irq_mask &= ~CHT_WC_EXTCHGRIRQ_CLIENT_IRQ; in cht_wc_i2c_irq_enable()
256 adap->irq_mask |= CHT_WC_EXTCHGRIRQ_CLIENT_IRQ; in cht_wc_i2c_irq_disable()
269 "tcpm-source-psy-i2c-fusb302" };
272 PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_suppliers),
273 PROPERTY_ENTRY_BOOL("omit-battery-class"),
274 PROPERTY_ENTRY_BOOL("disable-reset"),
285 .dev_name = "i2c-fusb302",
329 PROPERTY_ENTRY_BOOL("linux,skip-reset"),
330 PROPERTY_ENTRY_BOOL("linux,read-back-settings"),
346 /********** Lenovo Yogabook YB1-X90F/-X91F/-X91L charger settings **********/
350 PROPERTY_ENTRY_STRING_ARRAY("supplied-from",
352 PROPERTY_ENTRY_U32("linux,pump-express-vbus-max", 12000000),
353 PROPERTY_ENTRY_BOOL("linux,skip-reset"),
356 * somewhat low charge-current of 2048mA and worse to a battery-voltage
358 * Use our own values instead of "linux,read-back-settings" to fix this.
360 PROPERTY_ENTRY_U32("ti,charge-current", 4224000),
361 PROPERTY_ENTRY_U32("ti,battery-regulation-voltage", 4352000),
362 PROPERTY_ENTRY_U32("ti,termination-current", 256000),
363 PROPERTY_ENTRY_U32("ti,precharge-current", 128000),
364 PROPERTY_ENTRY_U32("ti,minimum-sys-voltage", 3500000),
365 PROPERTY_ENTRY_U32("ti,boost-voltage", 4998000),
366 PROPERTY_ENTRY_U32("ti,boost-max-current", 1400000),
367 PROPERTY_ENTRY_BOOL("ti,use-ilim-pin"),
385 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); in cht_wc_i2c_adap_i2c_probe()
394 adap = devm_kzalloc(&pdev->dev, sizeof(*adap), GFP_KERNEL); in cht_wc_i2c_adap_i2c_probe()
396 return -ENOMEM; in cht_wc_i2c_adap_i2c_probe()
398 init_waitqueue_head(&adap->wait); in cht_wc_i2c_adap_i2c_probe()
399 mutex_init(&adap->adap_lock); in cht_wc_i2c_adap_i2c_probe()
400 mutex_init(&adap->irqchip_lock); in cht_wc_i2c_adap_i2c_probe()
401 adap->irqchip = cht_wc_i2c_irq_chip; in cht_wc_i2c_adap_i2c_probe()
402 adap->regmap = pmic->regmap; in cht_wc_i2c_adap_i2c_probe()
403 adap->adapter.owner = THIS_MODULE; in cht_wc_i2c_adap_i2c_probe()
404 adap->adapter.class = I2C_CLASS_HWMON; in cht_wc_i2c_adap_i2c_probe()
405 adap->adapter.algo = &cht_wc_i2c_adap_algo; in cht_wc_i2c_adap_i2c_probe()
406 adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops; in cht_wc_i2c_adap_i2c_probe()
407 strscpy(adap->adapter.name, "PMIC I2C Adapter", in cht_wc_i2c_adap_i2c_probe()
408 sizeof(adap->adapter.name)); in cht_wc_i2c_adap_i2c_probe()
409 adap->adapter.dev.parent = &pdev->dev; in cht_wc_i2c_adap_i2c_probe()
411 /* Clear and activate i2c-adapter interrupts, disable client IRQ */ in cht_wc_i2c_adap_i2c_probe()
412 adap->old_irq_mask = adap->irq_mask = ~CHT_WC_EXTCHGRIRQ_ADAP_IRQMASK; in cht_wc_i2c_adap_i2c_probe()
414 ret = regmap_read(adap->regmap, CHT_WC_I2C_RDDATA, ®); in cht_wc_i2c_adap_i2c_probe()
418 ret = regmap_write(adap->regmap, CHT_WC_EXTCHGRIRQ, ~adap->irq_mask); in cht_wc_i2c_adap_i2c_probe()
422 ret = regmap_write(adap->regmap, CHT_WC_EXTCHGRIRQ_MSK, adap->irq_mask); in cht_wc_i2c_adap_i2c_probe()
427 adap->irq_domain = irq_domain_add_linear(NULL, 1, &irq_domain_simple_ops, NULL); in cht_wc_i2c_adap_i2c_probe()
428 if (!adap->irq_domain) in cht_wc_i2c_adap_i2c_probe()
429 return -ENOMEM; in cht_wc_i2c_adap_i2c_probe()
431 adap->client_irq = irq_create_mapping(adap->irq_domain, 0); in cht_wc_i2c_adap_i2c_probe()
432 if (!adap->client_irq) { in cht_wc_i2c_adap_i2c_probe()
433 ret = -ENOMEM; in cht_wc_i2c_adap_i2c_probe()
437 irq_set_chip_data(adap->client_irq, adap); in cht_wc_i2c_adap_i2c_probe()
438 irq_set_chip_and_handler(adap->client_irq, &adap->irqchip, in cht_wc_i2c_adap_i2c_probe()
441 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, in cht_wc_i2c_adap_i2c_probe()
447 i2c_set_adapdata(&adap->adapter, adap); in cht_wc_i2c_adap_i2c_probe()
448 ret = i2c_add_adapter(&adap->adapter); in cht_wc_i2c_adap_i2c_probe()
452 switch (pmic->cht_wc_model) { in cht_wc_i2c_adap_i2c_probe()
463 dev_warn(&pdev->dev, "Unknown model, not instantiating charger device\n"); in cht_wc_i2c_adap_i2c_probe()
468 board_info->irq = adap->client_irq; in cht_wc_i2c_adap_i2c_probe()
469 adap->client = i2c_new_client_device(&adap->adapter, board_info); in cht_wc_i2c_adap_i2c_probe()
470 if (IS_ERR(adap->client)) { in cht_wc_i2c_adap_i2c_probe()
471 ret = PTR_ERR(adap->client); in cht_wc_i2c_adap_i2c_probe()
480 i2c_del_adapter(&adap->adapter); in cht_wc_i2c_adap_i2c_probe()
482 irq_domain_remove(adap->irq_domain); in cht_wc_i2c_adap_i2c_probe()
490 i2c_unregister_device(adap->client); in cht_wc_i2c_adap_i2c_remove()
491 i2c_del_adapter(&adap->adapter); in cht_wc_i2c_adap_i2c_remove()
492 irq_domain_remove(adap->irq_domain); in cht_wc_i2c_adap_i2c_remove()