Lines Matching +full:at91rm9200 +full:- +full:tcb
1 // SPDX-License-Identifier: GPL-2.0-only
75 if (priv->qdec_mode) in mchp_tc_count_function_read()
90 regmap_read(priv->regmap, ATMEL_TC_BMR, &bmr); in mchp_tc_count_function_write()
91 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_function_write()
98 priv->qdec_mode = 0; in mchp_tc_count_function_write()
101 if (priv->tc_cfg->has_gclk) in mchp_tc_count_function_write()
110 if (!priv->tc_cfg->has_qdec) in mchp_tc_count_function_write()
111 return -EINVAL; in mchp_tc_count_function_write()
113 if (priv->num_channels < 2 || priv->channel[0] != 0 || in mchp_tc_count_function_write()
114 priv->channel[1] != 1) { in mchp_tc_count_function_write()
116 return -EINVAL; in mchp_tc_count_function_write()
118 priv->qdec_mode = 1; in mchp_tc_count_function_write()
124 return -EINVAL; in mchp_tc_count_function_write()
127 regmap_write(priv->regmap, ATMEL_TC_BMR, bmr); in mchp_tc_count_function_write()
128 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), cmr); in mchp_tc_count_function_write()
131 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CCR), in mchp_tc_count_function_write()
134 if (priv->qdec_mode) { in mchp_tc_count_function_write()
135 regmap_write(priv->regmap, in mchp_tc_count_function_write()
136 ATMEL_TC_REG(priv->channel[1], CMR), cmr); in mchp_tc_count_function_write()
137 regmap_write(priv->regmap, in mchp_tc_count_function_write()
138 ATMEL_TC_REG(priv->channel[1], CCR), in mchp_tc_count_function_write()
153 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr); in mchp_tc_count_signal_read()
155 if (signal->id == 1) in mchp_tc_count_signal_read()
173 if (priv->qdec_mode) { in mchp_tc_count_action_read()
178 /* Only TIOA signal is evaluated in non-QDEC mode */ in mchp_tc_count_action_read()
179 if (synapse->signal->id != 0) { in mchp_tc_count_action_read()
184 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_action_read()
212 /* QDEC mode is rising edge only; only TIOA handled in non-QDEC mode */ in mchp_tc_count_action_write()
213 if (priv->qdec_mode || synapse->signal->id != 0) in mchp_tc_count_action_write()
214 return -EINVAL; in mchp_tc_count_action_write()
231 return -EINVAL; in mchp_tc_count_action_write()
234 return regmap_write_bits(priv->regmap, in mchp_tc_count_action_write()
235 ATMEL_TC_REG(priv->channel[0], CMR), in mchp_tc_count_action_write()
245 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CV), &cnt); in mchp_tc_count_read()
291 { .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
292 { .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
293 { .compatible = "atmel,sama5d2-tcb", .data = &tcb_sama5d2_config, },
294 { .compatible = "atmel,sama5d3-tcb", .data = &tcb_sama5d3_config, },
305 struct device_node *np = pdev->dev.of_node; in mchp_tc_probe()
316 counter = devm_counter_alloc(&pdev->dev, sizeof(*priv)); in mchp_tc_probe()
318 return -ENOMEM; in mchp_tc_probe()
321 match = of_match_node(atmel_tc_of_match, np->parent); in mchp_tc_probe()
322 tcb_config = match->data; in mchp_tc_probe()
324 dev_err(&pdev->dev, "No matching parent node found\n"); in mchp_tc_probe()
325 return -ENODEV; in mchp_tc_probe()
328 regmap = syscon_node_to_regmap(np->parent); in mchp_tc_probe()
333 priv->num_channels = of_property_count_u32_elems(np, "reg"); in mchp_tc_probe()
334 if (priv->num_channels < 0) { in mchp_tc_probe()
335 dev_err(&pdev->dev, "Invalid or missing channel\n"); in mchp_tc_probe()
336 return -EINVAL; in mchp_tc_probe()
340 for (i = 0; i < priv->num_channels; i++) { in mchp_tc_probe()
343 return -ENODEV; in mchp_tc_probe()
345 priv->channel[i] = channel; in mchp_tc_probe()
349 clk[i] = of_clk_get_by_name(np->parent, clk_name); in mchp_tc_probe()
352 clk[i] = of_clk_get_by_name(np->parent, "t0_clk"); in mchp_tc_probe()
361 ret = devm_add_action_or_reset(&pdev->dev, in mchp_tc_probe()
367 dev_dbg(&pdev->dev, in mchp_tc_probe()
372 priv->tc_cfg = tcb_config; in mchp_tc_probe()
373 priv->regmap = regmap; in mchp_tc_probe()
374 counter->name = dev_name(&pdev->dev); in mchp_tc_probe()
375 counter->parent = &pdev->dev; in mchp_tc_probe()
376 counter->ops = &mchp_tc_ops; in mchp_tc_probe()
377 counter->num_counts = ARRAY_SIZE(mchp_tc_counts); in mchp_tc_probe()
378 counter->counts = mchp_tc_counts; in mchp_tc_probe()
379 counter->num_signals = ARRAY_SIZE(mchp_tc_count_signals); in mchp_tc_probe()
380 counter->signals = mchp_tc_count_signals; in mchp_tc_probe()
382 ret = devm_counter_add(&pdev->dev, counter); in mchp_tc_probe()
384 return dev_err_probe(&pdev->dev, ret, "Failed to add counter\n"); in mchp_tc_probe()
390 { .compatible = "microchip,tcb-capture", },
398 .name = "microchip-tcb-capture",
405 MODULE_DESCRIPTION("Microchip TCB Capture driver");