Lines Matching full:meson
3 * PWM controller driver for Amlogic Meson SoCs.
122 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_request() local
131 channel = &meson->channels[pwm->hwpwm]; in meson_pwm_request()
161 static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, in meson_pwm_calc() argument
176 dev_err(meson->chip.dev, "invalid source clock frequency\n"); in meson_pwm_calc()
180 dev_dbg(meson->chip.dev, "fin_freq: %lu Hz\n", fin_freq); in meson_pwm_calc()
184 dev_err(meson->chip.dev, "unable to get period pre_div\n"); in meson_pwm_calc()
190 dev_err(meson->chip.dev, "unable to get period cnt\n"); in meson_pwm_calc()
194 dev_dbg(meson->chip.dev, "period=%u pre_div=%u cnt=%u\n", period, in meson_pwm_calc()
210 dev_err(meson->chip.dev, "unable to get duty cycle\n"); in meson_pwm_calc()
214 dev_dbg(meson->chip.dev, "duty=%u pre_div=%u duty_cnt=%u\n", in meson_pwm_calc()
225 static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm) in meson_pwm_enable() argument
234 spin_lock_irqsave(&meson->lock, flags); in meson_pwm_enable()
236 value = readl(meson->base + REG_MISC_AB); in meson_pwm_enable()
240 writel(value, meson->base + REG_MISC_AB); in meson_pwm_enable()
244 writel(value, meson->base + channel_data->reg_offset); in meson_pwm_enable()
246 value = readl(meson->base + REG_MISC_AB); in meson_pwm_enable()
248 writel(value, meson->base + REG_MISC_AB); in meson_pwm_enable()
250 spin_unlock_irqrestore(&meson->lock, flags); in meson_pwm_enable()
253 static void meson_pwm_disable(struct meson_pwm *meson, struct pwm_device *pwm) in meson_pwm_disable() argument
258 spin_lock_irqsave(&meson->lock, flags); in meson_pwm_disable()
260 value = readl(meson->base + REG_MISC_AB); in meson_pwm_disable()
262 writel(value, meson->base + REG_MISC_AB); in meson_pwm_disable()
264 spin_unlock_irqrestore(&meson->lock, flags); in meson_pwm_disable()
271 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_apply() local
295 meson_pwm_enable(meson, pwm); in meson_pwm_apply()
297 meson_pwm_disable(meson, pwm); in meson_pwm_apply()
300 err = meson_pwm_calc(meson, pwm, state); in meson_pwm_apply()
304 meson_pwm_enable(meson, pwm); in meson_pwm_apply()
313 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_cnt_to_ns() local
319 channel = &meson->channels[pwm->hwpwm]; in meson_pwm_cnt_to_ns()
333 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_get_state() local
341 channel = &meson->channels[pwm->hwpwm]; in meson_pwm_get_state()
344 value = readl(meson->base + REG_MISC_AB); in meson_pwm_get_state()
352 value = readl(meson->base + channel_data->reg_offset); in meson_pwm_get_state()
461 .compatible = "amlogic,meson-gxbb-pwm",
465 .compatible = "amlogic,meson-gxbb-ao-pwm",
469 .compatible = "amlogic,meson-axg-ee-pwm",
473 .compatible = "amlogic,meson-axg-ao-pwm",
477 .compatible = "amlogic,meson-g12a-ee-pwm",
481 .compatible = "amlogic,meson-g12a-ao-pwm-ab",
485 .compatible = "amlogic,meson-g12a-ao-pwm-cd",
492 static int meson_pwm_init_channels(struct meson_pwm *meson) in meson_pwm_init_channels() argument
494 struct device *dev = meson->chip.dev; in meson_pwm_init_channels()
500 for (i = 0; i < meson->chip.npwm; i++) { in meson_pwm_init_channels()
501 struct meson_pwm_channel *channel = &meson->channels[i]; in meson_pwm_init_channels()
508 init.parent_names = meson->data->parent_names; in meson_pwm_init_channels()
509 init.num_parents = meson->data->num_parents; in meson_pwm_init_channels()
511 channel->mux.reg = meson->base + REG_MISC_AB; in meson_pwm_init_channels()
516 channel->mux.lock = &meson->lock; in meson_pwm_init_channels()
539 struct meson_pwm *meson; in meson_pwm_probe() local
543 meson = devm_kzalloc(&pdev->dev, sizeof(*meson), GFP_KERNEL); in meson_pwm_probe()
544 if (!meson) in meson_pwm_probe()
548 meson->base = devm_ioremap_resource(&pdev->dev, regs); in meson_pwm_probe()
549 if (IS_ERR(meson->base)) in meson_pwm_probe()
550 return PTR_ERR(meson->base); in meson_pwm_probe()
552 spin_lock_init(&meson->lock); in meson_pwm_probe()
553 meson->chip.dev = &pdev->dev; in meson_pwm_probe()
554 meson->chip.ops = &meson_pwm_ops; in meson_pwm_probe()
555 meson->chip.base = -1; in meson_pwm_probe()
556 meson->chip.npwm = MESON_NUM_PWMS; in meson_pwm_probe()
557 meson->chip.of_xlate = of_pwm_xlate_with_flags; in meson_pwm_probe()
558 meson->chip.of_pwm_n_cells = 3; in meson_pwm_probe()
560 meson->data = of_device_get_match_data(&pdev->dev); in meson_pwm_probe()
562 err = meson_pwm_init_channels(meson); in meson_pwm_probe()
566 err = pwmchip_add(&meson->chip); in meson_pwm_probe()
572 platform_set_drvdata(pdev, meson); in meson_pwm_probe()
579 struct meson_pwm *meson = platform_get_drvdata(pdev); in meson_pwm_remove() local
581 return pwmchip_remove(&meson->chip); in meson_pwm_remove()
586 .name = "meson-pwm",
594 MODULE_DESCRIPTION("Amlogic Meson PWM Generator driver");