Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: s3c64xx: add support for google,gs101-spi

Merge series from Tudor Ambarus <tudor.ambarus@linaro.org>:

The Google GCS101 uses a variant of the Samsung SPI controller IP.

+71 -15
+1
Documentation/devicetree/bindings/spi/samsung,spi.yaml
··· 17 17 compatible: 18 18 oneOf: 19 19 - enum: 20 + - google,gs101-spi 20 21 - samsung,s3c2443-spi # for S3C2443, S3C2416 and S3C2450 21 22 - samsung,s3c6410-spi 22 23 - samsung,s5pv210-spi # for S5PV210 and S5PC110
+70 -15
drivers/spi/spi-s3c64xx.c
··· 17 17 18 18 #include <linux/platform_data/spi-s3c64xx.h> 19 19 20 - #define MAX_SPI_PORTS 12 20 + #define MAX_SPI_PORTS 16 21 21 #define S3C64XX_SPI_QUIRK_CS_AUTO (1 << 1) 22 22 #define AUTOSUSPEND_TIMEOUT 2000 23 23 ··· 142 142 * prescaler unit. 143 143 * @clk_ioclk: True if clock is present on this device 144 144 * @has_loopback: True if loopback mode can be supported 145 + * @use_32bit_io: True if the SoC allows only 32-bit register accesses. 145 146 * 146 147 * The Samsung s3c64xx SPI controller are used on various Samsung SoC's but 147 148 * differ in some aspects such as the size of the fifo and spi bus clock ··· 159 158 bool clk_from_cmu; 160 159 bool clk_ioclk; 161 160 bool has_loopback; 161 + bool use_32bit_io; 162 162 }; 163 163 164 164 /** ··· 416 414 417 415 } 418 416 417 + static void s3c64xx_iowrite8_32_rep(volatile void __iomem *addr, 418 + const void *buffer, unsigned int count) 419 + { 420 + if (count) { 421 + const u8 *buf = buffer; 422 + 423 + do { 424 + __raw_writel(*buf++, addr); 425 + } while (--count); 426 + } 427 + } 428 + 429 + static void s3c64xx_iowrite16_32_rep(volatile void __iomem *addr, 430 + const void *buffer, unsigned int count) 431 + { 432 + if (count) { 433 + const u16 *buf = buffer; 434 + 435 + do { 436 + __raw_writel(*buf++, addr); 437 + } while (--count); 438 + } 439 + } 440 + 441 + static void s3c64xx_iowrite_rep(const struct s3c64xx_spi_driver_data *sdd, 442 + struct spi_transfer *xfer) 443 + { 444 + void __iomem *addr = sdd->regs + S3C64XX_SPI_TX_DATA; 445 + const void *buf = xfer->tx_buf; 446 + unsigned int len = xfer->len; 447 + 448 + switch (sdd->cur_bpw) { 449 + case 32: 450 + iowrite32_rep(addr, buf, len / 4); 451 + break; 452 + case 16: 453 + if (sdd->port_conf->use_32bit_io) 454 + s3c64xx_iowrite16_32_rep(addr, buf, len / 2); 455 + else 456 + iowrite16_rep(addr, buf, len / 2); 457 + break; 458 + default: 459 + if (sdd->port_conf->use_32bit_io) 460 + s3c64xx_iowrite8_32_rep(addr, buf, len); 461 + else 462 + iowrite8_rep(addr, buf, len); 463 + break; 464 + } 465 + } 466 + 419 467 static int s3c64xx_enable_datapath(struct s3c64xx_spi_driver_data *sdd, 420 468 struct spi_transfer *xfer, int dma_mode) 421 469 { ··· 499 447 modecfg |= S3C64XX_SPI_MODE_TXDMA_ON; 500 448 ret = prepare_dma(&sdd->tx_dma, &xfer->tx_sg); 501 449 } else { 502 - switch (sdd->cur_bpw) { 503 - case 32: 504 - iowrite32_rep(regs + S3C64XX_SPI_TX_DATA, 505 - xfer->tx_buf, xfer->len / 4); 506 - break; 507 - case 16: 508 - iowrite16_rep(regs + S3C64XX_SPI_TX_DATA, 509 - xfer->tx_buf, xfer->len / 2); 510 - break; 511 - default: 512 - iowrite8_rep(regs + S3C64XX_SPI_TX_DATA, 513 - xfer->tx_buf, xfer->len); 514 - break; 515 - } 450 + s3c64xx_iowrite_rep(sdd, xfer); 516 451 } 517 452 } 518 453 ··· 1534 1495 .quirks = S3C64XX_SPI_QUIRK_CS_AUTO, 1535 1496 }; 1536 1497 1498 + static const struct s3c64xx_spi_port_config gs101_spi_port_config = { 1499 + .fifo_lvl_mask = { 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 1500 + 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f}, 1501 + .rx_lvl_offset = 15, 1502 + .tx_st_done = 25, 1503 + .clk_div = 4, 1504 + .high_speed = true, 1505 + .clk_from_cmu = true, 1506 + .has_loopback = true, 1507 + .use_32bit_io = true, 1508 + .quirks = S3C64XX_SPI_QUIRK_CS_AUTO, 1509 + }; 1510 + 1537 1511 static const struct platform_device_id s3c64xx_spi_driver_ids[] = { 1538 1512 { 1539 1513 .name = "s3c2443-spi", ··· 1559 1507 }; 1560 1508 1561 1509 static const struct of_device_id s3c64xx_spi_dt_match[] = { 1510 + { .compatible = "google,gs101-spi", 1511 + .data = &gs101_spi_port_config, 1512 + }, 1562 1513 { .compatible = "samsung,s3c2443-spi", 1563 1514 .data = (void *)&s3c2443_spi_port_config, 1564 1515 },