* [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
@ 2017-04-14 8:22 Quentin Schulz
2017-04-14 8:22 ` [PATCH 2/2] spi: atmel: add deepest PM support to SAMA5D2 Quentin Schulz
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Quentin Schulz @ 2017-04-14 8:22 UTC (permalink / raw)
To: nicolas.ferre, broonie
Cc: Quentin Schulz, linux-spi, linux-kernel, alexandre.belloni,
thomas.petazzoni
The SPI controller configuration during the init can be reused, for the
resume function for example.
Let's move this configuration to a separate function.
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
drivers/spi/spi-atmel.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 0e7712b..247d920 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1464,6 +1464,25 @@ static int atmel_spi_gpio_cs(struct platform_device *pdev)
return 0;
}
+static void atmel_spi_init(struct atmel_spi *as)
+{
+ spi_writel(as, CR, SPI_BIT(SWRST));
+ spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
+ if (as->caps.has_wdrbt) {
+ spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
+ | SPI_BIT(MSTR));
+ } else {
+ spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
+ }
+
+ if (as->use_pdc)
+ spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
+ spi_writel(as, CR, SPI_BIT(SPIEN));
+
+ if (as->fifo_size)
+ spi_writel(as, CR, SPI_BIT(FIFOEN));
+}
+
static int atmel_spi_probe(struct platform_device *pdev)
{
struct resource *regs;
@@ -1572,26 +1591,14 @@ static int atmel_spi_probe(struct platform_device *pdev)
as->spi_clk = clk_get_rate(clk);
- spi_writel(as, CR, SPI_BIT(SWRST));
- spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
- if (as->caps.has_wdrbt) {
- spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
- | SPI_BIT(MSTR));
- } else {
- spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
- }
-
- if (as->use_pdc)
- spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
- spi_writel(as, CR, SPI_BIT(SPIEN));
-
as->fifo_size = 0;
if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",
&as->fifo_size)) {
dev_info(&pdev->dev, "Using FIFO (%u data)\n", as->fifo_size);
- spi_writel(as, CR, SPI_BIT(FIFOEN));
}
+ atmel_spi_init(as);
+
pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
--
2.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] spi: atmel: add deepest PM support to SAMA5D2
2017-04-14 8:22 [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init Quentin Schulz
@ 2017-04-14 8:22 ` Quentin Schulz
2017-04-14 10:35 ` Alexandre Belloni
2017-04-14 10:35 ` Alexandre Belloni
2017-04-14 17:03 ` Mark Brown
2 siblings, 1 reply; 12+ messages in thread
From: Quentin Schulz @ 2017-04-14 8:22 UTC (permalink / raw)
To: nicolas.ferre, broonie
Cc: Quentin Schulz, linux-spi, linux-kernel, alexandre.belloni,
thomas.petazzoni
This adds deepest (Backup+Self-Refresh) PM support to the ATMEL SAMA5D2
SoC's SPI controller.
When resuming from deepest state, it is required to restore MR register
as the registers are lost since VDD core has been shut down when
entering deepest state on the SAMA5D2.
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
v2:
- fix commit log explanation on why restoring the registers is required
after resuming from deepest state,
drivers/spi/spi-atmel.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 247d920..1eb83c9 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1702,8 +1702,17 @@ static int atmel_spi_suspend(struct device *dev)
static int atmel_spi_resume(struct device *dev)
{
struct spi_master *master = dev_get_drvdata(dev);
+ struct atmel_spi *as = spi_master_get_devdata(master);
int ret;
+ ret = clk_prepare_enable(as->clk);
+ if (ret)
+ return ret;
+
+ atmel_spi_init(as);
+
+ clk_disable_unprepare(as->clk);
+
if (!pm_runtime_suspended(dev)) {
ret = atmel_spi_runtime_resume(dev);
if (ret)
--
2.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] spi: atmel: add deepest PM support to SAMA5D2
@ 2017-04-14 10:35 ` Alexandre Belloni
0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2017-04-14 10:35 UTC (permalink / raw)
To: Quentin Schulz
Cc: nicolas.ferre, broonie, linux-spi, linux-kernel, thomas.petazzoni
On 14/04/2017 at 10:22:43 +0200, Quentin Schulz wrote:
> This adds deepest (Backup+Self-Refresh) PM support to the ATMEL SAMA5D2
> SoC's SPI controller.
>
> When resuming from deepest state, it is required to restore MR register
> as the registers are lost since VDD core has been shut down when
> entering deepest state on the SAMA5D2.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>
> v2:
> - fix commit log explanation on why restoring the registers is required
> after resuming from deepest state,
>
> drivers/spi/spi-atmel.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 247d920..1eb83c9 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1702,8 +1702,17 @@ static int atmel_spi_suspend(struct device *dev)
> static int atmel_spi_resume(struct device *dev)
> {
> struct spi_master *master = dev_get_drvdata(dev);
> + struct atmel_spi *as = spi_master_get_devdata(master);
> int ret;
>
> + ret = clk_prepare_enable(as->clk);
> + if (ret)
> + return ret;
> +
> + atmel_spi_init(as);
> +
> + clk_disable_unprepare(as->clk);
> +
> if (!pm_runtime_suspended(dev)) {
> ret = atmel_spi_runtime_resume(dev);
> if (ret)
> --
> 2.9.3
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/2] spi: atmel: add deepest PM support to SAMA5D2
@ 2017-04-14 10:35 ` Alexandre Belloni
0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2017-04-14 10:35 UTC (permalink / raw)
To: Quentin Schulz
Cc: nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA,
broonie-DgEjT+Ai2ygdnm+yROfE0A, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
On 14/04/2017 at 10:22:43 +0200, Quentin Schulz wrote:
> This adds deepest (Backup+Self-Refresh) PM support to the ATMEL SAMA5D2
> SoC's SPI controller.
>
> When resuming from deepest state, it is required to restore MR register
> as the registers are lost since VDD core has been shut down when
> entering deepest state on the SAMA5D2.
>
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Acked-by: Alexandre Belloni <alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>
> v2:
> - fix commit log explanation on why restoring the registers is required
> after resuming from deepest state,
>
> drivers/spi/spi-atmel.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 247d920..1eb83c9 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1702,8 +1702,17 @@ static int atmel_spi_suspend(struct device *dev)
> static int atmel_spi_resume(struct device *dev)
> {
> struct spi_master *master = dev_get_drvdata(dev);
> + struct atmel_spi *as = spi_master_get_devdata(master);
> int ret;
>
> + ret = clk_prepare_enable(as->clk);
> + if (ret)
> + return ret;
> +
> + atmel_spi_init(as);
> +
> + clk_disable_unprepare(as->clk);
> +
> if (!pm_runtime_suspended(dev)) {
> ret = atmel_spi_runtime_resume(dev);
> if (ret)
> --
> 2.9.3
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 2/2] spi: atmel: add deepest PM support to SAMA5D2
2017-04-14 10:35 ` Alexandre Belloni
(?)
@ 2017-04-18 8:50 ` Nicolas.Ferre
-1 siblings, 0 replies; 12+ messages in thread
From: Nicolas.Ferre @ 2017-04-18 8:50 UTC (permalink / raw)
To: alexandre.belloni, quentin.schulz
Cc: broonie, linux-spi, linux-kernel, thomas.petazzoni
(sorry for malformed email but I didn't want to hold this patch longer)
On 14/04/2017 at 10:22:43 +0200, Quentin Schulz wrote:
> This adds deepest (Backup+Self-Refresh) PM support to the ATMEL SAMA5D2
> SoC's SPI controller.
>
> When resuming from deepest state, it is required to restore MR register
> as the registers are lost since VDD core has been shut down when
> entering deepest state on the SAMA5D2.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> ---
>
> v2:
> - fix commit log explanation on why restoring the registers is required
> after resuming from deepest state,
>
> drivers/spi/spi-atmel.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 247d920..1eb83c9 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1702,8 +1702,17 @@ static int atmel_spi_suspend(struct device *dev)
> static int atmel_spi_resume(struct device *dev)
> {
> struct spi_master *master = dev_get_drvdata(dev);
> + struct atmel_spi *as = spi_master_get_devdata(master);
> int ret;
>
> + ret = clk_prepare_enable(as->clk);
> + if (ret)
> + return ret;
> +
> + atmel_spi_init(as);
> +
> + clk_disable_unprepare(as->clk);
> +
> if (!pm_runtime_suspended(dev)) {
> ret = atmel_spi_runtime_resume(dev);
> if (ret)
> --
> 2.9.3
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
@ 2017-04-14 10:35 ` Alexandre Belloni
0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2017-04-14 10:35 UTC (permalink / raw)
To: Quentin Schulz
Cc: nicolas.ferre, broonie, linux-spi, linux-kernel, thomas.petazzoni
On 14/04/2017 at 10:22:42 +0200, Quentin Schulz wrote:
> The SPI controller configuration during the init can be reused, for the
> resume function for example.
>
> Let's move this configuration to a separate function.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Note that this one has already been applied.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
@ 2017-04-14 10:35 ` Alexandre Belloni
0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2017-04-14 10:35 UTC (permalink / raw)
To: Quentin Schulz
Cc: nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA,
broonie-DgEjT+Ai2ygdnm+yROfE0A, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
On 14/04/2017 at 10:22:42 +0200, Quentin Schulz wrote:
> The SPI controller configuration during the init can be reused, for the
> resume function for example.
>
> Let's move this configuration to a separate function.
>
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Acked-by: Nicolas Ferre <nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
Note that this one has already been applied.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
2017-04-14 8:22 [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init Quentin Schulz
2017-04-14 8:22 ` [PATCH 2/2] spi: atmel: add deepest PM support to SAMA5D2 Quentin Schulz
2017-04-14 10:35 ` Alexandre Belloni
@ 2017-04-14 17:03 ` Mark Brown
2 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2017-04-14 17:03 UTC (permalink / raw)
To: Quentin Schulz
Cc: nicolas.ferre, linux-spi, linux-kernel, alexandre.belloni,
thomas.petazzoni
[-- Attachment #1: Type: text/plain, Size: 574 bytes --]
On Fri, Apr 14, 2017 at 10:22:42AM +0200, Quentin Schulz wrote:
> The SPI controller configuration during the init can be reused, for the
> resume function for example.
Please don't resubmit patches that have already been applied, you should
submit patches against current code in the tree you're expecting things
to be applied to. If any updates are needed to a patch that's already
been applied you should submit incremental patches which make those
updates. This avoids having to change published git commits which could
cause problems for people working against git.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
@ 2017-04-12 7:05 ` Quentin Schulz
0 siblings, 0 replies; 12+ messages in thread
From: Quentin Schulz @ 2017-04-12 7:05 UTC (permalink / raw)
To: nicolas.ferre, broonie
Cc: Quentin Schulz, linux-spi, linux-kernel, alexandre.belloni,
thomas.petazzoni
The SPI controller configuration during the init can be reused, for the
resume function for example.
Let's move this configuration to a separate function.
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
drivers/spi/spi-atmel.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 0e7712b..247d920 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1464,6 +1464,25 @@ static int atmel_spi_gpio_cs(struct platform_device *pdev)
return 0;
}
+static void atmel_spi_init(struct atmel_spi *as)
+{
+ spi_writel(as, CR, SPI_BIT(SWRST));
+ spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
+ if (as->caps.has_wdrbt) {
+ spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
+ | SPI_BIT(MSTR));
+ } else {
+ spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
+ }
+
+ if (as->use_pdc)
+ spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
+ spi_writel(as, CR, SPI_BIT(SPIEN));
+
+ if (as->fifo_size)
+ spi_writel(as, CR, SPI_BIT(FIFOEN));
+}
+
static int atmel_spi_probe(struct platform_device *pdev)
{
struct resource *regs;
@@ -1572,26 +1591,14 @@ static int atmel_spi_probe(struct platform_device *pdev)
as->spi_clk = clk_get_rate(clk);
- spi_writel(as, CR, SPI_BIT(SWRST));
- spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
- if (as->caps.has_wdrbt) {
- spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
- | SPI_BIT(MSTR));
- } else {
- spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
- }
-
- if (as->use_pdc)
- spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
- spi_writel(as, CR, SPI_BIT(SPIEN));
-
as->fifo_size = 0;
if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",
&as->fifo_size)) {
dev_info(&pdev->dev, "Using FIFO (%u data)\n", as->fifo_size);
- spi_writel(as, CR, SPI_BIT(FIFOEN));
}
+ atmel_spi_init(as);
+
pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
--
2.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
@ 2017-04-12 7:05 ` Quentin Schulz
0 siblings, 0 replies; 12+ messages in thread
From: Quentin Schulz @ 2017-04-12 7:05 UTC (permalink / raw)
To: nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA, broonie-DgEjT+Ai2ygdnm+yROfE0A
Cc: Quentin Schulz, linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
The SPI controller configuration during the init can be reused, for the
resume function for example.
Let's move this configuration to a separate function.
Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
drivers/spi/spi-atmel.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 0e7712b..247d920 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1464,6 +1464,25 @@ static int atmel_spi_gpio_cs(struct platform_device *pdev)
return 0;
}
+static void atmel_spi_init(struct atmel_spi *as)
+{
+ spi_writel(as, CR, SPI_BIT(SWRST));
+ spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
+ if (as->caps.has_wdrbt) {
+ spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
+ | SPI_BIT(MSTR));
+ } else {
+ spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
+ }
+
+ if (as->use_pdc)
+ spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
+ spi_writel(as, CR, SPI_BIT(SPIEN));
+
+ if (as->fifo_size)
+ spi_writel(as, CR, SPI_BIT(FIFOEN));
+}
+
static int atmel_spi_probe(struct platform_device *pdev)
{
struct resource *regs;
@@ -1572,26 +1591,14 @@ static int atmel_spi_probe(struct platform_device *pdev)
as->spi_clk = clk_get_rate(clk);
- spi_writel(as, CR, SPI_BIT(SWRST));
- spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
- if (as->caps.has_wdrbt) {
- spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
- | SPI_BIT(MSTR));
- } else {
- spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
- }
-
- if (as->use_pdc)
- spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
- spi_writel(as, CR, SPI_BIT(SPIEN));
-
as->fifo_size = 0;
if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",
&as->fifo_size)) {
dev_info(&pdev->dev, "Using FIFO (%u data)\n", as->fifo_size);
- spi_writel(as, CR, SPI_BIT(FIFOEN));
}
+ atmel_spi_init(as);
+
pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
--
2.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
@ 2017-04-12 8:40 ` Nicolas Ferre
0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Ferre @ 2017-04-12 8:40 UTC (permalink / raw)
To: Quentin Schulz, broonie
Cc: linux-spi, linux-kernel, alexandre.belloni, thomas.petazzoni
Le 12/04/2017 à 09:05, Quentin Schulz a écrit :
> The SPI controller configuration during the init can be reused, for the
> resume function for example.
>
> Let's move this configuration to a separate function.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Okay:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> ---
> drivers/spi/spi-atmel.c | 35 +++++++++++++++++++++--------------
> 1 file changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 0e7712b..247d920 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1464,6 +1464,25 @@ static int atmel_spi_gpio_cs(struct platform_device *pdev)
> return 0;
> }
>
> +static void atmel_spi_init(struct atmel_spi *as)
> +{
> + spi_writel(as, CR, SPI_BIT(SWRST));
> + spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
> + if (as->caps.has_wdrbt) {
> + spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
> + | SPI_BIT(MSTR));
> + } else {
> + spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
> + }
> +
> + if (as->use_pdc)
> + spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
> + spi_writel(as, CR, SPI_BIT(SPIEN));
> +
> + if (as->fifo_size)
> + spi_writel(as, CR, SPI_BIT(FIFOEN));
> +}
> +
> static int atmel_spi_probe(struct platform_device *pdev)
> {
> struct resource *regs;
> @@ -1572,26 +1591,14 @@ static int atmel_spi_probe(struct platform_device *pdev)
>
> as->spi_clk = clk_get_rate(clk);
>
> - spi_writel(as, CR, SPI_BIT(SWRST));
> - spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
> - if (as->caps.has_wdrbt) {
> - spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
> - | SPI_BIT(MSTR));
> - } else {
> - spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
> - }
> -
> - if (as->use_pdc)
> - spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
> - spi_writel(as, CR, SPI_BIT(SPIEN));
> -
> as->fifo_size = 0;
> if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",
> &as->fifo_size)) {
> dev_info(&pdev->dev, "Using FIFO (%u data)\n", as->fifo_size);
> - spi_writel(as, CR, SPI_BIT(FIFOEN));
> }
>
> + atmel_spi_init(as);
> +
> pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
> pm_runtime_use_autosuspend(&pdev->dev);
> pm_runtime_set_active(&pdev->dev);
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init
@ 2017-04-12 8:40 ` Nicolas Ferre
0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Ferre @ 2017-04-12 8:40 UTC (permalink / raw)
To: Quentin Schulz, broonie-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
Le 12/04/2017 à 09:05, Quentin Schulz a écrit :
> The SPI controller configuration during the init can be reused, for the
> resume function for example.
>
> Let's move this configuration to a separate function.
>
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Okay:
Acked-by: Nicolas Ferre <nicolas.ferre-UWL1GkI3JZL3oGB3hsPCZA@public.gmane.org>
> ---
> drivers/spi/spi-atmel.c | 35 +++++++++++++++++++++--------------
> 1 file changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 0e7712b..247d920 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1464,6 +1464,25 @@ static int atmel_spi_gpio_cs(struct platform_device *pdev)
> return 0;
> }
>
> +static void atmel_spi_init(struct atmel_spi *as)
> +{
> + spi_writel(as, CR, SPI_BIT(SWRST));
> + spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
> + if (as->caps.has_wdrbt) {
> + spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
> + | SPI_BIT(MSTR));
> + } else {
> + spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
> + }
> +
> + if (as->use_pdc)
> + spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
> + spi_writel(as, CR, SPI_BIT(SPIEN));
> +
> + if (as->fifo_size)
> + spi_writel(as, CR, SPI_BIT(FIFOEN));
> +}
> +
> static int atmel_spi_probe(struct platform_device *pdev)
> {
> struct resource *regs;
> @@ -1572,26 +1591,14 @@ static int atmel_spi_probe(struct platform_device *pdev)
>
> as->spi_clk = clk_get_rate(clk);
>
> - spi_writel(as, CR, SPI_BIT(SWRST));
> - spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */
> - if (as->caps.has_wdrbt) {
> - spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS)
> - | SPI_BIT(MSTR));
> - } else {
> - spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS));
> - }
> -
> - if (as->use_pdc)
> - spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS));
> - spi_writel(as, CR, SPI_BIT(SPIEN));
> -
> as->fifo_size = 0;
> if (!of_property_read_u32(pdev->dev.of_node, "atmel,fifo-size",
> &as->fifo_size)) {
> dev_info(&pdev->dev, "Using FIFO (%u data)\n", as->fifo_size);
> - spi_writel(as, CR, SPI_BIT(FIFOEN));
> }
>
> + atmel_spi_init(as);
> +
> pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT);
> pm_runtime_use_autosuspend(&pdev->dev);
> pm_runtime_set_active(&pdev->dev);
>
--
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-04-18 8:52 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-14 8:22 [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init Quentin Schulz
2017-04-14 8:22 ` [PATCH 2/2] spi: atmel: add deepest PM support to SAMA5D2 Quentin Schulz
2017-04-14 10:35 ` Alexandre Belloni
2017-04-14 10:35 ` Alexandre Belloni
2017-04-18 8:50 ` Nicolas.Ferre
2017-04-14 10:35 ` [PATCH 1/2] spi: atmel: factorize reusable code for SPI controller init Alexandre Belloni
2017-04-14 10:35 ` Alexandre Belloni
2017-04-14 17:03 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2017-04-12 7:05 Quentin Schulz
2017-04-12 7:05 ` Quentin Schulz
2017-04-12 8:40 ` Nicolas Ferre
2017-04-12 8:40 ` Nicolas Ferre
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.