dt-bindings: vendor-prefixes: Add Injoinic
Samuel Holland
maintainerPATCH 1/3 dt-bindings: vendor-prefixes: Add Injoinic
Add prefix for Injoinic Technology Corp. (http://www.injoinic.com/)
---
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -561,6 +561,8 @@ patternProperties: description: InfoVision Optoelectronics Kunshan Co. Ltd. "^ingenic,.*": description: Ingenic Semiconductor + "^injoinic,.*": + description: Injoinic Technology Corp. "^innolux,.*": description: Innolux Corporation "^inside-secure,.*":
Signature · 1 line
2.33.1
Samuel Holland
maintainerPATCH 2/3 dt-bindings: trivial-devices: Add Injoinic power bank ICs
Some Injoinic power bank ICs feature an I2C interface which allows monitoring and controlling the battery charger and boost converter.
---
Documentation/devicetree/bindings/trivial-devices.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/trivial-devices.yaml +8 -0
@@ -141,6 +141,14 @@ properties: - infineon,xdpe12254 # Infineon Multi-phase Digital VR Controller xdpe12284 - infineon,xdpe12284 + # Injoinic IP5108 2.0A Power Bank IC with I2C + - injoinic,ip5108 + # Injoinic IP5109 2.1A Power Bank IC with I2C + - injoinic,ip5109 + # Injoinic IP5207 1.2A Power Bank IC with I2C + - injoinic,ip5207 + # Injoinic IP5209 2.4A Power Bank IC with I2C + - injoinic,ip5209 # Inspur Power System power supply unit version 1 - inspur,ipsps1 # Intersil ISL29028 Ambient Light and Proximity Sensor
Signature · 1 line
2.33.1
Re: [PATCH 2/3] dt-bindings: trivial-devices: Add Injoinic power bank ICs
Quoted 9 lines · Samuel Holland
Some Injoinic power bank ICs feature an I2C interface which allows monitoring and controlling the battery charger and boost converter.
Signed-off-by Samuel Holland <[email protected]>---
Documentation/devicetree/bindings/trivial-devices.yaml | 8 ++++++++ 1 file changed, 8 insertions(+)
Samuel Holland
maintainerPATCH 3/3 power: supply: Add a driver for Injoinic power bank ICs
In reply to Samuel HollandThis driver supports several chip variants which all share the same I2C register interface. Since the chip will turn off and become inaccessible under conditions outside of software control (e.g. upon button press or input voltage removal), some special handling is needed to delay the initialization of the IC until it is accessible.
---
MAINTAINERS | 5 + drivers/power/supply/Kconfig | 8 + drivers/power/supply/Makefile | 1 + drivers/power/supply/ip5xxx_power.c | 563 ++++++++++++++++++++++++++++ 4 files changed, 577 insertions(+) create mode 100644 drivers/power/supply/ip5xxx_power.c
MAINTAINERS +5 -0
@@ -9464,6 +9464,11 @@ F: include/linux/mfd/ingenic-tcu.h F: sound/soc/codecs/jz47* F: sound/soc/jz4740/ +INJOINIC IP5xxx POWER BANK IC DRIVER +M: Samuel Holland <[email protected]> +S: Maintained +F: drivers/power/supply/ip5xxx_power.c + INOTIFY M: Jan Kara <[email protected]> R: Amir Goldstein <[email protected]>
drivers/power/supply/Kconfig +8 -0
@@ -51,6 +51,14 @@ config GENERIC_ADC_BATTERY Say Y here to enable support for the generic battery driver which uses IIO framework to read adc. +config IP5XXX_POWER + tristate "Injoinic IP5xxx power bank IC driver" + depends on I2C + select REGMAP_I2C + help + Say Y to include support for Injoinic IP5xxx power bank ICs, + which include a battery charger and a boost converter. + config MAX8925_POWER tristate "MAX8925 battery charger support" depends on MFD_MAX8925
drivers/power/supply/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_GENERIC_ADC_BATTERY) += generic-adc-battery.o obj-$(CONFIG_PDA_POWER) += pda_power.o obj-$(CONFIG_APM_POWER) += apm_power.o obj-$(CONFIG_AXP20X_POWER) += axp20x_usb_power.o +obj-$(CONFIG_IP5XXX_POWER) += ip5xxx_power.o obj-$(CONFIG_MAX8925_POWER) += max8925_power.o obj-$(CONFIG_WM831X_BACKUP) += wm831x_backup.o obj-$(CONFIG_WM831X_POWER) += wm831x_power.o
drivers/power/supply/ip5xxx_power.c new file +563 -0
563 lines not on this page · raw message
Signature · 1 line
2.33.1
Re: [PATCH 3/3] power: supply: Add a driver for Injoinic power bank ICs
Hi,
Quoted 8 lines · Samuel Holland
This driver supports several chip variants which all share the same I2C register interface. Since the chip will turn off and become inaccessible under conditions outside of software control (e.g. upon button press or input voltage removal), some special handling is needed to delay the initialization of the IC until it is accessible.
Signed-off-by Samuel Holland <[email protected]>---
Thanks, driver looks mostly good to me. Just two things:
drivers/power/supply/ip5xxx_power.c line 506
Quoted 4 lines
[...]
drivers/power/supply/ip5xxx_power.c new file +3
-0+static const struct power_supply_desc ip5xxx_charger_desc = { + .name ="ip5xxx-charger" , + .type =POWER_SUPPLY_TYPE_BATTERY ,
POWER_SUPPLY_TYPE_BATTERY is the wrong type for a charger. Considering the chips want 5V on the input side as far as I could see, a sensible type is POWER_SUPPLY_TYPE_USB.
Quoted 11 lines
drivers/power/supply/ip5xxx_power.c new file +11
-0+ .properties = ip5xxx_charger_properties, + .num_properties = ARRAY_SIZE(ip5xxx_charger_properties), + .get_property = ip5xxx_charger_get_property, + .set_property = ip5xxx_charger_set_property, + .property_is_writeable = ip5xxx_charger_property_is_writeable, +}; + +static const struct regmap_config ip5xxx_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .max_register =IP5XXX_BATOCV_DAT1 ,
drivers/power/supply/ip5xxx_power.c line 527
Quoted 10 lines
drivers/power/supply/ip5xxx_power.c new file +10
-0+}; + +static int ip5xxx_power_probe (struct i2c_client *client) +{ +struct power_supply_config psy_cfg = {}; +struct device *dev = &client->dev; +struct power_supply *psy; +struct ip5xxx *ip5xxx; + + ip5xxx =devm_kzalloc (dev,sizeof (*ip5xxx),GFP_KERNEL );
if (!ip5xxx)
return -ENOMEM;
-- Sebastian
Quoted 38 lines
drivers/power/supply/ip5xxx_power.c new file +35
-0+ ip5xxx->regmap =devm_regmap_init_i2c (client, &ip5xxx_regmap_config); +if (IS_ERR (ip5xxx->regmap)) +return PTR_ERR (ip5xxx->regmap); + + psy_cfg.of_node = dev->of_node; + psy_cfg.drv_data = ip5xxx; + + psy =devm_power_supply_register (dev, &ip5xxx_charger_desc, &psy_cfg); +if (IS_ERR (psy)) +return PTR_ERR (psy); + +return 0 ; +} + +static const struct of_device_id ip5xxx_power_of_match[] = { + { .compatible ="injoinic,ip5108" }, + { .compatible ="injoinic,ip5109" }, + { .compatible ="injoinic,ip5207" }, + { .compatible ="injoinic,ip5209" }, + { } +}; +MODULE_DEVICE_TABLE (of, ip5xxx_power_of_match); + +static struct i2c_driver ip5xxx_power_driver = { + .probe_new = ip5xxx_power_probe, + .driver = { + .name ="ip5xxx-power" , + .of_match_table = ip5xxx_power_of_match, + } +}; +module_i2c_driver (ip5xxx_power_driver); + +MODULE_AUTHOR ("Samuel Holland <[email protected]>" ); +MODULE_DESCRIPTION ("Injoinic IP5xxx power bank IC driver" ); +MODULE_LICENSE ("GPL" );Signature · 1 line
2.33.1
Samuel Holland
maintainerRe: [PATCH 3/3] power: supply: Add a driver for Injoinic power bank ICs
Hi,
Quoted 14 lines · Sebastian Reichel
Hi,
Quoted 8 lines · Samuel Holland
This driver supports several chip variants which all share the same I2C register interface. Since the chip will turn off and become inaccessible under conditions outside of software control (e.g. upon button press or input voltage removal), some special handling is needed to delay the initialization of the IC until it is accessible.
Signed-off-by Samuel Holland <[email protected]>---
Thanks, driver looks mostly good to me. Just two things:
Quoted 8 lines
drivers/power/supply/ip5xxx_power.c line 506
Quoted 4 lines
[...]
drivers/power/supply/ip5xxx_power.c new file +3
-0+static const struct power_supply_desc ip5xxx_charger_desc = { + .name ="ip5xxx-charger" , + .type =POWER_SUPPLY_TYPE_BATTERY ,
POWER_SUPPLY_TYPE_BATTERYis the wrong type for a charger. Considering the chips want 5V on the input side as far as I could see, a sensible type isPOWER_SUPPLY_TYPE_USB.
The chip takes a 5V USB input, charges a battery, and then boosts the battery voltage back up to 5V on the output side (or passes the input voltage, if present, directly through to the output).
Currently only POWER_SUPPLY_PROP_ONLINE describes the output side of the chip. All of the other properties here describe the battery. For example, POWER_SUPPLY_PROP_VOLTAGE/CURRENT_NOW is the battery voltage/current, not the output voltage/current. That doesn't match what I would expect from POWER_SUPPLY_TYPE_USB.
Should there really be two separate power supplies, one for the battery of type POWER_SUPPLY_TYPE_BATTERY, and a second one for the output side of type POWER_SUPPLY_TYPE_USB, with the battery supplying the boost output stage? I'll send v2 with this idea; please let me know what you think.
Since these two supplies would share the same device and OF node, how would I link them together?
Quoted 23 lines
Quoted 11 lines
drivers/power/supply/ip5xxx_power.c new file +11
-0+ .properties = ip5xxx_charger_properties, + .num_properties = ARRAY_SIZE(ip5xxx_charger_properties), + .get_property = ip5xxx_charger_get_property, + .set_property = ip5xxx_charger_set_property, + .property_is_writeable = ip5xxx_charger_property_is_writeable, +}; + +static const struct regmap_config ip5xxx_regmap_config = { + .reg_bits =8 , + .val_bits =8 , + .max_register =IP5XXX_BATOCV_DAT1 ,drivers/power/supply/ip5xxx_power.c line 527
Quoted 10 lines
drivers/power/supply/ip5xxx_power.c new file +10
-0+}; + +static int ip5xxx_power_probe (struct i2c_client *client) +{ +struct power_supply_config psy_cfg = {}; +struct device *dev = &client->dev; +struct power_supply *psy; +struct ip5xxx *ip5xxx; + + ip5xxx =devm_kzalloc (dev,sizeof (*ip5xxx),GFP_KERNEL );if (!ip5xxx)
Quoted 1 line
return -ENOMEM;
I'll fix this in v2.
Regards,
Samuel
Quoted 40 lines
-- Sebastian
Quoted 38 lines
drivers/power/supply/ip5xxx_power.c new file +35
-0+ ip5xxx->regmap =devm_regmap_init_i2c (client, &ip5xxx_regmap_config); +if (IS_ERR (ip5xxx->regmap)) +return PTR_ERR (ip5xxx->regmap); + + psy_cfg.of_node = dev->of_node; + psy_cfg.drv_data = ip5xxx; + + psy =devm_power_supply_register (dev, &ip5xxx_charger_desc, &psy_cfg); +if (IS_ERR (psy)) +return PTR_ERR (psy); + +return 0 ; +} + +static const struct of_device_id ip5xxx_power_of_match[] = { + { .compatible ="injoinic,ip5108" }, + { .compatible ="injoinic,ip5109" }, + { .compatible ="injoinic,ip5207" }, + { .compatible ="injoinic,ip5209" }, + { } +}; +MODULE_DEVICE_TABLE (of, ip5xxx_power_of_match); + +static struct i2c_driver ip5xxx_power_driver = { + .probe_new = ip5xxx_power_probe, + .driver = { + .name ="ip5xxx-power" , + .of_match_table = ip5xxx_power_of_match, + } +}; +module_i2c_driver (ip5xxx_power_driver); + +MODULE_AUTHOR ("Samuel Holland <[email protected]>" ); +MODULE_DESCRIPTION ("Injoinic IP5xxx power bank IC driver" ); +MODULE_LICENSE ("GPL" );Signature · 1 line
2.33.1
Quoted 8 lines · Samuel Holland
Add prefix for Injoinic Technology Corp. (http://www.injoinic.com/)
Signed-off-by Samuel Holland <[email protected]>---
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)