Chromium Code Reviews| 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 » NS16550_clear(CONFIG_SPI_CORRUPTS_UART); |
|
robotboy
2011/03/25 00:18:23
Is clear strictly required here? Is just calling
| |
| 161 » */ | 161 #endif |
| 162 » udelay(1000); | |
| 163 | |
| 164 /* | 162 /* |
| 165 * We need to dynamically change the pinmux, shared w/UART RXD/CTS! | 163 * We need to dynamically change the pinmux, shared w/UART RXD/CTS! |
| 166 */ | 164 */ |
| 167 | 165 |
| 168 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); | 166 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); |
| 169 val |= 0x0000000C; /* 3 = SFLASH */ | 167 val |= 0x0000000C; /* 3 = SFLASH */ |
| 170 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); | 168 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); |
| 171 debug("spi_init: PinMuxRegB = %08x\n", val); | 169 debug("spi_init: PinMuxRegB = %08x\n", val); |
| 172 | 170 |
| 173 /* On Seaboard, MOSI/MISO are shared w/UART. | 171 /* On Seaboard, MOSI/MISO are shared w/UART. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 186 debug("spi_cs_activate: CS driven %s\n", | 184 debug("spi_cs_activate: CS driven %s\n", |
| 187 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); | 185 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); |
| 188 } | 186 } |
| 189 | 187 |
| 190 void spi_cs_deactivate(struct spi_slave *slave) | 188 void spi_cs_deactivate(struct spi_slave *slave) |
| 191 { | 189 { |
| 192 volatile spi_tegra_t *spi = (spi_tegra_t *) TEGRA2_SPI_BASE; | 190 volatile spi_tegra_t *spi = (spi_tegra_t *) TEGRA2_SPI_BASE; |
| 193 u32 val; | 191 u32 val; |
| 194 | 192 |
| 195 /* | 193 /* |
| 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, | 194 * Looks like we may also need to dynamically change the pinmux, |
| 203 * shared w/UART RXD/CTS! | 195 * shared w/UART RXD/CTS! |
| 204 */ | 196 */ |
| 205 | 197 |
| 206 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); | 198 val = NV_READ32(NV_ADDRESS_MAP_APB_MISC_BASE + 0x84); |
| 207 val &= 0xFFFFFFF3; /* 0 = UART */ | 199 val &= 0xFFFFFFF3; /* 0 = UART */ |
| 208 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); | 200 NV_WRITE32((NV_ADDRESS_MAP_APB_MISC_BASE + 0x84), val); |
| 209 debug("spi_init: PinMuxRegB = %08x\n", val); | 201 debug("spi_init: PinMuxRegB = %08x\n", val); |
| 210 | 202 |
| 211 /* On Seaboard, MOSI/MISO are shared w/UART. | 203 /* On Seaboard, MOSI/MISO are shared w/UART. |
| 212 * GPIO I3 (UART_DISABLE) was used to tristate UART in cs_activate. | 204 * 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. | 205 * Enable UART here by setting that GPIO to 0 so we can do U-Boot comms. |
| 214 */ | 206 */ |
| 215 | 207 |
| 216 tg2_gpio_direction_output(UART_DISABLE_PORT, UART_DISABLE_BIT, 0); | 208 tg2_gpio_direction_output(UART_DISABLE_PORT, UART_DISABLE_BIT, 0); |
| 217 debug("spi_cs_deactivate: ENABLED UART!\n"); | 209 debug("spi_cs_deactivate: ENABLED UART!\n"); |
| 218 /* | 210 /* |
| 219 * CS is negated on Tegra, so drive a 0 to get a 1 | 211 * CS is negated on Tegra, so drive a 0 to get a 1 |
| 220 */ | 212 */ |
| 221 spi->command &= ~SPI_CMD_CS_VAL; | 213 spi->command &= ~SPI_CMD_CS_VAL; |
| 222 | 214 |
| 223 debug("spi_cs_deactivate: CS driven %s\n", | 215 debug("spi_cs_deactivate: CS driven %s\n", |
| 224 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); | 216 (spi->command & SPI_CMD_CS_VAL) ? "LOW" : "HIGH"); |
| 217 | |
| 218 #ifdef CONFIG_SPI_CORRUPTS_UART | |
| 219 NS16550_drain(CONFIG_SPI_CORRUPTS_UART); | |
|
robotboy
2011/03/25 00:18:23
Same question as above, except in this case is dra
| |
| 220 NS16550_clear(CONFIG_SPI_CORRUPTS_UART); | |
| 221 #endif | |
| 225 } | 222 } |
| 226 | 223 |
| 227 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, | 224 int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, |
| 228 void *din, unsigned long flags) | 225 void *din, unsigned long flags) |
| 229 { | 226 { |
| 230 volatile spi_tegra_t *spi = (spi_tegra_t *)TEGRA2_SPI_BASE; | 227 volatile spi_tegra_t *spi = (spi_tegra_t *)TEGRA2_SPI_BASE; |
| 231 unsigned int tmpdin, status; | 228 unsigned int tmpdin, status; |
| 232 int numBytes = (bitlen + 7) / 8; | 229 int numBytes = (bitlen + 7) / 8; |
| 233 int ret, tm, isRead = 0; | 230 int ret, tm, isRead = 0; |
| 234 | 231 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 spi->status = status; /* ACK RDY, etc. bits */ | 332 spi->status = status; /* ACK RDY, etc. bits */ |
| 336 } | 333 } |
| 337 | 334 |
| 338 if (flags & SPI_XFER_END) | 335 if (flags & SPI_XFER_END) |
| 339 spi_cs_deactivate(slave); | 336 spi_cs_deactivate(slave); |
| 340 | 337 |
| 341 debug("spi_xfer: transfer ended. Value=%08x, status = %08x\n", | 338 debug("spi_xfer: transfer ended. Value=%08x, status = %08x\n", |
| 342 tmpdin, status); | 339 tmpdin, status); |
| 343 return ret; | 340 return ret; |
| 344 } | 341 } |
| OLD | NEW |