Lines Matching full:omap
12 * This file is the core OMAP support for the generic, Linux
13 * PWM driver / controller, using the OMAP's dual-mode timers
29 * - PWM OMAP DM timer cannot change the polarity when pwm is active. When
44 #include <linux/platform_data/dmtimer-omap.h>
56 * corresponding to omap dmtimer.
59 * @dm_timer: Pointer to omap dm timer.
60 * @pdata: Pointer to omap dm timer ops.
61 * @dm_timer_pdev: Pointer to omap dm timer platform device
91 * pwm_omap_dmtimer_start() - Start the pwm omap dm timer in pwm mode
92 * @omap: Pointer to pwm omap dm timer chip
94 static void pwm_omap_dmtimer_start(struct pwm_omap_dmtimer_chip *omap) in pwm_omap_dmtimer_start() argument
97 * According to OMAP 4 TRM section 22.2.4.10 the counter should be in pwm_omap_dmtimer_start()
104 omap->pdata->enable(omap->dm_timer); in pwm_omap_dmtimer_start()
105 omap->pdata->write_counter(omap->dm_timer, DM_TIMER_LOAD_MIN); in pwm_omap_dmtimer_start()
106 omap->pdata->disable(omap->dm_timer); in pwm_omap_dmtimer_start()
108 omap->pdata->start(omap->dm_timer); in pwm_omap_dmtimer_start()
113 * @omap: Pointer to pwm omap dm timer chip
117 static bool pwm_omap_dmtimer_is_enabled(struct pwm_omap_dmtimer_chip *omap) in pwm_omap_dmtimer_is_enabled() argument
121 status = omap->pdata->get_pwm_status(omap->dm_timer); in pwm_omap_dmtimer_is_enabled()
128 * @omap: Pointer to pwm omap dm timer chip
132 static int pwm_omap_dmtimer_polarity(struct pwm_omap_dmtimer_chip *omap) in pwm_omap_dmtimer_polarity() argument
136 status = omap->pdata->get_pwm_status(omap->dm_timer); in pwm_omap_dmtimer_polarity()
142 * pwm_omap_dmtimer_config() - Update the configuration of pwm omap dm timer
155 struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip); in pwm_omap_dmtimer_config() local
168 fclk = omap->pdata->get_fclk(omap->dm_timer); in pwm_omap_dmtimer_config()
231 omap->pdata->set_load(omap->dm_timer, load_value); in pwm_omap_dmtimer_config()
232 omap->pdata->set_match(omap->dm_timer, true, match_value); in pwm_omap_dmtimer_config()
250 struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip); in pwm_omap_dmtimer_set_polarity() local
254 enabled = pwm_omap_dmtimer_is_enabled(omap); in pwm_omap_dmtimer_set_polarity()
256 omap->pdata->stop(omap->dm_timer); in pwm_omap_dmtimer_set_polarity()
258 omap->pdata->set_pwm(omap->dm_timer, in pwm_omap_dmtimer_set_polarity()
264 pwm_omap_dmtimer_start(omap); in pwm_omap_dmtimer_set_polarity()
268 * pwm_omap_dmtimer_apply() - Changes the state of the pwm omap dm timer.
279 struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip); in pwm_omap_dmtimer_apply() local
282 mutex_lock(&omap->mutex); in pwm_omap_dmtimer_apply()
284 if (pwm_omap_dmtimer_is_enabled(omap) && !state->enabled) { in pwm_omap_dmtimer_apply()
285 omap->pdata->stop(omap->dm_timer); in pwm_omap_dmtimer_apply()
289 if (pwm_omap_dmtimer_polarity(omap) != state->polarity) in pwm_omap_dmtimer_apply()
297 if (!pwm_omap_dmtimer_is_enabled(omap) && state->enabled) { in pwm_omap_dmtimer_apply()
298 omap->pdata->set_pwm(omap->dm_timer, in pwm_omap_dmtimer_apply()
303 pwm_omap_dmtimer_start(omap); in pwm_omap_dmtimer_apply()
307 mutex_unlock(&omap->mutex); in pwm_omap_dmtimer_apply()
323 struct pwm_omap_dmtimer_chip *omap; in pwm_omap_dmtimer_probe() local
380 omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL); in pwm_omap_dmtimer_probe()
381 if (!omap) { in pwm_omap_dmtimer_probe()
386 omap->pdata = pdata; in pwm_omap_dmtimer_probe()
387 omap->dm_timer = dm_timer; in pwm_omap_dmtimer_probe()
388 omap->dm_timer_pdev = timer_pdev; in pwm_omap_dmtimer_probe()
394 if (pm_runtime_active(&omap->dm_timer_pdev->dev)) in pwm_omap_dmtimer_probe()
395 omap->pdata->stop(omap->dm_timer); in pwm_omap_dmtimer_probe()
398 omap->pdata->set_prescaler(omap->dm_timer, v); in pwm_omap_dmtimer_probe()
402 omap->pdata->set_source(omap->dm_timer, v); in pwm_omap_dmtimer_probe()
404 omap->chip.dev = &pdev->dev; in pwm_omap_dmtimer_probe()
405 omap->chip.ops = &pwm_omap_dmtimer_ops; in pwm_omap_dmtimer_probe()
406 omap->chip.npwm = 1; in pwm_omap_dmtimer_probe()
408 mutex_init(&omap->mutex); in pwm_omap_dmtimer_probe()
410 ret = pwmchip_add(&omap->chip); in pwm_omap_dmtimer_probe()
418 platform_set_drvdata(pdev, omap); in pwm_omap_dmtimer_probe()
425 * *omap is allocated using devm_kzalloc, in pwm_omap_dmtimer_probe()
446 struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev); in pwm_omap_dmtimer_remove() local
448 pwmchip_remove(&omap->chip); in pwm_omap_dmtimer_remove()
450 if (pm_runtime_active(&omap->dm_timer_pdev->dev)) in pwm_omap_dmtimer_remove()
451 omap->pdata->stop(omap->dm_timer); in pwm_omap_dmtimer_remove()
453 omap->pdata->free(omap->dm_timer); in pwm_omap_dmtimer_remove()
455 put_device(&omap->dm_timer_pdev->dev); in pwm_omap_dmtimer_remove()
457 mutex_destroy(&omap->mutex); in pwm_omap_dmtimer_remove()
463 {.compatible = "ti,omap-dmtimer-pwm"},
470 .name = "omap-dmtimer-pwm",
482 MODULE_DESCRIPTION("OMAP PWM Driver using Dual-mode Timers");