Lines Matching +full:clk +full:- +full:out +full:- +full:frequency
1 // SPDX-License-Identifier: GPL-2.0-or-later
11 #include <linux/clk.h>
41 * Maximum control word value allowed when variable-frequency PWM is used as a
42 * clock for the constant-frequency PMW.
56 struct clk *clk; member
63 return __raw_readl(p->base + offset); in brcmstb_pwm_readl()
65 return readl_relaxed(p->base + offset); in brcmstb_pwm_readl()
72 __raw_writel(value, p->base + offset); in brcmstb_pwm_writel()
74 writel_relaxed(value, p->base + offset); in brcmstb_pwm_writel()
83 * Fv is derived from the variable frequency output. The variable frequency
86 * W = cword, if cword < 2 ^ 15 else 16-bit 2's complement of cword
88 * Fv = W x 2 ^ -16 x 27Mhz (reference clock)
100 unsigned int channel = pwm->hwpwm; in brcmstb_pwm_config()
106 * produce a flat 100% duty cycle signal, and max out the "on" time in brcmstb_pwm_config()
110 pc = PWM_ON_PERIOD_MAX - 1; in brcmstb_pwm_config()
118 * Calculate the base rate from base frequency and current in brcmstb_pwm_config()
121 rate = (u64)clk_get_rate(p->clk) * (u64)cword; in brcmstb_pwm_config()
132 return -EINVAL; in brcmstb_pwm_config()
140 * frequency generator to output a 50% duty cycle variable in brcmstb_pwm_config()
141 * frequency which is used as input clock to the fixed in brcmstb_pwm_config()
142 * frequency generator. in brcmstb_pwm_config()
151 return -EINVAL; in brcmstb_pwm_config()
156 * Configure the defined "cword" value to have the variable frequency in brcmstb_pwm_config()
157 * generator output a base frequency for the constant frequency in brcmstb_pwm_config()
163 /* Select constant frequency signal output */ in brcmstb_pwm_config()
200 if (state->polarity != PWM_POLARITY_NORMAL) in brcmstb_pwm_apply()
201 return -EINVAL; in brcmstb_pwm_apply()
203 if (!state->enabled) { in brcmstb_pwm_apply()
204 if (pwm->state.enabled) in brcmstb_pwm_apply()
205 brcmstb_pwm_enable_set(p, pwm->hwpwm, false); in brcmstb_pwm_apply()
210 err = brcmstb_pwm_config(chip, pwm, state->duty_cycle, state->period); in brcmstb_pwm_apply()
214 if (!pwm->state.enabled) in brcmstb_pwm_apply()
215 brcmstb_pwm_enable_set(p, pwm->hwpwm, true); in brcmstb_pwm_apply()
225 { .compatible = "brcm,bcm7038-pwm", },
236 chip = devm_pwmchip_alloc(&pdev->dev, 2, sizeof(*p)); in brcmstb_pwm_probe()
241 p->clk = devm_clk_get_enabled(&pdev->dev, NULL); in brcmstb_pwm_probe()
242 if (IS_ERR(p->clk)) in brcmstb_pwm_probe()
243 return dev_err_probe(&pdev->dev, PTR_ERR(p->clk), in brcmstb_pwm_probe()
248 chip->ops = &brcmstb_pwm_ops; in brcmstb_pwm_probe()
250 p->base = devm_platform_ioremap_resource(pdev, 0); in brcmstb_pwm_probe()
251 if (IS_ERR(p->base)) in brcmstb_pwm_probe()
252 return PTR_ERR(p->base); in brcmstb_pwm_probe()
254 ret = devm_pwmchip_add(&pdev->dev, chip); in brcmstb_pwm_probe()
256 return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); in brcmstb_pwm_probe()
265 clk_disable_unprepare(p->clk); in brcmstb_pwm_suspend()
274 return clk_prepare_enable(p->clk); in brcmstb_pwm_resume()
283 .name = "pwm-brcmstb",
292 MODULE_ALIAS("platform:pwm-brcmstb");