Re: [PATCH 2/2] soc: ti: pruss: add support for AM18XX/OMAP-L138 PRUSS

2021-01-16 Thread David Lechner

On 1/15/21 6:52 PM, Suman Anna wrote:

Hi David,

On 1/4/21 12:30 PM, David Lechner wrote:

This adds support for the PRUSS found in AM18XX/OMAP-L138. This PRUSS
doesn't have a CFG register, so that is made optional as selected by
the device tree compatible string.

ARCH_DAVINCI is added in the Kconfig so that the driver can be selected
on that platform.

Signed-off-by: David Lechner 
---
  drivers/soc/ti/Kconfig |  2 +-
  drivers/soc/ti/pruss.c | 76 --
  2 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
index 7e2fb1c16af1..7a692a21480a 100644
--- a/drivers/soc/ti/Kconfig
+++ b/drivers/soc/ti/Kconfig
@@ -85,7 +85,7 @@ config TI_K3_SOCINFO
  
  config TI_PRUSS

tristate "TI PRU-ICSS Subsystem Platform drivers"
-   depends on SOC_AM33XX || SOC_AM43XX || SOC_DRA7XX || ARCH_KEYSTONE || 
ARCH_K3
+   depends on ARCH_DAVINCI || SOC_AM33XX || SOC_AM43XX || SOC_DRA7XX || 
ARCH_KEYSTONE || ARCH_K3
select MFD_SYSCON
help
  TI PRU-ICSS Subsystem platform specific support.
diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
index 5d6e7132a5c4..bfaf3ff74b01 100644
--- a/drivers/soc/ti/pruss.c
+++ b/drivers/soc/ti/pruss.c
@@ -24,10 +24,12 @@
   * struct pruss_private_data - PRUSS driver private data
   * @has_no_sharedram: flag to indicate the absence of PRUSS Shared Data RAM
   * @has_core_mux_clock: flag to indicate the presence of PRUSS core clock
+ * @has_cfg: flag to indicate the presence of PRUSS CFG registers


I recommend to change this to a negative flag as the Davinci platforms are the
only ones that don't have CFG (being the very first SoCs with a PRUSS IP)
sub-module.


Negative flags hurt my brain. :-)

I was actually thinking about submitting a patch to convert
has_no_sharedram to a positive flag as well. But I understand
the sentiment of only setting the flag true for the odd case
rather than the usual case.




   */
  struct pruss_private_data {
bool has_no_sharedram;
bool has_core_mux_clock;
+   bool has_cfg;
  };
  
  static void pruss_of_free_clk_provider(void *data)

@@ -239,42 +241,44 @@ static int pruss_probe(struct platform_device *pdev)
goto rpm_disable;
}
  


And use it here to skip all the cfg code parsing. All the below delta is just
for the additional indentation for the flag. If you don't like goto's in
non-error paths, then we can refactor the CFG parse code into a separate 
function.



Refactoring to a separate function sounds good to me.


Re: [PATCH 2/2] soc: ti: pruss: add support for AM18XX/OMAP-L138 PRUSS

2021-01-15 Thread Suman Anna
Hi David,

