Skip to content

Commit

Permalink
Merge tag 'for-3.8-rc1' of git://gitorious.org/linux-pwm/linux-pwm
Browse files Browse the repository at this point in the history
Pull pwm changes from Thierry Reding:
 "A new driver has been added for the SPEAr platform and the
  TWL4030/6030 driver has been replaced by two drivers that control the
  regular PWMs and the PWM driven LEDs provided by the chips.

  The vt8500, tiecap, tiehrpwm, i.MX, LPC32xx and Samsung drivers have
  all been improved and the device tree bindings now support the PWM
  signal polarity."

Fix up trivial conflicts due to __devinit/exit removal.

* tag 'for-3.8-rc1' of git://gitorious.org/linux-pwm/linux-pwm: (21 commits)
  pwm: samsung: add missing s3c->pwm_id assignment
  pwm: lpc32xx: Set the chip base for dynamic allocation
  pwm: lpc32xx: Properly disable the clock on device removal
  pwm: lpc32xx: Fix the PWM polarity
  pwm: i.MX: eliminate build warning
  pwm: Export of_pwm_xlate_with_flags()
  pwm: Remove pwm-twl6030 driver
  pwm: New driver to support PWM driven LEDs on TWL4030/6030 series of PMICs
  pwm: New driver to support PWMs on TWL4030/6030 series of PMICs
  pwm: pwm-tiehrpwm: pinctrl support
  pwm: tiehrpwm: Add device-tree binding
  pwm: pwm-tiehrpwm: Adding TBCLK gating support.
  pwm: pwm-tiecap: pinctrl support
  pwm: tiecap: Add device-tree binding
  pwm: Add TI PWM subsystem driver
  pwm: Device tree support for PWM polarity
  pwm: vt8500: Ensure PWM clock is enabled during pwm_config
  pwm: vt8500: Fix build error
  pwm: spear: Staticize spear_pwm_config()
  pwm: Add SPEAr PWM chip driver support
  ...
  • Loading branch information
torvalds committed Dec 19, 2012
2 parents 5031a2a + 20e8ac3 commit 74779e2
Show file tree
Hide file tree
Showing 24 changed files with 1,593 additions and 221 deletions.
23 changes: 23 additions & 0 deletions Documentation/devicetree/bindings/pwm/pwm-tiecap.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
TI SOC ECAP based APWM controller

Required properties:
- compatible: Must be "ti,am33xx-ecap"
- #pwm-cells: Should be 3. Number of cells being used to specify PWM property.
First cell specifies the per-chip index of the PWM to use, the second
cell is the period in nanoseconds and bit 0 in the third cell is used to
encode the polarity of PWM output. Set bit 0 of the third in PWM specifier
to 1 for inverse polarity & set to 0 for normal polarity.
- reg: physical base address and size of the registers map.

Optional properties:
- ti,hwmods: Name of the hwmod associated to the ECAP:
"ecap<x>", <x> being the 0-based instance number from the HW spec

Example:

ecap0: ecap@0 {
compatible = "ti,am33xx-ecap";
#pwm-cells = <3>;
reg = <0x48300100 0x80>;
ti,hwmods = "ecap0";
};
23 changes: 23 additions & 0 deletions Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
TI SOC EHRPWM based PWM controller

Required properties:
- compatible : Must be "ti,am33xx-ehrpwm"
- #pwm-cells: Should be 3. Number of cells being used to specify PWM property.
First cell specifies the per-chip index of the PWM to use, the second
cell is the period in nanoseconds and bit 0 in the third cell is used to
encode the polarity of PWM output. Set bit 0 of the third in PWM specifier
to 1 for inverse polarity & set to 0 for normal polarity.
- reg: physical base address and size of the registers map.

Optional properties:
- ti,hwmods: Name of the hwmod associated to the EHRPWM:
"ehrpwm<x>", <x> being the 0-based instance number from the HW spec

Example:

ehrpwm0: ehrpwm@0 {
compatible = "ti,am33xx-ehrpwm";
#pwm-cells = <3>;
reg = <0x48300200 0x100>;
ti,hwmods = "ehrpwm0";
};
31 changes: 31 additions & 0 deletions Documentation/devicetree/bindings/pwm/pwm-tipwmss.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
TI SOC based PWM Subsystem

Required properties:
- compatible: Must be "ti,am33xx-pwmss";
- reg: physical base address and size of the registers map.
- address-cells: Specify the number of u32 entries needed in child nodes.
Should set to 1.
- size-cells: specify number of u32 entries needed to specify child nodes size
in reg property. Should set to 1.
- ranges: describes the address mapping of a memory-mapped bus. Should set to
physical address map of child's base address, physical address within
parent's address space and length of the address map. For am33xx,
3 set of child register maps present, ECAP register space, EQEP
register space, EHRPWM register space.

Also child nodes should also populated under PWMSS DT node.

