Skip to contentSkip to conversation

pwm: opencores: Add PWM driver support

PATCH Superseded William Qiu 3 participants 5 messages Aug 9, 2024 – Aug 20, 2024 PWM

v14 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

PATCH v14 1/1 pwm: opencores: Add PWM driver support

Add driver for OpenCores PWM Controller. And add compatibility code which based on StarFive SoC.

---
 MAINTAINERS              |   7 ++
 drivers/pwm/Kconfig      |  12 ++
 drivers/pwm/Makefile     |   1 +
 drivers/pwm/pwm-ocores.c | 242 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 262 insertions(+)
 create mode 100644 drivers/pwm/pwm-ocores.c
MAINTAINERS +7 -0
index 8766f3e5e87e..e79bd16cfab8 100644
@@ -17109,6 +17109,13 @@ F:	Documentation/i2c/busses/i2c-ocores.rst
 F:	drivers/i2c/busses/i2c-ocores.c
 F:	include/linux/platform_data/i2c-ocores.h
 
+OPENCORES PWM DRIVER
+M:	William Qiu <[email protected]>
+M:	Hal Feng <[email protected]>
+S:	Supported
+F:	Documentation/devicetree/bindings/pwm/opencores,pwm.yaml
+F:	drivers/pwm/pwm-ocores.c
+
 OPENRISC ARCHITECTURE
 M:	Jonas Bonn <[email protected]>
 M:	Stefan Kristiansson <[email protected]>
drivers/pwm/Kconfig +12 -0
index 3e53838990f5..7682936484aa 100644
@@ -464,6 +464,18 @@ config PWM_NTXEC
 	  controller found in certain e-book readers designed by the original
 	  design manufacturer Netronix.
 
+config PWM_OCORES
+	tristate "OpenCores PTC PWM support"
+	depends on HAS_IOMEM && OF
+	depends on COMMON_CLK
+	depends on ARCH_STARFIVE || COMPILE_TEST
+	help
+	  If you say yes to this option, support will be included for the
+	  OpenCores PWM. For details see https://opencores.org/projects/ptc.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called pwm-ocores.
+
 config PWM_OMAP_DMTIMER
 	tristate "OMAP Dual-Mode Timer PWM support"
 	depends on OF
drivers/pwm/Makefile +1 -0
index 0be4f3e6dd43..5d87811e8537 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_PWM_MICROCHIP_CORE)	+= pwm-microchip-core.o
 obj-$(CONFIG_PWM_MTK_DISP)	+= pwm-mtk-disp.o
 obj-$(CONFIG_PWM_MXS)		+= pwm-mxs.o
 obj-$(CONFIG_PWM_NTXEC)		+= pwm-ntxec.o
+obj-$(CONFIG_PWM_OCORES)	+= pwm-ocores.o
 obj-$(CONFIG_PWM_OMAP_DMTIMER)	+= pwm-omap-dmtimer.o
 obj-$(CONFIG_PWM_PCA9685)	+= pwm-pca9685.o
 obj-$(CONFIG_PWM_PXA)		+= pwm-pxa.o
drivers/pwm/pwm-ocores.c new file +242 -0

242 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

Le 09/08/2024 à 12:38, William Qiu a écrit :

Quoted 7 lines

Add driver for OpenCores PWM Controller. And add compatibility code which based on StarFive SoC.

---

Hi,

...

Quoted 16 lines
drivers/pwm/pwm-ocores.c new file +16 -0
+static int ocores_pwm_apply(struct pwm_chip *chip,
+			    struct pwm_device *pwm,
+			    const struct pwm_state *state)
+{
+	struct ocores_pwm_device *ddata = chip_to_ocores(chip);
+	u32 ctrl_data = 0;
+	u64 period_data, duty_data;
+
+	if (state->polarity != PWM_POLARITY_INVERSED)
+		return -EINVAL;
+
+	period_data = mul_u64_u32_div(state->period, ddata->clk_rate, NSEC_PER_SEC);
+	if (!period_data)
+		return -EINVAL;
+
+	if (period_data > U32_MAX)

drivers/pwm/pwm-ocores.c line 132

Quoted 10 lines
drivers/pwm/pwm-ocores.c new file +10 -0
+		period_data = U32_MAX;
+
+	ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_LRC, (u32)period_data);
+
+	duty_data = mul_u64_u32_div(state->duty_cycle, ddata->clk_rate, NSEC_PER_SEC);
+	if (duty_data <= U32_MAX)
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);
+	else if (duty_data > U32_MAX)
+		duty_data = U32_MAX;
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);

I guess that some {} are missing. BTW, does it even compile without it???

Review

Quoted 2 lines
(quoted diff) +2 -0
+	else
+		return -EINVAL;

What is the use of this else? duty_data is either <= U32_MAX or > U32_MAX. Or I missed something?

