Skip to contentSkip to conversation

Add Anbernic RG Vita-Pro

PATCH Superseded Chris Morgan 3 participants 8 messages Jul 22 – Jul 24

Subsystems (3)

v9 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v9 cover Add Anbernic RG Vita-Pro

From: Chris Morgan <[email protected]>

Add support for the Anbernic RG Vita-Pro, based on the Rockchip RK3576 SoC.

Changes Since V1:
- Updated documentation filename to matche compatible string.
- Corrected order of allocating IRQ in charger driver and switched to using devm managed function to allocate work queue.
Changes Since V2:
- Corrected issue with naming of panel binding document and added fallback compatible string.
- Switched to devm helpers in panel driver. Note that devm_drm_panel_add() is currently only in the drm-next branch.
- Optimized setting GPIOs for panel driver.
Changes Since V3:
- Fixed numerous issues identifed by Sashiko bot, mainly relating to unclamped or improperly clamped values from within the charger driver.
- Corrected hard-coded values in the panel driver unprepare routine as well as correcting an improperly checked return condition.
Changes Since V4:
- Fixed errors identified by Sashiko bot on charger driver that could result in an improper value being written to the registers.
- Corrected some error handling in the panel driver.
Changes Since V5:
- Corrected minor errors in documentation and added default values.
- Further corrected clamping behavior in charger driver.
Changes Since V6:
- Additional corrections as suggested by Sashiko bot to fix potential edge cases during probe for sgm41542.
- Corrected an improperly shifted value being written to register for sgm41542.
- Changed a MV value to UV in sgm41542 driver to simplify function.
Changes Since V7:
- Added PM functions to sgm41542 driver per request from Sashiko, which stops the hardware watchdog during suspend.
- Switched from device_init_wakeup() to devm_device_init_wakeup().
- Confirmed a state change in IRQ handler for sgm41542 to ensure we don't update input current limit except when the vbus goes from not okay to okay.
- Removed panel patches, which have already been accepted upstream. Please note that this *may* cause an error about missing bindings. See commit 0fd6ead8270270d859a28d0196a4b47e7d6845b8 in linux-next.
Changes Since V8:
- Added linux/bitfield.h header to prevent compile errors on certain platforms.
- Added regulator to Kconfig as a dependency.
- Added mutex to IRQ handling function.
- Added update to watchdog enable field in suspend routine to ensure watchdog status "goes back to the way it was" after resume.
- Sashiko complains of an issue if userspace updates values after devm_power_supply_register() is called but before the hardware limits are set from the device tree. While this is possible the threat of a problem should be very low given that the hardware limits are set immediately afterward and would overwrite any wrong values from userspace (should happen within a few milliseconds). Unfortunately, given that the function to get these limits requires the power supply be registered in order to read the battery node, it's not something that can be easily fixed at this time. Since it's an *extremely* unlikely edge case, I think that's acceptable.

Chris Morgan (4):
dt-bindings: power: supply: sgm41542: document sgm41542
power: supply: sgm41542: Add SG Micro sgm41542 charger
dt-bindings: arm: rockchip: Add Anbernic RG Vita-Pro
arm64: dts: rockchip: Add Anbernic RG Vita-Pro

 .../devicetree/bindings/arm/rockchip.yaml     |    6 +
 .../power/supply/sgmicro,sgm41542.yaml        |   96 ++
 arch/arm64/boot/dts/rockchip/Makefile         |    1 +
 .../rockchip/rk3576-anbernic-rg-vita-pro.dts  | 1327 +++++++++++++++++
 drivers/power/supply/Kconfig                  |    9 +
 drivers/power/supply/Makefile                 |    1 +
 drivers/power/supply/sgm41542_charger.c       | 1118 ++++++++++++++
 7 files changed, 2558 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/sgmicro,sgm41542.yaml
 create mode 100644 arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts
 create mode 100644 drivers/power/supply/sgm41542_charger.c
Signature · 1 line
2.43.0
#1 lore raw

PATCH v9 1/4 dt-bindings: power: supply: sgm41542: document sgm41542

From: Chris Morgan <[email protected]>

Document the SG Micro sgm41542 battery charger/boost converter. The parameters of input-current-limit-microamp and input-voltage-limit-microvolt are defined as such since they are in common use among multiple bindings currently.

