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)
17 /* 32-bit registers */
28 /* 16-bit registers */
69 /* EQEP Inputs */
98 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_count_read()
101 regmap_read(priv->regmap32, QPOSCNT, &cnt); in ti_eqep_count_read()
110 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_count_write()
113 regmap_read(priv->regmap32, QPOSMAX, &max); in ti_eqep_count_write()
115 return -EINVAL; in ti_eqep_count_write()
117 return regmap_write(priv->regmap32, QPOSCNT, val); in ti_eqep_count_write()
123 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_function_get()
126 regmap_read(priv->regmap16, QDECCTL, &qdecctl); in ti_eqep_function_get()
135 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_function_set()
137 return regmap_write_bits(priv->regmap16, QDECCTL, QDECCTL_QSRC, in ti_eqep_function_set()
145 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_action_get()
162 /* In direction-count mode only rising edge of QEPA is counted in ti_eqep_action_get()
165 switch (synapse->signal->id) { in ti_eqep_action_get()
174 return -EINVAL; in ti_eqep_action_get()
178 /* In up/down-count modes only QEPA is counted and QEPB is not in ti_eqep_action_get()
181 switch (synapse->signal->id) { in ti_eqep_action_get()
183 err = regmap_read(priv->regmap16, QDECCTL, &qdecctl); in ti_eqep_action_get()
197 return -EINVAL; in ti_eqep_action_get()
201 return -EINVAL; in ti_eqep_action_get()
217 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_position_ceiling_read()
220 regmap_read(priv->regmap32, QPOSMAX, &qposmax); in ti_eqep_position_ceiling_read()
230 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_position_ceiling_write()
238 regmap_write(priv->regmap32, QPOSMAX, res); in ti_eqep_position_ceiling_write()
247 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_position_enable_read()
250 regmap_read(priv->regmap16, QEPCTL, &qepctl); in ti_eqep_position_enable_read()
260 struct ti_eqep_cnt *priv = counter->priv; in ti_eqep_position_enable_write()
268 regmap_write_bits(priv->regmap16, QEPCTL, QEPCTL_PHEN, res ? -1 : 0); in ti_eqep_position_enable_write()
337 .name = "32-bit",
345 .name = "16-bit",
354 struct device *dev = &pdev->dev; in ti_eqep_probe()
361 return -ENOMEM; in ti_eqep_probe()
367 priv->regmap32 = devm_regmap_init_mmio(dev, base, in ti_eqep_probe()
369 if (IS_ERR(priv->regmap32)) in ti_eqep_probe()
370 return PTR_ERR(priv->regmap32); in ti_eqep_probe()
372 priv->regmap16 = devm_regmap_init_mmio(dev, base + 0x24, in ti_eqep_probe()
374 if (IS_ERR(priv->regmap16)) in ti_eqep_probe()
375 return PTR_ERR(priv->regmap16); in ti_eqep_probe()
377 priv->counter.name = dev_name(dev); in ti_eqep_probe()
378 priv->counter.parent = dev; in ti_eqep_probe()
379 priv->counter.ops = &ti_eqep_counter_ops; in ti_eqep_probe()
380 priv->counter.counts = ti_eqep_counts; in ti_eqep_probe()
381 priv->counter.num_counts = ARRAY_SIZE(ti_eqep_counts); in ti_eqep_probe()
382 priv->counter.signals = ti_eqep_signals; in ti_eqep_probe()
383 priv->counter.num_signals = ARRAY_SIZE(ti_eqep_signals); in ti_eqep_probe()
384 priv->counter.priv = priv; in ti_eqep_probe()
396 err = counter_register(&priv->counter); in ti_eqep_probe()
409 struct device *dev = &pdev->dev; in ti_eqep_remove()
411 counter_unregister(&priv->counter); in ti_eqep_remove()
419 { .compatible = "ti,am3352-eqep", },
428 .name = "ti-eqep-cnt",
435 MODULE_DESCRIPTION("TI eQEP counter driver");