Lines Matching +full:lpc3220 +full:- +full:clk

1 // SPDX-License-Identifier: GPL-2.0-only
6 #include <linux/clk.h>
18 struct clk *clk; member
37 c = clk_get_rate(lpc32xx->clk); in lpc32xx_pwm_config()
43 return -ERANGE; in lpc32xx_pwm_config()
48 duty_cycles = div64_u64((unsigned long long)(period_ns - duty_ns) * 256, in lpc32xx_pwm_config()
55 val = readl(lpc32xx->base); in lpc32xx_pwm_config()
58 writel(val, lpc32xx->base); in lpc32xx_pwm_config()
69 ret = clk_prepare_enable(lpc32xx->clk); in lpc32xx_pwm_enable()
73 val = readl(lpc32xx->base); in lpc32xx_pwm_enable()
75 writel(val, lpc32xx->base); in lpc32xx_pwm_enable()
85 val = readl(lpc32xx->base); in lpc32xx_pwm_disable()
87 writel(val, lpc32xx->base); in lpc32xx_pwm_disable()
89 clk_disable_unprepare(lpc32xx->clk); in lpc32xx_pwm_disable()
97 if (state->polarity != PWM_POLARITY_NORMAL) in lpc32xx_pwm_apply()
98 return -EINVAL; in lpc32xx_pwm_apply()
100 if (!state->enabled) { in lpc32xx_pwm_apply()
101 if (pwm->state.enabled) in lpc32xx_pwm_apply()
107 err = lpc32xx_pwm_config(chip, pwm, state->duty_cycle, state->period); in lpc32xx_pwm_apply()
111 if (!pwm->state.enabled) in lpc32xx_pwm_apply()
128 chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*lpc32xx)); in lpc32xx_pwm_probe()
133 lpc32xx->base = devm_platform_ioremap_resource(pdev, 0); in lpc32xx_pwm_probe()
134 if (IS_ERR(lpc32xx->base)) in lpc32xx_pwm_probe()
135 return PTR_ERR(lpc32xx->base); in lpc32xx_pwm_probe()
137 lpc32xx->clk = devm_clk_get(&pdev->dev, NULL); in lpc32xx_pwm_probe()
138 if (IS_ERR(lpc32xx->clk)) in lpc32xx_pwm_probe()
139 return PTR_ERR(lpc32xx->clk); in lpc32xx_pwm_probe()
141 chip->ops = &lpc32xx_pwm_ops; in lpc32xx_pwm_probe()
144 val = readl(lpc32xx->base); in lpc32xx_pwm_probe()
146 writel(val, lpc32xx->base); in lpc32xx_pwm_probe()
148 ret = devm_pwmchip_add(&pdev->dev, chip); in lpc32xx_pwm_probe()
150 dev_err(&pdev->dev, "failed to add PWM chip, error %d\n", ret); in lpc32xx_pwm_probe()
158 { .compatible = "nxp,lpc3220-pwm", },
165 .name = "lpc32xx-pwm",
172 MODULE_ALIAS("platform:lpc32xx-pwm");