microchip-tcb-capture.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2020 Microchip
  4. *
  5. * Author: Kamel Bouhara <kamel.bouhara@bootlin.com>
  6. */
  7. #include <linux/clk.h>
  8. #include <linux/counter.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/mfd/syscon.h>
  11. #include <linux/module.h>
  12. #include <linux/mutex.h>
  13. #include <linux/of.h>
  14. #include <linux/of_irq.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/regmap.h>
  17. #include <uapi/linux/counter/microchip-tcb-capture.h>
  18. #include <soc/at91/atmel_tcb.h>
  19. #define ATMEL_TC_CMR_MASK (ATMEL_TC_LDRA_RISING | ATMEL_TC_LDRB_FALLING | \
  20. ATMEL_TC_ETRGEDG_RISING | ATMEL_TC_LDBDIS | \
  21. ATMEL_TC_LDBSTOP)
  22. #define ATMEL_TC_DEF_IRQS (ATMEL_TC_ETRGS | ATMEL_TC_COVFS | \
  23. ATMEL_TC_LDRAS | ATMEL_TC_LDRBS | ATMEL_TC_CPCS)
  24. #define ATMEL_TC_QDEN BIT(8)
  25. #define ATMEL_TC_POSEN BIT(9)
  26. struct mchp_tc_data {
  27. const struct atmel_tcb_config *tc_cfg;
  28. struct regmap *regmap;
  29. int qdec_mode;
  30. int num_channels;
  31. int channel[2];
  32. };
  33. static const enum counter_function mchp_tc_count_functions[] = {
  34. COUNTER_FUNCTION_INCREASE,
  35. COUNTER_FUNCTION_QUADRATURE_X4,
  36. };
  37. static const enum counter_synapse_action mchp_tc_synapse_actions[] = {
  38. COUNTER_SYNAPSE_ACTION_NONE,
  39. COUNTER_SYNAPSE_ACTION_RISING_EDGE,
  40. COUNTER_SYNAPSE_ACTION_FALLING_EDGE,
  41. COUNTER_SYNAPSE_ACTION_BOTH_EDGES,
  42. };
  43. static struct counter_signal mchp_tc_count_signals[] = {
  44. {
  45. .id = 0,
  46. .name = "Channel A",
  47. },
  48. {
  49. .id = 1,
  50. .name = "Channel B",
  51. }
  52. };
  53. static struct counter_synapse mchp_tc_count_synapses[] = {
  54. {
  55. .actions_list = mchp_tc_synapse_actions,
  56. .num_actions = ARRAY_SIZE(mchp_tc_synapse_actions),
  57. .signal = &mchp_tc_count_signals[0]
  58. },
  59. {
  60. .actions_list = mchp_tc_synapse_actions,
  61. .num_actions = ARRAY_SIZE(mchp_tc_synapse_actions),
  62. .signal = &mchp_tc_count_signals[1]
  63. }
  64. };
  65. static int mchp_tc_count_function_read(struct counter_device *counter,
  66. struct counter_count *count,
  67. enum counter_function *function)
  68. {
  69. struct mchp_tc_data *const priv = counter_priv(counter);
  70. if (priv->qdec_mode)
  71. *function = COUNTER_FUNCTION_QUADRATURE_X4;
  72. else
  73. *function = COUNTER_FUNCTION_INCREASE;
  74. return 0;
  75. }
  76. static int mchp_tc_count_function_write(struct counter_device *counter,
  77. struct counter_count *count,
  78. enum counter_function function)
  79. {
  80. struct mchp_tc_data *const priv = counter_priv(counter);
  81. u32 bmr, cmr;
  82. regmap_read(priv->regmap, ATMEL_TC_BMR, &bmr);
  83. regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr);
  84. /* Set capture mode */
  85. cmr &= ~ATMEL_TC_WAVE;
  86. switch (function) {
  87. case COUNTER_FUNCTION_INCREASE:
  88. priv->qdec_mode = 0;
  89. /* Set highest rate based on whether soc has gclk or not */
  90. bmr &= ~(ATMEL_TC_QDEN | ATMEL_TC_POSEN);
  91. if (!priv->tc_cfg->has_gclk)
  92. cmr |= ATMEL_TC_TIMER_CLOCK2;
  93. else
  94. cmr |= ATMEL_TC_TIMER_CLOCK1;
  95. /* Setup the period capture mode */
  96. cmr |= ATMEL_TC_CMR_MASK;
  97. cmr &= ~(ATMEL_TC_ABETRG | ATMEL_TC_XC0);
  98. break;
  99. case COUNTER_FUNCTION_QUADRATURE_X4:
  100. if (!priv->tc_cfg->has_qdec)
  101. return -EINVAL;
  102. /* In QDEC mode settings both channels 0 and 1 are required */
  103. if (priv->num_channels < 2 || priv->channel[0] != 0 ||
  104. priv->channel[1] != 1) {
  105. pr_err("Invalid channels number or id for quadrature mode\n");
  106. return -EINVAL;
  107. }
  108. priv->qdec_mode = 1;
  109. bmr |= ATMEL_TC_QDEN | ATMEL_TC_POSEN;
  110. cmr |= ATMEL_TC_ETRGEDG_RISING | ATMEL_TC_ABETRG | ATMEL_TC_XC0;
  111. break;
  112. default:
  113. /* should never reach this path */
  114. return -EINVAL;
  115. }
  116. regmap_write(priv->regmap, ATMEL_TC_BMR, bmr);
  117. regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), cmr);
  118. /* Enable clock and trigger counter */
  119. regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], CCR),
  120. ATMEL_TC_CLKEN | ATMEL_TC_SWTRG);
  121. if (priv->qdec_mode) {
  122. regmap_write(priv->regmap,
  123. ATMEL_TC_REG(priv->channel[1], CMR), cmr);
  124. regmap_write(priv->regmap,
  125. ATMEL_TC_REG(priv->channel[1], CCR),
  126. ATMEL_TC_CLKEN | ATMEL_TC_SWTRG);
  127. }
  128. return 0;
  129. }
  130. static int mchp_tc_count_signal_read(struct counter_device *counter,
  131. struct counter_signal *signal,
  132. enum counter_signal_level *lvl)
  133. {
  134. struct mchp_tc_data *const priv = counter_priv(counter);
  135. bool sigstatus;
  136. u32 sr;
  137. regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr);
  138. if (signal->id == 1)
  139. sigstatus = (sr & ATMEL_TC_MTIOB);
  140. else
  141. sigstatus = (sr & ATMEL_TC_MTIOA);
  142. *lvl = sigstatus ? COUNTER_SIGNAL_LEVEL_HIGH : COUNTER_SIGNAL_LEVEL_LOW;
  143. return 0;
  144. }
  145. static int mchp_tc_count_action_read(struct counter_device *counter,
  146. struct counter_count *count,
  147. struct counter_synapse *synapse,
  148. enum counter_synapse_action *action)
  149. {
  150. struct mchp_tc_data *const priv = counter_priv(counter);
  151. u32 cmr;
  152. if (priv->qdec_mode) {
  153. *action = COUNTER_SYNAPSE_ACTION_BOTH_EDGES;
  154. return 0;
  155. }
  156. /* Only TIOA signal is evaluated in non-QDEC mode */
  157. if (synapse->signal->id != 0) {
  158. *action = COUNTER_SYNAPSE_ACTION_NONE;
  159. return 0;
  160. }
  161. regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr);
  162. switch (cmr & ATMEL_TC_ETRGEDG) {
  163. default:
  164. *action = COUNTER_SYNAPSE_ACTION_NONE;
  165. break;
  166. case ATMEL_TC_ETRGEDG_RISING:
  167. *action = COUNTER_SYNAPSE_ACTION_RISING_EDGE;
  168. break;
  169. case ATMEL_TC_ETRGEDG_FALLING:
  170. *action = COUNTER_SYNAPSE_ACTION_FALLING_EDGE;
  171. break;
  172. case ATMEL_TC_ETRGEDG_BOTH:
  173. *action = COUNTER_SYNAPSE_ACTION_BOTH_EDGES;
  174. break;
  175. }
  176. return 0;
  177. }
  178. static int mchp_tc_count_action_write(struct counter_device *counter,
  179. struct counter_count *count,
  180. struct counter_synapse *synapse,
  181. enum counter_synapse_action action)
  182. {
  183. struct mchp_tc_data *const priv = counter_priv(counter);
  184. u32 edge = ATMEL_TC_ETRGEDG_NONE;
  185. /* QDEC mode is rising edge only; only TIOA handled in non-QDEC mode */
  186. if (priv->qdec_mode || synapse->signal->id != 0)
  187. return -EINVAL;
  188. switch (action) {
  189. case COUNTER_SYNAPSE_ACTION_NONE:
  190. edge = ATMEL_TC_ETRGEDG_NONE;
  191. break;
  192. case COUNTER_SYNAPSE_ACTION_RISING_EDGE:
  193. edge = ATMEL_TC_ETRGEDG_RISING;
  194. break;
  195. case COUNTER_SYNAPSE_ACTION_FALLING_EDGE:
  196. edge = ATMEL_TC_ETRGEDG_FALLING;
  197. break;
  198. case COUNTER_SYNAPSE_ACTION_BOTH_EDGES:
  199. edge = ATMEL_TC_ETRGEDG_BOTH;
  200. break;
  201. default:
  202. /* should never reach this path */
  203. return -EINVAL;
  204. }
  205. return regmap_write_bits(priv->regmap,
  206. ATMEL_TC_REG(priv->channel[0], CMR),
  207. ATMEL_TC_ETRGEDG, edge);
  208. }
  209. static int mchp_tc_count_read(struct counter_device *counter,
  210. struct counter_count *count, u64 *val)
  211. {
  212. struct mchp_tc_data *const priv = counter_priv(counter);
  213. u32 cnt;
  214. regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CV), &cnt);
  215. *val = cnt;
  216. return 0;
  217. }
  218. static int mchp_tc_count_cap_read(struct counter_device *counter,
  219. struct counter_count *count, size_t idx, u64 *val)
  220. {
  221. struct mchp_tc_data *const priv = counter_priv(counter);
  222. u32 cnt;
  223. int ret;
  224. switch (idx) {
  225. case COUNTER_MCHP_EXCAP_RA:
  226. ret = regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], RA), &cnt);
  227. break;
  228. case COUNTER_MCHP_EXCAP_RB:
  229. ret = regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], RB), &cnt);
  230. break;
  231. default:
  232. return -EINVAL;
  233. }
  234. if (ret < 0)
  235. return ret;
  236. *val = cnt;
  237. return 0;
  238. }
  239. static int mchp_tc_count_cap_write(struct counter_device *counter,
  240. struct counter_count *count, size_t idx, u64 val)
  241. {
  242. struct mchp_tc_data *const priv = counter_priv(counter);
  243. int ret;
  244. if (val > U32_MAX)
  245. return -ERANGE;
  246. switch (idx) {
  247. case COUNTER_MCHP_EXCAP_RA:
  248. ret = regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], RA), val);
  249. break;
  250. case COUNTER_MCHP_EXCAP_RB:
  251. ret = regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], RB), val);
  252. break;
  253. default:
  254. return -EINVAL;
  255. }
  256. return ret;
  257. }
  258. static int mchp_tc_count_compare_read(struct counter_device *counter, struct counter_count *count,
  259. u64 *val)
  260. {
  261. struct mchp_tc_data *const priv = counter_priv(counter);
  262. u32 cnt;
  263. int ret;
  264. ret = regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], RC), &cnt);
  265. if (ret < 0)
  266. return ret;
  267. *val = cnt;
  268. return 0;
  269. }
  270. static int mchp_tc_count_compare_write(struct counter_device *counter, struct counter_count *count,
  271. u64 val)
  272. {
  273. struct mchp_tc_data *const priv = counter_priv(counter);
  274. if (val > U32_MAX)
  275. return -ERANGE;
  276. return regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], RC), val);
  277. }
  278. static DEFINE_COUNTER_ARRAY_CAPTURE(mchp_tc_cnt_cap_array, 2);
  279. static struct counter_comp mchp_tc_count_ext[] = {
  280. COUNTER_COMP_ARRAY_CAPTURE(mchp_tc_count_cap_read, mchp_tc_count_cap_write,
  281. mchp_tc_cnt_cap_array),
  282. COUNTER_COMP_COMPARE(mchp_tc_count_compare_read, mchp_tc_count_compare_write),
  283. };
  284. static int mchp_tc_watch_validate(struct counter_device *counter,
  285. const struct counter_watch *watch)
  286. {
  287. if (watch->channel == COUNTER_MCHP_EVCHN_CV || watch->channel == COUNTER_MCHP_EVCHN_RA)
  288. switch (watch->event) {
  289. case COUNTER_EVENT_CHANGE_OF_STATE:
  290. case COUNTER_EVENT_OVERFLOW:
  291. case COUNTER_EVENT_CAPTURE:
  292. return 0;
  293. default:
  294. return -EINVAL;
  295. }
  296. if (watch->channel == COUNTER_MCHP_EVCHN_RB && watch->event == COUNTER_EVENT_CAPTURE)
  297. return 0;
  298. if (watch->channel == COUNTER_MCHP_EVCHN_RC && watch->event == COUNTER_EVENT_THRESHOLD)
  299. return 0;
  300. return -EINVAL;
  301. }
  302. static struct counter_count mchp_tc_counts[] = {
  303. {
  304. .id = 0,
  305. .name = "Timer Counter",
  306. .functions_list = mchp_tc_count_functions,
  307. .num_functions = ARRAY_SIZE(mchp_tc_count_functions),
  308. .synapses = mchp_tc_count_synapses,
  309. .num_synapses = ARRAY_SIZE(mchp_tc_count_synapses),
  310. .ext = mchp_tc_count_ext,
  311. .num_ext = ARRAY_SIZE(mchp_tc_count_ext),
  312. },
  313. };
  314. static const struct counter_ops mchp_tc_ops = {
  315. .signal_read = mchp_tc_count_signal_read,
  316. .count_read = mchp_tc_count_read,
  317. .function_read = mchp_tc_count_function_read,
  318. .function_write = mchp_tc_count_function_write,
  319. .action_read = mchp_tc_count_action_read,
  320. .action_write = mchp_tc_count_action_write,
  321. .watch_validate = mchp_tc_watch_validate,
  322. };
  323. static const struct atmel_tcb_config tcb_rm9200_config = {
  324. .counter_width = 16,
  325. };
  326. static const struct atmel_tcb_config tcb_sam9x5_config = {
  327. .counter_width = 32,
  328. };
  329. static const struct atmel_tcb_config tcb_sama5d2_config = {
  330. .counter_width = 32,
  331. .has_gclk = true,
  332. .has_qdec = true,
  333. };
  334. static const struct atmel_tcb_config tcb_sama5d3_config = {
  335. .counter_width = 32,
  336. .has_qdec = true,
  337. };
  338. static const struct of_device_id atmel_tc_of_match[] = {
  339. { .compatible = "atmel,at91rm9200-tcb", .data = &tcb_rm9200_config, },
  340. { .compatible = "atmel,at91sam9x5-tcb", .data = &tcb_sam9x5_config, },
  341. { .compatible = "atmel,sama5d2-tcb", .data = &tcb_sama5d2_config, },
  342. { .compatible = "atmel,sama5d3-tcb", .data = &tcb_sama5d3_config, },
  343. { /* sentinel */ }
  344. };
  345. static irqreturn_t mchp_tc_isr(int irq, void *dev_id)
  346. {
  347. struct counter_device *const counter = dev_id;
  348. struct mchp_tc_data *const priv = counter_priv(counter);
  349. u32 sr, mask;
  350. regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], SR), &sr);
  351. regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], IMR), &mask);
  352. sr &= mask;
  353. if (!(sr & ATMEL_TC_ALL_IRQ))
  354. return IRQ_NONE;
  355. if (sr & ATMEL_TC_ETRGS)
  356. counter_push_event(counter, COUNTER_EVENT_CHANGE_OF_STATE,
  357. COUNTER_MCHP_EVCHN_CV);
  358. if (sr & ATMEL_TC_LDRAS)
  359. counter_push_event(counter, COUNTER_EVENT_CAPTURE,
  360. COUNTER_MCHP_EVCHN_RA);
  361. if (sr & ATMEL_TC_LDRBS)
  362. counter_push_event(counter, COUNTER_EVENT_CAPTURE,
  363. COUNTER_MCHP_EVCHN_RB);
  364. if (sr & ATMEL_TC_CPCS)
  365. counter_push_event(counter, COUNTER_EVENT_THRESHOLD,
  366. COUNTER_MCHP_EVCHN_RC);
  367. if (sr & ATMEL_TC_COVFS)
  368. counter_push_event(counter, COUNTER_EVENT_OVERFLOW,
  369. COUNTER_MCHP_EVCHN_CV);
  370. return IRQ_HANDLED;
  371. }
  372. static void mchp_tc_irq_remove(void *ptr)
  373. {
  374. struct mchp_tc_data *priv = ptr;
  375. regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], IDR), ATMEL_TC_DEF_IRQS);
  376. }
  377. static int mchp_tc_irq_enable(struct counter_device *const counter, int irq)
  378. {
  379. struct mchp_tc_data *const priv = counter_priv(counter);
  380. int ret = devm_request_irq(counter->parent, irq, mchp_tc_isr, IRQF_SHARED,
  381. dev_name(counter->parent), counter);
  382. if (ret < 0)
  383. return ret;
  384. ret = regmap_write(priv->regmap, ATMEL_TC_REG(priv->channel[0], IER), ATMEL_TC_DEF_IRQS);
  385. if (ret < 0)
  386. return ret;
  387. ret = devm_add_action_or_reset(counter->parent, mchp_tc_irq_remove, priv);
  388. if (ret < 0)
  389. return ret;
  390. return 0;
  391. }
  392. static void mchp_tc_clk_remove(void *ptr)
  393. {
  394. clk_disable_unprepare((struct clk *)ptr);
  395. }
  396. static int mchp_tc_probe(struct platform_device *pdev)
  397. {
  398. struct device_node *np = pdev->dev.of_node;
  399. const struct atmel_tcb_config *tcb_config;
  400. const struct of_device_id *match;
  401. struct counter_device *counter;
  402. struct mchp_tc_data *priv;
  403. char clk_name[7];
  404. struct regmap *regmap;
  405. struct clk *clk[3];
  406. int channel;
  407. int ret, i;
  408. counter = devm_counter_alloc(&pdev->dev, sizeof(*priv));
  409. if (!counter)
  410. return -ENOMEM;
  411. priv = counter_priv(counter);
  412. match = of_match_node(atmel_tc_of_match, np->parent);
  413. tcb_config = match->data;
  414. if (!tcb_config) {
  415. dev_err(&pdev->dev, "No matching parent node found\n");
  416. return -ENODEV;
  417. }
  418. regmap = syscon_node_to_regmap(np->parent);
  419. if (IS_ERR(regmap))
  420. return PTR_ERR(regmap);
  421. /* max. channels number is 2 when in QDEC mode */
  422. priv->num_channels = of_property_count_u32_elems(np, "reg");
  423. if (priv->num_channels < 0) {
  424. dev_err(&pdev->dev, "Invalid or missing channel\n");
  425. return -EINVAL;
  426. }
  427. /* Register channels and initialize clocks */
  428. for (i = 0; i < priv->num_channels; i++) {
  429. ret = of_property_read_u32_index(np, "reg", i, &channel);
  430. if (ret < 0 || channel > 2)
  431. return -ENODEV;
  432. priv->channel[i] = channel;
  433. snprintf(clk_name, sizeof(clk_name), "t%d_clk", channel);
  434. clk[i] = of_clk_get_by_name(np->parent, clk_name);
  435. if (IS_ERR(clk[i])) {
  436. /* Fallback to t0_clk */
  437. clk[i] = of_clk_get_by_name(np->parent, "t0_clk");
  438. if (IS_ERR(clk[i]))
  439. return PTR_ERR(clk[i]);
  440. }
  441. ret = clk_prepare_enable(clk[i]);
  442. if (ret)
  443. return ret;
  444. ret = devm_add_action_or_reset(&pdev->dev,
  445. mchp_tc_clk_remove,
  446. clk[i]);
  447. if (ret)
  448. return ret;
  449. dev_dbg(&pdev->dev,
  450. "Initialized capture mode on channel %d\n",
  451. channel);
  452. }
  453. /* Disable Quadrature Decoder and position measure */
  454. ret = regmap_update_bits(regmap, ATMEL_TC_BMR, ATMEL_TC_QDEN | ATMEL_TC_POSEN, 0);
  455. if (ret)
  456. return ret;
  457. /* Setup the period capture mode */
  458. ret = regmap_update_bits(regmap, ATMEL_TC_REG(priv->channel[0], CMR),
  459. ATMEL_TC_WAVE | ATMEL_TC_ABETRG | ATMEL_TC_CMR_MASK |
  460. ATMEL_TC_TCCLKS,
  461. ATMEL_TC_CMR_MASK);
  462. if (ret)
  463. return ret;
  464. /* Enable clock and trigger counter */
  465. ret = regmap_write(regmap, ATMEL_TC_REG(priv->channel[0], CCR),
  466. ATMEL_TC_CLKEN | ATMEL_TC_SWTRG);
  467. if (ret)
  468. return ret;
  469. priv->tc_cfg = tcb_config;
  470. priv->regmap = regmap;
  471. counter->name = dev_name(&pdev->dev);
  472. counter->parent = &pdev->dev;
  473. counter->ops = &mchp_tc_ops;
  474. counter->num_counts = ARRAY_SIZE(mchp_tc_counts);
  475. counter->counts = mchp_tc_counts;
  476. counter->num_signals = ARRAY_SIZE(mchp_tc_count_signals);
  477. counter->signals = mchp_tc_count_signals;
  478. i = of_irq_get(np->parent, 0);
  479. if (i == -EPROBE_DEFER)
  480. return -EPROBE_DEFER;
  481. if (i > 0) {
  482. ret = mchp_tc_irq_enable(counter, i);
  483. if (ret < 0)
  484. return dev_err_probe(&pdev->dev, ret, "Failed to set up IRQ");
  485. }
  486. ret = devm_counter_add(&pdev->dev, counter);
  487. if (ret < 0)
  488. return dev_err_probe(&pdev->dev, ret, "Failed to add counter\n");
  489. return 0;
  490. }
  491. static const struct of_device_id mchp_tc_dt_ids[] = {
  492. { .compatible = "microchip,tcb-capture", },
  493. { /* sentinel */ },
  494. };
  495. MODULE_DEVICE_TABLE(of, mchp_tc_dt_ids);
  496. static struct platform_driver mchp_tc_driver = {
  497. .probe = mchp_tc_probe,
  498. .driver = {
  499. .name = "microchip-tcb-capture",
  500. .of_match_table = mchp_tc_dt_ids,
  501. },
  502. };
  503. module_platform_driver(mchp_tc_driver);
  504. MODULE_AUTHOR("Kamel Bouhara <kamel.bouhara@bootlin.com>");
  505. MODULE_DESCRIPTION("Microchip TCB Capture driver");
  506. MODULE_LICENSE("GPL v2");
  507. MODULE_IMPORT_NS("COUNTER");