Skip to content

Commit a157b3a

Browse files
committed
Merge tag 'pwm/for-4.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm updates from Thierry Reding: "This set of changes improve some aspects of the atomic API as well as make use of this new API in the regulator framework to allow properly dealing with critical regulators controlled by a PWM. Aside from that there's a bunch of updates and cleanups for existing drivers, as well as the addition of new drivers for the Broadcom iProc, STMPE and ChromeOS EC controllers" * tag 'pwm/for-4.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (44 commits) regulator: pwm: Document pwm-dutycycle-unit and pwm-dutycycle-range regulator: pwm: Support extra continuous mode cases pwm: Add ChromeOS EC PWM driver dt-bindings: pwm: Add binding for ChromeOS EC PWM mfd: cros_ec: Add EC_PWM function definitions mfd: cros_ec: Add cros_ec_cmd_xfer_status() helper pwm: atmel: Use of_device_get_match_data() pwm: atmel: Fix checkpatch warnings pwm: atmel: Fix disabling of PWM channels dt-bindings: pwm: Add R-Car H3 device tree bindings pwm: rcar: Use ARCH_RENESAS pwm: tegra: Add support for Tegra186 dt-bindings: pwm: tegra: Add compatible string for Tegra186 pwm: tegra: Avoid overflow when calculating duty cycle pwm: tegra: Allow 100 % duty cycle pwm: tegra: Add support for reset control pwm: tegra: Rename mmio_base to regs pwm: tegra: Remove useless padding pwm: tegra: Drop NUM_PWM macro pwm: lpc32xx: Set PWM_PIN_LEVEL bit to default value ...
2 parents 32199ec + 53de7c2 commit a157b3a

29 files changed

+1561
-283
lines changed

Documentation/ABI/testing/sysfs-class-pwm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,12 @@ Description:
7777
Enable/disable the PWM signal.
7878
0 is disabled
7979
1 is enabled
80+
81+
What: /sys/class/pwm/pwmchipN/pwmX/capture
82+
Date: June 2016
83+
KernelVersion: 4.8
84+
Contact: Lee Jones <lee.jones@linaro.org>
85+
Description:
86+
Capture information about a PWM signal. The output format is a
87+
pair unsigned integers (period and duty cycle), separated by a
88+
single space.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Broadcom iProc PWM controller device tree bindings
2+
3+
This controller has 4 channels.
4+
5+
Required Properties :
6+
- compatible: must be "brcm,iproc-pwm"
7+
- reg: physical base address and length of the controller's registers
8+
- clocks: phandle + clock specifier pair for the external clock
9+
- #pwm-cells: Should be 3. See pwm.txt in this directory for a
10+
description of the cells format.
11+
12+
Refer to clocks/clock-bindings.txt for generic clock consumer properties.
13+
14+
Example:
15+
16+
pwm: pwm@18031000 {
17+
compatible = "brcm,iproc-pwm";
18+
reg = <0x18031000 0x28>;
19+
clocks = <&osc>;
20+
#pwm-cells = <3>;
21+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
* PWM controlled by ChromeOS EC
2+
3+
Google's ChromeOS EC PWM is a simple PWM attached to the Embedded Controller
4+
(EC) and controlled via a host-command interface.
5+
6+
An EC PWM node should be only found as a sub-node of the EC node (see
7+
Documentation/devicetree/bindings/mfd/cros-ec.txt).
8+
9+
Required properties:
10+
- compatible: Must contain "google,cros-ec-pwm"
11+
- #pwm-cells: Should be 1. The cell specifies the PWM index.
12+
13+
Example:
14+
cros-ec@0 {
15+
compatible = "google,cros-ec-spi";
16+
17+
...
18+
19+
cros_ec_pwm: ec-pwm {
20+
compatible = "google,cros-ec-pwm";
21+
#pwm-cells = <1>;
22+
};
23+
};

Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
Tegra SoC PWFM controller
22

33
Required properties:
4-
- compatible: For Tegra20, must contain "nvidia,tegra20-pwm". For Tegra30,
5-
must contain "nvidia,tegra30-pwm". Otherwise, must contain
6-
"nvidia,<chip>-pwm", plus one of the above, where <chip> is tegra114,
7-
tegra124, tegra132, or tegra210.
4+
- compatible: Must be:
5+
- "nvidia,tegra20-pwm": for Tegra20
6+
- "nvidia,tegra30-pwm", "nvidia,tegra20-pwm": for Tegra30
7+
- "nvidia,tegra114-pwm", "nvidia,tegra20-pwm": for Tegra114
8+
- "nvidia,tegra124-pwm", "nvidia,tegra20-pwm": for Tegra124
9+
- "nvidia,tegra132-pwm", "nvidia,tegra20-pwm": for Tegra132
10+
- "nvidia,tegra210-pwm", "nvidia,tegra20-pwm": for Tegra210
11+
- "nvidia,tegra186-pwm": for Tegra186
812
- reg: physical base address and length of the controller's registers
913
- #pwm-cells: should be 2. See pwm.txt in this directory for a description of
1014
the cells format.

Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Required Properties:
77
- "renesas,pwm-r8a7790": for R-Car H2
88
- "renesas,pwm-r8a7791": for R-Car M2-W
99
- "renesas,pwm-r8a7794": for R-Car E2
10+
- "renesas,pwm-r8a7795": for R-Car H3
1011
- reg: base address and length of the registers block for the PWM.
1112
- #pwm-cells: should be 2. See pwm.txt in this directory for a description of
1213
the cells format.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
== ST STMPE PWM controller ==
2+
3+
This is a PWM block embedded in the ST Microelectronics STMPE
4+
(ST Multi-Purpose Expander) chips. The PWM is registered as a
5+
subdevices of the STMPE MFD device.
6+
7+
Required properties:
8+
- compatible: should be:
9+
- "st,stmpe-pwm"
10+
- #pwm-cells: should be 2. See pwm.txt in this directory for a description of
11+
the cells format.
12+
13+
Example:
14+
15+
pwm0: pwm {
16+
compatible = "st,stmpe-pwm";
17+
#pwm-cells = <2>;
18+
};

Documentation/devicetree/bindings/regulator/pwm-regulator.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ Only required for Voltage Table Mode:
3434
First cell is voltage in microvolts (uV)
3535
Second cell is duty-cycle in percent (%)
3636

37+
Optional properties for Continuous mode:
38+
- pwm-dutycycle-unit: Integer value encoding the duty cycle unit. If not
39+
defined, <100> is assumed, meaning that
40+
pwm-dutycycle-range contains values expressed in
41+
percent.
42+
43+
- pwm-dutycycle-range: Should contain 2 entries. The first entry is encoding
44+
the dutycycle for regulator-min-microvolt and the
45+
second one the dutycycle for regulator-max-microvolt.
46+
Duty cycle values are expressed in pwm-dutycycle-unit.
47+
If not defined, <0 100> is assumed.
48+
3749
NB: To be clear, if voltage-table is provided, then the device will be used
3850
in Voltage Table Mode. If no voltage-table is provided, then the device will
3951
be used in Continuous Voltage Mode.
@@ -53,6 +65,13 @@ Continuous Voltage With Enable GPIO Example:
5365
regulator-min-microvolt = <1016000>;
5466
regulator-max-microvolt = <1114000>;
5567
regulator-name = "vdd_logic";
68+
/* unit == per-mille */
69+
pwm-dutycycle-unit = <1000>;
70+
/*
71+
* Inverted PWM logic, and the duty cycle range is limited
72+
* to 30%-70%.
73+
*/
74+
pwm-dutycycle-range <700 300>; /* */
5675
};
5776