On 1/4/21 12:30 PM, David Lechner wrote:
> This adds support for the PRUSS found in AM18XX/OMAP-L138. This PRUSS
> doesn't have a CFG register, so that is made optional as selected by
> the device tree compatible string.
> 
> ARCH_DAVINCI is added in the Kconfig so that the driver can be selected
> on that platform.
> 
> Signed-off-by: David Lechner 
> ---
>  drivers/soc/ti/Kconfig |  2 +-
>  drivers/soc/ti/pruss.c | 76 --
>  2 files changed, 45 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
> index 7e2fb1c16af1..7a692a21480a 100644
> --- a/drivers/soc/ti/Kconfig
> +++ b/drivers/soc/ti/Kconfig
> @@ -85,7 +85,7 @@ config TI_K3_SOCINFO
>  
>  config TI_PRUSS
>   tristate "TI PRU-ICSS Subsystem Platform drivers"
> - depends on SOC_AM33XX || SOC_AM43XX || SOC_DRA7XX || ARCH_KEYSTONE || 
> ARCH_K3
> + depends on ARCH_DAVINCI || SOC_AM33XX || SOC_AM43XX || SOC_DRA7XX || 
> ARCH_KEYSTONE || ARCH_K3
>   select MFD_SYSCON
>   help
> TI PRU-ICSS Subsystem platform specific support.
> diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
> index 5d6e7132a5c4..bfaf3ff74b01 100644
> --- a/drivers/soc/ti/pruss.c
> +++ b/drivers/soc/ti/pruss.c
> @@ -24,10 +24,12 @@
>   * struct pruss_private_data - PRUSS driver private data
>   * @has_no_sharedram: flag to indicate the absence of PRUSS Shared Data RAM
>   * @has_core_mux_clock: flag to indicate the presence of PRUSS core clock
> + * @has_cfg: flag to indicate the presence of PRUSS CFG registers

I recommend to change this to a negative flag as the Davinci platforms are the
only ones that don't have CFG (being the very first SoCs with a PRUSS IP)
sub-module.

>   */
>  struct pruss_private_data {
>   bool has_no_sharedram;
>   bool has_core_mux_clock;
> + bool has_cfg;
>  };
>  
>  static void pruss_of_free_clk_provider(void *data)
> @@ -239,42 +241,44 @@ static int pruss_probe(struct platform_device *pdev)
>   goto rpm_disable;
>   }
>  

And use it here to skip all the cfg code parsing. All the below delta is just
for the additional indentation for the flag. If you don't like goto's in
non-error paths, then we can refactor the CFG parse code into a separate 
function.

regards
Suman

