xref: /OK3568_Linux_fs/kernel/drivers/pwm/pwm-tegra.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-or-later
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * drivers/pwm/pwm-tegra.c
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Tegra pulse-width-modulation controller driver
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Copyright (c) 2010-2020, NVIDIA Corporation.
8*4882a593Smuzhiyun  * Based on arch/arm/plat-mxc/pwm.c by Sascha Hauer <s.hauer@pengutronix.de>
9*4882a593Smuzhiyun  *
10*4882a593Smuzhiyun  * Overview of Tegra Pulse Width Modulator Register:
11*4882a593Smuzhiyun  * 1. 13-bit: Frequency division (SCALE)
12*4882a593Smuzhiyun  * 2. 8-bit : Pulse division (DUTY)
13*4882a593Smuzhiyun  * 3. 1-bit : Enable bit
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * The PWM clock frequency is divided by 256 before subdividing it based
16*4882a593Smuzhiyun  * on the programmable frequency division value to generate the required
17*4882a593Smuzhiyun  * frequency for PWM output. The maximum output frequency that can be
18*4882a593Smuzhiyun  * achieved is (max rate of source clock) / 256.
19*4882a593Smuzhiyun  * e.g. if source clock rate is 408 MHz, maximum output frequency can be:
20*4882a593Smuzhiyun  * 408 MHz/256 = 1.6 MHz.
21*4882a593Smuzhiyun  * This 1.6 MHz frequency can further be divided using SCALE value in PWM.
22*4882a593Smuzhiyun  *
23*4882a593Smuzhiyun  * PWM pulse width: 8 bits are usable [23:16] for varying pulse width.
24*4882a593Smuzhiyun  * To achieve 100% duty cycle, program Bit [24] of this register to
25*4882a593Smuzhiyun  * 1’b1. In which case the other bits [23:16] are set to don't care.
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * Limitations:
28*4882a593Smuzhiyun  * -	When PWM is disabled, the output is driven to inactive.
29*4882a593Smuzhiyun  * -	It does not allow the current PWM period to complete and
30*4882a593Smuzhiyun  *	stops abruptly.
31*4882a593Smuzhiyun  *
32*4882a593Smuzhiyun  * -	If the register is reconfigured while PWM is running,
33*4882a593Smuzhiyun  *	it does not complete the currently running period.
34*4882a593Smuzhiyun  *
35*4882a593Smuzhiyun  * -	If the user input duty is beyond acceptible limits,
36*4882a593Smuzhiyun  *	-EINVAL is returned.
37*4882a593Smuzhiyun  */
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #include <linux/clk.h>
40*4882a593Smuzhiyun #include <linux/err.h>
41*4882a593Smuzhiyun #include <linux/io.h>
42*4882a593Smuzhiyun #include <linux/module.h>
43*4882a593Smuzhiyun #include <linux/of.h>
44*4882a593Smuzhiyun #include <linux/of_device.h>
45*4882a593Smuzhiyun #include <linux/pwm.h>
46*4882a593Smuzhiyun #include <linux/platform_device.h>
47*4882a593Smuzhiyun #include <linux/pinctrl/consumer.h>
48*4882a593Smuzhiyun #include <linux/slab.h>
49*4882a593Smuzhiyun #include <linux/reset.h>
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun #define PWM_ENABLE	(1 << 31)
52*4882a593Smuzhiyun #define PWM_DUTY_WIDTH	8
53*4882a593Smuzhiyun #define PWM_DUTY_SHIFT	16
54*4882a593Smuzhiyun #define PWM_SCALE_WIDTH	13
55*4882a593Smuzhiyun #define PWM_SCALE_SHIFT	0
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun struct tegra_pwm_soc {
58*4882a593Smuzhiyun 	unsigned int num_channels;
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun 	/* Maximum IP frequency for given SoCs */
61*4882a593Smuzhiyun 	unsigned long max_frequency;
62*4882a593Smuzhiyun };
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun struct tegra_pwm_chip {
65*4882a593Smuzhiyun 	struct pwm_chip chip;
66*4882a593Smuzhiyun 	struct device *dev;
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun 	struct clk *clk;
69*4882a593Smuzhiyun 	struct reset_control*rst;
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun 	unsigned long clk_rate;
72*4882a593Smuzhiyun 	unsigned long min_period_ns;
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun 	void __iomem *regs;
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 	const struct tegra_pwm_soc *soc;
77*4882a593Smuzhiyun };
78*4882a593Smuzhiyun 
to_tegra_pwm_chip(struct pwm_chip * chip)79*4882a593Smuzhiyun static inline struct tegra_pwm_chip *to_tegra_pwm_chip(struct pwm_chip *chip)
80*4882a593Smuzhiyun {
81*4882a593Smuzhiyun 	return container_of(chip, struct tegra_pwm_chip, chip);
82*4882a593Smuzhiyun }
83*4882a593Smuzhiyun 
pwm_readl(struct tegra_pwm_chip * chip,unsigned int num)84*4882a593Smuzhiyun static inline u32 pwm_readl(struct tegra_pwm_chip *chip, unsigned int num)
85*4882a593Smuzhiyun {
86*4882a593Smuzhiyun 	return readl(chip->regs + (num << 4));
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun 
pwm_writel(struct tegra_pwm_chip * chip,unsigned int num,unsigned long val)89*4882a593Smuzhiyun static inline void pwm_writel(struct tegra_pwm_chip *chip, unsigned int num,
90*4882a593Smuzhiyun 			     unsigned long val)
91*4882a593Smuzhiyun {
92*4882a593Smuzhiyun 	writel(val, chip->regs + (num << 4));
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun 
tegra_pwm_config(struct pwm_chip * chip,struct pwm_device * pwm,int duty_ns,int period_ns)95*4882a593Smuzhiyun static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
96*4882a593Smuzhiyun 			    int duty_ns, int period_ns)
97*4882a593Smuzhiyun {
98*4882a593Smuzhiyun 	struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
99*4882a593Smuzhiyun 	unsigned long long c = duty_ns, hz;
100*4882a593Smuzhiyun 	unsigned long rate, required_clk_rate;
101*4882a593Smuzhiyun 	u32 val = 0;
102*4882a593Smuzhiyun 	int err;
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 	/*
105*4882a593Smuzhiyun 	 * Convert from duty_ns / period_ns to a fixed number of duty ticks
106*4882a593Smuzhiyun 	 * per (1 << PWM_DUTY_WIDTH) cycles and make sure to round to the
107*4882a593Smuzhiyun 	 * nearest integer during division.
108*4882a593Smuzhiyun 	 */
109*4882a593Smuzhiyun 	c *= (1 << PWM_DUTY_WIDTH);
110*4882a593Smuzhiyun 	c = DIV_ROUND_CLOSEST_ULL(c, period_ns);
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun 	val = (u32)c << PWM_DUTY_SHIFT;
113*4882a593Smuzhiyun 
114*4882a593Smuzhiyun 	/*
115*4882a593Smuzhiyun 	 *  min period = max clock limit >> PWM_DUTY_WIDTH
116*4882a593Smuzhiyun 	 */
117*4882a593Smuzhiyun 	if (period_ns < pc->min_period_ns)
118*4882a593Smuzhiyun 		return -EINVAL;
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun 	/*
121*4882a593Smuzhiyun 	 * Compute the prescaler value for which (1 << PWM_DUTY_WIDTH)
122*4882a593Smuzhiyun 	 * cycles at the PWM clock rate will take period_ns nanoseconds.
123*4882a593Smuzhiyun 	 *
124*4882a593Smuzhiyun 	 * num_channels: If single instance of PWM controller has multiple
125*4882a593Smuzhiyun 	 * channels (e.g. Tegra210 or older) then it is not possible to
126*4882a593Smuzhiyun 	 * configure separate clock rates to each of the channels, in such
127*4882a593Smuzhiyun 	 * case the value stored during probe will be referred.
128*4882a593Smuzhiyun 	 *
129*4882a593Smuzhiyun 	 * If every PWM controller instance has one channel respectively, i.e.
130*4882a593Smuzhiyun 	 * nums_channels == 1 then only the clock rate can be modified
131*4882a593Smuzhiyun 	 * dynamically (e.g. Tegra186 or Tegra194).
132*4882a593Smuzhiyun 	 */
133*4882a593Smuzhiyun 	if (pc->soc->num_channels == 1) {
134*4882a593Smuzhiyun 		/*
135*4882a593Smuzhiyun 		 * Rate is multiplied with 2^PWM_DUTY_WIDTH so that it matches
136*4882a593Smuzhiyun 		 * with the maximum possible rate that the controller can
137*4882a593Smuzhiyun 		 * provide. Any further lower value can be derived by setting
138*4882a593Smuzhiyun 		 * PFM bits[0:12].
139*4882a593Smuzhiyun 		 *
140*4882a593Smuzhiyun 		 * required_clk_rate is a reference rate for source clock and
141*4882a593Smuzhiyun 		 * it is derived based on user requested period. By setting the
142*4882a593Smuzhiyun 		 * source clock rate as required_clk_rate, PWM controller will
143*4882a593Smuzhiyun 		 * be able to configure the requested period.
144*4882a593Smuzhiyun 		 */
145*4882a593Smuzhiyun 		required_clk_rate =
146*4882a593Smuzhiyun 			(NSEC_PER_SEC / period_ns) << PWM_DUTY_WIDTH;
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun 		err = clk_set_rate(pc->clk, required_clk_rate);
149*4882a593Smuzhiyun 		if (err < 0)
150*4882a593Smuzhiyun 			return -EINVAL;
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun 		/* Store the new rate for further references */
153*4882a593Smuzhiyun 		pc->clk_rate = clk_get_rate(pc->clk);
154*4882a593Smuzhiyun 	}
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun 	rate = pc->clk_rate >> PWM_DUTY_WIDTH;
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun 	/* Consider precision in PWM_SCALE_WIDTH rate calculation */
159*4882a593Smuzhiyun 	hz = DIV_ROUND_CLOSEST_ULL(100ULL * NSEC_PER_SEC, period_ns);
160*4882a593Smuzhiyun 	rate = DIV_ROUND_CLOSEST_ULL(100ULL * rate, hz);
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun 	/*
163*4882a593Smuzhiyun 	 * Since the actual PWM divider is the register's frequency divider
164*4882a593Smuzhiyun 	 * field plus 1, we need to decrement to get the correct value to
165*4882a593Smuzhiyun 	 * write to the register.
166*4882a593Smuzhiyun 	 */
167*4882a593Smuzhiyun 	if (rate > 0)
168*4882a593Smuzhiyun 		rate--;
169*4882a593Smuzhiyun 
170*4882a593Smuzhiyun 	/*
171*4882a593Smuzhiyun 	 * Make sure that the rate will fit in the register's frequency
172*4882a593Smuzhiyun 	 * divider field.
173*4882a593Smuzhiyun 	 */
174*4882a593Smuzhiyun 	if (rate >> PWM_SCALE_WIDTH)
175*4882a593Smuzhiyun 		return -EINVAL;
176*4882a593Smuzhiyun 
177*4882a593Smuzhiyun 	val |= rate << PWM_SCALE_SHIFT;
178*4882a593Smuzhiyun 
179*4882a593Smuzhiyun 	/*
180*4882a593Smuzhiyun 	 * If the PWM channel is disabled, make sure to turn on the clock
181*4882a593Smuzhiyun 	 * before writing the register. Otherwise, keep it enabled.
182*4882a593Smuzhiyun 	 */
183*4882a593Smuzhiyun 	if (!pwm_is_enabled(pwm)) {
184*4882a593Smuzhiyun 		err = clk_prepare_enable(pc->clk);
185*4882a593Smuzhiyun 		if (err < 0)
186*4882a593Smuzhiyun 			return err;
187*4882a593Smuzhiyun 	} else
188*4882a593Smuzhiyun 		val |= PWM_ENABLE;
189*4882a593Smuzhiyun 
190*4882a593Smuzhiyun 	pwm_writel(pc, pwm->hwpwm, val);
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun 	/*
193*4882a593Smuzhiyun 	 * If the PWM is not enabled, turn the clock off again to save power.
194*4882a593Smuzhiyun 	 */
195*4882a593Smuzhiyun 	if (!pwm_is_enabled(pwm))
196*4882a593Smuzhiyun 		clk_disable_unprepare(pc->clk);
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun 	return 0;
199*4882a593Smuzhiyun }
200*4882a593Smuzhiyun 
tegra_pwm_enable(struct pwm_chip * chip,struct pwm_device * pwm)201*4882a593Smuzhiyun static int tegra_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
202*4882a593Smuzhiyun {
203*4882a593Smuzhiyun 	struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
204*4882a593Smuzhiyun 	int rc = 0;
205*4882a593Smuzhiyun 	u32 val;
206*4882a593Smuzhiyun 
207*4882a593Smuzhiyun 	rc = clk_prepare_enable(pc->clk);
208*4882a593Smuzhiyun 	if (rc < 0)
209*4882a593Smuzhiyun 		return rc;
210*4882a593Smuzhiyun 
211*4882a593Smuzhiyun 	val = pwm_readl(pc, pwm->hwpwm);
212*4882a593Smuzhiyun 	val |= PWM_ENABLE;
213*4882a593Smuzhiyun 	pwm_writel(pc, pwm->hwpwm, val);
214*4882a593Smuzhiyun 
215*4882a593Smuzhiyun 	return 0;
216*4882a593Smuzhiyun }
217*4882a593Smuzhiyun 
tegra_pwm_disable(struct pwm_chip * chip,struct pwm_device * pwm)218*4882a593Smuzhiyun static void tegra_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
219*4882a593Smuzhiyun {
220*4882a593Smuzhiyun 	struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
221*4882a593Smuzhiyun 	u32 val;
222*4882a593Smuzhiyun 
223*4882a593Smuzhiyun 	val = pwm_readl(pc, pwm->hwpwm);
224*4882a593Smuzhiyun 	val &= ~PWM_ENABLE;
225*4882a593Smuzhiyun 	pwm_writel(pc, pwm->hwpwm, val);
226*4882a593Smuzhiyun 
227*4882a593Smuzhiyun 	clk_disable_unprepare(pc->clk);
228*4882a593Smuzhiyun }
229*4882a593Smuzhiyun 
230*4882a593Smuzhiyun static const struct pwm_ops tegra_pwm_ops = {
231*4882a593Smuzhiyun 	.config = tegra_pwm_config,
232*4882a593Smuzhiyun 	.enable = tegra_pwm_enable,
233*4882a593Smuzhiyun 	.disable = tegra_pwm_disable,
234*4882a593Smuzhiyun 	.owner = THIS_MODULE,
235*4882a593Smuzhiyun };
236*4882a593Smuzhiyun 
tegra_pwm_probe(struct platform_device * pdev)237*4882a593Smuzhiyun static int tegra_pwm_probe(struct platform_device *pdev)
238*4882a593Smuzhiyun {
239*4882a593Smuzhiyun 	struct tegra_pwm_chip *pwm;
240*4882a593Smuzhiyun 	struct resource *r;
241*4882a593Smuzhiyun 	int ret;
242*4882a593Smuzhiyun 
243*4882a593Smuzhiyun 	pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
244*4882a593Smuzhiyun 	if (!pwm)
245*4882a593Smuzhiyun 		return -ENOMEM;
246*4882a593Smuzhiyun 
247*4882a593Smuzhiyun 	pwm->soc = of_device_get_match_data(&pdev->dev);
248*4882a593Smuzhiyun 	pwm->dev = &pdev->dev;
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
251*4882a593Smuzhiyun 	pwm->regs = devm_ioremap_resource(&pdev->dev, r);
252*4882a593Smuzhiyun 	if (IS_ERR(pwm->regs))
253*4882a593Smuzhiyun 		return PTR_ERR(pwm->regs);
254*4882a593Smuzhiyun 
255*4882a593Smuzhiyun 	platform_set_drvdata(pdev, pwm);
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun 	pwm->clk = devm_clk_get(&pdev->dev, NULL);
258*4882a593Smuzhiyun 	if (IS_ERR(pwm->clk))
259*4882a593Smuzhiyun 		return PTR_ERR(pwm->clk);
260*4882a593Smuzhiyun 
261*4882a593Smuzhiyun 	/* Set maximum frequency of the IP */
262*4882a593Smuzhiyun 	ret = clk_set_rate(pwm->clk, pwm->soc->max_frequency);
263*4882a593Smuzhiyun 	if (ret < 0) {
264*4882a593Smuzhiyun 		dev_err(&pdev->dev, "Failed to set max frequency: %d\n", ret);
265*4882a593Smuzhiyun 		return ret;
266*4882a593Smuzhiyun 	}
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun 	/*
269*4882a593Smuzhiyun 	 * The requested and configured frequency may differ due to
270*4882a593Smuzhiyun 	 * clock register resolutions. Get the configured frequency
271*4882a593Smuzhiyun 	 * so that PWM period can be calculated more accurately.
272*4882a593Smuzhiyun 	 */
273*4882a593Smuzhiyun 	pwm->clk_rate = clk_get_rate(pwm->clk);
274*4882a593Smuzhiyun 
275*4882a593Smuzhiyun 	/* Set minimum limit of PWM period for the IP */
276*4882a593Smuzhiyun 	pwm->min_period_ns =
277*4882a593Smuzhiyun 	    (NSEC_PER_SEC / (pwm->soc->max_frequency >> PWM_DUTY_WIDTH)) + 1;
278*4882a593Smuzhiyun 
279*4882a593Smuzhiyun 	pwm->rst = devm_reset_control_get_exclusive(&pdev->dev, "pwm");
280*4882a593Smuzhiyun 	if (IS_ERR(pwm->rst)) {
281*4882a593Smuzhiyun 		ret = PTR_ERR(pwm->rst);
282*4882a593Smuzhiyun 		dev_err(&pdev->dev, "Reset control is not found: %d\n", ret);
283*4882a593Smuzhiyun 		return ret;
284*4882a593Smuzhiyun 	}
285*4882a593Smuzhiyun 
286*4882a593Smuzhiyun 	reset_control_deassert(pwm->rst);
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun 	pwm->chip.dev = &pdev->dev;
289*4882a593Smuzhiyun 	pwm->chip.ops = &tegra_pwm_ops;
290*4882a593Smuzhiyun 	pwm->chip.base = -1;
291*4882a593Smuzhiyun 	pwm->chip.npwm = pwm->soc->num_channels;
292*4882a593Smuzhiyun 
293*4882a593Smuzhiyun 	ret = pwmchip_add(&pwm->chip);
294*4882a593Smuzhiyun 	if (ret < 0) {
295*4882a593Smuzhiyun 		dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
296*4882a593Smuzhiyun 		reset_control_assert(pwm->rst);
297*4882a593Smuzhiyun 		return ret;
298*4882a593Smuzhiyun 	}
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun 	return 0;
301*4882a593Smuzhiyun }
302*4882a593Smuzhiyun 
tegra_pwm_remove(struct platform_device * pdev)303*4882a593Smuzhiyun static int tegra_pwm_remove(struct platform_device *pdev)
304*4882a593Smuzhiyun {
305*4882a593Smuzhiyun 	struct tegra_pwm_chip *pc = platform_get_drvdata(pdev);
306*4882a593Smuzhiyun 	int err;
307*4882a593Smuzhiyun 
308*4882a593Smuzhiyun 	if (WARN_ON(!pc))
309*4882a593Smuzhiyun 		return -ENODEV;
310*4882a593Smuzhiyun 
311*4882a593Smuzhiyun 	err = clk_prepare_enable(pc->clk);
312*4882a593Smuzhiyun 	if (err < 0)
313*4882a593Smuzhiyun 		return err;
314*4882a593Smuzhiyun 
315*4882a593Smuzhiyun 	reset_control_assert(pc->rst);
316*4882a593Smuzhiyun 	clk_disable_unprepare(pc->clk);
317*4882a593Smuzhiyun 
318*4882a593Smuzhiyun 	return pwmchip_remove(&pc->chip);
319*4882a593Smuzhiyun }
320*4882a593Smuzhiyun 
321*4882a593Smuzhiyun #ifdef CONFIG_PM_SLEEP
tegra_pwm_suspend(struct device * dev)322*4882a593Smuzhiyun static int tegra_pwm_suspend(struct device *dev)
323*4882a593Smuzhiyun {
324*4882a593Smuzhiyun 	return pinctrl_pm_select_sleep_state(dev);
325*4882a593Smuzhiyun }
326*4882a593Smuzhiyun 
tegra_pwm_resume(struct device * dev)327*4882a593Smuzhiyun static int tegra_pwm_resume(struct device *dev)
328*4882a593Smuzhiyun {
329*4882a593Smuzhiyun 	return pinctrl_pm_select_default_state(dev);
330*4882a593Smuzhiyun }
331*4882a593Smuzhiyun #endif
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun static const struct tegra_pwm_soc tegra20_pwm_soc = {
334*4882a593Smuzhiyun 	.num_channels = 4,
335*4882a593Smuzhiyun 	.max_frequency = 48000000UL,
336*4882a593Smuzhiyun };
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun static const struct tegra_pwm_soc tegra186_pwm_soc = {
339*4882a593Smuzhiyun 	.num_channels = 1,
340*4882a593Smuzhiyun 	.max_frequency = 102000000UL,
341*4882a593Smuzhiyun };
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun static const struct tegra_pwm_soc tegra194_pwm_soc = {
344*4882a593Smuzhiyun 	.num_channels = 1,
345*4882a593Smuzhiyun 	.max_frequency = 408000000UL,
346*4882a593Smuzhiyun };
347*4882a593Smuzhiyun 
348*4882a593Smuzhiyun static const struct of_device_id tegra_pwm_of_match[] = {
349*4882a593Smuzhiyun 	{ .compatible = "nvidia,tegra20-pwm", .data = &tegra20_pwm_soc },
350*4882a593Smuzhiyun 	{ .compatible = "nvidia,tegra186-pwm", .data = &tegra186_pwm_soc },
351*4882a593Smuzhiyun 	{ .compatible = "nvidia,tegra194-pwm", .data = &tegra194_pwm_soc },
352*4882a593Smuzhiyun 	{ }
353*4882a593Smuzhiyun };
354*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, tegra_pwm_of_match);
355*4882a593Smuzhiyun 
356*4882a593Smuzhiyun static const struct dev_pm_ops tegra_pwm_pm_ops = {
357*4882a593Smuzhiyun 	SET_SYSTEM_SLEEP_PM_OPS(tegra_pwm_suspend, tegra_pwm_resume)
358*4882a593Smuzhiyun };
359*4882a593Smuzhiyun 
360*4882a593Smuzhiyun static struct platform_driver tegra_pwm_driver = {
361*4882a593Smuzhiyun 	.driver = {
362*4882a593Smuzhiyun 		.name = "tegra-pwm",
363*4882a593Smuzhiyun 		.of_match_table = tegra_pwm_of_match,
364*4882a593Smuzhiyun 		.pm = &tegra_pwm_pm_ops,
365*4882a593Smuzhiyun 	},
366*4882a593Smuzhiyun 	.probe = tegra_pwm_probe,
367*4882a593Smuzhiyun 	.remove = tegra_pwm_remove,
368*4882a593Smuzhiyun };
369*4882a593Smuzhiyun 
370*4882a593Smuzhiyun module_platform_driver(tegra_pwm_driver);
371*4882a593Smuzhiyun 
372*4882a593Smuzhiyun MODULE_LICENSE("GPL");
373*4882a593Smuzhiyun MODULE_AUTHOR("Sandipan Patra <spatra@nvidia.com>");
374*4882a593Smuzhiyun MODULE_DESCRIPTION("Tegra PWM controller driver");
375*4882a593Smuzhiyun MODULE_ALIAS("platform:tegra-pwm");
376