431-drivers-spi-mt65xx-Move-chip_config-to-driver-s-priv.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. From bfd3acc428085742d754a6d328d1a93ebf9451df Mon Sep 17 00:00:00 2001
  2. From: "SkyLake.Huang" <[email protected]>
  3. Date: Thu, 23 Jun 2022 18:29:51 +0800
  4. Subject: [PATCH 1/6] drivers: spi-mt65xx: Move chip_config to driver's private
  5. data
  6. Signed-off-by: SkyLake.Huang <[email protected]>
  7. ---
  8. drivers/spi/spi-mt65xx.c | 29 +++++++++---------------
  9. include/linux/platform_data/spi-mt65xx.h | 17 --------------
  10. 2 files changed, 11 insertions(+), 35 deletions(-)
  11. delete mode 100644 include/linux/platform_data/spi-mt65xx.h
  12. --- a/drivers/spi/spi-mt65xx.c
  13. +++ b/drivers/spi/spi-mt65xx.c
  14. @@ -14,7 +14,6 @@
  15. #include <linux/of.h>
  16. #include <linux/gpio/consumer.h>
  17. #include <linux/platform_device.h>
  18. -#include <linux/platform_data/spi-mt65xx.h>
  19. #include <linux/pm_runtime.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/spi/spi-mem.h>
  22. @@ -171,6 +170,8 @@ struct mtk_spi {
  23. struct device *dev;
  24. dma_addr_t tx_dma;
  25. dma_addr_t rx_dma;
  26. + u32 sample_sel;
  27. + u32 get_tick_dly;
  28. };
  29. static const struct mtk_spi_compatible mtk_common_compat;
  30. @@ -216,15 +217,6 @@ static const struct mtk_spi_compatible m
  31. .no_need_unprepare = true,
  32. };
  33. -/*
  34. - * A piece of default chip info unless the platform
  35. - * supplies it.
  36. - */
  37. -static const struct mtk_chip_config mtk_default_chip_info = {
  38. - .sample_sel = 0,
  39. - .tick_delay = 0,
  40. -};
  41. -
  42. static const struct of_device_id mtk_spi_of_match[] = {
  43. { .compatible = "mediatek,spi-ipm",
  44. .data = (void *)&mtk_ipm_compat,
  45. @@ -352,7 +344,6 @@ static int mtk_spi_hw_init(struct spi_ma
  46. {
  47. u16 cpha, cpol;
  48. u32 reg_val;
  49. - struct mtk_chip_config *chip_config = spi->controller_data;
  50. struct mtk_spi *mdata = spi_master_get_devdata(master);
  51. cpha = spi->mode & SPI_CPHA ? 1 : 0;
  52. @@ -402,7 +393,7 @@ static int mtk_spi_hw_init(struct spi_ma
  53. else
  54. reg_val &= ~SPI_CMD_CS_POL;
  55. - if (chip_config->sample_sel)
  56. + if (mdata->sample_sel)
  57. reg_val |= SPI_CMD_SAMPLE_SEL;
  58. else
  59. reg_val &= ~SPI_CMD_SAMPLE_SEL;
  60. @@ -429,20 +420,20 @@ static int mtk_spi_hw_init(struct spi_ma
  61. if (mdata->dev_comp->ipm_design) {
  62. reg_val = readl(mdata->base + SPI_CMD_REG);
  63. reg_val &= ~SPI_CMD_IPM_GET_TICKDLY_MASK;
  64. - reg_val |= ((chip_config->tick_delay & 0x7)
  65. + reg_val |= ((mdata->get_tick_dly & 0x7)
  66. << SPI_CMD_IPM_GET_TICKDLY_OFFSET);
  67. writel(reg_val, mdata->base + SPI_CMD_REG);
  68. } else {
  69. reg_val = readl(mdata->base + SPI_CFG1_REG);
  70. reg_val &= ~SPI_CFG1_GET_TICK_DLY_MASK;
  71. - reg_val |= ((chip_config->tick_delay & 0x7)
  72. + reg_val |= ((mdata->get_tick_dly & 0x7)
  73. << SPI_CFG1_GET_TICK_DLY_OFFSET);
  74. writel(reg_val, mdata->base + SPI_CFG1_REG);
  75. }
  76. } else {
  77. reg_val = readl(mdata->base + SPI_CFG1_REG);
  78. reg_val &= ~SPI_CFG1_GET_TICK_DLY_MASK_V1;
  79. - reg_val |= ((chip_config->tick_delay & 0x3)
  80. + reg_val |= ((mdata->get_tick_dly & 0x3)
  81. << SPI_CFG1_GET_TICK_DLY_OFFSET_V1);
  82. writel(reg_val, mdata->base + SPI_CFG1_REG);
  83. }
  84. @@ -732,9 +723,6 @@ static int mtk_spi_setup(struct spi_devi
  85. {
  86. struct mtk_spi *mdata = spi_master_get_devdata(spi->master);
  87. - if (!spi->controller_data)
  88. - spi->controller_data = (void *)&mtk_default_chip_info;
  89. -
  90. if (mdata->dev_comp->need_pad_sel && spi->cs_gpiod)
  91. /* CS de-asserted, gpiolib will handle inversion */
  92. gpiod_direction_output(spi->cs_gpiod, 0);
  93. @@ -1138,6 +1126,10 @@ static int mtk_spi_probe(struct platform
  94. mdata = spi_master_get_devdata(master);
  95. mdata->dev_comp = device_get_match_data(dev);
  96. + /* Set device configs to default first. Calibrate it later. */
  97. + mdata->sample_sel = 0;
  98. + mdata->get_tick_dly = 2;
  99. +
  100. if (mdata->dev_comp->enhance_timing)
  101. master->mode_bits |= SPI_CS_HIGH;
  102. --- a/include/linux/platform_data/spi-mt65xx.h
  103. +++ /dev/null
  104. @@ -1,17 +0,0 @@
  105. -/* SPDX-License-Identifier: GPL-2.0-only */
  106. -/*
  107. - * MTK SPI bus driver definitions
  108. - *
  109. - * Copyright (c) 2015 MediaTek Inc.
  110. - * Author: Leilk Liu <[email protected]>
  111. - */
  112. -
  113. -#ifndef ____LINUX_PLATFORM_DATA_SPI_MTK_H
  114. -#define ____LINUX_PLATFORM_DATA_SPI_MTK_H
  115. -
  116. -/* Board specific platform_data */
  117. -struct mtk_chip_config {
  118. - u32 sample_sel;
  119. - u32 tick_delay;
  120. -};
  121. -#endif