Lines Matching +full:vbus +full:- +full:boost +full:- +full:supply
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"),
283 .supply = "vbus",
285 .dev_name = "i2c-fusb302",
312 .supply = "vbus",
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"),
383 /********** Lenovo Yogabook YT3-X90F charger settings **********/
387 * bq25892 charger settings for the round li-ion cells in the hinge,
391 PROPERTY_ENTRY_STRING_ARRAY("supplied-from", lenovo_yt3_bq25892_1_suppliers),
392 PROPERTY_ENTRY_STRING("linux,secondary-charger-name", "bq25890-charger-0"),
393 PROPERTY_ENTRY_U32("linux,iinlim-percentage", 60),
394 PROPERTY_ENTRY_U32("linux,pump-express-vbus-max", 12000000),
395 PROPERTY_ENTRY_BOOL("linux,skip-reset"),
398 * charge-current and battery-voltage of 2048mA resp 4.2V. Use the
399 * Android values instead of "linux,read-back-settings" to fix this.
401 PROPERTY_ENTRY_U32("ti,charge-current", 3072000),
402 PROPERTY_ENTRY_U32("ti,battery-regulation-voltage", 4352000),
403 PROPERTY_ENTRY_U32("ti,termination-current", 128000),
404 PROPERTY_ENTRY_U32("ti,precharge-current", 128000),
405 PROPERTY_ENTRY_U32("ti,minimum-sys-voltage", 3700000),
406 PROPERTY_ENTRY_BOOL("ti,use-ilim-pin"),
407 /* Set 5V boost current-limit to 1.2A (MAX/POR values are 2.45A/1.4A) */
408 PROPERTY_ENTRY_U32("ti,boost-voltage", 4998000),
409 PROPERTY_ENTRY_U32("ti,boost-max-current", 1200000),
417 /* bq25892 charger for the round li-ion cells in the hinge */
428 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); in cht_wc_i2c_adap_i2c_probe()
437 adap = devm_kzalloc(&pdev->dev, sizeof(*adap), GFP_KERNEL); in cht_wc_i2c_adap_i2c_probe()
439 return -ENOMEM; in cht_wc_i2c_adap_i2c_probe()
441 init_waitqueue_head(&adap->wait); in cht_wc_i2c_adap_i2c_probe()
442 mutex_init(&adap->adap_lock); in cht_wc_i2c_adap_i2c_probe()
443 mutex_init(&adap->irqchip_lock); in cht_wc_i2c_adap_i2c_probe()
444 adap->irqchip = cht_wc_i2c_irq_chip; in cht_wc_i2c_adap_i2c_probe()
445 adap->regmap = pmic->regmap; in cht_wc_i2c_adap_i2c_probe()
446 adap->adapter.owner = THIS_MODULE; in cht_wc_i2c_adap_i2c_probe()
447 adap->adapter.class = I2C_CLASS_HWMON; in cht_wc_i2c_adap_i2c_probe()
448 adap->adapter.algo = &cht_wc_i2c_adap_algo; in cht_wc_i2c_adap_i2c_probe()
449 adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops; in cht_wc_i2c_adap_i2c_probe()
450 strscpy(adap->adapter.name, "PMIC I2C Adapter", in cht_wc_i2c_adap_i2c_probe()
451 sizeof(adap->adapter.name)); in cht_wc_i2c_adap_i2c_probe()
452 adap->adapter.dev.parent = &pdev->dev; in cht_wc_i2c_adap_i2c_probe()
454 /* Clear and activate i2c-adapter interrupts, disable client IRQ */ in cht_wc_i2c_adap_i2c_probe()
455 adap->old_irq_mask = adap->irq_mask = ~CHT_WC_EXTCHGRIRQ_ADAP_IRQMASK; in cht_wc_i2c_adap_i2c_probe()
457 ret = regmap_read(adap->regmap, CHT_WC_I2C_RDDATA, ®); in cht_wc_i2c_adap_i2c_probe()
461 ret = regmap_write(adap->regmap, CHT_WC_EXTCHGRIRQ, ~adap->irq_mask); in cht_wc_i2c_adap_i2c_probe()
465 ret = regmap_write(adap->regmap, CHT_WC_EXTCHGRIRQ_MSK, adap->irq_mask); in cht_wc_i2c_adap_i2c_probe()
470 adap->irq_domain = irq_domain_add_linear(NULL, 1, &irq_domain_simple_ops, NULL); in cht_wc_i2c_adap_i2c_probe()
471 if (!adap->irq_domain) in cht_wc_i2c_adap_i2c_probe()
472 return -ENOMEM; in cht_wc_i2c_adap_i2c_probe()
474 adap->client_irq = irq_create_mapping(adap->irq_domain, 0); in cht_wc_i2c_adap_i2c_probe()
475 if (!adap->client_irq) { in cht_wc_i2c_adap_i2c_probe()
476 ret = -ENOMEM; in cht_wc_i2c_adap_i2c_probe()
480 irq_set_chip_data(adap->client_irq, adap); in cht_wc_i2c_adap_i2c_probe()
481 irq_set_chip_and_handler(adap->client_irq, &adap->irqchip, in cht_wc_i2c_adap_i2c_probe()
484 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, in cht_wc_i2c_adap_i2c_probe()
490 i2c_set_adapdata(&adap->adapter, adap); in cht_wc_i2c_adap_i2c_probe()
491 ret = i2c_add_adapter(&adap->adapter); in cht_wc_i2c_adap_i2c_probe()
495 switch (pmic->cht_wc_model) { in cht_wc_i2c_adap_i2c_probe()
509 dev_warn(&pdev->dev, "Unknown model, not instantiating charger device\n"); in cht_wc_i2c_adap_i2c_probe()
514 board_info->irq = adap->client_irq; in cht_wc_i2c_adap_i2c_probe()
515 adap->client = i2c_new_client_device(&adap->adapter, board_info); in cht_wc_i2c_adap_i2c_probe()
516 if (IS_ERR(adap->client)) { in cht_wc_i2c_adap_i2c_probe()
517 ret = PTR_ERR(adap->client); in cht_wc_i2c_adap_i2c_probe()
526 i2c_del_adapter(&adap->adapter); in cht_wc_i2c_adap_i2c_probe()
528 irq_domain_remove(adap->irq_domain); in cht_wc_i2c_adap_i2c_probe()
536 i2c_unregister_device(adap->client); in cht_wc_i2c_adap_i2c_remove()
537 i2c_del_adapter(&adap->adapter); in cht_wc_i2c_adap_i2c_remove()
538 irq_domain_remove(adap->irq_domain); in cht_wc_i2c_adap_i2c_remove()