* [PATCH v5 0/3] mfd: twl: Add clock for TWL6030
@ 2024-10-14 16:11 Andreas Kemnade
2024-10-14 16:11 ` [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Andreas Kemnade
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Andreas Kemnade @ 2024-10-14 16:11 UTC (permalink / raw)
To: Tony Lindgren, linux-omap, Aaro Koskinen, Lee Jones, Kevin Hilman,
linux-kernel, Roger Quadros, linux-clk, Michael Turquette,
Stephen Boyd
Cc: Andreas Kemnade
Previously the clock support for only implemented for TWL6032 so add
it also for the TWL6030. There are devices out there where especially
WLAN only works if these clocks are enabled by some patched U-Boot.
This allows to explicitly specify the clock requirements.
Changes in V5:
- fix unprepare 6032 vs 30 mismatch
Changes in V4:
- cleanup if (TWL6032_SUBCLASS)
Changes in V3:
- use type enum in driver_data and twl_clock_info
- revert back to store device instead of platform_device
Changes in V2:
- cleanup some defines
- no separate ops for 6030
- remove is_prepared()
- update Kconfig
Andreas Kemnade (3):
mfd: twl-core: Add a clock subdevice for the TWL6030
clk: twl: remove is_prepared
clk: twl: add TWL6030 support
drivers/clk/Kconfig | 2 +-
drivers/clk/clk-twl.c | 69 ++++++++++++++++++++++++++----------------
drivers/mfd/twl-core.c | 26 +++++++++++-----
3 files changed, 62 insertions(+), 35 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030
2024-10-14 16:11 [PATCH v5 0/3] mfd: twl: Add clock for TWL6030 Andreas Kemnade
@ 2024-10-14 16:11 ` Andreas Kemnade
2024-10-15 8:33 ` (subset) " Lee Jones
2024-10-14 16:11 ` [PATCH v5 2/3] clk: twl: remove is_prepared Andreas Kemnade
2024-10-14 16:11 ` [PATCH v5 3/3] clk: twl: add TWL6030 support Andreas Kemnade
2 siblings, 1 reply; 10+ messages in thread
From: Andreas Kemnade @ 2024-10-14 16:11 UTC (permalink / raw)
To: Tony Lindgren, linux-omap, Aaro Koskinen, Lee Jones, Kevin Hilman,
linux-kernel, Roger Quadros, linux-clk, Michael Turquette,
Stephen Boyd
Cc: Andreas Kemnade
Also the TWL6030 has some clocks, so add a subdevice for that.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
---
drivers/mfd/twl-core.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index c130ffef182f..f89eda4a17fe 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -711,6 +711,10 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = {
{ /* sentinel */ },
};
+static const struct mfd_cell twl6030_cells[] = {
+ { .name = "twl6030-clk" },
+};
+
static const struct mfd_cell twl6032_cells[] = {
{ .name = "twl6032-clk" },
};
@@ -861,17 +865,23 @@ 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 (twl_class_is_6030()) {
+ const struct mfd_cell *cells;
+ int num_cells;
+
+ if (id->driver_data & TWL6032_SUBCLASS) {
+ cells = twl6032_cells;
+ num_cells = ARRAY_SIZE(twl6032_cells);
+ } else {
+ cells = twl6030_cells;
+ num_cells = ARRAY_SIZE(twl6030_cells);
+ }
+
+ status = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
+ cells, num_cells, NULL, 0, NULL);
if (status < 0)
goto free;
- }
- if (twl_class_is_6030()) {
if (of_device_is_system_power_controller(node)) {
if (!pm_power_off)
pm_power_off = twl6030_power_off;
--
2.39.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 2/3] clk: twl: remove is_prepared
2024-10-14 16:11 [PATCH v5 0/3] mfd: twl: Add clock for TWL6030 Andreas Kemnade
2024-10-14 16:11 ` [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Andreas Kemnade
@ 2024-10-14 16:11 ` Andreas Kemnade
2024-10-17 19:05 ` Stephen Boyd
2024-10-14 16:11 ` [PATCH v5 3/3] clk: twl: add TWL6030 support Andreas Kemnade
2 siblings, 1 reply; 10+ messages in thread
From: Andreas Kemnade @ 2024-10-14 16:11 UTC (permalink / raw)
To: Tony Lindgren, linux-omap, Aaro Koskinen, Lee Jones, Kevin Hilman,
linux-kernel, Roger Quadros, linux-clk, Michael Turquette,
Stephen Boyd
Cc: Andreas Kemnade
Remove is_prepared to simplify adding of TWL6030 support.
The default implementation should be enough.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
---
drivers/clk/clk-twl.c | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/drivers/clk/clk-twl.c b/drivers/clk/clk-twl.c
index eab9d3c8ed8a..1d684b358401 100644
--- a/drivers/clk/clk-twl.c
+++ b/drivers/clk/clk-twl.c
@@ -77,26 +77,9 @@ static void twl6032_clks_unprepare(struct clk_hw *hw)
dev_err(cinfo->dev, "clk unprepare failed\n");
}
-static int twl6032_clks_is_prepared(struct clk_hw *hw)
-{
- struct twl_clock_info *cinfo = to_twl_clks_info(hw);
- int val;
-
- val = twlclk_read(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE);
- if (val < 0) {
- dev_err(cinfo->dev, "clk read failed\n");
- return val;
- }
-
- val &= TWL6030_CFG_STATE_MASK;
-
- return val == TWL6030_CFG_STATE_ON;
-}
-
static const struct clk_ops twl6032_clks_ops = {
.prepare = twl6032_clks_prepare,
.unprepare = twl6032_clks_unprepare,
- .is_prepared = twl6032_clks_is_prepared,
.recalc_rate = twl_clks_recalc_rate,
};
--
2.39.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 3/3] clk: twl: add TWL6030 support
2024-10-14 16:11 [PATCH v5 0/3] mfd: twl: Add clock for TWL6030 Andreas Kemnade
2024-10-14 16:11 ` [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Andreas Kemnade
2024-10-14 16:11 ` [PATCH v5 2/3] clk: twl: remove is_prepared Andreas Kemnade
@ 2024-10-14 16:11 ` Andreas Kemnade
2024-10-16 18:51 ` Roger Quadros
2024-10-17 19:05 ` Stephen Boyd
2 siblings, 2 replies; 10+ messages in thread
From: Andreas Kemnade @ 2024-10-14 16:11 UTC (permalink / raw)
To: Tony Lindgren, linux-omap, Aaro Koskinen, Lee Jones, Kevin Hilman,
linux-kernel, Roger Quadros, linux-clk, Michael Turquette,
Stephen Boyd
Cc: Andreas Kemnade
The TWL6030 has similar clocks, so add support for it. Take care of the
resource grouping handling needed.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
drivers/clk/Kconfig | 2 +-
drivers/clk/clk-twl.c | 52 +++++++++++++++++++++++++++++++++++--------
2 files changed, 44 insertions(+), 10 deletions(-)
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 299bc678ed1b..82ec12f9b82c 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -291,7 +291,7 @@ config CLK_TWL
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
+ controlled by software. For now, the TWL6032 and TWL6030 clocks are
supported.
config CLK_TWL6040
diff --git a/drivers/clk/clk-twl.c b/drivers/clk/clk-twl.c
index 1d684b358401..20bc3bf8fd62 100644
--- a/drivers/clk/clk-twl.c
+++ b/drivers/clk/clk-twl.c
@@ -11,13 +11,29 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
-#define VREG_STATE 2
+#define VREG_STATE 2
+#define VREG_GRP 0
#define TWL6030_CFG_STATE_OFF 0x00
#define TWL6030_CFG_STATE_ON 0x01
#define TWL6030_CFG_STATE_MASK 0x03
+#define TWL6030_CFG_STATE_GRP_SHIFT 5
+#define TWL6030_CFG_STATE_APP_SHIFT 2
+#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
+#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
+ TWL6030_CFG_STATE_APP_SHIFT)
+#define P1_GRP BIT(0) /* processor power group */
+#define P2_GRP BIT(1)
+#define P3_GRP BIT(2)
+#define ALL_GRP (P1_GRP | P2_GRP | P3_GRP)
+
+enum twl_type {
+ TWL_TYPE_6030,
+ TWL_TYPE_6032,
+};
struct twl_clock_info {
struct device *dev;
+ enum twl_type type;
u8 base;
struct clk_hw hw;
};
@@ -56,14 +72,21 @@ static unsigned long twl_clks_recalc_rate(struct clk_hw *hw,
static int twl6032_clks_prepare(struct clk_hw *hw)
{
struct twl_clock_info *cinfo = to_twl_clks_info(hw);
- int ret;
- ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
- TWL6030_CFG_STATE_ON);
- if (ret < 0)
- dev_err(cinfo->dev, "clk prepare failed\n");
+ if (cinfo->type == TWL_TYPE_6030) {
+ int grp;
+
+ grp = twlclk_read(cinfo, TWL_MODULE_PM_RECEIVER, VREG_GRP);
+ if (grp < 0)
+ return grp;
- return ret;
+ return twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
+ grp << TWL6030_CFG_STATE_GRP_SHIFT |
+ TWL6030_CFG_STATE_ON);
+ }
+
+ return twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
+ TWL6030_CFG_STATE_ON);
}
static void twl6032_clks_unprepare(struct clk_hw *hw)
@@ -71,8 +94,14 @@ static void twl6032_clks_unprepare(struct clk_hw *hw)
struct twl_clock_info *cinfo = to_twl_clks_info(hw);
int ret;
- ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
- TWL6030_CFG_STATE_OFF);
+ if (cinfo->type == TWL_TYPE_6030)
+ ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
+ ALL_GRP << TWL6030_CFG_STATE_GRP_SHIFT |
+ TWL6030_CFG_STATE_OFF);
+ else
+ ret = twlclk_write(cinfo, TWL_MODULE_PM_RECEIVER, VREG_STATE,
+ TWL6030_CFG_STATE_OFF);
+
if (ret < 0)
dev_err(cinfo->dev, "clk unprepare failed\n");
}
@@ -138,6 +167,7 @@ static int twl_clks_probe(struct platform_device *pdev)
for (i = 0; i < count; i++) {
cinfo[i].base = hw_data[i].base;
cinfo[i].dev = &pdev->dev;
+ cinfo[i].type = platform_get_device_id(pdev)->driver_data;
cinfo[i].hw.init = &hw_data[i].init;
ret = devm_clk_hw_register(&pdev->dev, &cinfo[i].hw);
if (ret) {
@@ -159,7 +189,11 @@ static int twl_clks_probe(struct platform_device *pdev)
static const struct platform_device_id twl_clks_id[] = {
{
+ .name = "twl6030-clk",
+ .driver_data = TWL_TYPE_6030,
+ }, {
.name = "twl6032-clk",
+ .driver_data = TWL_TYPE_6032,
}, {
/* sentinel */
}
--
2.39.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: (subset) [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030
2024-10-14 16:11 ` [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Andreas Kemnade
@ 2024-10-15 8:33 ` Lee Jones
2024-10-23 10:04 ` Andreas Kemnade
0 siblings, 1 reply; 10+ messages in thread
From: Lee Jones @ 2024-10-15 8:33 UTC (permalink / raw)
To: Tony Lindgren, linux-omap, Aaro Koskinen, Lee Jones, Kevin Hilman,
linux-kernel, Roger Quadros, linux-clk, Michael Turquette,
Stephen Boyd, Andreas Kemnade
On Mon, 14 Oct 2024 18:11:07 +0200, Andreas Kemnade wrote:
> Also the TWL6030 has some clocks, so add a subdevice for that.
>
>
Applied, thanks!
[1/3] mfd: twl-core: Add a clock subdevice for the TWL6030
commit: 5ebc60259a0fdd13aef077726b1773f1ae091efc
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 3/3] clk: twl: add TWL6030 support
2024-10-14 16:11 ` [PATCH v5 3/3] clk: twl: add TWL6030 support Andreas Kemnade
@ 2024-10-16 18:51 ` Roger Quadros
2024-10-17 19:05 ` Stephen Boyd
1 sibling, 0 replies; 10+ messages in thread
From: Roger Quadros @ 2024-10-16 18:51 UTC (permalink / raw)
To: Andreas Kemnade, Tony Lindgren, linux-omap, Aaro Koskinen,
Lee Jones, Kevin Hilman, linux-kernel, linux-clk,
Michael Turquette, Stephen Boyd
On 14/10/2024 19:11, Andreas Kemnade wrote:
> The TWL6030 has similar clocks, so add support for it. Take care of the
> resource grouping handling needed.
>
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 2/3] clk: twl: remove is_prepared
2024-10-14 16:11 ` [PATCH v5 2/3] clk: twl: remove is_prepared Andreas Kemnade
@ 2024-10-17 19:05 ` Stephen Boyd
0 siblings, 0 replies; 10+ messages in thread
From: Stephen Boyd @ 2024-10-17 19:05 UTC (permalink / raw)
To: Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Lee Jones,
Michael Turquette, Roger Quadros, Tony Lindgren, linux-clk,
linux-kernel, linux-omap
Cc: Andreas Kemnade
Quoting Andreas Kemnade (2024-10-14 09:11:08)
> Remove is_prepared to simplify adding of TWL6030 support.
> The default implementation should be enough.
>
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> Reviewed-by: Roger Quadros <rogerq@kernel.org>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 3/3] clk: twl: add TWL6030 support
2024-10-14 16:11 ` [PATCH v5 3/3] clk: twl: add TWL6030 support Andreas Kemnade
2024-10-16 18:51 ` Roger Quadros
@ 2024-10-17 19:05 ` Stephen Boyd
1 sibling, 0 replies; 10+ messages in thread
From: Stephen Boyd @ 2024-10-17 19:05 UTC (permalink / raw)
To: Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Lee Jones,
Michael Turquette, Roger Quadros, Tony Lindgren, linux-clk,
linux-kernel, linux-omap
Cc: Andreas Kemnade
Quoting Andreas Kemnade (2024-10-14 09:11:09)
> The TWL6030 has similar clocks, so add support for it. Take care of the
> resource grouping handling needed.
>
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (subset) [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030
2024-10-15 8:33 ` (subset) " Lee Jones
@ 2024-10-23 10:04 ` Andreas Kemnade
2024-10-25 8:50 ` Lee Jones
0 siblings, 1 reply; 10+ messages in thread
From: Andreas Kemnade @ 2024-10-23 10:04 UTC (permalink / raw)
To: Lee Jones
Cc: Tony Lindgren, linux-omap, Aaro Koskinen, Kevin Hilman,
linux-kernel, Roger Quadros, linux-clk, Michael Turquette,
Stephen Boyd
Am Tue, 15 Oct 2024 09:33:10 +0100
schrieb Lee Jones <lee@kernel.org>:
> On Mon, 14 Oct 2024 18:11:07 +0200, Andreas Kemnade wrote:
> > Also the TWL6030 has some clocks, so add a subdevice for that.
> >
> >
>
> Applied, thanks!
>
> [1/3] mfd: twl-core: Add a clock subdevice for the TWL6030
> commit: 5ebc60259a0fdd13aef077726b1773f1ae091efc
>
hmm, this does not appear in linux-next. Did anything went wrong?
Regards,
Andreas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (subset) [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030
2024-10-23 10:04 ` Andreas Kemnade
@ 2024-10-25 8:50 ` Lee Jones
0 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2024-10-25 8:50 UTC (permalink / raw)
To: Andreas Kemnade
Cc: Tony Lindgren, linux-omap, Aaro Koskinen, Kevin Hilman,
linux-kernel, Roger Quadros, linux-clk, Michael Turquette,
Stephen Boyd
On Wed, 23 Oct 2024, Andreas Kemnade wrote:
> Am Tue, 15 Oct 2024 09:33:10 +0100
> schrieb Lee Jones <lee@kernel.org>:
>
> > On Mon, 14 Oct 2024 18:11:07 +0200, Andreas Kemnade wrote:
> > > Also the TWL6030 has some clocks, so add a subdevice for that.
> > >
> > >
> >
> > Applied, thanks!
> >
> > [1/3] mfd: twl-core: Add a clock subdevice for the TWL6030
> > commit: 5ebc60259a0fdd13aef077726b1773f1ae091efc
> >
> hmm, this does not appear in linux-next. Did anything went wrong?
Looks like a clerical error on my part.
Thanks for noticing. Re-applied and pushed.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-10-25 8:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 16:11 [PATCH v5 0/3] mfd: twl: Add clock for TWL6030 Andreas Kemnade
2024-10-14 16:11 ` [PATCH v5 1/3] mfd: twl-core: Add a clock subdevice for the TWL6030 Andreas Kemnade
2024-10-15 8:33 ` (subset) " Lee Jones
2024-10-23 10:04 ` Andreas Kemnade
2024-10-25 8:50 ` Lee Jones
2024-10-14 16:11 ` [PATCH v5 2/3] clk: twl: remove is_prepared Andreas Kemnade
2024-10-17 19:05 ` Stephen Boyd
2024-10-14 16:11 ` [PATCH v5 3/3] clk: twl: add TWL6030 support Andreas Kemnade
2024-10-16 18:51 ` Roger Quadros
2024-10-17 19:05 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).