Lines Matching +full:clk +full:- +full:out +full:- +full:frequency
20 #include <linux/clk.h>
50 * Maximum control word value allowed when variable-frequency PWM is used as a
51 * clock for the constant-frequency PMW.
66 struct clk *clk; member
74 return __raw_readl(p->base + offset); in brcmstb_pwm_readl()
76 return readl_relaxed(p->base + offset); in brcmstb_pwm_readl()
83 __raw_writel(value, p->base + offset); in brcmstb_pwm_writel()
85 writel_relaxed(value, p->base + offset); in brcmstb_pwm_writel()
94 * Fv is derived from the variable frequency output. The variable frequency
97 * W = cword, if cword < 2 ^ 15 else 16-bit 2's complement of cword
99 * Fv = W x 2 ^ -16 x 27Mhz (reference clock)
111 unsigned int channel = pwm->hwpwm; in brcmstb_pwm_config()
117 * produce a flat 100% duty cycle signal, and max out the "on" time in brcmstb_pwm_config()
121 pc = PWM_ON_PERIOD_MAX - 1; in brcmstb_pwm_config()
129 * Calculate the base rate from base frequency and current in brcmstb_pwm_config()
132 rate = (u64)clk_get_rate(p->clk) * (u64)cword; in brcmstb_pwm_config()
148 return -EINVAL; in brcmstb_pwm_config()
156 * frequency generator to output a 50% duty cycle variable in brcmstb_pwm_config()
157 * frequency which is used as input clock to the fixed in brcmstb_pwm_config()
158 * frequency generator. in brcmstb_pwm_config()
167 return -EINVAL; in brcmstb_pwm_config()
172 * Configure the defined "cword" value to have the variable frequency in brcmstb_pwm_config()
173 * generator output a base frequency for the constant frequency in brcmstb_pwm_config()
176 spin_lock(&p->lock); in brcmstb_pwm_config()
180 /* Select constant frequency signal output */ in brcmstb_pwm_config()
188 spin_unlock(&p->lock); in brcmstb_pwm_config()
199 spin_lock(&p->lock); in brcmstb_pwm_enable_set()
211 spin_unlock(&p->lock); in brcmstb_pwm_enable_set()
218 brcmstb_pwm_enable_set(p, pwm->hwpwm, true); in brcmstb_pwm_enable()
227 brcmstb_pwm_enable_set(p, pwm->hwpwm, false); in brcmstb_pwm_disable()
238 { .compatible = "brcm,bcm7038-pwm", },
249 p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); in brcmstb_pwm_probe()
251 return -ENOMEM; in brcmstb_pwm_probe()
253 spin_lock_init(&p->lock); in brcmstb_pwm_probe()
255 p->clk = devm_clk_get(&pdev->dev, NULL); in brcmstb_pwm_probe()
256 if (IS_ERR(p->clk)) { in brcmstb_pwm_probe()
257 dev_err(&pdev->dev, "failed to obtain clock\n"); in brcmstb_pwm_probe()
258 return PTR_ERR(p->clk); in brcmstb_pwm_probe()
261 ret = clk_prepare_enable(p->clk); in brcmstb_pwm_probe()
263 dev_err(&pdev->dev, "failed to enable clock: %d\n", ret); in brcmstb_pwm_probe()
269 p->chip.dev = &pdev->dev; in brcmstb_pwm_probe()
270 p->chip.ops = &brcmstb_pwm_ops; in brcmstb_pwm_probe()
271 p->chip.base = -1; in brcmstb_pwm_probe()
272 p->chip.npwm = 2; in brcmstb_pwm_probe()
275 p->base = devm_ioremap_resource(&pdev->dev, res); in brcmstb_pwm_probe()
276 if (IS_ERR(p->base)) { in brcmstb_pwm_probe()
277 ret = PTR_ERR(p->base); in brcmstb_pwm_probe()
281 ret = pwmchip_add(&p->chip); in brcmstb_pwm_probe()
283 dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret); in brcmstb_pwm_probe()
290 clk_disable_unprepare(p->clk); in brcmstb_pwm_probe()
299 ret = pwmchip_remove(&p->chip); in brcmstb_pwm_remove()
300 clk_disable_unprepare(p->clk); in brcmstb_pwm_remove()
310 clk_disable(p->clk); in brcmstb_pwm_suspend()
319 clk_enable(p->clk); in brcmstb_pwm_resume()
332 .name = "pwm-brcmstb",
341 MODULE_ALIAS("platform:pwm-brcmstb");