> - child = of_get_child_by_name(np, "cfg");
> - if (!child) {
> - dev_err(dev, "%pOF is missing its 'cfg' node\n", child);
> - ret = -ENODEV;
> - goto rpm_put;
> - }
> + if (data->has_cfg) {
> + child = of_get_child_by_name(np, "cfg");
> + if (!child) {
> + dev_err(dev, "%pOF is missing its 'cfg' node\n", child);
> + ret = -ENODEV;
> + goto rpm_put;
> + }
>  
> - if (of_address_to_resource(child, 0, )) {
> - ret = -ENOMEM;
> - goto node_put;
> - }
> + if (of_address_to_resource(child, 0, )) {
> + ret = -ENOMEM;
> + goto node_put;
> + }
>  
> - pruss->cfg_base = devm_ioremap(dev, res.start, resource_size());
> - if (!pruss->cfg_base) {
> - ret = -ENOMEM;
> - goto node_put;
> - }
> + pruss->cfg_base = devm_ioremap(dev, res.start, 
> resource_size());
> + if (!pruss->cfg_base) {
> + ret = -ENOMEM;
> + goto node_put;
> + }
>  
> - regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child,
> -  (u64)res.start);
> - regmap_conf.max_register = resource_size() - 4;
> -
> - pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base,
> -   _conf);
> - kfree(regmap_conf.name);
> - if (IS_ERR(pruss->cfg_regmap)) {
> - dev_err(dev, "regmap_init_mmio failed for cfg, ret = %ld\n",
> - PTR_ERR(pruss->cfg_regmap));
> - ret = PTR_ERR(pruss->cfg_regmap);
> - goto node_put;
> - }
> + regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child,
> +  (u64)res.start);
> + regmap_conf.max_register = resource_size() - 4;
> +
> + pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base,
> +   _conf);
> + kfree(regmap_conf.name);
> + if (IS_ERR(pruss->cfg_regmap)) {
> + dev_err(dev, "regmap_init_mmio failed for cfg, ret = 
> %ld\n",
> + PTR_ERR(pruss->cfg_regmap));
> + ret = PTR_ERR(pruss->cfg_regmap);
> + goto node_put;
> + }
>  
> - ret = pruss_clk_init(pruss, child);
> - if (ret) {
> - dev_err(dev, "failed to setup coreclk-mux\n");
> - goto node_put;
> +

RE: [PATCH 2/2] soc: ti: pruss: add support for AM18XX/OMAP-L138 PRUSS

2021-01-05 Thread Hans-Frieder Vogt
Hi David,

since you introduced a configuration parameter which was implicitly true 
before, the config parameter now needs to be explicitly set to true for all 
SoCs which have cfg registers (specifically AM33XX and AM57XX), see below.

On Mon, Jan 4, 2021, David Lechner wrote:
> This adds support for the PRUSS found in AM18XX/OMAP-L138. This PRUSS
> doesn't have a CFG register, so that is made optional as selected by
> the device tree compatible string.
>
> ARCH_DAVINCI is added in the Kconfig so that the driver can be selected
> on that platform.
>
> Signed-off-by: David Lechner 

... shortened ...

> @@ -309,19 +313,27 @@ static int pruss_remove(struct platform_device *pdev)
>  }
>
>  /* instance-specific driver private data */
> +static const struct pruss_private_data am18xx_pruss_data = {
> + .has_no_sharedram = true,
> +};
> +
>  static const struct pruss_private_data am437x_pruss1_data = {
>   .has_no_sharedram = false,
> + .has_cfg = true,
>  };
>
>  static const struct pruss_private_data am437x_pruss0_data = {
>   .has_no_sharedram = true,
> + .has_cfg = true,
>  };
>
>  static const struct pruss_private_data am65x_j721e_pruss_data = {
>   .has_core_mux_clock = true,
> + .has_cfg = true,
>  };
>
>  static const struct of_device_id pruss_of_match[] = {
> + { .compatible = "ti,am1806-pruss", .data = _pruss_data, },
>   { .compatible = "ti,am3356-pruss" },

needs something like:
{ .compatible = "ti,am3356-pruss", .data = _am57xx_pruss_data, },
{ .compatible = "ti,am5728-pruss", .data = _am57xx_pruss_data, },
with
 static const struct pruss_private_data am33xx_am57xx_pruss_data = {
.has_cfg = true,
 };

>   { .compatible = "ti,am4376-pruss0", .data = _pruss0_data, },
>   { .compatible = "ti,am4376-pruss1", .data = _pruss1_data, },

---
Best regards,
Hans-Frieder


[PATCH 2/2] soc: ti: pruss: add support for AM18XX/OMAP-L138 PRUSS

2021-01-04 Thread David Lechner
This adds support for the PRUSS found in AM18XX/OMAP-L138. This PRUSS
doesn't have a CFG register, so that is made optional as selected by
the device tree compatible string.

ARCH_DAVINCI is added in the Kconfig so that the driver can be selected
on that platform.

Signed-off-by: David Lechner 
---
 drivers/soc/ti/Kconfig |  2 +-
 drivers/soc/ti/pruss.c | 76 --
 2 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/drivers/soc/ti/Kconfig b/drivers/soc/ti/Kconfig
index 7e2fb1c16af1..7a692a21480a 100644
--- a/drivers/soc/ti/Kconfig
+++ b/drivers/soc/ti/Kconfig
@@ -85,7 +85,7 @@ config TI_K3_SOCINFO
 
 config TI_PRUSS
tristate "TI PRU-ICSS Subsystem Platform drivers"
-   depends on SOC_AM33XX || SOC_AM43XX || SOC_DRA7XX || ARCH_KEYSTONE || 
ARCH_K3
+   depends on ARCH_DAVINCI || SOC_AM33XX || SOC_AM43XX || SOC_DRA7XX || 
ARCH_KEYSTONE || ARCH_K3
select MFD_SYSCON
help
  TI PRU-ICSS Subsystem platform specific support.
diff --git a/drivers/soc/ti/pruss.c b/drivers/soc/ti/pruss.c
index 5d6e7132a5c4..bfaf3ff74b01 100644
--- a/drivers/soc/ti/pruss.c
+++ b/drivers/soc/ti/pruss.c
@@ -24,10 +24,12 @@
  * struct pruss_private_data - PRUSS driver private data
  * @has_no_sharedram: flag to indicate the absence of PRUSS Shared Data RAM
  * @has_core_mux_clock: flag to indicate the presence of PRUSS core clock
+ * @has_cfg: flag to indicate the presence of PRUSS CFG registers
  */
 struct pruss_private_data {
bool has_no_sharedram;
bool has_core_mux_clock;
+   bool has_cfg;
 };
 
 static void pruss_of_free_clk_provider(void *data)
@@ -239,42 +241,44 @@ static int pruss_probe(struct platform_device *pdev)
goto rpm_disable;
}
 
