pwm: meson: dt-bindings fixup
Subsystems (3)
Jerome Brunet
reviewerv5 cover pwm: meson: dt-bindings fixup
This patchset aims to:
* Fix the incorrect bindings for the s4 type of pwm that was introduced while converting the documentation from txt to yaml format.
* Introduce a new compatible for the existing PWMs to better describe the HW in DT, instead of describing driver settings.
* Make the introduction of a new pwm variant (s4) slightly easier.
Changes since v4 [4]:
* Rebased on Uwe's pwm rework in pwm-next
* Drop change to carry device data in drvdata
* Make the length of parent name array fixed
* Single allocation instead 3 for the internal clock elements
* meson8-pwm-v2 and meson-pwm-s4 compatibles under an enum instead of 2 const
Changes since v3 [3]:
* Split first rework patch into 3 changes
* Use dev_warn_once() to notify use of obsolete bindings
* Rebased on Uwe dev_err_probe() change.
Changes since v2 [2]:
* Drop DTS changes. These will be re-submitted later on. Possibly after u-boot gets support for the new compatible to minimise conversion problems.
* Position deprecated property correctly in dt-bindings for the old meson8 type pwm bindings
* Reword commit description of patch #2 to make more obvious it does not introduce a new HW support but fixes a bad bindings.
* Dropped Rob's Reviewed-by on patch #2. It seemed appropriate considering the discussion on this change.
Changes since v1 [1]:
* Fix typo in the new binding compatible documentation
* Disallow clock-names for the new compatibles in the schema documenation
[1]: https://lore.kernel.org/linux-amlogic/[email protected]
[2]: https://lore.kernel.org/linux-amlogic/[email protected]
[3]: https://lore.kernel.org/linux-amlogic/[email protected]
[4]: https://lore.kernel.org/linux-amlogic/[email protected]
Jerome Brunet (5):
dt-bindings: pwm: amlogic: fix s4 bindings
dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types
pwm: meson: generalize 4 inputs clock on meson8 pwm type
pwm: meson: don't carry internal clock elements around
pwm: meson: add generic compatible for meson8 to sm1
.../devicetree/bindings/pwm/pwm-amlogic.yaml | 115 ++++++- drivers/pwm/pwm-meson.c | 289 ++++++++++-------- 2 files changed, 260 insertions(+), 144 deletions(-)
Signature · 1 line
2.43.0
Jerome Brunet
reviewerPATCH v5 1/5 dt-bindings: pwm: amlogic: fix s4 bindings
s4 has been added to the compatible list while converting the Amlogic PWM binding documentation from txt to yaml.
However, on the s4, the clock bindings have different meaning compared to the previous SoCs.
On the previous SoCs the clock bindings used to describe which input the PWM channel multiplexer should pick among its possible parents.
This is very much tied to the driver implementation, instead of describing the HW for what it is. When support for the Amlogic PWM was first added, how to deal with clocks through DT was not as clear as it nowadays. The Linux driver now ignores this DT setting, but still relies on the hard-coded list of clock sources.
On the s4, the input multiplexer is gone. The clock bindings actually describe the clock as it exists, not a setting. The property has a different meaning, even if it is still 2 clocks and it would pass the check when support is actually added.
Also the s4 cannot work if the clocks are not provided, so the property is no longer optional.
Finally, for once it makes sense to see the input as being numbered somehow. No need to bother with clock-names on the s4 type of PWM.
--- .../devicetree/bindings/pwm/pwm-amlogic.yaml | 67 ++++++++++++++++--- 1 file changed, 58 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +58 -9
@@ -9,9 +9,6 @@ title: Amlogic PWM maintainers: - Heiner Kallweit <[email protected]> -allOf: - - $ref: pwm.yaml# - properties: compatible: oneOf:
@@ -43,12 +40,8 @@ properties: maxItems: 2 clock-names: - oneOf: - - items: - - enum: [clkin0, clkin1] - - items: - - const: clkin0 - - const: clkin1 + minItems: 1 + maxItems: 2 "#pwm-cells": const: 3
@@ -57,6 +50,55 @@ required: - compatible - reg +allOf: + - $ref: pwm.yaml# + + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8-pwm + - amlogic,meson8b-pwm + - amlogic,meson-gxbb-pwm + - amlogic,meson-gxbb-ao-pwm + - amlogic,meson-axg-ee-pwm + - amlogic,meson-axg-ao-pwm + - amlogic,meson-g12a-ee-pwm + - amlogic,meson-g12a-ao-pwm-ab + - amlogic,meson-g12a-ao-pwm-cd + then: + # Historic bindings tied to the driver implementation + # The clocks provided here are meant to be matched with the input + # known (hard-coded) in the driver and used to select pwm clock + # source. Currently, the linux driver ignores this. + properties: + clock-names: + oneOf: + - items: + - enum: [clkin0, clkin1] + - items: + - const: clkin0 + - const: clkin1 + + # Newer IP block take a single input per channel, instead of 4 inputs + # for both channels + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson-s4-pwm + then: + properties: + clocks: + items: + - description: input clock of PWM channel A + - description: input clock of PWM channel B + clock-names: false + required: + - clocks + additionalProperties: false examples:
@@ -68,3 +110,10 @@ examples: clock-names = "clkin0", "clkin1"; #pwm-cells = <3>; }; + - | + pwm@1000 { + compatible = "amlogic,meson-s4-pwm"; + reg = <0x1000 0x10>; + clocks = <&pwm_src_a>, <&pwm_src_b>; + #pwm-cells = <3>; + };
Signature · 1 line
2.43.0
Jerome Brunet
reviewerPATCH v5 2/5 dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types
In reply to Jerome BrunetThe binding that is used up to now describe which input the PWM channel multiplexer should pick among its possible parents, which are hardcoded in the driver. This isn't a good binding in the sense that it should describe hardware but not usage.
Add a new binding deprecating the old one that uses clocks in a better way and how clocks are usually used today: The list of clocks describe the inputs of the PWM block as they are realised in hardware.
So deprecate the old bindings and introduce a compatible per SoC family to replace these.
--- .../devicetree/bindings/pwm/pwm-amlogic.yaml | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/pwm/pwm-amlogic.yaml +47 -3
@@ -21,23 +21,36 @@ properties: - amlogic,meson-g12a-ee-pwm - amlogic,meson-g12a-ao-pwm-ab - amlogic,meson-g12a-ao-pwm-cd - - amlogic,meson-s4-pwm + deprecated: true - items: - const: amlogic,meson-gx-pwm - const: amlogic,meson-gxbb-pwm + deprecated: true - items: - const: amlogic,meson-gx-ao-pwm - const: amlogic,meson-gxbb-ao-pwm + deprecated: true - items: - const: amlogic,meson8-pwm - const: amlogic,meson8b-pwm + deprecated: true + - enum: + - amlogic,meson8-pwm-v2 + - amlogic,meson-s4-pwm + - items: + - enum: + - amlogic,meson8b-pwm-v2 + - amlogic,meson-gxbb-pwm-v2 + - amlogic,meson-axg-pwm-v2 + - amlogic,meson-g12-pwm-v2 + - const: amlogic,meson8-pwm-v2 reg: maxItems: 1 clocks: minItems: 1 - maxItems: 2 + maxItems: 4 clock-names: minItems: 1
@@ -68,11 +81,14 @@ allOf: - amlogic,meson-g12a-ao-pwm-ab - amlogic,meson-g12a-ao-pwm-cd then: - # Historic bindings tied to the driver implementation + # Obsolete historic bindings tied to the driver implementation # The clocks provided here are meant to be matched with the input # known (hard-coded) in the driver and used to select pwm clock # source. Currently, the linux driver ignores this. + # This is kept to maintain ABI backward compatibility. properties: + clocks: + maxItems: 2 clock-names: oneOf: - items:
@@ -81,6 +97,27 @@ allOf: - const: clkin0 - const: clkin1 + # Newer binding where clock describe the actual clock inputs of the pwm + # block. These are necessary but some inputs may be grounded. + - if: + properties: + compatible: + contains: + enum: + - amlogic,meson8-pwm-v2 + then: + properties: + clocks: + minItems: 1 + items: + - description: input clock 0 of the pwm block + - description: input clock 1 of the pwm block + - description: input clock 2 of the pwm block + - description: input clock 3 of the pwm block + clock-names: false + required: + - clocks + # Newer IP block take a single input per channel, instead of 4 inputs # for both channels - if:
@@ -110,6 +147,13 @@ examples: clock-names = "clkin0", "clkin1"; #pwm-cells = <3>; }; + - | + pwm@2000 { + compatible = "amlogic,meson8-pwm-v2"; + reg = <0x1000 0x10>; + clocks = <&xtal>, <0>, <&fdiv4>, <&fdiv5>; + #pwm-cells = <3>; + }; - | pwm@1000 { compatible = "amlogic,meson-s4-pwm";
Signature · 1 line
2.43.0
Re: [PATCH v5 2/5] dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types
Quoted 10 lines · Jerome Brunet
The binding that is used up to now describe which input the PWM channel multiplexer should pick among its possible parents, which are hardcoded in the driver. This isn't a good binding in the sense that it should describe hardware but not usage.
Add a new binding deprecating the old one that uses clocks in a better way and how clocks are usually used today: The list of clocks describe the inputs of the PWM block as they are realised in hardware.
Quoted 8 lines
So deprecate the old bindings and introduce a compatible per SoC family to replace these.
Signed-off-by Jerome Brunet <[email protected]>--- .../devicetree/bindings/pwm/pwm-amlogic.yaml | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-)
Jerome Brunet
reviewerPATCH v5 3/5 pwm: meson: generalize 4 inputs clock on meson8 pwm type
In reply to Jerome BrunetMeson8 pwm type always has 4 input clocks. Some inputs may be grounded, like in the AO domain of some SoCs.
Drop the parent number parameter and make this is constant. This is also done to make the addition of generic meson8 compatible easier.
--- drivers/pwm/pwm-meson.c | 53 +++++++++-------------------------------- 1 file changed, 11 insertions(+), 42 deletions(-)
drivers/pwm/pwm-meson.c +11 -42
@@ -60,7 +60,7 @@#define MISC_A_EN BIT(0)#define MESON_NUM_PWMS 2 -#define MESON_MAX_MUX_PARENTS 4 +#define MESON_NUM_MUX_PARENTS 4 static struct meson_pwm_channel_data { u8 reg_offset;
@@ -97,8 +97,7 @@ struct meson_pwm_channel { };struct meson_pwm_data { -const char *const *parent_names; -unsigned int num_parents; +const char *const parent_names[MESON_NUM_MUX_PARENTS ]; };struct meson_pwm {
@@ -339,62 +338,32 @@ static const struct pwm_ops meson_pwm_ops = { .get_state = meson_pwm_get_state, }; -static const char *const pwm_meson8b_parent_names[] = { -"xtal" ,NULL ,"fclk_div4" ,"fclk_div3" -}; -static const struct meson_pwm_data pwm_meson8b_data = { - .parent_names = pwm_meson8b_parent_names, - .num_parents =ARRAY_SIZE (pwm_meson8b_parent_names), + .parent_names = {"xtal" ,NULL ,"fclk_div4" ,"fclk_div3" }, };/* * Only the 2 first inputs of the GXBB AO PWMs are valid * The last 2 are grounded */ -static const char *const pwm_gxbb_ao_parent_names[] = { -"xtal" ,"clk81" -}; -static const struct meson_pwm_data pwm_gxbb_ao_data = { - .parent_names = pwm_gxbb_ao_parent_names, - .num_parents =ARRAY_SIZE (pwm_gxbb_ao_parent_names), -}; - -static const char *const pwm_axg_ee_parent_names[] = { -"xtal" ,"fclk_div5" ,"fclk_div4" ,"fclk_div3" + .parent_names = {"xtal" ,"clk81" ,NULL ,NULL }, };static const struct meson_pwm_data pwm_axg_ee_data = { - .parent_names = pwm_axg_ee_parent_names, - .num_parents =ARRAY_SIZE (pwm_axg_ee_parent_names), -}; - -static const char *const pwm_axg_ao_parent_names[] = { -"xtal" ,"axg_ao_clk81" ,"fclk_div4" ,"fclk_div5" + .parent_names = {"xtal" ,"fclk_div5" ,"fclk_div4" ,"fclk_div3" }, };static const struct meson_pwm_data pwm_axg_ao_data = { - .parent_names = pwm_axg_ao_parent_names, - .num_parents =ARRAY_SIZE (pwm_axg_ao_parent_names), -}; - -static const char *const pwm_g12a_ao_ab_parent_names[] = { -"xtal" ,"g12a_ao_clk81" ,"fclk_div4" ,"fclk_div5" + .parent_names = {"xtal" ,"axg_ao_clk81" ,"fclk_div4" ,"fclk_div5" }, };static const struct meson_pwm_data pwm_g12a_ao_ab_data = { - .parent_names = pwm_g12a_ao_ab_parent_names, - .num_parents =ARRAY_SIZE (pwm_g12a_ao_ab_parent_names), -}; - -static const char *const pwm_g12a_ao_cd_parent_names[] = { -"xtal" ,"g12a_ao_clk81" , + .parent_names = {"xtal" ,"g12a_ao_clk81" ,"fclk_div4" ,"fclk_div5" }, };static const struct meson_pwm_data pwm_g12a_ao_cd_data = { - .parent_names = pwm_g12a_ao_cd_parent_names, - .num_parents =ARRAY_SIZE (pwm_g12a_ao_cd_parent_names), + .parent_names = {"xtal" ,"g12a_ao_clk81" ,NULL ,NULL }, };static const struct of_device_id meson_pwm_matches[] = {
@@ -437,13 +406,13 @@ MODULE_DEVICE_TABLE(of, meson_pwm_matches);static int meson_pwm_init_channels (struct pwm_chip *chip) {struct meson_pwm *meson =to_meson_pwm (chip); -struct clk_parent_data mux_parent_data[MESON_MAX_MUX_PARENTS ] = {}; +struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS ] = {};struct device *dev =pwmchip_parent (chip);unsigned int i;char name[255 ];int err; -for (i =0 ; i < meson->data->num_parents; i++) { +for (i =0 ; i <MESON_NUM_MUX_PARENTS ; i++) { mux_parent_data[i].index =-1 ; mux_parent_data[i].name = meson->data->parent_names[i]; }
@@ -459,7 +428,7 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.ops = &clk_mux_ops; init.flags =0 ; init.parent_data = mux_parent_data; - init.num_parents = meson->data->num_parents; + init.num_parents =MESON_NUM_MUX_PARENTS ; channel->mux.reg = meson->base +REG_MISC_AB ; channel->mux.shift =
Signature · 1 line
2.43.0
Jerome Brunet
reviewerPATCH v5 4/5 pwm: meson: don't carry internal clock elements around
In reply to Jerome BrunetPointers to the internal clock elements of the PWM are useless after probe. There is no need to carry this around in the device data.
Rework the clock registration to let devres deal with it
--- drivers/pwm/pwm-meson.c | 73 ++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 33 deletions(-)
drivers/pwm/pwm-meson.c +40 -33
@@ -85,14 +85,17 @@ static struct meson_pwm_channel_data { } }; +struct meson8b_pwm_clocks { +struct clk_divider div; +struct clk_gate gate; +struct clk_mux mux; +}; +struct meson_pwm_channel {unsigned long rate;unsigned int hi;unsigned int lo; -struct clk_mux mux; -struct clk_divider div; -struct clk_gate gate;struct clk *clk; };
@@ -419,9 +422,14 @@ static int meson_pwm_init_channels(struct pwm_chip *chip)for (i =0 ; i < chip->npwm; i++) {struct meson_pwm_channel *channel = &meson->channels[i]; -struct clk_parent_data div_parent = {}, gate_parent = {}; +struct clk_parent_data pdata = {}; +struct meson8b_pwm_clocks *clks;struct clk_init_data init = {}; + clks =devm_kzalloc (dev,sizeof (*clks),GFP_KERNEL ); +if (!clks) +return -ENOMEM ; +snprintf (name,sizeof (name),"%s#mux%u" ,dev_name (dev), i); init.name = name;
@@ -430,16 +438,15 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.parent_data = mux_parent_data; init.num_parents =MESON_NUM_MUX_PARENTS ; - channel->mux.reg = meson->base +REG_MISC_AB ; - channel->mux.shift = - meson_pwm_per_channel_data[i].clk_sel_shift; - channel->mux.mask =MISC_CLK_SEL_MASK ; - channel->mux.flags =0 ; - channel->mux.lock = &meson->lock; - channel->mux.table =NULL ; - channel->mux.hw.init = &init; + clks->mux.reg = meson->base +REG_MISC_AB ; + clks->mux.shift = meson_pwm_per_channel_data[i].clk_sel_shift; + clks->mux.mask =MISC_CLK_SEL_MASK ; + clks->mux.flags =0 ; + clks->mux.lock = &meson->lock; + clks->mux.table =NULL ; + clks->mux.hw.init = &init; - err =devm_clk_hw_register (dev, &channel->mux.hw); + err =devm_clk_hw_register (dev, &clks->mux.hw);if (err)return dev_err_probe (dev, err,"failed to register %s\n" , name);
@@ -449,19 +456,19 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.name = name; init.ops = &clk_divider_ops; init.flags =CLK_SET_RATE_PARENT ; - div_parent.index =-1 ; - div_parent.hw = &channel->mux.hw; - init.parent_data = &div_parent; + pdata.index =-1 ; + pdata.hw = &clks->mux.hw; + init.parent_data = &pdata; init.num_parents =1 ; - channel->div.reg = meson->base +REG_MISC_AB ; - channel->div.shift = meson_pwm_per_channel_data[i].clk_div_shift; - channel->div.width =MISC_CLK_DIV_WIDTH ; - channel->div.hw.init = &init; - channel->div.flags =0 ; - channel->div.lock = &meson->lock; + clks->div.reg = meson->base +REG_MISC_AB ; + clks->div.shift = meson_pwm_per_channel_data[i].clk_div_shift; + clks->div.width =MISC_CLK_DIV_WIDTH ; + clks->div.hw.init = &init; + clks->div.flags =0 ; + clks->div.lock = &meson->lock; - err =devm_clk_hw_register (dev, &channel->div.hw); + err =devm_clk_hw_register (dev, &clks->div.hw);if (err)return dev_err_probe (dev, err,"failed to register %s\n" , name);
@@ -471,22 +478,22 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.name = name; init.ops = &clk_gate_ops; init.flags =CLK_SET_RATE_PARENT |CLK_IGNORE_UNUSED ; - gate_parent.index =-1 ; - gate_parent.hw = &channel->div.hw; - init.parent_data = &gate_parent; + pdata.index =-1 ; + pdata.hw = &clks->div.hw; + init.parent_data = &pdata; init.num_parents =1 ; - channel->gate.reg = meson->base +REG_MISC_AB ; - channel->gate.bit_idx = meson_pwm_per_channel_data[i].clk_en_shift; - channel->gate.hw.init = &init; - channel->gate.flags =0 ; - channel->gate.lock = &meson->lock; + clks->gate.reg = meson->base +REG_MISC_AB ; + clks->gate.bit_idx = meson_pwm_per_channel_data[i].clk_en_shift; + clks->gate.hw.init = &init; + clks->gate.flags =0 ; + clks->gate.lock = &meson->lock; - err =devm_clk_hw_register (dev, &channel->gate.hw); + err =devm_clk_hw_register (dev, &clks->gate.hw);if (err)return dev_err_probe (dev, err,"failed to register %s\n" , name); - channel->clk =devm_clk_hw_get_clk (dev, &channel->gate.hw,NULL ); + channel->clk =devm_clk_hw_get_clk (dev, &clks->gate.hw,NULL );if (IS_ERR (channel->clk))return dev_err_probe (dev,PTR_ERR (channel->clk),"failed to register %s\n" , name);
Signature · 1 line
2.43.0
Re: [PATCH v5 4/5] pwm: meson: don't carry internal clock elements around
Hello Jerome,
Quoted 25 lines · Jerome Brunet
Pointers to the internal clock elements of the PWM are useless after probe. There is no need to carry this around in the device data.
Rework the clock registration to let devres deal with it
Signed-off-by Jerome Brunet <[email protected]>--- drivers/pwm/pwm-meson.c | 73 ++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 33 deletions(-)drivers/pwm/pwm-meson.c +6
-0@@ -85,14 +85,17 @@ static struct meson_pwm_channel_data { } }; +struct meson8b_pwm_clocks { +struct clk_divider div; +struct clk_gate gate; +struct clk_mux mux; +}; +
drivers/pwm/pwm-meson.c static struct meson_pwm_channel_data { · line 100
Quoted 10 lines
drivers/pwm/pwm-meson.c +0
-3struct meson_pwm_channel {unsigned long rate;unsigned int hi;unsigned int lo; -struct clk_mux mux; -struct clk_divider div; -struct clk_gate gate;struct clk *clk; };
I don't think there is a valuable benefit here. Yes, the three structures are not used explicitly in the driver afterwards, but the memory has to stay around to call clk_hw_unregister() when the device is unregistered. So to hide these from struct meson_pwm_channel, we're not saving any memory, but add the overhead of one additional devm_kzalloc per PWM channel. For me the cost-benefit calculation is bad here.
Quoted 42 lines
drivers/pwm/pwm-meson.c +14
-10@@ -419,9 +422,14 @@ static int meson_pwm_init_channels(struct pwm_chip *chip)for (i =0 ; i < chip->npwm; i++) {struct meson_pwm_channel *channel = &meson->channels[i]; -struct clk_parent_data div_parent = {}, gate_parent = {}; +struct clk_parent_data pdata = {}; +struct meson8b_pwm_clocks *clks;struct clk_init_data init = {}; + clks =devm_kzalloc (dev,sizeof (*clks),GFP_KERNEL ); +if (!clks) +return -ENOMEM ; +snprintf (name,sizeof (name),"%s#mux%u" ,dev_name (dev), i); init.name = name;@@ -430,16 +438,15 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.parent_data = mux_parent_data; init.num_parents =MESON_NUM_MUX_PARENTS ; - channel->mux.reg = meson->base +REG_MISC_AB ; - channel->mux.shift = - meson_pwm_per_channel_data[i].clk_sel_shift; - channel->mux.mask =MISC_CLK_SEL_MASK ; - channel->mux.flags =0 ; - channel->mux.lock = &meson->lock; - channel->mux.table =NULL ; - channel->mux.hw.init = &init; + clks->mux.reg = meson->base +REG_MISC_AB ; + clks->mux.shift = meson_pwm_per_channel_data[i].clk_sel_shift; + clks->mux.mask =MISC_CLK_SEL_MASK ; + clks->mux.flags =0 ; + clks->mux.lock = &meson->lock; + clks->mux.table =NULL ; + clks->mux.hw.init = &init; - err =devm_clk_hw_register (dev, &channel->mux.hw); + err =devm_clk_hw_register (dev, &clks->mux.hw);if (err)return dev_err_probe (dev, err,"failed to register %s\n" , name);
drivers/pwm/pwm-meson.c static int meson_pwm_init_channels(struct pwm_chip *chip) · line 461
Quoted 9 lines
drivers/pwm/pwm-meson.c +3
-3@@ -449,19 +456,19 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.name = name; init.ops = &clk_divider_ops; init.flags =CLK_SET_RATE_PARENT ; - div_parent.index =-1 ; - div_parent.hw = &channel->mux.hw; - init.parent_data = &div_parent; + pdata.index =-1 ; + pdata.hw = &clks->mux.hw; + init.parent_data = &pdata;
Is it safe to use a single pdata instead of separate div_parent + gate_parent below as before? That should be a separate change then (or at least motivated in the commit log.)
Quoted 23 lines
drivers/pwm/pwm-meson.c +7
-7init.num_parents =1 ; - channel->div.reg = meson->base +REG_MISC_AB ; - channel->div.shift = meson_pwm_per_channel_data[i].clk_div_shift; - channel->div.width =MISC_CLK_DIV_WIDTH ; - channel->div.hw.init = &init; - channel->div.flags =0 ; - channel->div.lock = &meson->lock; + clks->div.reg = meson->base +REG_MISC_AB ; + clks->div.shift = meson_pwm_per_channel_data[i].clk_div_shift; + clks->div.width =MISC_CLK_DIV_WIDTH ; + clks->div.hw.init = &init; + clks->div.flags =0 ; + clks->div.lock = &meson->lock; - err =devm_clk_hw_register (dev, &channel->div.hw); + err =devm_clk_hw_register (dev, &clks->div.hw);if (err)return dev_err_probe (dev, err,"failed to register %s\n" , name);@@ -471,22 +478,22 @@ static int meson_pwm_init_channels(struct pwm_chip *chip) init.name = name; init.ops = &clk_gate_ops;
drivers/pwm/pwm-meson.c static int meson_pwm_init_channels(struct pwm_chip *chip) · line 485
Quoted 10 lines
drivers/pwm/pwm-meson.c +3
-3init.flags =CLK_SET_RATE_PARENT |CLK_IGNORE_UNUSED ; - gate_parent.index =-1 ; - gate_parent.hw = &channel->div.hw; - init.parent_data = &gate_parent; + pdata.index =-1 ; + pdata.hw = &clks->div.hw; + init.parent_data = &pdata; init.num_parents =1 ;
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Jerome Brunet
reviewerPATCH v5 5/5 pwm: meson: add generic compatible for meson8 to sm1
In reply to Jerome BrunetIntroduce a new compatible support in the Amlogic PWM driver.
The PWM HW is actually the same for all SoCs supported so far. A specific compatible is needed only because the clock sources of the PWMs are hard-coded in the driver.
It is better to have the clock source described in DT but this changes the bindings so a new compatible must be introduced.
When all supported platform have migrated to the new compatible, support for the legacy ones may be removed from the driver.
The addition of this new compatible makes the old ones obsolete, as described in the DT documentation.
Adding a callback to setup the clock will also make it easier to add support for the new PWM HW found in a1, s4, c3 and t7 SoC families.
--- drivers/pwm/pwm-meson.c | 195 +++++++++++++++++++++++++--------------- 1 file changed, 121 insertions(+), 74 deletions(-)
drivers/pwm/pwm-meson.c +121 -74
@@ -101,6 +101,7 @@ struct meson_pwm_channel {struct meson_pwm_data {const char *const parent_names[MESON_NUM_MUX_PARENTS ]; +int (*channels_init)(struct pwm_chip *chip); };struct meson_pwm {
@@ -341,86 +342,16 @@ static const struct pwm_ops meson_pwm_ops = { .get_state = meson_pwm_get_state, }; -static const struct meson_pwm_data pwm_meson8b_data = { - .parent_names = {"xtal" ,NULL ,"fclk_div4" ,"fclk_div3" }, -}; - -/* -* Only the 2 first inputs of the GXBB AO PWMs are valid -* The last 2 are grounded -*/ -static const struct meson_pwm_data pwm_gxbb_ao_data = { - .parent_names = {"xtal" ,"clk81" ,NULL ,NULL }, -}; - -static const struct meson_pwm_data pwm_axg_ee_data = { - .parent_names = {"xtal" ,"fclk_div5" ,"fclk_div4" ,"fclk_div3" }, -}; - -static const struct meson_pwm_data pwm_axg_ao_data = { - .parent_names = {"xtal" ,"axg_ao_clk81" ,"fclk_div4" ,"fclk_div5" }, -}; - -static const struct meson_pwm_data pwm_g12a_ao_ab_data = { - .parent_names = {"xtal" ,"g12a_ao_clk81" ,"fclk_div4" ,"fclk_div5" }, -}; - -static const struct meson_pwm_data pwm_g12a_ao_cd_data = { - .parent_names = {"xtal" ,"g12a_ao_clk81" ,NULL ,NULL }, -}; - -static const struct of_device_id meson_pwm_matches[] = { - { - .compatible ="amlogic,meson8b-pwm" , - .data = &pwm_meson8b_data - }, - { - .compatible ="amlogic,meson-gxbb-pwm" , - .data = &pwm_meson8b_data - }, - { - .compatible ="amlogic,meson-gxbb-ao-pwm" , - .data = &pwm_gxbb_ao_data - }, - { - .compatible ="amlogic,meson-axg-ee-pwm" , - .data = &pwm_axg_ee_data - }, - { - .compatible ="amlogic,meson-axg-ao-pwm" , - .data = &pwm_axg_ao_data - }, - { - .compatible ="amlogic,meson-g12a-ee-pwm" , - .data = &pwm_meson8b_data - }, - { - .compatible ="amlogic,meson-g12a-ao-pwm-ab" , - .data = &pwm_g12a_ao_ab_data - }, - { - .compatible ="amlogic,meson-g12a-ao-pwm-cd" , - .data = &pwm_g12a_ao_cd_data - }, - {}, -}; -MODULE_DEVICE_TABLE (of, meson_pwm_matches); - -static int meson_pwm_init_channels (struct pwm_chip *chip) +static int meson_pwm_init_clocks_meson8b (struct pwm_chip *chip, +struct clk_parent_data *mux_parent_data) {struct meson_pwm *meson =to_meson_pwm (chip); -struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS ] = {};struct device *dev =pwmchip_parent (chip);unsigned int i;char name[255 ];int err; -for (i =0 ; i <MESON_NUM_MUX_PARENTS ; i++) { - mux_parent_data[i].index =-1 ; - mux_parent_data[i].name = meson->data->parent_names[i]; - } - -for (i =0 ; i < chip->npwm; i++) { +for (i =0 ; i <MESON_NUM_PWMS ; i++) {struct meson_pwm_channel *channel = &meson->channels[i];struct clk_parent_data pdata = {};struct meson8b_pwm_clocks *clks;
@@ -502,6 +433,122 @@ static int meson_pwm_init_channels(struct pwm_chip *chip)return 0 ; } +static int meson_pwm_init_channels_meson8b_legacy (struct pwm_chip *chip) +{ +struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS ] = {}; +struct meson_pwm *meson =to_meson_pwm (chip); +int i; + +dev_warn_once (pwmchip_parent (chip), +"using obsolete compatible, please consider updating dt\n" ); + +for (i =0 ; i <MESON_NUM_MUX_PARENTS ; i++) { + mux_parent_data[i].index =-1 ; + mux_parent_data[i].name = meson->data->parent_names[i]; + } + +return meson_pwm_init_clocks_meson8b (chip, mux_parent_data); +} + +static int meson_pwm_init_channels_meson8b_v2 (struct pwm_chip *chip) +{ +struct clk_parent_data mux_parent_data[MESON_NUM_MUX_PARENTS ] = {}; +int i; + +/* +* NOTE: Instead of relying on the hard coded names in the driver +* as the legacy version, this relies on DT to provide the list of +* clocks. +* For once, using input numbers actually makes more sense than names. +* Also DT requires clock-names to be explicitly ordered, so there is +* no point bothering with clock names in this case. +*/ +for (i =0 ; i <MESON_NUM_MUX_PARENTS ; i++) + mux_parent_data[i].index = i; + +return meson_pwm_init_clocks_meson8b (chip, mux_parent_data); +} + +static const struct meson_pwm_data pwm_meson8b_data = { + .parent_names = {"xtal" ,NULL ,"fclk_div4" ,"fclk_div3" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +/* +* Only the 2 first inputs of the GXBB AO PWMs are valid +* The last 2 are grounded +*/ +static const struct meson_pwm_data pwm_gxbb_ao_data = { + .parent_names = {"xtal" ,"clk81" ,NULL ,NULL }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_axg_ee_data = { + .parent_names = {"xtal" ,"fclk_div5" ,"fclk_div4" ,"fclk_div3" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_axg_ao_data = { + .parent_names = {"xtal" ,"axg_ao_clk81" ,"fclk_div4" ,"fclk_div5" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_g12a_ao_ab_data = { + .parent_names = {"xtal" ,"g12a_ao_clk81" ,"fclk_div4" ,"fclk_div5" }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_g12a_ao_cd_data = { + .parent_names = {"xtal" ,"g12a_ao_clk81" ,NULL ,NULL }, + .channels_init = meson_pwm_init_channels_meson8b_legacy, +}; + +static const struct meson_pwm_data pwm_meson8_v2_data = { + .channels_init = meson_pwm_init_channels_meson8b_v2, +}; + +static const struct of_device_id meson_pwm_matches[] = { + { + .compatible ="amlogic,meson8-pwm-v2" , + .data = &pwm_meson8_v2_data + }, +/* The following compatibles are obsolete */ + { + .compatible ="amlogic,meson8b-pwm" , + .data = &pwm_meson8b_data + }, + { + .compatible ="amlogic,meson-gxbb-pwm" , + .data = &pwm_meson8b_data + }, + { + .compatible ="amlogic,meson-gxbb-ao-pwm" , + .data = &pwm_gxbb_ao_data + }, + { + .compatible ="amlogic,meson-axg-ee-pwm" , + .data = &pwm_axg_ee_data + }, + { + .compatible ="amlogic,meson-axg-ao-pwm" , + .data = &pwm_axg_ao_data + }, + { + .compatible ="amlogic,meson-g12a-ee-pwm" , + .data = &pwm_meson8b_data + }, + { + .compatible ="amlogic,meson-g12a-ao-pwm-ab" , + .data = &pwm_g12a_ao_ab_data + }, + { + .compatible ="amlogic,meson-g12a-ao-pwm-cd" , + .data = &pwm_g12a_ao_cd_data + }, + {}, +}; +MODULE_DEVICE_TABLE (of, meson_pwm_matches); +static int meson_pwm_probe (struct platform_device *pdev) {struct pwm_chip *chip;
@@ -522,7 +569,7 @@ static int meson_pwm_probe(struct platform_device *pdev) meson->data =of_device_get_match_data (&pdev->dev); - err =meson_pwm_init_channels (chip); + err = meson->data->channels_init (chip);if (err <0 )return err;
Signature · 1 line
2.43.0
Re: [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
Quoted 12 lines · Jerome Brunet
Introduce a new compatible support in the Amlogic PWM driver.
The PWM HW is actually the same for all SoCs supported so far. A specific compatible is needed only because the clock sources of the PWMs are hard-coded in the driver.
It is better to have the clock source described in DT but this changes the bindings so a new compatible must be introduced.
When all supported platform have migrated to the new compatible, support for the legacy ones may be removed from the driver.
Quoted 7 lines
The addition of this new compatible makes the old ones obsolete, as described in the DT documentation.
Adding a callback to setup the clock will also make it easier to add support for the new PWM HW found in a1, s4, c3 and t7 SoC families.
Signed-off-by Jerome Brunet <[email protected]>
After spending some brain cycles on this one I think I understood it. Looks fine to me, I only considered questioning if the dev_warn_once is too offensive.
b4 + git applied the patch just fine even without patch #4 of this series. Would you be so kind to double check it works as intended?
BTW, b4 diagnosed:
Checking attestation on all messages, may take a moment...
---
✗ [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Uwe Kleine-König <[email protected]>
---
✗ BADSIG: DKIM/baylibre-com.20230601.gappssmtp.com
Is this only because it took me so long to reply, or is there a configuration issue with the baylibre MTA?
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Jerome Brunet
reviewerRe: [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
Quoted 20 lines · Uwe Kleine-König
[[PGP Signed Part:Undecided]]
Quoted 18 lines · Jerome Brunet
Introduce a new compatible support in the Amlogic PWM driver.
The PWM HW is actually the same for all SoCs supported so far. A specific compatible is needed only because the clock sources of the PWMs are hard-coded in the driver.
It is better to have the clock source described in DT but this changes the bindings so a new compatible must be introduced.
When all supported platform have migrated to the new compatible, support for the legacy ones may be removed from the driver.
The addition of this new compatible makes the old ones obsolete, as described in the DT documentation.
Adding a callback to setup the clock will also make it easier to add support for the new PWM HW found in a1, s4, c3 and t7 SoC families.
Quoted 8 lines
Quoted 1 line
Signed-off-by Jerome Brunet <[email protected]>After spending some brain cycles on this one I think I understood it. Looks fine to me, I only considered questioning if the
dev_warn_onceis too offensive.b4 + git applied the patch just fine even without patch #4 of this series. Would you be so kind to double check it works as intended?
It does, Thx.
Quoted 11 lines
BTW, b4 diagnosed:
Checking attestation on all messages, may take a moment...
---
✗ [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Uwe Kleine-König <[email protected]>
---
✗ BADSIG: DKIM/baylibre-com.20230601.gappssmtp.com
Quoted 2 lines
Is this only because it took me so long to reply, or is there a configuration issue with the baylibre MTA?
I have no idea. This is the first time this is reported
Quoted 3 lines
Best regards
Uwe
Signature · 1 line
Jerome
Re: [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
Quoted 5 lines · Jerome Brunet
Quoted 2 lines · Uwe Kleine-König
b4 + git applied the patch just fine even without patch #4 of this series. Would you be so kind to double check it works as intended?
It does, Thx.
Thank you.
Quoted 10 lines
Quoted 10 lines
BTW, b4 diagnosed:
Checking attestation on all messages, may take a moment...
---
✗ [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Uwe Kleine-König <[email protected]>
---
✗ BADSIG: DKIM/baylibre-com.20230601.gappssmtp.com
Quoted 4 lines
Quoted 2 lines
Is this only because it took me so long to reply, or is there a configuration issue with the baylibre MTA?
I have no idea. This is the first time this is reported
I just picked up a patch by one of your colleagues and there the DKIM stuff was fine. I didn't debug that further.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Neil Armstrong
maintainerRe: [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
Quoted 19 lines · Uwe Kleine-König
Quoted 5 lines · Jerome Brunet
Quoted 2 lines · Uwe Kleine-König
b4 + git applied the patch just fine even without patch #4 of this series. Would you be so kind to double check it works as intended?
It does, Thx.
Thank you.
Quoted 10 lines
Quoted 10 lines
BTW, b4 diagnosed:
Checking attestation on all messages, may take a moment...
---
✗ [PATCH v5 5/5] pwm: meson: add generic compatible for meson8 to sm1
+ Link: https://lore.kernel.org/r/[email protected]
+ Signed-off-by: Uwe Kleine-König <[email protected]>
---
✗ BADSIG: DKIM/baylibre-com.20230601.gappssmtp.com
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Is this only because it took me so long to reply, or is there a configuration issue with the baylibre MTA?
I have no idea. This is the first time this is reported
I just picked up a patch by one of your colleagues and there the DKIM stuff was fine. I didn't debug that further.
Google's DKIM key gets rotated, after while the DKIM signature gets invalid.
The best is to add a GPG signature on top of DKIM, like with B4.
Neil
Quoted 4 lines
Best regards
Uwe
Hello Jerome,
Quoted 6 lines · Jerome Brunet
Jerome Brunet (5):
dt-bindings: pwm: amlogic: fix s4 bindings
dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types
pwm: meson: generalize 4 inputs clock on meson8 pwm type
pwm: meson: don't carry internal clock elements around
pwm: meson: add generic compatible for meson8 to sm1
I applied patches #1 to #3. This doesn't mean #4 and #5 are bad, just that I need some more time for review.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Jerome Brunet
reviewerQuoted 11 lines · Uwe Kleine-König
[[PGP Signed Part:Undecided]]
Hello Jerome,Quoted 6 lines · Jerome Brunet
Jerome Brunet (5):
dt-bindings: pwm: amlogic: fix s4 bindings
dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types
pwm: meson: generalize 4 inputs clock on meson8 pwm type
pwm: meson: don't carry internal clock elements around
pwm: meson: add generic compatible for meson8 to sm1
Quoted 2 lines
I applied patches #1 to #3. This doesn't mean #4 and #5 are bad, just that I need some more time for review.
No worries. The change in those, especially #5, are pretty simple but the diff are indeed hard to read :/
Quoted 3 lines
Best regards
Uwe
Signature · 1 line
Jerome
Jerome Brunet
reviewerQuoted 13 lines · Jerome Brunet
Quoted 11 lines · Uwe Kleine-König
[[PGP Signed Part:Undecided]]
Hello Jerome,Quoted 6 lines · Jerome Brunet
Jerome Brunet (5):
dt-bindings: pwm: amlogic: fix s4 bindings
dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types
pwm: meson: generalize 4 inputs clock on meson8 pwm type
pwm: meson: don't carry internal clock elements around
pwm: meson: add generic compatible for meson8 to sm1
Quoted 5 lines
Quoted 2 lines
I applied patches #1 to #3. This doesn't mean #4 and #5 are bad, just that I need some more time for review.
No worries. The change in those, especially #5, are pretty simple but the diff are indeed hard to read :/
Hello Uwe,
Introducing the s4 support depends on this series. Is there any news ?
Thanks
Regards
Quoted 4 lines
Quoted 4 lines
Best regards
Uwe
Signature · 1 line
Jerome
Hello Jerome, Uwe
Quoted 19 lines · Jerome Brunet
Quoted 16 lines · Jerome Brunet
Quoted 13 lines · Uwe Kleine-König
[[PGP Signed Part:Undecided]]
Hello Jerome,Quoted 6 lines · Jerome Brunet
Jerome Brunet (5):
dt-bindings: pwm: amlogic: fix s4 bindings
dt-bindings: pwm: amlogic: Add a new binding for meson8 pwm types
pwm: meson: generalize 4 inputs clock on meson8 pwm type
pwm: meson: don't carry internal clock elements around
pwm: meson: add generic compatible for meson8 to sm1I applied patches #1 to #3. This doesn't mean #4 and #5 are bad, just that I need some more time for review.
Quoted 7 lines
Quoted 2 lines
No worries. The change in those, especially #5, are pretty simple but the diff are indeed hard to read :/
Hello Uwe,
Introducing the s4 support depends on this series. Is there any news ?
Actually we're waiting for the opportunity to introduce a1 support too.
Quoted 10 lines
Thanks
RegardsQuoted 4 lines
Quoted 4 lines
Best regards
Uwe
Signature · 2 lines
Best regards George