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()
405 .compatible = "amlogic,meson-gxbb-pwm",
409 .compatible = "amlogic,meson-gxbb-ao-pwm",
413 .compatible = "amlogic,meson-axg-ee-pwm",
417 .compatible = "amlogic,meson-axg-ao-pwm",
421 .compatible = "amlogic,meson-g12a-ee-pwm",
425 .compatible = "amlogic,meson-g12a-ao-pwm-ab",
429 .compatible = "amlogic,meson-g12a-ao-pwm-cd",
436 static int meson_pwm_init_channels(struct meson_pwm *meson) in meson_pwm_init_channels() argument
439 struct device *dev = meson->chip.dev; in meson_pwm_init_channels()
444 for (i = 0; i < meson->data->num_parents; i++) { in meson_pwm_init_channels()
446 mux_parent_data[i].name = meson->data->parent_names[i]; in meson_pwm_init_channels()
449 for (i = 0; i < meson->chip.npwm; i++) { in meson_pwm_init_channels()
450 struct meson_pwm_channel *channel = &meson->channels[i]; in meson_pwm_init_channels()
460 init.num_parents = meson->data->num_parents; in meson_pwm_init_channels()
462 channel->mux.reg = meson->base + REG_MISC_AB; in meson_pwm_init_channels()
467 channel->mux.lock = &meson->lock; in meson_pwm_init_channels()
487 channel->div.reg = meson->base + REG_MISC_AB; in meson_pwm_init_channels()
492 channel->div.lock = &meson->lock; in meson_pwm_init_channels()
510 channel->gate.reg = meson->base + REG_MISC_AB; in meson_pwm_init_channels()
514 channel->gate.lock = &meson->lock; in meson_pwm_init_channels()
535 struct meson_pwm *meson; in meson_pwm_probe() local
538 meson = devm_kzalloc(&pdev->dev, sizeof(*meson), GFP_KERNEL); in meson_pwm_probe()
539 if (!meson) in meson_pwm_probe()
542 meson->base = devm_platform_ioremap_resource(pdev, 0); in meson_pwm_probe()
543 if (IS_ERR(meson->base)) in meson_pwm_probe()
544 return PTR_ERR(meson->base); in meson_pwm_probe()
546 spin_lock_init(&meson->lock); in meson_pwm_probe()
547 meson->chip.dev = &pdev->dev; in meson_pwm_probe()
548 meson->chip.ops = &meson_pwm_ops; in meson_pwm_probe()
549 meson->chip.npwm = MESON_NUM_PWMS; in meson_pwm_probe()
551 meson->data = of_device_get_match_data(&pdev->dev); in meson_pwm_probe()
553 err = meson_pwm_init_channels(meson); in meson_pwm_probe()
557 err = devm_pwmchip_add(&pdev->dev, &meson->chip); in meson_pwm_probe()
568 .name = "meson-pwm",
575 MODULE_DESCRIPTION("Amlogic Meson PWM Generator driver");