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()
141 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_get_state() local
146 state->period = tpm->real_period; in pwm_imx_tpm_get_state()
149 rate = clk_get_rate(tpm->clk); in pwm_imx_tpm_get_state()
150 val = readl(tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_get_state()
152 tmp = readl(tpm->base + PWM_IMX_TPM_CnV(pwm->hwpwm)); in pwm_imx_tpm_get_state()
157 val = readl(tpm->base + PWM_IMX_TPM_CnSC(pwm->hwpwm)); in pwm_imx_tpm_get_state()
179 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_apply_hw() local
186 if (state->period != tpm->real_period) { in pwm_imx_tpm_apply_hw()
193 if (tpm->user_count > 1) in pwm_imx_tpm_apply_hw()
196 val = readl(tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
205 writel(val, tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
215 writel(p->mod, tpm->base + PWM_IMX_TPM_MOD); in pwm_imx_tpm_apply_hw()
216 tpm->real_period = state->period; in pwm_imx_tpm_apply_hw()
235 writel(p->val, tpm->base + PWM_IMX_TPM_CnV(pwm->hwpwm)); in pwm_imx_tpm_apply_hw()
241 timeout = jiffies + msecs_to_jiffies(tpm->real_period / in pwm_imx_tpm_apply_hw()
243 while (readl(tpm->base + PWM_IMX_TPM_MOD) != p->mod in pwm_imx_tpm_apply_hw()
244 || readl(tpm->base + PWM_IMX_TPM_CnV(pwm->hwpwm)) in pwm_imx_tpm_apply_hw()
258 val = readl(tpm->base + PWM_IMX_TPM_CnSC(pwm->hwpwm)); in pwm_imx_tpm_apply_hw()
274 writel(val, tpm->base + PWM_IMX_TPM_CnSC(pwm->hwpwm)); in pwm_imx_tpm_apply_hw()
278 val = readl(tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
280 if (++tpm->enable_count == 1) in pwm_imx_tpm_apply_hw()
283 if (--tpm->enable_count == 0) in pwm_imx_tpm_apply_hw()
286 writel(val, tpm->base + PWM_IMX_TPM_SC); in pwm_imx_tpm_apply_hw()
296 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_apply() local
305 mutex_lock(&tpm->lock); in pwm_imx_tpm_apply()
307 mutex_unlock(&tpm->lock); in pwm_imx_tpm_apply()
314 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_request() local
316 mutex_lock(&tpm->lock); in pwm_imx_tpm_request()
317 tpm->user_count++; in pwm_imx_tpm_request()
318 mutex_unlock(&tpm->lock); in pwm_imx_tpm_request()
325 struct imx_tpm_pwm_chip *tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_free() local
327 mutex_lock(&tpm->lock); in pwm_imx_tpm_free()
328 tpm->user_count--; in pwm_imx_tpm_free()
329 mutex_unlock(&tpm->lock); in pwm_imx_tpm_free()
342 struct imx_tpm_pwm_chip *tpm; in pwm_imx_tpm_probe() local
346 tpm = devm_kzalloc(&pdev->dev, sizeof(*tpm), GFP_KERNEL); in pwm_imx_tpm_probe()
347 if (!tpm) in pwm_imx_tpm_probe()
350 platform_set_drvdata(pdev, tpm); in pwm_imx_tpm_probe()
352 tpm->base = devm_platform_ioremap_resource(pdev, 0); in pwm_imx_tpm_probe()
353 if (IS_ERR(tpm->base)) in pwm_imx_tpm_probe()
354 return PTR_ERR(tpm->base); in pwm_imx_tpm_probe()
356 tpm->clk = devm_clk_get(&pdev->dev, NULL); in pwm_imx_tpm_probe()
357 if (IS_ERR(tpm->clk)) in pwm_imx_tpm_probe()
358 return dev_err_probe(&pdev->dev, PTR_ERR(tpm->clk), in pwm_imx_tpm_probe()
361 ret = clk_prepare_enable(tpm->clk); in pwm_imx_tpm_probe()
368 tpm->chip.dev = &pdev->dev; in pwm_imx_tpm_probe()
369 tpm->chip.ops = &imx_tpm_pwm_ops; in pwm_imx_tpm_probe()
372 val = readl(tpm->base + PWM_IMX_TPM_PARAM); in pwm_imx_tpm_probe()
373 tpm->chip.npwm = FIELD_GET(PWM_IMX_TPM_PARAM_CHAN, val); in pwm_imx_tpm_probe()
375 mutex_init(&tpm->lock); in pwm_imx_tpm_probe()
377 ret = pwmchip_add(&tpm->chip); in pwm_imx_tpm_probe()
380 clk_disable_unprepare(tpm->clk); in pwm_imx_tpm_probe()
388 struct imx_tpm_pwm_chip *tpm = platform_get_drvdata(pdev); in pwm_imx_tpm_remove() local
390 pwmchip_remove(&tpm->chip); in pwm_imx_tpm_remove()
392 clk_disable_unprepare(tpm->clk); in pwm_imx_tpm_remove()
397 struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); in pwm_imx_tpm_suspend() local
399 if (tpm->enable_count > 0) in pwm_imx_tpm_suspend()
407 tpm->real_period = 0; in pwm_imx_tpm_suspend()
409 clk_disable_unprepare(tpm->clk); in pwm_imx_tpm_suspend()
416 struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); in pwm_imx_tpm_resume() local
419 ret = clk_prepare_enable(tpm->clk); in pwm_imx_tpm_resume()