linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] Genpd related code changes to drop am335x pdata
@ 2020-10-26 11:10 Tony Lindgren
  2020-10-26 11:10 ` [PATCH 1/9] ARM: OMAP2+: Check for inited flag Tony Lindgren
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Bjorn Andersson, Michael Turquette,
	Philipp Zabel, Santosh Shilimkar, Stephen Boyd, linux-clk,
	linux-remoteproc

Hi all,

Here are the code related changes for v5.11 merge window to drop the
remaining am335x platform data. I'll be posting the related device tree
changes separately.

Regards,

Tony


Tero Kristo (1):
  soc: ti: omap-prm: am3: add genpd support for remaining PRM instances

Tony Lindgren (8):
  ARM: OMAP2+: Check for inited flag
  ARM: OMAP2+: Probe PRCM first to probe l4_wkup with simple-pm-bus
  clk: ti: am33xx: Keep am3 l3 main clock always on for genpd
  bus: ti-sysc: Support modules without control registers
  bus: ti-sysc: Implement GPMC debug quirk to drop platform data
  soc: ti: omap-prm: Add pm_clk for genpd
  soc: ti: pm33xx: Enable basic PM runtime support for genpd
  remoteproc/wkup_m3: Use reset control driver if available

 arch/arm/mach-omap2/omap_hwmod.c      |  6 +++
 arch/arm/mach-omap2/pdata-quirks.c    | 11 ++++
 drivers/bus/ti-sysc.c                 | 17 +++++++
 drivers/clk/ti/clk-33xx.c             |  2 +
 drivers/remoteproc/wkup_m3_rproc.c    | 28 +++++++---
 drivers/soc/ti/omap_prm.c             | 73 +++++++++++++++++++++++++--
 drivers/soc/ti/pm33xx.c               | 17 ++++++-
 include/linux/platform_data/ti-sysc.h |  1 +
 8 files changed, 143 insertions(+), 12 deletions(-)

-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/9] ARM: OMAP2+: Check for inited flag
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 2/9] ARM: OMAP2+: Probe PRCM first to probe l4_wkup with simple-pm-bus Tony Lindgren
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Bjorn Andersson, Michael Turquette,
	Philipp Zabel, Santosh Shilimkar, Stephen Boyd, linux-clk,
	linux-remoteproc

If we have no hwmods configured and omap_hwmod_init() is not called,
we don't want to call omap_hwmod_setup_all() as it will fail with
checks for configured MPU at least.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/omap_hwmod.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -627,6 +627,9 @@ static struct clockdomain *_get_clkdm(struct omap_hwmod *oh)
 {
 	struct clk_hw_omap *clk;
 
+	if (!oh)
+		return NULL;
+
 	if (oh->clkdm) {
 		return oh->clkdm;
 	} else if (oh->_clk) {
@@ -3677,6 +3680,9 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
  */
 static int __init omap_hwmod_setup_all(void)
 {
+	if (!inited)
+		return 0;
+
 	_ensure_mpu_hwmod_is_setup(NULL);
 
 	omap_hwmod_for_each(_init, NULL);
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 2/9] ARM: OMAP2+: Probe PRCM first to probe l4_wkup with simple-pm-bus
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
  2020-10-26 11:10 ` [PATCH 1/9] ARM: OMAP2+: Check for inited flag Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 3/9] clk: ti: am33xx: Keep am3 l3 main clock always on for genpd Tony Lindgren
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Bjorn Andersson, Michael Turquette,
	Philipp Zabel, Santosh Shilimkar, Stephen Boyd, linux-clk,
	linux-remoteproc

In preparation for probing the interconnects with simple-pm-bus to
make use of genpd, we need to probe the always-on PRCM first for the
clocks needed by l4_wkup instance.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/pdata-quirks.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -580,6 +580,8 @@ static void pdata_quirks_check(struct pdata_init *quirks)
 
 void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
 {
+	struct device_node *np;
+
 	/*
 	 * We still need this for omap2420 and omap3 PM to work, others are
 	 * using drivers/misc/sram.c already.
@@ -591,6 +593,15 @@ void __init pdata_quirks_init(const struct of_device_id *omap_dt_match_table)
 	if (of_machine_is_compatible("ti,omap3"))
 		omap3_mcbsp_init();
 	pdata_quirks_check(auxdata_quirks);
+
+	/* Populate always-on PRCM in l4_wkup to probe l4_wkup */
+	np = of_find_node_by_name(NULL, "prcm");
+	if (!np)
+		np = of_find_node_by_name(NULL, "prm");
+	if (np)
+		of_platform_populate(np, omap_dt_match_table,
+				     omap_auxdata_lookup, NULL);
+
 	of_platform_populate(NULL, omap_dt_match_table,
 			     omap_auxdata_lookup, NULL);
 	pdata_quirks_check(pdata_quirks);
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 3/9] clk: ti: am33xx: Keep am3 l3 main clock always on for genpd
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
  2020-10-26 11:10 ` [PATCH 1/9] ARM: OMAP2+: Check for inited flag Tony Lindgren
  2020-10-26 11:10 ` [PATCH 2/9] ARM: OMAP2+: Probe PRCM first to probe l4_wkup with simple-pm-bus Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 4/9] bus: ti-sysc: Support modules without control registers Tony Lindgren
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, linux-clk, Michael Turquette, Stephen Boyd,
	Bjorn Andersson, Philipp Zabel, Santosh Shilimkar,
	linux-remoteproc

