• Home
  • Raw
  • Download

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()
209 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_action_set()
213 if (priv->qdec_mode) in mchp_tc_count_action_set()
214 return -EINVAL; in mchp_tc_count_action_set()
231 return regmap_write_bits(priv->regmap, in mchp_tc_count_action_set()
232 ATMEL_TC_REG(priv->channel[0], CMR), in mchp_tc_count_action_set()
240 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_read()
243 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CV), &cnt); in mchp_tc_count_read()
289 { .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
290 { .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
291 { .compatible = "atmel,sama5d2-tcb", .data = &tcb_sama5d2_config, },
292 { .compatible = "atmel,sama5d3-tcb", .data = &tcb_sama5d3_config, },
303 struct device_node *np = pdev->dev.of_node; in mchp_tc_probe()
313 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mchp_tc_probe()
315 return -ENOMEM; in mchp_tc_probe()
319 match = of_match_node(atmel_tc_of_match, np->parent); in mchp_tc_probe()
320 tcb_config = match->data; in mchp_tc_probe()
322 dev_err(&pdev->dev, "No matching parent node found\n"); in mchp_tc_probe()
323 return -ENODEV; in mchp_tc_probe()
326 regmap = syscon_node_to_regmap(np->parent); in mchp_tc_probe()
331 priv->num_channels = of_property_count_u32_elems(np, "reg"); in mchp_tc_probe()
332 if (priv->num_channels < 0) { in mchp_tc_probe()
333 dev_err(&pdev->dev, "Invalid or missing channel\n"); in mchp_tc_probe()
334 return -EINVAL; in mchp_tc_probe()
338 for (i = 0; i < priv->num_channels; i++) { in mchp_tc_probe()
341 return -ENODEV; in mchp_tc_probe()
343 priv->channel[i] = channel; in mchp_tc_probe()
347 clk[i] = of_clk_get_by_name(np->parent, clk_name); in mchp_tc_probe()
350 clk[i] = of_clk_get_by_name(np->parent, "t0_clk"); in mchp_tc_probe()
359 ret = devm_add_action_or_reset(&pdev->dev, in mchp_tc_probe()
365 dev_dbg(&pdev->dev, in mchp_tc_probe()
366 "Initialized capture mode on channel %d\n", in mchp_tc_probe()
370 priv->tc_cfg = tcb_config; in mchp_tc_probe()
371 priv->regmap = regmap; in mchp_tc_probe()
372 priv->counter.name = dev_name(&pdev->dev); in mchp_tc_probe()
373 priv->counter.parent = &pdev->dev; in mchp_tc_probe()
374 priv->counter.ops = &mchp_tc_ops; in mchp_tc_probe()
375 priv->counter.num_counts = ARRAY_SIZE(mchp_tc_counts); in mchp_tc_probe()
376 priv->counter.counts = mchp_tc_counts; in mchp_tc_probe()
377 priv->counter.num_signals = ARRAY_SIZE(mchp_tc_count_signals); in mchp_tc_probe()
378 priv->counter.signals = mchp_tc_count_signals; in mchp_tc_probe()
379 priv->counter.priv = priv; in mchp_tc_probe()
381 return devm_counter_register(&pdev->dev, &priv->counter); in mchp_tc_probe()
385 { .compatible = "microchip,tcb-capture", },
393 .name = "microchip-tcb-capture",
400 MODULE_DESCRIPTION("Microchip TCB Capture driver");