Lines Matching +full:tcb +full:- +full:capture

1 // SPDX-License-Identifier: GPL-2.0-only
87 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_function_get()
89 if (priv->qdec_mode) in mchp_tc_count_function_get()
101 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_function_set()
104 regmap_read(priv->regmap, ATMEL_TC_BMR, &bmr); in mchp_tc_count_function_set()
105 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_function_set()
107 /* Set capture mode */ in mchp_tc_count_function_set()
112 priv->qdec_mode = 0; in mchp_tc_count_function_set()
115 if (priv->tc_cfg->has_gclk) in mchp_tc_count_function_set()
119 /* Setup the period capture mode */ in mchp_tc_count_function_set()
124 if (!priv->tc_cfg->has_qdec) in mchp_tc_count_function_set()
125 return -EINVAL; in mchp_tc_count_function_set()
127 if (priv->num_channels < 2 || priv->channel[0] != 0 || in mchp_tc_count_function_set()
128 priv->channel[1] != 1) { in mchp_tc_count_function_set()
130 return -EINVAL; in mchp_tc_count_function_set()
132 priv->qdec_mode = 1; in mchp_tc_count_function_set()
138 regmap_write(priv->regmap, ATMEL_TC_BMR, bmr); in mchp_tc_count_function_set()
139 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), cmr); in mchp_tc_count_function_set()
142 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CCR), in mchp_tc_count_function_set()
145 if (priv->qdec_mode) { in mchp_tc_count_function_set()
146 regmap_write(priv->regmap, in mchp_tc_count_function_set()
147 ATMEL_TC_REG(priv->channel[1], CMR), cmr); in mchp_tc_count_function_set()
148 regmap_write(priv->regmap, in mchp_tc_count_function_set()
149 ATMEL_TC_REG(priv->channel[1], CCR), in mchp_tc_count_function_set()
160 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_signal_read()
164 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr); in mchp_tc_count_signal_read()
166 if (priv->trig_inverted) in mchp_tc_count_signal_read()
181 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_action_get()
184 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_action_get()
205 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_action_set()
209 if (priv->qdec_mode) in mchp_tc_count_action_set()
210 return -EINVAL; in mchp_tc_count_action_set()
227 return regmap_write_bits(priv->regmap, in mchp_tc_count_action_set()
228 ATMEL_TC_REG(priv->channel[0], CMR), in mchp_tc_count_action_set()
236 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_read()
239 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CV), &cnt); in mchp_tc_count_read()
285 { .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
286 { .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
287 { .compatible = "atmel,sama5d2-tcb", .data = &tcb_sama5d2_config, },
288 { .compatible = "atmel,sama5d3-tcb", .data = &tcb_sama5d3_config, },
299 struct device_node *np = pdev->dev.of_node; in mchp_tc_probe()
309 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mchp_tc_probe()
311 return -ENOMEM; in mchp_tc_probe()
315 match = of_match_node(atmel_tc_of_match, np->parent); in mchp_tc_probe()
316 tcb_config = match->data; in mchp_tc_probe()
318 dev_err(&pdev->dev, "No matching parent node found\n"); in mchp_tc_probe()
319 return -ENODEV; in mchp_tc_probe()
322 regmap = syscon_node_to_regmap(np->parent); in mchp_tc_probe()
327 priv->num_channels = of_property_count_u32_elems(np, "reg"); in mchp_tc_probe()
328 if (priv->num_channels < 0) { in mchp_tc_probe()
329 dev_err(&pdev->dev, "Invalid or missing channel\n"); in mchp_tc_probe()
330 return -EINVAL; in mchp_tc_probe()
334 for (i = 0; i < priv->num_channels; i++) { in mchp_tc_probe()
337 return -ENODEV; in mchp_tc_probe()
339 priv->channel[i] = channel; in mchp_tc_probe()
343 clk[i] = of_clk_get_by_name(np->parent, clk_name); in mchp_tc_probe()
346 clk[i] = of_clk_get_by_name(np->parent, "t0_clk"); in mchp_tc_probe()
355 ret = devm_add_action_or_reset(&pdev->dev, in mchp_tc_probe()
361 dev_dbg(&pdev->dev, in mchp_tc_probe()
362 "Initialized capture mode on channel %d\n", in mchp_tc_probe()
366 priv->tc_cfg = tcb_config; in mchp_tc_probe()
367 priv->regmap = regmap; in mchp_tc_probe()
368 priv->counter.name = dev_name(&pdev->dev); in mchp_tc_probe()
369 priv->counter.parent = &pdev->dev; in mchp_tc_probe()
370 priv->counter.ops = &mchp_tc_ops; in mchp_tc_probe()
371 priv->counter.num_counts = ARRAY_SIZE(mchp_tc_counts); in mchp_tc_probe()
372 priv->counter.counts = mchp_tc_counts; in mchp_tc_probe()
373 priv->counter.num_signals = ARRAY_SIZE(mchp_tc_count_signals); in mchp_tc_probe()
374 priv->counter.signals = mchp_tc_count_signals; in mchp_tc_probe()
375 priv->counter.priv = priv; in mchp_tc_probe()
377 return devm_counter_register(&pdev->dev, &priv->counter); in mchp_tc_probe()
381 { .compatible = "microchip,tcb-capture", },
389 .name = "microchip-tcb-capture",
396 MODULE_DESCRIPTION("Microchip TCB Capture driver");