5877
Voltage Table Example:

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,20 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
380380
return ret;
381381
}
382382
EXPORT_SYMBOL(cros_ec_cmd_xfer);
383+
384+
int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
385+
struct cros_ec_command *msg)
386+
{
387+
int ret;
388+
389+
ret = cros_ec_cmd_xfer(ec_dev, msg);
390+
if (ret < 0) {
391+
dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret);
392+
} else if (msg->result != EC_RES_SUCCESS) {
393+
dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result);
394+
return -EPROTO;
395+
}
396+
397+
return ret;
398+
}
399+
EXPORT_SYMBOL(cros_ec_cmd_xfer_status);

drivers/pwm/Kconfig

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ config PWM_ATMEL_TCB
7474
To compile this driver as a module, choose M here: the module
7575
will be called pwm-atmel-tcb.
7676

77+
config PWM_BCM_IPROC
78+
tristate "iProc PWM support"
79+
depends on ARCH_BCM_IPROC
80+
help
81+
Generic PWM framework driver for Broadcom iProc PWM block. This
82+
block is used in Broadcom iProc SoC's.
83+
84+
To compile this driver as a module, choose M here: the module
85+
will be called pwm-bcm-iproc.
86+
7787
config PWM_BCM_KONA
7888
tristate "Kona PWM support"
7989
depends on ARCH_BCM_MOBILE
@@ -137,6 +147,13 @@ config PWM_CRC
137147
Generic PWM framework driver for Crystalcove (CRC) PMIC based PWM
138148
control.
139149

150+
config PWM_CROS_EC
151+
tristate "ChromeOS EC PWM driver"
152+
depends on MFD_CROS_EC
153+
help
154+
PWM driver for exposing a PWM attached to the ChromeOS Embedded
155+
Controller.
156+
140157
config PWM_EP93XX
141158
tristate "Cirrus Logic EP93xx PWM support"
142159
depends on ARCH_EP93XX
@@ -305,7 +322,7 @@ config PWM_PXA
305322

306323
config PWM_RCAR
307324
tristate "Renesas R-Car PWM support"
308-
depends on ARCH_RCAR_GEN1 || ARCH_RCAR_GEN2 || COMPILE_TEST
325+
depends on ARCH_RENESAS || COMPILE_TEST
309326
depends on HAS_IOMEM
310327
help
311328
This driver exposes the PWM Timer controller found in Renesas
@@ -362,6 +379,13 @@ config PWM_STI
362379
To compile this driver as a module, choose M here: the module
363380
will be called pwm-sti.
364381

382+
config PWM_STMPE
383+
bool "STMPE expander PWM export"
384+
depends on MFD_STMPE
385+
help
386+
This enables support for the PWMs found in the STMPE I/O
387+
expanders.
388+
365389
config PWM_SUN4I
366390
tristate "Allwinner PWM support"
367391
depends on ARCH_SUNXI || COMPILE_TEST

drivers/pwm/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ obj-$(CONFIG_PWM_AB8500) += pwm-ab8500.o
44
obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o
55
obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM) += pwm-atmel-hlcdc.o
66
obj-$(CONFIG_PWM_ATMEL_TCB) += pwm-atmel-tcb.o
7+
obj-$(CONFIG_PWM_BCM_IPROC) += pwm-bcm-iproc.o
78
obj-$(CONFIG_PWM_BCM_KONA) += pwm-bcm-kona.o
89
obj-$(CONFIG_PWM_BCM2835) += pwm-bcm2835.o
910
obj-$(CONFIG_PWM_BERLIN) += pwm-berlin.o
1011
obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o
1112
obj-$(CONFIG_PWM_BRCMSTB) += pwm-brcmstb.o
1213
obj-$(CONFIG_PWM_CLPS711X) += pwm-clps711x.o
1314
obj-$(CONFIG_PWM_CRC) += pwm-crc.o
15+
obj-$(CONFIG_PWM_CROS_EC) += pwm-cros-ec.o
1416
obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o
1517
obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o
1618
obj-$(CONFIG_PWM_IMG) += pwm-img.o
@@ -34,6 +36,7 @@ obj-$(CONFIG_PWM_ROCKCHIP) += pwm-rockchip.o
3436
obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
3537
obj-$(CONFIG_PWM_SPEAR) += pwm-spear.o
3638
obj-$(CONFIG_PWM_STI) += pwm-sti.o
39+
obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o
3740
obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o
3841
obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
3942
obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o

drivers/pwm/core.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,33 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
525525
}
526526
EXPORT_SYMBOL_GPL(pwm_apply_state);
527527

528+
/**
529+
* pwm_capture() - capture and report a PWM signal
530+
* @pwm: PWM device
531+
* @result: structure to fill with capture result
532+
* @timeout: time to wait, in milliseconds, before giving up on capture
533+
*
534+
* Returns: 0 on success or a negative error code on failure.
535+
*/
536+
int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
537+
unsigned long timeout)
538+
{
539+
int err;
540+
541+
if (!pwm || !pwm->chip->ops)
542+
return -EINVAL;
543+
544+
if (!pwm->chip->ops->capture)
545+
return -ENOSYS;
546+
547+
mutex_lock(&pwm_lock);
548+
err = pwm->chip->ops->capture(pwm->chip, pwm, result, timeout);
549+
mutex_unlock(&pwm_lock);
550+
551+
return err;
552+
}
553+
EXPORT_SYMBOL_GPL(pwm_capture);
554+
528555
/**
529556
* pwm_adjust_config() - adjust the current PWM config to the PWM arguments
530557
* @pwm: PWM device

drivers/pwm/pwm-atmel.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ struct atmel_pwm_chip {
6464
void __iomem *base;
6565

6666
unsigned int updated_pwms;
67-
struct mutex isr_lock; /* ISR is cleared when read, ensure only one thread does that */
67+
/* ISR is cleared when read, ensure only one thread does that */
68+
struct mutex isr_lock;
6869

6970
void (*config)(struct pwm_chip *chip, struct pwm_device *pwm,
7071
unsigned long dty, unsigned long prd);
@@ -271,6 +272,16 @@ static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
271272
mutex_unlock(&atmel_pwm->isr_lock);
272273
atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << pwm->hwpwm);
273274

275+
/*
276+
* Wait for the PWM channel disable operation to be effective before
277+
* stopping the clock.
278+
*/
279+
timeout = jiffies + 2 * HZ;
280+
281+
while ((atmel_pwm_readl(atmel_pwm, PWM_SR) & (1 << pwm->hwpwm)) &&
282+
time_before(jiffies, timeout))
283+
usleep_range(10, 100);
284+
274285
clk_disable(atmel_pwm->clk);
275286
}
276287

@@ -324,21 +335,14 @@ MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids);
324335
static inline const struct atmel_pwm_data *
325336
atmel_pwm_get_driver_data(struct platform_device *pdev)
326337
{
327-
if (pdev->dev.of_node) {
328-
const struct of_device_id *match;
329-
330-
match = of_match_device(atmel_pwm_dt_ids, &pdev->dev);
331-
if (!match)
332-
return NULL;
338+
const struct platform_device_id *id;
333339

334-
return match->data;
335-
} else {
336-
const struct platform_device_id *id;
340+
if (pdev->dev.of_node)
341+
return of_device_get_match_data(&pdev->dev);
337342

338-
id = platform_get_device_id(pdev);
343+
id = platform_get_device_id(pdev);
339344

340-
return (struct atmel_pwm_data *)id->driver_data;
341-
}
345+
return (struct atmel_pwm_data *)id->driver_data;
342346
}
343347

344348
static int atmel_pwm_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)