Lines Matching full:meson

3  * PWM controller driver for Amlogic Meson SoCs.
123 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_request() local
124 struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; in meson_pwm_request()
140 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_free() local
141 struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; in meson_pwm_free()
146 static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm, in meson_pwm_calc() argument
149 struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; in meson_pwm_calc()
172 dev_err(meson->chip.dev, "invalid source clock frequency\n"); in meson_pwm_calc()
176 dev_dbg(meson->chip.dev, "fin_freq: %lu Hz\n", fin_freq); in meson_pwm_calc()
180 dev_err(meson->chip.dev, "unable to get period cnt\n"); in meson_pwm_calc()
184 dev_dbg(meson->chip.dev, "period=%llu cnt=%u\n", period, cnt); in meson_pwm_calc()
195 dev_dbg(meson->chip.dev, "duty=%llu duty_cnt=%u\n", duty, duty_cnt); in meson_pwm_calc()
206 static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm) in meson_pwm_enable() argument
208 struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; in meson_pwm_enable()
218 dev_err(meson->chip.dev, "setting clock rate failed\n"); in meson_pwm_enable()
220 spin_lock_irqsave(&meson->lock, flags); in meson_pwm_enable()
224 writel(value, meson->base + channel_data->reg_offset); in meson_pwm_enable()
226 value = readl(meson->base + REG_MISC_AB); in meson_pwm_enable()
228 writel(value, meson->base + REG_MISC_AB); in meson_pwm_enable()
230 spin_unlock_irqrestore(&meson->lock, flags); in meson_pwm_enable()
233 static void meson_pwm_disable(struct meson_pwm *meson, struct pwm_device *pwm) in meson_pwm_disable() argument
238 spin_lock_irqsave(&meson->lock, flags); in meson_pwm_disable()
240 value = readl(meson->base + REG_MISC_AB); in meson_pwm_disable()
242 writel(value, meson->base + REG_MISC_AB); in meson_pwm_disable()
244 spin_unlock_irqrestore(&meson->lock, flags); in meson_pwm_disable()
250 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_apply() local
251 struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm]; in meson_pwm_apply()
272 meson_pwm_enable(meson, pwm); in meson_pwm_apply()
274 meson_pwm_disable(meson, pwm); in meson_pwm_apply()
277 err = meson_pwm_calc(meson, pwm, state); in meson_pwm_apply()
281 meson_pwm_enable(meson, pwm); in meson_pwm_apply()
290 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_cnt_to_ns() local
295 channel = &meson->channels[pwm->hwpwm]; in meson_pwm_cnt_to_ns()
307 struct meson_pwm *meson = to_meson_pwm(chip); in meson_pwm_get_state() local
315 channel = &meson->channels[pwm->hwpwm]; in meson_pwm_get_state()
318 value = readl(meson->base + REG_MISC_AB); in meson_pwm_get_state()
321 value = readl(meson->base + channel_data->reg_offset); in meson_pwm_get_state()
404 .compatible = "amlogic,meson-gxbb-pwm",
408 .compatible = "amlogic,meson-gxbb-ao-pwm",
412 .compatible = "amlogic,meson-axg-ee-pwm",
416 .compatible = "amlogic,meson-axg-ao-pwm",
420 .compatible = "amlogic,meson-g12a-ee-pwm",
424 .compatible = "amlogic,meson-g12a-ao-pwm-ab",
428 .compatible = "amlogic,meson-g12a-ao-pwm-cd",
435 static int meson_pwm_init_channels(struct meson_pwm *meson) in meson_pwm_init_channels() argument
438 struct device *dev = meson->chip.dev; in meson_pwm_init_channels()
443 for (i = 0; i < meson->data->num_parents; i++) { in meson_pwm_init_channels()
445 mux_parent_data[i].name = meson->data->parent_names[i]; in meson_pwm_init_channels()
448 for (i = 0; i < meson->chip.npwm; i++) { in meson_pwm_init_channels()
449 struct meson_pwm_channel *channel = &meson->channels[i]; in meson_pwm_init_channels()
459 init.num_parents = meson->data->num_parents; in meson_pwm_init_channels()
461 channel->mux.reg = meson->base + REG_MISC_AB; in meson_pwm_init_channels()
466 channel->mux.lock = &meson->lock; in meson_pwm_init_channels()
485 channel->div.reg = meson->base + REG_MISC_AB; in meson_pwm_init_channels()
490 channel->div.lock = &meson->lock; in meson_pwm_init_channels()
507 channel->gate.reg = meson->base + REG_MISC_AB; in meson_pwm_init_channels()
511 channel->gate.lock = &meson->lock; in meson_pwm_init_channels()
528 struct meson_pwm *meson; in meson_pwm_probe() local
531 meson = devm_kzalloc(&pdev->dev, sizeof(*meson), GFP_KERNEL); in meson_pwm_probe()
532 if (!meson) in meson_pwm_probe()
535 meson->base = devm_platform_ioremap_resource(pdev, 0); in meson_pwm_probe()
536 if (IS_ERR(meson->base)) in meson_pwm_probe()
537 return PTR_ERR(meson->base); in meson_pwm_probe()
539 spin_lock_init(&meson->lock); in meson_pwm_probe()
540 meson->chip.dev = &pdev->dev; in meson_pwm_probe()
541 meson->chip.ops = &meson_pwm_ops; in meson_pwm_probe()
542 meson->chip.npwm = MESON_NUM_PWMS; in meson_pwm_probe()
544 meson->data = of_device_get_match_data(&pdev->dev); in meson_pwm_probe()
546 err = meson_pwm_init_channels(meson); in meson_pwm_probe()
550 err = devm_pwmchip_add(&pdev->dev, &meson->chip); in meson_pwm_probe()
560 .name = "meson-pwm",
567 MODULE_DESCRIPTION("Amlogic Meson PWM Generator driver");