Lines Matching full:tpm

6  * - The TPM counter and period counter are shared between
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()
188 * TPM counter is shared by multiple channels, so 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()
202 /* set TPM counter prescale */ 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
362 chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*tpm)); in pwm_imx_tpm_probe()
365 tpm = to_imx_tpm_pwm_chip(chip); in pwm_imx_tpm_probe()
367 platform_set_drvdata(pdev, tpm); in pwm_imx_tpm_probe()
369 tpm->base = base; in pwm_imx_tpm_probe()
370 tpm->clk = clk; in pwm_imx_tpm_probe()
374 mutex_init(&tpm->lock); in pwm_imx_tpm_probe()
385 struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); in pwm_imx_tpm_suspend() local
388 if (tpm->enable_count > 0) in pwm_imx_tpm_suspend()
396 tpm->real_period = 0; in pwm_imx_tpm_suspend()
398 clk_disable_unprepare(tpm->clk); in pwm_imx_tpm_suspend()
402 clk_prepare_enable(tpm->clk); in pwm_imx_tpm_suspend()
409 struct imx_tpm_pwm_chip *tpm = dev_get_drvdata(dev); in pwm_imx_tpm_resume() local
416 ret = clk_prepare_enable(tpm->clk); in pwm_imx_tpm_resume()
436 .name = "imx7ulp-tpm-pwm",
445 MODULE_DESCRIPTION("i.MX TPM PWM Driver");