All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-12 23:23 ` Alexandre Belloni
  0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2014-09-12 23:23 UTC (permalink / raw)
  To: Josh Wu, Brian Norris
  Cc: David Woodhouse, Boris Brezillon, Nicolas Ferre, linux-mtd,
	linux-arm-kernel, linux-kernel, Alexandre Belloni

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
compatibility with previous device trees but document it as mandatory so newer
device trees will include it.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Josh Wu <josh.wu@atmel.com>
---
Changes in v5:
 - Added a proper commit log

 .../devicetree/bindings/mtd/atmel-nand.txt         |  2 ++
 drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
index c4728839d0c1..6edc3b616e98 100644
--- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
@@ -36,6 +36,7 @@ Optional properties:
     - reg : should specify the address and size used for NFC command registers,
             NFC registers and NFC Sram. NFC Sram address and size can be absent
             if don't want to use it.
+    - clocks: phandle to the peripheral clock
   - Optional properties:
     - atmel,write-by-sram: boolean to enable NFC write by sram.
 
@@ -98,6 +99,7 @@ nand0: nand@40000000 {
 		compatible = "atmel,sama5d3-nfc";
 		#address-cells = <1>;
 		#size-cells = <1>;
+		clocks = <&hsmc_clk>
 		reg = <
 			0x70000000 0x10000000	/* NFC Command Registers */
 			0xffffc000 0x00000070	/* NFC HSMC regs */
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 9c5f717bda54..d1e502f8dbd0 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -27,6 +27,7 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -96,6 +97,8 @@ struct atmel_nfc {
 	bool			use_nfc_sram;
 	bool			write_by_sram;
 
+	struct clk		*clk;
+
 	bool			is_initialized;
 	struct completion	comp_ready;
 	struct completion	comp_cmd_done;
@@ -2248,6 +2251,7 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
 {
 	struct atmel_nfc *nfc = &nand_nfc;
 	struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram;
+	int ret;
 
 	nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	nfc->base_cmd_regs = devm_ioremap_resource(&pdev->dev, nfc_cmd_regs);
@@ -2279,8 +2283,28 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
 	nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff);
 	nfc_readl(nfc->hsmc_regs, SR);	/* clear the NFC_SR */
 
+	nfc->clk = devm_clk_get(&pdev->dev, NULL);
+	if (!IS_ERR(nfc->clk)) {
+		ret = clk_prepare_enable(nfc->clk);
+		if (ret)
+			return ret;
+	} else {
+		dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");
+	}
+
 	nfc->is_initialized = true;
 	dev_info(&pdev->dev, "NFC is probed.\n");
+
+	return 0;
+}
+
+static int atmel_nand_nfc_remove(struct platform_device *pdev)
+{
+	struct atmel_nfc *nfc = &nand_nfc;
+
+	if (!IS_ERR(nfc->clk))
+		clk_disable_unprepare(nfc->clk);
+
 	return 0;
 }
 
@@ -2297,6 +2321,7 @@ static struct platform_driver atmel_nand_nfc_driver = {
 		.of_match_table = of_match_ptr(atmel_nand_nfc_match),
 	},
 	.probe = atmel_nand_nfc_probe,
+	.remove = atmel_nand_nfc_remove,
 };
 
 static struct platform_driver atmel_nand_driver = {
-- 
1.9.1


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

* [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-12 23:23 ` Alexandre Belloni
  0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2014-09-12 23:23 UTC (permalink / raw)
  To: Josh Wu, Brian Norris
  Cc: Boris Brezillon, Nicolas Ferre, linux-kernel, linux-mtd,
	Alexandre Belloni, David Woodhouse, linux-arm-kernel

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
compatibility with previous device trees but document it as mandatory so newer
device trees will include it.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Josh Wu <josh.wu@atmel.com>
---
Changes in v5:
 - Added a proper commit log

 .../devicetree/bindings/mtd/atmel-nand.txt         |  2 ++
 drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
index c4728839d0c1..6edc3b616e98 100644
--- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
@@ -36,6 +36,7 @@ Optional properties:
     - reg : should specify the address and size used for NFC command registers,
             NFC registers and NFC Sram. NFC Sram address and size can be absent
             if don't want to use it.