In order for suspend and resume to work with genpd on am3, we must keep
l3 main clock always on. Otherwise prm_omap driver will shut down the l3
main clock on suspend when simple-pm-bus and GENPD_FLAG_PM_CLK are used.
Note that we already keep the l3 main clock always on with the legacy
platform code.

Later on we may want to start managing the l3 main clock with a dedicated
interconnect driver instead of using simple-pm-bus and GENPD_FLAG_PM_CLK.

Cc: linux-clk@vger.kernel.org
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/clk/ti/clk-33xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/ti/clk-33xx.c b/drivers/clk/ti/clk-33xx.c
--- a/drivers/clk/ti/clk-33xx.c
+++ b/drivers/clk/ti/clk-33xx.c
@@ -266,6 +266,8 @@ static const char *enable_init_clks[] = {
 	"dpll_ddr_m2_ck",
 	"dpll_mpu_m2_ck",
 	"l3_gclk",
+	/* AM3_L3_L3_MAIN_CLKCTRL, needed during suspend */
+	"l3-clkctrl:00bc:0",
 	"l4hs_gclk",
 	"l4fw_gclk",
 	"l4ls_gclk",
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 4/9] bus: ti-sysc: Support modules without control registers
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
                   ` (2 preceding siblings ...)
  2020-10-26 11:10 ` [PATCH 3/9] clk: ti: am33xx: Keep am3 l3 main clock always on for genpd Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 5/9] bus: ti-sysc: Implement GPMC debug quirk to drop platform data Tony Lindgren
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Bjorn Andersson, Michael Turquette,
	Philipp Zabel, Santosh Shilimkar, Stephen Boyd, linux-clk,
	linux-remoteproc

Some modules like MPU have a powerdomain and functional clock but not
necessarily any control registers. Let's allow configuring interconnect
target modules with no control registers.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/bus/ti-sysc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -850,8 +850,12 @@ static int sysc_ioremap(struct sysc *ddata)
  */
 static int sysc_map_and_check_registers(struct sysc *ddata)
 {
+	struct device_node *np = ddata->dev->of_node;
 	int error;
 
+	if (!of_get_property(np, "reg", NULL))
+		return 0;
+
 	error = sysc_parse_and_check_child_range(ddata);
 	if (error)
 		return error;
@@ -2906,6 +2910,9 @@ static int sysc_probe(struct platform_device *pdev)
 	if (!ddata)
 		return -ENOMEM;
 
+	ddata->offsets[SYSC_REVISION] = -ENODEV;
+	ddata->offsets[SYSC_SYSCONFIG] = -ENODEV;
+	ddata->offsets[SYSC_SYSSTATUS] = -ENODEV;
 	ddata->dev = &pdev->dev;
 	platform_set_drvdata(pdev, ddata);
 
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 5/9] bus: ti-sysc: Implement GPMC debug quirk to drop platform data
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
                   ` (3 preceding siblings ...)
  2020-10-26 11:10 ` [PATCH 4/9] bus: ti-sysc: Support modules without control registers Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 6/9] soc: ti: omap-prm: Add pm_clk for genpd Tony Lindgren
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Bjorn Andersson, Michael Turquette,
	Philipp Zabel, Santosh Shilimkar, Stephen Boyd, linux-clk,
	linux-remoteproc

We need to enable no-reset-on-init quirk for GPMC if the config
option for CONFIG_OMAP_GPMC_DEBUG is set. Otherwise the GPMC
driver code is unable to show the bootloader configured timings.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/bus/ti-sysc.c                 | 10 ++++++++++
 include/linux/platform_data/ti-sysc.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -1382,6 +1382,8 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
 		   SYSC_QUIRK_CLKDM_NOAUTO),
 	SYSC_QUIRK("dwc3", 0x488c0000, 0, 0x10, -ENODEV, 0x500a0200, 0xffffffff,
 		   SYSC_QUIRK_CLKDM_NOAUTO),
+	SYSC_QUIRK("gpmc", 0, 0, 0x10, 0x14, 0x00000060, 0xffffffff,
+		   SYSC_QUIRK_GPMC_DEBUG),
 	SYSC_QUIRK("hdmi", 0, 0, 0x10, -ENODEV, 0x50030200, 0xffffffff,
 		   SYSC_QUIRK_OPT_CLKS_NEEDED),
 	SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff,
@@ -1815,6 +1817,14 @@ static void sysc_init_module_quirks(struct sysc *ddata)
 		return;
 	}
 
