Add power sequence for Amlogic WCN chips
Subsystems (2)
cover Add power sequence for Amlogic WCN chips
Add Amlogic WCN power sequence, including dt-binding, power sequence provider with Amlogic, and enable POWER_SEQUENCING_AML_WCN in defconfig.
---
Yang Li (3):
dt-bindings: power: Add power sequence for Amloigc WCN chips
power: sequenceing: Add power sequence for Amlogic WCN chips
MAINTAINERS: Add an entry for Amlogic WCN power sequence
.../bindings/power/amlogic,w155s2-pwrseq.yaml | 62 ++++++ MAINTAINERS | 8 + drivers/power/sequencing/Kconfig | 7 + drivers/power/sequencing/Makefile | 1 + drivers/power/sequencing/pwrseq-aml-wcn.c | 209 +++++++++++++++++++++ 5 files changed, 287 insertions(+)
---
base-commit: 0b58e108042b0ed28a71cd7edf5175999955b233
change-id: 20240701-pwrseq-2c7db60f7ad1
Best regards,
Signature · 1 line
Yang Li <[email protected]>
PATCH 1/3 dt-bindings: power: Add power sequence for Amloigc WCN chips
Add binding document to introduce power sequence of Amlogic WCN chips.
--- .../bindings/power/amlogic,w155s2-pwrseq.yaml | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+)
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/amlogic,w155s2-pwrseq.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Amlogic power sequence for WCN chips + +maintainers: + - Yang Li <[email protected]> + +description: + The Amlogic WCN chip contains discrete modules for WLAN and Bluetooth. Power on + Bluetooth and Wi-Fi respectively, including chip_en pull-up and bt_en pull-up, + and generation of the 32.768KHz clock. + +properties: + compatible: + oneOf: + - const: amlogic,w155s2-pwrseq + - items: + - enum: + - amlogic,w265s1-pwrseq + - amlogic,w265p1-pwrseq + - amlogic,w265s2-pwrseq + - const: amlogic,w155s2-pwrseq + + clocks: + maxItems: 1 + description: clock provided to the controller (32.768KHz) + + clock-names: + items: + - const: ext_clock + + amlogic,chip-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable chipset + + amlogic,bt-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable BT + +required: + - compatible + - clocks + - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq { + compatible = "amlogic,w155s2-pwrseq"; + clocks = <&extclk>; + clock-names = "ext_clock"; + amlogic,chip-enable-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + amlogic,bt-enable-gpios = <&gpio 17 GPIO_ACTIVE_HIGH>; + };
Signature · 1 line
2.42.0
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Quoted 6 lines · On Fri, Jul 5, 2024 at 1:13 PM Yang Li via B4 Relay…
From: Yang Li <[email protected]>
Add binding document to introduce power sequence of Amlogic WCN chips.
Hi! Thanks for the interest in this new subsystem.
Quoted 27 lines
Signed-off-by Yang Li <[email protected]>--- .../bindings/power/amlogic,w155s2-pwrseq.yaml | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+)Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +16
-0@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/amlogic,w155s2-pwrseq.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Amlogic power sequence for WCN chips + +maintainers: + - Yang Li <[email protected]> + +description: + The Amlogic WCN chip contains discrete modules for WLAN and Bluetooth. Power on + Bluetooth and Wi-Fi respectively, including chip_en pull-up and bt_en pull-up, + and generation of the 32.768KHz clock. +
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 26
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+properties: + compatible: + oneOf: + - const: amlogic,w155s2-pwrseq + - items: + - enum: + - amlogic,w265s1-pwrseq + - amlogic,w265p1-pwrseq + - amlogic,w265s2-pwrseq + - const: amlogic,w155s2-pwrseq
The name is wrong. There's no such device as 'pwrseq'. There's most likely some kind of a Power Management Unit and the compatible string must reflect this.
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 38
Quoted 12 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +12
-0+ + clocks: + maxItems: 1 + description: clock provided to the controller (32.768KHz) + + clock-names: + items: + - const: ext_clock + + amlogic,chip-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable chipset
Why not simply: chip-enable-gpios or even enable-gpios?
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 43
Quoted 5 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +5
-0+ + amlogic,bt-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable BT +
Same here: should be simply bt-enable-gpios.
Bart
Quoted 24 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +19
-1+required: + - compatible + - clocks + - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq { + compatible = "amlogic,w155s2-pwrseq"; + clocks = <&extclk>; + clock-names = "ext_clock"; + amlogic,chip-enable-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + amlogic,bt-enable-gpios = <&gpio 17 GPIO_ACTIVE_HIGH>; + }; --2.42.0
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Dear Bartosz
Thanks for your careful guidance and suggestions.
Quoted 41 lines
Quoted 5 lines · On Fri, Jul 5, 2024 at 1:13 PM Yang Li via B4 Relay…
From: Yang Li <[email protected]>
Add binding document to introduce power sequence of Amlogic WCN chips.
Hi! Thanks for the interest in this new subsystem.
Quoted 32 lines
Signed-off-by Yang Li <[email protected]>--- .../bindings/power/amlogic,w155s2-pwrseq.yaml | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+)Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +21
-0@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/amlogic,w155s2-pwrseq.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Amlogic power sequence for WCN chips + +maintainers: + - Yang Li <[email protected]> + +description: + The Amlogic WCN chip contains discrete modules for WLAN and Bluetooth. Power on + Bluetooth and Wi-Fi respectively, including chip_en pull-up and bt_en pull-up, + and generation of the 32.768KHz clock. + +properties: + compatible: + oneOf: + - const: amlogic,w155s2-pwrseq + - items:
Quoted 8 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 26
Quoted 5 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +5
-0+ - enum: + - amlogic,w265s1-pwrseq + - amlogic,w265p1-pwrseq + - amlogic,w265s2-pwrseq + - const: amlogic,w155s2-pwrseqThe name is wrong. There's no such device as 'pwrseq'. There's most likely some kind of a Power Management Unit and the compatible string must reflect this.
Yes, I got it!
I will change "pwrseq" to "pmu".
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +5
-0+ + clocks: + maxItems: 1 + description: clock provided to the controller (32.768KHz) +
Quoted 8 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 38
Quoted 7 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +7
-0+ clock-names: + items: + - const: ext_clock + + amlogic,chip-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable chipsetWhy not simply: chip-enable-gpios or even enable-gpios?
Well, I will do. "amlogic,chip-enable-gpios" => "enable-gpios"
Quoted 9 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 43
Quoted 6 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +5
-0+ + amlogic,bt-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable BT +Same here: should be simply bt-enable-gpios.
Bart
Well, I well change "amlogic,bt-enable-gpios" to "bt-enable-gpios".
Quoted 24 lines
Quoted 24 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +19
-1+required: + - compatible + - clocks + - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq { + compatible = "amlogic,w155s2-pwrseq"; + clocks = <&extclk>; + clock-names = "ext_clock"; + amlogic,chip-enable-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + amlogic,bt-enable-gpios = <&gpio 17 GPIO_ACTIVE_HIGH>; + }; --2.42.0
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
In reply to Yang LiQuoted 40 lines · On 05/07/2024 13:13, Yang Li via B4 Relay wrote:
From: Yang Li <[email protected]>
Add binding document to introduce power sequence of Amlogic WCN chips.
Signed-off-by Yang Li <[email protected]>--- .../bindings/power/amlogic,w155s2-pwrseq.yaml | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+)Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +24
-0@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/amlogic,w155s2-pwrseq.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Amlogic power sequence for WCN chips + +maintainers: + - Yang Li <[email protected]> + +description: + The Amlogic WCN chip contains discrete modules for WLAN and Bluetooth. Power on + Bluetooth and Wi-Fi respectively, including chip_en pull-up and bt_en pull-up, + and generation of the 32.768KHz clock. + +properties: + compatible: + oneOf: + - const: amlogic,w155s2-pwrseq + - items: + - enum: + - amlogic,w265s1-pwrseq + - amlogic,w265p1-pwrseq
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 34
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+ - amlogic,w265s2-pwrseq + - const: amlogic,w155s2-pwrseq + + clocks: + maxItems: 1 + description: clock provided to the controller (32.768KHz) + + clock-names: + items: + - const: ext_clock
Drop _clock... or actually drop entire clock-names, not much helpful.
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 38
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ + amlogic,chip-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable chipset
For entire chipset? Then enable-gpios
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 42
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ + amlogic,bt-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable BT
Follow existing bindings for Qualcomm as example.
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ +required: + - compatible + - clocks
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {
No underscores in node names, generic node names.
There is no device as "pwrseq". I also do not get what "wcn" means here.
Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Dear Krzysztof
Thanks for your immediate recovery and careful guidance.
Quoted 44 lines · On 05/07/2024 13:13, Yang Li via B4 Relay wrote:
Quoted 43 lines
From: Yang Li <[email protected]>
Add binding document to introduce power sequence of Amlogic WCN chips.
Signed-off-by Yang Li <[email protected]>--- .../bindings/power/amlogic,w155s2-pwrseq.yaml | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+)Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +27
-0@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/amlogic,w155s2-pwrseq.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Amlogic power sequence for WCN chips + +maintainers: + - Yang Li <[email protected]> + +description: + The Amlogic WCN chip contains discrete modules for WLAN and Bluetooth. Power on + Bluetooth and Wi-Fi respectively, including chip_en pull-up and bt_en pull-up, + and generation of the 32.768KHz clock. + +properties: + compatible: + oneOf: + - const: amlogic,w155s2-pwrseq + - items: + - enum: + - amlogic,w265s1-pwrseq + - amlogic,w265p1-pwrseq + - amlogic,w265s2-pwrseq + - const: amlogic,w155s2-pwrseq +
Quoted 8 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 34
Quoted 7 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +7
-0+ clocks: + maxItems: 1 + description: clock provided to the controller (32.768KHz) + + clock-names: + items: + - const: ext_clockDrop
_clock... or actually drop entire clock-names, not much helpful.
Got it~ will do.
Quoted 6 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 38
Quoted 5 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ + amlogic,chip-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable chipsetFor entire chipset? Then enable-gpios
Yes, I will change "amlogic,chip-enable-gpios" to "enable-gpio"
Quoted 5 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 42
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ + amlogic,bt-enable-gpios: + maxItems: 1 + description: gpio specifier used to enable BTFollow existing bindings for Qualcomm as example.
Okay, I will change "amlogic,bt-enable-gpios"to "bt-enable-gpios" follow
Qualcomm's example.
Quoted 16 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ +required: + - compatible + - clocksDocumentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {No underscores in node names, generic node names.
Quoted 1 line
There is no device as "pwrseq". I also do not get what "wcn" means here.
Yes, I understand.
Can I change "wcn_pwrseq" to "pmu", and do I need to change the binding file name to "amlogic,w155s2-pmu"
Quoted 3 lines
Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Quoted 16 lines · Yang Li
Quoted 16 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ +required: + - compatible + - clocksDocumentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {No underscores in node names, generic node names.
Quoted 5 lines
Quoted 1 line
There is no device as "pwrseq". I also do not get what "wcn" means here.
Yes, I understand.
Can I change "
wcn_pwrseq" to "pmu", and do I need to change the binding
What is pmu for your device? What is this device in the first place you are documenting? Where is the datasheet?
Quoted 1 line
file name to "amlogic,w155s2-pmu"
Yes, compatible should also match proper device.
Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Quoted 19 lines · Krzysztof Kozlowski
[ EXTERNAL EMAIL ]
Quoted 16 lines · Yang Li
Quoted 16 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ +required: + - compatible + - clocksDocumentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {No underscores in node names, generic node names.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
There is no device as "pwrseq". I also do not get what "wcn" means here.
Yes, I understand.
Can I change "
wcn_pwrseq" to "pmu", and do I need to change the bindingWhat is pmu for your device? What is this device in the first place you are documenting? Where is the datasheet?
^_^ Well, You are right, the "pmu" wasn't really fit in here.
I'd like to explain the current usage first, and could you please give me a suggestion?
This module(pwrseq) used to power on Bluetooth & Wi-Fi combo chip, both Bluetooth and
Wi-Fi driver need to control "chip-en-gpios" pins, so we introduced the power sequence module.
What should we call it in this case?
Quoted 7 lines
Quoted 1 line
file name to "amlogic,w155s2-pmu"
Yes, compatible should also match proper device.
Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Quoted 33 lines · Yang Li
Quoted 19 lines · Krzysztof Kozlowski
[ EXTERNAL EMAIL ]
Quoted 16 lines · Yang Li
Quoted 16 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ +required: + - compatible + - clocksDocumentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {No underscores in node names, generic node names.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
There is no device as "pwrseq". I also do not get what "wcn" means here.
Yes, I understand.
Can I change "
wcn_pwrseq" to "pmu", and do I need to change the bindingWhat is pmu for your device? What is this device in the first place you are documenting? Where is the datasheet?
^_^ Well, You are right, the "pmu" wasn't really fit in here.
I'd like to explain the current usage first, and could you please give me a suggestion?
Quoted 7 lines
This module(pwrseq) used to power on Bluetooth & Wi-Fi combo chip, both Bluetooth and
Wi-Fi driver need to control "chip-en-gpios" pins, so we introduced the power sequence module.
What should we call it in this case?
Sorry, you describe driver, not a device.
That would be a no-go for entire binding. Please describe the hardware, not what you want to achieve in Linux drivers.
Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Quoted 33 lines · Krzysztof Kozlowski
Quoted 32 lines · Yang Li
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Yang Li
Quoted 16 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +4
-0+ +required: + - compatible + - clocksDocumentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml line 56
Quoted 10 lines
Documentation/devicetree/bindings/power/amlogic,w155s2-pwrseq.yaml new file +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {No underscores in node names, generic node names.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
There is no device as "pwrseq". I also do not get what "wcn" means here.
Yes, I understand.
Can I change "
wcn_pwrseq" to "pmu", and do I need to change the bindingWhat is pmu for your device? What is this device in the first place you are documenting? Where is the datasheet?
^_^ Well, You are right, the "pmu" wasn't really fit in here.
I'd like to explain the current usage first, and could you please give me a suggestion?
This module(pwrseq) used to power on Bluetooth & Wi-Fi combo chip, both Bluetooth and
Quoted 8 lines
Quoted 4 lines
Wi-Fi driver need to control "chip-en-gpios" pins, so we introduced the power sequence module.
What should we call it in this case?
Sorry, you describe driver, not a device.
That would be a no-go for entire binding. Please describe the hardware, not what you want to achieve in Linux drivers.
W155s2 is a Bluetooth and WiFi combination chip. Bluetooth requires the bt-en pin to be pulled up, the chip-en pin to be pulled up, and the 32.768KHz clock. WiFi requires the chip-en pin to be pulled up, and the 32.768KHz clock. It can be seen that Bluetooth and WiFi are coupled to the chip-en pin and the 32.768KHz clock. When Bluetooth and WiFi are working at the same time, no matter which one is turned off, it will affect the other device. Therefore, a pwrseq device is now abstracted to manage the chip-en pin, bt-en pin, and the 32.768KHz clock.
There is currently no matching device name for the pwrseq composite device.
Could you please give me some advice?
Quoted 4 lines
Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Quoted 21 lines · Yang Li
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Yang Li
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Yang Li
Quoted 16 lines
Quoted 4 lines
(quoted diff) +4
-0+ +required: + - compatible + - clocksReview
Quoted 10 lines
(quoted diff) +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {No underscores in node names, generic node names.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
There is no device as "pwrseq". I also do not get what "wcn" means here.
Yes, I understand.
Can I change "
wcn_pwrseq" to "pmu", and do I need to change the bindingWhat is pmu for your device? What is this device in the first place you are documenting? Where is the datasheet?
^_^ Well, You are right, the "pmu" wasn't really fit in here.
So no datasheet? Then you are on your own.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
I'd like to explain the current usage first, and could you please give me a suggestion?
This module(pwrseq) used to power on Bluetooth & Wi-Fi combo chip, both Bluetooth and
Wi-Fi driver need to control "chip-en-gpios" pins, so we introduced the power sequence module.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
What should we call it in this case?
Sorry, you describe driver, not a device.
That would be a no-go for entire binding. Please describe the hardware, not what you want to achieve in Linux drivers.
W155s2 is a Bluetooth and WiFi combination chip. Bluetooth requires the
I asked about this device here.
You speak now about W155s2 but everywhere else you were using "WCN". What is that WCN?
Quoted 6 lines
bt-en pin to be pulled up, the chip-en pin to be pulled up, and the 32.768KHz clock. WiFi requires the chip-en pin to be pulled up, and the 32.768KHz clock. It can be seen that Bluetooth and WiFi are coupled to the chip-en pin and the 32.768KHz clock. When Bluetooth and WiFi are working at the same time, no matter which one is turned off, it will affect the other device. Therefore, a pwrseq device is now abstracted to
It is the first time you mention pwrseq device from above paragraph. Nothing above describes pwrseq.
Stop describing your problem, we all know it exactly if you follow the discussions about power sequencing. Instead describe this particular device you add binding for. What is this pwrseq in hardware? How does it look? Where is it located? What are its pins? What are its supplies?
Quoted 4 lines
manage the chip-en pin, bt-en pin, and the 32.768KHz clock.
There is currently no matching device name for the pwrseq composite device.
? No clue what does this mean.
Quoted 2 lines
Could you please give me some advice?
Again, you do not describe the device for the binding but something else. Something for your drivers, sorry. No.
If you disagree, respond accurately to all questions above, not to only some of them...
Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: Add power sequence for Amloigc WCN chips
Quoted 79 lines · Krzysztof Kozlowski
Quoted 21 lines · Yang Li
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Yang Li
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Yang Li
Quoted 16 lines
Quoted 4 lines
(quoted diff) +4
-0+ +required: + - compatible + - clocksReview
Quoted 10 lines
(quoted diff) +10
-0+ - clock-names + - amlogic,chip-enable-gpios + - amlogic,bt-enable-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + wcn_pwrseq {No underscores in node names, generic node names.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
There is no device as "pwrseq". I also do not get what "wcn" means here.
Yes, I understand.
Can I change "
wcn_pwrseq" to "pmu", and do I need to change the bindingWhat is pmu for your device? What is this device in the first place you are documenting? Where is the datasheet?
^_^ Well, You are right, the "pmu" wasn't really fit in here.
So no datasheet? Then you are on your own.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
I'd like to explain the current usage first, and could you please give me a suggestion?
This module(pwrseq) used to power on Bluetooth & Wi-Fi combo chip, both Bluetooth and
Wi-Fi driver need to control "chip-en-gpios" pins, so we introduced the power sequence module.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
What should we call it in this case?
Sorry, you describe driver, not a device.
That would be a no-go for entire binding. Please describe the hardware, not what you want to achieve in Linux drivers.
W155s2 is a Bluetooth and WiFi combination chip. Bluetooth requires the
I asked about this device here.
You speak now about W155s2 but everywhere else you were using "WCN". What is that WCN?
Quoted 6 lines
bt-en pin to be pulled up, the chip-en pin to be pulled up, and the 32.768KHz clock. WiFi requires the chip-en pin to be pulled up, and the 32.768KHz clock. It can be seen that Bluetooth and WiFi are coupled to the chip-en pin and the 32.768KHz clock. When Bluetooth and WiFi are working at the same time, no matter which one is turned off, it will affect the other device. Therefore, a pwrseq device is now abstracted to
It is the first time you mention pwrseq device from above paragraph. Nothing above describes pwrseq.
Stop describing your problem, we all know it exactly if you follow the discussions about power sequencing. Instead describe this particular device you add binding for. What is this pwrseq in hardware? How does it look? Where is it located? What are its pins? What are its supplies?
Quoted 4 lines
manage the chip-en pin, bt-en pin, and the 32.768KHz clock.
There is currently no matching device name for the pwrseq composite device.
? No clue what does this mean.
Quoted 2 lines
Could you please give me some advice?
Quoted 9 lines
Again, you do not describe the device for the binding but something else. Something for your drivers, sorry. No.
If you disagree, respond accurately to all questions above, not to only some of them...
Best regards,
Krzysztof
Yang, please look at the existing pwrseq-qcom-wcn.c driver and its bindings. They do exactly what you most likely want to do here. They describe the power management unit of the chipset, its inputs from host and outputs consumed by the WLAN and BT modules. Please try to follow it for your device.
Bart
PATCH 2/3 power: sequenceing: Add power sequence for Amlogic WCN chips
In reply to Yang LiAdd power sequence for Bluetooth and Wi-Fi respectively, including chip_en pull-up and bt_en pull-up, and generation of the 32.768 clock.
--- drivers/power/sequencing/Kconfig | 7 + drivers/power/sequencing/Makefile | 1 + drivers/power/sequencing/pwrseq-aml-wcn.c | 209 ++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+)
drivers/power/sequencing/Kconfig +7 -0
@@ -26,4 +26,11 @@ config POWER_SEQUENCING_QCOM_WCN this driver is needed for correct power control or else we'd risk not respecting the required delays between enabling Bluetooth and WLAN. +config POWER_SEQUENCING_AML_WCN + tristate "Amlogic WCN family PMU driver" + default m if ARCH_MESON + help + Say Y here to enable the power sequencing driver for Amlogic + WCN Bluetooth/WLAN chipsets. + endif
drivers/power/sequencing/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_POWER_SEQUENCING) += pwrseq-core.o pwrseq-core-y := core.o obj-$(CONFIG_POWER_SEQUENCING_QCOM_WCN) += pwrseq-qcom-wcn.o +obj-$(CONFIG_POWER_SEQUENCING_AML_WCN) += pwrseq-aml-wcn.o
drivers/power/sequencing/pwrseq-aml-wcn.c new file +209 -0
209 lines not on this page · raw message
Signature · 1 line
2.42.0
Re: [PATCH 2/3] power: sequenceing: Add power sequence for Amlogic WCN chips
Quoted 47 lines · On Fri, Jul 5, 2024 at 1:13 PM Yang Li via B4 Relay…
From: Yang Li <[email protected]>
Add power sequence for Bluetooth and Wi-Fi respectively, including
chip_enpull-up andbt_enpull-up, and generation of the 32.768 clock.Signed-off-by Yang Li <[email protected]>--- drivers/power/sequencing/Kconfig | 7 + drivers/power/sequencing/Makefile | 1 + drivers/power/sequencing/pwrseq-aml-wcn.c | 209 ++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+)drivers/power/sequencing/Kconfig +7
-0@@ -26,4 +26,11 @@ config POWER_SEQUENCING_QCOM_WCN this driver is needed for correct power control or else we'd risk not respecting the required delays between enabling Bluetooth and WLAN. +config POWER_SEQUENCING_AML_WCN + tristate "Amlogic WCN family PMU driver" + default m if ARCH_MESON + help + Say Y here to enable the power sequencing driver for Amlogic + WCN Bluetooth/WLAN chipsets. + endifdrivers/power/sequencing/Makefile +1
-0@@ -4,3 +4,4 @@ obj-$(CONFIG_POWER_SEQUENCING) += pwrseq-core.o pwrseq-core-y := core.o obj-$(CONFIG_POWER_SEQUENCING_QCOM_WCN) += pwrseq-qcom-wcn.o +obj-$(CONFIG_POWER_SEQUENCING_AML_WCN) += pwrseq-aml-wcn.odrivers/power/sequencing/pwrseq-aml-wcn.c new file +3
-0@@ -0,0 +1,209 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR MIT) +/* +* Copyright (C) 2024 Amlogic, Inc. All rights reserved
drivers/power/sequencing/pwrseq-aml-wcn.c line 13
Quoted 10 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +10
-0+*/ + +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/gpio.h>
Please see line 5 in this file.
drivers/power/sequencing/pwrseq-aml-wcn.c line 14
Quoted 1 line
drivers/power/sequencing/pwrseq-aml-wcn.c new file +1
-0+#include <linux/of_gpio.h>
You don't need this either.
Quoted 5 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +5
-0+#include <linux/platform_device.h> +#include <linux/pwrseq/provider.h> +#include <linux/string.h> +#include <linux/types.h> +
drivers/power/sequencing/pwrseq-aml-wcn.c line 29
Quoted 10 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +10
-0+struct pwrseq_aml_wcn_ctx { +struct pwrseq_device *pwrseq; +int bt_enable_gpio; +int chip_enable_gpio; +struct clk *lpo_clk; +unsigned int pwr_count; +}; + +static DEFINE_MUTEX (pwrseq_lock); +
Why is this global?
drivers/power/sequencing/pwrseq-aml-wcn.c line 35
Quoted 6 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +6
-0+static int pwrseq_aml_wcn_chip_enable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); +int err; + +mutex_lock (&pwrseq_lock);
Please use guard() from linux/cleanup.h.
drivers/power/sequencing/pwrseq-aml-wcn.c line 39
Quoted 4 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +4
-0+if (ctx->pwr_count ==0 ) { +gpio_request (ctx->chip_enable_gpio,"chip-enable-gpios" ); +gpio_direction_output (ctx->chip_enable_gpio,1 ); +gpio_free (ctx->chip_enable_gpio);
Not only are these legacy APIs but they are also used wrong. You almost never want to release the GPIO after setting the direction as someone else may grab it and use it.
Quoted 95 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +95
-0+ +if (!IS_ERR (ctx->lpo_clk)) { + err =clk_prepare_enable (ctx->lpo_clk); +if (err) { +mutex_unlock (&pwrseq_lock); +return err; + } + } + } + + ctx->pwr_count++; +mutex_unlock (&pwrseq_lock); +return 0 ; +} + +static int pwrseq_aml_wcn_chip_disable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); + +mutex_lock (&pwrseq_lock); +if (--ctx->pwr_count ==0 ) { +gpio_request (ctx->chip_enable_gpio,"chip-enable-gpios" ); +gpio_direction_output (ctx->chip_enable_gpio,0 ); +gpio_free (ctx->chip_enable_gpio); + +if (!IS_ERR (ctx->lpo_clk)) +clk_disable_unprepare (ctx->lpo_clk); + } + +mutex_unlock (&pwrseq_lock); +return 0 ; +} + +static const struct pwrseq_unit_data pwrseq_aml_wcn_chip_power_unit_data = { + .name ="chip-enable" , + .enable = pwrseq_aml_wcn_chip_enable, + .disable = pwrseq_aml_wcn_chip_disable, +}; + +static const struct pwrseq_unit_data *pwrseq_aml_wcn_unit_deps[] = { + &pwrseq_aml_wcn_chip_power_unit_data, +NULL +}; + +static int pwrseq_aml_wcn_bt_enable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); + +gpio_request (ctx->bt_enable_gpio,"bt-enable-gpios" ); +gpio_direction_output (ctx->bt_enable_gpio,1 ); +gpio_free (ctx->bt_enable_gpio); + +/* wait 100ms for bluetooth controller power on */ +msleep (100 ); + +return 0 ; +} + +static int pwrseq_aml_wcn_bt_disable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); + +gpio_request (ctx->bt_enable_gpio,"bt-enable-gpios" ); +gpio_direction_output (ctx->bt_enable_gpio,0 ); +gpio_free (ctx->bt_enable_gpio); + +return 0 ; +} + +static const struct pwrseq_unit_data pwrseq_aml_wcn_bt_unit_data = { + .name ="bluetooth-enable" , + .deps = pwrseq_aml_wcn_unit_deps, + .enable = pwrseq_aml_wcn_bt_enable, + .disable = pwrseq_aml_wcn_bt_disable, +}; + +static const struct pwrseq_unit_data pwrseq_aml_wcn_wlan_unit_data = { + .name ="wlan-enable" , + .deps = pwrseq_aml_wcn_unit_deps, +}; + +static const struct pwrseq_target_data pwrseq_aml_wcn_bt_target_data = { + .name ="bluetooth" , + .unit = &pwrseq_aml_wcn_bt_unit_data, +}; + +static const struct pwrseq_target_data pwrseq_aml_wcn_wlan_target_data = { + .name ="wlan" , + .unit = &pwrseq_aml_wcn_wlan_unit_data, +}; + +static const struct pwrseq_target_data *pwrseq_aml_wcn_targets[] = { + &pwrseq_aml_wcn_bt_target_data, + &pwrseq_aml_wcn_wlan_target_data, +NULL
drivers/power/sequencing/pwrseq-aml-wcn.c line 144
Quoted 10 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +10
-0+}; + +static int pwrseq_aml_wcn_match (struct pwrseq_device *pwrseq, +struct device *dev) +{ +struct device_node *dev_node = dev->of_node; + +if (!of_property_present (dev_node,"amlogic,wcn-pwrseq" )) +return 0 ; +
You must never reference the notion of power sequencing in the DT. Please take a look at the pwrseq-qcom-wcn driver where we model the PMU with its regulators and then parse them in match() to figure out if we have the right thing or not.
Quoted 11 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +11
-0+return 1 ; +} + +static int pwrseq_aml_wcn_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct pwrseq_aml_wcn_ctx *ctx; +struct pwrseq_config config; + + ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL ); +if (!ctx)
drivers/power/sequencing/pwrseq-aml-wcn.c line 165
Quoted 10 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +10
-0+return -ENOMEM ; + + ctx->bt_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,bt-enable-gpios" ,0 ); +if (!gpio_is_valid (ctx->bt_enable_gpio)) +return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the bt enable GPIO" ); + + ctx->chip_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,chip-enable-gpios" ,0 );
You don't need the OF variant. Use the regular devm_gpiod_get(). You also forgot to release it but the devres variant will take care of it.
drivers/power/sequencing/pwrseq-aml-wcn.c line 168
Quoted 3 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +3
-0+if (!gpio_is_valid (ctx->chip_enable_gpio)) +return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the chip enable GPIO" );
Wat
Quoted 43 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +41
-1+ + ctx->lpo_clk =devm_clk_get_optional (dev,NULL ); +if (IS_ERR (ctx->lpo_clk)) +return dev_err_probe (dev,PTR_ERR (ctx->lpo_clk), +"Failed to get the clock source" ); + +memset (&config,0 ,sizeof (config)); + + config.parent = dev; + config.owner =THIS_MODULE ; + config.drvdata = ctx; + config.match = pwrseq_aml_wcn_match; + config.targets = pwrseq_aml_wcn_targets; + + ctx->pwr_count =0 ; + ctx->pwrseq =devm_pwrseq_device_register (dev, &config); +if (IS_ERR (ctx->pwrseq)) +return dev_err_probe (dev,PTR_ERR (ctx->pwrseq), +"Failed to register the power sequencer\n" ); + +return 0 ; +} + +static const struct of_device_id pwrseq_aml_wcn_of_match[] = { + { .compatible ="amlogic,w155s2-pwrseq" }, + {/* sentinel */ }, +}; +MODULE_DEVICE_TABLE (of, pwrseq_aml_wcn_of_match); + +static struct platform_driver pwrseq_aml_wcn_driver = { + .driver = { + .name ="pwrseq-aml_wcn" , + .of_match_table = pwrseq_aml_wcn_of_match, + }, + .probe = pwrseq_aml_wcn_probe, +}; +module_platform_driver (pwrseq_aml_wcn_driver); + +MODULE_AUTHOR ("Yang Li <[email protected]>" ); +MODULE_DESCRIPTION ("Amlogic WCN PMU power sequencing driver" ); +MODULE_LICENSE ("GPL" ); --
Quoted 3 lines
2.42.0
Bart
Re: [PATCH 2/3] power: sequenceing: Add power sequence for Amlogic WCN chips
Quoted 51 lines · Bartosz Golaszewski
Quoted 49 lines · On Fri, Jul 5, 2024 at 1:13 PM Yang Li via B4 Relay…
From: Yang Li<[email protected]>
Add power sequence for Bluetooth and Wi-Fi respectively, including
chip_enpull-up andbt_enpull-up, and generation of the 32.768 clock.Signed-off-by Yang Li<[email protected]>--- drivers/power/sequencing/Kconfig | 7 + drivers/power/sequencing/Makefile | 1 + drivers/power/sequencing/pwrseq-aml-wcn.c | 209 ++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+)drivers/power/sequencing/Kconfig +7
-0@@ -26,4 +26,11 @@ config POWER_SEQUENCING_QCOM_WCN this driver is needed for correct power control or else we'd risk not respecting the required delays between enabling Bluetooth and WLAN. +config POWER_SEQUENCING_AML_WCN + tristate "Amlogic WCN family PMU driver" + default m if ARCH_MESON + help + Say Y here to enable the power sequencing driver for Amlogic + WCN Bluetooth/WLAN chipsets. + endifdrivers/power/sequencing/Makefile +1
-0@@ -4,3 +4,4 @@ obj-$(CONFIG_POWER_SEQUENCING) += pwrseq-core.o pwrseq-core-y := core.o obj-$(CONFIG_POWER_SEQUENCING_QCOM_WCN) += pwrseq-qcom-wcn.o +obj-$(CONFIG_POWER_SEQUENCING_AML_WCN) += pwrseq-aml-wcn.odrivers/power/sequencing/pwrseq-aml-wcn.c new file +6
-0@@ -0,0 +1,209 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR MIT) +/* +* Copyright (C) 2024 Amlogic, Inc. All rights reserved +*/ + +#include <linux/clk.h>
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 13
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +7
-0+#include <linux/delay.h> +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/gpio.h> Please see line 5 in this file.
I got it, I will remove this line, and include linux/gpio/consumer.h.
Quoted 2 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 14
Quoted 1 line
drivers/power/sequencing/pwrseq-aml-wcn.c new file +1
-0+#include <linux/of_gpio.h> You don't need this either.
Yes, I will remove it.
Quoted 8 lines
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +8
-0+#include <linux/platform_device.h> +#include <linux/pwrseq/provider.h> +#include <linux/string.h> +#include <linux/types.h> + +struct pwrseq_aml_wcn_ctx { +struct pwrseq_device *pwrseq; +int bt_enable_gpio;
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 29
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +7
-0+int chip_enable_gpio; +struct clk *lpo_clk; +unsigned int pwr_count; +}; + +static DEFINE_MUTEX (pwrseq_lock); +Why is this global?
Okay, I will add it to structure of pwrseq_aml_wcn_ctx .
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 35
Quoted 6 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +6
-0+static int pwrseq_aml_wcn_chip_enable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); +int err; + +mutex_lock (&pwrseq_lock);Please use
guard()fromlinux/cleanup.h.
Well, I will use guard(mutex)(&pwrse_lock) to replace mutex_lock(&pwrseq_lock).
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 39
Quoted 4 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +4
-0+if (ctx->pwr_count ==0 ) { +gpio_request (ctx->chip_enable_gpio,"chip-enable-gpios" ); +gpio_direction_output (ctx->chip_enable_gpio,1 ); +gpio_free (ctx->chip_enable_gpio);Not only are these legacy APIs but they are also used wrong. You almost never want to release the GPIO after setting the direction as someone else may grab it and use it.
Okay, I will use consumer API of devm_gpiod_get() to replace them.
Quoted 101 lines
Quoted 101 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +101
-0+ +if (!IS_ERR (ctx->lpo_clk)) { + err =clk_prepare_enable (ctx->lpo_clk); +if (err) { +mutex_unlock (&pwrseq_lock); +return err; + } + } + } + + ctx->pwr_count++; +mutex_unlock (&pwrseq_lock); +return 0 ; +} + +static int pwrseq_aml_wcn_chip_disable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); + +mutex_lock (&pwrseq_lock); +if (--ctx->pwr_count ==0 ) { +gpio_request (ctx->chip_enable_gpio,"chip-enable-gpios" ); +gpio_direction_output (ctx->chip_enable_gpio,0 ); +gpio_free (ctx->chip_enable_gpio); + +if (!IS_ERR (ctx->lpo_clk)) +clk_disable_unprepare (ctx->lpo_clk); + } + +mutex_unlock (&pwrseq_lock); +return 0 ; +} + +static const struct pwrseq_unit_data pwrseq_aml_wcn_chip_power_unit_data = { + .name ="chip-enable" , + .enable = pwrseq_aml_wcn_chip_enable, + .disable = pwrseq_aml_wcn_chip_disable, +}; + +static const struct pwrseq_unit_data *pwrseq_aml_wcn_unit_deps[] = { + &pwrseq_aml_wcn_chip_power_unit_data, +NULL +}; + +static int pwrseq_aml_wcn_bt_enable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); + +gpio_request (ctx->bt_enable_gpio,"bt-enable-gpios" ); +gpio_direction_output (ctx->bt_enable_gpio,1 ); +gpio_free (ctx->bt_enable_gpio); + +/* wait 100ms for bluetooth controller power on */ +msleep (100 ); + +return 0 ; +} + +static int pwrseq_aml_wcn_bt_disable (struct pwrseq_device *pwrseq) +{ +struct pwrseq_aml_wcn_ctx *ctx =pwrseq_device_get_drvdata (pwrseq); + +gpio_request (ctx->bt_enable_gpio,"bt-enable-gpios" ); +gpio_direction_output (ctx->bt_enable_gpio,0 ); +gpio_free (ctx->bt_enable_gpio); + +return 0 ; +} + +static const struct pwrseq_unit_data pwrseq_aml_wcn_bt_unit_data = { + .name ="bluetooth-enable" , + .deps = pwrseq_aml_wcn_unit_deps, + .enable = pwrseq_aml_wcn_bt_enable, + .disable = pwrseq_aml_wcn_bt_disable, +}; + +static const struct pwrseq_unit_data pwrseq_aml_wcn_wlan_unit_data = { + .name ="wlan-enable" , + .deps = pwrseq_aml_wcn_unit_deps, +}; + +static const struct pwrseq_target_data pwrseq_aml_wcn_bt_target_data = { + .name ="bluetooth" , + .unit = &pwrseq_aml_wcn_bt_unit_data, +}; + +static const struct pwrseq_target_data pwrseq_aml_wcn_wlan_target_data = { + .name ="wlan" , + .unit = &pwrseq_aml_wcn_wlan_unit_data, +}; + +static const struct pwrseq_target_data *pwrseq_aml_wcn_targets[] = { + &pwrseq_aml_wcn_bt_target_data, + &pwrseq_aml_wcn_wlan_target_data, +NULL +}; + +static int pwrseq_aml_wcn_match (struct pwrseq_device *pwrseq, +struct device *dev) +{ +struct device_node *dev_node = dev->of_node;
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 144
Quoted 4 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +4
-0+ +if (!of_property_present (dev_node,"amlogic,wcn-pwrseq" )) +return 0 ; +You must never reference the notion of power sequencing in the DT. Please take a look at the pwrseq-qcom-wcn driver where we model the PMU with its regulators and then parse them in
match()to figure out if we have the right thing or not.
There is some different between pwrseq-aml-wcn and pwrseq-qcom-wcn, pwrseq-aml-wcn device is abstracted to manage the chip-en pin, bt-en pin, and 32.768KHz clock. The drivers/power/sequence/core.c requirements need to be defined match () function is used to determine whether a potential consumers actually related to the sequencer. So, I need to add a meaningless node "amlogic,wcn-pwrseq" to both the consumer dt-binding and the provider dt-binding.
Right now, I add "amlogic,wcn-pwrseq" in binding file of "amlogic,w155s2-bt.yaml" only, may I need to add this properties ("amlogic,wcn-pwrseq") in the binding file of "amlogic,w155s2-pwrseq.yaml"?
Or there are any others way to fixed this issue please let me know.
Quoted 15 lines
Quoted 15 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +15
-0+return 1 ; +} + +static int pwrseq_aml_wcn_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct pwrseq_aml_wcn_ctx *ctx; +struct pwrseq_config config; + + ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + + ctx->bt_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,bt-enable-gpios" ,0 );
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 165
Quoted 6 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +6
-0+if (!gpio_is_valid (ctx->bt_enable_gpio)) +return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the bt enable GPIO" ); + + ctx->chip_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,chip-enable-gpios" ,0 );You don't need the OF variant. Use the regular
devm_gpiod_get(). You also forgot to release it but the devres variant will take care of it.
Well, I will do it.
Quoted 5 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 168
Quoted 4 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +3
-0+if (!gpio_is_valid (ctx->chip_enable_gpio)) +return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the chip enable GPIO" );Wat
I got it, and I will fix it.
Quoted 48 lines
Quoted 44 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +41
-1+ + ctx->lpo_clk =devm_clk_get_optional (dev,NULL ); +if (IS_ERR (ctx->lpo_clk)) +return dev_err_probe (dev,PTR_ERR (ctx->lpo_clk), +"Failed to get the clock source" ); + +memset (&config,0 ,sizeof (config)); + + config.parent = dev; + config.owner =THIS_MODULE ; + config.drvdata = ctx; + config.match = pwrseq_aml_wcn_match; + config.targets = pwrseq_aml_wcn_targets; + + ctx->pwr_count =0 ; + ctx->pwrseq =devm_pwrseq_device_register (dev, &config); +if (IS_ERR (ctx->pwrseq)) +return dev_err_probe (dev,PTR_ERR (ctx->pwrseq), +"Failed to register the power sequencer\n" ); + +return 0 ; +} + +static const struct of_device_id pwrseq_aml_wcn_of_match[] = { + { .compatible ="amlogic,w155s2-pwrseq" }, + {/* sentinel */ }, +}; +MODULE_DEVICE_TABLE (of, pwrseq_aml_wcn_of_match); + +static struct platform_driver pwrseq_aml_wcn_driver = { + .driver = { + .name ="pwrseq-aml_wcn" , + .of_match_table = pwrseq_aml_wcn_of_match, + }, + .probe = pwrseq_aml_wcn_probe, +}; +module_platform_driver (pwrseq_aml_wcn_driver); + +MODULE_AUTHOR ("Yang Li<[email protected]>" ); +MODULE_DESCRIPTION ("Amlogic WCN PMU power sequencing driver" ); +MODULE_LICENSE ("GPL" ); --Quoted 3 lines
2.42.0
Bart
Re: [PATCH 2/3] power: sequenceing: Add power sequence for Amlogic WCN chips
In reply to Yang LiQuoted 14 lines · On 05/07/2024 13:13, Yang Li via B4 Relay wrote:
From: Yang Li <[email protected]>
Add power sequence for Bluetooth and Wi-Fi respectively, including
chip_enpull-up andbt_enpull-up, and generation of the 32.768 clock.Signed-off-by Yang Li <[email protected]>drivers/power/sequencing/pwrseq-aml-wcn.c new file +7
-0+#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h>
drivers/power/sequencing/pwrseq-aml-wcn.c line 22
Quoted 10 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +10
-0+#include <linux/gpio.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h> +#include <linux/pwrseq/provider.h> +#include <linux/string.h> +#include <linux/types.h> + +struct pwrseq_aml_wcn_ctx { +struct pwrseq_device *pwrseq; +int bt_enable_gpio;
Why? It's never used... or you use wrong API. Confusing code.
drivers/power/sequencing/pwrseq-aml-wcn.c line 28
Quoted 6 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +6
-0+int chip_enable_gpio; +struct clk *lpo_clk; +unsigned int pwr_count; +}; + +static DEFINE_MUTEX (pwrseq_lock);
Why this is not part of structure above?
Quoted 1 line
+
...
drivers/power/sequencing/pwrseq-aml-wcn.c line 142
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +7
-0+ +static int pwrseq_aml_wcn_match (struct pwrseq_device *pwrseq, +struct device *dev) +{ +struct device_node *dev_node = dev->of_node; + +if (!of_property_present (dev_node,"amlogic,wcn-pwrseq" ))
You cannot have undocumented properties, sorry, that's a NAK.
Quoted 18 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +18
-0+return 0 ; + +return 1 ; +} + +static int pwrseq_aml_wcn_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct pwrseq_aml_wcn_ctx *ctx; +struct pwrseq_config config; + + ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + + ctx->bt_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,bt-enable-gpios" ,0 ); +if (!gpio_is_valid (ctx->bt_enable_gpio))
drivers/power/sequencing/pwrseq-aml-wcn.c line 170
Quoted 10 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +10
-0+return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the bt enable GPIO" ); + + ctx->chip_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,chip-enable-gpios" ,0 ); +if (!gpio_is_valid (ctx->chip_enable_gpio)) +return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the chip enable GPIO" ); + + ctx->lpo_clk =devm_clk_get_optional (dev,NULL );
Clock is not optional, according to you binding.
drivers/power/sequencing/pwrseq-aml-wcn.c line 175
Quoted 5 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +5
-0+if (IS_ERR (ctx->lpo_clk)) +return dev_err_probe (dev,PTR_ERR (ctx->lpo_clk), +"Failed to get the clock source" ); + +memset (&config,0 ,sizeof (config));
Just initialize it on the stack with 0.
Best regards,
Krzysztof
Re: [PATCH 2/3] power: sequenceing: Add power sequence for Amlogic WCN chips
Dear Krzysztof
Thanks for your comments.
Quoted 17 lines · On 05/07/2024 13:13, Yang Li via B4 Relay wrote:
Quoted 16 lines
From: Yang Li <[email protected]>
Add power sequence for Bluetooth and Wi-Fi respectively, including
chip_enpull-up andbt_enpull-up, and generation of the 32.768 clock.Signed-off-by Yang Li <[email protected]>drivers/power/sequencing/pwrseq-aml-wcn.c new file +10
-0+#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/of.h> +#include <linux/gpio.h> +#include <linux/of_gpio.h> +#include <linux/platform_device.h>
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 22
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +7
-0+#include <linux/pwrseq/provider.h> +#include <linux/string.h> +#include <linux/types.h> + +struct pwrseq_aml_wcn_ctx { +struct pwrseq_device *pwrseq; +int bt_enable_gpio;Why? It's never used... or you use wrong API. Confusing code.
Well, I will used the "struct gpio_desc" replace current method.
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 28
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +6
-0+int chip_enable_gpio; +struct clk *lpo_clk; +unsigned int pwr_count; +}; + +static DEFINE_MUTEX (pwrseq_lock);Why this is not part of structure above?
Sorry, I referenced some outdated examples.
And I will put it in structure of pwrseq_aml_wcn_ctx.
Quoted 4 lines
Quoted 1 line
+
...
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 142
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +7
-0+ +static int pwrseq_aml_wcn_match (struct pwrseq_device *pwrseq, +struct device *dev) +{ +struct device_node *dev_node = dev->of_node; + +if (!of_property_present (dev_node,"amlogic,wcn-pwrseq" ))You cannot have undocumented properties, sorry, that's a NAK.
About the match () function I also have some doubts, the drivers/power/sequence/core.c requirements need to be defined match () function is used to determine whether a potential consumers actually related to the sequencer. So, I need to add a meaningless node "amlogic,wcn-pwrseq" to both the consumer dt-binding and the provider dt-binding.
Right now, I add "amlogic,wcn-pwrseq" in binding file of "amlogic,w155s2-bt.yaml" only, may I need to add this properties ("amlogic,wcn-pwrseq") in the binding file of "amlogic,w155s2-pwrseq.yaml"?
Quoted 21 lines
Quoted 21 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +21
-0+return 0 ; + +return 1 ; +} + +static int pwrseq_aml_wcn_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct pwrseq_aml_wcn_ctx *ctx; +struct pwrseq_config config; + + ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + + ctx->bt_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,bt-enable-gpios" ,0 ); +if (!gpio_is_valid (ctx->bt_enable_gpio)) +return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the bt enable GPIO" ); +
Quoted 8 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 170
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +7
-0+ ctx->chip_enable_gpio =of_get_named_gpio (dev->of_node, +"amlogic,chip-enable-gpios" ,0 ); +if (!gpio_is_valid (ctx->chip_enable_gpio)) +return dev_err_probe (dev, ctx->bt_enable_gpio, +"Failed to get the chip enable GPIO" ); + + ctx->lpo_clk =devm_clk_get_optional (dev,NULL );Clock is not optional, according to you binding.
Yes, I will used API of devm_clk_get(dev, "extclk") to relace it.
Quoted 7 lines
drivers/power/sequencing/pwrseq-aml-wcn.c line 175
Quoted 6 lines
drivers/power/sequencing/pwrseq-aml-wcn.c new file +5
-0+if (IS_ERR (ctx->lpo_clk)) +return dev_err_probe (dev,PTR_ERR (ctx->lpo_clk), +"Failed to get the clock source" ); + +memset (&config,0 ,sizeof (config));Just initialize it on the stack with 0.
Okay, I will delete this line and set config to zero when initializing.
Quoted 6 lines
Best regards,
Krzysztof
PATCH 3/3 MAINTAINERS: Add an entry for Amlogic WCN power sequence
In reply to Yang LiAdd an entry for Amlogic WCN power sequence.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -1174,6 +1174,14 @@ F: Documentation/devicetree/bindings/perf/amlogic,g12-ddr-pmu.yaml F: drivers/perf/amlogic/ F: include/soc/amlogic/ +AMLOGIC WCN POWER SEQUENCING +M: Yang Li <[email protected]> +L: [email protected] +S: Maintained +W: http://www.amlogic.com +F: Documentation/devicetree/bindings/power/amlogic,w1552-pwrseq.yaml +F: drivers/power/sequencing/pwrseq-aml-wcn.c + AMPHENOL CHIPCAP 2 HUMIDITY-TEMPERATURE IIO DRIVER M: Javier Carrasco <[email protected]> L: [email protected]
Signature · 1 line
2.42.0
Re: [PATCH 3/3] MAINTAINERS: Add an entry for Amlogic WCN power sequence
Quoted 14 lines · On 05/07/2024 13:13, Yang Li via B4 Relay wrote:
From: Yang Li <[email protected]>
Add an entry for Amlogic WCN power sequence.
Signed-off-by Yang Li <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0
MAINTAINERS F: Documentation/devicetree/bindings/perf/amlogic,g12-ddr-pmu.yaml · line 1181
Quoted 8 lines
MAINTAINERS +5
-0@@ -1174,6 +1174,14 @@ F: Documentation/devicetree/bindings/perf/amlogic,g12-ddr-pmu.yaml F: drivers/perf/amlogic/ F: include/soc/amlogic/ +AMLOGIC WCN POWER SEQUENCING +M: Yang Li <[email protected]> +L: [email protected] +S: Maintained +W: http://www.amlogic.com
Drop. It's not helpful at all. Don't throw at us your company marketing.
Best regards,
Krzysztof
Re: [PATCH 3/3] MAINTAINERS: Add an entry for Amlogic WCN power sequence
Quoted 19 lines · On 05/07/2024 13:13, Yang Li via B4 Relay wrote:
Quoted 17 lines
From: Yang Li <[email protected]>
Add an entry for Amlogic WCN power sequence.
Signed-off-by Yang Li <[email protected]>--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)MAINTAINERS +0
-0@@ -1174,6 +1174,14 @@ F: Documentation/devicetree/bindings/perf/amlogic,g12-ddr-pmu.yaml F: drivers/perf/amlogic/ F: include/soc/amlogic/
Quoted 6 lines
MAINTAINERS F: Documentation/devicetree/bindings/perf/amlogic,g12-ddr-pmu.yaml · line 1181
Quoted 5 lines
MAINTAINERS +5
-0+AMLOGIC WCN POWER SEQUENCING +M: Yang Li <[email protected]> +L: [email protected] +S: Maintained +W: http://www.amlogic.comDrop. It's not helpful at all. Don't throw at us your company marketing.
Well, I got it.
I will delete this line.
Thanks!
Quoted 4 lines
Best regards,
Krzysztof