diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-02-08 10:52:26 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-14 15:24:53 -0500 |
commit | 56fc0b42dc5aeb4ee2b10ab5785e28c87c83280a (patch) | |
tree | a4f4c700e95297726308227f8d9a47c3e96d5a27 /drivers/spi/spi-ep93xx.c | |
parent | 38dbfb59d1175ef458d006556061adeaa8751b72 (diff) |
spi: ep93xx: Convert to let spi core handle checking transfer speed
By setting master->max_speed_hz and master->min_speed_hz, spi core will handle
checking transfer speed. So we can remove the same checking in this driver.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Mika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-ep93xx.c')
-rw-r--r-- | drivers/spi/spi-ep93xx.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index 1bfaed6e4073..2f675d32df0e 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c | |||
@@ -73,8 +73,6 @@ | |||
73 | * @clk: clock for the controller | 73 | * @clk: clock for the controller |
74 | * @regs_base: pointer to ioremap()'d registers | 74 | * @regs_base: pointer to ioremap()'d registers |
75 | * @sspdr_phys: physical address of the SSPDR register | 75 | * @sspdr_phys: physical address of the SSPDR register |
76 | * @min_rate: minimum clock rate (in Hz) supported by the controller | ||
77 | * @max_rate: maximum clock rate (in Hz) supported by the controller | ||
78 | * @wait: wait here until given transfer is completed | 76 | * @wait: wait here until given transfer is completed |
79 | * @current_msg: message that is currently processed (or %NULL if none) | 77 | * @current_msg: message that is currently processed (or %NULL if none) |
80 | * @tx: current byte in transfer to transmit | 78 | * @tx: current byte in transfer to transmit |
@@ -95,8 +93,6 @@ struct ep93xx_spi { | |||
95 | struct clk *clk; | 93 | struct clk *clk; |
96 | void __iomem *regs_base; | 94 | void __iomem *regs_base; |
97 | unsigned long sspdr_phys; | 95 | unsigned long sspdr_phys; |
98 | unsigned long min_rate; | ||
99 | unsigned long max_rate; | ||
100 | struct completion wait; | 96 | struct completion wait; |
101 | struct spi_message *current_msg; | 97 | struct spi_message *current_msg; |
102 | size_t tx; | 98 | size_t tx; |
@@ -199,9 +195,9 @@ static void ep93xx_spi_disable_interrupts(const struct ep93xx_spi *espi) | |||
199 | * @div_scr: pointer to return the scr divider | 195 | * @div_scr: pointer to return the scr divider |
200 | */ | 196 | */ |
201 | static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi, | 197 | static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi, |
202 | unsigned long rate, | 198 | u32 rate, u8 *div_cpsr, u8 *div_scr) |
203 | u8 *div_cpsr, u8 *div_scr) | ||
204 | { | 199 | { |
200 | struct spi_master *master = platform_get_drvdata(espi->pdev); | ||
205 | unsigned long spi_clk_rate = clk_get_rate(espi->clk); | 201 | unsigned long spi_clk_rate = clk_get_rate(espi->clk); |
206 | int cpsr, scr; | 202 | int cpsr, scr; |
207 | 203 | ||
@@ -210,7 +206,7 @@ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi, | |||
210 | * controller. Note that minimum value is already checked in | 206 | * controller. Note that minimum value is already checked in |
211 | * ep93xx_spi_transfer_one_message(). | 207 | * ep93xx_spi_transfer_one_message(). |
212 | */ | 208 | */ |
213 | rate = clamp(rate, espi->min_rate, espi->max_rate); | 209 | rate = clamp(rate, master->min_speed_hz, master->max_speed_hz); |
214 | 210 | ||
215 | /* | 211 | /* |
216 | * Calculate divisors so that we can get speed according the | 212 | * Calculate divisors so that we can get speed according the |
@@ -735,13 +731,6 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master, | |||
735 | struct spi_message *msg) | 731 | struct spi_message *msg) |
736 | { | 732 | { |
737 | struct ep93xx_spi *espi = spi_master_get_devdata(master); | 733 | struct ep93xx_spi *espi = spi_master_get_devdata(master); |
738 | struct spi_transfer *t; | ||
739 | |||
740 | /* first validate each transfer */ | ||
741 | list_for_each_entry(t, &msg->transfers, transfer_list) { | ||
742 | if (t->speed_hz < espi->min_rate) | ||
743 | return -EINVAL; | ||
744 | } | ||
745 | 734 | ||
746 | msg->state = NULL; | 735 | msg->state = NULL; |
747 | msg->status = 0; | 736 | msg->status = 0; |
@@ -917,8 +906,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) | |||
917 | * Calculate maximum and minimum supported clock rates | 906 | * Calculate maximum and minimum supported clock rates |
918 | * for the controller. | 907 | * for the controller. |
919 | */ | 908 | */ |
920 | espi->max_rate = clk_get_rate(espi->clk) / 2; | 909 | master->max_speed_hz = clk_get_rate(espi->clk) / 2; |
921 | espi->min_rate = clk_get_rate(espi->clk) / (254 * 256); | 910 | master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); |
922 | espi->pdev = pdev; | 911 | espi->pdev = pdev; |
923 | 912 | ||
924 | espi->sspdr_phys = res->start + SSPDR; | 913 | espi->sspdr_phys = res->start + SSPDR; |