* [PATCH v1 1/6] pwm: Add a stub for devm_pwmchip_add()
2022-11-01 15:56 [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Andy Shevchenko
@ 2022-11-01 15:56 ` Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 2/6] pwm: lpss: Rename MAX_PWMS --> LPSS_MAX_PWMS Andy Shevchenko
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2022-11-01 15:56 UTC (permalink / raw)
To: Andy Shevchenko, Hans de Goede, Uwe Kleine-König,
Thierry Reding, linux-kernel, linux-gpio, linux-pwm
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij
devm_pwmchip_add() can be called by a module that optionally
instantiates PWM chip. In case of CONFIG_PWM=n, the compilation
can't be performed. Hence, add a necessary stub.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/pwm.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index d70c6e5a839d..bba492eea96c 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -478,6 +478,11 @@ static inline int pwmchip_remove(struct pwm_chip *chip)
return -EINVAL;
}
+static inline int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip)
+{
+ return -EINVAL;
+}
+
static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
unsigned int index,
const char *label)
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 2/6] pwm: lpss: Rename MAX_PWMS --> LPSS_MAX_PWMS
2022-11-01 15:56 [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 1/6] pwm: Add a stub for devm_pwmchip_add() Andy Shevchenko
@ 2022-11-01 15:56 ` Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 3/6] pwm: lpss: Include headers we are direct user of Andy Shevchenko
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2022-11-01 15:56 UTC (permalink / raw)
To: Andy Shevchenko, Hans de Goede, Uwe Kleine-König,
Thierry Reding, linux-kernel, linux-gpio, linux-pwm
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij
The MAX_PWMS definition is already being used by PWM core.
Using the same name in the certain driver confuses people
and potentially can clash with it.
Hence, rename it by adding LPSS prefix.
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pwm/pwm-lpss.c | 2 +-
drivers/pwm/pwm-lpss.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
index accdef5dd58e..b8739cd2c235 100644
--- a/drivers/pwm/pwm-lpss.c
+++ b/drivers/pwm/pwm-lpss.c
@@ -252,7 +252,7 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
int i, ret;
u32 ctrl;
- if (WARN_ON(info->npwm > MAX_PWMS))
+ if (WARN_ON(info->npwm > LPSS_MAX_PWMS))
return ERR_PTR(-ENODEV);
lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
index 8e82eb5a7e00..2c746c51b883 100644
--- a/drivers/pwm/pwm-lpss.h
+++ b/drivers/pwm/pwm-lpss.h
@@ -13,7 +13,7 @@
#include <linux/device.h>
#include <linux/pwm.h>
-#define MAX_PWMS 4
+#define LPSS_MAX_PWMS 4
struct pwm_lpss_chip {
struct pwm_chip chip;
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 3/6] pwm: lpss: Include headers we are direct user of
2022-11-01 15:56 [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 1/6] pwm: Add a stub for devm_pwmchip_add() Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 2/6] pwm: lpss: Rename MAX_PWMS --> LPSS_MAX_PWMS Andy Shevchenko
@ 2022-11-01 15:56 ` Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 4/6] pwm: lpss: Allow other drivers to enable PWM LPSS Andy Shevchenko
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2022-11-01 15:56 UTC (permalink / raw)
To: Andy Shevchenko, Hans de Goede, Uwe Kleine-König,
Thierry Reding, linux-kernel, linux-gpio, linux-pwm
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij
For the sake of integrity, include headers we are direct user of.
While at it, move the struct pwm_lpss_chip to be after
the struct pwm_lpss_boardinfo as the former uses pointer
to the latter.
Replace device.h with a forward declaration in order to improve
the compilation time due to reducing overhead of device.h parsing
with entire train of dependencies.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/pwm/pwm-lpss.h | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
index 2c746c51b883..4561d229b27d 100644
--- a/drivers/pwm/pwm-lpss.h
+++ b/drivers/pwm/pwm-lpss.h
@@ -10,16 +10,12 @@
#ifndef __PWM_LPSS_H
#define __PWM_LPSS_H
-#include <linux/device.h>
#include <linux/pwm.h>
+#include <linux/types.h>
-#define LPSS_MAX_PWMS 4
+struct device;
-struct pwm_lpss_chip {
- struct pwm_chip chip;
- void __iomem *regs;
- const struct pwm_lpss_boardinfo *info;
-};
+#define LPSS_MAX_PWMS 4
struct pwm_lpss_boardinfo {
unsigned long clk_rate;
@@ -43,6 +39,12 @@ extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info;
extern const struct pwm_lpss_boardinfo pwm_lpss_bxt_info;
extern const struct pwm_lpss_boardinfo pwm_lpss_tng_info;
+struct pwm_lpss_chip {
+ struct pwm_chip chip;
+ void __iomem *regs;
+ const struct pwm_lpss_boardinfo *info;
+};
+
struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
const struct pwm_lpss_boardinfo *info);
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 4/6] pwm: lpss: Allow other drivers to enable PWM LPSS
2022-11-01 15:56 [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Andy Shevchenko
` (2 preceding siblings ...)
2022-11-01 15:56 ` [PATCH v1 3/6] pwm: lpss: Include headers we are direct user of Andy Shevchenko
@ 2022-11-01 15:56 ` Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 5/6] pwm: lpss: Add pwm_lpss_probe() stub Andy Shevchenko
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2022-11-01 15:56 UTC (permalink / raw)
To: Andy Shevchenko, Hans de Goede, Uwe Kleine-König,
Thierry Reding, linux-kernel, linux-gpio, linux-pwm
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij
The PWM LPSS device can be embedded in another device.
In order to enable it, allow that drivers to probe
a corresponding device.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/pwm/pwm-lpss.h | 22 +--------------
.../linux/platform_data/x86}/pwm-lpss.h | 28 ++++---------------
2 files changed, 6 insertions(+), 44 deletions(-)
copy {drivers/pwm => include/linux/platform_data/x86}/pwm-lpss.h (53%)
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
index 4561d229b27d..b721532c6c3c 100644
--- a/drivers/pwm/pwm-lpss.h
+++ b/drivers/pwm/pwm-lpss.h
@@ -13,27 +13,10 @@
#include <linux/pwm.h>
#include <linux/types.h>
-struct device;
+#include <linux/platform_data/x86/pwm-lpss.h>
#define LPSS_MAX_PWMS 4
-struct pwm_lpss_boardinfo {
- unsigned long clk_rate;
- unsigned int npwm;
- unsigned long base_unit_bits;
- /*
- * Some versions of the IP may stuck in the state machine if enable
- * bit is not set, and hence update bit will show busy status till
- * the reset. For the rest it may be otherwise.
- */
- bool bypass;
- /*
- * On some devices the _PS0/_PS3 AML code of the GPU (GFX0) device
- * messes with the PWM0 controllers state,
- */
- bool other_devices_aml_touches_pwm_regs;
-};
-
extern const struct pwm_lpss_boardinfo pwm_lpss_byt_info;
extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info;
extern const struct pwm_lpss_boardinfo pwm_lpss_bxt_info;
@@ -45,7 +28,4 @@ struct pwm_lpss_chip {
const struct pwm_lpss_boardinfo *info;
};
-struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
- const struct pwm_lpss_boardinfo *info);
-
#endif /* __PWM_LPSS_H */
diff --git a/drivers/pwm/pwm-lpss.h b/include/linux/platform_data/x86/pwm-lpss.h
similarity index 53%
copy from drivers/pwm/pwm-lpss.h
copy to include/linux/platform_data/x86/pwm-lpss.h
index 4561d229b27d..296bd837ddbb 100644
--- a/drivers/pwm/pwm-lpss.h
+++ b/include/linux/platform_data/x86/pwm-lpss.h
@@ -1,21 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel Low Power Subsystem PWM controller driver
- *
- * Copyright (C) 2014, Intel Corporation
- *
- * Derived from the original pwm-lpss.c
- */
+/* Intel Low Power Subsystem PWM controller driver */
-#ifndef __PWM_LPSS_H
-#define __PWM_LPSS_H
+#ifndef __PLATFORM_DATA_X86_PWM_LPSS_H
+#define __PLATFORM_DATA_X86_PWM_LPSS_H
-#include <linux/pwm.h>
#include <linux/types.h>
struct device;
-#define LPSS_MAX_PWMS 4
+struct pwm_lpss_chip;
struct pwm_lpss_boardinfo {
unsigned long clk_rate;
@@ -34,18 +27,7 @@ struct pwm_lpss_boardinfo {
bool other_devices_aml_touches_pwm_regs;
};
-extern const struct pwm_lpss_boardinfo pwm_lpss_byt_info;
-extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info;
-extern const struct pwm_lpss_boardinfo pwm_lpss_bxt_info;
-extern const struct pwm_lpss_boardinfo pwm_lpss_tng_info;
-
-struct pwm_lpss_chip {
- struct pwm_chip chip;
- void __iomem *regs;
- const struct pwm_lpss_boardinfo *info;
-};
-
struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
const struct pwm_lpss_boardinfo *info);
-#endif /* __PWM_LPSS_H */
+#endif /* __PLATFORM_DATA_X86_PWM_LPSS_H */
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 5/6] pwm: lpss: Add pwm_lpss_probe() stub
2022-11-01 15:56 [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Andy Shevchenko
` (3 preceding siblings ...)
2022-11-01 15:56 ` [PATCH v1 4/6] pwm: lpss: Allow other drivers to enable PWM LPSS Andy Shevchenko
@ 2022-11-01 15:56 ` Andy Shevchenko
2022-11-01 15:56 ` [PATCH v1 6/6] pinctrl: intel: Enumerate PWM device when community has a capabilitty Andy Shevchenko
2022-11-02 12:19 ` [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Mika Westerberg
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2022-11-01 15:56 UTC (permalink / raw)
To: Andy Shevchenko, Hans de Goede, Uwe Kleine-König,
Thierry Reding, linux-kernel, linux-gpio, linux-pwm
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij
In case the PWM LPSS module is not provided, allow users to be
compiled with a help of a pwm_lpss_probe() stub.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/platform_data/x86/pwm-lpss.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/platform_data/x86/pwm-lpss.h b/include/linux/platform_data/x86/pwm-lpss.h
index 296bd837ddbb..c868b396ed2c 100644
--- a/include/linux/platform_data/x86/pwm-lpss.h
+++ b/include/linux/platform_data/x86/pwm-lpss.h
@@ -4,6 +4,8 @@
#ifndef __PLATFORM_DATA_X86_PWM_LPSS_H
#define __PLATFORM_DATA_X86_PWM_LPSS_H
+#include <linux/err.h>
+#include <linux/kconfig.h>
#include <linux/types.h>
struct device;
@@ -27,7 +29,16 @@ struct pwm_lpss_boardinfo {
bool other_devices_aml_touches_pwm_regs;
};
+#if IS_REACHABLE(CONFIG_PWM_LPSS)
struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
const struct pwm_lpss_boardinfo *info);
+#else
+static inline
+struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
+ const struct pwm_lpss_boardinfo *info)
+{
+ return ERR_PTR(-ENODEV);
+}
+#endif /* CONFIG_PWM_LPSS */
#endif /* __PLATFORM_DATA_X86_PWM_LPSS_H */
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 6/6] pinctrl: intel: Enumerate PWM device when community has a capabilitty
2022-11-01 15:56 [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Andy Shevchenko
` (4 preceding siblings ...)
2022-11-01 15:56 ` [PATCH v1 5/6] pwm: lpss: Add pwm_lpss_probe() stub Andy Shevchenko
@ 2022-11-01 15:56 ` Andy Shevchenko
2022-11-02 12:19 ` [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Mika Westerberg
6 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2022-11-01 15:56 UTC (permalink / raw)
To: Andy Shevchenko, Hans de Goede, Uwe Kleine-König,
Thierry Reding, linux-kernel, linux-gpio, linux-pwm
Cc: Mika Westerberg, Andy Shevchenko, Linus Walleij
Some of the Communities may have PWM capability. In such cases,
enumerate PWM device via respective driver. User is still responsible
for setting correct pin muxing for the line that needs to output the
signal.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pinctrl/intel/pinctrl-intel.c | 29 +++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index e17d1318b913..fe5bf2184cbf 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -24,6 +24,8 @@
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinmux.h>
+#include <linux/platform_data/x86/pwm-lpss.h>
+
#include "../core.h"
#include "pinctrl-intel.h"
@@ -49,6 +51,8 @@
#define PADOWN_MASK(p) (GENMASK(3, 0) << PADOWN_SHIFT(p))
#define PADOWN_GPP(p) ((p) / 8)
+#define PWMC 0x204
+
/* Offset from pad_regs */
#define PADCFG0 0x000
#define PADCFG0_RXEVCFG_SHIFT 25
@@ -1494,6 +1498,27 @@ static int intel_pinctrl_pm_init(struct intel_pinctrl *pctrl)
return 0;
}
+static int intel_pinctrl_probe_pwm(struct intel_pinctrl *pctrl,
+ struct intel_community *community)
+{
+ static const struct pwm_lpss_boardinfo info = {
+ .clk_rate = 19200000,
+ .npwm = 1,
+ .base_unit_bits = 22,
+ .bypass = true,
+ };
+ struct pwm_lpss_chip *pwm;
+
+ if (!(community->features & PINCTRL_FEATURE_PWM))
+ return 0;
+
+ pwm = pwm_lpss_probe(pctrl->dev, community->regs + PWMC, &info);
+ if (IS_ERR(pwm) && PTR_ERR(pwm) != -ENODEV)
+ return PTR_ERR(pwm);
+
+ return 0;
+}
+
int intel_pinctrl_probe(struct platform_device *pdev,
const struct intel_pinctrl_soc_data *soc_data)
{
@@ -1592,6 +1617,10 @@ int intel_pinctrl_probe(struct platform_device *pdev,
ret = intel_pinctrl_add_padgroups_by_size(pctrl, community);
if (ret)
return ret;
+
+ ret = intel_pinctrl_probe_pwm(pctrl, community);
+ if (ret)
+ return ret;
}
irq = platform_get_irq(pdev, 0);
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature
2022-11-01 15:56 [PATCH v1 0/6] pinctrl: intel: Enable PWM optional feature Andy Shevchenko
` (5 preceding siblings ...)
2022-11-01 15:56 ` [PATCH v1 6/6] pinctrl: intel: Enumerate PWM device when community has a capabilitty Andy Shevchenko
@ 2022-11-02 12:19 ` Mika Westerberg
6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2022-11-02 12:19 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Hans de Goede, Uwe Kleine-K??nig, Thierry Reding, linux-kernel,
linux-gpio, linux-pwm, Andy Shevchenko, Linus Walleij
Hi Andy,
On Tue, Nov 01, 2022 at 05:56:36PM +0200, Andy Shevchenko wrote:
> This is a continuation of the previously applied PWM LPSS clean up.
> Now, we would like to enable PWM optional feature that may be embedded
> into Intel pin control IPs (starting from Sky Lake platforms).
>
> I would like to route this via Intel pin control tree with issuing
> an immutable branch for both PINCTRL and PWM subsystems, but I'm
> open for other suggestions.
>
> Hans, I dared to leave your Rb tags, however the patches are slighly
> differ, because of the Uwe's suggestion on how to handle the missing
> headers. I hope you is okay with that. If not, please comment what
> must be ammended then.
>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> Andy Shevchenko (6):
> pwm: Add a stub for devm_pwmchip_add()
> pwm: lpss: Rename MAX_PWMS --> LPSS_MAX_PWMS
> pwm: lpss: Include headers we are direct user of
> pwm: lpss: Allow other drivers to enable PWM LPSS
> pwm: lpss: Add pwm_lpss_probe() stub
> pinctrl: intel: Enumerate PWM device when community has a capabilitty
Looks good to me. For the entire series,
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread