diff options
author | Hans de Goede <hdegoede@redhat.com> | 2017-10-11 05:41:20 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2017-10-27 09:51:51 -0400 |
commit | 0224d45c9d46401b6d7018a96cfe049c5da7d91c (patch) | |
tree | 9615ee7d2b6c0171f6f52a2aea55435e157653a3 | |
parent | 728fe6cef27444b6575c5e7ab5de13274610488b (diff) |
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 <hdegoede@redhat.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/busses/Kconfig | 5 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-cht-wc.c | 51 |
2 files changed, 49 insertions, 7 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 45a3f3ca29b3..009345d8f49d 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -198,6 +198,11 @@ config I2C_CHT_WC | |||
198 | SMBus controller found in the Intel Cherry Trail Whiskey Cove PMIC | 198 | SMBus controller found in the Intel Cherry Trail Whiskey Cove PMIC |
199 | found on some Intel Cherry Trail systems. | 199 | found on some Intel Cherry Trail systems. |
200 | 200 | ||
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 | |||
201 | config I2C_NFORCE2 | 206 | config I2C_NFORCE2 |
202 | tristate "Nvidia nForce2, nForce3 and nForce4" | 207 | tristate "Nvidia nForce2, nForce3 and nForce4" |
203 | depends on PCI | 208 | depends on PCI |
diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c index 190bbbc7bfee..0d05dadb2dc5 100644 --- a/drivers/i2c/busses/i2c-cht-wc.c +++ b/drivers/i2c/busses/i2c-cht-wc.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/acpi.h> | ||
19 | #include <linux/completion.h> | 20 | #include <linux/completion.h> |
20 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
21 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
@@ -25,6 +26,7 @@ | |||
25 | #include <linux/mfd/intel_soc_pmic.h> | 26 | #include <linux/mfd/intel_soc_pmic.h> |
26 | #include <linux/module.h> | 27 | #include <linux/module.h> |
27 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/power/bq24190_charger.h> | ||
28 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
29 | 31 | ||
30 | #define CHT_WC_I2C_CTRL 0x5e24 | 32 | #define CHT_WC_I2C_CTRL 0x5e24 |
@@ -232,13 +234,35 @@ static const struct irq_chip cht_wc_i2c_irq_chip = { | |||
232 | .name = "cht_wc_ext_chrg_irq_chip", | 234 | .name = "cht_wc_ext_chrg_irq_chip", |
233 | }; | 235 | }; |
234 | 236 | ||
237 | static const char * const bq24190_suppliers[] = { "fusb302-typec-source" }; | ||
238 | |||
235 | static const struct property_entry bq24190_props[] = { | 239 | 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), |
237 | PROPERTY_ENTRY_BOOL("omit-battery-class"), | 241 | PROPERTY_ENTRY_BOOL("omit-battery-class"), |
238 | PROPERTY_ENTRY_BOOL("disable-reset"), | 242 | PROPERTY_ENTRY_BOOL("disable-reset"), |
239 | { } | 243 | { } |
240 | }; | 244 | }; |
241 | 245 | ||
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 | |||
242 | static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) | 266 | static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) |
243 | { | 267 | { |
244 | struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); | 268 | struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); |
@@ -246,7 +270,9 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) | |||
246 | struct i2c_board_info board_info = { | 270 | struct i2c_board_info board_info = { |
247 | .type = "bq24190", | 271 | .type = "bq24190", |
248 | .addr = 0x6b, | 272 | .addr = 0x6b, |
273 | .dev_name = "bq24190", | ||
249 | .properties = bq24190_props, | 274 | .properties = bq24190_props, |
275 | .platform_data = &bq24190_pdata, | ||
250 | }; | 276 | }; |
251 | int ret, reg, irq; | 277 | int ret, reg, irq; |
252 | 278 | ||
@@ -314,11 +340,21 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) | |||
314 | if (ret) | 340 | if (ret) |
315 | goto remove_irq_domain; | 341 | goto remove_irq_domain; |
316 | 342 | ||
317 | board_info.irq = adap->client_irq; | 343 | /* |
318 | adap->client = i2c_new_device(&adap->adapter, &board_info); | 344 | * Normally the Whiskey Cove PMIC is paired with a TI bq24292i charger, |
319 | if (!adap->client) { | 345 | * connected to this i2c bus, and a max17047 fuel-gauge and a fusb302 |
320 | ret = -ENOMEM; | 346 | * USB Type-C controller connected to another i2c bus. In this setup |
321 | goto del_adapter; | 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 | } | ||
322 | } | 358 | } |
323 | 359 | ||
324 | platform_set_drvdata(pdev, adap); | 360 | platform_set_drvdata(pdev, adap); |
@@ -335,7 +371,8 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev) | |||
335 | { | 371 | { |
336 | struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev); | 372 | struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev); |
337 | 373 | ||
338 | i2c_unregister_device(adap->client); | 374 | if (adap->client) |
375 | i2c_unregister_device(adap->client); | ||
339 | i2c_del_adapter(&adap->adapter); | 376 | i2c_del_adapter(&adap->adapter); |
340 | irq_domain_remove(adap->irq_domain); | 377 | irq_domain_remove(adap->irq_domain); |
341 | 378 | ||