Lines Matching +full:at91rm9200 +full:- +full:tcb

1 // SPDX-License-Identifier: GPL-2.0-only
74 if (priv->qdec_mode) in mchp_tc_count_function_read()
89 regmap_read(priv->regmap, ATMEL_TC_BMR, &bmr); in mchp_tc_count_function_write()
90 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_function_write()
97 priv->qdec_mode = 0; in mchp_tc_count_function_write()
100 if (!priv->tc_cfg->has_gclk) in mchp_tc_count_function_write()
109 if (!priv->tc_cfg->has_qdec) in mchp_tc_count_function_write()
110 return -EINVAL; in mchp_tc_count_function_write()
112 if (priv->num_channels < 2 || priv->channel[0] != 0 || in mchp_tc_count_function_write()
113 priv->channel[1] != 1) { in mchp_tc_count_function_write()
115 return -EINVAL; in mchp_tc_count_function_write()
117 priv->qdec_mode = 1; in mchp_tc_count_function_write()
123 return -EINVAL; in mchp_tc_count_function_write()
126 regmap_write(priv->regmap, ATMEL_TC_BMR, bmr); in mchp_tc_count_function_write()
127 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), cmr); in mchp_tc_count_function_write()
130 regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CCR), in mchp_tc_count_function_write()
133 if (priv->qdec_mode) { in mchp_tc_count_function_write()
134 regmap_write(priv->regmap, in mchp_tc_count_function_write()
135 ATMEL_TC_REG(priv->channel[1], CMR), cmr); in mchp_tc_count_function_write()
136 regmap_write(priv->regmap, in mchp_tc_count_function_write()
137 ATMEL_TC_REG(priv->channel[1], CCR), in mchp_tc_count_function_write()
152 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr); in mchp_tc_count_signal_read()
154 if (signal->id == 1) in mchp_tc_count_signal_read()
172 if (priv->qdec_mode) { in mchp_tc_count_action_read()
177 /* Only TIOA signal is evaluated in non-QDEC mode */ in mchp_tc_count_action_read()
178 if (synapse->signal->id != 0) { in mchp_tc_count_action_read()
183 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); in mchp_tc_count_action_read()
211 /* QDEC mode is rising edge only; only TIOA handled in non-QDEC mode */ in mchp_tc_count_action_write()
212 if (priv->qdec_mode || synapse->signal->id != 0) in mchp_tc_count_action_write()
213 return -EINVAL; in mchp_tc_count_action_write()
230 return -EINVAL; in mchp_tc_count_action_write()
233 return regmap_write_bits(priv->regmap, in mchp_tc_count_action_write()
234 ATMEL_TC_REG(priv->channel[0], CMR), in mchp_tc_count_action_write()
244 regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CV), &cnt); in mchp_tc_count_read()
290 { .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
291 { .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
292 { .compatible = "atmel,sama5d2-tcb", .data = &tcb_sama5d2_config, },
293 { .compatible = "atmel,sama5d3-tcb", .data = &tcb_sama5d3_config, },
304 struct device_node *np = pdev->dev.of_node; in mchp_tc_probe()
315 counter = devm_counter_alloc(&pdev->dev, sizeof(*priv)); in mchp_tc_probe()
317 return -ENOMEM; in mchp_tc_probe()
320 match = of_match_node(atmel_tc_of_match, np->parent); in mchp_tc_probe()
321 tcb_config = match->data; in mchp_tc_probe()
323 dev_err(&pdev->dev, "No matching parent node found\n"); in mchp_tc_probe()
324 return -ENODEV; in mchp_tc_probe()
327 regmap = syscon_node_to_regmap(np->parent); in mchp_tc_probe()
332 priv->num_channels = of_property_count_u32_elems(np, "reg"); in mchp_tc_probe()
333 if (priv->num_channels < 0) { in mchp_tc_probe()
334 dev_err(&pdev->dev, "Invalid or missing channel\n"); in mchp_tc_probe()
335 return -EINVAL; in mchp_tc_probe()
339 for (i = 0; i < priv->num_channels; i++) { in mchp_tc_probe()
342 return -ENODEV; in mchp_tc_probe()
344 priv->channel[i] = channel; in mchp_tc_probe()
348 clk[i] = of_clk_get_by_name(np->parent, clk_name); in mchp_tc_probe()
351 clk[i] = of_clk_get_by_name(np->parent, "t0_clk"); in mchp_tc_probe()
360 ret = devm_add_action_or_reset(&pdev->dev, in mchp_tc_probe()
366 dev_dbg(&pdev->dev, in mchp_tc_probe()
371 priv->tc_cfg = tcb_config; in mchp_tc_probe()
372 priv->regmap = regmap; in mchp_tc_probe()
373 counter->name = dev_name(&pdev->dev); in mchp_tc_probe()
374 counter->parent = &pdev->dev; in mchp_tc_probe()
375 counter->ops = &mchp_tc_ops; in mchp_tc_probe()
376 counter->num_counts = ARRAY_SIZE(mchp_tc_counts); in mchp_tc_probe()
377 counter->counts = mchp_tc_counts; in mchp_tc_probe()
378 counter->num_signals = ARRAY_SIZE(mchp_tc_count_signals); in mchp_tc_probe()
379 counter->signals = mchp_tc_count_signals; in mchp_tc_probe()
381 ret = devm_counter_add(&pdev->dev, counter); in mchp_tc_probe()
383 return dev_err_probe(&pdev->dev, ret, "Failed to add counter\n"); in mchp_tc_probe()
389 { .compatible = "microchip,tcb-capture", },
397 .name = "microchip-tcb-capture",
404 MODULE_DESCRIPTION("Microchip TCB Capture driver");