aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/spi-ep93xx.c21
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 */
201static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi, 197static 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;