+#ifdef CONFIG_OMAP_GPMC_DEBUG
+	if (ddata->cfg.quirks & SYSC_QUIRK_GPMC_DEBUG) {
+		ddata->cfg.quirks |= SYSC_QUIRK_NO_RESET_ON_INIT;
+
+		return;
+	}
+#endif
+
 	if (ddata->cfg.quirks & SYSC_MODULE_QUIRK_I2C) {
 		ddata->pre_reset_quirk = sysc_pre_reset_quirk_i2c;
 		ddata->post_reset_quirk = sysc_post_reset_quirk_i2c;
diff --git a/include/linux/platform_data/ti-sysc.h b/include/linux/platform_data/ti-sysc.h
--- a/include/linux/platform_data/ti-sysc.h
+++ b/include/linux/platform_data/ti-sysc.h
@@ -50,6 +50,7 @@ struct sysc_regbits {
 	s8 emufree_shift;
 };
 
+#define SYSC_QUIRK_GPMC_DEBUG		BIT(26)
 #define SYSC_MODULE_QUIRK_ENA_RESETDONE	BIT(25)
 #define SYSC_MODULE_QUIRK_PRUSS		BIT(24)
 #define SYSC_MODULE_QUIRK_DSS_RESET	BIT(23)
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 6/9] soc: ti: omap-prm: Add pm_clk for genpd
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
                   ` (4 preceding siblings ...)
  2020-10-26 11:10 ` [PATCH 5/9] bus: ti-sysc: Implement GPMC debug quirk to drop platform data Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 7/9] soc: ti: omap-prm: am3: add genpd support for remaining PRM instances Tony Lindgren
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Santosh Shilimkar, Bjorn Andersson,
	Michael Turquette, Philipp Zabel, Stephen Boyd, linux-clk,
	linux-remoteproc

In order to probe l3 and l4 interconnects with simple-pm-bus, we want
genpd to manage the clocks for the interconnects. For interconnect target
modules, we already have ti-sysc manage the clocks so let's skipe managing
clocks for ti-sysc modules.

Cc: Santosh Shilimkar <ssantosh@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/soc/ti/omap_prm.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/soc/ti/omap_prm.c b/drivers/soc/ti/omap_prm.c
--- a/drivers/soc/ti/omap_prm.c
+++ b/drivers/soc/ti/omap_prm.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
@@ -14,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/pm_clock.h>
 #include <linux/pm_domain.h>
 #include <linux/reset-controller.h>
 #include <linux/delay.h>
@@ -325,6 +327,35 @@ static int omap_prm_domain_power_off(struct generic_pm_domain *domain)
 	return 0;
 }
 
