mbox series

[v3,0/5] ARM: omap: omap4-embt2ws: 32K clock for WLAN

Message ID 20230911221346.1484543-1-andreas@kemnade.info
Headers show
Series ARM: omap: omap4-embt2ws: 32K clock for WLAN | expand

Message

Andreas Kemnade Sept. 11, 2023, 10:13 p.m. UTC
To have WLAN working properly, enable a 32K clock of the TWL6032.
In earlier tests, it was still enabled from a previous boot into
the vendor system.

Changes in V3:
- maintainer change in binding doc
- fix references to binding doc
- additionalProperties: false
- remove subdevices also from examples until
  subdevices are referenced/added

Changes in V2:
- no separate device node for the clock
- converted toplevel node of TWL

Andreas Kemnade (5):
  dt-bindings: mfd: convert twl-family.txt to json-schema
  dt-bindings: mfd: ti,twl: Add clock provider properties
  mfd: twl-core: Add a clock subdevice for the TWL6032
  clk: twl: add clock driver for TWL6032
  ARM: dts: omap4-embt2ws: enable 32K clock on WLAN

 .../bindings/input/twl4030-pwrbutton.txt      |   2 +-
 .../devicetree/bindings/mfd/ti,twl.yaml       |  67 ++++++
 .../devicetree/bindings/mfd/twl-family.txt    |  46 ----
 .../boot/dts/ti/omap/omap4-epson-embt2ws.dts  |   8 +
 drivers/clk/Kconfig                           |   9 +
 drivers/clk/Makefile                          |   1 +
 drivers/clk/clk-twl.c                         | 197 ++++++++++++++++++
 drivers/mfd/twl-core.c                        |  16 ++
 8 files changed, 299 insertions(+), 47 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti,twl.yaml
 delete mode 100644 Documentation/devicetree/bindings/mfd/twl-family.txt
 create mode 100644 drivers/clk/clk-twl.c

Comments

Christophe JAILLET Sept. 12, 2023, 5:15 p.m. UTC | #1
Le 12/09/2023 à 00:13, Andreas Kemnade a écrit :
> The TWL6032 has some clock outputs which are controlled like
> fixed-voltage regulators, in some drivers for these chips
> found in the wild, just the regulator api is abused for controlling
> them, so simply use something similar to the regulator functions.
> Due to a lack of hardware available for testing, leave out the
> TWL6030-specific part of those functions.
> 
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>   drivers/clk/Kconfig   |   9 ++
>   drivers/clk/Makefile  |   1 +
>   drivers/clk/clk-twl.c | 197 ++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 207 insertions(+)
>   create mode 100644 drivers/clk/clk-twl.c
> 

...

> +static int twl_clks_probe(struct platform_device *pdev)
> +{
> +	struct clk_hw_onecell_data *clk_data;
> +	const struct twl_clks_data *hw_data;
> +
> +	struct twl_clock_info *cinfo;
> +	int ret;
> +	int i;
> +	int count;
> +
> +	hw_data = twl6032_clks;
> +	for (count = 0; hw_data[count].init.name; count++)
> +		;

Nit: does removing the /* sentinel */ and using 
ARRAY_SIZE(twl_clks_data) would make sense and be simpler?

CJ

> +
> +	clk_data = devm_kzalloc(&pdev->dev,
> +				struct_size(clk_data, hws, count),
> +				GFP_KERNEL);
> +	if (!clk_data)
> +		return -ENOMEM;
> +
> +	clk_data->num = count;
> +	cinfo = devm_kcalloc(&pdev->dev, count, sizeof(*cinfo), GFP_KERNEL);
> +	if (!cinfo)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < count; i++) {
> +		cinfo[i].base = hw_data[i].base;
> +		cinfo[i].dev = &pdev->dev;
> +		cinfo[i].hw.init = &hw_data[i].init;
> +		ret = devm_clk_hw_register(&pdev->dev, &cinfo[i].hw);
> +		if (ret) {
> +			dev_err(&pdev->dev, "Fail to register clock %s, %d\n",
> +				hw_data[i].init.name, ret);
> +			return ret;
> +		}
> +		clk_data->hws[i] = &cinfo[i].hw;
> +	}
> +
> +	ret = devm_of_clk_add_hw_provider(&pdev->dev,
> +					  of_clk_hw_onecell_get, clk_data);
> +	if (ret < 0)
> +		dev_err(&pdev->dev, "Fail to add clock driver, %d\n", ret);
> +
> +	return ret;

Nit: should there be a V4, some prefer return 0 to be more explicit.

> +}

