aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2014-12-15 06:59:09 -0500
committerBrian Norris <computersforpeace@gmail.com>2015-01-13 00:08:04 -0500
commit69d5af8d016c803420258a476789ec6e7e7844dc (patch)
tree993d41ac3ef12db23a802fcca55c2f431181bcb1 /drivers/mtd
parent5ecd3ea188fd60e5f663a956dbe23d61a99f504a (diff)
mtd: st_spi_fsm: Obtain and use EMI clock
ST's Common Clk Framework is now available. This patch ensures the FSM makes use of it by obtaining and enabling the EMI clock. If system fails to provide the EMI clock, we bomb out. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/st_spi_fsm.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index bebc8b5637c0..3451864b9f68 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/of.h> 26#include <linux/of.h>
27#include <linux/clk.h>
27 28
28#include "serial_flash_cmds.h" 29#include "serial_flash_cmds.h"
29 30
@@ -262,6 +263,7 @@ struct stfsm {
262 struct mtd_info mtd; 263 struct mtd_info mtd;
263 struct mutex lock; 264 struct mutex lock;
264 struct flash_info *info; 265 struct flash_info *info;
266 struct clk *clk;
265 267
266 uint32_t configuration; 268 uint32_t configuration;
267 uint32_t fifo_dir_delay; 269 uint32_t fifo_dir_delay;
@@ -1906,8 +1908,7 @@ static void stfsm_set_freq(struct stfsm *fsm, uint32_t spi_freq)
1906 uint32_t emi_freq; 1908 uint32_t emi_freq;
1907 uint32_t clk_div; 1909 uint32_t clk_div;
1908 1910
1909 /* TODO: Make this dynamic */ 1911 emi_freq = clk_get_rate(fsm->clk);
1910 emi_freq = STFSM_DEFAULT_EMI_FREQ;
1911 1912
1912 /* 1913 /*
1913 * Calculate clk_div - values between 2 and 128 1914 * Calculate clk_div - values between 2 and 128
@@ -2057,6 +2058,18 @@ static int stfsm_probe(struct platform_device *pdev)
2057 return PTR_ERR(fsm->base); 2058 return PTR_ERR(fsm->base);
2058 } 2059 }
2059 2060
2061 fsm->clk = devm_clk_get(&pdev->dev, NULL);
2062 if (IS_ERR(fsm->clk)) {
2063 dev_err(fsm->dev, "Couldn't find EMI clock.\n");
2064 return PTR_ERR(fsm->clk);
2065 }
2066
2067 ret = clk_prepare_enable(fsm->clk);
2068 if (ret) {
2069 dev_err(fsm->dev, "Failed to enable EMI clock.\n");
2070 return ret;
2071 }
2072
2060 mutex_init(&fsm->lock); 2073 mutex_init(&fsm->lock);
2061 2074
2062 ret = stfsm_init(fsm); 2075 ret = stfsm_init(fsm);
@@ -2121,6 +2134,28 @@ static int stfsm_remove(struct platform_device *pdev)
2121 return mtd_device_unregister(&fsm->mtd); 2134 return mtd_device_unregister(&fsm->mtd);
2122} 2135}
2123 2136
2137#ifdef CONFIG_PM_SLEEP
2138static int stfsmfsm_suspend(struct device *dev)
2139{
2140 struct stfsm *fsm = dev_get_drvdata(dev);
2141
2142 clk_disable_unprepare(fsm->clk);
2143
2144 return 0;
2145}
2146
2147static int stfsmfsm_resume(struct device *dev)
2148{
2149 struct stfsm *fsm = dev_get_drvdata(dev);
2150
2151 clk_prepare_enable(fsm->clk);
2152
2153 return 0;
2154}
2155#endif
2156
2157static SIMPLE_DEV_PM_OPS(stfsm_pm_ops, stfsmfsm_suspend, stfsmfsm_resume);
2158
2124static const struct of_device_id stfsm_match[] = { 2159static const struct of_device_id stfsm_match[] = {
2125 { .compatible = "st,spi-fsm", }, 2160 { .compatible = "st,spi-fsm", },
2126 {}, 2161 {},
@@ -2133,6 +2168,7 @@ static struct platform_driver stfsm_driver = {
2133 .driver = { 2168 .driver = {
2134 .name = "st-spi-fsm", 2169 .name = "st-spi-fsm",
2135 .of_match_table = stfsm_match, 2170 .of_match_table = stfsm_match,
2171 .pm = &stfsm_pm_ops,
2136 }, 2172 },
2137}; 2173};
2138module_platform_driver(stfsm_driver); 2174module_platform_driver(stfsm_driver);