Example:
pwmss0: pwmss@48300000 {
compatible = "ti,am33xx-pwmss";
reg = <0x48300000 0x10>;
ti,hwmods = "epwmss0";
#address-cells = <1>;
#size-cells = <1>;
status = "disabled";
ranges = <0x48300100 0x48300100 0x80 /* ECAP */
0x48300180 0x48300180 0x80 /* EQEP */
0x48300200 0x48300200 0x80>; /* EHRPWM */

/* child nodes go here */
};
17 changes: 14 additions & 3 deletions Documentation/devicetree/bindings/pwm/pwm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@ device:
pwm-names = "backlight";
};

Note that in the example above, specifying the "pwm-names" is redundant
because the name "backlight" would be used as fallback anyway.

pwm-specifier typically encodes the chip-relative PWM number and the PWM
period in nanoseconds. Note that in the example above, specifying the
"pwm-names" is redundant because the name "backlight" would be used as
fallback anyway.
period in nanoseconds.

Optionally, the pwm-specifier can encode a number of flags in a third cell:
- bit 0: PWM signal polarity (0: normal polarity, 1: inverse polarity)

Example with optional PWM specifier for inverse polarity

bl: backlight {
pwms = <&pwm 0 5000000 1>;
pwm-names = "backlight";
};

2) PWM controller nodes
-----------------------
Expand Down
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/pwm/spear-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
== ST SPEAr SoC PWM controller ==

Required properties:
- compatible: should be one of:
- "st,spear320-pwm"
- "st,spear1340-pwm"
- reg: physical base address and length of the controller's registers
- #pwm-cells: number of cells used to specify PWM which is fixed to 2 on
SPEAr. The first cell specifies the per-chip index of the PWM to use and
the second cell is the period in nanoseconds.

Example:

pwm: pwm@a8000000 {
compatible ="st,spear320-pwm";
reg = <0xa8000000 0x1000>;
#pwm-cells = <2>;
};
17 changes: 17 additions & 0 deletions Documentation/devicetree/bindings/pwm/ti,twl-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Texas Instruments TWL series PWM drivers

Supported PWMs:
On TWL4030 series: PWM1 and PWM2
On TWL6030 series: PWM0 and PWM1

Required properties:
- compatible: "ti,twl4030-pwm" or "ti,twl6030-pwm"
- #pwm-cells: should be 2. The first cell specifies the per-chip index
of the PWM to use and the second cell is the period in nanoseconds.

Example:

twl_pwm: pwm {
compatible = "ti,twl6030-pwm";
#pwm-cells = <2>;
};
17 changes: 17 additions & 0 deletions Documentation/devicetree/bindings/pwm/ti,twl-pwmled.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Texas Instruments TWL series PWM drivers connected to LED terminals

Supported PWMs:
On TWL4030 series: PWMA and PWMB (connected to LEDA and LEDB terminals)
On TWL6030 series: LED PWM (mainly used as charging indicator LED)

Required properties:
- compatible: "ti,twl4030-pwmled" or "ti,twl6030-pwmled"
- #pwm-cells: should be 2. The first cell specifies the per-chip index
of the PWM to use and the second cell is the period in nanoseconds.

Example:

twl_pwmled: pwmled {
compatible = "ti,twl6030-pwmled";
#pwm-cells = <2>;
};
17 changes: 17 additions & 0 deletions Documentation/devicetree/bindings/pwm/vt8500-pwm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
VIA/Wondermedia VT8500/WM8xxx series SoC PWM controller

Required properties:
- compatible: should be "via,vt8500-pwm"
- reg: physical base address and length of the controller's registers
- #pwm-cells: should be 2. The first cell specifies the per-chip index
of the PWM to use and the second cell is the period in nanoseconds.
- clocks: phandle to the PWM source clock

Example:

pwm1: pwm@d8220000 {
#pwm-cells = <2>;
compatible = "via,vt8500-pwm";
reg = <0xd8220000 0x1000>;
clocks = <&clkpwm>;
};
39 changes: 35 additions & 4 deletions drivers/pwm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ config PWM_SAMSUNG
To compile this driver as a module, choose M here: the module
will be called pwm-samsung.

config PWM_SPEAR
tristate "STMicroelectronics SPEAr PWM support"
depends on PLAT_SPEAR
depends on OF
help
Generic PWM framework driver for the PWM controller on ST
SPEAr SoCs.

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

config PWM_TEGRA
tristate "NVIDIA Tegra PWM support"
depends on ARCH_TEGRA
Expand All @@ -125,6 +136,7 @@ config PWM_TEGRA
config PWM_TIECAP
tristate "ECAP PWM support"
depends on SOC_AM33XX
select PWM_TIPWMSS
help
PWM driver support for the ECAP APWM controller found on AM33XX
TI SOC
Expand All @@ -135,21 +147,40 @@ config PWM_TIECAP
config PWM_TIEHRPWM
tristate "EHRPWM PWM support"
depends on SOC_AM33XX
select PWM_TIPWMSS
help
PWM driver support for the EHRPWM controller found on AM33XX
TI SOC

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

config PWM_TWL6030
tristate "TWL6030 PWM support"
config PWM_TIPWMSS
bool
depends on SOC_AM33XX && (PWM_TIEHRPWM || PWM_TIECAP)
help
PWM Subsystem driver support for AM33xx SOC.

PWM submodules require PWM config space access from submodule
drivers and require common parent driver support.