+/*
+ * Note that ti-sysc already manages the module clocks separately so
+ * no need to manage those. Interconnect instances need clocks managed
+ * for simple-pm-bus.
+ */
+static int omap_prm_domain_attach_clock(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+	int error;
+
+	if (of_device_is_compatible(np, "ti-sysc"))
+		return 0;
+
+	if (!of_property_read_bool(np, "clocks"))
+		return 0;
+
+	error = pm_clk_create(dev);
+	if (error)
+		return error;
+
+	error = of_pm_clk_add_clks(dev);
+	if (error < 0) {
+		pm_clk_destroy(dev);
+		return error;
+	}
+
+	return 0;
+}
+
 static int omap_prm_domain_attach_dev(struct generic_pm_domain *domain,
 				      struct device *dev)
 {
@@ -349,6 +380,10 @@ static int omap_prm_domain_attach_dev(struct generic_pm_domain *domain,
 	genpd_data = dev_gpd_data(dev);
 	genpd_data->data = NULL;
 
+	ret = omap_prm_domain_attach_clock(dev);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
@@ -357,6 +392,7 @@ static void omap_prm_domain_detach_dev(struct generic_pm_domain *domain,
 {
 	struct generic_pm_domain_data *genpd_data;
 
+	pm_clk_destroy(dev);
 	genpd_data = dev_gpd_data(dev);
 	genpd_data->data = NULL;
 }
@@ -393,6 +429,7 @@ static int omap_prm_domain_init(struct device *dev, struct omap_prm *prm)
 	prmd->pd.power_off = omap_prm_domain_power_off;
 	prmd->pd.attach_dev = omap_prm_domain_attach_dev;
 	prmd->pd.detach_dev = omap_prm_domain_detach_dev;
+	prmd->pd.flags = GENPD_FLAG_PM_CLK;
 
 	pm_genpd_init(&prmd->pd, NULL, true);
 	error = of_genpd_add_provider_simple(np, &prmd->pd);
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 7/9] soc: ti: omap-prm: am3: add genpd support for remaining PRM instances
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
                   ` (5 preceding siblings ...)
  2020-10-26 11:10 ` [PATCH 6/9] soc: ti: omap-prm: Add pm_clk for genpd Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 8/9] soc: ti: pm33xx: Enable basic PM runtime support for genpd Tony Lindgren
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Santosh Shilimkar, Bjorn Andersson,
	Michael Turquette, Philipp Zabel, Stephen Boyd, linux-clk,
	linux-remoteproc

From: Tero Kristo <t-kristo@ti.com>

Add genpd support for per, wkup, mpu, rtc and cefuse instances.

Cc: Santosh Shilimkar <ssantosh@kernel.org>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/soc/ti/omap_prm.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/ti/omap_prm.c b/drivers/soc/ti/omap_prm.c
--- a/drivers/soc/ti/omap_prm.c
+++ b/drivers/soc/ti/omap_prm.c
@@ -123,6 +123,10 @@ static const struct omap_prm_domain_map omap_prm_onoff_noauto = {
 	.statechange = 1,
 };
 
+static const struct omap_prm_domain_map omap_prm_alwon = {
+	.usable_modes = BIT(OMAP_PRMD_ON_ACTIVE),
+};
+
 static const struct omap_rst_map rst_map_0[] = {
 	{ .rst = 0, .st = 0 },
 	{ .rst = -1 },
@@ -189,14 +193,40 @@ static const struct omap_rst_map am3_wkup_rst_map[] = {
 };
 
 static const struct omap_prm_data am3_prm_data[] = {
-	{ .name = "per", .base = 0x44e00c00, .rstctrl = 0x0, .rstmap = am3_per_rst_map, .flags = OMAP_PRM_HAS_RSTCTRL, .clkdm_name = "pruss_ocp" },
-	{ .name = "wkup", .base = 0x44e00d00, .rstctrl = 0x0, .rstst = 0xc, .rstmap = am3_wkup_rst_map, .flags = OMAP_PRM_HAS_RSTCTRL | OMAP_PRM_HAS_NO_CLKDM },
-	{ .name = "device", .base = 0x44e00f00, .rstctrl = 0x0, .rstst = 0x8, .rstmap = rst_map_01, .flags = OMAP_PRM_HAS_RSTCTRL | OMAP_PRM_HAS_NO_CLKDM },
+	{
+		.name = "per", .base = 0x44e00c00,
+		.pwrstctrl = 0xc, .pwrstst = 0x8, .dmap = &omap_prm_noinact,
+		.rstctrl = 0x0, .rstmap = am3_per_rst_map,
+		.flags = OMAP_PRM_HAS_RSTCTRL, .clkdm_name = "pruss_ocp"
+	},
+	{
+		.name = "wkup", .base = 0x44e00d00,
+		.pwrstctrl = 0x4, .pwrstst = 0x4, .dmap = &omap_prm_alwon,
+		.rstctrl = 0x0, .rstst = 0xc, .rstmap = am3_wkup_rst_map,
+		.flags = OMAP_PRM_HAS_RSTCTRL | OMAP_PRM_HAS_NO_CLKDM
+	},
+	{
+		.name = "mpu", .base = 0x44e00e00,
+		.pwrstctrl = 0x0, .pwrstst = 0x4, .dmap = &omap_prm_noinact,
+	},
+	{
+		.name = "device", .base = 0x44e00f00,
+		.rstctrl = 0x0, .rstst = 0x8, .rstmap = rst_map_01,
+		.flags = OMAP_PRM_HAS_RSTCTRL | OMAP_PRM_HAS_NO_CLKDM
+	},
+	{
+		.name = "rtc", .base = 0x44e01000,
+		.pwrstctrl = 0x0, .pwrstst = 0x4, .dmap = &omap_prm_alwon,
+	},
 	{
 		.name = "gfx", .base = 0x44e01100,
 		.pwrstctrl = 0, .pwrstst = 0x10, .dmap = &omap_prm_noinact,
 		.rstctrl = 0x4, .rstst = 0x14, .rstmap = rst_map_0, .clkdm_name = "gfx_l3",
 	},
+	{
+		.name = "cefuse", .base = 0x44e01200,
+		.pwrstctrl = 0x0, .pwrstst = 0x4, .dmap = &omap_prm_onoff_noauto,
+	},
 	{ },
 };
 
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 8/9] soc: ti: pm33xx: Enable basic PM runtime support for genpd
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
                   ` (6 preceding siblings ...)
  2020-10-26 11:10 ` [PATCH 7/9] soc: ti: omap-prm: am3: add genpd support for remaining PRM instances Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:10 ` [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available Tony Lindgren
  2020-10-26 13:13 ` [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Santosh Shilimkar, Bjorn Andersson,
	Michael Turquette, Philipp Zabel, Stephen Boyd, linux-clk,
	linux-remoteproc

To prepare for moving to use genpd, let's enable basic PM
runtime support.

Cc: Dave Gerlach <d-gerlach@ti.com>
Cc: Santosh Shilimkar <ssantosh@kernel.org>
Cc: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/soc/ti/pm33xx.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/ti/pm33xx.c b/drivers/soc/ti/pm33xx.c
--- a/drivers/soc/ti/pm33xx.c
+++ b/drivers/soc/ti/pm33xx.c
@@ -19,6 +19,7 @@
 #include <linux/of_address.h>
 #include <linux/platform_data/pm33xx.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/rtc.h>
 #include <linux/rtc/rtc-omap.h>
 #include <linux/sizes.h>
@@ -555,16 +556,26 @@ static int am33xx_pm_probe(struct platform_device *pdev)
 	suspend_wfi_flags |= WFI_FLAG_WAKE_M3;
 #endif /* CONFIG_SUSPEND */
 
+	pm_runtime_enable(dev);
+	ret = pm_runtime_get_sync(dev);
+	if (ret < 0) {
+		pm_runtime_put_noidle(dev);
+		goto err_pm_runtime_disable;
+	}
+
 	ret = pm_ops->init(am33xx_do_sram_idle);
 	if (ret) {
 		dev_err(dev, "Unable to call core pm init!\n");
 		ret = -ENODEV;
-		goto err_put_wkup_m3_ipc;
+		goto err_pm_runtime_put;
 	}
 
 	return 0;
 
-err_put_wkup_m3_ipc:
+err_pm_runtime_put:
+	pm_runtime_put_sync(dev);
+err_pm_runtime_disable:
+	pm_runtime_disable(dev);
 	wkup_m3_ipc_put(m3_ipc);
 err_free_sram:
 	am33xx_pm_free_sram();
@@ -574,6 +585,8 @@ static int am33xx_pm_probe(struct platform_device *pdev)
 
 static int am33xx_pm_remove(struct platform_device *pdev)
 {
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	if (pm_ops->deinit)
 		pm_ops->deinit();
 	suspend_set_ops(NULL);
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
                   ` (7 preceding siblings ...)
  2020-10-26 11:10 ` [PATCH 8/9] soc: ti: pm33xx: Enable basic PM runtime support for genpd Tony Lindgren
@ 2020-10-26 11:10 ` Tony Lindgren
  2020-10-26 11:35   ` Philipp Zabel
  2020-10-26 13:13 ` [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
  9 siblings, 1 reply; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 11:10 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, linux-remoteproc, Bjorn Andersson,
	Philipp Zabel, Michael Turquette, Santosh Shilimkar,
	Stephen Boyd, linux-clk

In order to move wkup_m3 to probe without platform data, let's add
support for using optional reset control driver if configured in the
dts. With this change and the related dts change, we can start
dropping the platform data for am335x.

And once wkup_m3 no longer needs platform data, we can simply drop the
related legacy reset platform data callbacks from wkup_m3 driver later
on after also am437x no longer depends on it.

Cc: linux-remoteproc@vger.kernel.org
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Dave Gerlach <d-gerlach@ti.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---

Please review and ack if no issues. If you guys instead want to set up an
immutable remoteproc branch with just this patch in it against v5.10-rc1
that works too :)

---
 drivers/remoteproc/wkup_m3_rproc.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
--- a/drivers/remoteproc/wkup_m3_rproc.c
+++ b/drivers/remoteproc/wkup_m3_rproc.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/remoteproc.h>
+#include <linux/reset.h>
 
 #include <linux/platform_data/wkup_m3.h>
 
@@ -43,11 +44,13 @@ struct wkup_m3_mem {
  * @rproc: rproc handle
  * @pdev: pointer to platform device
  * @mem: WkupM3 memory information
+ * @rsts: reset control
  */
 struct wkup_m3_rproc {
 	struct rproc *rproc;
 	struct platform_device *pdev;
 	struct wkup_m3_mem mem[WKUPM3_MEM_MAX];
+	struct reset_control *rsts;
 };
 
 static int wkup_m3_rproc_start(struct rproc *rproc)
@@ -57,6 +60,9 @@ static int wkup_m3_rproc_start(struct rproc *rproc)
 	struct device *dev = &pdev->dev;
 	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
 
+	if (wkupm3->rsts)
+		return reset_control_deassert(wkupm3->rsts);
+
 	if (pdata->deassert_reset(pdev, pdata->reset_name)) {
 		dev_err(dev, "Unable to reset wkup_m3!\n");
 		return -ENODEV;
@@ -72,6 +78,9 @@ static int wkup_m3_rproc_stop(struct rproc *rproc)
 	struct device *dev = &pdev->dev;
 	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
 
+	if (wkupm3->rsts)
+		return reset_control_assert(wkupm3->rsts);
+
 	if (pdata->assert_reset(pdev, pdata->reset_name)) {
 		dev_err(dev, "Unable to assert reset of wkup_m3!\n");
 		return -ENODEV;
@@ -132,12 +141,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
-	if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
-	      pdata->reset_name)) {
-		dev_err(dev, "Platform data missing!\n");
-		return -ENODEV;
-	}
-
 	ret = of_property_read_string(dev->of_node, "ti,pm-firmware",
 				      &fw_name);
 	if (ret) {
@@ -165,6 +168,17 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
 	wkupm3->rproc = rproc;
 	wkupm3->pdev = pdev;
 
+	wkupm3->rsts = devm_reset_control_get_optional_shared(dev, "rstctrl");
+	if (PTR_ERR_OR_ZERO(wkupm3->rsts)) {
+		if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
+		      pdata->reset_name)) {
+			dev_err(dev, "Platform data missing!\n");
+			ret = -ENODEV;
+			goto err_put_rproc;
+		}
+		wkupm3->rsts = NULL;
+	}
+
 	for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
 		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 						   mem_names[i]);
@@ -173,7 +187,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "devm_ioremap_resource failed for resource %d\n",
 				i);
 			ret = PTR_ERR(wkupm3->mem[i].cpu_addr);
-			goto err;
+			goto err_put_rproc;
 		}
 		wkupm3->mem[i].bus_addr = res->start;
 		wkupm3->mem[i].size = resource_size(res);
-- 
2.29.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available
  2020-10-26 11:10 ` [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available Tony Lindgren
@ 2020-10-26 11:35   ` Philipp Zabel
  2020-10-26 13:02     ` Tony Lindgren
  0 siblings, 1 reply; 14+ messages in thread
From: Philipp Zabel @ 2020-10-26 11:35 UTC (permalink / raw)
  To: Tony Lindgren, linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, linux-remoteproc, Bjorn Andersson,
	Michael Turquette, Santosh Shilimkar, Stephen Boyd, linux-clk

Hi Tony,

On Mon, 2020-10-26 at 13:10 +0200, Tony Lindgren wrote:
> In order to move wkup_m3 to probe without platform data, let's add
> support for using optional reset control driver if configured in the
> dts. With this change and the related dts change, we can start
> dropping the platform data for am335x.
> 
> And once wkup_m3 no longer needs platform data, we can simply drop the
> related legacy reset platform data callbacks from wkup_m3 driver later
> on after also am437x no longer depends on it.
> 
> Cc: linux-remoteproc@vger.kernel.org
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Dave Gerlach <d-gerlach@ti.com>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Suman Anna <s-anna@ti.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> 
> Please review and ack if no issues. If you guys instead want to set up an
> immutable remoteproc branch with just this patch in it against v5.10-rc1
> that works too :)
> 
> ---
>  drivers/remoteproc/wkup_m3_rproc.c | 28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
> --- a/drivers/remoteproc/wkup_m3_rproc.c
> +++ b/drivers/remoteproc/wkup_m3_rproc.c
> @@ -17,6 +17,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/remoteproc.h>
> +#include <linux/reset.h>
>  
>  #include <linux/platform_data/wkup_m3.h>
>  
> @@ -43,11 +44,13 @@ struct wkup_m3_mem {
>   * @rproc: rproc handle
>   * @pdev: pointer to platform device
>   * @mem: WkupM3 memory information
> + * @rsts: reset control
>   */
>  struct wkup_m3_rproc {
>  	struct rproc *rproc;
>  	struct platform_device *pdev;
>  	struct wkup_m3_mem mem[WKUPM3_MEM_MAX];
> +	struct reset_control *rsts;
>  };
>  
>  static int wkup_m3_rproc_start(struct rproc *rproc)
> @@ -57,6 +60,9 @@ static int wkup_m3_rproc_start(struct rproc *rproc)
>  	struct device *dev = &pdev->dev;
>  	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
>  
> +	if (wkupm3->rsts)

No need for this check, reset_control_deassert() just returns 0 if the
rstc parameter is NULL.

> +		return reset_control_deassert(wkupm3->rsts);
> +
>  	if (pdata->deassert_reset(pdev, pdata->reset_name)) {
>  		dev_err(dev, "Unable to reset wkup_m3!\n");
>  		return -ENODEV;
> @@ -72,6 +78,9 @@ static int wkup_m3_rproc_stop(struct rproc *rproc)
>  	struct device *dev = &pdev->dev;
>  	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
>  
> +	if (wkupm3->rsts)

Same as above.

> +		return reset_control_assert(wkupm3->rsts);
> +
>  	if (pdata->assert_reset(pdev, pdata->reset_name)) {
>  		dev_err(dev, "Unable to assert reset of wkup_m3!\n");
>  		return -ENODEV;
> @@ -132,12 +141,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
>  	int ret;
>  	int i;
>  
> -	if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
> -	      pdata->reset_name)) {
> -		dev_err(dev, "Platform data missing!\n");
> -		return -ENODEV;
> -	}
> -
>  	ret = of_property_read_string(dev->of_node, "ti,pm-firmware",
>  				      &fw_name);
>  	if (ret) {
> @@ -165,6 +168,17 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
>  	wkupm3->rproc = rproc;
>  	wkupm3->pdev = pdev;
>  
> +	wkupm3->rsts = devm_reset_control_get_optional_shared(dev, "rstctrl");
> +	if (PTR_ERR_OR_ZERO(wkupm3->rsts)) {

Please properly return errors. rsts will be NULL if the optional rstctrl
reset is not specified:

	if (IS_ERR(wkump3->rsts))
		return PTR_ERR(wkump3->rsts);

	if (!wkump3->rsts) {
> +		if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
> +		      pdata->reset_name)) {
> +			dev_err(dev, "Platform data missing!\n");
> +			ret = -ENODEV;
> +			goto err_put_rproc;
> +		}
> +		wkupm3->rsts = NULL;

I assume this will later be dropped with the platform data support?

> +	}
> +
>  	for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
>  		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
>  						   mem_names[i]);
> @@ -173,7 +187,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev, "devm_ioremap_resource failed for resource %d\n",
>  				i);
>  			ret = PTR_ERR(wkupm3->mem[i].cpu_addr);
> -			goto err;
> +			goto err_put_rproc;
>  		}
>  		wkupm3->mem[i].bus_addr = res->start;
>  		wkupm3->mem[i].size = resource_size(res);

regards
Philipp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available
  2020-10-26 11:35   ` Philipp Zabel
@ 2020-10-26 13:02     ` Tony Lindgren
  0 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 13:02 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-omap, Andrew F . Davis, Dave Gerlach, Faiz Abbas,
	Greg Kroah-Hartman, Grygorii Strashko, Keerthy, Nishanth Menon,
	Peter Ujfalusi, Roger Quadros, Suman Anna, Tero Kristo,
	linux-kernel, linux-arm-kernel, linux-remoteproc,
	Bjorn Andersson, Michael Turquette, Santosh Shilimkar,
	Stephen Boyd, linux-clk

Hi,

* Philipp Zabel <p.zabel@pengutronix.de> [201026 11:35]:
> On Mon, 2020-10-26 at 13:10 +0200, Tony Lindgren wrote:
> > @@ -57,6 +60,9 @@ static int wkup_m3_rproc_start(struct rproc *rproc)
> >  	struct device *dev = &pdev->dev;
> >  	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
> >  
> > +	if (wkupm3->rsts)
> 
> No need for this check, reset_control_deassert() just returns 0 if the
> rstc parameter is NULL.
> 
> > +		return reset_control_deassert(wkupm3->rsts);
> > +
> >  	if (pdata->deassert_reset(pdev, pdata->reset_name)) {
> >  		dev_err(dev, "Unable to reset wkup_m3!\n");
> >  		return -ENODEV;
> > @@ -72,6 +78,9 @@ static int wkup_m3_rproc_stop(struct rproc *rproc)
> >  	struct device *dev = &pdev->dev;
> >  	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
> >  
> > +	if (wkupm3->rsts)
> 
> Same as above.

OK great.

> > +		return reset_control_assert(wkupm3->rsts);
> > +
> >  	if (pdata->assert_reset(pdev, pdata->reset_name)) {
> >  		dev_err(dev, "Unable to assert reset of wkup_m3!\n");
> >  		return -ENODEV;
> > @@ -132,12 +141,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
> >  	int ret;
> >  	int i;
> >  
> > -	if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
> > -	      pdata->reset_name)) {
> > -		dev_err(dev, "Platform data missing!\n");
> > -		return -ENODEV;
> > -	}
> > -
> >  	ret = of_property_read_string(dev->of_node, "ti,pm-firmware",
> >  				      &fw_name);
> >  	if (ret) {
> > @@ -165,6 +168,17 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
> >  	wkupm3->rproc = rproc;
> >  	wkupm3->pdev = pdev;
> >  
> > +	wkupm3->rsts = devm_reset_control_get_optional_shared(dev, "rstctrl");
> > +	if (PTR_ERR_OR_ZERO(wkupm3->rsts)) {
> 
> Please properly return errors. rsts will be NULL if the optional rstctrl
> reset is not specified:
> 
> 	if (IS_ERR(wkump3->rsts))
> 		return PTR_ERR(wkump3->rsts);

OK thanks will do.

> 	if (!wkump3->rsts) {
> > +		if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
> > +		      pdata->reset_name)) {
> > +			dev_err(dev, "Platform data missing!\n");
> > +			ret = -ENODEV;
> > +			goto err_put_rproc;
> > +		}
> > +		wkupm3->rsts = NULL;
> 
> I assume this will later be dropped with the platform data support?

Yes once also am437x has been updated to probe with dts data only we
can drop the custom callbacks.

Regards,

Tony

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/9] Genpd related code changes to drop am335x pdata
  2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
                   ` (8 preceding siblings ...)
  2020-10-26 11:10 ` [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available Tony Lindgren
@ 2020-10-26 13:13 ` Tony Lindgren
  9 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-10-26 13:13 UTC (permalink / raw)
  To: linux-omap
  Cc: Andrew F . Davis, Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman,
	Grygorii Strashko, Keerthy, Nishanth Menon, Peter Ujfalusi,
	Roger Quadros, Suman Anna, Tero Kristo, linux-kernel,
	linux-arm-kernel, Bjorn Andersson, Michael Turquette,
	Philipp Zabel, Santosh Shilimkar, Stephen Boyd, linux-clk,
	linux-remoteproc

* Tony Lindgren <tony@atomide.com> [201026 11:11]:
> Hi all,
> 
> Here are the code related changes for v5.11 merge window to drop the
> remaining am335x platform data. I'll be posting the related device tree
> changes separately.

Sorry I forgot to mention that this series depends also on a series of
fixes posted earlier at [1].

Also, the related dts changes are now posted at [2], and I've also
pushed out an initial branch for easier testing at [3].

Regards,

Tony

[1] https://lore.kernel.org/linux-omap/20201026105812.38418-1-tony@atomide.com/T/#t
[2] https://lore.kernel.org/linux-omap/20201026131007.GB5639@atomide.com/T/#t
[3] https://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git/log/?h=omap-for-v5.11/genpd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available
  2020-11-10 11:20 [PATCHv2 " Tony Lindgren
@ 2020-11-10 11:20 ` Tony Lindgren
  0 siblings, 0 replies; 14+ messages in thread
From: Tony Lindgren @ 2020-11-10 11:20 UTC (permalink / raw)
  To: linux-omap
  Cc: Dave Gerlach, Faiz Abbas, Greg Kroah-Hartman, Grygorii Strashko,
	Keerthy, Nishanth Menon, Peter Ujfalusi, Roger Quadros,
	Suman Anna, Tero Kristo, linux-kernel, linux-arm-kernel,
	linux-remoteproc, Bjorn Andersson, Philipp Zabel,
	Michael Turquette, Santosh Shilimkar, Stephen Boyd, linux-clk

In order to move wkup_m3 to probe without platform data, let's add
support for using optional reset control driver if configured in the
dts. With this change and the related dts change, we can start
dropping the platform data for am335x.

And once wkup_m3 no longer needs platform data, we can simply drop the
related legacy reset platform data callbacks from wkup_m3 driver later
on after also am437x no longer depends on it.

Cc: linux-remoteproc@vger.kernel.org
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Dave Gerlach <d-gerlach@ti.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---

Please review and ack if no issues. If you guys instead want to set up an
immutable remoteproc branch with just this patch in it against v5.10-rc1
that works too :)

---
 drivers/remoteproc/wkup_m3_rproc.c | 41 ++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/remoteproc/wkup_m3_rproc.c b/drivers/remoteproc/wkup_m3_rproc.c
--- a/drivers/remoteproc/wkup_m3_rproc.c
+++ b/drivers/remoteproc/wkup_m3_rproc.c
@@ -17,6 +17,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/remoteproc.h>
+#include <linux/reset.h>
 
 #include <linux/platform_data/wkup_m3.h>
 
@@ -43,11 +44,13 @@ struct wkup_m3_mem {
  * @rproc: rproc handle
  * @pdev: pointer to platform device
  * @mem: WkupM3 memory information
+ * @rsts: reset control
  */
 struct wkup_m3_rproc {
 	struct rproc *rproc;
 	struct platform_device *pdev;
 	struct wkup_m3_mem mem[WKUPM3_MEM_MAX];
+	struct reset_control *rsts;
 };
 
 static int wkup_m3_rproc_start(struct rproc *rproc)
@@ -56,13 +59,16 @@ static int wkup_m3_rproc_start(struct rproc *rproc)
 	struct platform_device *pdev = wkupm3->pdev;
 	struct device *dev = &pdev->dev;
 	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
+	int error = 0;
 
-	if (pdata->deassert_reset(pdev, pdata->reset_name)) {
+	error = reset_control_deassert(wkupm3->rsts);
+
+	if (!wkupm3->rsts && pdata->deassert_reset(pdev, pdata->reset_name)) {
 		dev_err(dev, "Unable to reset wkup_m3!\n");
-		return -ENODEV;
+		error = -ENODEV;
 	}
 
-	return 0;
+	return error;
 }
 
 static int wkup_m3_rproc_stop(struct rproc *rproc)
@@ -71,13 +77,16 @@ static int wkup_m3_rproc_stop(struct rproc *rproc)
 	struct platform_device *pdev = wkupm3->pdev;
 	struct device *dev = &pdev->dev;
 	struct wkup_m3_platform_data *pdata = dev_get_platdata(dev);
+	int error = 0;
 
-	if (pdata->assert_reset(pdev, pdata->reset_name)) {
+	error = reset_control_assert(wkupm3->rsts);
+
+	if (!wkupm3->rsts && pdata->assert_reset(pdev, pdata->reset_name)) {
 		dev_err(dev, "Unable to assert reset of wkup_m3!\n");
-		return -ENODEV;
+		error = -ENODEV;
 	}
 
-	return 0;
+	return error;
 }
 
 static void *wkup_m3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
@@ -132,12 +141,6 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
 	int ret;
 	int i;
 
-	if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
-	      pdata->reset_name)) {
-		dev_err(dev, "Platform data missing!\n");
-		return -ENODEV;
-	}
-
 	ret = of_property_read_string(dev->of_node, "ti,pm-firmware",
 				      &fw_name);
 	if (ret) {
@@ -165,6 +168,18 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
 	wkupm3->rproc = rproc;
 	wkupm3->pdev = pdev;
 
+	wkupm3->rsts = devm_reset_control_get_optional_shared(dev, "rstctrl");
+	if (IS_ERR(wkupm3->rsts))
+		return PTR_ERR(wkupm3->rsts);
+	if (!wkupm3->rsts) {
+		if (!(pdata && pdata->deassert_reset && pdata->assert_reset &&
+		      pdata->reset_name)) {
+			dev_err(dev, "Platform data missing!\n");
+			ret = -ENODEV;
+			goto err_put_rproc;
+		}
+	}
+
 	for (i = 0; i < ARRAY_SIZE(mem_names); i++) {
 		res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 						   mem_names[i]);
@@ -173,7 +188,7 @@ static int wkup_m3_rproc_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "devm_ioremap_resource failed for resource %d\n",
 				i);
 			ret = PTR_ERR(wkupm3->mem[i].cpu_addr);
