461-spi-ath79-add-fast-flash-read.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --- a/drivers/spi/spi-ath79.c
  2. +++ b/drivers/spi/spi-ath79.c
  3. @@ -101,9 +101,6 @@ static void ath79_spi_enable(struct ath7
  4. /* save CTRL register */
  5. sp->reg_ctrl = ath79_spi_rr(sp, AR71XX_SPI_REG_CTRL);
  6. sp->ioc_base = ath79_spi_rr(sp, AR71XX_SPI_REG_IOC);
  7. -
  8. - /* TODO: setup speed? */
  9. - ath79_spi_wr(sp, AR71XX_SPI_REG_CTRL, 0x43);
  10. }
  11. static void ath79_spi_disable(struct ath79_spi *sp)
  12. @@ -203,6 +200,38 @@ static u32 ath79_spi_txrx_mode0(struct s
  13. return ath79_spi_rr(sp, AR71XX_SPI_REG_RDS);
  14. }
  15. +static bool ath79_spi_flash_read_supported(struct spi_device *spi)
  16. +{
  17. + if (spi->chip_select || gpio_is_valid(spi->cs_gpio))
  18. + return false;
  19. +
  20. + return true;
  21. +}
  22. +
  23. +static int ath79_spi_read_flash_data(struct spi_device *spi,
  24. + struct spi_flash_read_message *msg)
  25. +{
  26. + struct ath79_spi *sp = ath79_spidev_to_sp(spi);
  27. +
  28. + if (msg->addr_width > 3)
  29. + return -EOPNOTSUPP;
  30. +
  31. + /* disable GPIO mode */
  32. + ath79_spi_wr(sp, AR71XX_SPI_REG_FS, 0);
  33. +
  34. + memcpy_fromio(msg->buf, sp->base + msg->from, msg->len);
  35. +
  36. + /* enable GPIO mode */
  37. + ath79_spi_wr(sp, AR71XX_SPI_REG_FS, AR71XX_SPI_FS_GPIO);
  38. +
  39. + /* restore IOC register */
  40. + ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, sp->ioc_base);
  41. +
  42. + msg->retlen = msg->len;
  43. +
  44. + return 0;
  45. +}
  46. +
  47. static int ath79_spi_probe(struct platform_device *pdev)
  48. {
  49. struct spi_master *master;
  50. @@ -237,6 +266,8 @@ static int ath79_spi_probe(struct platfo
  51. ret = PTR_ERR(sp->base);
  52. goto err_put_master;
  53. }
  54. + master->spi_flash_read = ath79_spi_read_flash_data;
  55. + master->flash_read_supported = ath79_spi_flash_read_supported;
  56. sp->clk = devm_clk_get(&pdev->dev, "ahb");
  57. if (IS_ERR(sp->clk)) {