xref: /linux/drivers/pwm/pwm-omap-dmtimer.c (revision 922201d129c8f9d0c3207dca90ea6ffd8e2242f0)
16604c655SNeil Armstrong /*
26604c655SNeil Armstrong  * Copyright (c) 2015 Neil Armstrong <narmstrong@baylibre.com>
36604c655SNeil Armstrong  * Copyright (c) 2014 Joachim Eastwood <manabian@gmail.com>
46604c655SNeil Armstrong  * Copyright (c) 2012 NeilBrown <neilb@suse.de>
56604c655SNeil Armstrong  * Heavily based on earlier code which is:
66604c655SNeil Armstrong  * Copyright (c) 2010 Grant Erickson <marathon96@gmail.com>
76604c655SNeil Armstrong  *
86604c655SNeil Armstrong  * Also based on pwm-samsung.c
96604c655SNeil Armstrong  *
106604c655SNeil Armstrong  * This program is free software; you can redistribute it and/or
116604c655SNeil Armstrong  * modify it under the terms of the GNU General Public License
126604c655SNeil Armstrong  * version 2 as published by the Free Software Foundation.
136604c655SNeil Armstrong  *
146604c655SNeil Armstrong  * Description:
156604c655SNeil Armstrong  *   This file is the core OMAP support for the generic, Linux
166604c655SNeil Armstrong  *   PWM driver / controller, using the OMAP's dual-mode timers.
176604c655SNeil Armstrong  */
186604c655SNeil Armstrong 
196604c655SNeil Armstrong #include <linux/clk.h>
206604c655SNeil Armstrong #include <linux/err.h>
216604c655SNeil Armstrong #include <linux/kernel.h>
226604c655SNeil Armstrong #include <linux/module.h>
236604c655SNeil Armstrong #include <linux/mutex.h>
246604c655SNeil Armstrong #include <linux/of.h>
256604c655SNeil Armstrong #include <linux/of_platform.h>
266604c655SNeil Armstrong #include <linux/platform_data/pwm_omap_dmtimer.h>
276604c655SNeil Armstrong #include <linux/platform_device.h>
286604c655SNeil Armstrong #include <linux/pm_runtime.h>
296604c655SNeil Armstrong #include <linux/pwm.h>
306604c655SNeil Armstrong #include <linux/slab.h>
316604c655SNeil Armstrong #include <linux/time.h>
326604c655SNeil Armstrong 
336604c655SNeil Armstrong #define DM_TIMER_LOAD_MIN 0xfffffffe
34f8caa792SDavid Rivshin #define DM_TIMER_MAX      0xffffffff
356604c655SNeil Armstrong 
366604c655SNeil Armstrong struct pwm_omap_dmtimer_chip {
376604c655SNeil Armstrong 	struct pwm_chip chip;
386604c655SNeil Armstrong 	struct mutex mutex;
396604c655SNeil Armstrong 	pwm_omap_dmtimer *dm_timer;
406604c655SNeil Armstrong 	struct pwm_omap_dmtimer_pdata *pdata;
416604c655SNeil Armstrong 	struct platform_device *dm_timer_pdev;
426604c655SNeil Armstrong };
436604c655SNeil Armstrong 
446604c655SNeil Armstrong static inline struct pwm_omap_dmtimer_chip *
456604c655SNeil Armstrong to_pwm_omap_dmtimer_chip(struct pwm_chip *chip)
466604c655SNeil Armstrong {
476604c655SNeil Armstrong 	return container_of(chip, struct pwm_omap_dmtimer_chip, chip);
486604c655SNeil Armstrong }
496604c655SNeil Armstrong 
50f8caa792SDavid Rivshin static u32 pwm_omap_dmtimer_get_clock_cycles(unsigned long clk_rate, int ns)
516604c655SNeil Armstrong {
527b0883f3SDavid Rivshin 	return DIV_ROUND_CLOSEST_ULL((u64)clk_rate * ns, NSEC_PER_SEC);
536604c655SNeil Armstrong }
546604c655SNeil Armstrong 
556604c655SNeil Armstrong static void pwm_omap_dmtimer_start(struct pwm_omap_dmtimer_chip *omap)
566604c655SNeil Armstrong {
576604c655SNeil Armstrong 	/*
586604c655SNeil Armstrong 	 * According to OMAP 4 TRM section 22.2.4.10 the counter should be
596604c655SNeil Armstrong 	 * started at 0xFFFFFFFE when overflow and match is used to ensure
606604c655SNeil Armstrong 	 * that the PWM line is toggled on the first event.
616604c655SNeil Armstrong 	 *
626604c655SNeil Armstrong 	 * Note that omap_dm_timer_enable/disable is for register access and
636604c655SNeil Armstrong 	 * not the timer counter itself.
646604c655SNeil Armstrong 	 */
656604c655SNeil Armstrong 	omap->pdata->enable(omap->dm_timer);
666604c655SNeil Armstrong 	omap->pdata->write_counter(omap->dm_timer, DM_TIMER_LOAD_MIN);
676604c655SNeil Armstrong 	omap->pdata->disable(omap->dm_timer);
686604c655SNeil Armstrong 
696604c655SNeil Armstrong 	omap->pdata->start(omap->dm_timer);
706604c655SNeil Armstrong }
716604c655SNeil Armstrong 
726604c655SNeil Armstrong static int pwm_omap_dmtimer_enable(struct pwm_chip *chip,
736604c655SNeil Armstrong 				   struct pwm_device *pwm)
746604c655SNeil Armstrong {
756604c655SNeil Armstrong 	struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip);
766604c655SNeil Armstrong 
776604c655SNeil Armstrong 	mutex_lock(&omap->mutex);
786604c655SNeil Armstrong 	pwm_omap_dmtimer_start(omap);
796604c655SNeil Armstrong 	mutex_unlock(&omap->mutex);
806604c655SNeil Armstrong 
816604c655SNeil Armstrong 	return 0;
826604c655SNeil Armstrong }
836604c655SNeil Armstrong 
846604c655SNeil Armstrong static void pwm_omap_dmtimer_disable(struct pwm_chip *chip,
856604c655SNeil Armstrong 				     struct pwm_device *pwm)
866604c655SNeil Armstrong {
876604c655SNeil Armstrong 	struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip);
886604c655SNeil Armstrong 
896604c655SNeil Armstrong 	mutex_lock(&omap->mutex);
906604c655SNeil Armstrong 	omap->pdata->stop(omap->dm_timer);
916604c655SNeil Armstrong 	mutex_unlock(&omap->mutex);
926604c655SNeil Armstrong }
936604c655SNeil Armstrong 
946604c655SNeil Armstrong static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
956604c655SNeil Armstrong 				   struct pwm_device *pwm,
966604c655SNeil Armstrong 				   int duty_ns, int period_ns)
976604c655SNeil Armstrong {
986604c655SNeil Armstrong 	struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip);
99f8caa792SDavid Rivshin 	u32 period_cycles, duty_cycles;
100f8caa792SDavid Rivshin 	u32 load_value, match_value;
1016604c655SNeil Armstrong 	struct clk *fclk;
1026604c655SNeil Armstrong 	unsigned long clk_rate;
1036604c655SNeil Armstrong 	bool timer_active;
1046604c655SNeil Armstrong 
105*922201d1SDavid Rivshin 	dev_dbg(chip->dev, "requested duty cycle: %d ns, period: %d ns\n",
106*922201d1SDavid Rivshin 		duty_ns, period_ns);
1076604c655SNeil Armstrong 
1086604c655SNeil Armstrong 	mutex_lock(&omap->mutex);
1096604c655SNeil Armstrong 	if (duty_ns == pwm_get_duty_cycle(pwm) &&
1106604c655SNeil Armstrong 	    period_ns == pwm_get_period(pwm)) {
1116604c655SNeil Armstrong 		/* No change - don't cause any transients. */
1126604c655SNeil Armstrong 		mutex_unlock(&omap->mutex);
1136604c655SNeil Armstrong 		return 0;
1146604c655SNeil Armstrong 	}
1156604c655SNeil Armstrong 
1166604c655SNeil Armstrong 	fclk = omap->pdata->get_fclk(omap->dm_timer);
1176604c655SNeil Armstrong 	if (!fclk) {
1186604c655SNeil Armstrong 		dev_err(chip->dev, "invalid pmtimer fclk\n");
119cd378881SDavid Rivshin 		goto err_einval;
1206604c655SNeil Armstrong 	}
1216604c655SNeil Armstrong 
1226604c655SNeil Armstrong 	clk_rate = clk_get_rate(fclk);
1236604c655SNeil Armstrong 	if (!clk_rate) {
1246604c655SNeil Armstrong 		dev_err(chip->dev, "invalid pmtimer fclk rate\n");
125cd378881SDavid Rivshin 		goto err_einval;
1266604c655SNeil Armstrong 	}
1276604c655SNeil Armstrong 
1286604c655SNeil Armstrong 	dev_dbg(chip->dev, "clk rate: %luHz\n", clk_rate);
1296604c655SNeil Armstrong 
1306604c655SNeil Armstrong 	/*
1316604c655SNeil Armstrong 	 * Calculate the appropriate load and match values based on the
1326604c655SNeil Armstrong 	 * specified period and duty cycle. The load value determines the
133f8caa792SDavid Rivshin 	 * period time and the match value determines the duty time.
134f8caa792SDavid Rivshin 	 *
135f8caa792SDavid Rivshin 	 * The period lasts for (DM_TIMER_MAX-load_value+1) clock cycles.
136f8caa792SDavid Rivshin 	 * Similarly, the active time lasts (match_value-load_value+1) cycles.
137f8caa792SDavid Rivshin 	 * The non-active time is the remainder: (DM_TIMER_MAX-match_value)
138f8caa792SDavid Rivshin 	 * clock cycles.
139f8caa792SDavid Rivshin 	 *
140cd378881SDavid Rivshin 	 * NOTE: It is required that: load_value <= match_value < DM_TIMER_MAX
141cd378881SDavid Rivshin 	 *
142f8caa792SDavid Rivshin 	 * References:
143f8caa792SDavid Rivshin 	 *   OMAP4430/60/70 TRM sections 22.2.4.10 and 22.2.4.11
144f8caa792SDavid Rivshin 	 *   AM335x Sitara TRM sections 20.1.3.5 and 20.1.3.6
1456604c655SNeil Armstrong 	 */
146f8caa792SDavid Rivshin 	period_cycles = pwm_omap_dmtimer_get_clock_cycles(clk_rate, period_ns);
147f8caa792SDavid Rivshin 	duty_cycles = pwm_omap_dmtimer_get_clock_cycles(clk_rate, duty_ns);
148f8caa792SDavid Rivshin 
149cd378881SDavid Rivshin 	if (period_cycles < 2) {
150cd378881SDavid Rivshin 		dev_info(chip->dev,
151cd378881SDavid Rivshin 			 "period %d ns too short for clock rate %lu Hz\n",
152cd378881SDavid Rivshin 			 period_ns, clk_rate);
153cd378881SDavid Rivshin 		goto err_einval;
154cd378881SDavid Rivshin 	}
155cd378881SDavid Rivshin 
156cd378881SDavid Rivshin 	if (duty_cycles < 1) {
157cd378881SDavid Rivshin 		dev_dbg(chip->dev,
158cd378881SDavid Rivshin 			"duty cycle %d ns is too short for clock rate %lu Hz\n",
159cd378881SDavid Rivshin 			duty_ns, clk_rate);
160cd378881SDavid Rivshin 		dev_dbg(chip->dev, "using minimum of 1 clock cycle\n");
161cd378881SDavid Rivshin 		duty_cycles = 1;
162cd378881SDavid Rivshin 	} else if (duty_cycles >= period_cycles) {
163cd378881SDavid Rivshin 		dev_dbg(chip->dev,
164cd378881SDavid Rivshin 			"duty cycle %d ns is too long for period %d ns at clock rate %lu Hz\n",
165cd378881SDavid Rivshin 			duty_ns, period_ns, clk_rate);
166cd378881SDavid Rivshin 		dev_dbg(chip->dev, "using maximum of 1 clock cycle less than period\n");
167cd378881SDavid Rivshin 		duty_cycles = period_cycles - 1;
168cd378881SDavid Rivshin 	}
169cd378881SDavid Rivshin 
170*922201d1SDavid Rivshin 	dev_dbg(chip->dev, "effective duty cycle: %lld ns, period: %lld ns\n",
171*922201d1SDavid Rivshin 		DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * duty_cycles,
172*922201d1SDavid Rivshin 				      clk_rate),
173*922201d1SDavid Rivshin 		DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * period_cycles,
174*922201d1SDavid Rivshin 				      clk_rate));
175*922201d1SDavid Rivshin 
176f8caa792SDavid Rivshin 	load_value = (DM_TIMER_MAX - period_cycles) + 1;
177f8caa792SDavid Rivshin 	match_value = load_value + duty_cycles - 1;
1786604c655SNeil Armstrong 
1796604c655SNeil Armstrong 	/*
1806604c655SNeil Armstrong 	 * We MUST stop the associated dual-mode timer before attempting to
1816604c655SNeil Armstrong 	 * write its registers, but calls to omap_dm_timer_start/stop must
1826604c655SNeil Armstrong 	 * be balanced so check if timer is active before calling timer_stop.
1836604c655SNeil Armstrong 	 */
1846604c655SNeil Armstrong 	timer_active = pm_runtime_active(&omap->dm_timer_pdev->dev);
1856604c655SNeil Armstrong 	if (timer_active)
1866604c655SNeil Armstrong 		omap->pdata->stop(omap->dm_timer);
1876604c655SNeil Armstrong 
1886604c655SNeil Armstrong 	omap->pdata->set_load(omap->dm_timer, true, load_value);
1896604c655SNeil Armstrong 	omap->pdata->set_match(omap->dm_timer, true, match_value);
1906604c655SNeil Armstrong 
1916604c655SNeil Armstrong 	dev_dbg(chip->dev, "load value: %#08x (%d), match value: %#08x (%d)\n",
1926604c655SNeil Armstrong 		load_value, load_value,	match_value, match_value);
1936604c655SNeil Armstrong 
1946604c655SNeil Armstrong 	omap->pdata->set_pwm(omap->dm_timer,
1956604c655SNeil Armstrong 			      pwm->polarity == PWM_POLARITY_INVERSED,
1966604c655SNeil Armstrong 			      true,
1976604c655SNeil Armstrong 			      PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE);
1986604c655SNeil Armstrong 
1996604c655SNeil Armstrong 	/* If config was called while timer was running it must be reenabled. */
2006604c655SNeil Armstrong 	if (timer_active)
2016604c655SNeil Armstrong 		pwm_omap_dmtimer_start(omap);
2026604c655SNeil Armstrong 
2036604c655SNeil Armstrong 	mutex_unlock(&omap->mutex);
2046604c655SNeil Armstrong 
2056604c655SNeil Armstrong 	return 0;
206cd378881SDavid Rivshin 
207cd378881SDavid Rivshin err_einval:
208cd378881SDavid Rivshin 	mutex_unlock(&omap->mutex);
209cd378881SDavid Rivshin 
210cd378881SDavid Rivshin 	return -EINVAL;
2116604c655SNeil Armstrong }
2126604c655SNeil Armstrong 
2136604c655SNeil Armstrong static int pwm_omap_dmtimer_set_polarity(struct pwm_chip *chip,
2146604c655SNeil Armstrong 					 struct pwm_device *pwm,
2156604c655SNeil Armstrong 					 enum pwm_polarity polarity)
2166604c655SNeil Armstrong {
2176604c655SNeil Armstrong 	struct pwm_omap_dmtimer_chip *omap = to_pwm_omap_dmtimer_chip(chip);
2186604c655SNeil Armstrong 
2196604c655SNeil Armstrong 	/*
2206604c655SNeil Armstrong 	 * PWM core will not call set_polarity while PWM is enabled so it's
2216604c655SNeil Armstrong 	 * safe to reconfigure the timer here without stopping it first.
2226604c655SNeil Armstrong 	 */
2236604c655SNeil Armstrong 	mutex_lock(&omap->mutex);
2246604c655SNeil Armstrong 	omap->pdata->set_pwm(omap->dm_timer,
2256604c655SNeil Armstrong 			      polarity == PWM_POLARITY_INVERSED,
2266604c655SNeil Armstrong 			      true,
2276604c655SNeil Armstrong 			      PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE);
2286604c655SNeil Armstrong 	mutex_unlock(&omap->mutex);
2296604c655SNeil Armstrong 
2306604c655SNeil Armstrong 	return 0;
2316604c655SNeil Armstrong }
2326604c655SNeil Armstrong 
2336604c655SNeil Armstrong static const struct pwm_ops pwm_omap_dmtimer_ops = {
2346604c655SNeil Armstrong 	.enable	= pwm_omap_dmtimer_enable,
2356604c655SNeil Armstrong 	.disable = pwm_omap_dmtimer_disable,
2366604c655SNeil Armstrong 	.config	= pwm_omap_dmtimer_config,
2376604c655SNeil Armstrong 	.set_polarity = pwm_omap_dmtimer_set_polarity,
2386604c655SNeil Armstrong 	.owner = THIS_MODULE,
2396604c655SNeil Armstrong };
2406604c655SNeil Armstrong 
2416604c655SNeil Armstrong static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
2426604c655SNeil Armstrong {
2436604c655SNeil Armstrong 	struct device_node *np = pdev->dev.of_node;
2446604c655SNeil Armstrong 	struct device_node *timer;
2456604c655SNeil Armstrong 	struct pwm_omap_dmtimer_chip *omap;
2466604c655SNeil Armstrong 	struct pwm_omap_dmtimer_pdata *pdata;
2476604c655SNeil Armstrong 	pwm_omap_dmtimer *dm_timer;
2486604c655SNeil Armstrong 	u32 prescaler;
2496604c655SNeil Armstrong 	int status;
2506604c655SNeil Armstrong 
2516604c655SNeil Armstrong 	pdata = dev_get_platdata(&pdev->dev);
2526604c655SNeil Armstrong 	if (!pdata) {
2536604c655SNeil Armstrong 		dev_err(&pdev->dev, "Missing dmtimer platform data\n");
2546604c655SNeil Armstrong 		return -EINVAL;
2556604c655SNeil Armstrong 	}
2566604c655SNeil Armstrong 
2576604c655SNeil Armstrong 	if (!pdata->request_by_node ||
2586604c655SNeil Armstrong 	    !pdata->free ||
2596604c655SNeil Armstrong 	    !pdata->enable ||
2606604c655SNeil Armstrong 	    !pdata->disable ||
2616604c655SNeil Armstrong 	    !pdata->get_fclk ||
2626604c655SNeil Armstrong 	    !pdata->start ||
2636604c655SNeil Armstrong 	    !pdata->stop ||
2646604c655SNeil Armstrong 	    !pdata->set_load ||
2656604c655SNeil Armstrong 	    !pdata->set_match ||
2666604c655SNeil Armstrong 	    !pdata->set_pwm ||
2676604c655SNeil Armstrong 	    !pdata->set_prescaler ||
2686604c655SNeil Armstrong 	    !pdata->write_counter) {
2696604c655SNeil Armstrong 		dev_err(&pdev->dev, "Incomplete dmtimer pdata structure\n");
2706604c655SNeil Armstrong 		return -EINVAL;
2716604c655SNeil Armstrong 	}
2726604c655SNeil Armstrong 
2736604c655SNeil Armstrong 	timer = of_parse_phandle(np, "ti,timers", 0);
2746604c655SNeil Armstrong 	if (!timer)
2756604c655SNeil Armstrong 		return -ENODEV;
2766604c655SNeil Armstrong 
2776604c655SNeil Armstrong 	if (!of_get_property(timer, "ti,timer-pwm", NULL)) {
2786604c655SNeil Armstrong 		dev_err(&pdev->dev, "Missing ti,timer-pwm capability\n");
2796604c655SNeil Armstrong 		return -ENODEV;
2806604c655SNeil Armstrong 	}
2816604c655SNeil Armstrong 
2826604c655SNeil Armstrong 	dm_timer = pdata->request_by_node(timer);
2836604c655SNeil Armstrong 	if (!dm_timer)
2846604c655SNeil Armstrong 		return -EPROBE_DEFER;
2856604c655SNeil Armstrong 
2866604c655SNeil Armstrong 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
2876604c655SNeil Armstrong 	if (!omap) {
28807472640SDan Carpenter 		pdata->free(dm_timer);
2896604c655SNeil Armstrong 		return -ENOMEM;
2906604c655SNeil Armstrong 	}
2916604c655SNeil Armstrong 
2926604c655SNeil Armstrong 	omap->pdata = pdata;
2936604c655SNeil Armstrong 	omap->dm_timer = dm_timer;
2946604c655SNeil Armstrong 
2956604c655SNeil Armstrong 	omap->dm_timer_pdev = of_find_device_by_node(timer);
2966604c655SNeil Armstrong 	if (!omap->dm_timer_pdev) {
2976604c655SNeil Armstrong 		dev_err(&pdev->dev, "Unable to find timer pdev\n");
2986604c655SNeil Armstrong 		omap->pdata->free(dm_timer);
2996604c655SNeil Armstrong 		return -EINVAL;
3006604c655SNeil Armstrong 	}
3016604c655SNeil Armstrong 
3026604c655SNeil Armstrong 	/*
3036604c655SNeil Armstrong 	 * Ensure that the timer is stopped before we allow PWM core to call
3046604c655SNeil Armstrong 	 * pwm_enable.
3056604c655SNeil Armstrong 	 */
3066604c655SNeil Armstrong 	if (pm_runtime_active(&omap->dm_timer_pdev->dev))
3076604c655SNeil Armstrong 		omap->pdata->stop(omap->dm_timer);
3086604c655SNeil Armstrong 
3096604c655SNeil Armstrong 	/* setup dmtimer prescaler */
3106604c655SNeil Armstrong 	if (!of_property_read_u32(pdev->dev.of_node, "ti,prescaler",
3116604c655SNeil Armstrong 				&prescaler))
3126604c655SNeil Armstrong 		omap->pdata->set_prescaler(omap->dm_timer, prescaler);
3136604c655SNeil Armstrong 
3146604c655SNeil Armstrong 	omap->chip.dev = &pdev->dev;
3156604c655SNeil Armstrong 	omap->chip.ops = &pwm_omap_dmtimer_ops;
3166604c655SNeil Armstrong 	omap->chip.base = -1;
3176604c655SNeil Armstrong 	omap->chip.npwm = 1;
3186604c655SNeil Armstrong 	omap->chip.of_xlate = of_pwm_xlate_with_flags;
3196604c655SNeil Armstrong 	omap->chip.of_pwm_n_cells = 3;
3206604c655SNeil Armstrong 
3216604c655SNeil Armstrong 	mutex_init(&omap->mutex);
3226604c655SNeil Armstrong 
3236604c655SNeil Armstrong 	status = pwmchip_add(&omap->chip);
3246604c655SNeil Armstrong 	if (status < 0) {
3256604c655SNeil Armstrong 		dev_err(&pdev->dev, "failed to register PWM\n");
3266604c655SNeil Armstrong 		omap->pdata->free(omap->dm_timer);
3276604c655SNeil Armstrong 		return status;
3286604c655SNeil Armstrong 	}
3296604c655SNeil Armstrong 
3306604c655SNeil Armstrong 	platform_set_drvdata(pdev, omap);
3316604c655SNeil Armstrong 
3326604c655SNeil Armstrong 	return 0;
3336604c655SNeil Armstrong }
3346604c655SNeil Armstrong 
3356604c655SNeil Armstrong static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
3366604c655SNeil Armstrong {
3376604c655SNeil Armstrong 	struct pwm_omap_dmtimer_chip *omap = platform_get_drvdata(pdev);
3386604c655SNeil Armstrong 
3396604c655SNeil Armstrong 	if (pm_runtime_active(&omap->dm_timer_pdev->dev))
3406604c655SNeil Armstrong 		omap->pdata->stop(omap->dm_timer);
3416604c655SNeil Armstrong 
3426604c655SNeil Armstrong 	omap->pdata->free(omap->dm_timer);
3436604c655SNeil Armstrong 
3446604c655SNeil Armstrong 	mutex_destroy(&omap->mutex);
3456604c655SNeil Armstrong 
3466604c655SNeil Armstrong 	return pwmchip_remove(&omap->chip);
3476604c655SNeil Armstrong }
3486604c655SNeil Armstrong 
3496604c655SNeil Armstrong static const struct of_device_id pwm_omap_dmtimer_of_match[] = {
3506604c655SNeil Armstrong 	{.compatible = "ti,omap-dmtimer-pwm"},
3516604c655SNeil Armstrong 	{}
3526604c655SNeil Armstrong };
3536604c655SNeil Armstrong MODULE_DEVICE_TABLE(of, pwm_omap_dmtimer_of_match);
3546604c655SNeil Armstrong 
3556604c655SNeil Armstrong static struct platform_driver pwm_omap_dmtimer_driver = {
3566604c655SNeil Armstrong 	.driver = {
3576604c655SNeil Armstrong 		.name = "omap-dmtimer-pwm",
3586604c655SNeil Armstrong 		.of_match_table = of_match_ptr(pwm_omap_dmtimer_of_match),
3596604c655SNeil Armstrong 	},
3606604c655SNeil Armstrong 	.probe = pwm_omap_dmtimer_probe,
3616604c655SNeil Armstrong 	.remove	= pwm_omap_dmtimer_remove,
3626604c655SNeil Armstrong };
3636604c655SNeil Armstrong module_platform_driver(pwm_omap_dmtimer_driver);
3646604c655SNeil Armstrong 
3656604c655SNeil Armstrong MODULE_AUTHOR("Grant Erickson <marathon96@gmail.com>");
3666604c655SNeil Armstrong MODULE_AUTHOR("NeilBrown <neilb@suse.de>");
3676604c655SNeil Armstrong MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
3686604c655SNeil Armstrong MODULE_LICENSE("GPL v2");
3696604c655SNeil Armstrong MODULE_DESCRIPTION("OMAP PWM Driver using Dual-mode Timers");
370