-			goto err;
+			goto err_put_rproc;
 		}
 		wkupm3->mem[i].bus_addr = res->start;
 		wkupm3->mem[i].size = resource_size(res);
-- 
2.29.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-11-10 11:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 11:10 [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
2020-10-26 11:10 ` [PATCH 1/9] ARM: OMAP2+: Check for inited flag Tony Lindgren
2020-10-26 11:10 ` [PATCH 2/9] ARM: OMAP2+: Probe PRCM first to probe l4_wkup with simple-pm-bus Tony Lindgren
2020-10-26 11:10 ` [PATCH 3/9] clk: ti: am33xx: Keep am3 l3 main clock always on for genpd Tony Lindgren
2020-10-26 11:10 ` [PATCH 4/9] bus: ti-sysc: Support modules without control registers Tony Lindgren
2020-10-26 11:10 ` [PATCH 5/9] bus: ti-sysc: Implement GPMC debug quirk to drop platform data Tony Lindgren
2020-10-26 11:10 ` [PATCH 6/9] soc: ti: omap-prm: Add pm_clk for genpd Tony Lindgren
2020-10-26 11:10 ` [PATCH 7/9] soc: ti: omap-prm: am3: add genpd support for remaining PRM instances Tony Lindgren
2020-10-26 11:10 ` [PATCH 8/9] soc: ti: pm33xx: Enable basic PM runtime support for genpd Tony Lindgren
2020-10-26 11:10 ` [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available Tony Lindgren
2020-10-26 11:35   ` Philipp Zabel
2020-10-26 13:02     ` Tony Lindgren
2020-10-26 13:13 ` [PATCH 0/9] Genpd related code changes to drop am335x pdata Tony Lindgren
2020-11-10 11:20 [PATCHv2 " Tony Lindgren
2020-11-10 11:20 ` [PATCH 9/9] remoteproc/wkup_m3: Use reset control driver if available Tony Lindgren

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).