Driver for UCS1002
Subsystems (2)
v6 cover Driver for UCS1002
Everyone:
This small series adds a driver for UCS1002 Programmable USB Port Power Controller with Charger Emulation. See [page] for product page and [datasheet] for device dataseet. Hopefully each individual patch is self explanatory.
Note that this series is a revival of the upstreaming effort by Enric Balletbo Serra last version of which can be found at [original-effort]
Feedback is welcome!
Thanks,
Andrey Smirnov
Changes since [v5]:
- Collected Reviewed-by for "power: supply: Add driver for Microchip UCS1002" from Guenter
- Fixed Kconfig indentation issue
Changes since [v4]:
- Chagned "interrupts-extended" -> "interrupts" in DT bindings description
- Collected Reviewed-by from Rob
Changes since [v3]:
- Added a check for negative values to ucs1002_set_usb_type()
Changes since [v2]:
- Fixed a bug pointed out by Lucas
Changes since [v1]:
- Moved IRQ trigger specification to DT
- Fixed silent error paths in probe()
- Dropped error message in ucs1002_set_max_current()
- Fixed license mismatch
- Changed the driver to configure the chip to BC1.2 CDP by default
- Made other small fixes as per feedback for v1
[v5] https://lore.kernel.org/lkml/[email protected]
[v4] https://lore.kernel.org/lkml/[email protected]
[v3] https://lore.kernel.org/lkml/[email protected]
[v2] https://lore.kernel.org/lkml/[email protected]
[v1] https://lore.kernel.org/lkml/[email protected]/
[page] https://www.microchip.com/wwwproducts/en/UCS1002-2
[datasheet] https://ww1.microchip.com/downloads/en/DeviceDoc/UCS1002-2%20Data%20Sheet.pdf
[original-effort] https://lore.kernel.org/lkml/[email protected]/
Andrey Smirnov (3):
power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant
power: supply: Add driver for Microchip UCS1002
dt-bindings: power: supply: Add bindings for Microchip UCS1002
.../power/supply/microchip,ucs1002.txt | 27 + drivers/power/supply/Kconfig | 9 + drivers/power/supply/Makefile | 1 + drivers/power/supply/power_supply_sysfs.c | 2 +- drivers/power/supply/ucs1002_power.c | 646 ++++++++++++++++++ include/linux/power_supply.h | 1 + 6 files changed, 685 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt create mode 100644 drivers/power/supply/ucs1002_power.c
Signature · 1 line
2.21.0
PATCH v6 1/3 power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant
Add POWER_SUPPLY_HEALTH_OVERCURRENT constant in order to allow singalling overcurrent condition via power supply health information.
--- drivers/power/supply/power_supply_sysfs.c | 2 +- include/linux/power_supply.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/power/supply/power_supply_sysfs.c +1 -1
@@ -62,7 +62,7 @@ static const char * const power_supply_charge_type_text[] = {static const char *const power_supply_health_text[] = {"Unknown" ,"Good" ,"Overheat" ,"Dead" ,"Over voltage" ,"Unspecified failure" ,"Cold" ,"Watchdog timer expire" , -"Safety timer expire" +"Safety timer expire" ,"Over current" };static const char *const power_supply_technology_text[] = {
include/linux/power_supply.h +1 -0
@@ -57,6 +57,7 @@ enum {POWER_SUPPLY_HEALTH_COLD ,POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE ,POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE , + POWER_SUPPLY_HEALTH_OVERCURRENT, }; enum {
Signature · 1 line
2.21.0
PATCH v6 2/3 power: supply: Add driver for Microchip UCS1002
In reply to Andrey SmirnovAdd driver for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation. The driver exposed a power supply device to control/monitor various parameter of the device as well as a regulator to allow controlling VBUS line.
--- drivers/power/supply/Kconfig | 9 + drivers/power/supply/Makefile | 1 + drivers/power/supply/ucs1002_power.c | 646 +++++++++++++++++++++++++++ 3 files changed, 656 insertions(+) create mode 100644 drivers/power/supply/ucs1002_power.c
drivers/power/supply/Kconfig +9 -0
@@ -660,4 +660,13 @@ config FUEL_GAUGE_SC27XX Say Y here to enable support for fuel gauge with SC27XX PMIC chips. +config CHARGER_UCS1002 + tristate "Microchip UCS1002 USB Port Power Controller" + depends on I2C + depends on OF + select REGMAP_I2C + help + Say Y to enable support for Microchip UCS1002 Programmable + USB Port Power Controller with Charger Emulation. + endif # POWER_SUPPLY
drivers/power/supply/Makefile +1 -0
@@ -87,3 +87,4 @@ obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o obj-$(CONFIG_CHARGER_CROS_USBPD) += cros_usbpd-charger.o obj-$(CONFIG_CHARGER_SC2731) += sc2731_charger.o obj-$(CONFIG_FUEL_GAUGE_SC27XX) += sc27xx_fuel_gauge.o +obj-$(CONFIG_CHARGER_UCS1002) += ucs1002_power.o
drivers/power/supply/ucs1002_power.c new file +646 -0
646 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v6 3/3 dt-bindings: power: supply: Add bindings for Microchip UCS1002
In reply to Andrey SmirnovAdd bindings for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation.
--- .../power/supply/microchip,ucs1002.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +27 -0
@@ -0,0 +1,27 @@ +Microchip UCS1002 USB Port Power Controller + +Required properties: +- compatible : Should be "microchip,ucs1002"; +- reg : I2C slave address + +Optional properties: +- interrupts : A list of interrupts lines present (could be either + corresponding to A_DET# pin, ALERT# pin, or both) +- interrupt-names : A list of interrupt names. Should contain (if + present): + - "a_det" for line connected to A_DET# pin + - "alert" for line connected to ALERT# pin + Both are expected to be IRQ_TYPE_EDGE_BOTH +Example: + +&i2c3 { + charger@32 { + compatible = "microchip,ucs1002"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ucs1002_pins>; + reg = <0x32>; + interrupts-extended = <&gpio5 2 IRQ_TYPE_EDGE_BOTH>, + <&gpio3 21 IRQ_TYPE_EDGE_BOTH>; + interrupt-names = "a_det", "alert"; + }; +};
Signature · 1 line
2.21.0
Re: [PATCH v6 3/3] dt-bindings: power: supply: Add bindings for Microchip UCS1002
Quoted 38 lines · Andrey Smirnov
Add bindings for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation.
Signed-off-by Andrey Smirnov <[email protected]>Reviewed-by Rob Herring <[email protected]>Cc Enric Balletbo Serra <[email protected]>Cc Chris Healy <[email protected]>Cc Lucas Stach <[email protected]>Cc Fabio Estevam <[email protected]>Cc Guenter Roeck <[email protected]>Cc Sebastian Reichel <[email protected]>--- .../power/supply/microchip,ucs1002.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txtDocumentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +14
-0@@ -0,0 +1,27 @@ +Microchip UCS1002 USB Port Power Controller + +Required properties: +- compatible : Should be "microchip,ucs1002"; +- reg : I2C slave address + +Optional properties: +- interrupts : A list of interrupts lines present (could be either + corresponding to A_DET# pin, ALERT# pin, or both) +- interrupt-names : A list of interrupt names. Should contain (if + present): + - "a_det" for line connected to A_DET# pin + - "alert" for line connected to ALERT# pin + Both are expected to be IRQ_TYPE_EDGE_BOTH
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 24
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +10
-0+Example: + +&i2c3 { + charger@32 { + compatible = "microchip,ucs1002"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ucs1002_pins>; + reg = <0x32>; + interrupts-extended = <&gpio5 2 IRQ_TYPE_EDGE_BOTH>, + <&gpio3 21 IRQ_TYPE_EDGE_BOTH>;
interrupts ?
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +3
-0+ interrupt-names = "a_det", "alert"; + }; +};Signature · 1 line
2.21.0
Re: [PATCH v6 3/3] dt-bindings: power: supply: Add bindings for Microchip UCS1002
Quoted 44 lines · Guenter Roeck
Quoted 42 lines · Andrey Smirnov
Add bindings for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation.
Signed-off-by Andrey Smirnov <[email protected]>Reviewed-by Rob Herring <[email protected]>Cc Enric Balletbo Serra <[email protected]>Cc Chris Healy <[email protected]>Cc Lucas Stach <[email protected]>Cc Fabio Estevam <[email protected]>Cc Guenter Roeck <[email protected]>Cc Sebastian Reichel <[email protected]>--- .../power/supply/microchip,ucs1002.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txtDocumentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +18
-0@@ -0,0 +1,27 @@ +Microchip UCS1002 USB Port Power Controller + +Required properties: +- compatible : Should be "microchip,ucs1002"; +- reg : I2C slave address + +Optional properties: +- interrupts : A list of interrupts lines present (could be either + corresponding to A_DET# pin, ALERT# pin, or both) +- interrupt-names : A list of interrupt names. Should contain (if + present): + - "a_det" for line connected to A_DET# pin + - "alert" for line connected to ALERT# pin + Both are expected to be IRQ_TYPE_EDGE_BOTH +Example: + +&i2c3 { + charger@32 {
Quoted 8 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 24
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +6
-0+ compatible = "microchip,ucs1002"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ucs1002_pins>; + reg = <0x32>; + interrupts-extended = <&gpio5 2 IRQ_TYPE_EDGE_BOTH>, + <&gpio3 21 IRQ_TYPE_EDGE_BOTH>;interrupts ?
Can't really use it here since it assumes single "interrupt-parent" (we have gpio5 and gpio3 as parents above)
Thanks,
Andrey Smirnov
Re: [PATCH v6 3/3] dt-bindings: power: supply: Add bindings for Microchip UCS1002
Quoted 54 lines · Andrey Smirnov
Quoted 44 lines · Guenter Roeck
Quoted 42 lines · Andrey Smirnov
Add bindings for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation.
Signed-off-by Andrey Smirnov <[email protected]>Reviewed-by Rob Herring <[email protected]>Cc Enric Balletbo Serra <[email protected]>Cc Chris Healy <[email protected]>Cc Lucas Stach <[email protected]>Cc Fabio Estevam <[email protected]>Cc Guenter Roeck <[email protected]>Cc Sebastian Reichel <[email protected]>--- .../power/supply/microchip,ucs1002.txt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txtDocumentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +18
-0@@ -0,0 +1,27 @@ +Microchip UCS1002 USB Port Power Controller + +Required properties: +- compatible : Should be "microchip,ucs1002"; +- reg : I2C slave address + +Optional properties: +- interrupts : A list of interrupts lines present (could be either + corresponding to A_DET# pin, ALERT# pin, or both) +- interrupt-names : A list of interrupt names. Should contain (if + present): + - "a_det" for line connected to A_DET# pin + - "alert" for line connected to ALERT# pin + Both are expected to be IRQ_TYPE_EDGE_BOTH +Example: + +&i2c3 { + charger@32 {Quoted 8 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 24
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +6
-0+ compatible = "microchip,ucs1002"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ucs1002_pins>; + reg = <0x32>; + interrupts-extended = <&gpio5 2 IRQ_TYPE_EDGE_BOTH>, + <&gpio3 21 IRQ_TYPE_EDGE_BOTH>;interrupts ?
Quoted 3 lines
Can't really use it here since it assumes single "interrupt-parent" (we have gpio5 and gpio3 as parents above)
Ah, ok. Thanks for the clarification.
Guenter
Sebastian Reichel
maintainerHi,
Quoted 7 lines · Andrey Smirnov
This small series adds a driver for UCS1002 Programmable USB Port Power Controller with Charger Emulation. See [page] for product page and [datasheet] for device dataseet. Hopefully each individual patch is self explanatory.
Note that this series is a revival of the upstreaming effort by Enric Balletbo Serra last version of which can be found at [original-effort]
Thanks, queued (whole series).
-- Sebastian