Lines Matching refs:tpm

92 	struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip);  in pwm_imx_tpm_round_state()  local
96 rate = clk_get_rate(tpm->clk); in pwm_imx_tpm_round_state()
139 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_get_state() local
144 state->period = tpm->real_period; in pwm_imx_tpm_get_state()
147 rate = clk_get_rate(tpm->clk); in pwm_imx_tpm_get_state()
148 val = readl(tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_get_state()
150 tmp = readl(tpm->base + PWM_IMX_TPM_CnV(pwm->hwpwm)); in pwm_imx_tpm_get_state()
155 val = readl(tpm->base + PWM_IMX_TPM_CnSC(pwm->hwpwm)); in pwm_imx_tpm_get_state()
175 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_apply_hw() local
182 if (state->period != tpm->real_period) { in pwm_imx_tpm_apply_hw()
189 if (tpm->user_count > 1) in pwm_imx_tpm_apply_hw()
192 val = readl(tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
201 writel(val, tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
211 writel(p->mod, tpm->base + PWM_IMX_TPM_MOD); in pwm_imx_tpm_apply_hw()
212 tpm->real_period = state->period; in pwm_imx_tpm_apply_hw()
231 writel(p->val, tpm->base + PWM_IMX_TPM_CnV(pwm->hwpwm)); in pwm_imx_tpm_apply_hw()
237 timeout = jiffies + msecs_to_jiffies(tpm->real_period / in pwm_imx_tpm_apply_hw()
239 while (readl(tpm->base + PWM_IMX_TPM_MOD) != p->mod in pwm_imx_tpm_apply_hw()
240 || readl(tpm->base + PWM_IMX_TPM_CnV(pwm->hwpwm)) in pwm_imx_tpm_apply_hw()
254 val = readl(tpm->base + PWM_IMX_TPM_CnSC(pwm->hwpwm)); in pwm_imx_tpm_apply_hw()
270 writel(val, tpm->base + PWM_IMX_TPM_CnSC(pwm->hwpwm)); in pwm_imx_tpm_apply_hw()
274 val = readl(tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
276 if (++tpm->enable_count == 1) in pwm_imx_tpm_apply_hw()
279 if (--tpm->enable_count == 0) in pwm_imx_tpm_apply_hw()
282 writel(val, tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
292 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_apply() local
301 mutex_lock(&tpm->lock); in pwm_imx_tpm_apply()
303 mutex_unlock(&tpm->lock); in pwm_imx_tpm_apply()
310 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_request() local
312 mutex_lock(&tpm->lock); in pwm_imx_tpm_request()
313 tpm->user_count++; in pwm_imx_tpm_request()
314 mutex_unlock(&tpm->lock); in pwm_imx_tpm_request()
321 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_free() local
323 mutex_lock(&tpm->lock); in pwm_imx_tpm_free()
324 tpm->user_count--; in pwm_imx_tpm_free()
325 mutex_unlock(&tpm->lock); in pwm_imx_tpm_free()
338 struct imx_tpm_pwm_chip *tpm; in pwm_imx_tpm_probe() local
342 tpm = devm_kzalloc(&pdev->dev, sizeof(*tpm), GFP_KERNEL); in pwm_imx_tpm_probe()
343 if (!tpm) in pwm_imx_tpm_probe()
346 platform_set_drvdata(pdev, tpm); in pwm_imx_tpm_probe()
348 tpm->base = devm_platform_ioremap_resource(pdev, 0); in pwm_imx_tpm_probe()
349 if (IS_ERR(tpm->base)) in pwm_imx_tpm_probe()
350 return PTR_ERR(tpm->base); in pwm_imx_tpm_probe()
352 tpm->clk = devm_clk_get(&pdev->dev, NULL); in pwm_imx_tpm_probe()
353 if (IS_ERR(tpm->clk)) in pwm_imx_tpm_probe()
354 return dev_err_probe(&pdev->dev, PTR_ERR(tpm->clk), in pwm_imx_tpm_probe()
357 ret = clk_prepare_enable(tpm->clk); in pwm_imx_tpm_probe()
364 tpm->chip.dev = &pdev->dev; in pwm_imx_tpm_probe()
365 tpm->chip.ops = &imx_tpm_pwm_ops; in pwm_imx_tpm_probe()
368 val = readl(tpm->base + PWM_IMX_TPM_PARAM); in pwm_imx_tpm_probe()
369 tpm->chip.npwm = FIELD_GET(PWM_IMX_TPM_PARAM_CHAN, val); in pwm_imx_tpm_probe()
371 mutex_init(&tpm->lock); in pwm_imx_tpm_probe()
373 ret = pwmchip_add(&tpm->chip); in pwm_imx_tpm_probe()
376 clk_disable_unprepare(tpm->clk); in pwm_imx_tpm_probe()
384 struct imx_tpm_pwm_chip *tpm = platform_get_drvdata(pdev); in pwm_imx_tpm_remove() local
386 pwmchip_remove(&tpm->chip); in pwm_imx_tpm_remove()
388 clk_disable_unprepare(tpm->clk); in pwm_imx_tpm_remove()
395 struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); in pwm_imx_tpm_suspend() local
397 if (tpm->enable_count > 0) in pwm_imx_tpm_suspend()
400 clk_disable_unprepare(tpm->clk); in pwm_imx_tpm_suspend()
407 struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); in pwm_imx_tpm_resume() local
410 ret = clk_prepare_enable(tpm->clk); in pwm_imx_tpm_resume()