Maybe just simplify things and write something as done with period_data just a few lines above?

Quoted 11 lines
drivers/pwm/pwm-ocores.c new file +11 -0
+
+	ctrl_data = ocores_pwm_readl(ddata, pwm->hwpwm, REG_OCPWM_CTRL);
+	if (state->enabled)
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
+				  ctrl_data | REG_OCPWM_CNTR_EN | REG_OCPWM_CNTR_OE);
+	else
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
+				  ctrl_data & ~(REG_OCPWM_CNTR_EN | REG_OCPWM_CNTR_OE));
+
+	return 0;
+}

...

Quoted 42 lines
drivers/pwm/pwm-ocores.c new file +42 -0
+static int ocores_pwm_probe(struct platform_device *pdev)
+{
+	const struct of_device_id *id;
+	struct device *dev = &pdev->dev;
+	struct ocores_pwm_device *ddata;
+	struct pwm_chip *chip;
+	struct clk *clk;
+	struct reset_control *rst;
+	int ret;
+
+	id = of_match_device(ocores_pwm_of_match, dev);
+	if (!id)
+		return -EINVAL;
+
+	chip = devm_pwmchip_alloc(&pdev->dev, 8, sizeof(*ddata));
+	if (IS_ERR(chip))
+		return -ENOMEM;
+
+	ddata = chip_to_ocores(chip);
+	ddata->data = id->data;
+	chip->ops = &ocores_pwm_ops;
+
+	ddata->regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(ddata->regs))
+		return dev_err_probe(dev, PTR_ERR(ddata->regs),
+				     "Unable to map IO resources\n");
+
+	clk = devm_clk_get_enabled(dev, NULL);
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk),
+				     "Unable to get pwm's clock\n");
+
+	ret = devm_clk_rate_exclusive_get(dev, clk);
+	if (ret)
+		return ret;
+
+	rst = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (IS_ERR(rst))
+		return dev_err_probe(dev, PTR_ERR(rst),
+				     "Unable to get pwm's reset\n");
+
+	ret = reset_control_deassert(rst);

drivers/pwm/pwm-ocores.c line 220

Quoted 10 lines
drivers/pwm/pwm-ocores.c new file +10 -0
+	if (ret)
+		return ret;
+
+	ret = devm_add_action_or_reset(dev, ocores_pwm_reset_control_assert, rst);
+	if (ret)
+		return ret;
+
+	ddata->clk_rate = clk_get_rate(clk);
+	if (ddata->clk_rate > NSEC_PER_SEC)
+		return dev_err_probe(dev, ddata->clk_rate,

Does it work?
I would expect -EINVAL.

drivers/pwm/pwm-ocores.c line 228

Quoted 8 lines
drivers/pwm/pwm-ocores.c new file +8 -0
+				     "Unable to get clock's rate\n");
+
+	ret = devm_pwmchip_add(dev, chip);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Could not register PWM chip\n");
+
+	return 0;
+}

...

CJ

#2 lore raw
Quoted 48 lines

-----Original Message-----
From: Christophe JAILLET <[email protected]>
Sent: 2024年8月9日 20:28
To: William Qiu <[email protected]>; [email protected]; [email protected]
Cc: Uwe Kleine-König <[email protected]>; Hal Feng <[email protected]>; Philipp Zabel <[email protected]>
Subject: Re: [PATCH v14] pwm: opencores: Add PWM driver support

Le 09/08/2024 à 12:38, William Qiu a écrit :

Quoted 7 lines

Add driver for OpenCores PWM Controller. And add compatibility code which based on StarFive SoC.

---

Hi,

...

drivers/pwm/pwm-ocores.c

Quoted 11 lines
drivers/pwm/pwm-ocores.c new file +11 -0
+static int ocores_pwm_apply(struct pwm_chip *chip,
+			    struct pwm_device *pwm,
+			    const struct pwm_state *state) {
+	struct ocores_pwm_device *ddata = chip_to_ocores(chip);
+	u32 ctrl_data = 0;
+	u64 period_data, duty_data;
+
+	if (state->polarity != PWM_POLARITY_INVERSED)
+		return -EINVAL;
+
+	period_data = mul_u64_u32_div(state->period, ddata->clk_rate,

NSEC_PER_SEC);

drivers/pwm/pwm-ocores.c

Quoted 10 lines
drivers/pwm/pwm-ocores.c new file +10 -0
+	if (!period_data)
+		return -EINVAL;
+
+	if (period_data > U32_MAX)
+		period_data = U32_MAX;
+
+	ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_LRC,
+(u32)period_data);
+
+	duty_data = mul_u64_u32_div(state->duty_cycle, ddata->clk_rate,

NSEC_PER_SEC);

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (duty_data <= U32_MAX)
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC,

