Skip to content

Commit 2474542

Browse files
committed
Merge tag 'for-3.7-rc1' of git://gitorious.org/linux-pwm/linux-pwm
Pull pwm changes from Thierry Reding: "All legacy PWM providers have now been moved to the PWM subsystem. The plan for 3.8 is to adapt all board files to provide a lookup table for PWM devices in order to get rid of the global namespace. Subsequently, users of the legacy pwm_request() and pwm_free() functions can be migrated to the new pwm_get() and pwm_put() functions. Once this has been completed, the legacy API and the compatibility code in the core can be removed. In addition to the above, these changes also add support for configuring the polarity of a PWM signal (currently only supported on ECAP and EHRPWM) and include a much needed rework of the i.MX driver. Managed functions to obtain and release a PWM device (devm_pwm_get() and devm_pwm_put()) have been added and the pwm-backlight driver has been updated to use them. If the PWM subsystem hasn't been enabled, dummy functions are provided that allow the subsystem to safely compile out. Some common checks on input parameters have been moved to the core and removed from the drivers. Finally, a small fix corrects the description of the PWM specifier's second cell in the device tree representation." * tag 'for-3.7-rc1' of git://gitorious.org/linux-pwm/linux-pwm: (23 commits) pwm: dt: Fix description of second PWM cell pwm: Check for negative duty-cycle and period pwm: Add Ingenic JZ4740 support MIPS: JZ4740: Export timer API pwm: Move PUV3 PWM driver to PWM framework unicore32: pwm: Use managed resource allocations unicore32: pwm: Remove unnecessary indirection unicore32: pwm: Use module_platform_driver() unicore32: pwm: Properly remap memory-mapped registers pwm-backlight: Use devm_pwm_get() instead of pwm_get() pwm: Move AB8500 PWM driver to PWM framework pwm: Fix compilation error when CONFIG_PWM is not defined pwm: i.MX: fix clock lookup pwm: i.MX: use per clock unconditionally pwm: i.MX: add devicetree support pwm: i.MX: Use module_platform_driver pwm: i.MX: add functions to enable/disable pwm. pwm: i.MX: remove unnecessary if in pwm_[en|dis]able pwm: i.MX: factor out SoC specific functions pwm: pwm-tiehrpwm: Add support for configuring polarity of PWM ...
2 parents c7a6ced + 85f8879 commit 2474542

File tree

35 files changed

+1069
-822
lines changed

35 files changed

