| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 NVIDIA Corporation | 2 * Copyright (c) 2010 NVIDIA Corporation |
| 3 * With help from the mpc8xxx SPI driver | 3 * With help from the mpc8xxx SPI driver |
| 4 * | 4 * |
| 5 * See file CREDITS for list of people who contributed to this | 5 * See file CREDITS for list of people who contributed to this |
| 6 * project. | 6 * project. |
| 7 * | 7 * |
| 8 * This program is free software; you can redistribute it and/or | 8 * This program is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU General Public License as | 9 * modify it under the terms of the GNU General Public License as |
| 10 * published by the Free Software Foundation; either version 2 of | 10 * published by the Free Software Foundation; either version 2 of |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void spi_release_bus(struct spi_slave *slave) | 148 void spi_release_bus(struct spi_slave *slave) |
| 149 { | 149 { |
| 150 /* Release UART_DISABLE and set pinmux to UART4 here? */ | 150 /* Release UART_DISABLE and set pinmux to UART4 here? */ |
| 151 } | 151 } |
| 152 | 152 |
| 153 void spi_cs_activate(struct spi_slave *slave) | 153 void spi_cs_activate(struct spi_slave *slave) |
| 154 { | 154 { |
| 155 volatile spi_tegra_t *spi = (spi_tegra_t *)TEGRA2_SPI_BASE; | 155 volatile spi_tegra_t *spi = (spi_tegra_t *)TEGRA2_SPI_BASE; |
| 156 u32 val; | 156 u32 val; |
| 157 | 157 |
| 158 » /* | 158 #ifdef CONFIG_SPI_CORRUPTS_UART |
| 159 » * Delay here to clean up comms - spurious chars seen around SPI xfers. | 159 » NS16550_drain(CONFIG_SPI_CORRUPTS_UART); |
| 160 » * Fine-tune later. | 160 #endif |
| 161 » */ | |
| 162 » udelay(1000); | |
| 163 | |
| 164 /* | 161 /* |
| 165 * We need to dynamically change the pinmux, shared w/UART RXD/CTS! | 162 * We need to dynamically change the pinmux, shared w/UART RXD/CTS! |
| 166 */ | 163 */ |
| 167 | 164 |
| 168 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); | 165 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); |
| 169 val |= 0x0000000C; /* 3 = SFLASH */ | 166 val |= 0x0000000C; /* 3 = SFLASH */ |
| 170 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); | 167 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); |
| 171 debug("spi_init: PinMuxRegB = %08x\n", val); | 168 debug("spi_init: PinMuxRegB = %08x\n", val); |
| 172 | 169 |
| 173 /* On Seaboard, MOSI/MISO are shared w/UART. | 170 /* On Seaboard, MOSI/MISO are shared w/UART. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 186 debug("spi_cs_activate: CS driven %s\n", | 183 debug("spi_cs_activate: CS driven %s\n", |
| 187 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); | 184 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); |
| 188 } | 185 } |
| 189 | 186 |
| 190 void spi_cs_deactivate(struct spi_slave *slave) | 187 void spi_cs_deactivate(struct spi_slave *slave) |
| 191 { | 188 { |
| 192 volatile spi_tegra_t *spi = (spi_tegra_t *) TEGRA2_SPI_BASE; | 189 volatile spi_tegra_t *spi = (spi_tegra_t *) TEGRA2_SPI_BASE; |
| 193 u32 val; | 190 u32 val; |
| 194 | 191 |
| 195 /* | 192 /* |
| 196 * Delay here to clean up comms - spurious chars seen around SPI xfers. | |
| 197 * Fine-tune later. | |
| 198 */ | |
| 199 udelay(1000); | |
| 200 | |
| 201 /* | |
| 202 * Looks like we may also need to dynamically change the pinmux, | 193 * Looks like we may also need to dynamically change the pinmux, |
| 203 * shared w/UART RXD/CTS! | 194 * shared w/UART RXD/CTS! |
| 204 */ | 195 */ |
| 205 | 196 |
| 206 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); | 197 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); |
| 207 val &= 0xFFFFFFF3; /* 0 = UART */ | 198 val &= 0xFFFFFFF3; /* 0 = UART */ |
| 208 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); | 199 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); |
| 209 debug("spi_init: PinMuxRegB = %08x\n", val); | 200 debug("spi_init: PinMuxRegB = %08x\n", val); |
| 210 | 201 |
| 211 /* On Seaboard, MOSI/MISO are shared w/UART. | 202 /* On Seaboard, MOSI/MISO are shared w/UART. |
| 212 * GPIO I3 (UART_DISABLE) was used to tristate UART in cs_activate. | 203 * GPIO I3 (UART_DISABLE) was used to tristate UART in cs_activate. |
| 213 * Enable UART here by setting that GPIO to 0 so we can do U-Boot comms. | 204 * Enable UART here by setting that GPIO to 0 so we can do U-Boot comms. |
| 214 */ | 205 */ |
| 215 | 206 |
| 216 tg2_gpio_direction_output(UART_DISABLE_PORT, UART_DISABLE_BIT, 0); | 207 tg2_gpio_direction_output(UART_DISABLE_PORT, UART_DISABLE_BIT, 0); |
| 217 debug("spi_cs_deactivate: ENABLED UART!\n"); | 208 debug("spi_cs_deactivate: ENABLED UART!\n"); |
| 218 /* | 209 /* |
| 219 * CS is negated on Tegra, so drive a 0 to get a 1 | 210 * CS is negated on Tegra, so drive a 0 to get a 1 |
| 220 */ | 211 */ |
| 221 spi->command &= ~SPI_CMD_CS_VAL; | 212 spi->command &= ~SPI_CMD_CS_VAL; |
| 222 | 213 |
| 223 debug("spi_cs_deactivate: CS driven %s\n", | 214 debug("spi_cs_deactivate: CS driven %s\n", |
| 224 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); | 215 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); |
| 216 |
| 217 #ifdef CONFIG_SPI_CORRUPTS_UART |
| 218 udelay(100); |
| 219 NS16550_clear(CONFIG_SPI_CORRUPTS_UART); |
| 220 #endif |
| 225 } | 221 } |
| 226 | 222 |
| 227 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, | 223 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, |
| 228 void *din, unsigned long flags) | 224 void *din, unsigned long flags) |
| 229 { | 225 { |
| 230 volatile spi_tegra_t *spi = (spi_tegra_t *)TEGRA2_SPI_BASE; | 226 volatile spi_tegra_t *spi = (spi_tegra_t *)TEGRA2_SPI_BASE; |
| 231 unsigned int tmpdin, status; | 227 unsigned int tmpdin, status; |
| 232 int numBytes = (bitlen + 7) / 8; | 228 int numBytes = (bitlen + 7) / 8; |
| 233 int ret, tm, isRead = 0; | 229 int ret, tm, isRead = 0; |
| 234 | 230 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 spi->status = status; /* ACK RDY, etc. bits */ | 331 spi->status = status; /* ACK RDY, etc. bits */ |
| 336 } | 332 } |
| 337 | 333 |
| 338 if (flags & SPI_XFER_END) | 334 if (flags & SPI_XFER_END) |
| 339 spi_cs_deactivate(slave); | 335 spi_cs_deactivate(slave); |
| 340 | 336 |
| 341 debug("spi_xfer: transfer ended. Value=%08x, status = %08x\n", | 337 debug("spi_xfer: transfer ended. Value=%08x, status = %08x\n", |
| 342 tmpdin, status); | 338 tmpdin, status); |
| 343 return ret; | 339 return ret; |
| 344 } | 340 } |
| OLD | NEW |