ab5500-debugfs.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. /*
  2. * Copyright (C) 2011 ST-Ericsson
  3. * License terms: GNU General Public License (GPL) version 2
  4. * Debugfs support for the AB5500 MFD driver
  5. */
  6. #include <linux/module.h>
  7. #include <linux/debugfs.h>
  8. #include <linux/seq_file.h>
  9. #include <linux/mfd/abx500.h>
  10. #include <linux/mfd/abx500/ab5500.h>
  11. #include <linux/uaccess.h>
  12. #include "ab5500-core.h"
  13. #include "ab5500-debugfs.h"
  14. static struct ab5500_i2c_ranges ab5500_reg_ranges[AB5500_NUM_BANKS] = {
  15. [AB5500_BANK_LED] = {
  16. .bankid = AB5500_BANK_LED,
  17. .nranges = 1,
  18. .range = (struct ab5500_reg_range[]) {
  19. {
  20. .first = 0x00,
  21. .last = 0x0C,
  22. .perm = AB5500_PERM_RW,
  23. },
  24. },
  25. },
  26. [AB5500_BANK_ADC] = {
  27. .bankid = AB5500_BANK_ADC,
  28. .nranges = 6,
  29. .range = (struct ab5500_reg_range[]) {
  30. {
  31. .first = 0x1F,
  32. .last = 0x22,
  33. .perm = AB5500_PERM_RO,
  34. },
  35. {
  36. .first = 0x23,
  37. .last = 0x24,
  38. .perm = AB5500_PERM_RW,
  39. },
  40. {
  41. .first = 0x26,
  42. .last = 0x2D,
  43. .perm = AB5500_PERM_RO,
  44. },
  45. {
  46. .first = 0x2F,
  47. .last = 0x34,
  48. .perm = AB5500_PERM_RW,
  49. },
  50. {
  51. .first = 0x37,
  52. .last = 0x57,
  53. .perm = AB5500_PERM_RW,
  54. },
  55. {
  56. .first = 0x58,
  57. .last = 0x58,
  58. .perm = AB5500_PERM_RO,
  59. },
  60. },
  61. },
  62. [AB5500_BANK_RTC] = {
  63. .bankid = AB5500_BANK_RTC,
  64. .nranges = 2,
  65. .range = (struct ab5500_reg_range[]) {
  66. {
  67. .first = 0x00,
  68. .last = 0x04,
  69. .perm = AB5500_PERM_RW,
  70. },
  71. {
  72. .first = 0x06,
  73. .last = 0x0C,
  74. .perm = AB5500_PERM_RW,
  75. },
  76. },
  77. },
  78. [AB5500_BANK_STARTUP] = {
  79. .bankid = AB5500_BANK_STARTUP,
  80. .nranges = 12,
  81. .range = (struct ab5500_reg_range[]) {
  82. {
  83. .first = 0x00,
  84. .last = 0x01,
  85. .perm = AB5500_PERM_RW,
  86. },
  87. {
  88. .first = 0x1F,
  89. .last = 0x1F,
  90. .perm = AB5500_PERM_RW,
  91. },
  92. {
  93. .first = 0x2E,
  94. .last = 0x2E,
  95. .perm = AB5500_PERM_RO,
  96. },
  97. {
  98. .first = 0x2F,
  99. .last = 0x30,
  100. .perm = AB5500_PERM_RW,
  101. },
  102. {
  103. .first = 0x50,
  104. .last = 0x51,
  105. .perm = AB5500_PERM_RW,
  106. },
  107. {
  108. .first = 0x60,
  109. .last = 0x61,
  110. .perm = AB5500_PERM_RW,
  111. },
  112. {
  113. .first = 0x66,
  114. .last = 0x8A,
  115. .perm = AB5500_PERM_RW,
  116. },
  117. {
  118. .first = 0x8C,
  119. .last = 0x96,
  120. .perm = AB5500_PERM_RW,
  121. },
  122. {
  123. .first = 0xAA,
  124. .last = 0xB4,
  125. .perm = AB5500_PERM_RW,
  126. },
  127. {
  128. .first = 0xB7,
  129. .last = 0xBF,
  130. .perm = AB5500_PERM_RW,
  131. },
  132. {
  133. .first = 0xC1,
  134. .last = 0xCA,
  135. .perm = AB5500_PERM_RW,
  136. },
  137. {
  138. .first = 0xD3,
  139. .last = 0xE0,
  140. .perm = AB5500_PERM_RW,
  141. },
  142. },
  143. },
  144. [AB5500_BANK_DBI_ECI] = {
  145. .bankid = AB5500_BANK_DBI_ECI,
  146. .nranges = 3,
  147. .range = (struct ab5500_reg_range[]) {
  148. {
  149. .first = 0x00,
  150. .last = 0x07,
  151. .perm = AB5500_PERM_RW,
  152. },
  153. {
  154. .first = 0x10,
  155. .last = 0x10,
  156. .perm = AB5500_PERM_RW,
  157. },
  158. {
  159. .first = 0x13,
  160. .last = 0x13,
  161. .perm = AB5500_PERM_RW,
  162. },
  163. },
  164. },
  165. [AB5500_BANK_CHG] = {
  166. .bankid = AB5500_BANK_CHG,
  167. .nranges = 2,
  168. .range = (struct ab5500_reg_range[]) {
  169. {
  170. .first = 0x11,
  171. .last = 0x11,
  172. .perm = AB5500_PERM_RO,
  173. },
  174. {
  175. .first = 0x12,
  176. .last = 0x1B,
  177. .perm = AB5500_PERM_RW,
  178. },
  179. },
  180. },
  181. [AB5500_BANK_FG_BATTCOM_ACC] = {
  182. .bankid = AB5500_BANK_FG_BATTCOM_ACC,
  183. .nranges = 2,
  184. .range = (struct ab5500_reg_range[]) {
  185. {
  186. .first = 0x00,
  187. .last = 0x0B,
  188. .perm = AB5500_PERM_RO,
  189. },
  190. {
  191. .first = 0x0C,
  192. .last = 0x10,
  193. .perm = AB5500_PERM_RW,
  194. },
  195. },
  196. },
  197. [AB5500_BANK_USB] = {
  198. .bankid = AB5500_BANK_USB,
  199. .nranges = 12,
  200. .range = (struct ab5500_reg_range[]) {
  201. {
  202. .first = 0x01,
  203. .last = 0x01,
  204. .perm = AB5500_PERM_RW,
  205. },
  206. {
  207. .first = 0x80,
  208. .last = 0x83,
  209. .perm = AB5500_PERM_RW,
  210. },
  211. {
  212. .first = 0x87,
  213. .last = 0x8A,
  214. .perm = AB5500_PERM_RW,
  215. },
  216. {
  217. .first = 0x8B,
  218. .last = 0x8B,
  219. .perm = AB5500_PERM_RO,
  220. },
  221. {
  222. .first = 0x91,
  223. .last = 0x92,
  224. .perm = AB5500_PERM_RO,
  225. },
  226. {
  227. .first = 0x93,
  228. .last = 0x93,
  229. .perm = AB5500_PERM_RW,
  230. },
  231. {
  232. .first = 0x94,
  233. .last = 0x94,
  234. .perm = AB5500_PERM_RO,
  235. },
  236. {
  237. .first = 0xA8,
  238. .last = 0xB0,
  239. .perm = AB5500_PERM_RO,
  240. },
  241. {
  242. .first = 0xB2,
  243. .last = 0xB2,
  244. .perm = AB5500_PERM_RO,
  245. },
  246. {
  247. .first = 0xB4,
  248. .last = 0xBC,
  249. .perm = AB5500_PERM_RO,
  250. },
  251. {
  252. .first = 0xBF,
  253. .last = 0xBF,
  254. .perm = AB5500_PERM_RO,
  255. },
  256. {
  257. .first = 0xC1,
  258. .last = 0xC5,
  259. .perm = AB5500_PERM_RO,
  260. },
  261. },
  262. },
  263. [AB5500_BANK_IT] = {
  264. .bankid = AB5500_BANK_IT,
  265. .nranges = 4,
  266. .range = (struct ab5500_reg_range[]) {
  267. {
  268. .first = 0x00,
  269. .last = 0x02,
  270. .perm = AB5500_PERM_RO,
  271. },
  272. {
  273. .first = 0x20,
  274. .last = 0x36,
  275. .perm = AB5500_PERM_RO,
  276. },
  277. {
  278. .first = 0x40,
  279. .last = 0x56,
  280. .perm = AB5500_PERM_RO,
  281. },
  282. {
  283. .first = 0x60,
  284. .last = 0x76,
  285. .perm = AB5500_PERM_RO,
  286. },
  287. },
  288. },
  289. [AB5500_BANK_VDDDIG_IO_I2C_CLK_TST] = {
  290. .bankid = AB5500_BANK_VDDDIG_IO_I2C_CLK_TST,
  291. .nranges = 7,
  292. .range = (struct ab5500_reg_range[]) {
  293. {
  294. .first = 0x02,
  295. .last = 0x02,
  296. .perm = AB5500_PERM_RW,
  297. },
  298. {
  299. .first = 0x12,
  300. .last = 0x12,
  301. .perm = AB5500_PERM_RW,
  302. },
  303. {
  304. .first = 0x30,
  305. .last = 0x34,
  306. .perm = AB5500_PERM_RW,
  307. },
  308. {
  309. .first = 0x40,
  310. .last = 0x44,
  311. .perm = AB5500_PERM_RW,
  312. },
  313. {
  314. .first = 0x50,
  315. .last = 0x54,
  316. .perm = AB5500_PERM_RW,
  317. },
  318. {
  319. .first = 0x60,
  320. .last = 0x64,
  321. .perm = AB5500_PERM_RW,
  322. },
  323. {
  324. .first = 0x70,
  325. .last = 0x74,
  326. .perm = AB5500_PERM_RW,
  327. },
  328. },
  329. },
  330. [AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP] = {
  331. .bankid = AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP,
  332. .nranges = 13,
  333. .range = (struct ab5500_reg_range[]) {
  334. {
  335. .first = 0x01,
  336. .last = 0x01,
  337. .perm = AB5500_PERM_RW,
  338. },
  339. {
  340. .first = 0x02,
  341. .last = 0x02,
  342. .perm = AB5500_PERM_RO,
  343. },
  344. {
  345. .first = 0x0D,
  346. .last = 0x0F,
  347. .perm = AB5500_PERM_RW,
  348. },
  349. {
  350. .first = 0x1C,
  351. .last = 0x1C,
  352. .perm = AB5500_PERM_RW,
  353. },
  354. {
  355. .first = 0x1E,
  356. .last = 0x1E,
  357. .perm = AB5500_PERM_RW,
  358. },
  359. {
  360. .first = 0x20,
  361. .last = 0x21,
  362. .perm = AB5500_PERM_RW,
  363. },
  364. {
  365. .first = 0x25,
  366. .last = 0x25,
  367. .perm = AB5500_PERM_RW,
  368. },
  369. {
  370. .first = 0x28,
  371. .last = 0x2A,
  372. .perm = AB5500_PERM_RW,
  373. },
  374. {
  375. .first = 0x30,
  376. .last = 0x33,
  377. .perm = AB5500_PERM_RW,
  378. },
  379. {
  380. .first = 0x40,
  381. .last = 0x43,
  382. .perm = AB5500_PERM_RW,
  383. },
  384. {
  385. .first = 0x50,
  386. .last = 0x53,
  387. .perm = AB5500_PERM_RW,
  388. },
  389. {
  390. .first = 0x60,
  391. .last = 0x63,
  392. .perm = AB5500_PERM_RW,
  393. },
  394. {
  395. .first = 0x70,
  396. .last = 0x73,
  397. .perm = AB5500_PERM_RW,
  398. },
  399. },
  400. },
  401. [AB5500_BANK_VIBRA] = {
  402. .bankid = AB5500_BANK_VIBRA,
  403. .nranges = 2,
  404. .range = (struct ab5500_reg_range[]) {
  405. {
  406. .first = 0x10,
  407. .last = 0x13,
  408. .perm = AB5500_PERM_RW,
  409. },
  410. {
  411. .first = 0xFE,
  412. .last = 0xFE,
  413. .perm = AB5500_PERM_RW,
  414. },
  415. },
  416. },
  417. [AB5500_BANK_AUDIO_HEADSETUSB] = {
  418. .bankid = AB5500_BANK_AUDIO_HEADSETUSB,
  419. .nranges = 2,
  420. .range = (struct ab5500_reg_range[]) {
  421. {
  422. .first = 0x00,
  423. .last = 0x48,
  424. .perm = AB5500_PERM_RW,
  425. },
  426. {
  427. .first = 0xEB,
  428. .last = 0xFB,
  429. .perm = AB5500_PERM_RW,
  430. },
  431. },
  432. },
  433. [AB5500_BANK_SIM_USBSIM] = {
  434. .bankid = AB5500_BANK_SIM_USBSIM,
  435. .nranges = 1,
  436. .range = (struct ab5500_reg_range[]) {
  437. {
  438. .first = 0x13,
  439. .last = 0x19,
  440. .perm = AB5500_PERM_RW,
  441. },
  442. },
  443. },
  444. [AB5500_BANK_VDENC] = {
  445. .bankid = AB5500_BANK_VDENC,
  446. .nranges = 12,
  447. .range = (struct ab5500_reg_range[]) {
  448. {
  449. .first = 0x00,
  450. .last = 0x08,
  451. .perm = AB5500_PERM_RW,
  452. },
  453. {
  454. .first = 0x09,
  455. .last = 0x09,
  456. .perm = AB5500_PERM_RO,
  457. },
  458. {
  459. .first = 0x0A,
  460. .last = 0x12,
  461. .perm = AB5500_PERM_RW,
  462. },
  463. {
  464. .first = 0x15,
  465. .last = 0x19,
  466. .perm = AB5500_PERM_RW,
  467. },
  468. {
  469. .first = 0x1B,
  470. .last = 0x21,
  471. .perm = AB5500_PERM_RW,
  472. },
  473. {
  474. .first = 0x27,
  475. .last = 0x2C,
  476. .perm = AB5500_PERM_RW,
  477. },
  478. {
  479. .first = 0x41,
  480. .last = 0x41,
  481. .perm = AB5500_PERM_RW,
  482. },
  483. {
  484. .first = 0x45,
  485. .last = 0x5B,
  486. .perm = AB5500_PERM_RW,
  487. },
  488. {
  489. .first = 0x5D,
  490. .last = 0x5D,
  491. .perm = AB5500_PERM_RW,
  492. },
  493. {
  494. .first = 0x69,
  495. .last = 0x69,
  496. .perm = AB5500_PERM_RW,
  497. },
  498. {
  499. .first = 0x6C,
  500. .last = 0x6D,
  501. .perm = AB5500_PERM_RW,
  502. },
  503. {
  504. .first = 0x80,
  505. .last = 0x81,
  506. .perm = AB5500_PERM_RW,
  507. },
  508. },
  509. },
  510. };
  511. static int ab5500_registers_print(struct seq_file *s, void *p)
  512. {
  513. struct ab5500 *ab = s->private;
  514. unsigned int i;
  515. u8 bank = (u8)ab->debug_bank;
  516. seq_printf(s, "ab5500 register values:\n");
  517. for (bank = 0; bank < AB5500_NUM_BANKS; bank++) {
  518. seq_printf(s, " bank %u, %s (0x%x):\n", bank,
  519. bankinfo[bank].name,
  520. bankinfo[bank].slave_addr);
  521. for (i = 0; i < ab5500_reg_ranges[bank].nranges; i++) {
  522. u8 reg;
  523. int err;
  524. for (reg = ab5500_reg_ranges[bank].range[i].first;
  525. reg <= ab5500_reg_ranges[bank].range[i].last;
  526. reg++) {
  527. u8 value;
  528. err = ab5500_get_register_interruptible_raw(ab,
  529. bank, reg,
  530. &value);
  531. if (err < 0) {
  532. dev_err(ab->dev, "get_reg failed %d"
  533. "bank 0x%x reg 0x%x\n",
  534. err, bank, reg);
  535. return err;
  536. }
  537. err = seq_printf(s, "[%d/0x%02X]: 0x%02X\n",
  538. bank, reg, value);
  539. if (err < 0) {
  540. dev_err(ab->dev,
  541. "seq_printf overflow\n");
  542. /*
  543. * Error is not returned here since
  544. * the output is wanted in any case
  545. */
  546. return 0;
  547. }
  548. }
  549. }
  550. }
  551. return 0;
  552. }
  553. static int ab5500_registers_open(struct inode *inode, struct file *file)
  554. {
  555. return single_open(file, ab5500_registers_print, inode->i_private);
  556. }
  557. static const struct file_operations ab5500_registers_fops = {
  558. .open = ab5500_registers_open,
  559. .read = seq_read,
  560. .llseek = seq_lseek,
  561. .release = single_release,
  562. .owner = THIS_MODULE,
  563. };
  564. static int ab5500_bank_print(struct seq_file *s, void *p)
  565. {
  566. struct ab5500 *ab = s->private;
  567. seq_printf(s, "%d\n", ab->debug_bank);
  568. return 0;
  569. }
  570. static int ab5500_bank_open(struct inode *inode, struct file *file)
  571. {
  572. return single_open(file, ab5500_bank_print, inode->i_private);
  573. }
  574. static ssize_t ab5500_bank_write(struct file *file,
  575. const char __user *user_buf,
  576. size_t count, loff_t *ppos)
  577. {
  578. struct ab5500 *ab = ((struct seq_file *)(file->private_data))->private;
  579. char buf[32];
  580. int buf_size;
  581. unsigned long user_bank;
  582. int err;
  583. /* Get userspace string and assure termination */
  584. buf_size = min(count, (sizeof(buf) - 1));
  585. if (copy_from_user(buf, user_buf, buf_size))
  586. return -EFAULT;
  587. buf[buf_size] = 0;
  588. err = strict_strtoul(buf, 0, &user_bank);
  589. if (err)
  590. return -EINVAL;
  591. if (user_bank >= AB5500_NUM_BANKS) {
  592. dev_err(ab->dev,
  593. "debugfs error input > number of banks\n");
  594. return -EINVAL;
  595. }
  596. ab->debug_bank = user_bank;
  597. return buf_size;
  598. }
  599. static int ab5500_address_print(struct seq_file *s, void *p)
  600. {
  601. struct ab5500 *ab = s->private;
  602. seq_printf(s, "0x%02X\n", ab->debug_address);
  603. return 0;
  604. }
  605. static int ab5500_address_open(struct inode *inode, struct file *file)
  606. {
  607. return single_open(file, ab5500_address_print, inode->i_private);
  608. }
  609. static ssize_t ab5500_address_write(struct file *file,
  610. const char __user *user_buf,
  611. size_t count, loff_t *ppos)
  612. {
  613. struct ab5500 *ab = ((struct seq_file *)(file->private_data))->private;
  614. char buf[32];
  615. int buf_size;
  616. unsigned long user_address;
  617. int err;
  618. /* Get userspace string and assure termination */
  619. buf_size = min(count, (sizeof(buf) - 1));
  620. if (copy_from_user(buf, user_buf, buf_size))
  621. return -EFAULT;
  622. buf[buf_size] = 0;
  623. err = strict_strtoul(buf, 0, &user_address);
  624. if (err)
  625. return -EINVAL;
  626. if (user_address > 0xff) {
  627. dev_err(ab->dev,
  628. "debugfs error input > 0xff\n");
  629. return -EINVAL;
  630. }
  631. ab->debug_address = user_address;
  632. return buf_size;
  633. }
  634. static int ab5500_val_print(struct seq_file *s, void *p)
  635. {
  636. struct ab5500 *ab = s->private;
  637. int err;
  638. u8 regvalue;
  639. err = ab5500_get_register_interruptible_raw(ab, (u8)ab->debug_bank,
  640. (u8)ab->debug_address, &regvalue);
  641. if (err) {
  642. dev_err(ab->dev, "get_reg failed %d, bank 0x%x"
  643. ", reg 0x%x\n", err, ab->debug_bank,
  644. ab->debug_address);
  645. return -EINVAL;
  646. }
  647. seq_printf(s, "0x%02X\n", regvalue);
  648. return 0;
  649. }
  650. static int ab5500_val_open(struct inode *inode, struct file *file)
  651. {
  652. return single_open(file, ab5500_val_print, inode->i_private);
  653. }
  654. static ssize_t ab5500_val_write(struct file *file,
  655. const char __user *user_buf,
  656. size_t count, loff_t *ppos)
  657. {
  658. struct ab5500 *ab = ((struct seq_file *)(file->private_data))->private;
  659. char buf[32];
  660. int buf_size;
  661. unsigned long user_val;
  662. int err;
  663. u8 regvalue;
  664. /* Get userspace string and assure termination */
  665. buf_size = min(count, (sizeof(buf)-1));
  666. if (copy_from_user(buf, user_buf, buf_size))
  667. return -EFAULT;
  668. buf[buf_size] = 0;
  669. err = strict_strtoul(buf, 0, &user_val);
  670. if (err)
  671. return -EINVAL;
  672. if (user_val > 0xff) {
  673. dev_err(ab->dev,
  674. "debugfs error input > 0xff\n");
  675. return -EINVAL;
  676. }
  677. err = ab5500_mask_and_set_register_interruptible_raw(
  678. ab, (u8)ab->debug_bank,
  679. (u8)ab->debug_address, 0xFF, (u8)user_val);
  680. if (err)
  681. return -EINVAL;
  682. ab5500_get_register_interruptible_raw(ab, (u8)ab->debug_bank,
  683. (u8)ab->debug_address, &regvalue);
  684. if (err)
  685. return -EINVAL;
  686. return buf_size;
  687. }
  688. static const struct file_operations ab5500_bank_fops = {
  689. .open = ab5500_bank_open,
  690. .write = ab5500_bank_write,
  691. .read = seq_read,
  692. .llseek = seq_lseek,
  693. .release = single_release,
  694. .owner = THIS_MODULE,
  695. };
  696. static const struct file_operations ab5500_address_fops = {
  697. .open = ab5500_address_open,
  698. .write = ab5500_address_write,
  699. .read = seq_read,
  700. .llseek = seq_lseek,
  701. .release = single_release,
  702. .owner = THIS_MODULE,
  703. };
  704. static const struct file_operations ab5500_val_fops = {
  705. .open = ab5500_val_open,
  706. .write = ab5500_val_write,
  707. .read = seq_read,
  708. .llseek = seq_lseek,
  709. .release = single_release,
  710. .owner = THIS_MODULE,
  711. };
  712. static struct dentry *ab5500_dir;
  713. static struct dentry *ab5500_reg_file;
  714. static struct dentry *ab5500_bank_file;
  715. static struct dentry *ab5500_address_file;
  716. static struct dentry *ab5500_val_file;
  717. void __init ab5500_setup_debugfs(struct ab5500 *ab)
  718. {
  719. ab->debug_bank = AB5500_BANK_VIT_IO_I2C_CLK_TST_OTP;
  720. ab->debug_address = AB5500_CHIP_ID;
  721. ab5500_dir = debugfs_create_dir("ab5500", NULL);
  722. if (!ab5500_dir)
  723. goto exit_no_debugfs;
  724. ab5500_reg_file = debugfs_create_file("all-bank-registers",
  725. S_IRUGO, ab5500_dir, ab, &ab5500_registers_fops);
  726. if (!ab5500_reg_file)
  727. goto exit_destroy_dir;
  728. ab5500_bank_file = debugfs_create_file("register-bank",
  729. (S_IRUGO | S_IWUGO), ab5500_dir, ab, &ab5500_bank_fops);
  730. if (!ab5500_bank_file)
  731. goto exit_destroy_reg;
  732. ab5500_address_file = debugfs_create_file("register-address",
  733. (S_IRUGO | S_IWUGO), ab5500_dir, ab, &ab5500_address_fops);
  734. if (!ab5500_address_file)
  735. goto exit_destroy_bank;
  736. ab5500_val_file = debugfs_create_file("register-value",
  737. (S_IRUGO | S_IWUGO), ab5500_dir, ab, &ab5500_val_fops);
  738. if (!ab5500_val_file)
  739. goto exit_destroy_address;
  740. return;
  741. exit_destroy_address:
  742. debugfs_remove(ab5500_address_file);
  743. exit_destroy_bank:
  744. debugfs_remove(ab5500_bank_file);
  745. exit_destroy_reg:
  746. debugfs_remove(ab5500_reg_file);
  747. exit_destroy_dir:
  748. debugfs_remove(ab5500_dir);
  749. exit_no_debugfs:
  750. dev_err(ab->dev, "failed to create debugfs entries.\n");
  751. return;
  752. }
  753. void __exit ab5500_remove_debugfs(void)
  754. {
  755. debugfs_remove(ab5500_val_file);
  756. debugfs_remove(ab5500_address_file);
  757. debugfs_remove(ab5500_bank_file);
  758. debugfs_remove(ab5500_reg_file);
  759. debugfs_remove(ab5500_dir);
  760. }