Skip to content

Commit ebf2c89

Browse files
raagjadavUwe Kleine-König
authored andcommitted
pwm: dwc: Add 16 channel support for Intel Elkhart Lake
Intel Elkhart Lake PSE includes two instances of PWM as a single PCI function with 8 channels each. Add support for the remaining channels. Signed-off-by: Raag Jadav <[email protected]> Tested-by: Jarkko Nikula <[email protected]> Tested-by: Lakshmi Sowjanya D <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 144a000 commit ebf2c89

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

drivers/pwm/pwm-dwc.c

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,32 @@
2525

2626
#include "pwm-dwc.h"
2727

28-
static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
28+
/* Elkhart Lake */
29+
static const struct dwc_pwm_info ehl_pwm_info = {
30+
.nr = 2,
31+
.size = 0x1000,
32+
};
33+
34+
static int dwc_pwm_init_one(struct device *dev, void __iomem *base, unsigned int offset)
2935
{
30-
struct device *dev = &pci->dev;
3136
struct pwm_chip *chip;
3237
struct dwc_pwm *dwc;
33-
int ret;
3438

3539
chip = dwc_pwm_alloc(dev);
3640
if (IS_ERR(chip))
3741
return PTR_ERR(chip);
42+
3843
dwc = to_dwc_pwm(chip);
44+
dwc->base = base + offset;
45+
46+
return devm_pwmchip_add(dev, chip);
47+
}
48+
49+
static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
50+
{
51+
const struct dwc_pwm_info *info;
52+
struct device *dev = &pci->dev;
53+
int i, ret;
3954

4055
ret = pcim_enable_device(pci);
4156
if (ret) {
@@ -51,12 +66,17 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
5166
return ret;
5267
}
5368

54-
/* No need to check for failure, pcim_iomap_regions() does it for us. */
55-
dwc->base = pcim_iomap_table(pci)[0];
69+
info = (const struct dwc_pwm_info *)id->driver_data;
5670

57-
ret = devm_pwmchip_add(dev, chip);
58-
if (ret)
59-
return ret;
71+
for (i = 0; i < info->nr; i++) {
72+
/*
73+
* No need to check for pcim_iomap_table() failure,
74+
* pcim_iomap_regions() already does it for us.
75+
*/
76+
ret = dwc_pwm_init_one(dev, pcim_iomap_table(pci)[0], i * info->size);
77+
if (ret)
78+
return ret;
79+
}
6080

6181
pm_runtime_put(dev);
6282
pm_runtime_allow(dev);
@@ -108,7 +128,7 @@ static int dwc_pwm_resume(struct device *dev)
108128
static DEFINE_SIMPLE_DEV_PM_OPS(dwc_pwm_pm_ops, dwc_pwm_suspend, dwc_pwm_resume);
109129

110130
static const struct pci_device_id dwc_pwm_id_table[] = {
111-
{ PCI_VDEVICE(INTEL, 0x4bb7) }, /* Elkhart Lake */
131+
{ PCI_VDEVICE(INTEL, 0x4bb7), (kernel_ulong_t)&ehl_pwm_info },
112132
{ } /* Terminating Entry */
113133
};
114134
MODULE_DEVICE_TABLE(pci, dwc_pwm_id_table);

drivers/pwm/pwm-dwc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ MODULE_IMPORT_NS(dwc_pwm);
3333
#define DWC_TIM_CTRL_INT_MASK BIT(2)
3434
#define DWC_TIM_CTRL_PWM BIT(3)
3535

36+
struct dwc_pwm_info {
37+
unsigned int nr;
38+
unsigned int size;
39+
};
40+
3641
struct dwc_pwm_ctx {
3742
u32 cnt;
3843
u32 cnt2;

0 commit comments

Comments
 (0)