linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] mtd: nand: atmel_nand: retrieve NFC clock
@ 2014-09-11 17:52 Alexandre Belloni
  2014-09-12  7:52 ` Nicolas Ferre
  2014-09-12  8:40 ` Josh Wu
  0 siblings, 2 replies; 4+ messages in thread
From: Alexandre Belloni @ 2014-09-11 17:52 UTC (permalink / raw)
  To: 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>

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---

Changes in v2:
 - reworked the error path to really make the clock optional
 - Documented the new optional property

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

diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
index c4728839d0c1..f71e2ebab15b 100644
--- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
+++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
@@ -38,6 +38,7 @@ Optional properties:
             if don't want to use it.
   - Optional properties:
     - atmel,write-by-sram: boolean to enable NFC write by sram.
+    - clocks: phandle to the peripheral clock if it exists
 
 Examples:
 nand0: nand@40000000,0 {
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 9c5f717bda54..69e0eb1ace54 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);
@@ -2281,6 +2285,26 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
 
 	nfc->is_initialized = true;
 	dev_info(&pdev->dev, "NFC is probed.\n");
+
+	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 is missing");
+	}
+
+	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] 4+ messages in thread

* Re: [PATCHv2] mtd: nand: atmel_nand: retrieve NFC clock
  2014-09-11 17:52 [PATCHv2] mtd: nand: atmel_nand: retrieve NFC clock Alexandre Belloni
@ 2014-09-12  7:52 ` Nicolas Ferre
  2014-09-12  8:48   ` Josh Wu
  2014-09-12  8:40 ` Josh Wu
  1 sibling, 1 reply; 4+ messages in thread
From: Nicolas Ferre @ 2014-09-12  7:52 UTC (permalink / raw)
  To: Alexandre Belloni, Brian Norris, Wu, Josh
  Cc: David Woodhouse, Boris Brezillon, linux-mtd, linux-arm-kernel,
	linux-kernel

On 11/09/2014 19:52, Alexandre Belloni :
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

You may need to add Josh Wu to the list because he is the "de-facto"
Maintainer of this driver.

Bye,

> ---
> 
> Changes in v2:
>  - reworked the error path to really make the clock optional
>  - Documented the new optional property
> 
>  .../devicetree/bindings/mtd/atmel-nand.txt         |  1 +
>  drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> index c4728839d0c1..f71e2ebab15b 100644
> --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> @@ -38,6 +38,7 @@ Optional properties:
>              if don't want to use it.
>    - Optional properties:
>      - atmel,write-by-sram: boolean to enable NFC write by sram.
> +    - clocks: phandle to the peripheral clock if it exists
>  
>  Examples:
>  nand0: nand@40000000,0 {
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 9c5f717bda54..69e0eb1ace54 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);
> @@ -2281,6 +2285,26 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>  
>  	nfc->is_initialized = true;
>  	dev_info(&pdev->dev, "NFC is probed.\n");
> +
> +	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 is missing");
> +	}
> +
> +	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 = {
> 


-- 
Nicolas Ferre

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

* Re: [PATCHv2] mtd: nand: atmel_nand: retrieve NFC clock
  2014-09-11 17:52 [PATCHv2] mtd: nand: atmel_nand: retrieve NFC clock Alexandre Belloni
  2014-09-12  7:52 ` Nicolas Ferre
@ 2014-09-12  8:40 ` Josh Wu
  1 sibling, 0 replies; 4+ messages in thread
From: Josh Wu @ 2014-09-12  8:40 UTC (permalink / raw)
  To: Alexandre Belloni, Brian Norris
  Cc: Boris Brezillon, Nicolas Ferre, linux-kernel, linux-mtd,
	David Woodhouse, linux-arm-kernel

Hi, Alexandre

On 9/12/2014 1:52 AM, Alexandre Belloni wrote:
> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>
> Changes in v2:
>   - reworked the error path to really make the clock optional
>   - Documented the new optional property
>
>   .../devicetree/bindings/mtd/atmel-nand.txt         |  1 +
>   drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
>   2 files changed, 26 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> index c4728839d0c1..f71e2ebab15b 100644
> --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
> @@ -38,6 +38,7 @@ Optional properties:
>               if don't want to use it.
>     - Optional properties:
>       - atmel,write-by-sram: boolean to enable NFC write by sram.
> +    - clocks: phandle to the peripheral clock if it exists
>   
>   Examples:
>   nand0: nand@40000000,0 {
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 9c5f717bda54..69e0eb1ace54 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);
> @@ -2281,6 +2285,26 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>   
>   	nfc->is_initialized = true;
>   	dev_info(&pdev->dev, "NFC is probed.\n");
> +
> +	nfc->clk = devm_clk_get(&pdev->dev, NULL);
> +	if (!IS_ERR(nfc->clk)) {
> +		ret = clk_prepare_enable(nfc->clk);
> +		if (ret)
> +			return ret;

In this case, the NFC clock is not enabled, so I think 
nfc->is_initialized should set to false.
Otherwise, the nand driver will try to use the NFC without enabled the 
clock.

Is it better to move the code block

    nfc->is_initialized = true;
    dev_info(&pdev->dev, "NFC is probed.\n");

to just before the:

    return 0;


Best Regards,
Josh Wu
> +	} else {
> +		dev_warn(&pdev->dev, "NFC clock is missing");
> +	}
> +
> +	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 = {


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

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

Hi, Nicolas

On 9/12/2014 3:52 PM, Nicolas Ferre wrote:
> On 11/09/2014 19:52, Alexandre Belloni :
>> From: Boris BREZILLON <boris.brezillon@free-electrons.com>
>>
>> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> You may need to add Josh Wu to the list because he is the "de-facto"
> Maintainer of this driver.

Thanks for the email.
I almost miss it.

Best Regards,
Josh Wu
>
> Bye,
>
>> ---
>>
>> Changes in v2:
>>   - reworked the error path to really make the clock optional
>>   - Documented the new optional property
>>
>>   .../devicetree/bindings/mtd/atmel-nand.txt         |  1 +
>>   drivers/mtd/nand/atmel_nand.c                      | 25 ++++++++++++++++++++++
>>   2 files changed, 26 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
>> index c4728839d0c1..f71e2ebab15b 100644
>> --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt
>> +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt
>> @@ -38,6 +38,7 @@ Optional properties:
>>               if don't want to use it.
>>     - Optional properties:
>>       - atmel,write-by-sram: boolean to enable NFC write by sram.
>> +    - clocks: phandle to the peripheral clock if it exists
>>   
>>   Examples:
>>   nand0: nand@40000000,0 {
>> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
>> index 9c5f717bda54..69e0eb1ace54 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);
>> @@ -2281,6 +2285,26 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev)
>>   
>>   	nfc->is_initialized = true;
>>   	dev_info(&pdev->dev, "NFC is probed.\n");
>> +
>> +	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 is missing");
>> +	}
>> +
>> +	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 = {
>>
>


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

end of thread, other threads:[~2014-09-12  8:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-11 17:52 [PATCHv2] mtd: nand: atmel_nand: retrieve NFC clock Alexandre Belloni
2014-09-12  7:52 ` Nicolas Ferre
2014-09-12  8:48   ` Josh Wu
2014-09-12  8:40 ` Josh Wu

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