Skip to content

Commit 0224d45

Browse files
jwrdegoedeWolfram Sang
authored andcommitted
i2c-cht-wc: Add device-properties for fusb302 integration
Add device-properties to make the bq24292i charger connected to the bus get its input-current-limit from the fusb302 Type-C port controller which is used on boards with the cht-wc PMIC, as well as regulator_init_data for the 5V boost converter on the bq24292i. Since this means we now hook-up the bq24292i to the fusb302 Type-C port controller add a check for the ACPI device which instantiates the fusb302. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 728fe6c commit 0224d45

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

drivers/i2c/busses/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ config I2C_CHT_WC
198198
SMBus controller found in the Intel Cherry Trail Whiskey Cove PMIC
199199
found on some Intel Cherry Trail systems.
200200

201+
Note this controller is hooked up to a TI bq24292i charger-IC,
202+
combined with a FUSB302 Type-C port-controller as such it is advised
203+
to also select CONFIG_CHARGER_BQ24190=m and CONFIG_TYPEC_FUSB302=m
204+
(the fusb302 driver currently is in drivers/staging).
205+
201206
config I2C_NFORCE2
202207
tristate "Nvidia nForce2, nForce3 and nForce4"
203208
depends on PCI

drivers/i2c/busses/i2c-cht-wc.c

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* GNU General Public License for more details.
1717
*/
1818

19+
#include <linux/acpi.h>
1920
#include <linux/completion.h>
2021
#include <linux/delay.h>
2122
#include <linux/i2c.h>
@@ -25,6 +26,7 @@
2526
#include <linux/mfd/intel_soc_pmic.h>
2627
#include <linux/module.h>
2728
#include <linux/platform_device.h>
29+
#include <linux/power/bq24190_charger.h>
2830
#include <linux/slab.h>
2931

3032
#define CHT_WC_I2C_CTRL 0x5e24
@@ -232,21 +234,45 @@ static const struct irq_chip cht_wc_i2c_irq_chip = {
232234
.name = "cht_wc_ext_chrg_irq_chip",
233235
};
234236

237+
static const char * const bq24190_suppliers[] = { "fusb302-typec-source" };
238+
235239
static const struct property_entry bq24190_props[] = {
236-
PROPERTY_ENTRY_STRING("extcon-name", "cht_wcove_pwrsrc"),
240+
PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_suppliers),
237241
PROPERTY_ENTRY_BOOL("omit-battery-class"),
238242
PROPERTY_ENTRY_BOOL("disable-reset"),
239243
{ }
240244
};
241245

246+
static struct regulator_consumer_supply fusb302_consumer = {
247+
.supply = "vbus",
248+
/* Must match fusb302 dev_name in intel_cht_int33fe.c */
249+
.dev_name = "i2c-fusb302",
250+
};
251+
252+
static const struct regulator_init_data bq24190_vbus_init_data = {
253+
.constraints = {
254+
/* The name is used in intel_cht_int33fe.c do not change. */
255+
.name = "cht_wc_usb_typec_vbus",
256+
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
257+
},
258+
.consumer_supplies = &fusb302_consumer,
259+
.num_consumer_supplies = 1,
260+
};
261+
262+
static struct bq24190_platform_data bq24190_pdata = {
263+
.regulator_init_data = &bq24190_vbus_init_data,
264+
};
265+
242266
static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
243267
{
244268
struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
245269
struct cht_wc_i2c_adap *adap;
246270
struct i2c_board_info board_info = {
247271
.type = "bq24190",
248272
.addr = 0x6b,
273+
.dev_name = "bq24190",
249274
.properties = bq24190_props,
275+
.platform_data = &bq24190_pdata,
250276
};
251277
int ret, reg, irq;
252278

@@ -314,11 +340,21 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
314340
if (ret)
315341
goto remove_irq_domain;
316342

317-
board_info.irq = adap->client_irq;
318-
adap->client = i2c_new_device(&adap->adapter, &board_info);
319-
if (!adap->client) {
320-
ret = -ENOMEM;
321-
goto del_adapter;
343+
/*
344+
* Normally the Whiskey Cove PMIC is paired with a TI bq24292i charger,
345+
* connected to this i2c bus, and a max17047 fuel-gauge and a fusb302
346+
* USB Type-C controller connected to another i2c bus. In this setup
347+
* the max17047 and fusb302 devices are enumerated through an INT33FE
348+
* ACPI device. If this device is present register an i2c-client for
349+
* the TI bq24292i charger.
350+
*/
351+
if (acpi_dev_present("INT33FE", NULL, -1)) {
352+
board_info.irq = adap->client_irq;
353+
adap->client = i2c_new_device(&adap->adapter, &board_info);
354+
if (!adap->client) {
355+
ret = -ENOMEM;
356+
goto del_adapter;
357+
}
322358
}
323359

324360
platform_set_drvdata(pdev, adap);
@@ -335,7 +371,8 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
335371
{
336372
struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);
337373

338-
i2c_unregister_device(adap->client);
374+
if (adap->client)
375+
i2c_unregister_device(adap->client);
339376
i2c_del_adapter(&adap->adapter);
340377
irq_domain_remove(adap->irq_domain);
341378

0 commit comments

Comments
 (0)