Lines Matching +full:am3352 +full:- +full:eqep

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Counter driver for Texas Instruments Enhanced Quadrature Encoder Pulse (eQEP)
20 /* 32-bit registers */
31 /* 16-bit registers */
119 /* EQEP Inputs */
144 regmap_read(priv->regmap32, QPOSCNT, &cnt); in ti_eqep_count_read()
156 regmap_read(priv->regmap32, QPOSMAX, &max); in ti_eqep_count_write()
158 return -EINVAL; in ti_eqep_count_write()
160 return regmap_write(priv->regmap32, QPOSCNT, val); in ti_eqep_count_write()
170 regmap_read(priv->regmap16, QDECCTL, &qdecctl); in ti_eqep_function_read()
212 return -EINVAL; in ti_eqep_function_write()
215 return regmap_write_bits(priv->regmap16, QDECCTL, QDECCTL_QSRC, in ti_eqep_function_write()
241 /* In direction-count mode only rising edge of QEPA is counted in ti_eqep_action_read()
244 switch (synapse->signal->id) { in ti_eqep_action_read()
253 return -EINVAL; in ti_eqep_action_read()
257 /* In up/down-count modes only QEPA is counted and QEPB is not in ti_eqep_action_read()
260 switch (synapse->signal->id) { in ti_eqep_action_read()
262 err = regmap_read(priv->regmap16, QDECCTL, &qdecctl); in ti_eqep_action_read()
276 return -EINVAL; in ti_eqep_action_read()
280 return -EINVAL; in ti_eqep_action_read()
290 list_for_each_entry(event_node, &counter->events_list, l) { in ti_eqep_events_configure()
291 switch (event_node->event) { in ti_eqep_events_configure()
304 return regmap_write(priv->regmap16, QEINT, qeint); in ti_eqep_events_configure()
310 switch (watch->event) { in ti_eqep_watch_validate()
314 if (watch->channel != 0) in ti_eqep_watch_validate()
315 return -EINVAL; in ti_eqep_watch_validate()
319 return -EINVAL; in ti_eqep_watch_validate()
340 regmap_read(priv->regmap32, QPOSMAX, &qposmax); in ti_eqep_position_ceiling_read()
354 return -ERANGE; in ti_eqep_position_ceiling_write()
356 regmap_write(priv->regmap32, QPOSMAX, ceiling); in ti_eqep_position_ceiling_write()
367 regmap_read(priv->regmap16, QEPCTL, &qepctl); in ti_eqep_position_enable_read()
379 regmap_write_bits(priv->regmap16, QEPCTL, QEPCTL_PHEN, enable ? -1 : 0); in ti_eqep_position_enable_write()
391 regmap_read(priv->regmap16, QEPSTS, &qepsts); in ti_eqep_direction_read()
463 regmap_read(priv->regmap16, QFLG, &qflg); in ti_eqep_irq_handler()
474 regmap_write(priv->regmap16, QCLR, qflg); in ti_eqep_irq_handler()
480 .name = "32-bit",
488 .name = "16-bit",
497 struct device *dev = &pdev->dev; in ti_eqep_probe()
506 return -ENOMEM; in ti_eqep_probe()
513 priv->regmap32 = devm_regmap_init_mmio(dev, base, in ti_eqep_probe()
515 if (IS_ERR(priv->regmap32)) in ti_eqep_probe()
516 return PTR_ERR(priv->regmap32); in ti_eqep_probe()
518 priv->regmap16 = devm_regmap_init_mmio(dev, base + 0x24, in ti_eqep_probe()
520 if (IS_ERR(priv->regmap16)) in ti_eqep_probe()
521 return PTR_ERR(priv->regmap16); in ti_eqep_probe()
532 counter->name = dev_name(dev); in ti_eqep_probe()
533 counter->parent = dev; in ti_eqep_probe()
534 counter->ops = &ti_eqep_counter_ops; in ti_eqep_probe()
535 counter->counts = ti_eqep_counts; in ti_eqep_probe()
536 counter->num_counts = ARRAY_SIZE(ti_eqep_counts); in ti_eqep_probe()
537 counter->signals = ti_eqep_signals; in ti_eqep_probe()
538 counter->num_signals = ARRAY_SIZE(ti_eqep_signals); in ti_eqep_probe()
567 struct device *dev = &pdev->dev; in ti_eqep_remove()
575 { .compatible = "ti,am3352-eqep", },
576 { .compatible = "ti,am62-eqep", },
585 .name = "ti-eqep-cnt",
592 MODULE_DESCRIPTION("TI eQEP counter driver");