• Home
  • Raw
  • Download

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

1 // SPDX-License-Identifier: GPL-2.0-only
86 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_function_get()
88 if (priv->qdec_mode) in mchp_tc_count_function_get()
100 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_function_set()
103 regmap_read(priv->regmap, ATMEL_TC_BMR, &bmr); in mchp_tc_count_function_set()
104 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_function_set()
106 /* Set capture mode */ in mchp_tc_count_function_set()
111 priv->qdec_mode = 0; in mchp_tc_count_function_set()
114 if (!priv->tc_cfg->has_gclk) in mchp_tc_count_function_set()
118 /* Setup the period capture mode */ in mchp_tc_count_function_set()
123 if (!priv->tc_cfg->has_qdec) in mchp_tc_count_function_set()
124 return -EINVAL; in mchp_tc_count_function_set()
126 if (priv->num_channels < 2 || priv->channel[0] != 0 || in mchp_tc_count_function_set()
127 priv->channel[1] != 1) { in mchp_tc_count_function_set()
129 return -EINVAL; in mchp_tc_count_function_set()
131 priv->qdec_mode = 1; in mchp_tc_count_function_set()
137 regmap_write(priv->regmap, ATMEL_TC_BMR, bmr); in mchp_tc_count_function_set()
138 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), cmr); in mchp_tc_count_function_set()
141 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CCR), in mchp_tc_count_function_set()
144 if (priv->qdec_mode) { in mchp_tc_count_function_set()
145 regmap_write(priv->regmap, in mchp_tc_count_function_set()
146 ATMEL_TC_REG(priv->channel[1], CMR), cmr); in mchp_tc_count_function_set()
147 regmap_write(priv->regmap, in mchp_tc_count_function_set()
148 ATMEL_TC_REG(priv->channel[1], CCR), in mchp_tc_count_function_set()
159 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_signal_read()
163 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr); in mchp_tc_count_signal_read()
165 if (signal->id == 1) in mchp_tc_count_signal_read()
180 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_action_get()
183 if (priv->qdec_mode) { in mchp_tc_count_action_get()
188 /* Only TIOA signal is evaluated in non-QDEC mode */ in mchp_tc_count_action_get()
189 if (synapse->signal->id != 0) { in mchp_tc_count_action_get()
194 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_action_get()
219 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_action_set()
222 /* QDEC mode is rising edge only; only TIOA handled in non-QDEC mode */ in mchp_tc_count_action_set()
223 if (priv->qdec_mode || synapse->signal->id != 0) in mchp_tc_count_action_set()
224 return -EINVAL; in mchp_tc_count_action_set()
241 return regmap_write_bits(priv->regmap, in mchp_tc_count_action_set()
242 ATMEL_TC_REG(priv->channel[0], CMR), in mchp_tc_count_action_set()
250 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_read()
253 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CV), &cnt); in mchp_tc_count_read()
299 { .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
300 { .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
301 { .compatible = "atmel,sama5d2-tcb", .data = &tcb_sama5d2_config, },
302 { .compatible = "atmel,sama5d3-tcb", .data = &tcb_sama5d3_config, },
313 struct device_node *np = pdev->dev.of_node; in mchp_tc_probe()
323 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mchp_tc_probe()
325 return -ENOMEM; in mchp_tc_probe()
329 match = of_match_node(atmel_tc_of_match, np->parent); in mchp_tc_probe()
330 tcb_config = match->data; in mchp_tc_probe()
332 dev_err(&pdev->dev, "No matching parent node found\n"); in mchp_tc_probe()
333 return -ENODEV; in mchp_tc_probe()
336 regmap = syscon_node_to_regmap(np->parent); in mchp_tc_probe()
341 priv->num_channels = of_property_count_u32_elems(np, "reg"); in mchp_tc_probe()
342 if (priv->num_channels < 0) { in mchp_tc_probe()
343 dev_err(&pdev->dev, "Invalid or missing channel\n"); in mchp_tc_probe()
344 return -EINVAL; in mchp_tc_probe()
348 for (i = 0; i < priv->num_channels; i++) { in mchp_tc_probe()
351 return -ENODEV; in mchp_tc_probe()
353 priv->channel[i] = channel; in mchp_tc_probe()
357 clk[i] = of_clk_get_by_name(np->parent, clk_name); in mchp_tc_probe()
360 clk[i] = of_clk_get_by_name(np->parent, "t0_clk"); in mchp_tc_probe()
369 ret = devm_add_action_or_reset(&pdev->dev, in mchp_tc_probe()
375 dev_dbg(&pdev->dev, in mchp_tc_probe()
376 "Initialized capture mode on channel %d\n", in mchp_tc_probe()
380 priv->tc_cfg = tcb_config; in mchp_tc_probe()
381 priv->regmap = regmap; in mchp_tc_probe()
382 priv->counter.name = dev_name(&pdev->dev); in mchp_tc_probe()
383 priv->counter.parent = &pdev->dev; in mchp_tc_probe()
384 priv->counter.ops = &mchp_tc_ops; in mchp_tc_probe()
385 priv->counter.num_counts = ARRAY_SIZE(mchp_tc_counts); in mchp_tc_probe()
386 priv->counter.counts = mchp_tc_counts; in mchp_tc_probe()
387 priv->counter.num_signals = ARRAY_SIZE(mchp_tc_count_signals); in mchp_tc_probe()
388 priv->counter.signals = mchp_tc_count_signals; in mchp_tc_probe()
389 priv->counter.priv = priv; in mchp_tc_probe()
391 return devm_counter_register(&pdev->dev, &priv->counter); in mchp_tc_probe()
395 { .compatible = "microchip,tcb-capture", },
403 .name = "microchip-tcb-capture",
410 MODULE_DESCRIPTION("Microchip TCB Capture driver");