...
Christophe JAILLET Sept. 12, 2023, 6:24 p.m. UTC | #2
Le 12/09/2023 à 19:15, Christophe JAILLET a écrit :
> Le 12/09/2023 à 00:13, Andreas Kemnade a écrit :
>> The TWL6032 has some clock outputs which are controlled like
>> fixed-voltage regulators, in some drivers for these chips
>> found in the wild, just the regulator api is abused for controlling
>> them, so simply use something similar to the regulator functions.
>> Due to a lack of hardware available for testing, leave out the
>> TWL6030-specific part of those functions.
>>
>> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
>> ---
>>   drivers/clk/Kconfig   |   9 ++
>>   drivers/clk/Makefile  |   1 +
>>   drivers/clk/clk-twl.c | 197 ++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 207 insertions(+)
>>   create mode 100644 drivers/clk/clk-twl.c
>>
> 
> ...
> 
>> +static int twl_clks_probe(struct platform_device *pdev)
>> +{
>> +    struct clk_hw_onecell_data *clk_data;
>> +    const struct twl_clks_data *hw_data;
>> +
>> +    struct twl_clock_info *cinfo;
>> +    int ret;
>> +    int i;
>> +    int count;
>> +
>> +    hw_data = twl6032_clks;
>> +    for (count = 0; hw_data[count].init.name; count++)
>> +        ;
> 
> Nit: does removing the /* sentinel */ and using 
> ARRAY_SIZE(twl_clks_data) would make sense and be simpler?
> 
> CJ
> 
>> +
>> +    clk_data = devm_kzalloc(&pdev->dev,
>> +                struct_size(clk_data, hws, count),
>> +                GFP_KERNEL);
>> +    if (!clk_data)
>> +        return -ENOMEM;
>> +
>> +    clk_data->num = count;
>> +    cinfo = devm_kcalloc(&pdev->dev, count, sizeof(*cinfo), GFP_KERNEL);
>> +    if (!cinfo)
>> +        return -ENOMEM;
>> +
>> +    for (i = 0; i < count; i++) {
>> +        cinfo[i].base = hw_data[i].base;
>> +        cinfo[i].dev = &pdev->dev;
>> +        cinfo[i].hw.init = &hw_data[i].init;
>> +        ret = devm_clk_hw_register(&pdev->dev, &cinfo[i].hw);
>> +        if (ret) {
>> +            dev_err(&pdev->dev, "Fail to register clock %s, %d\n",
>> +                hw_data[i].init.name, ret);
>> +            return ret;
>> +        }
>> +        clk_data->hws[i] = &cinfo[i].hw;
>> +    }
>> +
>> +    ret = devm_of_clk_add_hw_provider(&pdev->dev,
>> +                      of_clk_hw_onecell_get, clk_data);
>> +    if (ret < 0)
>> +        dev_err(&pdev->dev, "Fail to add clock driver, %d\n", ret);
>> +
>> +    return ret;
> 
> Nit: should there be a V4, some prefer return 0 to be more explicit.

Oops, no, or a "return ret;" should be added as well a few lines above
(it would more future proof, so)

> 
>> +}
> 
> ...
> 
>
Andreas Kemnade Sept. 12, 2023, 6:56 p.m. UTC | #3
On Tue, 12 Sep 2023 19:15:54 +0200
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> Le 12/09/2023 à 00:13, Andreas Kemnade a écrit :
> > The TWL6032 has some clock outputs which are controlled like
> > fixed-voltage regulators, in some drivers for these chips
> > found in the wild, just the regulator api is abused for controlling
> > them, so simply use something similar to the regulator functions.
> > Due to a lack of hardware available for testing, leave out the
> > TWL6030-specific part of those functions.
> > 
> > Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> > ---
> >   drivers/clk/Kconfig   |   9 ++
> >   drivers/clk/Makefile  |   1 +
> >   drivers/clk/clk-twl.c | 197 ++++++++++++++++++++++++++++++++++++++++++
> >   3 files changed, 207 insertions(+)
> >   create mode 100644 drivers/clk/clk-twl.c
> >   
> 
> ...
> 
> > +static int twl_clks_probe(struct platform_device *pdev)
> > +{
> > +	struct clk_hw_onecell_data *clk_data;
> > +	const struct twl_clks_data *hw_data;
> > +
> > +	struct twl_clock_info *cinfo;
> > +	int ret;
> > +	int i;
> > +	int count;
> > +
> > +	hw_data = twl6032_clks;
> > +	for (count = 0; hw_data[count].init.name; count++)
> > +		;  
> 
> Nit: does removing the /* sentinel */ and using 
> ARRAY_SIZE(twl_clks_data) would make sense and be simpler?
> 
well, I would like to have it prepared for different arrays
passed in some device data in the future, so I am choosing that
approach.

Regards,
Andreas