(u32)duty_data);

Quoted 8 lines

drivers/pwm/pwm-ocores.c

Quoted 4 lines
drivers/pwm/pwm-ocores.c new file +4 -0
+	else if (duty_data > U32_MAX)
+		duty_data = U32_MAX;
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC,
+(u32)duty_data);

I guess that some {} are missing. BTW, does it even compile without it???

It does miss {}; Will add it.

Quoted 10 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	else
+		return -EINVAL;

What is the use of this else? duty_data is either <= U32_MAX or > U32_MAX. Or I missed something?

Maybe just simplify things and write something as done with period_data just a few lines above?

Will update.

Quoted 63 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	ctrl_data = ocores_pwm_readl(ddata, pwm->hwpwm,

REG_OCPWM_CTRL);

drivers/pwm/pwm-ocores.c

Quoted 3 lines
drivers/pwm/pwm-ocores.c new file +3 -0
+	if (state->enabled)
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
+				  ctrl_data | REG_OCPWM_CNTR_EN |

REG_OCPWM_CNTR_OE);

drivers/pwm/pwm-ocores.c

Quoted 3 lines
drivers/pwm/pwm-ocores.c new file +3 -0
+	else
+		ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
+				  ctrl_data & ~(REG_OCPWM_CNTR_EN |

REG_OCPWM_CNTR_OE));

Quoted 3 lines
drivers/pwm/pwm-ocores.c new file +3 -0
+
+	return 0;
+}

...

Quoted 35 lines
drivers/pwm/pwm-ocores.c new file +35 -0
+static int ocores_pwm_probe(struct platform_device *pdev) {
+	const struct of_device_id *id;
+	struct device *dev = &pdev->dev;
+	struct ocores_pwm_device *ddata;
+	struct pwm_chip *chip;
+	struct clk *clk;
+	struct reset_control *rst;
+	int ret;
+
+	id = of_match_device(ocores_pwm_of_match, dev);
+	if (!id)
+		return -EINVAL;
+
+	chip = devm_pwmchip_alloc(&pdev->dev, 8, sizeof(*ddata));
+	if (IS_ERR(chip))
+		return -ENOMEM;
+
+	ddata = chip_to_ocores(chip);
+	ddata->data = id->data;
+	chip->ops = &ocores_pwm_ops;
+
+	ddata->regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(ddata->regs))
+		return dev_err_probe(dev, PTR_ERR(ddata->regs),
+				     "Unable to map IO resources\n");
+
+	clk = devm_clk_get_enabled(dev, NULL);
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk),
+				     "Unable to get pwm's clock\n");
+
+	ret = devm_clk_rate_exclusive_get(dev, clk);
+	if (ret)
+		return ret;
+

drivers/pwm/pwm-ocores.c

Quoted 10 lines
drivers/pwm/pwm-ocores.c new file +10 -0
+	rst = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (IS_ERR(rst))
+		return dev_err_probe(dev, PTR_ERR(rst),
+				     "Unable to get pwm's reset\n");
+
+	ret = reset_control_deassert(rst);
+	if (ret)
+		return ret;
+
+	ret = devm_add_action_or_reset(dev, ocores_pwm_reset_control_assert,

rst);

Quoted 10 lines

drivers/pwm/pwm-ocores.c line 220

Quoted 6 lines
drivers/pwm/pwm-ocores.c new file +6 -0
+	if (ret)
+		return ret;
+
+	ddata->clk_rate = clk_get_rate(clk);
+	if (ddata->clk_rate > NSEC_PER_SEC)
+		return dev_err_probe(dev, ddata->clk_rate,

Does it work?
I would expect -EINVAL.

Will update.

Quoted 11 lines
Quoted 8 lines
drivers/pwm/pwm-ocores.c new file +8 -0
+				     "Unable to get clock's rate\n");
+
+	ret = devm_pwmchip_add(dev, chip);
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Could not register PWM chip\n");
+
+	return 0;
+}

...

Quoted 1 line

CJ

Thanks for taking time for review this patch.

Best Regards,
William

#3 lore raw
In reply to William Qiu
kernel test robot noticed the following build errors:

Hi William,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on thierry-reding-pwm/for-next v6.11-rc2 next-20240809] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/William-Qiu/pwm-opencores-Add-PWM-driver-support/20240809-213210
base:   linus/master
patch link:    https://lore.kernel.org/r/20240809103831.156436-1-william.qiu%40starfivetech.com
patch subject: [PATCH v14] pwm: opencores: Add PWM driver support
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20240810/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

drivers/pwm/pwm-ocores.c: In function 'ocores_pwm_apply':

>> drivers/pwm/pwm-ocores.c:130:14: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     130 |         else if (duty_data > U32_MAX)
         |              ^~
   drivers/pwm/pwm-ocores.c:132:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
     132 |                 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);
         |                 ^~~~~~~~~~~~~~~~~
