diff options
| -rw-r--r-- | drivers/spi/amba-pl022.c | 178 | ||||
| -rw-r--r-- | include/linux/amba/pl022.h | 4 |
2 files changed, 125 insertions, 57 deletions
diff --git a/drivers/spi/amba-pl022.c b/drivers/spi/amba-pl022.c index e9aeee16d922..65092171cec3 100644 --- a/drivers/spi/amba-pl022.c +++ b/drivers/spi/amba-pl022.c | |||
| @@ -102,13 +102,21 @@ | |||
| 102 | /* | 102 | /* |
| 103 | * SSP Control Register 0 - SSP_CR0 | 103 | * SSP Control Register 0 - SSP_CR0 |
| 104 | */ | 104 | */ |
| 105 | #define SSP_CR0_MASK_DSS (0x1FUL << 0) | 105 | #define SSP_CR0_MASK_DSS (0x0FUL << 0) |
| 106 | #define SSP_CR0_MASK_HALFDUP (0x1UL << 5) | 106 | #define SSP_CR0_MASK_FRF (0x3UL << 4) |
| 107 | #define SSP_CR0_MASK_SPO (0x1UL << 6) | 107 | #define SSP_CR0_MASK_SPO (0x1UL << 6) |
| 108 | #define SSP_CR0_MASK_SPH (0x1UL << 7) | 108 | #define SSP_CR0_MASK_SPH (0x1UL << 7) |
| 109 | #define SSP_CR0_MASK_SCR (0xFFUL << 8) | 109 | #define SSP_CR0_MASK_SCR (0xFFUL << 8) |
| 110 | #define SSP_CR0_MASK_CSS (0x1FUL << 16) | 110 | |
| 111 | #define SSP_CR0_MASK_FRF (0x3UL << 21) | 111 | /* |
| 112 | * The ST version of this block moves som bits | ||
| 113 | * in SSP_CR0 and extends it to 32 bits | ||
| 114 | */ | ||
| 115 | #define SSP_CR0_MASK_DSS_ST (0x1FUL << 0) | ||
| 116 | #define SSP_CR0_MASK_HALFDUP_ST (0x1UL << 5) | ||
| 117 | #define SSP_CR0_MASK_CSS_ST (0x1FUL << 16) | ||
| 118 | #define SSP_CR0_MASK_FRF_ST (0x3UL << 21) | ||
| 119 | |||
| 112 | 120 | ||
| 113 | /* | 121 | /* |
| 114 | * SSP Control Register 0 - SSP_CR1 | 122 | * SSP Control Register 0 - SSP_CR1 |
| @@ -117,16 +125,16 @@ | |||
| 117 | #define SSP_CR1_MASK_SSE (0x1UL << 1) | 125 | #define SSP_CR1_MASK_SSE (0x1UL << 1) |
| 118 | #define SSP_CR1_MASK_MS (0x1UL << 2) | 126 | #define SSP_CR1_MASK_MS (0x1UL << 2) |
| 119 | #define SSP_CR1_MASK_SOD (0x1UL << 3) | 127 | #define SSP_CR1_MASK_SOD (0x1UL << 3) |
| 120 | #define SSP_CR1_MASK_RENDN (0x1UL << 4) | ||
| 121 | #define SSP_CR1_MASK_TENDN (0x1UL << 5) | ||
| 122 | #define SSP_CR1_MASK_MWAIT (0x1UL << 6) | ||
| 123 | #define SSP_CR1_MASK_RXIFLSEL (0x7UL << 7) | ||
| 124 | #define SSP_CR1_MASK_TXIFLSEL (0x7UL << 10) | ||
| 125 | 128 | ||
| 126 | /* | 129 | /* |
| 127 | * SSP Data Register - SSP_DR | 130 | * The ST version of this block adds some bits |
| 131 | * in SSP_CR1 | ||
| 128 | */ | 132 | */ |
| 129 | #define SSP_DR_MASK_DATA 0xFFFFFFFF | 133 | #define SSP_CR1_MASK_RENDN_ST (0x1UL << 4) |
| 134 | #define SSP_CR1_MASK_TENDN_ST (0x1UL << 5) | ||
| 135 | #define SSP_CR1_MASK_MWAIT_ST (0x1UL << 6) | ||
| 136 | #define SSP_CR1_MASK_RXIFLSEL_ST (0x7UL << 7) | ||
| 137 | #define SSP_CR1_MASK_TXIFLSEL_ST (0x7UL << 10) | ||
| 130 | 138 | ||
| 131 | /* | 139 | /* |
| 132 | * SSP Status Register - SSP_SR | 140 | * SSP Status Register - SSP_SR |
| @@ -134,7 +142,7 @@ | |||
| 134 | #define SSP_SR_MASK_TFE (0x1UL << 0) /* Transmit FIFO empty */ | 142 | #define SSP_SR_MASK_TFE (0x1UL << 0) /* Transmit FIFO empty */ |
| 135 | #define SSP_SR_MASK_TNF (0x1UL << 1) /* Transmit FIFO not full */ | 143 | #define SSP_SR_MASK_TNF (0x1UL << 1) /* Transmit FIFO not full */ |
| 136 | #define SSP_SR_MASK_RNE (0x1UL << 2) /* Receive FIFO not empty */ | 144 | #define SSP_SR_MASK_RNE (0x1UL << 2) /* Receive FIFO not empty */ |
| 137 | #define SSP_SR_MASK_RFF (0x1UL << 3) /* Receive FIFO full */ | 145 | #define SSP_SR_MASK_RFF (0x1UL << 3) /* Receive FIFO full */ |
| 138 | #define SSP_SR_MASK_BSY (0x1UL << 4) /* Busy Flag */ | 146 | #define SSP_SR_MASK_BSY (0x1UL << 4) /* Busy Flag */ |
| 139 | 147 | ||
| 140 | /* | 148 | /* |
| @@ -227,7 +235,7 @@ | |||
| 227 | /* | 235 | /* |
| 228 | * SSP Test Data Register - SSP_TDR | 236 | * SSP Test Data Register - SSP_TDR |
| 229 | */ | 237 | */ |
| 230 | #define TDR_MASK_TESTDATA (0xFFFFFFFF) | 238 | #define TDR_MASK_TESTDATA (0xFFFFFFFF) |
| 231 | 239 | ||
| 232 | /* | 240 | /* |
| 233 | * Message State | 241 | * Message State |
| @@ -235,33 +243,33 @@ | |||
| 235 | * hold a single state value, that's why all this | 243 | * hold a single state value, that's why all this |
| 236 | * (void *) casting is done here. | 244 | * (void *) casting is done here. |
| 237 | */ | 245 | */ |
| 238 | #define STATE_START ((void *) 0) | 246 | #define STATE_START ((void *) 0) |
| 239 | #define STATE_RUNNING ((void *) 1) | 247 | #define STATE_RUNNING ((void *) 1) |
| 240 | #define STATE_DONE ((void *) 2) | 248 | #define STATE_DONE ((void *) 2) |
| 241 | #define STATE_ERROR ((void *) -1) | 249 | #define STATE_ERROR ((void *) -1) |
| 242 | 250 | ||
| 243 | /* | 251 | /* |
| 244 | * Queue State | 252 | * Queue State |
| 245 | */ | 253 | */ |
| 246 | #define QUEUE_RUNNING (0) | 254 | #define QUEUE_RUNNING (0) |
| 247 | #define QUEUE_STOPPED (1) | 255 | #define QUEUE_STOPPED (1) |
| 248 | /* | 256 | /* |
| 249 | * SSP State - Whether Enabled or Disabled | 257 | * SSP State - Whether Enabled or Disabled |
| 250 | */ | 258 | */ |
| 251 | #define SSP_DISABLED (0) | 259 | #define SSP_DISABLED (0) |
| 252 | #define SSP_ENABLED (1) | 260 | #define SSP_ENABLED (1) |
| 253 | 261 | ||
| 254 | /* | 262 | /* |
| 255 | * SSP DMA State - Whether DMA Enabled or Disabled | 263 | * SSP DMA State - Whether DMA Enabled or Disabled |
| 256 | */ | 264 | */ |
| 257 | #define SSP_DMA_DISABLED (0) | 265 | #define SSP_DMA_DISABLED (0) |
| 258 | #define SSP_DMA_ENABLED (1) | 266 | #define SSP_DMA_ENABLED (1) |
| 259 | 267 | ||
| 260 | /* | 268 | /* |
| 261 | * SSP Clock Defaults | 269 | * SSP Clock Defaults |
| 262 | */ | 270 | */ |
| 263 | #define NMDK_SSP_DEFAULT_CLKRATE 0x2 | 271 | #define SSP_DEFAULT_CLKRATE 0x2 |
| 264 | #define NMDK_SSP_DEFAULT_PRESCALE 0x40 | 272 | #define SSP_DEFAULT_PRESCALE 0x40 |
| 265 | 273 | ||
| 266 | /* | 274 | /* |
| 267 | * SSP Clock Parameter ranges | 275 | * SSP Clock Parameter ranges |
| @@ -307,16 +315,20 @@ enum ssp_writing { | |||
| 307 | * @fifodepth: depth of FIFOs (both) | 315 | * @fifodepth: depth of FIFOs (both) |
| 308 | * @max_bpw: maximum number of bits per word | 316 | * @max_bpw: maximum number of bits per word |
| 309 | * @unidir: supports unidirection transfers | 317 | * @unidir: supports unidirection transfers |
| 318 | * @extended_cr: 32 bit wide control register 0 with extra | ||
| 319 | * features and extra features in CR1 as found in the ST variants | ||
| 310 | */ | 320 | */ |
| 311 | struct vendor_data { | 321 | struct vendor_data { |
| 312 | int fifodepth; | 322 | int fifodepth; |
| 313 | int max_bpw; | 323 | int max_bpw; |
| 314 | bool unidir; | 324 | bool unidir; |
| 325 | bool extended_cr; | ||
| 315 | }; | 326 | }; |
| 316 | 327 | ||
| 317 | /** | 328 | /** |
| 318 | * struct pl022 - This is the private SSP driver data structure | 329 | * struct pl022 - This is the private SSP driver data structure |
| 319 | * @adev: AMBA device model hookup | 330 | * @adev: AMBA device model hookup |
| 331 | * @vendor: Vendor data for the IP block | ||
| 320 | * @phybase: The physical memory where the SSP device resides | 332 | * @phybase: The physical memory where the SSP device resides |
| 321 | * @virtbase: The virtual memory where the SSP is mapped | 333 | * @virtbase: The virtual memory where the SSP is mapped |
| 322 | * @master: SPI framework hookup | 334 | * @master: SPI framework hookup |
| @@ -369,7 +381,8 @@ struct pl022 { | |||
| 369 | 381 | ||
| 370 | /** | 382 | /** |
| 371 | * struct chip_data - To maintain runtime state of SSP for each client chip | 383 | * struct chip_data - To maintain runtime state of SSP for each client chip |
| 372 | * @cr0: Value of control register CR0 of SSP | 384 | * @cr0: Value of control register CR0 of SSP - on later ST variants this |
| 385 | * register is 32 bits wide rather than just 16 | ||
| 373 | * @cr1: Value of control register CR1 of SSP | 386 | * @cr1: Value of control register CR1 of SSP |
| 374 | * @dmacr: Value of DMA control Register of SSP | 387 | * @dmacr: Value of DMA control Register of SSP |
| 375 | * @cpsr: Value of Clock prescale register | 388 | * @cpsr: Value of Clock prescale register |
| @@ -384,7 +397,7 @@ struct pl022 { | |||
| 384 | * This would be set according to the current message that would be served | 397 | * This would be set according to the current message that would be served |
| 385 | */ | 398 | */ |
| 386 | struct chip_data { | 399 | struct chip_data { |
| 387 | u16 cr0; | 400 | u32 cr0; |
| 388 | u16 cr1; | 401 | u16 cr1; |
| 389 | u16 dmacr; | 402 | u16 dmacr; |
| 390 | u16 cpsr; | 403 | u16 cpsr; |
| @@ -517,7 +530,10 @@ static void restore_state(struct pl022 *pl022) | |||
| 517 | { | 530 | { |
| 518 | struct chip_data *chip = pl022->cur_chip; | 531 | struct chip_data *chip = pl022->cur_chip; |
| 519 | 532 | ||
| 520 | writew(chip->cr0, SSP_CR0(pl022->virtbase)); | 533 | if (pl022->vendor->extended_cr) |
| 534 | writel(chip->cr0, SSP_CR0(pl022->virtbase)); | ||
| 535 | else | ||
| 536 | writew(chip->cr0, SSP_CR0(pl022->virtbase)); | ||
| 521 | writew(chip->cr1, SSP_CR1(pl022->virtbase)); | 537 | writew(chip->cr1, SSP_CR1(pl022->virtbase)); |
| 522 | writew(chip->dmacr, SSP_DMACR(pl022->virtbase)); | 538 | writew(chip->dmacr, SSP_DMACR(pl022->virtbase)); |
| 523 | writew(chip->cpsr, SSP_CPSR(pl022->virtbase)); | 539 | writew(chip->cpsr, SSP_CPSR(pl022->virtbase)); |
| @@ -535,28 +551,43 @@ static void restore_state(struct pl022 *pl022) | |||
| 535 | */ | 551 | */ |
| 536 | #define DEFAULT_SSP_REG_CR0 ( \ | 552 | #define DEFAULT_SSP_REG_CR0 ( \ |
| 537 | GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS, 0) | \ | 553 | GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS, 0) | \ |
| 538 | GEN_MASK_BITS(SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, SSP_CR0_MASK_HALFDUP, 5) | \ | 554 | GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF, 4) | \ |
| 555 | GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \ | ||
| 556 | GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \ | ||
| 557 | GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) \ | ||
| 558 | ) | ||
| 559 | |||
| 560 | /* ST versions have slightly different bit layout */ | ||
| 561 | #define DEFAULT_SSP_REG_CR0_ST ( \ | ||
| 562 | GEN_MASK_BITS(SSP_DATA_BITS_12, SSP_CR0_MASK_DSS_ST, 0) | \ | ||
| 563 | GEN_MASK_BITS(SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, SSP_CR0_MASK_HALFDUP_ST, 5) | \ | ||
| 539 | GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \ | 564 | GEN_MASK_BITS(SSP_CLK_POL_IDLE_LOW, SSP_CR0_MASK_SPO, 6) | \ |
| 540 | GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \ | 565 | GEN_MASK_BITS(SSP_CLK_SECOND_EDGE, SSP_CR0_MASK_SPH, 7) | \ |
| 541 | GEN_MASK_BITS(NMDK_SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) | \ | 566 | GEN_MASK_BITS(SSP_DEFAULT_CLKRATE, SSP_CR0_MASK_SCR, 8) | \ |
| 542 | GEN_MASK_BITS(SSP_BITS_8, SSP_CR0_MASK_CSS, 16) | \ | 567 | GEN_MASK_BITS(SSP_BITS_8, SSP_CR0_MASK_CSS_ST, 16) | \ |
| 543 | GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF, 21) \ | 568 | GEN_MASK_BITS(SSP_INTERFACE_MOTOROLA_SPI, SSP_CR0_MASK_FRF_ST, 21) \ |
| 544 | ) | 569 | ) |
| 545 | 570 | ||
| 546 | #define DEFAULT_SSP_REG_CR1 ( \ | 571 | #define DEFAULT_SSP_REG_CR1 ( \ |
| 547 | GEN_MASK_BITS(LOOPBACK_DISABLED, SSP_CR1_MASK_LBM, 0) | \ | 572 | GEN_MASK_BITS(LOOPBACK_DISABLED, SSP_CR1_MASK_LBM, 0) | \ |
| 548 | GEN_MASK_BITS(SSP_DISABLED, SSP_CR1_MASK_SSE, 1) | \ | 573 | GEN_MASK_BITS(SSP_DISABLED, SSP_CR1_MASK_SSE, 1) | \ |
| 549 | GEN_MASK_BITS(SSP_MASTER, SSP_CR1_MASK_MS, 2) | \ | 574 | GEN_MASK_BITS(SSP_MASTER, SSP_CR1_MASK_MS, 2) | \ |
| 550 | GEN_MASK_BITS(DO_NOT_DRIVE_TX, SSP_CR1_MASK_SOD, 3) | \ | 575 | GEN_MASK_BITS(DO_NOT_DRIVE_TX, SSP_CR1_MASK_SOD, 3) \ |
| 551 | GEN_MASK_BITS(SSP_RX_MSB, SSP_CR1_MASK_RENDN, 4) | \ | ||
| 552 | GEN_MASK_BITS(SSP_TX_MSB, SSP_CR1_MASK_TENDN, 5) | \ | ||
| 553 | GEN_MASK_BITS(SSP_MWIRE_WAIT_ZERO, SSP_CR1_MASK_MWAIT, 6) |\ | ||
| 554 | GEN_MASK_BITS(SSP_RX_1_OR_MORE_ELEM, SSP_CR1_MASK_RXIFLSEL, 7) | \ | ||
| 555 | GEN_MASK_BITS(SSP_TX_1_OR_MORE_EMPTY_LOC, SSP_CR1_MASK_TXIFLSEL, 10) \ | ||
| 556 | ) | 576 | ) |
| 557 | 577 | ||
| 578 | /* ST versions extend this register to use all 16 bits */ | ||
| 579 | #define DEFAULT_SSP_REG_CR1_ST ( \ | ||
| 580 | DEFAULT_SSP_REG_CR1 | \ | ||
| 581 | GEN_MASK_BITS(SSP_RX_MSB, SSP_CR1_MASK_RENDN_ST, 4) | \ | ||
| 582 | GEN_MASK_BITS(SSP_TX_MSB, SSP_CR1_MASK_TENDN_ST, 5) | \ | ||
| 583 | GEN_MASK_BITS(SSP_MWIRE_WAIT_ZERO, SSP_CR1_MASK_MWAIT_ST, 6) |\ | ||
| 584 | GEN_MASK_BITS(SSP_RX_1_OR_MORE_ELEM, SSP_CR1_MASK_RXIFLSEL_ST, 7) | \ | ||
| 585 | GEN_MASK_BITS(SSP_TX_1_OR_MORE_EMPTY_LOC, SSP_CR1_MASK_TXIFLSEL_ST, 10) \ | ||
| 586 | ) | ||
| 587 | |||
| 588 | |||
| 558 | #define DEFAULT_SSP_REG_CPSR ( \ | 589 | #define DEFAULT_SSP_REG_CPSR ( \ |
| 559 | GEN_MASK_BITS(NMDK_SSP_DEFAULT_PRESCALE, SSP_CPSR_MASK_CPSDVSR, 0) \ | 590 | GEN_MASK_BITS(SSP_DEFAULT_PRESCALE, SSP_CPSR_MASK_CPSDVSR, 0) \ |
| 560 | ) | 591 | ) |
| 561 | 592 | ||
| 562 | #define DEFAULT_SSP_REG_DMACR (\ | 593 | #define DEFAULT_SSP_REG_DMACR (\ |
| @@ -567,8 +598,13 @@ static void restore_state(struct pl022 *pl022) | |||
| 567 | 598 | ||
| 568 | static void load_ssp_default_config(struct pl022 *pl022) | 599 | static void load_ssp_default_config(struct pl022 *pl022) |
| 569 | { | 600 | { |
| 570 | writew(DEFAULT_SSP_REG_CR0, SSP_CR0(pl022->virtbase)); | 601 | if (pl022->vendor->extended_cr) { |
| 571 | writew(DEFAULT_SSP_REG_CR1, SSP_CR1(pl022->virtbase)); | 602 | writel(DEFAULT_SSP_REG_CR0_ST, SSP_CR0(pl022->virtbase)); |
| 603 | writew(DEFAULT_SSP_REG_CR1_ST, SSP_CR1(pl022->virtbase)); | ||
| 604 | } else { | ||
| 605 | writew(DEFAULT_SSP_REG_CR0, SSP_CR0(pl022->virtbase)); | ||
| 606 | writew(DEFAULT_SSP_REG_CR1, SSP_CR1(pl022->virtbase)); | ||
| 607 | } | ||
| 572 | writew(DEFAULT_SSP_REG_DMACR, SSP_DMACR(pl022->virtbase)); | 608 | writew(DEFAULT_SSP_REG_DMACR, SSP_DMACR(pl022->virtbase)); |
| 573 | writew(DEFAULT_SSP_REG_CPSR, SSP_CPSR(pl022->virtbase)); | 609 | writew(DEFAULT_SSP_REG_CPSR, SSP_CPSR(pl022->virtbase)); |
| 574 | writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase)); | 610 | writew(DISABLE_ALL_INTERRUPTS, SSP_IMSC(pl022->virtbase)); |
| @@ -1008,7 +1044,7 @@ static void do_polling_transfer(void *data) | |||
| 1008 | writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE), | 1044 | writew((readw(SSP_CR1(pl022->virtbase)) | SSP_CR1_MASK_SSE), |
| 1009 | SSP_CR1(pl022->virtbase)); | 1045 | SSP_CR1(pl022->virtbase)); |
| 1010 | 1046 | ||
| 1011 | dev_dbg(&pl022->adev->dev, "POLLING TRANSFER ONGOING ... \n"); | 1047 | dev_dbg(&pl022->adev->dev, "polling transfer ongoing ...\n"); |
| 1012 | /* FIXME: insert a timeout so we don't hang here indefinately */ | 1048 | /* FIXME: insert a timeout so we don't hang here indefinately */ |
| 1013 | while (pl022->tx < pl022->tx_end || pl022->rx < pl022->rx_end) | 1049 | while (pl022->tx < pl022->tx_end || pl022->rx < pl022->rx_end) |
| 1014 | readwriter(pl022); | 1050 | readwriter(pl022); |
| @@ -1280,11 +1316,21 @@ static int verify_controller_parameters(struct pl022 *pl022, | |||
| 1280 | "Wait State is configured incorrectly\n"); | 1316 | "Wait State is configured incorrectly\n"); |
| 1281 | return -EINVAL; | 1317 | return -EINVAL; |
| 1282 | } | 1318 | } |
| 1283 | if ((chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX) | 1319 | /* Half duplex is only available in the ST Micro version */ |
| 1284 | && (chip_info->duplex != | 1320 | if (pl022->vendor->extended_cr) { |
| 1285 | SSP_MICROWIRE_CHANNEL_HALF_DUPLEX)) { | 1321 | if ((chip_info->duplex != |
| 1286 | dev_err(chip_info->dev, | 1322 | SSP_MICROWIRE_CHANNEL_FULL_DUPLEX) |
| 1287 | "DUPLEX is configured incorrectly\n"); | 1323 | && (chip_info->duplex != |
| 1324 | SSP_MICROWIRE_CHANNEL_HALF_DUPLEX)) | ||
| 1325 | dev_err(chip_info->dev, | ||
| 1326 | "Microwire duplex mode is configured incorrectly\n"); | ||
| 1327 | return -EINVAL; | ||
| 1328 | } else { | ||
| 1329 | if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX) | ||
| 1330 | dev_err(chip_info->dev, | ||
| 1331 | "Microwire half duplex mode requested," | ||
| 1332 | " but this is only available in the" | ||
| 1333 | " ST version of PL022\n"); | ||
| 1288 | return -EINVAL; | 1334 | return -EINVAL; |
| 1289 | } | 1335 | } |
| 1290 | } | 1336 | } |
| @@ -1581,22 +1627,40 @@ static int pl022_setup(struct spi_device *spi) | |||
| 1581 | 1627 | ||
| 1582 | chip->cpsr = chip_info->clk_freq.cpsdvsr; | 1628 | chip->cpsr = chip_info->clk_freq.cpsdvsr; |
| 1583 | 1629 | ||
| 1584 | SSP_WRITE_BITS(chip->cr0, chip_info->data_size, SSP_CR0_MASK_DSS, 0); | 1630 | /* Special setup for the ST micro extended control registers */ |
| 1585 | SSP_WRITE_BITS(chip->cr0, chip_info->duplex, SSP_CR0_MASK_HALFDUP, 5); | 1631 | if (pl022->vendor->extended_cr) { |
| 1632 | SSP_WRITE_BITS(chip->cr0, chip_info->data_size, | ||
| 1633 | SSP_CR0_MASK_DSS_ST, 0); | ||
| 1634 | SSP_WRITE_BITS(chip->cr0, chip_info->duplex, | ||
| 1635 | SSP_CR0_MASK_HALFDUP_ST, 5); | ||
| 1636 | SSP_WRITE_BITS(chip->cr0, chip_info->ctrl_len, | ||
| 1637 | SSP_CR0_MASK_CSS_ST, 16); | ||
| 1638 | SSP_WRITE_BITS(chip->cr0, chip_info->iface, | ||
| 1639 | SSP_CR0_MASK_FRF_ST, 21); | ||
| 1640 | SSP_WRITE_BITS(chip->cr1, chip_info->endian_rx, | ||
| 1641 | SSP_CR1_MASK_RENDN_ST, 4); | ||
| 1642 | SSP_WRITE_BITS(chip->cr1, chip_info->endian_tx, | ||
| 1643 | SSP_CR1_MASK_TENDN_ST, 5); | ||
| 1644 | SSP_WRITE_BITS(chip->cr1, chip_info->wait_state, | ||
| 1645 | SSP_CR1_MASK_MWAIT_ST, 6); | ||
| 1646 | SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig, | ||
| 1647 | SSP_CR1_MASK_RXIFLSEL_ST, 7); | ||
| 1648 | SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig, | ||
| 1649 | SSP_CR1_MASK_TXIFLSEL_ST, 10); | ||
| 1650 | } else { | ||
| 1651 | SSP_WRITE_BITS(chip->cr0, chip_info->data_size, | ||
| 1652 | SSP_CR0_MASK_DSS, 0); | ||
| 1653 | SSP_WRITE_BITS(chip->cr0, chip_info->iface, | ||
| 1654 | SSP_CR0_MASK_FRF, 4); | ||
| 1655 | } | ||
| 1656 | /* Stuff that is common for all versions */ | ||
| 1586 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_pol, SSP_CR0_MASK_SPO, 6); | 1657 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_pol, SSP_CR0_MASK_SPO, 6); |
| 1587 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_phase, SSP_CR0_MASK_SPH, 7); | 1658 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_phase, SSP_CR0_MASK_SPH, 7); |
| 1588 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_freq.scr, SSP_CR0_MASK_SCR, 8); | 1659 | SSP_WRITE_BITS(chip->cr0, chip_info->clk_freq.scr, SSP_CR0_MASK_SCR, 8); |
| 1589 | SSP_WRITE_BITS(chip->cr0, chip_info->ctrl_len, SSP_CR0_MASK_CSS, 16); | ||
| 1590 | SSP_WRITE_BITS(chip->cr0, chip_info->iface, SSP_CR0_MASK_FRF, 21); | ||
| 1591 | SSP_WRITE_BITS(chip->cr1, chip_info->lbm, SSP_CR1_MASK_LBM, 0); | 1660 | SSP_WRITE_BITS(chip->cr1, chip_info->lbm, SSP_CR1_MASK_LBM, 0); |
| 1592 | SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1); | 1661 | SSP_WRITE_BITS(chip->cr1, SSP_DISABLED, SSP_CR1_MASK_SSE, 1); |
| 1593 | SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2); | 1662 | SSP_WRITE_BITS(chip->cr1, chip_info->hierarchy, SSP_CR1_MASK_MS, 2); |
| 1594 | SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3); | 1663 | SSP_WRITE_BITS(chip->cr1, chip_info->slave_tx_disable, SSP_CR1_MASK_SOD, 3); |
| 1595 | SSP_WRITE_BITS(chip->cr1, chip_info->endian_rx, SSP_CR1_MASK_RENDN, 4); | ||
| 1596 | SSP_WRITE_BITS(chip->cr1, chip_info->endian_tx, SSP_CR1_MASK_TENDN, 5); | ||
| 1597 | SSP_WRITE_BITS(chip->cr1, chip_info->wait_state, SSP_CR1_MASK_MWAIT, 6); | ||
| 1598 | SSP_WRITE_BITS(chip->cr1, chip_info->rx_lev_trig, SSP_CR1_MASK_RXIFLSEL, 7); | ||
| 1599 | SSP_WRITE_BITS(chip->cr1, chip_info->tx_lev_trig, SSP_CR1_MASK_TXIFLSEL, 10); | ||
| 1600 | 1664 | ||
| 1601 | /* Save controller_state */ | 1665 | /* Save controller_state */ |
| 1602 | spi_set_ctldata(spi, chip); | 1666 | spi_set_ctldata(spi, chip); |
| @@ -1809,6 +1873,7 @@ static struct vendor_data vendor_arm = { | |||
| 1809 | .fifodepth = 8, | 1873 | .fifodepth = 8, |
| 1810 | .max_bpw = 16, | 1874 | .max_bpw = 16, |
| 1811 | .unidir = false, | 1875 | .unidir = false, |
| 1876 | .extended_cr = false, | ||
| 1812 | }; | 1877 | }; |
| 1813 | 1878 | ||
| 1814 | 1879 | ||
| @@ -1816,6 +1881,7 @@ static struct vendor_data vendor_st = { | |||
| 1816 | .fifodepth = 32, | 1881 | .fifodepth = 32, |
| 1817 | .max_bpw = 32, | 1882 | .max_bpw = 32, |
| 1818 | .unidir = false, | 1883 | .unidir = false, |
| 1884 | .extended_cr = true, | ||
| 1819 | }; | 1885 | }; |
| 1820 | 1886 | ||
| 1821 | static struct amba_id pl022_ids[] = { | 1887 | static struct amba_id pl022_ids[] = { |
diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h index e4836c6b3dd7..612f39913340 100644 --- a/include/linux/amba/pl022.h +++ b/include/linux/amba/pl022.h | |||
| @@ -71,6 +71,7 @@ struct ssp_clock_params { | |||
| 71 | 71 | ||
| 72 | /** | 72 | /** |
| 73 | * enum ssp_rx_endian - endianess of Rx FIFO Data | 73 | * enum ssp_rx_endian - endianess of Rx FIFO Data |
| 74 | * this feature is only available in ST versionf of PL022 | ||
| 74 | */ | 75 | */ |
| 75 | enum ssp_rx_endian { | 76 | enum ssp_rx_endian { |
| 76 | SSP_RX_MSB, | 77 | SSP_RX_MSB, |
| @@ -181,7 +182,8 @@ enum ssp_microwire_wait_state { | |||
| 181 | }; | 182 | }; |
| 182 | 183 | ||
| 183 | /** | 184 | /** |
| 184 | * enum Microwire - whether Full/Half Duplex | 185 | * enum Microwire - whether Full/Half Duplex, only available |
| 186 | * in the ST Micro variant. | ||
| 185 | * @SSP_MICROWIRE_CHANNEL_FULL_DUPLEX: SSPTXD becomes bi-directional, | 187 | * @SSP_MICROWIRE_CHANNEL_FULL_DUPLEX: SSPTXD becomes bi-directional, |
| 186 | * SSPRXD not used | 188 | * SSPRXD not used |
| 187 | * @SSP_MICROWIRE_CHANNEL_HALF_DUPLEX: SSPTXD is an output, SSPRXD is | 189 | * @SSP_MICROWIRE_CHANNEL_HALF_DUPLEX: SSPTXD is an output, SSPRXD is |
