mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 11:09:57 +08:00
143 lines
4.2 KiB
Diff
143 lines
4.2 KiB
Diff
From 45ec6dfcc5f48127d5bd440fb615bbf48f3fc9c1 Mon Sep 17 00:00:00 2001
|
|
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
|
Date: Thu, 23 Jun 2022 18:29:51 +0800
|
|
Subject: [PATCH] drivers: spi-mt65xx: Move chip_config to driver's private
|
|
data
|
|
|
|
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
|
---
|
|
drivers/spi/spi-mt65xx.c | 31 +++++++++++-------------
|
|
include/linux/platform_data/spi-mt65xx.h | 17 -------------
|
|
2 files changed, 14 insertions(+), 34 deletions(-)
|
|
delete mode 100644 include/linux/platform_data/spi-mt65xx.h
|
|
|
|
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
|
|
index c19e2d4d7..0afd00891 100644
|
|
--- a/drivers/spi/spi-mt65xx.c
|
|
+++ b/drivers/spi/spi-mt65xx.c
|
|
@@ -14,7 +14,6 @@
|
|
#include <linux/of.h>
|
|
#include <linux/of_gpio.h>
|
|
#include <linux/platform_device.h>
|
|
-#include <linux/platform_data/spi-mt65xx.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/spi/spi-mem.h>
|
|
@@ -123,6 +122,11 @@ struct mtk_spi_compatible {
|
|
bool need_ahb_clk;
|
|
};
|
|
|
|
+struct mtk_spi_config {
|
|
+ u32 sample_sel;
|
|
+ u32 get_tick_dly;
|
|
+};
|
|
+
|
|
struct mtk_spi {
|
|
void __iomem *base;
|
|
u32 state;
|
|
@@ -135,6 +139,7 @@ struct mtk_spi {
|
|
struct scatterlist *tx_sgl, *rx_sgl;
|
|
u32 tx_sgl_len, rx_sgl_len;
|
|
const struct mtk_spi_compatible *dev_comp;
|
|
+ struct mtk_spi_config dev_config;
|
|
|
|
struct completion spimem_done;
|
|
bool use_spimem;
|
|
@@ -189,15 +194,6 @@ static const struct mtk_spi_compatible mt8183_compat = {
|
|
.enhance_timing = true,
|
|
};
|
|
|
|
-/*
|
|
- * A piece of default chip info unless the platform
|
|
- * supplies it.
|
|
- */
|
|
-static const struct mtk_chip_config mtk_default_chip_info = {
|
|
- .sample_sel = 0,
|
|
- .get_tick_dly = 2,
|
|
-};
|
|
-
|
|
static const struct of_device_id mtk_spi_of_match[] = {
|
|
{ .compatible = "mediatek,ipm-spi-single",
|
|
.data = (void *)&ipm_compat_single,
|
|
@@ -255,7 +251,6 @@ static int mtk_spi_hw_init(struct spi_master *master,
|
|
{
|
|
u16 cpha, cpol;
|
|
u32 reg_val;
|
|
- struct mtk_chip_config *chip_config = spi->controller_data;
|
|
struct mtk_spi *mdata = spi_master_get_devdata(master);
|
|
|
|
cpha = spi->mode & SPI_CPHA ? 1 : 0;
|
|
@@ -270,13 +265,13 @@ static int mtk_spi_hw_init(struct spi_master *master,
|
|
|
|
reg_val = readl(mdata->base + SPI_CMD_REG);
|
|
reg_val &= ~SPI_CMD_IPM_GET_TICKDLY_MASK;
|
|
- reg_val |= chip_config->get_tick_dly
|
|
+ reg_val |= mdata->dev_config.get_tick_dly
|
|
<< SPI_CMD_IPM_GET_TICKDLY_OFFSET;
|
|
writel(reg_val, mdata->base + SPI_CMD_REG);
|
|
} else {
|
|
reg_val = readl(mdata->base + SPI_CFG1_REG);
|
|
reg_val &= ~SPI_CFG1_GET_TICKDLY_MASK;
|
|
- reg_val |= chip_config->get_tick_dly
|
|
+ reg_val |= mdata->dev_config.get_tick_dly
|
|
<< SPI_CFG1_GET_TICKDLY_OFFSET;
|
|
writel(reg_val, mdata->base + SPI_CFG1_REG);
|
|
}
|
|
@@ -326,7 +321,7 @@ static int mtk_spi_hw_init(struct spi_master *master,
|
|
else
|
|
reg_val &= ~SPI_CMD_CS_POL;
|
|
|
|
- if (chip_config->sample_sel)
|
|
+ if (mdata->dev_config.sample_sel)
|
|
reg_val |= SPI_CMD_SAMPLE_SEL;
|
|
else
|
|
reg_val &= ~SPI_CMD_SAMPLE_SEL;
|
|
@@ -623,9 +618,6 @@ static int mtk_spi_setup(struct spi_device *spi)
|
|
{
|
|
struct mtk_spi *mdata = spi_master_get_devdata(spi->master);
|
|
|
|
- if (!spi->controller_data)
|
|
- spi->controller_data = (void *)&mtk_default_chip_info;
|
|
-
|
|
if (mdata->dev_comp->need_pad_sel && gpio_is_valid(spi->cs_gpio))
|
|
gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
|
|
|
|
@@ -1025,6 +1017,11 @@ static int mtk_spi_probe(struct platform_device *pdev)
|
|
}
|
|
|
|
mdata = spi_master_get_devdata(master);
|
|
+
|
|
+ /* Set device configs to default first. Calibrate it later. */
|
|
+ mdata->dev_config.sample_sel = 0;
|
|
+ mdata->dev_config.get_tick_dly = 2;
|
|
+
|
|
mdata->dev_comp = of_id->data;
|
|
|
|
if (mdata->dev_comp->enhance_timing)
|
|
diff --git a/include/linux/platform_data/spi-mt65xx.h b/include/linux/platform_data/spi-mt65xx.h
|
|
deleted file mode 100644
|
|
index fae9bc15c..000000000
|
|
--- a/include/linux/platform_data/spi-mt65xx.h
|
|
+++ /dev/null
|
|
@@ -1,17 +0,0 @@
|
|
-/* SPDX-License-Identifier: GPL-2.0-only */
|
|
-/*
|
|
- * MTK SPI bus driver definitions
|
|
- *
|
|
- * Copyright (c) 2015 MediaTek Inc.
|
|
- * Author: Leilk Liu <leilk.liu@mediatek.com>
|
|
- */
|
|
-
|
|
-#ifndef ____LINUX_PLATFORM_DATA_SPI_MTK_H
|
|
-#define ____LINUX_PLATFORM_DATA_SPI_MTK_H
|
|
-
|
|
-/* Board specific platform_data */
|
|
-struct mtk_chip_config {
|
|
- u32 sample_sel;
|
|
- u32 get_tick_dly;
|
|
-};
|
|
-#endif
|
|
--
|
|
2.18.0
|
|
|