+1069
-822
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Freescale i.MX PWM controller
2+
3+
Required properties:
4+
- compatible: should be "fsl,<soc>-pwm"
5+
- reg: physical base address and length of the controller's registers
6+
- #pwm-cells: should be 2. The first cell specifies the per-chip index
7+
of the PWM to use and the second cell is the period in nanoseconds.
8+
- interrupts: The interrupt for the pwm controller
9+
10+
Example:
11+
12+
pwm1: pwm@53fb4000 {
13+
#pwm-cells = <2>;
14+
compatible = "fsl,imx53-pwm", "fsl,imx27-pwm";
15+
reg = <0x53fb4000 0x4000>;
16+
interrupts = <61>;
17+
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Required properties:
44
- compatible: should be "fsl,imx23-pwm"
55
- reg: physical base address and length of the controller's registers
66
- #pwm-cells: should be 2. The first cell specifies the per-chip index
7-
of the PWM to use and the second cell is the duty cycle in nanoseconds.
7+
of the PWM to use and the second cell is the period in nanoseconds.
88
- fsl,pwm-number: the number of PWM devices
99

1010
Example:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Required properties:
77
- reg: physical base address and length of the controller's registers
88
- #pwm-cells: On Tegra the number of cells used to specify a PWM is 2. The
99
first cell specifies the per-chip index of the PWM to use and the second
10-
cell is the duty cycle in nanoseconds.
10+
cell is the period in nanoseconds.
1111

1212
Example:
1313

Documentation/driver-model/devres.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,7 @@ CLOCK
284284
PINCTRL
285285
devm_pinctrl_get()
286286
devm_pinctrl_put()
287+
288+
PWM
289+
devm_pwm_get()
290+
devm_pwm_put()

Documentation/pwm.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Legacy users can request a PWM device using pwm_request() and free it
3636
after usage with pwm_free().
3737

3838
New users should use the pwm_get() function and pass to it the consumer
39-
device or a consumer name. pwm_put() is used to free the PWM device.
39+
device or a consumer name. pwm_put() is used to free the PWM device. Managed
40+
variants of these functions, devm_pwm_get() and devm_pwm_put(), also exist.
4041

4142
After being requested a PWM has to be configured using:
4243

arch/mips/include/asm/mach-jz4740/platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern struct platform_device jz4740_pcm_device;
3131
extern struct platform_device jz4740_codec_device;
3232
extern struct platform_device jz4740_adc_device;
3333
extern struct platform_device jz4740_wdt_device;
34+
extern struct platform_device jz4740_pwm_device;
3435

3536
void jz4740_serial_device_register(void);
3637

arch/mips/include/asm/mach-jz4740/timer.h

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,120 @@
1616
#ifndef __ASM_MACH_JZ4740_TIMER
1717
#define __ASM_MACH_JZ4740_TIMER
1818

19+
#define JZ_REG_TIMER_STOP 0x0C
20+
#define JZ_REG_TIMER_STOP_SET 0x1C
21+
#define JZ_REG_TIMER_STOP_CLEAR 0x2C
22+
#define JZ_REG_TIMER_ENABLE 0x00
23+
#define JZ_REG_TIMER_ENABLE_SET 0x04
24+
#define JZ_REG_TIMER_ENABLE_CLEAR 0x08
25+
#define JZ_REG_TIMER_FLAG 0x10
26+
#define JZ_REG_TIMER_FLAG_SET 0x14
27+
#define JZ_REG_TIMER_FLAG_CLEAR 0x18
28+
#define JZ_REG_TIMER_MASK 0x20
29+
#define JZ_REG_TIMER_MASK_SET 0x24
30+
#define JZ_REG_TIMER_MASK_CLEAR 0x28
31+
32+
#define JZ_REG_TIMER_DFR(x) (((x) * 0x10) + 0x30)
33+
#define JZ_REG_TIMER_DHR(x) (((x) * 0x10) + 0x34)
34+
#define JZ_REG_TIMER_CNT(x) (((x) * 0x10) + 0x38)
35+
#define JZ_REG_TIMER_CTRL(x) (((x) * 0x10) + 0x3C)
36+
37+
#define JZ_TIMER_IRQ_HALF(x) BIT((x) + 0x10)
38+
#define JZ_TIMER_IRQ_FULL(x) BIT(x)
39+
40+
#define JZ_TIMER_CTRL_PWM_ABBRUPT_SHUTDOWN BIT(9)
41+
#define JZ_TIMER_CTRL_PWM_ACTIVE_LOW BIT(8)
42+
#define JZ_TIMER_CTRL_PWM_ENABLE BIT(7)
43+
#define JZ_TIMER_CTRL_PRESCALE_MASK 0x1c
44+
#define JZ_TIMER_CTRL_PRESCALE_OFFSET 0x3
45+
#define JZ_TIMER_CTRL_PRESCALE_1 (0 << 3)
46+
#define JZ_TIMER_CTRL_PRESCALE_4 (1 << 3)
47+
#define JZ_TIMER_CTRL_PRESCALE_16 (2 << 3)
48+
#define JZ_TIMER_CTRL_PRESCALE_64 (3 << 3)
49+
#define JZ_TIMER_CTRL_PRESCALE_256 (4 << 3)
50+
#define JZ_TIMER_CTRL_PRESCALE_1024 (5 << 3)
51+
52+
#define JZ_TIMER_CTRL_PRESCALER(x) ((x) << JZ_TIMER_CTRL_PRESCALE_OFFSET)
53+
54+
#define JZ_TIMER_CTRL_SRC_EXT BIT(2)
55+
#define JZ_TIMER_CTRL_SRC_RTC BIT(1)
56+
#define JZ_TIMER_CTRL_SRC_PCLK BIT(0)
57+
58+
extern void __iomem *jz4740_timer_base;
59+
void __init jz4740_timer_init(void);
60+
1961
void jz4740_timer_enable_watchdog(void);
2062
void jz4740_timer_disable_watchdog(void);
2163

64+
static inline void jz4740_timer_stop(unsigned int timer)
65+
{
66+
writel(BIT(timer), jz4740_timer_base + JZ_REG_TIMER_STOP_SET);
67+
}
68+
69+
static inline void jz4740_timer_start(unsigned int timer)
70+
{
71+
writel(BIT(timer), jz4740_timer_base + JZ_REG_TIMER_STOP_CLEAR);
72+
}
73+
74+
static inline bool jz4740_timer_is_enabled(unsigned int timer)
75+
{
76+
return readb(jz4740_timer_base + JZ_REG_TIMER_ENABLE) & BIT(timer);
77+
}
78+
79+
static inline void jz4740_timer_enable(unsigned int timer)
80+
{
81+
writeb(BIT(timer), jz4740_timer_base + JZ_REG_TIMER_ENABLE_SET);
82+
}
83+
84+
static inline void jz4740_timer_disable(unsigned int timer)
85+
{
86+
writeb(BIT(timer), jz4740_timer_base + JZ_REG_TIMER_ENABLE_CLEAR);
87+
}
88+
89+
static inline void jz4740_timer_set_period(unsigned int timer, uint16_t period)
90+
{
91+
writew(period, jz4740_timer_base + JZ_REG_TIMER_DFR(timer));
92+
}
93+
94+
static inline void jz4740_timer_set_duty(unsigned int timer, uint16_t duty)
95+
{
96+
writew(duty, jz4740_timer_base + JZ_REG_TIMER_DHR(timer));
97+
}
98+
99+
static inline void jz4740_timer_set_count(unsigned int timer, uint16_t count)
100+
{
101+
writew(count, jz4740_timer_base + JZ_REG_TIMER_CNT(timer));
102+
}
103+
104+
static inline uint16_t jz4740_timer_get_count(unsigned int timer)
105+
{
106+
return readw(jz4740_timer_base + JZ_REG_TIMER_CNT(timer));
107+
}
108+
109+
static inline void jz4740_timer_ack_full(unsigned int timer)
110+
{
111+
writel(JZ_TIMER_IRQ_FULL(timer), jz4740_timer_base + JZ_REG_TIMER_FLAG_CLEAR);
112+
}
113+
114+
static inline void jz4740_timer_irq_full_enable(unsigned int timer)
115+
{
116+
writel(JZ_TIMER_IRQ_FULL(timer), jz4740_timer_base + JZ_REG_TIMER_FLAG_CLEAR);
117+
writel(JZ_TIMER_IRQ_FULL(timer), jz4740_timer_base + JZ_REG_TIMER_MASK_CLEAR);
118+
}
119+
120+
static inline void jz4740_timer_irq_full_disable(unsigned int timer)
121+
{
122+
writel(JZ_TIMER_IRQ_FULL(timer), jz4740_timer_base + JZ_REG_TIMER_MASK_SET);
123+
}
124+
125+
static inline void jz4740_timer_set_ctrl(unsigned int timer, uint16_t ctrl)
126+
{
127+
writew(ctrl, jz4740_timer_base + JZ_REG_TIMER_CTRL(timer));
128+
}
129+
130+
static inline uint16_t jz4740_timer_get_ctrl(unsigned int timer)
131+
{
132+
return readw(jz4740_timer_base + JZ_REG_TIMER_CTRL(timer));
133+
}
134+
22135
#endif

arch/mips/jz4740/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ config JZ4740_QI_LB60
77
bool "Qi Hardware Ben NanoNote"
88

99
endchoice
10-
11-
config HAVE_PWM
12-
bool

arch/mips/jz4740/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Object file lists.
66

77
obj-y += prom.o irq.o time.o reset.o setup.o dma.o \
8-
gpio.o clock.o platform.o timer.o pwm.o serial.o
8+
gpio.o clock.o platform.o timer.o serial.o
99

1010
obj-$(CONFIG_DEBUG_FS) += clock-debugfs.o
1111

arch/mips/jz4740/board-qi_lb60.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ static struct platform_device *jz_platform_devices[] __initdata = {
437437
&jz4740_codec_device,
438438
&jz4740_rtc_device,
439439
&jz4740_adc_device,
440+
&jz4740_pwm_device,
440441
&qi_lb60_gpio_keys,
441442
&qi_lb60_pwm_beeper,
442443
&qi_lb60_charger_device,

0 commit comments

Comments
 (0)