---
 .../power/supply/sgmicro,sgm41542.yaml        | 96 +++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/sgmicro,sgm41542.yaml
Documentation/devicetree/bindings/power/supply/sgmicro,sgm41542.yaml new file +96 -0
new file mode 100644
index 000000000000..af80fe528505
@@ -0,0 +1,96 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/sgmicro,sgm41542.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SGM41542 Battery Charger
+
+description:
+  The SGMicro SGM41542 is a single cell battery charger/boost controller.
+
+maintainers:
+  - Chris Morgan <[email protected]>
+  - Xu Shengfei <[email protected]>
+
+allOf:
+  - $ref: power-supply.yaml#
+
+properties:
+  compatible:
+    const: sgmicro,sgm41542
+
+  input-current-limit-microamp:
+    default: 2400000
+    minimum: 100000
+    maximum: 3800000
+
+  input-voltage-limit-microvolt:
+    default: 4500000
+    minimum: 3900000
+    maximum: 12000000
+
+  interrupts:
+    maxItems: 1
+
+  monitored-battery:
+    description: |
+        The charger uses the following battery properties
+        constant-charge-current-max-microamp (default 2040000)
+        constant-charge-voltage-max-microvolt (default 4208000)
+        charge-term-current-microamp (default 180000)
+        precharge-current-microamp (default 180000)
+
+  reg:
+    maxItems: 1
+
+  regulators:
+    type: object
+    properties:
+      otg-vbus:
+        type: object
+        description: OTG boost regulator
+        $ref: /schemas/regulator/regulator.yaml
+        unevaluatedProperties: false
+    additionalProperties: false
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    battery: battery {
+      compatible = "simple-battery";
+      constant-charge-current-max-microamp = <10000000>;
+      constant-charge-voltage-max-microvolt = <4350000>;
+      precharge-current-microamp = <180000>;
+      charge-term-current-microamp = <300000>;
+    };
+
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      charger@3b {
+        compatible = "sgmicro,sgm41542";
+        reg = <0x3b>;
+        input-current-limit-microamp = <3000000>;
+        input-voltage-limit-microvolt = <4500000>;
+        interrupt-parent = <&gpio0>;
+        interrupts = <26 IRQ_TYPE_EDGE_FALLING>;
+        monitored-battery = <&battery>;
+
+        regulators {
+          otg-vbus {
+            regulator-max-microvolt = <5000000>;
+            regulator-min-microvolt = <5000000>;
+          };
+        };
+      };
+    };
Signature · 1 line
2.43.0
#2 lore raw

PATCH v9 2/4 power: supply: sgm41542: Add SG Micro sgm41542 charger

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add support for the SG Micro SGM41542 charger/boost converter. Driver was adapted from Rockchip BSP driver [1] and confirmed with vendor datasheet [2].

[1] https://github.com/rockchip-linux/kernel/blob/develop-6.6/drivers/power/supply/sgm41542_charger.c
[2] https://www.sg-micro.de/rect/assets/1e8de70b-657e-4156-be68-a64fdbe8e418/SGM41541_SGM41542.pdf

---
 drivers/power/supply/Kconfig            |    9 +
 drivers/power/supply/Makefile           |    1 +
 drivers/power/supply/sgm41542_charger.c | 1118 +++++++++++++++++++++++
 3 files changed, 1128 insertions(+)
 create mode 100644 drivers/power/supply/sgm41542_charger.c
drivers/power/supply/Kconfig +9 -0
index f0ede1cecb6a..6b2f755f97f3 100644
@@ -866,6 +866,15 @@ config CHARGER_S2M
 	  devices provide USB power supply information and also required
 	  for USB OTG role switching.
 
+config CHARGER_SGM41542
+	tristate "SGM41542 charger driver"
+	depends on I2C
+	depends on GPIOLIB || COMPILE_TEST
+	depends on REGULATOR
+	select REGMAP_I2C
+	help
+	  Say Y to enable support for the SGM41542 battery charger.
+
 config CHARGER_SMB347
 	tristate "Summit Microelectronics SMB3XX Battery Charger"
 	depends on I2C
