[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231027071426.17724-4-Linhua.xu@unisoc.com>
Date: Fri, 27 Oct 2023 15:14:23 +0800
From: Linhua Xu <Linhua.xu@...soc.com>
To: Linus Walleij <linus.walleij@...aro.org>
CC: Orson Zhai <orsonzhai@...il.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
Chunyan Zhang <zhang.lyra@...il.com>,
<linux-kernel@...r.kernel.org>, <linux-gpio@...r.kernel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
lh xu <xulh0829@...il.com>, Linhua Xu <Linhua.Xu@...soc.com>,
Zhirong Qiu <zhirong.qiu@...soc.com>,
Xiongpeng Wu <xiongpeng.wu@...soc.com>
Subject: [PATCH V3 3/6] pinctrl: sprd: Move common and misc offset parameters to private data
From: Linhua Xu <Linhua.Xu@...soc.com>
For UNISOC pin controller, the offset values of the common
register and misc register will be different. So add SoC
structure in sprd_pinctrl_of_match() and parse it in sprd-pinctrl_core.
Signed-off-by: Linhua Xu <Linhua.Xu@...soc.com>
---
drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c | 12 +++++++++---
drivers/pinctrl/sprd/pinctrl-sprd.c | 14 ++++++++++----
drivers/pinctrl/sprd/pinctrl-sprd.h | 5 +++++
3 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c b/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c
index d14f382f2392..6835f0f85888 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd-sc9860.c
@@ -10,6 +10,9 @@
#include "pinctrl-sprd.h"
+#define PINCTRL_REG_OFFSET 0x0020
+#define PINCTRL_REG_MISC_OFFSET 0x4020
+
enum sprd_sc9860_pins {
/* pin global control register 0 */
SC9860_VIO28_0_IRTE = SPRD_PIN_INFO(0, GLOBAL_CTRL_PIN, 11, 1, 0),
@@ -923,6 +926,11 @@ static struct sprd_pins_info sprd_sc9860_pins_info[] = {
SPRD_PINCTRL_PIN(SC9860_RFCTL39_MISC),
};
+static const struct sprd_pinctrl_priv_data sc9860_data = {
+ .common_offset = PINCTRL_REG_OFFSET,
+ .misc_offset = PINCTRL_REG_MISC_OFFSET,
+};
+
static int sprd_pinctrl_probe(struct platform_device *pdev)
{
return sprd_pinctrl_core_probe(pdev, sprd_sc9860_pins_info,
@@ -930,9 +938,7 @@ static int sprd_pinctrl_probe(struct platform_device *pdev)
}
static const struct of_device_id sprd_pinctrl_of_match[] = {
- {
- .compatible = "sprd,sc9860-pinctrl",
- },
+ { .compatible = "sprd,sc9860-pinctrl", .data = &sc9860_data},
{ },
};
MODULE_DEVICE_TABLE(of, sprd_pinctrl_of_match);
diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index b7a3cb9e7a61..7a79735ec30a 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -30,8 +30,6 @@
#include "pinctrl-sprd.h"
#define PINCTRL_BIT_MASK(width) (~(~0UL << (width)))
-#define PINCTRL_REG_OFFSET 0x20
-#define PINCTRL_REG_MISC_OFFSET 0x4020
#define PINCTRL_REG_LEN 0x4
#define PIN_FUNC_MASK (BIT(4) | BIT(5))
@@ -149,12 +147,14 @@ struct sprd_pinctrl_soc_info {
* @pctl: pointer to the pinctrl handle
* @base: base address of the controller
* @info: pointer to SoC's pins description information
+ * @pdata: pointer SoC's private data structure
*/
struct sprd_pinctrl {
struct device *dev;
struct pinctrl_dev *pctl;
void __iomem *base;
struct sprd_pinctrl_soc_info *info;
+ const struct sprd_pinctrl_priv_data *pdata;
};
#define SPRD_PIN_CONFIG_CONTROL (PIN_CONFIG_END + 1)
@@ -1026,12 +1026,12 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl,
ctrl_pin++;
} else if (pin->type == COMMON_PIN) {
pin->reg = (unsigned long)sprd_pctl->base +
- PINCTRL_REG_OFFSET + PINCTRL_REG_LEN *
+ sprd_pctl->pdata->common_offset + PINCTRL_REG_LEN *
(i - ctrl_pin);
com_pin++;
} else if (pin->type == MISC_PIN) {
pin->reg = (unsigned long)sprd_pctl->base +
- PINCTRL_REG_MISC_OFFSET + PINCTRL_REG_LEN *
+ sprd_pctl->pdata->misc_offset + PINCTRL_REG_LEN *
(i - ctrl_pin - com_pin);
}
}
@@ -1053,6 +1053,7 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
struct sprd_pinctrl *sprd_pctl;
struct sprd_pinctrl_soc_info *pinctrl_info;
struct pinctrl_pin_desc *pin_desc;
+ const struct sprd_pinctrl_priv_data *priv_data;
int ret, i;
sprd_pctl = devm_kzalloc(&pdev->dev, sizeof(struct sprd_pinctrl),
@@ -1070,6 +1071,11 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
if (!pinctrl_info)
return -ENOMEM;
+ priv_data = of_device_get_match_data(&pdev->dev);
+ if (!priv_data)
+ return -EINVAL;
+
+ sprd_pctl->pdata = priv_data;
sprd_pctl->info = pinctrl_info;
sprd_pctl->dev = &pdev->dev;
platform_set_drvdata(pdev, sprd_pctl);
diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.h b/drivers/pinctrl/sprd/pinctrl-sprd.h
index 69544a3cd635..23bced4665f1 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.h
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.h
@@ -50,6 +50,11 @@ struct sprd_pins_info {
unsigned int reg;
};
+struct sprd_pinctrl_priv_data {
+ unsigned long common_offset;
+ unsigned long misc_offset;
+};
+
int sprd_pinctrl_core_probe(struct platform_device *pdev,
struct sprd_pins_info *sprd_soc_pin_info,
int pins_cnt);
--
2.17.1
Powered by blists - more mailing lists