config PWM_TWL
tristate "TWL4030/6030 PWM support"
depends on TWL4030_CORE
help
Generic PWM framework driver for TWL4030/6030.

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

config PWM_TWL_LED
tristate "TWL4030/6030 PWM support for LED drivers"
depends on TWL4030_CORE
help
Generic PWM framework driver for TWL6030.
Generic PWM framework driver for TWL4030/6030 LED terminals.

To compile this driver as a module, choose M here: the module
will be called pwm-twl6030.
will be called pwm-twl-led.

config PWM_VT8500
tristate "vt8500 pwm support"
Expand Down
5 changes: 4 additions & 1 deletion drivers/pwm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ obj-$(CONFIG_PWM_MXS) += pwm-mxs.o
obj-$(CONFIG_PWM_PUV3) += pwm-puv3.o
obj-$(CONFIG_PWM_PXA) += pwm-pxa.o
obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o
obj-$(CONFIG_PWM_SPEAR) += pwm-spear.o
obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o
obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
obj-$(CONFIG_PWM_TWL6030) += pwm-twl6030.o
obj-$(CONFIG_PWM_TIPWMSS) += pwm-tipwmss.o
obj-$(CONFIG_PWM_TWL) += pwm-twl.o
obj-$(CONFIG_PWM_TWL_LED) += pwm-twl-led.o
obj-$(CONFIG_PWM_VT8500) += pwm-vt8500.o
29 changes: 29 additions & 0 deletions drivers/pwm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

#define MAX_PWMS 1024

/* flags in the third cell of the DT PWM specifier */
#define PWM_SPEC_POLARITY (1 << 0)

static DEFINE_MUTEX(pwm_lookup_lock);
static LIST_HEAD(pwm_lookup_list);
static DEFINE_MUTEX(pwm_lock);
Expand Down Expand Up @@ -129,6 +132,32 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
return 0;
}

struct pwm_device *
of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
{
struct pwm_device *pwm;

if (pc->of_pwm_n_cells < 3)
return ERR_PTR(-EINVAL);

if (args->args[0] >= pc->npwm)
return ERR_PTR(-EINVAL);

pwm = pwm_request_from_chip(pc, args->args[0], NULL);
if (IS_ERR(pwm))
return pwm;

pwm_set_period(pwm, args->args[1]);

if (args->args[2] & PWM_SPEC_POLARITY)
pwm_set_polarity(pwm, PWM_POLARITY_INVERSED);
else
pwm_set_polarity(pwm, PWM_POLARITY_NORMAL);

return pwm;
}
EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags);

static struct pwm_device *
of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/pwm/pwm-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static int imx_pwm_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id =
of_match_device(imx_pwm_dt_ids, &pdev->dev);
struct imx_pwm_data *data;
const struct imx_pwm_data *data;
struct imx_chip *imx;
struct resource *r;
int ret = 0;
Expand Down
23 changes: 21 additions & 2 deletions drivers/pwm/pwm-lpc32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,24 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
c = 0; /* 0 set division by 256 */
period_cycles = c;

/* The duty-cycle value is as follows:
*
* DUTY-CYCLE HIGH LEVEL
* 1 99.9%
* 25 90.0%
* 128 50.0%
* 220 10.0%
* 255 0.1%
* 0 0.0%
*
* In other words, the register value is duty-cycle % 256 with
* duty-cycle in the range 1-256.
*/
c = 256 * duty_ns;
do_div(c, period_ns);
duty_cycles = c;
if (c > 255)
c = 255;
duty_cycles = 256 - c;

writel(PWM_ENABLE | PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles),
lpc32xx->base + (pwm->hwpwm << 2));
Expand Down Expand Up @@ -106,6 +121,7 @@ static int lpc32xx_pwm_probe(struct platform_device *pdev)
lpc32xx->chip.dev = &pdev->dev;
lpc32xx->chip.ops = &lpc32xx_pwm_ops;
lpc32xx->chip.npwm = 2;
lpc32xx->chip.base = -1;

ret = pwmchip_add(&lpc32xx->chip);
if (ret < 0) {
Expand All @@ -121,8 +137,11 @@ static int lpc32xx_pwm_probe(struct platform_device *pdev)
static int lpc32xx_pwm_remove(struct platform_device *pdev)
{
struct lpc32xx_pwm_chip *lpc32xx = platform_get_drvdata(pdev);
unsigned int i;

for (i = 0; i < lpc32xx->chip.npwm; i++)
pwm_disable(&lpc32xx->chip.pwms[i]);

clk_disable(lpc32xx->clk);
return pwmchip_remove(&lpc32xx->chip);
}

Expand Down
1 change: 1 addition & 0 deletions drivers/pwm/pwm-samsung.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ static int s3c_pwm_probe(struct platform_device *pdev)

/* calculate base of control bits in TCON */
s3c->tcon_base = id == 0 ? 0 : (id * 4) + 4;
s3c->pwm_id = id;
s3c->chip.dev = &pdev->dev;
s3c->chip.ops = &s3c_pwm_ops;
s3c->chip.base = -1;
Expand Down
Loading

0 comments on commit 74779e2

Please sign in to comment.