drivers/power/supply/Makefile +1 -0
index 31fe4a145929..25d23ea3fcbd 100644
@@ -108,6 +108,7 @@ obj-$(CONFIG_CHARGER_BQ25980)	+= bq25980_charger.o
 obj-$(CONFIG_CHARGER_BQ256XX)	+= bq256xx_charger.o
 obj-$(CONFIG_CHARGER_RK817)	+= rk817_charger.o
 obj-$(CONFIG_CHARGER_S2M)	+= s2m-charger.o
+obj-$(CONFIG_CHARGER_SGM41542)	+= sgm41542_charger.o
 obj-$(CONFIG_CHARGER_SMB347)	+= smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090)	+= tps65090-charger.o
 obj-$(CONFIG_CHARGER_TPS65217)	+= tps65217_charger.o
drivers/power/supply/sgm41542_charger.c new file +1118 -0

1,118 lines not on this page · raw message

Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH V9 2/4] power: supply: sgm41542: Add SG Micro sgm41542 charger

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] The hardware watchdog timer remains permanently disabled after the first suspend/resume cycle.…

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] The hardware watchdog timer remains permanently disabled after the first suspend/resume cycle.
- [High] Concurrent sysfs reads mutate internal state without locking, silently swallowing IRQ edges.
- [High] The power supply is registered and exposed to userspace before driver data and hardware defaults are initialized.
- [Medium] Ignored return values from regmap_update_bits during hardware initialization.
- [Low] Pointer type mismatch when calling regmap_read.
--

--- Patch [2]: [PATCH V9 2/4] power: supply: sgm41542: Add SG Micro sgm41542 charger --- commit be99c7bac70834eb8af0ef1499024eb89ea7f026
Author: Chris Morgan <[email protected]>
power: supply: sgm41542: Add SG Micro sgm41542 charger

This commit adds support for the SG Micro SGM41542 charger/boost converter. The driver adapts a vendor BSP implementation to register a power supply, initialize I2C regmap, and manage charge parameters.

Quoted 6 lines
drivers/power/supply/sgm41542_charger.c new file +0 -0
new file mode 100644
index 0000000000000..dbce7ed2f8796
@@ -0,0 +1,1118 @@

[ ... ]

drivers/power/supply/sgm41542_charger.c line 548

