diff options
| author | Andrew Lunn <andrew@lunn.ch> | 2012-02-19 05:01:22 -0500 |
|---|---|---|
| committer | Mike Turquette <mturquette@linaro.org> | 2012-05-08 19:33:59 -0400 |
| commit | 9c2bd504b55ce3e680ae0d3768e78c15fef3448d (patch) | |
| tree | 01ca9fcb81c8d0bdf6680ceeb071f0120ad89c44 | |
| parent | 8c869edaee07c623066266827371235fb9c12e01 (diff) | |
ARM: Orion: NAND: Add support for clk, if there is one.
Not all orion platforms can gate the clock, but if it does exist,
enable/disable it as appropriate.
v2: Fix the name of the clkdev entry.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Jamie Lentin <jm@lentin.co.uk>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
| -rw-r--r-- | arch/arm/mach-kirkwood/common.c | 1 | ||||
| -rw-r--r-- | drivers/mtd/nand/orion_nand.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c index b0f20c0c7d54..99adebce7073 100644 --- a/arch/arm/mach-kirkwood/common.c +++ b/arch/arm/mach-kirkwood/common.c | |||
| @@ -116,6 +116,7 @@ void __init kirkwood_clk_init(void) | |||
| 116 | orion_clkdev_add("0", "sata_mv.0", sata0); | 116 | orion_clkdev_add("0", "sata_mv.0", sata0); |
| 117 | orion_clkdev_add("1", "sata_mv.0", sata1); | 117 | orion_clkdev_add("1", "sata_mv.0", sata1); |
| 118 | orion_clkdev_add(NULL, "orion-ehci.0", usb0); | 118 | orion_clkdev_add(NULL, "orion-ehci.0", usb0); |
| 119 | orion_clkdev_add(NULL, "orion_nand", runit); | ||
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | /***************************************************************************** | 122 | /***************************************************************************** |
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c index 1d3bfb26080c..fdc4786ea3e5 100644 --- a/drivers/mtd/nand/orion_nand.c +++ b/drivers/mtd/nand/orion_nand.c | |||
| @@ -16,6 +16,8 @@ | |||
| 16 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
| 17 | #include <linux/mtd/nand.h> | 17 | #include <linux/mtd/nand.h> |
| 18 | #include <linux/mtd/partitions.h> | 18 | #include <linux/mtd/partitions.h> |
| 19 | #include <linux/clk.h> | ||
| 20 | #include <linux/err.h> | ||
| 19 | #include <asm/io.h> | 21 | #include <asm/io.h> |
| 20 | #include <asm/sizes.h> | 22 | #include <asm/sizes.h> |
| 21 | #include <mach/hardware.h> | 23 | #include <mach/hardware.h> |
| @@ -77,6 +79,7 @@ static int __init orion_nand_probe(struct platform_device *pdev) | |||
| 77 | struct nand_chip *nc; | 79 | struct nand_chip *nc; |
| 78 | struct orion_nand_data *board; | 80 | struct orion_nand_data *board; |
| 79 | struct resource *res; | 81 | struct resource *res; |
| 82 | struct clk *clk; | ||
| 80 | void __iomem *io_base; | 83 | void __iomem *io_base; |
| 81 | int ret = 0; | 84 | int ret = 0; |
| 82 | 85 | ||
| @@ -123,6 +126,14 @@ static int __init orion_nand_probe(struct platform_device *pdev) | |||
| 123 | 126 | ||
| 124 | platform_set_drvdata(pdev, mtd); | 127 | platform_set_drvdata(pdev, mtd); |
| 125 | 128 | ||
| 129 | /* Not all platforms can gate the clock, so it is not | ||
| 130 | an error if the clock does not exists. */ | ||
| 131 | clk = clk_get(&pdev->dev, NULL); | ||
| 132 | if (!IS_ERR(clk)) { | ||
| 133 | clk_prepare_enable(clk); | ||
| 134 | clk_put(clk); | ||
| 135 | } | ||
| 136 | |||
| 126 | if (nand_scan(mtd, 1)) { | 137 | if (nand_scan(mtd, 1)) { |
| 127 | ret = -ENXIO; | 138 | ret = -ENXIO; |
| 128 | goto no_dev; | 139 | goto no_dev; |
| @@ -151,6 +162,7 @@ static int __devexit orion_nand_remove(struct platform_device *pdev) | |||
| 151 | { | 162 | { |
| 152 | struct mtd_info *mtd = platform_get_drvdata(pdev); | 163 | struct mtd_info *mtd = platform_get_drvdata(pdev); |
| 153 | struct nand_chip *nc = mtd->priv; | 164 | struct nand_chip *nc = mtd->priv; |
| 165 | struct clk *clk; | ||
| 154 | 166 | ||
| 155 | nand_release(mtd); | 167 | nand_release(mtd); |
| 156 | 168 | ||
| @@ -158,6 +170,12 @@ static int __devexit orion_nand_remove(struct platform_device *pdev) | |||
| 158 | 170 | ||
| 159 | kfree(nc); | 171 | kfree(nc); |
| 160 | 172 | ||
| 173 | clk = clk_get(&pdev->dev, NULL); | ||
| 174 | if (!IS_ERR(clk)) { | ||
| 175 | clk_disable_unprepare(clk); | ||
| 176 | clk_put(clk); | ||
| 177 | } | ||
| 178 | |||
| 161 | return 0; | 179 | return 0; |
| 162 | } | 180 | } |
| 163 | 181 | ||
