diff options
author | Boris BREZILLON <boris.brezillon@free-electrons.com> | 2014-09-12 19:23:59 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-09-17 03:45:11 -0400 |
commit | 2d405ec5fdd5b6848beb820301d4fcaa3e2c4159 (patch) | |
tree | 578b734e079cf35ac3fadbd6ac9f26e713a6ba29 | |
parent | 55ab9ec99bbfb4450dfa9bc0fd9e2c5052f4c3f7 (diff) |
mtd: nand: atmel_nand: retrieve NFC clock
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>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r-- | Documentation/devicetree/bindings/mtd/atmel-nand.txt | 2 | ||||
-rw-r--r-- | drivers/mtd/nand/atmel_nand.c | 25 |
2 files changed, 27 insertions, 0 deletions
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: | |||
36 | - reg : should specify the address and size used for NFC command registers, | 36 | - reg : should specify the address and size used for NFC command registers, |
37 | NFC registers and NFC Sram. NFC Sram address and size can be absent | 37 | NFC registers and NFC Sram. NFC Sram address and size can be absent |
38 | if don't want to use it. | 38 | if don't want to use it. |
39 | - clocks: phandle to the peripheral clock | ||
39 | - Optional properties: | 40 | - Optional properties: |
40 | - atmel,write-by-sram: boolean to enable NFC write by sram. | 41 | - atmel,write-by-sram: boolean to enable NFC write by sram. |
41 | 42 | ||
@@ -98,6 +99,7 @@ nand0: nand@40000000 { | |||
98 | compatible = "atmel,sama5d3-nfc"; | 99 | compatible = "atmel,sama5d3-nfc"; |
99 | #address-cells = <1>; | 100 | #address-cells = <1>; |
100 | #size-cells = <1>; | 101 | #size-cells = <1>; |
102 | clocks = <&hsmc_clk> | ||
101 | reg = < | 103 | reg = < |
102 | 0x70000000 0x10000000 /* NFC Command Registers */ | 104 | 0x70000000 0x10000000 /* NFC Command Registers */ |
103 | 0xffffc000 0x00000070 /* NFC HSMC regs */ | 105 | 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 @@ | |||
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/clk.h> | ||
30 | #include <linux/dma-mapping.h> | 31 | #include <linux/dma-mapping.h> |
31 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
32 | #include <linux/module.h> | 33 | #include <linux/module.h> |
@@ -96,6 +97,8 @@ struct atmel_nfc { | |||
96 | bool use_nfc_sram; | 97 | bool use_nfc_sram; |
97 | bool write_by_sram; | 98 | bool write_by_sram; |
98 | 99 | ||
100 | struct clk *clk; | ||
101 | |||
99 | bool is_initialized; | 102 | bool is_initialized; |
100 | struct completion comp_ready; | 103 | struct completion comp_ready; |
101 | struct completion comp_cmd_done; | 104 | struct completion comp_cmd_done; |
@@ -2248,6 +2251,7 @@ static int atmel_nand_nfc_probe(struct platform_device *pdev) | |||
2248 | { | 2251 | { |
2249 | struct atmel_nfc *nfc = &nand_nfc; | 2252 | struct atmel_nfc *nfc = &nand_nfc; |
2250 | struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram; | 2253 | struct resource *nfc_cmd_regs, *nfc_hsmc_regs, *nfc_sram; |
2254 | int ret; | ||
2251 | 2255 | ||
2252 | nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2256 | nfc_cmd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
2253 | nfc->base_cmd_regs = devm_ioremap_resource(&pdev->dev, nfc_cmd_regs); | 2257 | 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) | |||
2279 | nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff); | 2283 | nfc_writel(nfc->hsmc_regs, IDR, 0xffffffff); |
2280 | nfc_readl(nfc->hsmc_regs, SR); /* clear the NFC_SR */ | 2284 | nfc_readl(nfc->hsmc_regs, SR); /* clear the NFC_SR */ |
2281 | 2285 | ||
2286 | nfc->clk = devm_clk_get(&pdev->dev, NULL); | ||
2287 | if (!IS_ERR(nfc->clk)) { | ||
2288 | ret = clk_prepare_enable(nfc->clk); | ||
2289 | if (ret) | ||
2290 | return ret; | ||
2291 | } else { | ||
2292 | dev_warn(&pdev->dev, "NFC clock missing, update your Device Tree"); | ||
2293 | } | ||
2294 | |||
2282 | nfc->is_initialized = true; | 2295 | nfc->is_initialized = true; |
2283 | dev_info(&pdev->dev, "NFC is probed.\n"); | 2296 | dev_info(&pdev->dev, "NFC is probed.\n"); |
2297 | |||
2298 | return 0; | ||
2299 | } | ||
2300 | |||
2301 | static int atmel_nand_nfc_remove(struct platform_device *pdev) | ||
2302 | { | ||
2303 | struct atmel_nfc *nfc = &nand_nfc; | ||
2304 | |||
2305 | if (!IS_ERR(nfc->clk)) | ||
2306 | clk_disable_unprepare(nfc->clk); | ||
2307 | |||
2284 | return 0; | 2308 | return 0; |
2285 | } | 2309 | } |
2286 | 2310 | ||
@@ -2297,6 +2321,7 @@ static struct platform_driver atmel_nand_nfc_driver = { | |||
2297 | .of_match_table = of_match_ptr(atmel_nand_nfc_match), | 2321 | .of_match_table = of_match_ptr(atmel_nand_nfc_match), |
2298 | }, | 2322 | }, |
2299 | .probe = atmel_nand_nfc_probe, | 2323 | .probe = atmel_nand_nfc_probe, |
2324 | .remove = atmel_nand_nfc_remove, | ||
2300 | }; | 2325 | }; |
2301 | 2326 | ||
2302 | static struct platform_driver atmel_nand_driver = { | 2327 | static struct platform_driver atmel_nand_driver = { |