Lines Matching +full:at91rm9200 +full:- +full:tcb
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()
112 priv->qdec_mode = 0; in mchp_tc_count_function_set()
115 if (priv->tc_cfg->has_gclk) 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 return -EINVAL; in mchp_tc_count_function_set()
141 regmap_write(priv->regmap, ATMEL_TC_BMR, bmr); in mchp_tc_count_function_set()
142 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), cmr); in mchp_tc_count_function_set()
145 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CCR), in mchp_tc_count_function_set()
148 if (priv->qdec_mode) { in mchp_tc_count_function_set()
149 regmap_write(priv->regmap, in mchp_tc_count_function_set()
150 ATMEL_TC_REG(priv->channel[1], CMR), cmr); in mchp_tc_count_function_set()
151 regmap_write(priv->regmap, in mchp_tc_count_function_set()
152 ATMEL_TC_REG(priv->channel[1], CCR), in mchp_tc_count_function_set()
163 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_signal_read()
167 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr); in mchp_tc_count_signal_read()
169 if (priv->trig_inverted) in mchp_tc_count_signal_read()
184 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_action_get()
187 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_action_get()
212 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_action_set()
216 if (priv->qdec_mode) in mchp_tc_count_action_set()
217 return -EINVAL; in mchp_tc_count_action_set()
234 return -EINVAL; in mchp_tc_count_action_set()
237 return regmap_write_bits(priv->regmap, in mchp_tc_count_action_set()
238 ATMEL_TC_REG(priv->channel[0], CMR), in mchp_tc_count_action_set()
246 struct mchp_tc_data *const priv = counter->priv; in mchp_tc_count_read()
249 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CV), &cnt); in mchp_tc_count_read()
295 { .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
296 { .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
297 { .compatible = "atmel,sama5d2-tcb", .data = &tcb_sama5d2_config, },
298 { .compatible = "atmel,sama5d3-tcb", .data = &tcb_sama5d3_config, },
309 struct device_node *np = pdev->dev.of_node; in mchp_tc_probe()
319 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mchp_tc_probe()
321 return -ENOMEM; in mchp_tc_probe()
325 match = of_match_node(atmel_tc_of_match, np->parent); in mchp_tc_probe()
326 tcb_config = match->data; in mchp_tc_probe()
328 dev_err(&pdev->dev, "No matching parent node found\n"); in mchp_tc_probe()
329 return -ENODEV; in mchp_tc_probe()
332 regmap = syscon_node_to_regmap(np->parent); in mchp_tc_probe()
337 priv->num_channels = of_property_count_u32_elems(np, "reg"); in mchp_tc_probe()
338 if (priv->num_channels < 0) { in mchp_tc_probe()
339 dev_err(&pdev->dev, "Invalid or missing channel\n"); in mchp_tc_probe()
340 return -EINVAL; in mchp_tc_probe()
344 for (i = 0; i < priv->num_channels; i++) { in mchp_tc_probe()
347 return -ENODEV; in mchp_tc_probe()
349 priv->channel[i] = channel; in mchp_tc_probe()
353 clk[i] = of_clk_get_by_name(np->parent, clk_name); in mchp_tc_probe()
356 clk[i] = of_clk_get_by_name(np->parent, "t0_clk"); in mchp_tc_probe()
365 ret = devm_add_action_or_reset(&pdev->dev, in mchp_tc_probe()
371 dev_dbg(&pdev->dev, in mchp_tc_probe()
376 priv->tc_cfg = tcb_config; in mchp_tc_probe()
377 priv->regmap = regmap; in mchp_tc_probe()
378 priv->counter.name = dev_name(&pdev->dev); in mchp_tc_probe()
379 priv->counter.parent = &pdev->dev; in mchp_tc_probe()
380 priv->counter.ops = &mchp_tc_ops; in mchp_tc_probe()
381 priv->counter.num_counts = ARRAY_SIZE(mchp_tc_counts); in mchp_tc_probe()
382 priv->counter.counts = mchp_tc_counts; in mchp_tc_probe()
383 priv->counter.num_signals = ARRAY_SIZE(mchp_tc_count_signals); in mchp_tc_probe()
384 priv->counter.signals = mchp_tc_count_signals; in mchp_tc_probe()
385 priv->counter.priv = priv; in mchp_tc_probe()
387 return devm_counter_register(&pdev->dev, &priv->counter); in mchp_tc_probe()
391 { .compatible = "microchip,tcb-capture", },
399 .name = "microchip-tcb-capture",
406 MODULE_DESCRIPTION("Microchip TCB Capture driver");