Quoted 6 lines
drivers/power/supply/sgm41542_charger.c new file +6 -0
+static int sgm4154x_get_state(struct sgm4154x_device *sgm,
+			      struct sgm4154x_state *state)
+{
+	int reg, ret;
+
+	ret = regmap_read(sgm->regmap, SGM4154X_CHRG_STAT, &reg);

[Severity: Low]
Does passing an int pointer to regmap_read() cause a compiler warning here since the API expects an unsigned int pointer?

[ ... ]

Quoted 4 lines
drivers/power/supply/sgm41542_charger.c new file +4 -0
+static int sgm4154x_charger_get_property(struct power_supply *psy,
+					 enum power_supply_property psp,
+					 union power_supply_propval *val)
+{

drivers/power/supply/sgm41542_charger.c line 642

Quoted 10 lines
drivers/power/supply/sgm41542_charger.c new file +10 -0
+	struct sgm4154x_device *sgm = power_supply_get_drvdata(psy);
+	struct sgm4154x_state state;
+	int ret;
+
+	ret = sgm4154x_get_state(sgm, &state);
+	if (ret) {
+		dev_err(sgm->dev, "get state error!\n");
+		return ret;
+	}
+	sgm->state = state;

[Severity: High]
Could this un-locked assignment overwrite the cached state and break interrupt edge detection?

If a sysfs read races with a VBUS insertion interrupt, this might update sgm->state.vbus_gd to true before the IRQ thread runs. Then in sgm4154x_irq_handler_thread():

    if (state.vbus_gd && !oldstate.vbus_gd) {

Since oldstate caches the overwritten sgm->state, it would evaluate to false and silently drop the plug-in event, failing to apply the input current limit. Should this assignment be protected by sgm->lock, or removed if the getter only needs local state?

[ ... ]

Quoted 2 lines
drivers/power/supply/sgm41542_charger.c new file +2 -0
+static int sgm4154x_hw_init(struct sgm4154x_device *sgm)
+{

[ ... ]

Quoted 4 lines
drivers/power/supply/sgm41542_charger.c new file +4 -0
+	regmap_update_bits(sgm->regmap,
+			   SGM4154X_CHRG_CTRL_D,
+			   SGM4154X_JEITA_EN,
+			   0);

drivers/power/supply/sgm41542_charger.c line 890

Quoted 10 lines
drivers/power/supply/sgm41542_charger.c new file +10 -0
+
+	regmap_update_bits(sgm->regmap,
+			   SGM4154X_CHRG_CTRL_A,
+			   SGM4154X_IINDPM_INT_MASK,
+			   SGM4154X_IINDPM_INT_MASK);
+
+	regmap_update_bits(sgm->regmap,
+			   SGM4154X_CHRG_CTRL_A,
+			   SGM4154X_VINDPM_INT_MASK,
+			   SGM4154X_VINDPM_INT_MASK);

[Severity: Medium]
Is it intentional to ignore the return values from these hardware configuration writes, unlike the surrounding calls in this function?

If the I2C bus encounters a communication error, this could silently fail to configure the JEITA and DPM interrupt masks.

[ ... ]

drivers/power/supply/sgm41542_charger.c line 978

Quoted 13 lines
drivers/power/supply/sgm41542_charger.c new file +13 -0
+static void sgm_charger_work(struct work_struct *work)
+{
+	struct sgm4154x_device *sgm =
+		container_of(work,
+			     struct sgm4154x_device,
+			     sgm_delay_work.work);
+
+	sgm4154x_watchdog_timer_reset(sgm);
+	if (sgm->watchdog_enable)
+		queue_delayed_work(sgm->sgm_monitor_wq,
+				   &sgm->sgm_delay_work,
+				   msecs_to_jiffies(1000 * 5));
+}

[Severity: High]
Can the hardware watchdog timer remain permanently disabled after a suspend and resume cycle?

During suspend, sgm4154x_suspend() calls sgm4154x_set_watchdog_timer() with SGM4154X_WDT_TIMER_DISABLE. Upon resume, sgm4154x_resume() restarts this workqueue.

The worker function above pets the watchdog by setting WDT_RST, but does it ever re-program the CHRG_CTRL_5 configuration register to re-enable the timer duration? It seems the safety mechanism might remain turned off.

[ ... ]

Quoted 2 lines
drivers/power/supply/sgm41542_charger.c new file +2 -0
+static int sgm4154x_probe(struct i2c_client *client)
+{

[ ... ]

drivers/power/supply/sgm41542_charger.c line 1033

Quoted 12 lines
drivers/power/supply/sgm41542_charger.c new file +12 -0
+	ret = devm_delayed_work_autocancel(dev, &sgm->sgm_delay_work,
+					   sgm_charger_work);
+	if (ret)
+		return dev_err_probe(dev, ret, "Unable to register delayed work\n");
+
+	ret = sgm4154x_power_supply_init(sgm, dev);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to register power supply\n");
+
+	ret = sgm4154x_hw_init(sgm);
+	if (ret)
+		return dev_err_probe(dev, ret, "Cannot initialize the chip.\n");

[Severity: High]
Does registering the power supply before hw_init expose uninitialized limits to userspace?

If userspace triggers a sysfs write to change the charge voltage immediately after registration but before sgm4154x_hw_init() populates the default limits, sgm4154x_set_chrg_volt() might clamp the request against a zero-value sgm->init_data.max_vreg, potentially misconfiguring the hardware to its absolute minimum voltage. Should the hardware limits be initialized before registering the power supply?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw

PATCH v9 3/4 dt-bindings: arm: rockchip: Add Anbernic RG Vita-Pro

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add compatible string for the Anbernic RG Vita-Pro.

---
 Documentation/devicetree/bindings/arm/rockchip.yaml | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/arm/rockchip.yaml +6 -0
index 1a9dde18626d..b8babe9d3a26 100644
@@ -66,6 +66,12 @@ properties:
               - anbernic,rg-ds
           - const: rockchip,rk3568
 
+      - description: Anbernic RK3576 Handheld Gaming Console
+        items:
+          - enum:
+              - anbernic,rg-vita-pro
+          - const: rockchip,rk3576
+
       - description: Ariaboard Photonicat
         items:
           - const: ariaboard,photonicat
Signature · 1 line
2.43.0
#5 lore raw

PATCH v9 4/4 arm64: dts: rockchip: Add Anbernic RG Vita-Pro

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add device tree for the Anbernic RG Vita-Pro, based on the Rockchip RK3576. All hardware is currently working except for the accelerometer, the touchscreen, the battery monitor, and DisplayPort over USB-C. PWM is also missing currently, and as a result the LEDs and panel backlight are currently controlled via GPIO but will be changed to PWM once supported.

The Anbernic RG Vita-Pro includes the following hardware:
- A 1080x1920 DSI display with touch.
- 21 buttons.
- 3 LEDs.
- 64GB eMMC, 2 SDMMC slots.
- RTL8852BE WiFi (with Bluetooth via UART)
- 1 USB 3.0 USB-C port in OTG mode.
- 3.5mm headphone jack with play button support.
- 5000mAH battery

The following hardware has incomplete driver support and is not yet working:
- An Invensense icm42607p accelerometer.
- A Cellwise cw221x battery monitor.
- A Synaptics i2c touchscreen.
- DisplayPort over USB-C alt-mode.
- PWM controller.
- 2 Analog joysticks with LED controllers.

---
 arch/arm64/boot/dts/rockchip/Makefile         |    1 +
 .../rockchip/rk3576-anbernic-rg-vita-pro.dts  | 1327 +++++++++++++++++
 2 files changed, 1328 insertions(+)
 create mode 100644 arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts
arch/arm64/boot/dts/rockchip/Makefile +1 -0
index 761d82b4f4f2..7b003bc45dea 100644
@@ -165,6 +165,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-wolfvision-pf5.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-wolfvision-pf5-display-vz.dtbo
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3568-wolfvision-pf5-io-expander.dtbo
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3576-100ask-dshanpi-a1.dtb
+dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3576-anbernic-rg-vita-pro.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3576-armsom-sige5.dtb
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3576-armsom-sige5-v1.2-wifibt.dtbo
 dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3576-evb1-v10.dtb
arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts new file +1327 -0

1,327 lines not on this page · raw message

Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH V9 4/4] arm64: dts: rockchip: Add Anbernic RG Vita-Pro

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] The SD card slot 1 (&sdmmc) keeps its I/O voltage (VQMMC) active while its core power (VMMC) is…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The SD card slot 1 (&sdmmc) keeps its I/O voltage (VQMMC) active while its core power (VMMC) is turned off during system suspend.
- [Medium] The DisplayPort alt-mode Vendor Defined Object (VDO) is configured with an invalid value of 0xffffffff.
--

--- Patch [4]: [PATCH V9 4/4] arm64: dts: rockchip: Add Anbernic RG Vita-Pro --- commit 9b7e292cd22ab667469b2d0609662deb58a25790
Author: Chris Morgan <[email protected]>

arm64: dts: rockchip: Add Anbernic RG Vita-Pro

Add device tree for the Anbernic RG Vita-Pro, based on the Rockchip RK3576. All hardware is currently working except for the accelerometer, the touchscreen, the battery monitor, and DisplayPort over USB-C. PWM is also missing currently, and as a result the LEDs and panel backlight are currently controlled via GPIO but will be changed to PWM once supported.

Quoted 5 lines
arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts new file +0 -0
new file mode 100644
index 0000000000000..344ba18705338

[ ... ]

Quoted 13 lines
arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts new file +13 -0
+	vcc3v3_sd_s0: regulator-vcc3v3-sd-s0 {
+		compatible = "regulator-fixed";
+		enable-active-high;
+		gpio = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>;
+		pinctrl-0 = <&vcc_3v3_sd_s0_h>;
+		pinctrl-names = "default";
+		regulator-max-microvolt = <3300000>;
+		regulator-min-microvolt = <3300000>;
+		regulator-name = "vcc3v3_sd_s0";
+		regulator-state-mem {
+			regulator-off-in-suspend;
+		};
+	};

[ ... ]

arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts line 790

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts new file +10 -0
+			vccio_sd_s0: pldo-reg5 {
+				regulator-always-on;
+				regulator-boot-on;
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-name = "vccio_sd_s0";
+				regulator-state-mem {
+					regulator-on-in-suspend;
+				};
+			};

[Severity: Medium]
Will this configuration cause the SD card's internal I/O clamping diodes to be forward-biased during system suspend?

Since vccio_sd_s0 (used as vqmmc-supply for the sdmmc node) remains active with regulator-on-in-suspend, but vcc3v3_sd_s0 (used as vmmc-supply) is powered off with regulator-off-in-suspend, this can back-power the SD card.

Over time this could lead to excess battery drain and hardware degradation for both the SD card and the SoC's SD controller.

[ ... ]

arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts line 961

Quoted 6 lines
arch/arm64/boot/dts/rockchip/rk3576-anbernic-rg-vita-pro.dts new file +6 -0
+			altmodes {
+				displayport {
+					svid = /bits/ 16 <0xff01>;
+					vdo = <0xffffffff>;
+				};
+			};

[Severity: Medium]
Is 0xffffffff the intended Vendor Defined Object (VDO) value for the DisplayPort alt-mode in husb311?

This value asserts undefined reserved bits and advertises mutually exclusive capabilities (such as being both a DP plug and a receptacle simultaneously). This violates the DisplayPort Alt Mode specification and could break negotiation with compliant Type-C partners.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#7 lore raw
In reply to Chris Morgan

Hello Chris,

Quoted 53 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add support for the Anbernic RG Vita-Pro, based on the Rockchip RK3576 SoC.

Changes Since V1:
- Updated documentation filename to matche compatible string.
- Corrected order of allocating IRQ in charger driver and switched to using devm managed function to allocate work queue.
Changes Since V2:
- Corrected issue with naming of panel binding document and added fallback compatible string.
- Switched to devm helpers in panel driver. Note that devm_drm_panel_add() is currently only in the drm-next branch.
- Optimized setting GPIOs for panel driver.
Changes Since V3:
- Fixed numerous issues identifed by Sashiko bot, mainly relating to unclamped or improperly clamped values from within the charger driver.
- Corrected hard-coded values in the panel driver unprepare routine as well as correcting an improperly checked return condition.
Changes Since V4:
- Fixed errors identified by Sashiko bot on charger driver that could result in an improper value being written to the registers.
- Corrected some error handling in the panel driver.
Changes Since V5:
- Corrected minor errors in documentation and added default values.
- Further corrected clamping behavior in charger driver.
Changes Since V6:
- Additional corrections as suggested by Sashiko bot to fix potential edge cases during probe for sgm41542.
- Corrected an improperly shifted value being written to register for sgm41542.
- Changed a MV value to UV in sgm41542 driver to simplify function.
Changes Since V7:
- Added PM functions to sgm41542 driver per request from Sashiko, which stops the hardware watchdog during suspend.
- Switched from device_init_wakeup() to devm_device_init_wakeup().
- Confirmed a state change in IRQ handler for sgm41542 to ensure we don't update input current limit except when the vbus goes from not okay to okay.
- Removed panel patches, which have already been accepted upstream. Please note that this *may* cause an error about missing bindings. See commit 0fd6ead8270270d859a28d0196a4b47e7d6845b8 in linux-next.
Changes Since V8:
- Added linux/bitfield.h header to prevent compile errors on certain platforms.
- Added regulator to Kconfig as a dependency.
- Added mutex to IRQ handling function.
- Added update to watchdog enable field in suspend routine to ensure watchdog status "goes back to the way it was" after resume.
- Sashiko complains of an issue if userspace updates values after devm_power_supply_register() is called but before the hardware limits are set from the device tree. While this is possible the

Quoted 8 lines

threat of a problem should be very low given that the hardware limits are set immediately afterward and would overwrite any wrong values from userspace (should happen within a few milliseconds). Unfortunately, given that the function to get these limits requires the power supply be registered in order to read the battery node, it's not something that can be easily fixed at this time. Since it's an *extremely* unlikely edge case, I think that's acceptable.

Looks like there is more sensible Sashiko feedback. Regarding this one you can use this new functionality:

https://lore.kernel.org/linux-pm/[email protected]/

It's not yet merged, because it needs a user and I had some feedback on the follow-up max17042_battery patch using it. But I can take it together with the first user, so it's not a blocker.

Greetings,

-- Sebastian