summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2014-09-20 03:05:09 -0400
committerMark Brown <broonie@kernel.org>2014-09-24 04:40:24 -0400
commita5b4b234e15b68539dd4677bb8b0aeeef100fbba (patch)
treea380e53313c30709bfc98578ba43c642aed3561a
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff)
spi: clps711x: Migrate to the new clk subsystem
Currently clps711x arch have a fully functional CLK driver. This patch migrates clps711x-spi driver to use the new CLK subsystem. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-clps711x.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c
index ce538dad526b..181cf2262006 100644
--- a/drivers/spi/spi-clps711x.c
+++ b/drivers/spi/spi-clps711x.c
@@ -30,7 +30,6 @@
30struct spi_clps711x_data { 30struct spi_clps711x_data {
31 void __iomem *syncio; 31 void __iomem *syncio;
32 struct regmap *syscon; 32 struct regmap *syscon;
33 struct regmap *syscon1;
34 struct clk *spi_clk; 33 struct clk *spi_clk;
35 34
36 u8 *tx_buf; 35 u8 *tx_buf;
@@ -47,27 +46,6 @@ static int spi_clps711x_setup(struct spi_device *spi)
47 return 0; 46 return 0;
48} 47}
49 48
50static void spi_clps711x_setup_xfer(struct spi_device *spi,
51 struct spi_transfer *xfer)
52{
53 struct spi_master *master = spi->master;
54 struct spi_clps711x_data *hw = spi_master_get_devdata(master);
55
56 /* Setup SPI frequency divider */
57 if (xfer->speed_hz >= master->max_speed_hz)
58 regmap_update_bits(hw->syscon1, SYSCON_OFFSET,
59 SYSCON1_ADCKSEL_MASK, SYSCON1_ADCKSEL(3));
60 else if (xfer->speed_hz >= (master->max_speed_hz / 2))
61 regmap_update_bits(hw->syscon1, SYSCON_OFFSET,
62 SYSCON1_ADCKSEL_MASK, SYSCON1_ADCKSEL(2));
63 else if (xfer->speed_hz >= (master->max_speed_hz / 8))
64 regmap_update_bits(hw->syscon1, SYSCON_OFFSET,
65 SYSCON1_ADCKSEL_MASK, SYSCON1_ADCKSEL(1));
66 else
67 regmap_update_bits(hw->syscon1, SYSCON_OFFSET,
68 SYSCON1_ADCKSEL_MASK, SYSCON1_ADCKSEL(0));
69}
70
71static int spi_clps711x_prepare_message(struct spi_master *master, 49static int spi_clps711x_prepare_message(struct spi_master *master,
72 struct spi_message *msg) 50 struct spi_message *msg)
73{ 51{
@@ -87,7 +65,7 @@ static int spi_clps711x_transfer_one(struct spi_master *master,
87 struct spi_clps711x_data *hw = spi_master_get_devdata(master); 65 struct spi_clps711x_data *hw = spi_master_get_devdata(master);
88 u8 data; 66 u8 data;
89 67
90 spi_clps711x_setup_xfer(spi, xfer); 68 clk_set_rate(hw->spi_clk, xfer->speed_hz ? : spi->max_speed_hz);
91 69
92 hw->len = xfer->len; 70 hw->len = xfer->len;
93 hw->bpw = xfer->bits_per_word; 71 hw->bpw = xfer->bits_per_word;
@@ -176,13 +154,11 @@ static int spi_clps711x_probe(struct platform_device *pdev)
176 } 154 }
177 } 155 }
178 156
179 hw->spi_clk = devm_clk_get(&pdev->dev, "spi"); 157 hw->spi_clk = devm_clk_get(&pdev->dev, NULL);
180 if (IS_ERR(hw->spi_clk)) { 158 if (IS_ERR(hw->spi_clk)) {
181 dev_err(&pdev->dev, "Can't get clocks\n");
182 ret = PTR_ERR(hw->spi_clk); 159 ret = PTR_ERR(hw->spi_clk);
183 goto err_out; 160 goto err_out;
184 } 161 }
185 master->max_speed_hz = clk_get_rate(hw->spi_clk);
186 162
187 hw->syscon = syscon_regmap_lookup_by_pdevname("syscon.3"); 163 hw->syscon = syscon_regmap_lookup_by_pdevname("syscon.3");
188 if (IS_ERR(hw->syscon)) { 164 if (IS_ERR(hw->syscon)) {
@@ -190,12 +166,6 @@ static int spi_clps711x_probe(struct platform_device *pdev)
190 goto err_out; 166 goto err_out;
191 } 167 }
192 168
193 hw->syscon1 = syscon_regmap_lookup_by_pdevname("syscon.1");
194 if (IS_ERR(hw->syscon1)) {
195 ret = PTR_ERR(hw->syscon1);
196 goto err_out;
197 }
198
199 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
200 hw->syncio = devm_ioremap_resource(&pdev->dev, res); 170 hw->syncio = devm_ioremap_resource(&pdev->dev, res);
201 if (IS_ERR(hw->syncio)) { 171 if (IS_ERR(hw->syncio)) {