Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pwm: omap-dmtimer: Allow for setting dmtimer clock source

OMAP GP timers can have different input clocks that allow different PWM
frequencies. However, there is no other way of setting the clock source but
through clocks or clock-names properties of the timer itself. This limits
PWM functionality to only the frequencies allowed by the particular clock
source. Allowing setting the clock source by PWM rather than by timer
allows different PWMs to have different ranges by not hard-wiring the clock
source to the timer.

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Thierry Reding <treding@nvidia.com>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>

authored by

Ivaylo Dimitrov and committed by
Tony Lindgren
a74a1982 4406d52a

+11 -5
+4
Documentation/devicetree/bindings/pwm/pwm-omap-dmtimer.txt
··· 9 9 10 10 Optional properties: 11 11 - ti,prescaler: Should be a value between 0 and 7, see the timers datasheet 12 + - ti,clock-source: Set dmtimer parent clock, values between 0 and 2: 13 + - 0x00 - high-frequency system clock (timer_sys_ck) 14 + - 0x01 - 32-kHz always-on clock (timer_32k_ck) 15 + - 0x02 - external clock (timer_ext_ck, OMAP2 only) 12 16 13 17 Example: 14 18 pwm9: dmtimer-pwm@9 {
+7 -5
drivers/pwm/pwm-omap-dmtimer.c
··· 245 245 struct pwm_omap_dmtimer_chip *omap; 246 246 struct pwm_omap_dmtimer_pdata *pdata; 247 247 pwm_omap_dmtimer *dm_timer; 248 - u32 prescaler; 248 + u32 v; 249 249 int status; 250 250 251 251 pdata = dev_get_platdata(&pdev->dev); ··· 306 306 if (pm_runtime_active(&omap->dm_timer_pdev->dev)) 307 307 omap->pdata->stop(omap->dm_timer); 308 308 309 - /* setup dmtimer prescaler */ 310 - if (!of_property_read_u32(pdev->dev.of_node, "ti,prescaler", 311 - &prescaler)) 312 - omap->pdata->set_prescaler(omap->dm_timer, prescaler); 309 + if (!of_property_read_u32(pdev->dev.of_node, "ti,prescaler", &v)) 310 + omap->pdata->set_prescaler(omap->dm_timer, v); 311 + 312 + /* setup dmtimer clock source */ 313 + if (!of_property_read_u32(pdev->dev.of_node, "ti,clock-source", &v)) 314 + omap->pdata->set_source(omap->dm_timer, v); 313 315 314 316 omap->chip.dev = &pdev->dev; 315 317 omap->chip.ops = &pwm_omap_dmtimer_ops;