Lines Matching refs:vt8500

59 static inline void vt8500_pwm_busy_wait(struct vt8500_chip *vt8500, int nr, u8 bitmask)  in vt8500_pwm_busy_wait()  argument
64 while ((readl(vt8500->base + REG_STATUS) & mask) && --loops) in vt8500_pwm_busy_wait()
68 dev_warn(vt8500->chip.dev, "Waiting for status bits 0x%x to clear timed out\n", in vt8500_pwm_busy_wait()
75 struct vt8500_chip *vt8500 = to_vt8500_chip(chip); in vt8500_pwm_config() local
81 err = clk_enable(vt8500->clk); in vt8500_pwm_config()
87 c = clk_get_rate(vt8500->clk); in vt8500_pwm_config()
100 clk_disable(vt8500->clk); in vt8500_pwm_config()
108 writel(prescale, vt8500->base + REG_SCALAR(pwm->hwpwm)); in vt8500_pwm_config()
109 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_SCALAR_UPDATE); in vt8500_pwm_config()
111 writel(pv, vt8500->base + REG_PERIOD(pwm->hwpwm)); in vt8500_pwm_config()
112 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_PERIOD_UPDATE); in vt8500_pwm_config()
114 writel(dc, vt8500->base + REG_DUTY(pwm->hwpwm)); in vt8500_pwm_config()
115 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_DUTY_UPDATE); in vt8500_pwm_config()
117 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_config()
119 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_config()
120 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_config()
122 clk_disable(vt8500->clk); in vt8500_pwm_config()
128 struct vt8500_chip *vt8500 = to_vt8500_chip(chip); in vt8500_pwm_enable() local
132 err = clk_enable(vt8500->clk); in vt8500_pwm_enable()
138 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_enable()
140 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_enable()
141 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_enable()
148 struct vt8500_chip *vt8500 = to_vt8500_chip(chip); in vt8500_pwm_disable() local
151 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_disable()
153 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_disable()
154 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_disable()
156 clk_disable(vt8500->clk); in vt8500_pwm_disable()
163 struct vt8500_chip *vt8500 = to_vt8500_chip(chip); in vt8500_pwm_set_polarity() local
166 val = readl(vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_set_polarity()
173 writel(val, vt8500->base + REG_CTRL(pwm->hwpwm)); in vt8500_pwm_set_polarity()
174 vt8500_pwm_busy_wait(vt8500, pwm->hwpwm, STATUS_CTRL_UPDATE); in vt8500_pwm_set_polarity()
238 struct vt8500_chip *vt8500; in vt8500_pwm_probe() local
247 vt8500 = devm_kzalloc(&pdev->dev, sizeof(*vt8500), GFP_KERNEL); in vt8500_pwm_probe()
248 if (vt8500 == NULL) in vt8500_pwm_probe()
251 vt8500->chip.dev = &pdev->dev; in vt8500_pwm_probe()
252 vt8500->chip.ops = &vt8500_pwm_ops; in vt8500_pwm_probe()
253 vt8500->chip.npwm = VT8500_NR_PWMS; in vt8500_pwm_probe()
255 vt8500->clk = devm_clk_get(&pdev->dev, NULL); in vt8500_pwm_probe()
256 if (IS_ERR(vt8500->clk)) { in vt8500_pwm_probe()
258 return PTR_ERR(vt8500->clk); in vt8500_pwm_probe()
261 vt8500->base = devm_platform_ioremap_resource(pdev, 0); in vt8500_pwm_probe()
262 if (IS_ERR(vt8500->base)) in vt8500_pwm_probe()
263 return PTR_ERR(vt8500->base); in vt8500_pwm_probe()
265 ret = clk_prepare(vt8500->clk); in vt8500_pwm_probe()
271 ret = pwmchip_add(&vt8500->chip); in vt8500_pwm_probe()
274 clk_unprepare(vt8500->clk); in vt8500_pwm_probe()
278 platform_set_drvdata(pdev, vt8500); in vt8500_pwm_probe()
284 struct vt8500_chip *vt8500 = platform_get_drvdata(pdev); in vt8500_pwm_remove() local
286 pwmchip_remove(&vt8500->chip); in vt8500_pwm_remove()
288 clk_unprepare(vt8500->clk); in vt8500_pwm_remove()