ARM: omap: omap4-embt2ws: 32K clock for WLAN
Subsystems (7)
Andreas Kemnade
maintainerv3 cover ARM: omap: omap4-embt2ws: 32K clock for WLAN
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
Signature · 1 line
2.39.2
Andreas Kemnade
maintainerPATCH v3 1/5 dt-bindings: mfd: convert twl-family.txt to json-schema
Convert the TWL[46]030 binding to DT schema format. To do it as a step by step work, do not include / handle nodes for subdevices yet, just convert things with minimal corrections. There are already some bindings for its subdevices in the tree.
--- .../bindings/input/twl4030-pwrbutton.txt | 2 +- .../devicetree/bindings/mfd/ti,twl.yaml | 64 +++++++++++++++++++ .../devicetree/bindings/mfd/twl-family.txt | 46 ------------- 3 files changed, 65 insertions(+), 47 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/ti,twl.yaml delete mode 100644 Documentation/devicetree/bindings/mfd/twl-family.txt
Documentation/devicetree/bindings/input/twl4030-pwrbutton.txt +1 -1
@@ -1,7 +1,7 @@ Texas Instruments TWL family (twl4030) pwrbutton module This module is part of the TWL4030. For more details about the whole -chip see Documentation/devicetree/bindings/mfd/twl-family.txt. +chip see Documentation/devicetree/bindings/mfd/ti,twl.yaml. This module provides a simple power button event via an Interrupt.
Documentation/devicetree/bindings/mfd/ti,twl.yaml new file +64 -0
64 lines not on this page · raw message
Documentation/devicetree/bindings/mfd/twl-family.txt deleted +0 -46
46 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH v3 1/5] dt-bindings: mfd: convert twl-family.txt to json-schema
Quoted 35 lines · Andreas Kemnade
Convert the TWL[46]030 binding to DT schema format. To do it as a step by step work, do not include / handle nodes for subdevices yet, just convert things with minimal corrections. There are already some bindings for its subdevices in the tree.
Signed-off-by Andreas Kemnade <[email protected]>--- .../bindings/input/twl4030-pwrbutton.txt | 2 +- .../devicetree/bindings/mfd/ti,twl.yaml | 64 +++++++++++++++++++ .../devicetree/bindings/mfd/twl-family.txt | 46 ------------- 3 files changed, 65 insertions(+), 47 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/ti,twl.yaml delete mode 100644 Documentation/devicetree/bindings/mfd/twl-family.txtDocumentation/devicetree/bindings/input/twl4030-pwrbutton.txt +1
-1@@ -1,7 +1,7 @@ Texas Instruments TWL family (twl4030) pwrbutton module This module is part of the TWL4030. For more details about the whole -chip see Documentation/devicetree/bindings/mfd/twl-family.txt. +chip see Documentation/devicetree/bindings/mfd/ti,twl.yaml. This module provides a simple power button event via an Interrupt.Documentation/devicetree/bindings/mfd/ti,twl.yaml new file +2
-0@@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2
Documentation/devicetree/bindings/mfd/ti,twl.yaml line 12
Quoted 10 lines
Documentation/devicetree/bindings/mfd/ti,twl.yaml new file +10
-0+--- +$id: http://devicetree.org/schemas/mfd/ti,twl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments TWL family + +maintainers: + - Andreas Kemnade <[email protected]> + +description: |
FWIW the | is not needed here, but that's w/e.
This seems fine to me though,
Thanks,
Conor.
Quoted 107 lines
Documentation/devicetree/bindings/mfd/ti,twl.yaml new file +52
-0+ The TWLs are Integrated Power Management Chips. + Some version might contain much more analog function like + USB transceiver or Audio amplifier. + These chips are connected to an i2c bus. + +properties: + compatible: + description: + TWL4030 for integrated power-management/audio CODEC device used in OMAP3 + based boards + TWL6030/32 for integrated power-management used in OMAP4 based boards + enum: + - ti,twl4030 + - ti,twl6030 + - ti,twl6032 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + interrupt-controller: true + + "#interrupt-cells": + const: 1 + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - "#interrupt-cells" + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@48 { + compatible = "ti,twl6030"; + reg = <0x48>; + interrupts = <39>; /* IRQ_SYS_1N cascaded to gic */ + interrupt-controller; + #interrupt-cells = <1>; + interrupt-parent = <&gic>; + }; + }; +Documentation/devicetree/bindings/mfd/twl-family.txt deleted +0
-46@@ -1,46 +0,0 @@ -Texas Instruments TWL family - -The TWLs are Integrated Power Management Chips. -Some version might contain much more analog function like -USB transceiver or Audio amplifier. -These chips are connected to an i2c bus. - - -Required properties: -- compatible : Must be "ti,twl4030"; - For Integrated power-management/audio CODEC device used in OMAP3 - based boards -- compatible : Must be "ti,twl6030"; - For Integrated power-management used in OMAP4 based boards -- interrupts : This i2c device has an IRQ line connected to the main SoC -- interrupt-controller : Since the twl support several interrupts internally, - it is considered as an interrupt controller cascaded to the SoC one. -- #interrupt-cells = <1>; - -Optional node: -- Child nodes contain in the twl. The twl family is made of several variants - that support a different number of features. - The children nodes will thus depend of the capability of the variant. - - -Example: -/* - * Integrated Power Management Chip - * https://www.ti.com/lit/ds/symlink/twl6030.pdf - */ -twl@48 { - compatible = "ti,twl6030"; - reg = <0x48>; - interrupts = <39>; /* IRQ_SYS_1N cascaded to gic */ - interrupt-controller; - #interrupt-cells = <1>; - interrupt-parent = <&gic>; - #address-cells = <1>; - #size-cells = <0>; - - twl_rtc { - compatible = "ti,twl_rtc"; - interrupts = <11>; - reg = <0>; - }; -};Signature · 1 line
2.39.2
Andreas Kemnade
maintainerPATCH v3 2/5 dt-bindings: mfd: ti,twl: Add clock provider properties
In reply to Andreas KemnadeSince these devices provide clock outputs, add the corresponding property.
--- Documentation/devicetree/bindings/mfd/ti,twl.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/mfd/ti,twl.yaml +3 -0
@@ -37,6 +37,9 @@ properties: "#interrupt-cells": const: 1 + "#clock-cells": + const: 1 + additionalProperties: false required:
Signature · 1 line
2.39.2
Andreas Kemnade
maintainerPATCH v3 3/5 mfd: twl-core: Add a clock subdevice for the TWL6032
In reply to Andreas KemnadeClock device needs no separate devicetree node, so add it as a platform device. Other devices in the family also have controllable clocks, but due to the lack of testing, just add it for the TWL6032 now.
--- drivers/mfd/twl-core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/mfd/twl-core.c +16 -0
@@ -31,6 +31,8 @@#include <linux/regulator/machine.h> #include <linux/i2c.h> + +#include <linux/mfd/core.h> #include <linux/mfd/twl.h> /* Register descriptions for audio */
@@ -690,6 +692,10 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = { { /* sentinel */ }, }; +static const struct mfd_cell twl6032_cells[] = { + { .name ="twl6032-clk" }, +}; +/* NOTE: This driver only handles a single twl4030/tps659x0 chip */ static int twl_probe (struct i2c_client *client)
@@ -836,6 +842,16 @@ twl_probe(struct i2c_client *client) TWL4030_DCDC_GLOBAL_CFG); } +if (id->driver_data == (TWL6030_CLASS |TWL6032_SUBCLASS )) { + status =devm_mfd_add_devices (&client->dev, +PLATFORM_DEVID_NONE , + twl6032_cells, +ARRAY_SIZE (twl6032_cells), +NULL ,0 ,NULL ); +if (status <0 ) + goto free; + } + status =of_platform_populate (node,NULL , twl_auxdata_lookup, &client->dev);
Signature · 1 line
2.39.2
Andreas Kemnade
maintainerPATCH v3 4/5 clk: twl: add clock driver for TWL6032
In reply to Andreas KemnadeThe 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.
--- 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
drivers/clk/Kconfig +9 -0
@@ -277,6 +277,15 @@ config COMMON_CLK_S2MPS11 clock. These multi-function devices have two (S2MPS14) or three (S2MPS11, S5M8767) fixed-rate oscillators, clocked at 32KHz each. +config CLK_TWL + tristate "Clock driver for the TWL PMIC family" + depends on TWL4030_CORE + help + Enable support for controlling the clock resources on TWL family + PMICs. These devices have some 32K clock outputs which can be + controlled by software. For now, only the TWL6032 clocks are + supported. + config CLK_TWL6040 tristate "External McPDM functional clock from twl6040" depends on TWL6040_CORE
drivers/clk/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_COMMON_CLK_STM32H7) += clk-stm32h7.o obj-$(CONFIG_COMMON_CLK_STM32MP157) += clk-stm32mp1.o obj-$(CONFIG_COMMON_CLK_TPS68470) += clk-tps68470.o obj-$(CONFIG_CLK_TWL6040) += clk-twl6040.o +obj-$(CONFIG_CLK_TWL) += clk-twl.o obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o obj-$(CONFIG_COMMON_CLK_RS9_PCIE) += clk-renesas-pcie.o obj-$(CONFIG_COMMON_CLK_SI521XX) += clk-si521xx.o
drivers/clk/clk-twl.c new file +197 -0
197 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH v3 4/5] clk: twl: add clock driver for TWL6032
Le 12/09/2023 à 00:13, Andreas Kemnade a écrit :
Quoted 15 lines
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 <[email protected]>--- 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
...
drivers/clk/clk-twl.c line 143
Quoted 13 lines
drivers/clk/clk-twl.c new file +13
-0+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
Quoted 21 lines
drivers/clk/clk-twl.c new file +21
-0+ + 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;
drivers/clk/clk-twl.c line 174
Quoted 10 lines
drivers/clk/clk-twl.c new file +10
-0+ } + 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.
Quoted 1 line
+}
...
Re: [PATCH v3 4/5] clk: twl: add clock driver for TWL6032
Le 12/09/2023 à 19:15, Christophe JAILLET a écrit :
Quoted 62 lines
Le 12/09/2023 à 00:13, Andreas Kemnade a écrit :
Quoted 15 lines
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 <[email protected]>---
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...
drivers/clk/clk-twl.c line 143
Quoted 13 lines
drivers/clk/clk-twl.c new file +13
-0+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
Quoted 25 lines
drivers/clk/clk-twl.c new file +25
-0+ + 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; + } +
Quoted 8 lines
Quoted 6 lines
+ 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)
Quoted 6 lines
Quoted 2 lines
+}
...
Andreas Kemnade
maintainerRe: [PATCH v3 4/5] clk: twl: add clock driver for TWL6032
In reply to Christophe JAILLETQuoted 19 lines · On Tue, 12 Sep 2023 19:15:54 +0200 Christophe JAILLET…
Le 12/09/2023 à 00:13, Andreas Kemnade a écrit :
Quoted 15 lines
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 <[email protected]>--- 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...
Quoted 17 lines
drivers/clk/clk-twl.c line 143
Quoted 13 lines
drivers/clk/clk-twl.c new file +13
-0+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
Stephen Boyd
maintainerRe: [PATCH v3 4/5] clk: twl: add clock driver for TWL6032
In reply to Andreas KemnadeQuoting Andreas Kemnade (2023-09-11 15:13:45)
Quoted 6 lines
drivers/clk/clk-twl.c new file +0
-0
drivers/clk/clk-twl.c line 8
Quoted 8 lines
drivers/clk/clk-twl.c new file +8
-0@@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Clock driver for twl device. +* +* inspired by the driver for the Palmas device +*/ + +#include <linux/clk.h>
Please drop this include unless it is used.
Quoted 16 lines
drivers/clk/clk-twl.c new file +16
-0+#include <linux/clk-provider.h> +#include <linux/mfd/twl.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +#define VREG_STATE 2 +#define TWL6030_CFG_STATE_OFF 0x00 +#define TWL6030_CFG_STATE_ON 0x01 +#define TWL6030_CFG_STATE_MASK 0x03 + +struct twl_clock_info { +struct device *dev; +u8 base; +struct clk_hw hw; +};
[...]
Quoted 23 lines
drivers/clk/clk-twl.c new file +23
-0+ +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++) + ; + + 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 );
drivers/clk/clk-twl.c line 162
Quoted 10 lines
drivers/clk/clk-twl.c new file +10
-0+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",
Use dev_err_probe()
drivers/clk/clk-twl.c line 172
Quoted 10 lines
drivers/clk/clk-twl.c new file +10
-0+ 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);
Use dev_err_probe()
Quoted 2 lines
drivers/clk/clk-twl.c new file +2
-0+ +return ret;
Andreas Kemnade
maintainerPATCH v3 5/5 ARM: dts: omap4-embt2ws: enable 32K clock on WLAN
In reply to Andreas KemnadeWLAN did only work if clock was left enabled by the original system, so make it fully enable the needed resources itself.
--- arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/ti/omap/omap4-epson-embt2ws.dts +8 -0
@@ -69,6 +69,12 @@ unknown_supply: unknown-supply { regulator-name = "unknown"; }; + wl12xx_pwrseq: wl12xx-pwrseq { + compatible = "mmc-pwrseq-simple"; + clocks = <&twl 1>; + clock-names = "ext_clock"; + }; + /* regulator for wl12xx on sdio2 */ wl12xx_vmmc: wl12xx-vmmc { pinctrl-names = "default";
@@ -92,6 +98,7 @@ &i2c1 { twl: pmic@48 { compatible = "ti,twl6032"; reg = <0x48>; + #clock-cells = <1>; /* IRQ# = 7 */ interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; /* IRQ_SYS_1N cascaded to gic */ interrupt-controller;
@@ -316,6 +323,7 @@ &mmc3 { pinctrl-names = "default"; pinctrl-0 = <&wl12xx_pins>; vmmc-supply = <&wl12xx_vmmc>; + mmc-pwrseq = <&wl12xx_pwrseq>; interrupts-extended = <&wakeupgen GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH &omap4_pmx_core 0x12e>; non-removable;
Signature · 1 line
2.39.2