Lines Matching full:imx
98 static int pwm_imx27_clk_prepare_enable(struct pwm_imx27_chip *imx) in pwm_imx27_clk_prepare_enable() argument
102 ret = clk_prepare_enable(imx->clk_ipg); in pwm_imx27_clk_prepare_enable()
106 ret = clk_prepare_enable(imx->clk_per); in pwm_imx27_clk_prepare_enable()
108 clk_disable_unprepare(imx->clk_ipg); in pwm_imx27_clk_prepare_enable()
115 static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx) in pwm_imx27_clk_disable_unprepare() argument
117 clk_disable_unprepare(imx->clk_per); in pwm_imx27_clk_disable_unprepare()
118 clk_disable_unprepare(imx->clk_ipg); in pwm_imx27_clk_disable_unprepare()
124 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); in pwm_imx27_get_state() local
129 ret = pwm_imx27_clk_prepare_enable(imx); in pwm_imx27_get_state()
133 val = readl(imx->mmio_base + MX3_PWMCR); in pwm_imx27_get_state()
152 pwm_clk = clk_get_rate(imx->clk_per); in pwm_imx27_get_state()
153 val = readl(imx->mmio_base + MX3_PWMPR); in pwm_imx27_get_state()
165 val = readl(imx->mmio_base + MX3_PWMSAR); in pwm_imx27_get_state()
167 val = imx->duty_cycle; in pwm_imx27_get_state()
172 pwm_imx27_clk_disable_unprepare(imx); in pwm_imx27_get_state()
177 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); in pwm_imx27_sw_reset() local
182 writel(MX3_PWMCR_SWR, imx->mmio_base + MX3_PWMCR); in pwm_imx27_sw_reset()
185 cr = readl(imx->mmio_base + MX3_PWMCR); in pwm_imx27_sw_reset()
196 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); in pwm_imx27_wait_fifo_slot() local
202 sr = readl(imx->mmio_base + MX3_PWMSR); in pwm_imx27_wait_fifo_slot()
209 sr = readl(imx->mmio_base + MX3_PWMSR); in pwm_imx27_wait_fifo_slot()
219 struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); in pwm_imx27_apply() local
228 clkrate = clk_get_rate(imx->clk_per); in pwm_imx27_apply()
242 * according to imx pwm RM, the real period value should be PERIOD in pwm_imx27_apply()
257 ret = pwm_imx27_clk_prepare_enable(imx); in pwm_imx27_apply()
264 writel(duty_cycles, imx->mmio_base + MX3_PWMSAR); in pwm_imx27_apply()
265 writel(period_cycles, imx->mmio_base + MX3_PWMPR); in pwm_imx27_apply()
271 imx->duty_cycle = duty_cycles; in pwm_imx27_apply()
285 writel(cr, imx->mmio_base + MX3_PWMCR); in pwm_imx27_apply()
288 pwm_imx27_clk_disable_unprepare(imx); in pwm_imx27_apply()
307 struct pwm_imx27_chip *imx; in pwm_imx27_probe() local
311 imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL); in pwm_imx27_probe()
312 if (imx == NULL) in pwm_imx27_probe()
315 platform_set_drvdata(pdev, imx); in pwm_imx27_probe()
317 imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); in pwm_imx27_probe()
318 if (IS_ERR(imx->clk_ipg)) { in pwm_imx27_probe()
319 int ret = PTR_ERR(imx->clk_ipg); in pwm_imx27_probe()
328 imx->clk_per = devm_clk_get(&pdev->dev, "per"); in pwm_imx27_probe()
329 if (IS_ERR(imx->clk_per)) { in pwm_imx27_probe()
330 int ret = PTR_ERR(imx->clk_per); in pwm_imx27_probe()
340 imx->chip.ops = &pwm_imx27_ops; in pwm_imx27_probe()
341 imx->chip.dev = &pdev->dev; in pwm_imx27_probe()
342 imx->chip.base = -1; in pwm_imx27_probe()
343 imx->chip.npwm = 1; in pwm_imx27_probe()
345 imx->chip.of_xlate = of_pwm_xlate_with_flags; in pwm_imx27_probe()
346 imx->chip.of_pwm_n_cells = 3; in pwm_imx27_probe()
348 imx->mmio_base = devm_platform_ioremap_resource(pdev, 0); in pwm_imx27_probe()
349 if (IS_ERR(imx->mmio_base)) in pwm_imx27_probe()
350 return PTR_ERR(imx->mmio_base); in pwm_imx27_probe()
352 ret = pwm_imx27_clk_prepare_enable(imx); in pwm_imx27_probe()
357 pwmcr = readl(imx->mmio_base + MX3_PWMCR); in pwm_imx27_probe()
359 pwm_imx27_clk_disable_unprepare(imx); in pwm_imx27_probe()
361 return pwmchip_add(&imx->chip); in pwm_imx27_probe()
366 struct pwm_imx27_chip *imx; in pwm_imx27_remove() local
368 imx = platform_get_drvdata(pdev); in pwm_imx27_remove()
370 return pwmchip_remove(&imx->chip); in pwm_imx27_remove()