+    - clocks: phandle to the peripheral clock
   - Optional properties:
     - atmel,write-by-sram: boolean to enable NFC write by sram.
 
@@ -98,6 +99,7 @@ nand0: nand@40000000 {
 		compatible = "atmel,sama5d3-nfc";
 		#address-cells = <1>;
 		#size-cells = <1>;
+		clocks = <&hsmc_clk>
 		reg = <
 			0x70000000 0x10000000	/* NFC Command Registers */
 			0xffffc000 0x00000070	/* NFC HSMC regs */
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 9c5f717bda54..d1e502f8dbd0 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -27,6 +27,7 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -96,6 +97,8 @@ struct atmel_nfc {
 	bool			use_nfc_sram;
 	bool			write_by_sram;
 
+	struct clk		*clk;
+
 	bool			is_initialized;
 	struct completion	comp_ready;
 	struct completion	comp_cmd_done;
@@ -2248,6 +2251,7 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
 {
 	struct atmel_nfc *nfc = &nand_nfc;
 	struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram;
+	int ret;
 
 	nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	nfc->base_cmd_regs = devm_ioremap_resource(&pdev->dev, nfc_cmd_regs);
@@ -2279,8 +2283,28 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
 	nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff);
 	nfc_readl(nfc->hsmc_regs, SR);	/* clear the NFC_SR */
 
+	nfc->clk = devm_clk_get(&pdev->dev, NULL);
+	if (!IS_ERR(nfc->clk)) {
+		ret = clk_prepare_enable(nfc->clk);
+		if (ret)
+			return ret;
+	} else {
+		dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");
+	}
+
 	nfc->is_initialized = true;
 	dev_info(&pdev->dev, "NFC is probed.\n");
+
+	return 0;
+}
+
+static int atmel_nand_nfc_remove(struct platform_device *pdev)
+{
+	struct atmel_nfc *nfc = &nand_nfc;
+
+	if (!IS_ERR(nfc->clk))
+		clk_disable_unprepare(nfc->clk);
+
 	return 0;
 }
 
@@ -2297,6 +2321,7 @@ static struct platform_driver atmel_nand_nfc_driver = {
 		.of_match_table = of_match_ptr(atmel_nand_nfc_match),
 	},
 	.probe = atmel_nand_nfc_probe,
+	.remove = atmel_nand_nfc_remove,
 };
 
 static struct platform_driver atmel_nand_driver = {
-- 
1.9.1

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

* [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-12 23:23 ` Alexandre Belloni
  0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2014-09-12 23:23 UTC (permalink / raw)
  To: linux-arm-kernel

From: Boris BREZILLON <boris.brezillon@free-electrons.com>

Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
compatibility with previous device trees but document it as mandatory so newer
device trees will include it.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Josh Wu <josh.wu@atmel.com>
---
Changes in v5:
 - Added a proper commit log

 .../devicetree/bindings/mtd/atmel-nand.txt         |  2 ++
 drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
index c4728839d0c1..6edc3b616e98 100644
--- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
@@ -36,6 +36,7 @@ Optional properties:
     - reg : should specify the address and size used for NFC command registers,
             NFC registers and NFC Sram. NFC Sram address and size can be absent
             if don't want to use it.
+    - clocks: phandle to the peripheral clock
   - Optional properties:
     - atmel,write-by-sram: boolean to enable NFC write by sram.
 
@@ -98,6 +99,7 @@ nand0: nand at 40000000 {
 		compatible = "atmel,sama5d3-nfc";
 		#address-cells = <1>;
 		#size-cells = <1>;
+		clocks = <&hsmc_clk>
 		reg = <
 			0x70000000 0x10000000	/* NFC Command Registers */
 			0xffffc000 0x00000070	/* NFC HSMC regs */
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 9c5f717bda54..d1e502f8dbd0 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -27,6 +27,7 @@
  *
  */
 
+#include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -96,6 +97,8 @@ struct atmel_nfc {
 	bool			use_nfc_sram;
 	bool			write_by_sram;
 
+	struct clk		*clk;
+
 	bool			is_initialized;
 	struct completion	comp_ready;
 	struct completion	comp_cmd_done;
@@ -2248,6 +2251,7 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
 {
 	struct atmel_nfc *nfc = &nand_nfc;
 	struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram;
+	int ret;
 
 	nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	nfc->base_cmd_regs = devm_ioremap_resource(&pdev->dev, nfc_cmd_regs);
@@ -2279,8 +2283,28 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
 	nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff);
 	nfc_readl(nfc->hsmc_regs, SR);	/* clear the NFC_SR */
 
+	nfc->clk = devm_clk_get(&pdev->dev, NULL);
+	if (!IS_ERR(nfc->clk)) {
+		ret = clk_prepare_enable(nfc->clk);
+		if (ret)
+			return ret;
+	} else {
+		dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");
+	}
+
 	nfc->is_initialized = true;
 	dev_info(&pdev->dev, "NFC is probed.\n");
+
+	return 0;
+}
+
+static int atmel_nand_nfc_remove(struct platform_device *pdev)
+{
+	struct atmel_nfc *nfc = &nand_nfc;
+
+	if (!IS_ERR(nfc->clk))
+		clk_disable_unprepare(nfc->clk);
+
 	return 0;
 }
 
@@ -2297,6 +2321,7 @@ static struct platform_driver atmel_nand_nfc_driver = {
 		.of_match_table = of_match_ptr(atmel_nand_nfc_match),
 	},
 	.probe = atmel_nand_nfc_probe,
+	.remove = atmel_nand_nfc_remove,
 };
 
 static struct platform_driver atmel_nand_driver = {
-- 
1.9.1

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

* Re: [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
  2014-09-12 23:23 ` Alexandre Belloni
  (?)
@ 2014-09-13  9:26   ` Ezequiel Garcia
  -1 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-09-13  9:26 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Josh Wu, Brian Norris, Boris Brezillon, Nicolas Ferre,
	linux-kernel, linux-mtd, David Woodhouse, linux-arm-kernel

On 13 September 2014 00:23, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
>
> Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
> compatibility with previous device trees but document it as mandatory so newer
> device trees will include it.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Josh Wu <josh.wu@atmel.com>
> ---
> Changes in v5:
>  - Added a proper commit log
>
>  .../devicetree/bindings/mtd/atmel-nand.txt         |  2 ++
>  drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> index c4728839d0c1..6edc3b616e98 100644
> --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> @@ -36,6 +36,7 @@ Optional properties:
>      - reg : should specify the address and size used for NFC command registers,
>              NFC registers and NFC Sram. NFC Sram address and size can be absent
>              if don't want to use it.
> +    - clocks: phandle to the peripheral clock
>    - Optional properties:
>      - atmel,write-by-sram: boolean to enable NFC write by sram.
>
> @@ -98,6 +99,7 @@ nand0: nand@40000000 {
>                 compatible = "atmel,sama5d3-nfc";
>                 #address-cells = <1>;
>                 #size-cells = <1>;
> +               clocks = <&hsmc_clk>
>                 reg = <
>                         0x70000000 0x10000000   /* NFC Command Registers */
>                         0xffffc000 0x00000070   /* NFC HSMC regs */
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 9c5f717bda54..d1e502f8dbd0 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -27,6 +27,7 @@
>   *
>   */
>
> +#include <linux/clk.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/slab.h>
>  #include <linux/module.h>
> @@ -96,6 +97,8 @@ struct atmel_nfc {
>         bool                    use_nfc_sram;
>         bool                    write_by_sram;
>
> +       struct clk              *clk;
> +
>         bool                    is_initialized;
>         struct completion       comp_ready;
>         struct completion       comp_cmd_done;
> @@ -2248,6 +2251,7 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>  {
>         struct atmel_nfc *nfc = &nand_nfc;
>         struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram;
> +       int ret;
>
>         nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         nfc->base_cmd_regs = devm_ioremap_resource(&pdev->dev, nfc_cmd_regs);
> @@ -2279,8 +2283,28 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>         nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff);
>         nfc_readl(nfc->hsmc_regs, SR);  /* clear the NFC_SR */
>
> +       nfc->clk = devm_clk_get(&pdev->dev, NULL);
> +       if (!IS_ERR(nfc->clk)) {
> +               ret = clk_prepare_enable(nfc->clk);
> +               if (ret)
> +                       return ret;
> +       } else {
> +               dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");

Looks much better now thanks. If the clock is not really optional, you
can consider this a firmware bug. We've used FW_BUG messages for these
cases
(see vim drivers/watchdog/orion_wdt.c), so you could write something like:

dev_warn(..., FW_BUG "devicetree clock missing");

Just a suggestion.
-- 
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar

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

* Re: [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-13  9:26   ` Ezequiel Garcia
  0 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-09-13  9:26 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Boris Brezillon, Nicolas Ferre, linux-kernel, Josh Wu, linux-mtd,
	Brian Norris, David Woodhouse, linux-arm-kernel

On 13 September 2014 00:23, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
>
> Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
> compatibility with previous device trees but document it as mandatory so newer
> device trees will include it.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Josh Wu <josh.wu@atmel.com>
> ---
> Changes in v5:
>  - Added a proper commit log
>
>  .../devicetree/bindings/mtd/atmel-nand.txt         |  2 ++
>  drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> index c4728839d0c1..6edc3b616e98 100644
> --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> @@ -36,6 +36,7 @@ Optional properties:
>      - reg : should specify the address and size used for NFC command registers,
>              NFC registers and NFC Sram. NFC Sram address and size can be absent
>              if don't want to use it.
> +    - clocks: phandle to the peripheral clock
>    - Optional properties:
>      - atmel,write-by-sram: boolean to enable NFC write by sram.
>
> @@ -98,6 +99,7 @@ nand0: nand@40000000 {
>                 compatible = "atmel,sama5d3-nfc";
>                 #address-cells = <1>;
>                 #size-cells = <1>;
> +               clocks = <&hsmc_clk>
>                 reg = <
>                         0x70000000 0x10000000   /* NFC Command Registers */
>                         0xffffc000 0x00000070   /* NFC HSMC regs */
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 9c5f717bda54..d1e502f8dbd0 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -27,6 +27,7 @@
>   *
>   */
>
> +#include <linux/clk.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/slab.h>
>  #include <linux/module.h>
> @@ -96,6 +97,8 @@ struct atmel_nfc {
>         bool                    use_nfc_sram;
>         bool                    write_by_sram;
>
> +       struct clk              *clk;
> +
>         bool                    is_initialized;
>         struct completion       comp_ready;
>         struct completion       comp_cmd_done;
> @@ -2248,6 +2251,7 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>  {
>         struct atmel_nfc *nfc = &nand_nfc;
>         struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram;
> +       int ret;
>
>         nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         nfc->base_cmd_regs = devm_ioremap_resource(&pdev->dev, nfc_cmd_regs);
> @@ -2279,8 +2283,28 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>         nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff);
>         nfc_readl(nfc->hsmc_regs, SR);  /* clear the NFC_SR */
>
> +       nfc->clk = devm_clk_get(&pdev->dev, NULL);
> +       if (!IS_ERR(nfc->clk)) {
> +               ret = clk_prepare_enable(nfc->clk);
> +               if (ret)
> +                       return ret;
> +       } else {
> +               dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");

Looks much better now thanks. If the clock is not really optional, you
can consider this a firmware bug. We've used FW_BUG messages for these
cases
(see vim drivers/watchdog/orion_wdt.c), so you could write something like:

dev_warn(..., FW_BUG "devicetree clock missing");

Just a suggestion.
-- 
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar

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

* [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-13  9:26   ` Ezequiel Garcia
  0 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-09-13  9:26 UTC (permalink / raw)
  To: linux-arm-kernel

On 13 September 2014 00:23, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
>
> Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
> compatibility with previous device trees but document it as mandatory so newer
> device trees will include it.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Josh Wu <josh.wu@atmel.com>
> ---
> Changes in v5:
>  - Added a proper commit log
>
>  .../devicetree/bindings/mtd/atmel-nand.txt         |  2 ++
>  drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> index c4728839d0c1..6edc3b616e98 100644
> --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> @@ -36,6 +36,7 @@ Optional properties:
>      - reg : should specify the address and size used for NFC command registers,
>              NFC registers and NFC Sram. NFC Sram address and size can be absent
>              if don't want to use it.
> +    - clocks: phandle to the peripheral clock
>    - Optional properties:
>      - atmel,write-by-sram: boolean to enable NFC write by sram.
>
> @@ -98,6 +99,7 @@ nand0: nand at 40000000 {
>                 compatible = "atmel,sama5d3-nfc";
>                 #address-cells = <1>;
>                 #size-cells = <1>;
> +               clocks = <&hsmc_clk>
>                 reg = <
>                         0x70000000 0x10000000   /* NFC Command Registers */
>                         0xffffc000 0x00000070   /* NFC HSMC regs */
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 9c5f717bda54..d1e502f8dbd0 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -27,6 +27,7 @@
>   *
>   */
>
> +#include <linux/clk.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/slab.h>
>  #include <linux/module.h>
> @@ -96,6 +97,8 @@ struct atmel_nfc {
>         bool                    use_nfc_sram;
>         bool                    write_by_sram;
>
> +       struct clk              *clk;
> +
>         bool                    is_initialized;
>         struct completion       comp_ready;
>         struct completion       comp_cmd_done;
> @@ -2248,6 +2251,7 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>  {
>         struct atmel_nfc *nfc = &nand_nfc;
>         struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram;
> +       int ret;
>
>         nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         nfc->base_cmd_regs = devm_ioremap_resource(&pdev->dev, nfc_cmd_regs);
> @@ -2279,8 +2283,28 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>         nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff);
>         nfc_readl(nfc->hsmc_regs, SR);  /* clear the NFC_SR */
>
> +       nfc->clk = devm_clk_get(&pdev->dev, NULL);
> +       if (!IS_ERR(nfc->clk)) {
> +               ret = clk_prepare_enable(nfc->clk);
> +               if (ret)
> +                       return ret;
> +       } else {
> +               dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");

Looks much better now thanks. If the clock is not really optional, you
can consider this a firmware bug. We've used FW_BUG messages for these
cases
(see vim drivers/watchdog/orion_wdt.c), so you could write something like:

dev_warn(..., FW_BUG "devicetree clock missing");

Just a suggestion.
-- 
Ezequiel Garc?a, VanguardiaSur
www.vanguardiasur.com.ar

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

* Re: [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
  2014-09-13  9:26   ` Ezequiel Garcia
  (?)
@ 2014-09-13 10:59     ` Alexandre Belloni
  -1 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2014-09-13 10:59 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Josh Wu, Brian Norris, Boris Brezillon, Nicolas Ferre,
	linux-kernel, linux-mtd, David Woodhouse, linux-arm-kernel

Hi,

On 13/09/2014 at 10:26:18 +0100, Ezequiel Garcia wrote :
> > +       nfc->clk = devm_clk_get(&pdev->dev, NULL);
> > +       if (!IS_ERR(nfc->clk)) {
> > +               ret = clk_prepare_enable(nfc->clk);
> > +               if (ret)
> > +                       return ret;
> > +       } else {
> > +               dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");
> 
> Looks much better now thanks. If the clock is not really optional, you
> can consider this a firmware bug. We've used FW_BUG messages for these
> cases
> (see vim drivers/watchdog/orion_wdt.c), so you could write something like:
> 
> dev_warn(..., FW_BUG "devicetree clock missing");
> 

Yeah, I've considered using FW_WARN like Thomas suggested but I'm not
sure it really relates to device tree. Apart from x86, FW_WARN and
FW_BUG are only used on mvebu stuff ;)


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-13 10:59     ` Alexandre Belloni
  0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2014-09-13 10:59 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Boris Brezillon, Nicolas Ferre, linux-kernel, Josh Wu, linux-mtd,
	Brian Norris, David Woodhouse, linux-arm-kernel

Hi,

On 13/09/2014 at 10:26:18 +0100, Ezequiel Garcia wrote :
> > +       nfc->clk = devm_clk_get(&pdev->dev, NULL);
> > +       if (!IS_ERR(nfc->clk)) {
> > +               ret = clk_prepare_enable(nfc->clk);
> > +               if (ret)
> > +                       return ret;
> > +       } else {
> > +               dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");
> 
> Looks much better now thanks. If the clock is not really optional, you
> can consider this a firmware bug. We've used FW_BUG messages for these
> cases
> (see vim drivers/watchdog/orion_wdt.c), so you could write something like:
> 
> dev_warn(..., FW_BUG "devicetree clock missing");
> 

Yeah, I've considered using FW_WARN like Thomas suggested but I'm not
sure it really relates to device tree. Apart from x86, FW_WARN and
FW_BUG are only used on mvebu stuff ;)


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-13 10:59     ` Alexandre Belloni
  0 siblings, 0 replies; 12+ messages in thread
From: Alexandre Belloni @ 2014-09-13 10:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 13/09/2014 at 10:26:18 +0100, Ezequiel Garcia wrote :
> > +       nfc->clk = devm_clk_get(&pdev->dev, NULL);
> > +       if (!IS_ERR(nfc->clk)) {
> > +               ret = clk_prepare_enable(nfc->clk);
> > +               if (ret)
> > +                       return ret;
> > +       } else {
> > +               dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree");
> 
> Looks much better now thanks. If the clock is not really optional, you
> can consider this a firmware bug. We've used FW_BUG messages for these
> cases
> (see vim drivers/watchdog/orion_wdt.c), so you could write something like:
> 
> dev_warn(..., FW_BUG "devicetree clock missing");
> 

Yeah, I've considered using FW_WARN like Thomas suggested but I'm not
sure it really relates to device tree. Apart from x86, FW_WARN and
FW_BUG are only used on mvebu stuff ;)


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
  2014-09-12 23:23 ` Alexandre Belloni
  (?)
@ 2014-09-18  5:49   ` Brian Norris
  -1 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2014-09-18  5:49 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Josh Wu, David Woodhouse, Boris Brezillon, Nicolas Ferre,
	linux-mtd, linux-arm-kernel, linux-kernel

On Sat, Sep 13, 2014 at 01:23:59AM +0200, Alexandre Belloni wrote:
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
> compatibility with previous device trees but document it as mandatory so newer
> device trees will include it.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Josh Wu <josh.wu@atmel.com>
> ---
> Changes in v5:
>  - Added a proper commit log

Pushed to l2-mtd.git. Thanks!

Brian

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

* Re: [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-18  5:49   ` Brian Norris
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2014-09-18  5:49 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Boris Brezillon, Nicolas Ferre, linux-kernel, Josh Wu, linux-mtd,
	David Woodhouse, linux-arm-kernel

On Sat, Sep 13, 2014 at 01:23:59AM +0200, Alexandre Belloni wrote:
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
> compatibility with previous device trees but document it as mandatory so newer
> device trees will include it.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Josh Wu <josh.wu@atmel.com>
> ---
> Changes in v5:
>  - Added a proper commit log

Pushed to l2-mtd.git. Thanks!

Brian

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

* [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-18  5:49   ` Brian Norris
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Norris @ 2014-09-18  5:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Sep 13, 2014 at 01:23:59AM +0200, Alexandre Belloni wrote:
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Retrieve the NFC clock to make sure it is enabled. Make that optional to ensure
> compatibility with previous device trees but document it as mandatory so newer
> device trees will include it.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Josh Wu <josh.wu@atmel.com>
> ---
> Changes in v5:
>  - Added a proper commit log

Pushed to l2-mtd.git. Thanks!

Brian

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

end of thread, other threads:[~2014-09-18  5:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-12 23:23 [PATCHv5] mtd: nand: atmel_nand: retrieve NFC clock Alexandre Belloni
2014-09-12 23:23 ` Alexandre Belloni
2014-09-12 23:23 ` Alexandre Belloni
2014-09-13  9:26 ` Ezequiel Garcia
2014-09-13  9:26   ` Ezequiel Garcia
2014-09-13  9:26   ` Ezequiel Garcia
2014-09-13 10:59   ` Alexandre Belloni
2014-09-13 10:59     ` Alexandre Belloni
2014-09-13 10:59     ` Alexandre Belloni
2014-09-18  5:49 ` Brian Norris
2014-09-18  5:49   ` Brian Norris
2014-09-18  5:49   ` Brian Norris

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.