aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-tegra20-sflash.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-tegra20-sflash.c')
-rw-r--r--drivers/spi/spi-tegra20-sflash.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index e6f382b33818..08794977f21a 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -149,14 +149,14 @@ struct tegra_sflash_data {
149static int tegra_sflash_runtime_suspend(struct device *dev); 149static int tegra_sflash_runtime_suspend(struct device *dev);
150static int tegra_sflash_runtime_resume(struct device *dev); 150static int tegra_sflash_runtime_resume(struct device *dev);
151 151
152static inline unsigned long tegra_sflash_readl(struct tegra_sflash_data *tsd, 152static inline u32 tegra_sflash_readl(struct tegra_sflash_data *tsd,
153 unsigned long reg) 153 unsigned long reg)
154{ 154{
155 return readl(tsd->base + reg); 155 return readl(tsd->base + reg);
156} 156}
157 157
158static inline void tegra_sflash_writel(struct tegra_sflash_data *tsd, 158static inline void tegra_sflash_writel(struct tegra_sflash_data *tsd,
159 unsigned long val, unsigned long reg) 159 u32 val, unsigned long reg)
160{ 160{
161 writel(val, tsd->base + reg); 161 writel(val, tsd->base + reg);
162} 162}
@@ -186,7 +186,7 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf(
186 struct tegra_sflash_data *tsd, struct spi_transfer *t) 186 struct tegra_sflash_data *tsd, struct spi_transfer *t)
187{ 187{
188 unsigned nbytes; 188 unsigned nbytes;
189 unsigned long status; 189 u32 status;
190 unsigned max_n_32bit = tsd->curr_xfer_words; 190 unsigned max_n_32bit = tsd->curr_xfer_words;
191 u8 *tx_buf = (u8 *)t->tx_buf + tsd->cur_tx_pos; 191 u8 *tx_buf = (u8 *)t->tx_buf + tsd->cur_tx_pos;
192 192
@@ -197,11 +197,11 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf(
197 status = tegra_sflash_readl(tsd, SPI_STATUS); 197 status = tegra_sflash_readl(tsd, SPI_STATUS);
198 while (!(status & SPI_TXF_FULL)) { 198 while (!(status & SPI_TXF_FULL)) {
199 int i; 199 int i;
200 unsigned int x = 0; 200 u32 x = 0;
201 201
202 for (i = 0; nbytes && (i < tsd->bytes_per_word); 202 for (i = 0; nbytes && (i < tsd->bytes_per_word);
203 i++, nbytes--) 203 i++, nbytes--)
204 x |= ((*tx_buf++) << i*8); 204 x |= (u32)(*tx_buf++) << (i * 8);
205 tegra_sflash_writel(tsd, x, SPI_TX_FIFO); 205 tegra_sflash_writel(tsd, x, SPI_TX_FIFO);
206 if (!nbytes) 206 if (!nbytes)
207 break; 207 break;
@@ -215,16 +215,14 @@ static unsigned tegra_sflash_fill_tx_fifo_from_client_txbuf(
215static int tegra_sflash_read_rx_fifo_to_client_rxbuf( 215static int tegra_sflash_read_rx_fifo_to_client_rxbuf(
216 struct tegra_sflash_data *tsd, struct spi_transfer *t) 216 struct tegra_sflash_data *tsd, struct spi_transfer *t)
217{ 217{
218 unsigned long status; 218 u32 status;
219 unsigned int read_words = 0; 219 unsigned int read_words = 0;
220 u8 *rx_buf = (u8 *)t->rx_buf + tsd->cur_rx_pos; 220 u8 *rx_buf = (u8 *)t->rx_buf + tsd->cur_rx_pos;
221 221
222 status = tegra_sflash_readl(tsd, SPI_STATUS); 222 status = tegra_sflash_readl(tsd, SPI_STATUS);
223 while (!(status & SPI_RXF_EMPTY)) { 223 while (!(status & SPI_RXF_EMPTY)) {
224 int i; 224 int i;
225 unsigned long x; 225 u32 x = tegra_sflash_readl(tsd, SPI_RX_FIFO);
226
227 x = tegra_sflash_readl(tsd, SPI_RX_FIFO);
228 for (i = 0; (i < tsd->bytes_per_word); i++) 226 for (i = 0; (i < tsd->bytes_per_word); i++)
229 *rx_buf++ = (x >> (i*8)) & 0xFF; 227 *rx_buf++ = (x >> (i*8)) & 0xFF;
230 read_words++; 228 read_words++;
@@ -237,7 +235,7 @@ static int tegra_sflash_read_rx_fifo_to_client_rxbuf(
237static int tegra_sflash_start_cpu_based_transfer( 235static int tegra_sflash_start_cpu_based_transfer(
238 struct tegra_sflash_data *tsd, struct spi_transfer *t) 236 struct tegra_sflash_data *tsd, struct spi_transfer *t)
239{ 237{
240 unsigned long val = 0; 238 u32 val = 0;
241 unsigned cur_words; 239 unsigned cur_words;
242 240
243 if (tsd->cur_direction & DATA_DIR_TX) 241 if (tsd->cur_direction & DATA_DIR_TX)
@@ -267,7 +265,7 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,
267{ 265{
268 struct tegra_sflash_data *tsd = spi_master_get_devdata(spi->master); 266 struct tegra_sflash_data *tsd = spi_master_get_devdata(spi->master);
269 u32 speed; 267 u32 speed;
270 unsigned long command; 268 u32 command;
271 269
272 speed = t->speed_hz; 270 speed = t->speed_hz;
273 if (speed != tsd->cur_speed) { 271 if (speed != tsd->cur_speed) {
@@ -314,7 +312,7 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,
314 tegra_sflash_writel(tsd, command, SPI_COMMAND); 312 tegra_sflash_writel(tsd, command, SPI_COMMAND);
315 tsd->command_reg = command; 313 tsd->command_reg = command;
316 314
317 return tegra_sflash_start_cpu_based_transfer(tsd, t); 315 return tegra_sflash_start_cpu_based_transfer(tsd, t);
318} 316}
319 317
320static int tegra_sflash_setup(struct spi_device *spi) 318static int tegra_sflash_setup(struct spi_device *spi)