diff options
| -rw-r--r-- | arch/arm/mach-s3c2410/include/mach/spi.h | 2 | ||||
| -rw-r--r-- | drivers/spi/Kconfig | 11 | ||||
| -rw-r--r-- | drivers/spi/Makefile | 7 | ||||
| -rw-r--r-- | drivers/spi/spi_s3c24xx.c | 244 | ||||
| -rw-r--r-- | drivers/spi/spi_s3c24xx_fiq.S | 116 | ||||
| -rw-r--r-- | drivers/spi/spi_s3c24xx_fiq.h | 26 |
6 files changed, 392 insertions, 14 deletions
diff --git a/arch/arm/mach-s3c2410/include/mach/spi.h b/arch/arm/mach-s3c2410/include/mach/spi.h index 193b39d654ed..4d9588373aa5 100644 --- a/arch/arm/mach-s3c2410/include/mach/spi.h +++ b/arch/arm/mach-s3c2410/include/mach/spi.h | |||
| @@ -18,6 +18,8 @@ struct s3c2410_spi_info { | |||
| 18 | unsigned int num_cs; /* total chipselects */ | 18 | unsigned int num_cs; /* total chipselects */ |
| 19 | int bus_num; /* bus number to use. */ | 19 | int bus_num; /* bus number to use. */ |
| 20 | 20 | ||
| 21 | unsigned int use_fiq:1; /* use fiq */ | ||
| 22 | |||
| 21 | void (*gpio_setup)(struct s3c2410_spi_info *spi, int enable); | 23 | void (*gpio_setup)(struct s3c2410_spi_info *spi, int enable); |
| 22 | void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); | 24 | void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol); |
| 23 | }; | 25 | }; |
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index d7c1741c4c5b..6fa595e0c989 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig | |||
| @@ -219,6 +219,17 @@ config SPI_S3C24XX | |||
| 219 | help | 219 | help |
| 220 | SPI driver for Samsung S3C24XX series ARM SoCs | 220 | SPI driver for Samsung S3C24XX series ARM SoCs |
| 221 | 221 | ||
| 222 | config SPI_S3C24XX_FIQ | ||
| 223 | bool "S3C24XX driver with FIQ pseudo-DMA" | ||
| 224 | depends on SPI_S3C24XX | ||
| 225 | select FIQ | ||
| 226 | help | ||
| 227 | Enable FIQ support for the S3C24XX SPI driver to provide pseudo | ||
| 228 | DMA by using the fast-interrupt request framework, This allows | ||
| 229 | the driver to get DMA-like performance when there are either | ||
| 230 | no free DMA channels, or when doing transfers that required both | ||
| 231 | TX and RX data paths. | ||
| 232 | |||
| 222 | config SPI_S3C24XX_GPIO | 233 | config SPI_S3C24XX_GPIO |
| 223 | tristate "Samsung S3C24XX series SPI by GPIO" | 234 | tristate "Samsung S3C24XX series SPI by GPIO" |
| 224 | depends on ARCH_S3C2410 && EXPERIMENTAL | 235 | depends on ARCH_S3C2410 && EXPERIMENTAL |
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index a909e39f7e7c..33faa7fa0ab8 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile | |||
| @@ -32,7 +32,7 @@ obj-$(CONFIG_SPI_MPC52xx) += mpc52xx_spi.o | |||
| 32 | obj-$(CONFIG_SPI_MPC8xxx) += spi_mpc8xxx.o | 32 | obj-$(CONFIG_SPI_MPC8xxx) += spi_mpc8xxx.o |
| 33 | obj-$(CONFIG_SPI_PPC4xx) += spi_ppc4xx.o | 33 | obj-$(CONFIG_SPI_PPC4xx) += spi_ppc4xx.o |
| 34 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o | 34 | obj-$(CONFIG_SPI_S3C24XX_GPIO) += spi_s3c24xx_gpio.o |
| 35 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx.o | 35 | obj-$(CONFIG_SPI_S3C24XX) += spi_s3c24xx_hw.o |
| 36 | obj-$(CONFIG_SPI_TXX9) += spi_txx9.o | 36 | obj-$(CONFIG_SPI_TXX9) += spi_txx9.o |
| 37 | obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o | 37 | obj-$(CONFIG_SPI_XILINX) += xilinx_spi.o |
| 38 | obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o | 38 | obj-$(CONFIG_SPI_XILINX_OF) += xilinx_spi_of.o |
| @@ -41,6 +41,11 @@ obj-$(CONFIG_SPI_SH_SCI) += spi_sh_sci.o | |||
| 41 | obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o | 41 | obj-$(CONFIG_SPI_SH_MSIOF) += spi_sh_msiof.o |
| 42 | obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o | 42 | obj-$(CONFIG_SPI_STMP3XXX) += spi_stmp.o |
| 43 | obj-$(CONFIG_SPI_NUC900) += spi_nuc900.o | 43 | obj-$(CONFIG_SPI_NUC900) += spi_nuc900.o |
| 44 | |||
| 45 | # special build for s3c24xx spi driver with fiq support | ||
| 46 | spi_s3c24xx_hw-y := spi_s3c24xx.o | ||
| 47 | spi_s3c24xx_hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi_s3c24xx_fiq.o | ||
| 48 | |||
| 44 | # ... add above this line ... | 49 | # ... add above this line ... |
| 45 | 50 | ||
| 46 | # SPI protocol drivers (device/link on bus) | 51 | # SPI protocol drivers (device/link on bus) |
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index 33d94f76b9ef..4b0d25b497ac 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* linux/drivers/spi/spi_s3c24xx.c | 1 | /* linux/drivers/spi/spi_s3c24xx.c |
| 2 | * | 2 | * |
| 3 | * Copyright (c) 2006 Ben Dooks | 3 | * Copyright (c) 2006 Ben Dooks |
| 4 | * Copyright (c) 2006 Simtec Electronics | 4 | * Copyright 2006-2009 Simtec Electronics |
| 5 | * Ben Dooks <ben@simtec.co.uk> | 5 | * Ben Dooks <ben@simtec.co.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
| @@ -28,6 +28,11 @@ | |||
| 28 | #include <plat/regs-spi.h> | 28 | #include <plat/regs-spi.h> |
| 29 | #include <mach/spi.h> | 29 | #include <mach/spi.h> |
| 30 | 30 | ||
| 31 | #include <plat/fiq.h> | ||
| 32 | #include <asm/fiq.h> | ||
| 33 | |||
| 34 | #include "spi_s3c24xx_fiq.h" | ||
| 35 | |||
| 31 | /** | 36 | /** |
| 32 | * s3c24xx_spi_devstate - per device data | 37 | * s3c24xx_spi_devstate - per device data |
| 33 | * @hz: Last frequency calculated for @sppre field. | 38 | * @hz: Last frequency calculated for @sppre field. |
| @@ -42,6 +47,13 @@ struct s3c24xx_spi_devstate { | |||
| 42 | u8 sppre; | 47 | u8 sppre; |
| 43 | }; | 48 | }; |
| 44 | 49 | ||
| 50 | enum spi_fiq_mode { | ||
| 51 | FIQ_MODE_NONE = 0, | ||
| 52 | FIQ_MODE_TX = 1, | ||
| 53 | FIQ_MODE_RX = 2, | ||
| 54 | FIQ_MODE_TXRX = 3, | ||
| 55 | }; | ||
| 56 | |||
| 45 | struct s3c24xx_spi { | 57 | struct s3c24xx_spi { |
| 46 | /* bitbang has to be first */ | 58 | /* bitbang has to be first */ |
| 47 | struct spi_bitbang bitbang; | 59 | struct spi_bitbang bitbang; |
| @@ -52,6 +64,11 @@ struct s3c24xx_spi { | |||
| 52 | int len; | 64 | int len; |
| 53 | int count; | 65 | int count; |
| 54 | 66 | ||
| 67 | struct fiq_handler fiq_handler; | ||
| 68 | enum spi_fiq_mode fiq_mode; | ||
| 69 | unsigned char fiq_inuse; | ||
| 70 | unsigned char fiq_claimed; | ||
| 71 | |||
| 55 | void (*set_cs)(struct s3c2410_spi_info *spi, | 72 | void (*set_cs)(struct s3c2410_spi_info *spi, |
| 56 | int cs, int pol); | 73 | int cs, int pol); |
| 57 | 74 | ||
| @@ -67,6 +84,7 @@ struct s3c24xx_spi { | |||
| 67 | struct s3c2410_spi_info *pdata; | 84 | struct s3c2410_spi_info *pdata; |
| 68 | }; | 85 | }; |
| 69 | 86 | ||
| 87 | |||
| 70 | #define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT) | 88 | #define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT) |
| 71 | #define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP) | 89 | #define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP) |
| 72 | 90 | ||
| @@ -127,7 +145,7 @@ static int s3c24xx_spi_update_state(struct spi_device *spi, | |||
| 127 | } | 145 | } |
| 128 | 146 | ||
| 129 | if (spi->mode != cs->mode) { | 147 | if (spi->mode != cs->mode) { |
| 130 | u8 spcon = SPCON_DEFAULT; | 148 | u8 spcon = SPCON_DEFAULT | S3C2410_SPCON_ENSCK; |
| 131 | 149 | ||
| 132 | if (spi->mode & SPI_CPHA) | 150 | if (spi->mode & SPI_CPHA) |
| 133 | spcon |= S3C2410_SPCON_CPHA_FMTB; | 151 | spcon |= S3C2410_SPCON_CPHA_FMTB; |
| @@ -214,13 +232,196 @@ static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count) | |||
| 214 | return hw->tx ? hw->tx[count] : 0; | 232 | return hw->tx ? hw->tx[count] : 0; |
| 215 | } | 233 | } |
| 216 | 234 | ||
| 235 | #ifdef CONFIG_SPI_S3C24XX_FIQ | ||
| 236 | /* Support for FIQ based pseudo-DMA to improve the transfer speed. | ||
| 237 | * | ||
| 238 | * This code uses the assembly helper in spi_s3c24xx_spi.S which is | ||
| 239 | * used by the FIQ core to move data between main memory and the peripheral | ||
| 240 | * block. Since this is code running on the processor, there is no problem | ||
| 241 | * with cache coherency of the buffers, so we can use any buffer we like. | ||
| 242 | */ | ||
| 243 | |||
| 244 | /** | ||
| 245 | * struct spi_fiq_code - FIQ code and header | ||
| 246 | * @length: The length of the code fragment, excluding this header. | ||
| 247 | * @ack_offset: The offset from @data to the word to place the IRQ ACK bit at. | ||
| 248 | * @data: The code itself to install as a FIQ handler. | ||
| 249 | */ | ||
| 250 | struct spi_fiq_code { | ||
| 251 | u32 length; | ||
| 252 | u32 ack_offset; | ||
| 253 | u8 data[0]; | ||
| 254 | }; | ||
| 255 | |||
| 256 | extern struct spi_fiq_code s3c24xx_spi_fiq_txrx; | ||
| 257 | extern struct spi_fiq_code s3c24xx_spi_fiq_tx; | ||
| 258 | extern struct spi_fiq_code s3c24xx_spi_fiq_rx; | ||
| 259 | |||
| 260 | /** | ||
| 261 | * ack_bit - turn IRQ into IRQ acknowledgement bit | ||
| 262 | * @irq: The interrupt number | ||
| 263 | * | ||
| 264 | * Returns the bit to write to the interrupt acknowledge register. | ||
| 265 | */ | ||
| 266 | static inline u32 ack_bit(unsigned int irq) | ||
| 267 | { | ||
| 268 | return 1 << (irq - IRQ_EINT0); | ||
| 269 | } | ||
| 270 | |||
| 271 | /** | ||
| 272 | * s3c24xx_spi_tryfiq - attempt to claim and setup FIQ for transfer | ||
| 273 | * @hw: The hardware state. | ||
| 274 | * | ||
| 275 | * Claim the FIQ handler (only one can be active at any one time) and | ||
| 276 | * then setup the correct transfer code for this transfer. | ||
| 277 | * | ||
| 278 | * This call updates all the necessary state information if sucessful, | ||
| 279 | * so the caller does not need to do anything more than start the transfer | ||
| 280 | * as normal, since the IRQ will have been re-routed to the FIQ handler. | ||
| 281 | */ | ||
| 282 | void s3c24xx_spi_tryfiq(struct s3c24xx_spi *hw) | ||
| 283 | { | ||
| 284 | struct pt_regs regs; | ||
| 285 | enum spi_fiq_mode mode; | ||
| 286 | struct spi_fiq_code *code; | ||
| 287 | int ret; | ||
| 288 | |||
| 289 | if (!hw->fiq_claimed) { | ||
| 290 | /* try and claim fiq if we haven't got it, and if not | ||
| 291 | * then return and simply use another transfer method */ | ||
| 292 | |||
| 293 | ret = claim_fiq(&hw->fiq_handler); | ||
| 294 | if (ret) | ||
| 295 | return; | ||
| 296 | } | ||
| 297 | |||
| 298 | if (hw->tx && !hw->rx) | ||
| 299 | mode = FIQ_MODE_TX; | ||
| 300 | else if (hw->rx && !hw->tx) | ||
| 301 | mode = FIQ_MODE_RX; | ||
| 302 | else | ||
| 303 | mode = FIQ_MODE_TXRX; | ||
| 304 | |||
| 305 | regs.uregs[fiq_rspi] = (long)hw->regs; | ||
| 306 | regs.uregs[fiq_rrx] = (long)hw->rx; | ||
| 307 | regs.uregs[fiq_rtx] = (long)hw->tx + 1; | ||
| 308 | regs.uregs[fiq_rcount] = hw->len - 1; | ||
| 309 | regs.uregs[fiq_rirq] = (long)S3C24XX_VA_IRQ; | ||
| 310 | |||
| 311 | set_fiq_regs(®s); | ||
| 312 | |||
| 313 | if (hw->fiq_mode != mode) { | ||
| 314 | u32 *ack_ptr; | ||
| 315 | |||
| 316 | hw->fiq_mode = mode; | ||
| 317 | |||
| 318 | switch (mode) { | ||
| 319 | case FIQ_MODE_TX: | ||
| 320 | code = &s3c24xx_spi_fiq_tx; | ||
| 321 | break; | ||
| 322 | case FIQ_MODE_RX: | ||
| 323 | code = &s3c24xx_spi_fiq_rx; | ||
| 324 | break; | ||
| 325 | case FIQ_MODE_TXRX: | ||
| 326 | code = &s3c24xx_spi_fiq_txrx; | ||
| 327 | break; | ||
| 328 | default: | ||
| 329 | code = NULL; | ||
| 330 | } | ||
| 331 | |||
| 332 | BUG_ON(!code); | ||
| 333 | |||
| 334 | ack_ptr = (u32 *)&code->data[code->ack_offset]; | ||
| 335 | *ack_ptr = ack_bit(hw->irq); | ||
| 336 | |||
| 337 | set_fiq_handler(&code->data, code->length); | ||
| 338 | } | ||
| 339 | |||
| 340 | s3c24xx_set_fiq(hw->irq, true); | ||
| 341 | |||
| 342 | hw->fiq_mode = mode; | ||
| 343 | hw->fiq_inuse = 1; | ||
| 344 | } | ||
| 345 | |||
| 346 | /** | ||
| 347 | * s3c24xx_spi_fiqop - FIQ core code callback | ||
| 348 | * @pw: Data registered with the handler | ||
| 349 | * @release: Whether this is a release or a return. | ||
| 350 | * | ||
| 351 | * Called by the FIQ code when another module wants to use the FIQ, so | ||
| 352 | * return whether we are currently using this or not and then update our | ||
| 353 | * internal state. | ||
| 354 | */ | ||
| 355 | static int s3c24xx_spi_fiqop(void *pw, int release) | ||
| 356 | { | ||
| 357 | struct s3c24xx_spi *hw = pw; | ||
| 358 | int ret = 0; | ||
| 359 | |||
| 360 | if (release) { | ||
| 361 | if (hw->fiq_inuse) | ||
| 362 | ret = -EBUSY; | ||
| 363 | |||
| 364 | /* note, we do not need to unroute the FIQ, as the FIQ | ||
| 365 | * vector code de-routes it to signal the end of transfer */ | ||
| 366 | |||
| 367 | hw->fiq_mode = FIQ_MODE_NONE; | ||
| 368 | hw->fiq_claimed = 0; | ||
| 369 | } else { | ||
| 370 | hw->fiq_claimed = 1; | ||
| 371 | } | ||
| 372 | |||
| 373 | return ret; | ||
| 374 | } | ||
| 375 | |||
| 376 | /** | ||
| 377 | * s3c24xx_spi_initfiq - setup the information for the FIQ core | ||
| 378 | * @hw: The hardware state. | ||
| 379 | * | ||
| 380 | * Setup the fiq_handler block to pass to the FIQ core. | ||
| 381 | */ | ||
| 382 | static inline void s3c24xx_spi_initfiq(struct s3c24xx_spi *hw) | ||
| 383 | { | ||
| 384 | hw->fiq_handler.dev_id = hw; | ||
| 385 | hw->fiq_handler.name = dev_name(hw->dev); | ||
| 386 | hw->fiq_handler.fiq_op = s3c24xx_spi_fiqop; | ||
| 387 | } | ||
| 388 | |||
| 389 | /** | ||
| 390 | * s3c24xx_spi_usefiq - return if we should be using FIQ. | ||
| 391 | * @hw: The hardware state. | ||
| 392 | * | ||
| 393 | * Return true if the platform data specifies whether this channel is | ||
| 394 | * allowed to use the FIQ. | ||
| 395 | */ | ||
| 396 | static inline bool s3c24xx_spi_usefiq(struct s3c24xx_spi *hw) | ||
| 397 | { | ||
| 398 | return hw->pdata->use_fiq; | ||
| 399 | } | ||
| 400 | |||
| 401 | /** | ||
| 402 | * s3c24xx_spi_usingfiq - return if channel is using FIQ | ||
| 403 | * @spi: The hardware state. | ||
| 404 | * | ||
| 405 | * Return whether the channel is currently using the FIQ (separate from | ||
| 406 | * whether the FIQ is claimed). | ||
| 407 | */ | ||
| 408 | static inline bool s3c24xx_spi_usingfiq(struct s3c24xx_spi *spi) | ||
| 409 | { | ||
| 410 | return spi->fiq_inuse; | ||
| 411 | } | ||
| 412 | #else | ||
| 413 | |||
| 414 | static inline void s3c24xx_spi_initfiq(struct s3c24xx_spi *s) { } | ||
| 415 | static inline void s3c24xx_spi_tryfiq(struct s3c24xx_spi *s) { } | ||
| 416 | static inline bool s3c24xx_spi_usefiq(struct s3c24xx_spi *s) { return false; } | ||
| 417 | static inline bool s3c24xx_spi_usingfiq(struct s3c24xx_spi *s) { return false; } | ||
| 418 | |||
| 419 | #endif /* CONFIG_SPI_S3C24XX_FIQ */ | ||
| 420 | |||
| 217 | static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t) | 421 | static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t) |
| 218 | { | 422 | { |
| 219 | struct s3c24xx_spi *hw = to_hw(spi); | 423 | struct s3c24xx_spi *hw = to_hw(spi); |
| 220 | 424 | ||
| 221 | dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n", | ||
| 222 | t->tx_buf, t->rx_buf, t->len); | ||
| 223 | |||
| 224 | hw->tx = t->tx_buf; | 425 | hw->tx = t->tx_buf; |
| 225 | hw->rx = t->rx_buf; | 426 | hw->rx = t->rx_buf; |
| 226 | hw->len = t->len; | 427 | hw->len = t->len; |
| @@ -228,11 +429,14 @@ static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t) | |||
| 228 | 429 | ||
| 229 | init_completion(&hw->done); | 430 | init_completion(&hw->done); |
| 230 | 431 | ||
| 432 | hw->fiq_inuse = 0; | ||
| 433 | if (s3c24xx_spi_usefiq(hw) && t->len >= 3) | ||
| 434 | s3c24xx_spi_tryfiq(hw); | ||
| 435 | |||
| 231 | /* send the first byte */ | 436 | /* send the first byte */ |
| 232 | writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT); | 437 | writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT); |
| 233 | 438 | ||
| 234 | wait_for_completion(&hw->done); | 439 | wait_for_completion(&hw->done); |
| 235 | |||
| 236 | return hw->count; | 440 | return hw->count; |
| 237 | } | 441 | } |
| 238 | 442 | ||
| @@ -254,17 +458,27 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev) | |||
| 254 | goto irq_done; | 458 | goto irq_done; |
| 255 | } | 459 | } |
| 256 | 460 | ||
| 257 | hw->count++; | 461 | if (!s3c24xx_spi_usingfiq(hw)) { |
| 462 | hw->count++; | ||
| 258 | 463 | ||
| 259 | if (hw->rx) | 464 | if (hw->rx) |
| 260 | hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT); | 465 | hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT); |
| 261 | 466 | ||
| 262 | count++; | 467 | count++; |
| 468 | |||
| 469 | if (count < hw->len) | ||
| 470 | writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT); | ||
| 471 | else | ||
| 472 | complete(&hw->done); | ||
| 473 | } else { | ||
| 474 | hw->count = hw->len; | ||
| 475 | hw->fiq_inuse = 0; | ||
| 476 | |||
| 477 | if (hw->rx) | ||
| 478 | hw->rx[hw->len-1] = readb(hw->regs + S3C2410_SPRDAT); | ||
| 263 | 479 | ||
| 264 | if (count < hw->len) | ||
| 265 | writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT); | ||
| 266 | else | ||
| 267 | complete(&hw->done); | 480 | complete(&hw->done); |
| 481 | } | ||
| 268 | 482 | ||
| 269 | irq_done: | 483 | irq_done: |
| 270 | return IRQ_HANDLED; | 484 | return IRQ_HANDLED; |
| @@ -322,6 +536,10 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev) | |||
| 322 | platform_set_drvdata(pdev, hw); | 536 | platform_set_drvdata(pdev, hw); |
| 323 | init_completion(&hw->done); | 537 | init_completion(&hw->done); |
| 324 | 538 | ||
| 539 | /* initialise fiq handler */ | ||
| 540 | |||
| 541 | s3c24xx_spi_initfiq(hw); | ||
| 542 | |||
| 325 | /* setup the master state. */ | 543 | /* setup the master state. */ |
| 326 | 544 | ||
| 327 | /* the spi->mode bits understood by this driver: */ | 545 | /* the spi->mode bits understood by this driver: */ |
diff --git a/drivers/spi/spi_s3c24xx_fiq.S b/drivers/spi/spi_s3c24xx_fiq.S new file mode 100644 index 000000000000..3793cae361db --- /dev/null +++ b/drivers/spi/spi_s3c24xx_fiq.S | |||
| @@ -0,0 +1,116 @@ | |||
| 1 | /* linux/drivers/spi/spi_s3c24xx_fiq.S | ||
| 2 | * | ||
| 3 | * Copyright 2009 Simtec Electronics | ||
| 4 | * Ben Dooks <ben@simtec.co.uk> | ||
| 5 | * | ||
| 6 | * S3C24XX SPI - FIQ pseudo-DMA transfer code | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/linkage.h> | ||
| 14 | #include <asm/assembler.h> | ||
| 15 | |||
| 16 | #include <mach/map.h> | ||
| 17 | #include <mach/regs-irq.h> | ||
| 18 | #include <plat/regs-spi.h> | ||
| 19 | |||
| 20 | #include "spi_s3c24xx_fiq.h" | ||
| 21 | |||
| 22 | .text | ||
| 23 | |||
| 24 | @ entry to these routines is as follows, with the register names | ||
| 25 | @ defined in fiq.h so that they can be shared with the C files which | ||
| 26 | @ setup the calling registers. | ||
| 27 | @ | ||
| 28 | @ fiq_rirq The base of the IRQ registers to find S3C2410_SRCPND | ||
| 29 | @ fiq_rtmp Temporary register to hold tx/rx data | ||
| 30 | @ fiq_rspi The base of the SPI register block | ||
| 31 | @ fiq_rtx The tx buffer pointer | ||
| 32 | @ fiq_rrx The rx buffer pointer | ||
| 33 | @ fiq_rcount The number of bytes to move | ||
| 34 | |||
| 35 | @ each entry starts with a word entry of how long it is | ||
| 36 | @ and an offset to the irq acknowledgment word | ||
| 37 | |||
| 38 | ENTRY(s3c24xx_spi_fiq_rx) | ||
| 39 | s3c24xx_spi_fix_rx: | ||
| 40 | .word fiq_rx_end - fiq_rx_start | ||
| 41 | .word fiq_rx_irq_ack - fiq_rx_start | ||
| 42 | fiq_rx_start: | ||
| 43 | ldr fiq_rtmp, fiq_rx_irq_ack | ||
| 44 | str fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ] | ||
| 45 | |||
| 46 | ldrb fiq_rtmp, [ fiq_rspi, # S3C2410_SPRDAT ] | ||
| 47 | strb fiq_rtmp, [ fiq_rrx ], #1 | ||
| 48 | |||
| 49 | mov fiq_rtmp, #0xff | ||
| 50 | strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] | ||
| 51 | |||
| 52 | subs fiq_rcount, fiq_rcount, #1 | ||
| 53 | subnes pc, lr, #4 @@ return, still have work to do | ||
| 54 | |||
| 55 | @@ set IRQ controller so that next op will trigger IRQ | ||
| 56 | mov fiq_rtmp, #0 | ||
| 57 | str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] | ||
| 58 | subs pc, lr, #4 | ||
| 59 | |||
| 60 | fiq_rx_irq_ack: | ||
| 61 | .word 0 | ||
| 62 | fiq_rx_end: | ||
| 63 | |||
| 64 | ENTRY(s3c24xx_spi_fiq_txrx) | ||
| 65 | s3c24xx_spi_fiq_txrx: | ||
| 66 | .word fiq_txrx_end - fiq_txrx_start | ||
| 67 | .word fiq_txrx_irq_ack - fiq_txrx_start | ||
| 68 | fiq_txrx_start: | ||
| 69 | |||
| 70 | ldrb fiq_rtmp, [ fiq_rspi, # S3C2410_SPRDAT ] | ||
| 71 | strb fiq_rtmp, [ fiq_rrx ], #1 | ||
| 72 | |||
| 73 | ldr fiq_rtmp, fiq_txrx_irq_ack | ||
| 74 | str fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ] | ||
| 75 | |||
| 76 | ldrb fiq_rtmp, [ fiq_rtx ], #1 | ||
| 77 | strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] | ||
| 78 | |||
| 79 | subs fiq_rcount, fiq_rcount, #1 | ||
| 80 | subnes pc, lr, #4 @@ return, still have work to do | ||
| 81 | |||
| 82 | mov fiq_rtmp, #0 | ||
| 83 | str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] | ||
| 84 | subs pc, lr, #4 | ||
| 85 | |||
| 86 | fiq_txrx_irq_ack: | ||
| 87 | .word 0 | ||
| 88 | |||
| 89 | fiq_txrx_end: | ||
| 90 | |||
| 91 | ENTRY(s3c24xx_spi_fiq_tx) | ||
| 92 | s3c24xx_spi_fix_tx: | ||
| 93 | .word fiq_tx_end - fiq_tx_start | ||
| 94 | .word fiq_tx_irq_ack - fiq_tx_start | ||
| 95 | fiq_tx_start: | ||
| 96 | ldrb fiq_rtmp, [ fiq_rspi, # S3C2410_SPRDAT ] | ||
| 97 | |||
| 98 | ldr fiq_rtmp, fiq_tx_irq_ack | ||
| 99 | str fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ] | ||
| 100 | |||
| 101 | ldrb fiq_rtmp, [ fiq_rtx ], #1 | ||
| 102 | strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] | ||
| 103 | |||
| 104 | subs fiq_rcount, fiq_rcount, #1 | ||
| 105 | subnes pc, lr, #4 @@ return, still have work to do | ||
| 106 | |||
| 107 | mov fiq_rtmp, #0 | ||
| 108 | str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] | ||
| 109 | subs pc, lr, #4 | ||
| 110 | |||
| 111 | fiq_tx_irq_ack: | ||
| 112 | .word 0 | ||
| 113 | |||
| 114 | fiq_tx_end: | ||
| 115 | |||
| 116 | .end | ||
diff --git a/drivers/spi/spi_s3c24xx_fiq.h b/drivers/spi/spi_s3c24xx_fiq.h new file mode 100644 index 000000000000..a5950bb25b51 --- /dev/null +++ b/drivers/spi/spi_s3c24xx_fiq.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | /* linux/drivers/spi/spi_s3c24xx_fiq.h | ||
| 2 | * | ||
| 3 | * Copyright 2009 Simtec Electronics | ||
| 4 | * Ben Dooks <ben@simtec.co.uk> | ||
| 5 | * | ||
| 6 | * S3C24XX SPI - FIQ pseudo-DMA transfer support | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | */ | ||
| 12 | |||
| 13 | /* We have R8 through R13 to play with */ | ||
| 14 | |||
| 15 | #ifdef __ASSEMBLY__ | ||
| 16 | #define __REG_NR(x) r##x | ||
| 17 | #else | ||
| 18 | #define __REG_NR(x) (x) | ||
| 19 | #endif | ||
| 20 | |||
| 21 | #define fiq_rspi __REG_NR(8) | ||
| 22 | #define fiq_rtmp __REG_NR(9) | ||
| 23 | #define fiq_rrx __REG_NR(10) | ||
| 24 | #define fiq_rtx __REG_NR(11) | ||
| 25 | #define fiq_rcount __REG_NR(12) | ||
| 26 | #define fiq_rirq __REG_NR(13) | ||