-   child = of_get_child_by_name(np, "cfg");
-   if (!child) {
-   dev_err(dev, "%pOF is missing its 'cfg' node\n", child);
-   ret = -ENODEV;
-   goto rpm_put;
-   }
+   if (data->has_cfg) {
+   child = of_get_child_by_name(np, "cfg");
+   if (!child) {
+   dev_err(dev, "%pOF is missing its 'cfg' node\n", child);
+   ret = -ENODEV;
+   goto rpm_put;
+   }
 
-   if (of_address_to_resource(child, 0, )) {
-   ret = -ENOMEM;
-   goto node_put;
-   }
+   if (of_address_to_resource(child, 0, )) {
+   ret = -ENOMEM;
+   goto node_put;
+   }
 
-   pruss->cfg_base = devm_ioremap(dev, res.start, resource_size());
-   if (!pruss->cfg_base) {
-   ret = -ENOMEM;
-   goto node_put;
-   }
+   pruss->cfg_base = devm_ioremap(dev, res.start, 
resource_size());
+   if (!pruss->cfg_base) {
+   ret = -ENOMEM;
+   goto node_put;
+   }
 
-   regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child,
-(u64)res.start);
-   regmap_conf.max_register = resource_size() - 4;
-
-   pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base,
- _conf);
-   kfree(regmap_conf.name);
-   if (IS_ERR(pruss->cfg_regmap)) {
-   dev_err(dev, "regmap_init_mmio failed for cfg, ret = %ld\n",
-   PTR_ERR(pruss->cfg_regmap));
-   ret = PTR_ERR(pruss->cfg_regmap);
-   goto node_put;
-   }
+   regmap_conf.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", child,
+(u64)res.start);
+   regmap_conf.max_register = resource_size() - 4;
+
+   pruss->cfg_regmap = devm_regmap_init_mmio(dev, pruss->cfg_base,
+ _conf);
+   kfree(regmap_conf.name);
+   if (IS_ERR(pruss->cfg_regmap)) {
+   dev_err(dev, "regmap_init_mmio failed for cfg, ret = 
%ld\n",
+   PTR_ERR(pruss->cfg_regmap));
+   ret = PTR_ERR(pruss->cfg_regmap);
+   goto node_put;
+   }
 
-   ret = pruss_clk_init(pruss, child);
-   if (ret) {
-   dev_err(dev, "failed to setup coreclk-mux\n");
-   goto node_put;
+   ret = pruss_clk_init(pruss, child);
+   if (ret) {
+   dev_err(dev, "failed to setup coreclk-mux\n");
+   goto node_put;
+   }
}
 
ret = devm_of_platform_populate(dev);
@@ -309,19 +313,27 @@ static int pruss_remove(struct platform_device *pdev)
 }
 
 /* instance-specific driver private data */
+static const struct pruss_private_data am18xx_pruss_data = {
+   .has_no_sharedram = true,
+};
+
 static const struct pruss_private_data am437x_pruss1_data = {