>> drivers/pwm/pwm-ocores.c:133:9: error: 'else' without a previous 'if'
     133 |         else
         |         ^~~~

vim +133 drivers/pwm/pwm-ocores.c

106
107 static int ocores_pwm_apply(struct pwm_chip *chip,
108 struct pwm_device *pwm,
109 const struct pwm_state *state)
110 {
111 struct ocores_pwm_device *ddata = chip_to_ocores(chip);
112 u32 ctrl_data = 0;
113 u64 period_data, duty_data;
114
115 if (state->polarity != PWM_POLARITY_INVERSED)
116 return -EINVAL;
117
118 period_data = mul_u64_u32_div(state->period, ddata->clk_rate, NSEC_PER_SEC);
119 if (!period_data)
120 return -EINVAL;
121
122 if (period_data > U32_MAX)
123 period_data = U32_MAX;
124
125 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_LRC, (u32)period_data);
126
127 duty_data = mul_u64_u32_div(state->duty_cycle, ddata->clk_rate, NSEC_PER_SEC);
128 if (duty_data <= U32_MAX)
129 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);

 > 130		else if (duty_data > U32_MAX)
   131			duty_data = U32_MAX;
   132			ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);
 > 133		else

134 return -EINVAL;
135
136 ctrl_data = ocores_pwm_readl(ddata, pwm->hwpwm, REG_OCPWM_CTRL);
137 if (state->enabled)
138 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
139 ctrl_data | REG_OCPWM_CNTR_EN | REG_OCPWM_CNTR_OE);
140 else
141 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
142 ctrl_data & ~(REG_OCPWM_CNTR_EN | REG_OCPWM_CNTR_OE));
143
144 return 0;
145 }
146

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw
In reply to William Qiu
kernel test robot noticed the following build errors:

Hi William,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on thierry-reding-pwm/for-next v6.11-rc2 next-20240809] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/William-Qiu/pwm-opencores-Add-PWM-driver-support/20240809-213210
base:   linus/master
patch link:    https://lore.kernel.org/r/20240809103831.156436-1-william.qiu%40starfivetech.com
patch subject: [PATCH v14] pwm: opencores: Add PWM driver support
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20240810/[email protected]/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project f86594788ce93b696675c94f54016d27a6c21d18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from drivers/pwm/pwm-ocores.c:19:
In file included from include/linux/io.h:14:
In file included from arch/hexagon/include/asm/io.h:328:
include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]

     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from drivers/pwm/pwm-ocores.c:19:
   In file included from include/linux/io.h:14:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from drivers/pwm/pwm-ocores.c:19:
   In file included from include/linux/io.h:14:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
>> drivers/pwm/pwm-ocores.c:132:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
     132 |                 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);
         |                 ^
   drivers/pwm/pwm-ocores.c:130:2: note: previous statement is here
     130 |         else if (duty_data > U32_MAX)
         |         ^
>> drivers/pwm/pwm-ocores.c:133:2: error: expected expression
     133 |         else
         |         ^

7 warnings and 1 error generated.

vim +133 drivers/pwm/pwm-ocores.c

106
107 static int ocores_pwm_apply(struct pwm_chip *chip,
108 struct pwm_device *pwm,
109 const struct pwm_state *state)
110 {
111 struct ocores_pwm_device *ddata = chip_to_ocores(chip);
112 u32 ctrl_data = 0;
113 u64 period_data, duty_data;
114
115 if (state->polarity != PWM_POLARITY_INVERSED)
116 return -EINVAL;
117
118 period_data = mul_u64_u32_div(state->period, ddata->clk_rate, NSEC_PER_SEC);
119 if (!period_data)
120 return -EINVAL;
121
122 if (period_data > U32_MAX)
123 period_data = U32_MAX;
124
125 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_LRC, (u32)period_data);
126
127 duty_data = mul_u64_u32_div(state->duty_cycle, ddata->clk_rate, NSEC_PER_SEC);
128 if (duty_data <= U32_MAX)
129 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);
130 else if (duty_data > U32_MAX)
131 duty_data = U32_MAX;

 > 132			ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_HRC, (u32)duty_data);
 > 133		else

134 return -EINVAL;
135
136 ctrl_data = ocores_pwm_readl(ddata, pwm->hwpwm, REG_OCPWM_CTRL);
137 if (state->enabled)
138 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
139 ctrl_data | REG_OCPWM_CNTR_EN | REG_OCPWM_CNTR_OE);
140 else
141 ocores_pwm_writel(ddata, pwm->hwpwm, REG_OCPWM_CTRL,
142 ctrl_data & ~(REG_OCPWM_CNTR_EN | REG_OCPWM_CNTR_OE));
143
144 return 0;
145 }
146

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki