Skip to content

Commit

Permalink
Merge tag 'pwm/for-4.8-rc1' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/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
  ...
  • Loading branch information
torvalds committed Aug 6, 2016
2 parents 32199ec + 53de7c2 commit a157b3a
Show file tree
Hide file tree
Showing 29 changed files with 1,561 additions and 283 deletions.
9 changes: 9 additions & 0 deletions Documentation/ABI/testing/sysfs-class-pwm
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ Description:
Enable/disable the PWM signal.
0 is disabled
1 is enabled

What: /sys/class/pwm/pwmchipN/pwmX/capture
Date: June 2016
KernelVersion: 4.8
Contact: Lee Jones <[email protected]>
Description:
Capture information about a PWM signal. The output format is a
pair unsigned integers (period and duty cycle), separated by a
single space.
21 changes: 21 additions & 0 deletions Documentation/devicetree/bindings/pwm/brcm,iproc-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Broadcom iProc PWM controller device tree bindings

This controller has 4 channels.

Required Properties :
- compatible: must be "brcm,iproc-pwm"
- reg: physical base address and length of the controller's registers
- clocks: phandle + clock specifier pair for the external clock
- #pwm-cells: Should be 3. See pwm.txt in this directory for a
description of the cells format.

Refer to clocks/clock-bindings.txt for generic clock consumer properties.

Example:

pwm: pwm@18031000 {
compatible = "brcm,iproc-pwm";
reg = <0x18031000 0x28>;
clocks = <&osc>;
#pwm-cells = <3>;
};
23 changes: 23 additions & 0 deletions Documentation/devicetree/bindings/pwm/google,cros-ec-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
* PWM controlled by ChromeOS EC

Google's ChromeOS EC PWM is a simple PWM attached to the Embedded Controller
(EC) and controlled via a host-command interface.

An EC PWM node should be only found as a sub-node of the EC node (see
Documentation/devicetree/bindings/mfd/cros-ec.txt).

Required properties:
- compatible: Must contain "google,cros-ec-pwm"
- #pwm-cells: Should be 1. The cell specifies the PWM index.

Example:
cros-ec@0 {
compatible = "google,cros-ec-spi";

...

cros_ec_pwm: ec-pwm {
compatible = "google,cros-ec-pwm";
#pwm-cells = <1>;
};
};
12 changes: 8 additions & 4 deletions Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
Tegra SoC PWFM controller

Required properties:
- compatible: For Tegra20, must contain "nvidia,tegra20-pwm". For Tegra30,
must contain "nvidia,tegra30-pwm". Otherwise, must contain
"nvidia,<chip>-pwm", plus one of the above, where <chip> is tegra114,
tegra124, tegra132, or tegra210.
- compatible: Must be:
- "nvidia,tegra20-pwm": for Tegra20
- "nvidia,tegra30-pwm", "nvidia,tegra20-pwm": for Tegra30
- "nvidia,tegra114-pwm", "nvidia,tegra20-pwm": for Tegra114
- "nvidia,tegra124-pwm", "nvidia,tegra20-pwm": for Tegra124
- "nvidia,tegra132-pwm", "nvidia,tegra20-pwm": for Tegra132
- "nvidia,tegra210-pwm", "nvidia,tegra20-pwm": for Tegra210
- "nvidia,tegra186-pwm": for Tegra186
- reg: physical base address and length of the controller's registers
- #pwm-cells: should be 2. See pwm.txt in this directory for a description of
the cells format.
Expand Down
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/pwm/renesas,pwm-rcar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Required Properties:
- "renesas,pwm-r8a7790": for R-Car H2
- "renesas,pwm-r8a7791": for R-Car M2-W
- "renesas,pwm-r8a7794": for R-Car E2
- "renesas,pwm-r8a7795": for R-Car H3
- reg: base address and length of the registers block for the PWM.
- #pwm-cells: should be 2. See pwm.txt in this directory for a description of
the cells format.
Expand Down
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/pwm/st,stmpe-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
== ST STMPE PWM controller ==

This is a PWM block embedded in the ST Microelectronics STMPE
(ST Multi-Purpose Expander) chips. The PWM is registered as a
subdevices of the STMPE MFD device.

Required properties:
- compatible: should be:
- "st,stmpe-pwm"
- #pwm-cells: should be 2. See pwm.txt in this directory for a description of
the cells format.

Example:

pwm0: pwm {
compatible = "st,stmpe-pwm";
#pwm-cells = <2>;
};
19 changes: 19 additions & 0 deletions Documentation/devicetree/bindings/regulator/pwm-regulator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ Only required for Voltage Table Mode:
First cell is voltage in microvolts (uV)
Second cell is duty-cycle in percent (%)

Optional properties for Continuous mode:
- pwm-dutycycle-unit: Integer value encoding the duty cycle unit. If not
defined, <100> is assumed, meaning that
pwm-dutycycle-range contains values expressed in
percent.

- pwm-dutycycle-range: Should contain 2 entries. The first entry is encoding
the dutycycle for regulator-min-microvolt and the
second one the dutycycle for regulator-max-microvolt.
Duty cycle values are expressed in pwm-dutycycle-unit.
If not defined, <0 100> is assumed.

NB: To be clear, if voltage-table is provided, then the device will be used
in Voltage Table Mode. If no voltage-table is provided, then the device will
be used in Continuous Voltage Mode.
Expand All @@ -53,6 +65,13 @@ Continuous Voltage With Enable GPIO Example:
regulator-min-microvolt = <1016000>;
regulator-max-microvolt = <1114000>;
regulator-name = "vdd_logic";
/* unit == per-mille */
pwm-dutycycle-unit = <1000>;
/*
* Inverted PWM logic, and the duty cycle range is limited
* to 30%-70%.
*/
pwm-dutycycle-range <700 300>; /* */
};

Voltage Table Example:
Expand Down
17 changes: 17 additions & 0 deletions drivers/platform/chrome/cros_ec_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,20 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
return ret;
}
EXPORT_SYMBOL(cros_ec_cmd_xfer);

int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev,
struct cros_ec_command *msg)
{
int ret;

ret = cros_ec_cmd_xfer(ec_dev, msg);
if (ret < 0) {
dev_err(ec_dev->dev, "Command xfer error (err:%d)\n", ret);
} else if (msg->result != EC_RES_SUCCESS) {
dev_dbg(ec_dev->dev, "Command result (err: %d)\n", msg->result);
return -EPROTO;
}

return ret;
}
EXPORT_SYMBOL(cros_ec_cmd_xfer_status);
26 changes: 25 additions & 1 deletion drivers/pwm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ config PWM_ATMEL_TCB
To compile this driver as a module, choose M here: the module
will be called pwm-atmel-tcb.

config PWM_BCM_IPROC
tristate "iProc PWM support"
depends on ARCH_BCM_IPROC
help
Generic PWM framework driver for Broadcom iProc PWM block. This
block is used in Broadcom iProc SoC's.

To compile this driver as a module, choose M here: the module
will be called pwm-bcm-iproc.

config PWM_BCM_KONA
tristate "Kona PWM support"
depends on ARCH_BCM_MOBILE
Expand Down Expand Up @@ -137,6 +147,13 @@ config PWM_CRC
Generic PWM framework driver for Crystalcove (CRC) PMIC based PWM
control.

config PWM_CROS_EC
tristate "ChromeOS EC PWM driver"
depends on MFD_CROS_EC
help
PWM driver for exposing a PWM attached to the ChromeOS Embedded
Controller.

config PWM_EP93XX
tristate "Cirrus Logic EP93xx PWM support"
depends on ARCH_EP93XX
Expand Down Expand Up @@ -305,7 +322,7 @@ config PWM_PXA

config PWM_RCAR
tristate "Renesas R-Car PWM support"
depends on ARCH_RCAR_GEN1 || ARCH_RCAR_GEN2 || COMPILE_TEST
depends on ARCH_RENESAS || COMPILE_TEST
depends on HAS_IOMEM
help
This driver exposes the PWM Timer controller found in Renesas
Expand Down Expand Up @@ -362,6 +379,13 @@ config PWM_STI
To compile this driver as a module, choose M here: the module
will be called pwm-sti.

config PWM_STMPE
bool "STMPE expander PWM export"
depends on MFD_STMPE
help
This enables support for the PWMs found in the STMPE I/O
expanders.

config PWM_SUN4I
tristate "Allwinner PWM support"
depends on ARCH_SUNXI || COMPILE_TEST
Expand Down
3 changes: 3 additions & 0 deletions drivers/pwm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ obj-$(CONFIG_PWM_AB8500) += pwm-ab8500.o
obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o
obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM) += pwm-atmel-hlcdc.o
obj-$(CONFIG_PWM_ATMEL_TCB) += pwm-atmel-tcb.o
obj-$(CONFIG_PWM_BCM_IPROC) += pwm-bcm-iproc.o
obj-$(CONFIG_PWM_BCM_KONA) += pwm-bcm-kona.o
obj-$(CONFIG_PWM_BCM2835) += pwm-bcm2835.o
obj-$(CONFIG_PWM_BERLIN) += pwm-berlin.o
obj-$(CONFIG_PWM_BFIN) += pwm-bfin.o
obj-$(CONFIG_PWM_BRCMSTB) += pwm-brcmstb.o
obj-$(CONFIG_PWM_CLPS711X) += pwm-clps711x.o
obj-$(CONFIG_PWM_CRC) += pwm-crc.o
obj-$(CONFIG_PWM_CROS_EC) += pwm-cros-ec.o
obj-$(CONFIG_PWM_EP93XX) += pwm-ep93xx.o
obj-$(CONFIG_PWM_FSL_FTM) += pwm-fsl-ftm.o
obj-$(CONFIG_PWM_IMG) += pwm-img.o
Expand All @@ -34,6 +36,7 @@ obj-$(CONFIG_PWM_ROCKCHIP) += pwm-rockchip.o
obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
obj-$(CONFIG_PWM_SPEAR) += pwm-spear.o
obj-$(CONFIG_PWM_STI) += pwm-sti.o
obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o
obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o
obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o
Expand Down
27 changes: 27 additions & 0 deletions drivers/pwm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,33 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
}
EXPORT_SYMBOL_GPL(pwm_apply_state);

/**
* pwm_capture() - capture and report a PWM signal
* @pwm: PWM device
* @result: structure to fill with capture result
* @timeout: time to wait, in milliseconds, before giving up on capture
*
* Returns: 0 on success or a negative error code on failure.
*/
int pwm_capture(struct pwm_device *pwm, struct pwm_capture *result,
unsigned long timeout)
{
int err;

if (!pwm || !pwm->chip->ops)
return -EINVAL;

if (!pwm->chip->ops->capture)
return -ENOSYS;

mutex_lock(&pwm_lock);
err = pwm->chip->ops->capture(pwm->chip, pwm, result, timeout);
mutex_unlock(&pwm_lock);

return err;
}
EXPORT_SYMBOL_GPL(pwm_capture);

/**
* pwm_adjust_config() - adjust the current PWM config to the PWM arguments
* @pwm: PWM device
Expand Down
30 changes: 17 additions & 13 deletions drivers/pwm/pwm-atmel.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ struct atmel_pwm_chip {
void __iomem *base;

unsigned int updated_pwms;
struct mutex isr_lock; /* ISR is cleared when read, ensure only one thread does that */
/* ISR is cleared when read, ensure only one thread does that */
struct mutex isr_lock;

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

/*
* Wait for the PWM channel disable operation to be effective before
* stopping the clock.
*/
timeout = jiffies + 2 * HZ;

while ((atmel_pwm_readl(atmel_pwm, PWM_SR) & (1 << pwm->hwpwm)) &&
time_before(jiffies, timeout))
usleep_range(10, 100);

clk_disable(atmel_pwm->clk);
}

Expand Down Expand Up @@ -324,21 +335,14 @@ MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids);
static inline const struct atmel_pwm_data *
atmel_pwm_get_driver_data(struct platform_device *pdev)
{
if (pdev->dev.of_node) {
const struct of_device_id *match;

match = of_match_device(atmel_pwm_dt_ids, &pdev->dev);
if (!match)
return NULL;
const struct platform_device_id *id;

return match->data;
} else {
const struct platform_device_id *id;
if (pdev->dev.of_node)
return of_device_get_match_data(&pdev->dev);

id = platform_get_device_id(pdev);
id = platform_get_device_id(pdev);

return (struct atmel_pwm_data *)id->driver_data;
}
return (struct atmel_pwm_data *)id->driver_data;
}

static int atmel_pwm_probe(struct platform_device *pdev)
Expand Down
Loading

0 comments on commit a157b3a

Please sign in to comment.