Driver for UCS1002
Subsystems (2)
v4 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 [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
[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.20.1
PATCH v4 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.20.1
PATCH v4 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.20.1
Re: [PATCH v4 2/3] power: supply: Add driver for Microchip UCS1002
Quoted 5 lines · Andrey Smirnov
Add 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.
Quoted 9 lines
Signed-off-by Enric Balletbo Serra <[email protected]>Signed-off-by Andrey Smirnov <[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]>
PATCH v4 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-extended : 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.20.1
Re: [PATCH v4 3/3] dt-bindings: power: supply: Add bindings for Microchip UCS1002
Quoted 36 lines · Andrey Smirnov
Add bindings for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation.
Signed-off-by Andrey Smirnov <[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 Rob Herring <[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 +11
-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-extended : 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):
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 21
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +10
-0+ - "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>;
Document the above ? Or is that optional ?
[ I am not a DT expert, so feel free to ignore. ]
Guenter
Quoted 9 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +6
-0+ 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.20.1
Re: [PATCH v4 3/3] dt-bindings: power: supply: Add bindings for Microchip UCS1002
Quoted 20 lines · Guenter Roeck
Quoted 19 lines · Andrey Smirnov
Add bindings for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation.
Signed-off-by Andrey Smirnov <[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 Rob Herring <[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.txt
Quoted 15 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +0
-0Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 9
Quoted 9 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +9
-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-extended : A list of interrupts lines present (could be either + corresponding to A_DET# pin, ALERT# pin, or both)
Just make this 'interrupts'. Support for 'interrupts-extended' is implied.
With that,
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +6
-0+- 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:
Quoted 8 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 21
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +6
-0+ +&i2c3 { + charger@32 { + compatible = "microchip,ucs1002"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ucs1002_pins>;Document the above ? Or is that optional ?
I would have said to document this, but recently we had some discussion about allowing this to be implied when there's only a 'default' entry. We'll add it automatically for schemas.
Rob
Re: [PATCH v4 3/3] dt-bindings: power: supply: Add bindings for Microchip UCS1002
Quoted 59 lines · Rob Herring
Quoted 20 lines · Guenter Roeck
Quoted 19 lines · Andrey Smirnov
Add bindings for Microchip UCS1002 Programmable USB Port Power Controller with Charger Emulation.
Signed-off-by Andrey Smirnov <[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 Rob Herring <[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.txtQuoted 15 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +0
-0Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 9
Quoted 9 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +9
-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-extended : A list of interrupts lines present (could be either + corresponding to A_DET# pin, ALERT# pin, or both)Just make this 'interrupts'. Support for 'interrupts-extended' is implied.
With that,
Reviewed-by Rob Herring <[email protected]>Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +6
-0+- 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:Quoted 8 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt line 21
Quoted 6 lines
Documentation/devicetree/bindings/power/supply/microchip,ucs1002.txt new file +6
-0+ +&i2c3 { + charger@32 { + compatible = "microchip,ucs1002"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ucs1002_pins>;Document the above ? Or is that optional ?
Quoted 4 lines
I would have said to document this, but recently we had some discussion about allowing this to be implied when there's only a 'default' entry. We'll add it automatically for schemas.
Good to know. Thanks for the information!
Guenter