developer | 1fec643 | 2022-06-23 18:49:35 +0800 | [diff] [blame] | 1 | From 45ec6dfcc5f48127d5bd440fb615bbf48f3fc9c1 Mon Sep 17 00:00:00 2001 |
| 2 | From: "SkyLake.Huang" <skylake.huang@mediatek.com> |
| 3 | Date: Thu, 23 Jun 2022 18:29:51 +0800 |
| 4 | Subject: [PATCH] drivers: spi-mt65xx: Move chip_config to driver's private |
| 5 | data |
| 6 | |
| 7 | Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com> |
| 8 | --- |
| 9 | drivers/spi/spi-mt65xx.c | 31 +++++++++++------------- |
| 10 | include/linux/platform_data/spi-mt65xx.h | 17 ------------- |
| 11 | 2 files changed, 14 insertions(+), 34 deletions(-) |
| 12 | delete mode 100644 include/linux/platform_data/spi-mt65xx.h |
| 13 | |
| 14 | diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c |
| 15 | index c19e2d4d7..0afd00891 100644 |
| 16 | --- a/drivers/spi/spi-mt65xx.c |
| 17 | +++ b/drivers/spi/spi-mt65xx.c |
| 18 | @@ -14,7 +14,6 @@ |
| 19 | #include <linux/of.h> |
| 20 | #include <linux/of_gpio.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | -#include <linux/platform_data/spi-mt65xx.h> |
| 23 | #include <linux/pm_runtime.h> |
| 24 | #include <linux/spi/spi.h> |
| 25 | #include <linux/spi/spi-mem.h> |
| 26 | @@ -123,6 +122,11 @@ struct mtk_spi_compatible { |
| 27 | bool need_ahb_clk; |
| 28 | }; |
| 29 | |
| 30 | +struct mtk_spi_config { |
| 31 | + u32 sample_sel; |
| 32 | + u32 get_tick_dly; |
| 33 | +}; |
| 34 | + |
| 35 | struct mtk_spi { |
| 36 | void __iomem *base; |
| 37 | u32 state; |
| 38 | @@ -135,6 +139,7 @@ struct mtk_spi { |
| 39 | struct scatterlist *tx_sgl, *rx_sgl; |
| 40 | u32 tx_sgl_len, rx_sgl_len; |
| 41 | const struct mtk_spi_compatible *dev_comp; |
| 42 | + struct mtk_spi_config dev_config; |
| 43 | |
| 44 | struct completion spimem_done; |
| 45 | bool use_spimem; |
| 46 | @@ -189,15 +194,6 @@ static const struct mtk_spi_compatible mt8183_compat = { |
| 47 | .enhance_timing = true, |
| 48 | }; |
| 49 | |
| 50 | -/* |
| 51 | - * A piece of default chip info unless the platform |
| 52 | - * supplies it. |
| 53 | - */ |
| 54 | -static const struct mtk_chip_config mtk_default_chip_info = { |
| 55 | - .sample_sel = 0, |
| 56 | - .get_tick_dly = 2, |
| 57 | -}; |
| 58 | - |
| 59 | static const struct of_device_id mtk_spi_of_match[] = { |
| 60 | { .compatible = "mediatek,ipm-spi-single", |
| 61 | .data = (void *)&ipm_compat_single, |
| 62 | @@ -255,7 +251,6 @@ static int mtk_spi_hw_init(struct spi_master *master, |
| 63 | { |
| 64 | u16 cpha, cpol; |
| 65 | u32 reg_val; |
| 66 | - struct mtk_chip_config *chip_config = spi->controller_data; |
| 67 | struct mtk_spi *mdata = spi_master_get_devdata(master); |
| 68 | |
| 69 | cpha = spi->mode & SPI_CPHA ? 1 : 0; |
| 70 | @@ -270,13 +265,13 @@ static int mtk_spi_hw_init(struct spi_master *master, |
| 71 | |
| 72 | reg_val = readl(mdata->base + SPI_CMD_REG); |
| 73 | reg_val &= ~SPI_CMD_IPM_GET_TICKDLY_MASK; |
| 74 | - reg_val |= chip_config->get_tick_dly |
| 75 | + reg_val |= mdata->dev_config.get_tick_dly |
| 76 | << SPI_CMD_IPM_GET_TICKDLY_OFFSET; |
| 77 | writel(reg_val, mdata->base + SPI_CMD_REG); |
| 78 | } else { |
| 79 | reg_val = readl(mdata->base + SPI_CFG1_REG); |
| 80 | reg_val &= ~SPI_CFG1_GET_TICKDLY_MASK; |
| 81 | - reg_val |= chip_config->get_tick_dly |
| 82 | + reg_val |= mdata->dev_config.get_tick_dly |
| 83 | << SPI_CFG1_GET_TICKDLY_OFFSET; |
| 84 | writel(reg_val, mdata->base + SPI_CFG1_REG); |
| 85 | } |
| 86 | @@ -326,7 +321,7 @@ static int mtk_spi_hw_init(struct spi_master *master, |
| 87 | else |
| 88 | reg_val &= ~SPI_CMD_CS_POL; |
| 89 | |
| 90 | - if (chip_config->sample_sel) |
| 91 | + if (mdata->dev_config.sample_sel) |
| 92 | reg_val |= SPI_CMD_SAMPLE_SEL; |
| 93 | else |
| 94 | reg_val &= ~SPI_CMD_SAMPLE_SEL; |
| 95 | @@ -623,9 +618,6 @@ static int mtk_spi_setup(struct spi_device *spi) |
| 96 | { |
| 97 | struct mtk_spi *mdata = spi_master_get_devdata(spi->master); |
| 98 | |
| 99 | - if (!spi->controller_data) |
| 100 | - spi->controller_data = (void *)&mtk_default_chip_info; |
| 101 | - |
| 102 | if (mdata->dev_comp->need_pad_sel && gpio_is_valid(spi->cs_gpio)) |
| 103 | gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); |
| 104 | |
| 105 | @@ -1025,6 +1017,11 @@ static int mtk_spi_probe(struct platform_device *pdev) |
| 106 | } |
| 107 | |
| 108 | mdata = spi_master_get_devdata(master); |
| 109 | + |
| 110 | + /* Set device configs to default first. Calibrate it later. */ |
| 111 | + mdata->dev_config.sample_sel = 0; |
| 112 | + mdata->dev_config.get_tick_dly = 2; |
| 113 | + |
| 114 | mdata->dev_comp = of_id->data; |
| 115 | |
| 116 | if (mdata->dev_comp->enhance_timing) |
| 117 | diff --git a/include/linux/platform_data/spi-mt65xx.h b/include/linux/platform_data/spi-mt65xx.h |
| 118 | deleted file mode 100644 |
| 119 | index fae9bc15c..000000000 |
| 120 | --- a/include/linux/platform_data/spi-mt65xx.h |
| 121 | +++ /dev/null |
| 122 | @@ -1,17 +0,0 @@ |
| 123 | -/* SPDX-License-Identifier: GPL-2.0-only */ |
| 124 | -/* |
| 125 | - * MTK SPI bus driver definitions |
| 126 | - * |
| 127 | - * Copyright (c) 2015 MediaTek Inc. |
| 128 | - * Author: Leilk Liu <leilk.liu@mediatek.com> |
| 129 | - */ |
| 130 | - |
| 131 | -#ifndef ____LINUX_PLATFORM_DATA_SPI_MTK_H |
| 132 | -#define ____LINUX_PLATFORM_DATA_SPI_MTK_H |
| 133 | - |
| 134 | -/* Board specific platform_data */ |
| 135 | -struct mtk_chip_config { |
| 136 | - u32 sample_sel; |
| 137 | - u32 get_tick_dly; |
| 138 | -}; |
| 139 | -#endif |
| 140 | -- |
| 141 | 2.18.0 |
| 142 | |