xref: /openbmc/linux/drivers/pwm/pwm-bcm-kona.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
12aec85b2SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
22aec85b2SThomas Gleixner // Copyright (C) 2014 Broadcom Corporation
36a4e4bffSTim Kryger 
46a4e4bffSTim Kryger #include <linux/clk.h>
56a4e4bffSTim Kryger #include <linux/delay.h>
66a4e4bffSTim Kryger #include <linux/err.h>
76a4e4bffSTim Kryger #include <linux/io.h>
86a4e4bffSTim Kryger #include <linux/ioport.h>
96a4e4bffSTim Kryger #include <linux/math64.h>
106a4e4bffSTim Kryger #include <linux/module.h>
116a4e4bffSTim Kryger #include <linux/of.h>
126a4e4bffSTim Kryger #include <linux/platform_device.h>
136a4e4bffSTim Kryger #include <linux/pwm.h>
146a4e4bffSTim Kryger #include <linux/slab.h>
156a4e4bffSTim Kryger #include <linux/types.h>
166a4e4bffSTim Kryger 
176a4e4bffSTim Kryger /*
186a4e4bffSTim Kryger  * The Kona PWM has some unusual characteristics.  Here are the main points.
196a4e4bffSTim Kryger  *
206a4e4bffSTim Kryger  * 1) There is no disable bit and the hardware docs advise programming a zero
216a4e4bffSTim Kryger  *    duty to achieve output equivalent to that of a normal disable operation.
226a4e4bffSTim Kryger  *
236a4e4bffSTim Kryger  * 2) Changes to prescale, duty, period, and polarity do not take effect until
246a4e4bffSTim Kryger  *    a subsequent rising edge of the trigger bit.
256a4e4bffSTim Kryger  *
266a4e4bffSTim Kryger  * 3) If the smooth bit and trigger bit are both low, the output is a constant
276a4e4bffSTim Kryger  *    high signal.  Otherwise, the earlier waveform continues to be output.
286a4e4bffSTim Kryger  *
296a4e4bffSTim Kryger  * 4) If the smooth bit is set on the rising edge of the trigger bit, output
306a4e4bffSTim Kryger  *    will transition to the new settings on a period boundary (which could be
316a4e4bffSTim Kryger  *    seconds away).  If the smooth bit is clear, new settings will be applied
326a4e4bffSTim Kryger  *    as soon as possible (the hardware always has a 400ns delay).
336a4e4bffSTim Kryger  *
346a4e4bffSTim Kryger  * 5) When the external clock that feeds the PWM is disabled, output is pegged
356a4e4bffSTim Kryger  *    high or low depending on its state at that exact instant.
366a4e4bffSTim Kryger  */
376a4e4bffSTim Kryger 
386571d13eSSheetal Tigadoli #define PWM_CONTROL_OFFSET			0x00000000
396a4e4bffSTim Kryger #define PWM_CONTROL_SMOOTH_SHIFT(chan)		(24 + (chan))
406a4e4bffSTim Kryger #define PWM_CONTROL_TYPE_SHIFT(chan)		(16 + (chan))
416a4e4bffSTim Kryger #define PWM_CONTROL_POLARITY_SHIFT(chan)	(8 + (chan))
426a4e4bffSTim Kryger #define PWM_CONTROL_TRIGGER_SHIFT(chan)		(chan)
436a4e4bffSTim Kryger 
446571d13eSSheetal Tigadoli #define PRESCALE_OFFSET				0x00000004
456a4e4bffSTim Kryger #define PRESCALE_SHIFT(chan)			((chan) << 2)
466a4e4bffSTim Kryger #define PRESCALE_MASK(chan)			(0x7 << PRESCALE_SHIFT(chan))
476571d13eSSheetal Tigadoli #define PRESCALE_MIN				0x00000000
486571d13eSSheetal Tigadoli #define PRESCALE_MAX				0x00000007
496a4e4bffSTim Kryger 
506a4e4bffSTim Kryger #define PERIOD_COUNT_OFFSET(chan)		(0x00000008 + ((chan) << 3))
516571d13eSSheetal Tigadoli #define PERIOD_COUNT_MIN			0x00000002
526571d13eSSheetal Tigadoli #define PERIOD_COUNT_MAX			0x00ffffff
536a4e4bffSTim Kryger 
546a4e4bffSTim Kryger #define DUTY_CYCLE_HIGH_OFFSET(chan)		(0x0000000c + ((chan) << 3))
556571d13eSSheetal Tigadoli #define DUTY_CYCLE_HIGH_MIN			0x00000000
566571d13eSSheetal Tigadoli #define DUTY_CYCLE_HIGH_MAX			0x00ffffff
576a4e4bffSTim Kryger 
586a4e4bffSTim Kryger struct kona_pwmc {
596a4e4bffSTim Kryger 	struct pwm_chip chip;
606a4e4bffSTim Kryger 	void __iomem *base;
616a4e4bffSTim Kryger 	struct clk *clk;
626a4e4bffSTim Kryger };
636a4e4bffSTim Kryger 
to_kona_pwmc(struct pwm_chip * chip)64*51352c09SUwe Kleine-König static inline struct kona_pwmc *to_kona_pwmc(struct pwm_chip *chip)
656a4e4bffSTim Kryger {
66*51352c09SUwe Kleine-König 	return container_of(chip, struct kona_pwmc, chip);
676a4e4bffSTim Kryger }
686a4e4bffSTim Kryger 
69fe0aea79SJonathan Richardson /*
70fe0aea79SJonathan Richardson  * Clear trigger bit but set smooth bit to maintain old output.
71fe0aea79SJonathan Richardson  */
kona_pwmc_prepare_for_settings(struct kona_pwmc * kp,unsigned int chan)72fe0aea79SJonathan Richardson static void kona_pwmc_prepare_for_settings(struct kona_pwmc *kp,
73fe0aea79SJonathan Richardson 	unsigned int chan)
746a4e4bffSTim Kryger {
756a4e4bffSTim Kryger 	unsigned int value = readl(kp->base + PWM_CONTROL_OFFSET);
766a4e4bffSTim Kryger 
776a4e4bffSTim Kryger 	value |= 1 << PWM_CONTROL_SMOOTH_SHIFT(chan);
786a4e4bffSTim Kryger 	value &= ~(1 << PWM_CONTROL_TRIGGER_SHIFT(chan));
796a4e4bffSTim Kryger 	writel(value, kp->base + PWM_CONTROL_OFFSET);
806a4e4bffSTim Kryger 
81fe0aea79SJonathan Richardson 	/*
82fe0aea79SJonathan Richardson 	 * There must be a min 400ns delay between clearing trigger and setting
83fe0aea79SJonathan Richardson 	 * it. Failing to do this may result in no PWM signal.
84fe0aea79SJonathan Richardson 	 */
85fe0aea79SJonathan Richardson 	ndelay(400);
86fe0aea79SJonathan Richardson }
87fe0aea79SJonathan Richardson 
kona_pwmc_apply_settings(struct kona_pwmc * kp,unsigned int chan)88fe0aea79SJonathan Richardson static void kona_pwmc_apply_settings(struct kona_pwmc *kp, unsigned int chan)
89fe0aea79SJonathan Richardson {
90fe0aea79SJonathan Richardson 	unsigned int value = readl(kp->base + PWM_CONTROL_OFFSET);
91fe0aea79SJonathan Richardson 
926a4e4bffSTim Kryger 	/* Set trigger bit and clear smooth bit to apply new settings */
936a4e4bffSTim Kryger 	value &= ~(1 << PWM_CONTROL_SMOOTH_SHIFT(chan));
946a4e4bffSTim Kryger 	value |= 1 << PWM_CONTROL_TRIGGER_SHIFT(chan);
956a4e4bffSTim Kryger 	writel(value, kp->base + PWM_CONTROL_OFFSET);
96fe0aea79SJonathan Richardson 
97fe0aea79SJonathan Richardson 	/* Trigger bit must be held high for at least 400 ns. */
98fe0aea79SJonathan Richardson 	ndelay(400);
996a4e4bffSTim Kryger }
1006a4e4bffSTim Kryger 
kona_pwmc_config(struct pwm_chip * chip,struct pwm_device * pwm,u64 duty_ns,u64 period_ns)1016a4e4bffSTim Kryger static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm,
1021c1283dbSUwe Kleine-König 			    u64 duty_ns, u64 period_ns)
1036a4e4bffSTim Kryger {
1046a4e4bffSTim Kryger 	struct kona_pwmc *kp = to_kona_pwmc(chip);
1051c1283dbSUwe Kleine-König 	u64 div, rate;
1066a4e4bffSTim Kryger 	unsigned long prescale = PRESCALE_MIN, pc, dc;
1076a4e4bffSTim Kryger 	unsigned int value, chan = pwm->hwpwm;
1086a4e4bffSTim Kryger 
1096a4e4bffSTim Kryger 	/*
1106a4e4bffSTim Kryger 	 * Find period count, duty count and prescale to suit duty_ns and
1116a4e4bffSTim Kryger 	 * period_ns. This is done according to formulas described below:
1126a4e4bffSTim Kryger 	 *
1136a4e4bffSTim Kryger 	 * period_ns = 10^9 * (PRESCALE + 1) * PC / PWM_CLK_RATE
1146a4e4bffSTim Kryger 	 * duty_ns = 10^9 * (PRESCALE + 1) * DC / PWM_CLK_RATE
1156a4e4bffSTim Kryger 	 *
1166a4e4bffSTim Kryger 	 * PC = (PWM_CLK_RATE * period_ns) / (10^9 * (PRESCALE + 1))
1176a4e4bffSTim Kryger 	 * DC = (PWM_CLK_RATE * duty_ns) / (10^9 * (PRESCALE + 1))
1186a4e4bffSTim Kryger 	 */
1196a4e4bffSTim Kryger 
1206a4e4bffSTim Kryger 	rate = clk_get_rate(kp->clk);
1216a4e4bffSTim Kryger 
1226a4e4bffSTim Kryger 	while (1) {
1236a4e4bffSTim Kryger 		div = 1000000000;
1246a4e4bffSTim Kryger 		div *= 1 + prescale;
1251c1283dbSUwe Kleine-König 		pc = mul_u64_u64_div_u64(rate, period_ns, div);
1261c1283dbSUwe Kleine-König 		dc = mul_u64_u64_div_u64(rate, duty_ns, div);
1276a4e4bffSTim Kryger 
1286a4e4bffSTim Kryger 		/* If duty_ns or period_ns are not achievable then return */
12975de7259SLee Jones 		if (pc < PERIOD_COUNT_MIN)
1306a4e4bffSTim Kryger 			return -EINVAL;
1316a4e4bffSTim Kryger 
1326a4e4bffSTim Kryger 		/* If pc and dc are in bounds, the calculation is done */
1336a4e4bffSTim Kryger 		if (pc <= PERIOD_COUNT_MAX && dc <= DUTY_CYCLE_HIGH_MAX)
1346a4e4bffSTim Kryger 			break;
1356a4e4bffSTim Kryger 
1366a4e4bffSTim Kryger 		/* Otherwise, increase prescale and recalculate pc and dc */
1376a4e4bffSTim Kryger 		if (++prescale > PRESCALE_MAX)
1386a4e4bffSTim Kryger 			return -EINVAL;
1396a4e4bffSTim Kryger 	}
1406a4e4bffSTim Kryger 
141fe0aea79SJonathan Richardson 	kona_pwmc_prepare_for_settings(kp, chan);
142fe0aea79SJonathan Richardson 
1436a4e4bffSTim Kryger 	value = readl(kp->base + PRESCALE_OFFSET);
1446a4e4bffSTim Kryger 	value &= ~PRESCALE_MASK(chan);
1456a4e4bffSTim Kryger 	value |= prescale << PRESCALE_SHIFT(chan);
1466a4e4bffSTim Kryger 	writel(value, kp->base + PRESCALE_OFFSET);
1476a4e4bffSTim Kryger 
1486a4e4bffSTim Kryger 	writel(pc, kp->base + PERIOD_COUNT_OFFSET(chan));
1496a4e4bffSTim Kryger 
1506a4e4bffSTim Kryger 	writel(dc, kp->base + DUTY_CYCLE_HIGH_OFFSET(chan));
1516a4e4bffSTim Kryger 
1526a4e4bffSTim Kryger 	kona_pwmc_apply_settings(kp, chan);
1536a4e4bffSTim Kryger 
1546a4e4bffSTim Kryger 	return 0;
1556a4e4bffSTim Kryger }
1566a4e4bffSTim Kryger 
kona_pwmc_set_polarity(struct pwm_chip * chip,struct pwm_device * pwm,enum pwm_polarity polarity)1576a4e4bffSTim Kryger static int kona_pwmc_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
1586a4e4bffSTim Kryger 				  enum pwm_polarity polarity)
1596a4e4bffSTim Kryger {
1606a4e4bffSTim Kryger 	struct kona_pwmc *kp = to_kona_pwmc(chip);
1616a4e4bffSTim Kryger 	unsigned int chan = pwm->hwpwm;
1626a4e4bffSTim Kryger 	unsigned int value;
1636a4e4bffSTim Kryger 	int ret;
1646a4e4bffSTim Kryger 
1656a4e4bffSTim Kryger 	ret = clk_prepare_enable(kp->clk);
1666a4e4bffSTim Kryger 	if (ret < 0) {
1676a4e4bffSTim Kryger 		dev_err(chip->dev, "failed to enable clock: %d\n", ret);
1686a4e4bffSTim Kryger 		return ret;
1696a4e4bffSTim Kryger 	}
1706a4e4bffSTim Kryger 
171fe0aea79SJonathan Richardson 	kona_pwmc_prepare_for_settings(kp, chan);
172fe0aea79SJonathan Richardson 
1736a4e4bffSTim Kryger 	value = readl(kp->base + PWM_CONTROL_OFFSET);
1746a4e4bffSTim Kryger 
1756a4e4bffSTim Kryger 	if (polarity == PWM_POLARITY_NORMAL)
1766a4e4bffSTim Kryger 		value |= 1 << PWM_CONTROL_POLARITY_SHIFT(chan);
1776a4e4bffSTim Kryger 	else
1786a4e4bffSTim Kryger 		value &= ~(1 << PWM_CONTROL_POLARITY_SHIFT(chan));
1796a4e4bffSTim Kryger 
1806a4e4bffSTim Kryger 	writel(value, kp->base + PWM_CONTROL_OFFSET);
1816a4e4bffSTim Kryger 
1826a4e4bffSTim Kryger 	kona_pwmc_apply_settings(kp, chan);
1836a4e4bffSTim Kryger 
1846a4e4bffSTim Kryger 	clk_disable_unprepare(kp->clk);
1856a4e4bffSTim Kryger 
1866a4e4bffSTim Kryger 	return 0;
1876a4e4bffSTim Kryger }
1886a4e4bffSTim Kryger 
kona_pwmc_enable(struct pwm_chip * chip,struct pwm_device * pwm)1896a4e4bffSTim Kryger static int kona_pwmc_enable(struct pwm_chip *chip, struct pwm_device *pwm)
1906a4e4bffSTim Kryger {
1916a4e4bffSTim Kryger 	struct kona_pwmc *kp = to_kona_pwmc(chip);
1926a4e4bffSTim Kryger 	int ret;
1936a4e4bffSTim Kryger 
1946a4e4bffSTim Kryger 	ret = clk_prepare_enable(kp->clk);
1956a4e4bffSTim Kryger 	if (ret < 0) {
1966a4e4bffSTim Kryger 		dev_err(chip->dev, "failed to enable clock: %d\n", ret);
1976a4e4bffSTim Kryger 		return ret;
1986a4e4bffSTim Kryger 	}
1996a4e4bffSTim Kryger 
2006a4e4bffSTim Kryger 	return 0;
2016a4e4bffSTim Kryger }
2026a4e4bffSTim Kryger 
kona_pwmc_disable(struct pwm_chip * chip,struct pwm_device * pwm)2036a4e4bffSTim Kryger static void kona_pwmc_disable(struct pwm_chip *chip, struct pwm_device *pwm)
2046a4e4bffSTim Kryger {
2056a4e4bffSTim Kryger 	struct kona_pwmc *kp = to_kona_pwmc(chip);
2066a4e4bffSTim Kryger 	unsigned int chan = pwm->hwpwm;
207fe0aea79SJonathan Richardson 	unsigned int value;
208fe0aea79SJonathan Richardson 
209fe0aea79SJonathan Richardson 	kona_pwmc_prepare_for_settings(kp, chan);
2106a4e4bffSTim Kryger 
2116a4e4bffSTim Kryger 	/* Simulate a disable by configuring for zero duty */
2126a4e4bffSTim Kryger 	writel(0, kp->base + DUTY_CYCLE_HIGH_OFFSET(chan));
213fe0aea79SJonathan Richardson 	writel(0, kp->base + PERIOD_COUNT_OFFSET(chan));
2146a4e4bffSTim Kryger 
215fe0aea79SJonathan Richardson 	/* Set prescale to 0 for this channel */
216fe0aea79SJonathan Richardson 	value = readl(kp->base + PRESCALE_OFFSET);
217fe0aea79SJonathan Richardson 	value &= ~PRESCALE_MASK(chan);
218fe0aea79SJonathan Richardson 	writel(value, kp->base + PRESCALE_OFFSET);
219fe0aea79SJonathan Richardson 
220fe0aea79SJonathan Richardson 	kona_pwmc_apply_settings(kp, chan);
2216a4e4bffSTim Kryger 
2226a4e4bffSTim Kryger 	clk_disable_unprepare(kp->clk);
2236a4e4bffSTim Kryger }
2246a4e4bffSTim Kryger 
kona_pwmc_apply(struct pwm_chip * chip,struct pwm_device * pwm,const struct pwm_state * state)2251c1283dbSUwe Kleine-König static int kona_pwmc_apply(struct pwm_chip *chip, struct pwm_device *pwm,
2261c1283dbSUwe Kleine-König 			   const struct pwm_state *state)
2271c1283dbSUwe Kleine-König {
2281c1283dbSUwe Kleine-König 	int err;
2291c1283dbSUwe Kleine-König 	struct kona_pwmc *kp = to_kona_pwmc(chip);
2301c1283dbSUwe Kleine-König 	bool enabled = pwm->state.enabled;
2311c1283dbSUwe Kleine-König 
2321c1283dbSUwe Kleine-König 	if (state->polarity != pwm->state.polarity) {
2331c1283dbSUwe Kleine-König 		if (enabled) {
2341c1283dbSUwe Kleine-König 			kona_pwmc_disable(chip, pwm);
2351c1283dbSUwe Kleine-König 			enabled = false;
2361c1283dbSUwe Kleine-König 		}
2371c1283dbSUwe Kleine-König 
2381c1283dbSUwe Kleine-König 		err = kona_pwmc_set_polarity(chip, pwm, state->polarity);
2391c1283dbSUwe Kleine-König 		if (err)
2401c1283dbSUwe Kleine-König 			return err;
2411c1283dbSUwe Kleine-König 
2421c1283dbSUwe Kleine-König 		pwm->state.polarity = state->polarity;
2431c1283dbSUwe Kleine-König 	}
2441c1283dbSUwe Kleine-König 
2451c1283dbSUwe Kleine-König 	if (!state->enabled) {
2461c1283dbSUwe Kleine-König 		if (enabled)
2471c1283dbSUwe Kleine-König 			kona_pwmc_disable(chip, pwm);
2481c1283dbSUwe Kleine-König 		return 0;
2491c1283dbSUwe Kleine-König 	} else if (!enabled) {
2501c1283dbSUwe Kleine-König 		/*
2511c1283dbSUwe Kleine-König 		 * This is a bit special here, usually the PWM should only be
2521c1283dbSUwe Kleine-König 		 * enabled when duty and period are setup. But before this
2531c1283dbSUwe Kleine-König 		 * driver was converted to .apply it was done the other way
2541c1283dbSUwe Kleine-König 		 * around and so this behaviour was kept even though this might
2551c1283dbSUwe Kleine-König 		 * result in a glitch. This might be improvable by someone with
2561c1283dbSUwe Kleine-König 		 * hardware and/or documentation.
2571c1283dbSUwe Kleine-König 		 */
2581c1283dbSUwe Kleine-König 		err = kona_pwmc_enable(chip, pwm);
2591c1283dbSUwe Kleine-König 		if (err)
2601c1283dbSUwe Kleine-König 			return err;
2611c1283dbSUwe Kleine-König 	}
2621c1283dbSUwe Kleine-König 
2631c1283dbSUwe Kleine-König 	err = kona_pwmc_config(pwm->chip, pwm, state->duty_cycle, state->period);
2641c1283dbSUwe Kleine-König 	if (err && !pwm->state.enabled)
2651c1283dbSUwe Kleine-König 		clk_disable_unprepare(kp->clk);
2661c1283dbSUwe Kleine-König 
2671c1283dbSUwe Kleine-König 	return err;
2681c1283dbSUwe Kleine-König }
2691c1283dbSUwe Kleine-König 
2706a4e4bffSTim Kryger static const struct pwm_ops kona_pwm_ops = {
2711c1283dbSUwe Kleine-König 	.apply = kona_pwmc_apply,
2726a4e4bffSTim Kryger 	.owner = THIS_MODULE,
2736a4e4bffSTim Kryger };
2746a4e4bffSTim Kryger 
kona_pwmc_probe(struct platform_device * pdev)2756a4e4bffSTim Kryger static int kona_pwmc_probe(struct platform_device *pdev)
2766a4e4bffSTim Kryger {
2776a4e4bffSTim Kryger 	struct kona_pwmc *kp;
2786a4e4bffSTim Kryger 	unsigned int chan;
2796a4e4bffSTim Kryger 	unsigned int value = 0;
2806a4e4bffSTim Kryger 	int ret = 0;
2816a4e4bffSTim Kryger 
2826a4e4bffSTim Kryger 	kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL);
2836a4e4bffSTim Kryger 	if (kp == NULL)
2846a4e4bffSTim Kryger 		return -ENOMEM;
2856a4e4bffSTim Kryger 
2866a4e4bffSTim Kryger 	kp->chip.dev = &pdev->dev;
2876a4e4bffSTim Kryger 	kp->chip.ops = &kona_pwm_ops;
2886a4e4bffSTim Kryger 	kp->chip.npwm = 6;
2896a4e4bffSTim Kryger 
290537fe687SYangtao Li 	kp->base = devm_platform_ioremap_resource(pdev, 0);
2916a4e4bffSTim Kryger 	if (IS_ERR(kp->base))
2926a4e4bffSTim Kryger 		return PTR_ERR(kp->base);
2936a4e4bffSTim Kryger 
2946a4e4bffSTim Kryger 	kp->clk = devm_clk_get(&pdev->dev, NULL);
2956a4e4bffSTim Kryger 	if (IS_ERR(kp->clk)) {
2966a4e4bffSTim Kryger 		dev_err(&pdev->dev, "failed to get clock: %ld\n",
2976a4e4bffSTim Kryger 			PTR_ERR(kp->clk));
2986a4e4bffSTim Kryger 		return PTR_ERR(kp->clk);
2996a4e4bffSTim Kryger 	}
3006a4e4bffSTim Kryger 
3016a4e4bffSTim Kryger 	ret = clk_prepare_enable(kp->clk);
3026a4e4bffSTim Kryger 	if (ret < 0) {
3036a4e4bffSTim Kryger 		dev_err(&pdev->dev, "failed to enable clock: %d\n", ret);
3046a4e4bffSTim Kryger 		return ret;
3056a4e4bffSTim Kryger 	}
3066a4e4bffSTim Kryger 
307e23db65fSArun Ramamurthy 	/* Set push/pull for all channels */
308e23db65fSArun Ramamurthy 	for (chan = 0; chan < kp->chip.npwm; chan++)
3096a4e4bffSTim Kryger 		value |= (1 << PWM_CONTROL_TYPE_SHIFT(chan));
3106a4e4bffSTim Kryger 
3116a4e4bffSTim Kryger 	writel(value, kp->base + PWM_CONTROL_OFFSET);
3126a4e4bffSTim Kryger 
3136a4e4bffSTim Kryger 	clk_disable_unprepare(kp->clk);
3146a4e4bffSTim Kryger 
315ccc2df6fSUwe Kleine-König 	ret = devm_pwmchip_add(&pdev->dev, &kp->chip);
3166a4e4bffSTim Kryger 	if (ret < 0)
3176a4e4bffSTim Kryger 		dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
3186a4e4bffSTim Kryger 
3196a4e4bffSTim Kryger 	return ret;
3206a4e4bffSTim Kryger }
3216a4e4bffSTim Kryger 
3226a4e4bffSTim Kryger static const struct of_device_id bcm_kona_pwmc_dt[] = {
3236a4e4bffSTim Kryger 	{ .compatible = "brcm,kona-pwm" },
3246a4e4bffSTim Kryger 	{ },
3256a4e4bffSTim Kryger };
3266a4e4bffSTim Kryger MODULE_DEVICE_TABLE(of, bcm_kona_pwmc_dt);
3276a4e4bffSTim Kryger 
3286a4e4bffSTim Kryger static struct platform_driver kona_pwmc_driver = {
3296a4e4bffSTim Kryger 	.driver = {
3306a4e4bffSTim Kryger 		.name = "bcm-kona-pwm",
3316a4e4bffSTim Kryger 		.of_match_table = bcm_kona_pwmc_dt,
3326a4e4bffSTim Kryger 	},
3336a4e4bffSTim Kryger 	.probe = kona_pwmc_probe,
3346a4e4bffSTim Kryger };
3356a4e4bffSTim Kryger module_platform_driver(kona_pwmc_driver);
3366a4e4bffSTim Kryger 
3376a4e4bffSTim Kryger MODULE_AUTHOR("Broadcom Corporation <bcm-kernel-feedback-list@broadcom.com>");
3386a4e4bffSTim Kryger MODULE_AUTHOR("Tim Kryger <tkryger@broadcom.com>");
3396a4e4bffSTim Kryger MODULE_DESCRIPTION("Broadcom Kona PWM driver");
3406a4e4bffSTim Kryger MODULE_LICENSE("GPL v2");
341