2023-04-20 17:34:47 +00:00
|
|
|
From 73d20ebc21c562fbe79d02fa0fa38e095e716fa9 Mon Sep 17 00:00:00 2001
|
2023-03-10 19:57:18 +00:00
|
|
|
From: Daniel Golle <daniel@makrotopia.org>
|
2023-04-20 17:34:47 +00:00
|
|
|
Date: Wed, 19 Apr 2023 20:25:51 +0100
|
2023-03-10 19:57:18 +00:00
|
|
|
Subject: [PATCH] pwm: mediatek: Add support for MT7981
|
|
|
|
|
|
|
|
The PWM unit on MT7981 uses different register offsets than previous
|
|
|
|
MediaTek PWM units. Add support for these new offsets and add support
|
|
|
|
for PWM on MT7981 which has 3 PWM channels, one of them is typically
|
|
|
|
used for a temperature controlled fan.
|
|
|
|
|
|
|
|
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
|
|
|
---
|
2023-04-20 17:34:47 +00:00
|
|
|
drivers/pwm/pwm-mediatek.c | 41 ++++++++++++++++++++++++++++++--------
|
|
|
|
1 file changed, 33 insertions(+), 8 deletions(-)
|
2023-03-10 19:57:18 +00:00
|
|
|
|
|
|
|
--- a/drivers/pwm/pwm-mediatek.c
|
|
|
|
+++ b/drivers/pwm/pwm-mediatek.c
|
2023-04-20 17:34:47 +00:00
|
|
|
@@ -38,6 +38,7 @@ struct pwm_mediatek_of_data {
|
2023-03-10 19:57:18 +00:00
|
|
|
unsigned int num_pwms;
|
|
|
|
bool pwm45_fixup;
|
|
|
|
bool has_ck_26m_sel;
|
2023-04-20 17:34:47 +00:00
|
|
|
+ const unsigned int *reg_offset;
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2023-04-20 17:34:47 +00:00
|
|
|
@@ -59,10 +60,14 @@ struct pwm_mediatek_chip {
|
2023-03-10 19:57:18 +00:00
|
|
|
const struct pwm_mediatek_of_data *soc;
|
|
|
|
};
|
|
|
|
|
|
|
|
-static const unsigned int pwm_mediatek_reg_offset[] = {
|
|
|
|
+static const unsigned int mtk_pwm_reg_offset_v1[] = {
|
|
|
|
0x0010, 0x0050, 0x0090, 0x00d0, 0x0110, 0x0150, 0x0190, 0x0220
|
|
|
|
};
|
|
|
|
|
|
|
|
+static const unsigned int mtk_pwm_reg_offset_v2[] = {
|
2023-04-20 17:34:47 +00:00
|
|
|
+ 0x0080, 0x00c0, 0x0100, 0x0140, 0x0180, 0x01c0, 0x0200, 0x0240
|
2023-03-10 19:57:18 +00:00
|
|
|
+};
|
|
|
|
+
|
|
|
|
static inline struct pwm_mediatek_chip *
|
|
|
|
to_pwm_mediatek_chip(struct pwm_chip *chip)
|
|
|
|
{
|
2023-04-20 17:34:47 +00:00
|
|
|
@@ -111,7 +116,7 @@ static inline void pwm_mediatek_writel(s
|
2023-03-10 19:57:18 +00:00
|
|
|
unsigned int num, unsigned int offset,
|
|
|
|
u32 value)
|
|
|
|
{
|
|
|
|
- writel(value, chip->regs + pwm_mediatek_reg_offset[num] + offset);
|
2023-04-20 17:34:47 +00:00
|
|
|
+ writel(value, chip->regs + chip->soc->reg_offset[num] + offset);
|
2023-03-10 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
2023-04-20 17:34:47 +00:00
|
|
|
@@ -270,48 +275,63 @@ static const struct pwm_mediatek_of_data
|
2023-03-10 19:57:18 +00:00
|
|
|
.num_pwms = 8,
|
|
|
|
.pwm45_fixup = false,
|
|
|
|
.has_ck_26m_sel = false,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pwm_mediatek_of_data mt7622_pwm_data = {
|
|
|
|
.num_pwms = 6,
|
|
|
|
.pwm45_fixup = false,
|
|
|
|
.has_ck_26m_sel = true,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pwm_mediatek_of_data mt7623_pwm_data = {
|
|
|
|
.num_pwms = 5,
|
|
|
|
.pwm45_fixup = true,
|
|
|
|
.has_ck_26m_sel = false,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pwm_mediatek_of_data mt7628_pwm_data = {
|
|
|
|
.num_pwms = 4,
|
|
|
|
.pwm45_fixup = true,
|
|
|
|
.has_ck_26m_sel = false,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pwm_mediatek_of_data mt7629_pwm_data = {
|
|
|
|
.num_pwms = 1,
|
|
|
|
.pwm45_fixup = false,
|
|
|
|
.has_ck_26m_sel = false,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
2023-04-20 17:34:47 +00:00
|
|
|
static const struct pwm_mediatek_of_data mt8183_pwm_data = {
|
|
|
|
.num_pwms = 4,
|
2023-03-10 19:57:18 +00:00
|
|
|
.pwm45_fixup = false,
|
|
|
|
.has_ck_26m_sel = true,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static const struct pwm_mediatek_of_data mt7981_pwm_data = {
|
|
|
|
+ .num_pwms = 3,
|
|
|
|
+ .pwm45_fixup = false,
|
|
|
|
+ .has_ck_26m_sel = true,
|
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v2,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pwm_mediatek_of_data mt7986_pwm_data = {
|
|
|
|
.num_pwms = 2,
|
|
|
|
.pwm45_fixup = false,
|
|
|
|
.has_ck_26m_sel = true,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct pwm_mediatek_of_data mt8516_pwm_data = {
|
|
|
|
.num_pwms = 5,
|
|
|
|
.pwm45_fixup = false,
|
|
|
|
.has_ck_26m_sel = true,
|
2023-04-20 17:34:47 +00:00
|
|
|
+ .reg_offset = mtk_pwm_reg_offset_v1,
|
2023-03-10 19:57:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct of_device_id pwm_mediatek_of_match[] = {
|
2023-04-20 17:34:47 +00:00
|
|
|
@@ -320,6 +340,7 @@ static const struct of_device_id pwm_med
|
2023-03-10 19:57:18 +00:00
|
|
|
{ .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data },
|
|
|
|
{ .compatible = "mediatek,mt7628-pwm", .data = &mt7628_pwm_data },
|
|
|
|
{ .compatible = "mediatek,mt7629-pwm", .data = &mt7629_pwm_data },
|
|
|
|
+ { .compatible = "mediatek,mt7981-pwm", .data = &mt7981_pwm_data },
|
|
|
|
{ .compatible = "mediatek,mt7986-pwm", .data = &mt7986_pwm_data },
|
|
|
|
{ .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data },
|
|
|
|
{ .compatible = "mediatek,mt8516-pwm", .data = &mt8516_pwm_data },
|