usb20_phy_debugfs.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>
  4. #include <linux/debugfs.h>
  5. #include <linux/seq_file.h>
  6. #include <asm/uaccess.h>
  7. #include "musb_core.h"
  8. #include "musb_debug.h"
  9. #include "mtk_musb.h"
  10. #define MYDBG(fmt, args...) pr_warn("MTK_ICUSB [DBG], <%s(), %d> " fmt, __func__, __LINE__, ## args)
  11. /* general */
  12. #define BIT_WIDTH_1 1
  13. #define MSK_WIDTH_1 0x1
  14. #define VAL_MAX_WDITH_1 0x1
  15. #define VAL_0_WIDTH_1 0x0
  16. #define VAL_1_WIDTH_1 0x1
  17. #define STRNG_0_WIDTH_1 "0"
  18. #define STRNG_1_WIDTH_1 "1"
  19. #define BIT_WIDTH_3 3
  20. #define MSK_WIDTH_3 0x7
  21. #define VAL_MAX_WDITH_3 0x7
  22. #define VAL_0_WIDTH_3 0x0
  23. #define VAL_1_WIDTH_3 0x1
  24. #define VAL_2_WIDTH_3 0x2
  25. #define VAL_3_WIDTH_3 0x3
  26. #define VAL_4_WIDTH_3 0x4
  27. #define VAL_5_WIDTH_3 0x5
  28. #define VAL_6_WIDTH_3 0x6
  29. #define VAL_7_WIDTH_3 0x7
  30. #define STRNG_0_WIDTH_3 "000"
  31. #define STRNG_1_WIDTH_3 "001"
  32. #define STRNG_2_WIDTH_3 "010"
  33. #define STRNG_3_WIDTH_3 "011"
  34. #define STRNG_4_WIDTH_3 "100"
  35. #define STRNG_5_WIDTH_3 "101"
  36. #define STRNG_6_WIDTH_3 "110"
  37. #define STRNG_7_WIDTH_3 "111"
  38. /* specific */
  39. #define FILE_USB_DRIVING_CAPABILITY "USB_DRIVING_CAPABILITY"
  40. #define FILE_RG_USB20_TERM_VREF_SEL "RG_USB20_TERM_VREF_SEL"
  41. #define MSK_RG_USB20_TERM_VREF_SEL MSK_WIDTH_3
  42. #define SHFT_RG_USB20_TERM_VREF_SEL 0
  43. #define OFFSET_RG_USB20_TERM_VREF_SEL 0x5
  44. #define FILE_RG_USB20_HSTX_SRCTRL "RG_USB20_HSTX_SRCTRL"
  45. #define MSK_RG_USB20_HSTX_SRCTRL MSK_WIDTH_3
  46. #define SHFT_RG_USB20_HSTX_SRCTRL 4
  47. #define OFFSET_RG_USB20_HSTX_SRCTRL 0x15
  48. #define FILE_RG_USB20_VRT_VREF_SEL "RG_USB20_VRT_VREF_SEL"
  49. #define MSK_RG_USB20_VRT_VREF_SEL MSK_WIDTH_3
  50. #define SHFT_RG_USB20_VRT_VREF_SEL 4
  51. #define OFFSET_RG_USB20_VRT_VREF_SEL 0x5
  52. #define FILE_RG_USB20_INTR_EN "RG_USB20_INTR_EN"
  53. #define MSK_RG_USB20_INTR_EN MSK_WIDTH_1
  54. #define SHFT_RG_USB20_INTR_EN 5
  55. #define OFFSET_RG_USB20_INTR_EN 0x0
  56. static struct dentry *usb20_phy_debugfs_root;
  57. void usb20_phy_debugfs_write_width1(u8 offset, u8 shift, char *buf)
  58. {
  59. u8 clr_val = 0, set_val = 0;
  60. MYDBG("s(%s)\n", buf);
  61. if (!strncmp(buf, STRNG_0_WIDTH_1, BIT_WIDTH_1)) {
  62. MYDBG("%s case\n", STRNG_0_WIDTH_1);
  63. clr_val = VAL_1_WIDTH_1;
  64. }
  65. if (!strncmp(buf, STRNG_1_WIDTH_1, BIT_WIDTH_1)) {
  66. MYDBG("%s case\n", STRNG_1_WIDTH_1);
  67. set_val = VAL_1_WIDTH_1;
  68. }
  69. if (clr_val || set_val) {
  70. clr_val = VAL_MAX_WDITH_1 - set_val;
  71. MYDBG("offset:%x, clr_val:%x, set_val:%x, before shft\n", offset, clr_val, set_val);
  72. clr_val <<= shift;
  73. set_val <<= shift;
  74. MYDBG("offset:%x, clr_val:%x, set_val:%x, after shft\n", offset, clr_val, set_val);
  75. USBPHY_CLR8(offset, clr_val);
  76. USBPHY_SET8(offset, set_val);
  77. } else {
  78. MYDBG("do nothing\n");
  79. }
  80. }
  81. void usb20_phy_debugfs_write_width3(u8 offset, u8 shift, char *buf)
  82. {
  83. u8 clr_val = 0, set_val = 0;
  84. MYDBG("s(%s)\n", buf);
  85. if (!strncmp(buf, STRNG_0_WIDTH_3, BIT_WIDTH_3)) {
  86. MYDBG("%s case\n", STRNG_0_WIDTH_3);
  87. clr_val = VAL_7_WIDTH_3;
  88. }
  89. if (!strncmp(buf, STRNG_1_WIDTH_3, BIT_WIDTH_3)) {
  90. MYDBG("%s case\n", STRNG_1_WIDTH_3);
  91. set_val = VAL_1_WIDTH_3;
  92. }
  93. if (!strncmp(buf, STRNG_2_WIDTH_3, BIT_WIDTH_3)) {
  94. MYDBG("%s case\n", STRNG_2_WIDTH_3);
  95. set_val = VAL_2_WIDTH_3;
  96. }
  97. if (!strncmp(buf, STRNG_3_WIDTH_3, BIT_WIDTH_3)) {
  98. MYDBG("%s case\n", STRNG_3_WIDTH_3);
  99. set_val = VAL_3_WIDTH_3;
  100. }
  101. if (!strncmp(buf, STRNG_4_WIDTH_3, BIT_WIDTH_3)) {
  102. MYDBG("%s case\n", STRNG_4_WIDTH_3);
  103. set_val = VAL_4_WIDTH_3;
  104. }
  105. if (!strncmp(buf, STRNG_5_WIDTH_3, BIT_WIDTH_3)) {
  106. MYDBG("%s case\n", STRNG_5_WIDTH_3);
  107. set_val = VAL_5_WIDTH_3;
  108. }
  109. if (!strncmp(buf, STRNG_6_WIDTH_3, BIT_WIDTH_3)) {
  110. MYDBG("%s case\n", STRNG_6_WIDTH_3);
  111. set_val = VAL_6_WIDTH_3;
  112. }
  113. if (!strncmp(buf, STRNG_7_WIDTH_3, BIT_WIDTH_3)) {
  114. MYDBG("%s case\n", STRNG_7_WIDTH_3);
  115. set_val = VAL_7_WIDTH_3;
  116. }
  117. if (clr_val || set_val) {
  118. clr_val = VAL_MAX_WDITH_3 - set_val;
  119. MYDBG("offset:%x, clr_val:%x, set_val:%x, before shft\n", offset, clr_val, set_val);
  120. clr_val <<= shift;
  121. set_val <<= shift;
  122. MYDBG("offset:%x, clr_val:%x, set_val:%x, after shft\n", offset, clr_val, set_val);
  123. USBPHY_CLR8(offset, clr_val);
  124. USBPHY_SET8(offset, set_val);
  125. } else {
  126. MYDBG("do nothing\n");
  127. }
  128. }
  129. u8 usb20_phy_debugfs_read_val(u8 offset, u8 shft, u8 msk, u8 width, char *str)
  130. {
  131. u8 val;
  132. int i, temp;
  133. val = USBPHY_READ8(offset);
  134. MYDBG("offset:%x, val:%x, shft:%x, msk:%x\n", offset, val, shft, msk);
  135. val = val >> shft;
  136. MYDBG("offset:%x, val:%x, shft:%x, msk:%x\n", offset, val, shft, msk);
  137. val = val & msk;
  138. MYDBG("offset:%x, val:%x, shft:%x, msk:%x\n", offset, val, shft, msk);
  139. temp = val;
  140. str[width] = '\0';
  141. for (i = (width - 1); i >= 0; i--) {
  142. if (val % 2)
  143. str[i] = '1';
  144. else
  145. str[i] = '0';
  146. MYDBG("str[%d]:%c\n", i, str[i]);
  147. val /= 2;
  148. }
  149. MYDBG("str(%s)\n", str);
  150. return val;
  151. }
  152. static int usb_driving_capability_show(struct seq_file *s, void *unused)
  153. {
  154. u8 val;
  155. char str[16];
  156. u8 combined_val, tmp_val = 0xff;
  157. val = usb20_phy_debugfs_read_val(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
  158. MSK_RG_USB20_TERM_VREF_SEL, BIT_WIDTH_3, str);
  159. if (!strncmp(str, STRNG_0_WIDTH_3, BIT_WIDTH_3)) {
  160. MYDBG("%s case\n", STRNG_0_WIDTH_3);
  161. tmp_val = VAL_0_WIDTH_3;
  162. }
  163. if (!strncmp(str, STRNG_1_WIDTH_3, BIT_WIDTH_3)) {
  164. MYDBG("%s case\n", STRNG_1_WIDTH_3);
  165. tmp_val = VAL_1_WIDTH_3;
  166. }
  167. if (!strncmp(str, STRNG_2_WIDTH_3, BIT_WIDTH_3)) {
  168. MYDBG("%s case\n", STRNG_2_WIDTH_3);
  169. tmp_val = VAL_2_WIDTH_3;
  170. }
  171. if (!strncmp(str, STRNG_3_WIDTH_3, BIT_WIDTH_3)) {
  172. MYDBG("%s case\n", STRNG_3_WIDTH_3);
  173. tmp_val = VAL_3_WIDTH_3;
  174. }
  175. if (!strncmp(str, STRNG_4_WIDTH_3, BIT_WIDTH_3)) {
  176. MYDBG("%s case\n", STRNG_4_WIDTH_3);
  177. tmp_val = VAL_4_WIDTH_3;
  178. }
  179. if (!strncmp(str, STRNG_5_WIDTH_3, BIT_WIDTH_3)) {
  180. MYDBG("%s case\n", STRNG_5_WIDTH_3);
  181. tmp_val = VAL_5_WIDTH_3;
  182. }
  183. if (!strncmp(str, STRNG_6_WIDTH_3, BIT_WIDTH_3)) {
  184. MYDBG("%s case\n", STRNG_6_WIDTH_3);
  185. tmp_val = VAL_6_WIDTH_3;
  186. }
  187. if (!strncmp(str, STRNG_7_WIDTH_3, BIT_WIDTH_3)) {
  188. MYDBG("%s case\n", STRNG_7_WIDTH_3);
  189. tmp_val = VAL_7_WIDTH_3;
  190. }
  191. combined_val = tmp_val;
  192. val = usb20_phy_debugfs_read_val(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
  193. MSK_RG_USB20_VRT_VREF_SEL, BIT_WIDTH_3, str);
  194. if (!strncmp(str, STRNG_0_WIDTH_3, BIT_WIDTH_3)) {
  195. MYDBG("%s case\n", STRNG_0_WIDTH_3);
  196. tmp_val = VAL_0_WIDTH_3;
  197. }
  198. if (!strncmp(str, STRNG_1_WIDTH_3, BIT_WIDTH_3)) {
  199. MYDBG("%s case\n", STRNG_1_WIDTH_3);
  200. tmp_val = VAL_1_WIDTH_3;
  201. }
  202. if (!strncmp(str, STRNG_2_WIDTH_3, BIT_WIDTH_3)) {
  203. MYDBG("%s case\n", STRNG_2_WIDTH_3);
  204. tmp_val = VAL_2_WIDTH_3;
  205. }
  206. if (!strncmp(str, STRNG_3_WIDTH_3, BIT_WIDTH_3)) {
  207. MYDBG("%s case\n", STRNG_3_WIDTH_3);
  208. tmp_val = VAL_3_WIDTH_3;
  209. }
  210. if (!strncmp(str, STRNG_4_WIDTH_3, BIT_WIDTH_3)) {
  211. MYDBG("%s case\n", STRNG_4_WIDTH_3);
  212. tmp_val = VAL_4_WIDTH_3;
  213. }
  214. if (!strncmp(str, STRNG_5_WIDTH_3, BIT_WIDTH_3)) {
  215. MYDBG("%s case\n", STRNG_5_WIDTH_3);
  216. tmp_val = VAL_5_WIDTH_3;
  217. }
  218. if (!strncmp(str, STRNG_6_WIDTH_3, BIT_WIDTH_3)) {
  219. MYDBG("%s case\n", STRNG_6_WIDTH_3);
  220. tmp_val = VAL_6_WIDTH_3;
  221. }
  222. if (!strncmp(str, STRNG_7_WIDTH_3, BIT_WIDTH_3)) {
  223. MYDBG("%s case\n", STRNG_7_WIDTH_3);
  224. tmp_val = VAL_7_WIDTH_3;
  225. }
  226. MYDBG("combined_val(%d), tmp_val(%d)\n", combined_val, tmp_val);
  227. if ((tmp_val == (combined_val - 1)) || (tmp_val == combined_val))
  228. combined_val += tmp_val;
  229. else
  230. combined_val = tmp_val * (VAL_MAX_WDITH_3 + 1) + combined_val;
  231. MYDBG("combined_val(%d), tmp_val(%d)\n", combined_val, tmp_val);
  232. seq_printf(s, "%d", combined_val);
  233. return 0;
  234. }
  235. static int rg_usb20_term_vref_sel_show(struct seq_file *s, void *unused)
  236. {
  237. u8 val;
  238. char str[16];
  239. val =
  240. usb20_phy_debugfs_read_val(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
  241. MSK_RG_USB20_TERM_VREF_SEL, BIT_WIDTH_3, str);
  242. seq_printf(s, "%s", str);
  243. return 0;
  244. }
  245. static int rg_usb20_hstx_srctrl_show(struct seq_file *s, void *unused)
  246. {
  247. u8 val;
  248. char str[16];
  249. val =
  250. usb20_phy_debugfs_read_val(OFFSET_RG_USB20_HSTX_SRCTRL, SHFT_RG_USB20_HSTX_SRCTRL,
  251. MSK_RG_USB20_HSTX_SRCTRL, BIT_WIDTH_3, str);
  252. seq_printf(s, "%s", str);
  253. return 0;
  254. }
  255. static int rg_usb20_vrt_vref_sel_show(struct seq_file *s, void *unused)
  256. {
  257. u8 val;
  258. char str[16];
  259. val =
  260. usb20_phy_debugfs_read_val(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
  261. MSK_RG_USB20_VRT_VREF_SEL, BIT_WIDTH_3, str);
  262. seq_printf(s, "%s", str);
  263. return 0;
  264. }
  265. static int rg_usb20_intr_en_show(struct seq_file *s, void *unused)
  266. {
  267. u8 val;
  268. char str[16];
  269. val =
  270. usb20_phy_debugfs_read_val(OFFSET_RG_USB20_INTR_EN, SHFT_RG_USB20_INTR_EN,
  271. MSK_RG_USB20_INTR_EN, BIT_WIDTH_1, str);
  272. seq_printf(s, "%s", str);
  273. return 0;
  274. }
  275. static int usb_driving_capability_open(struct inode *inode, struct file *file)
  276. {
  277. return single_open(file, usb_driving_capability_show, inode->i_private);
  278. }
  279. static int rg_usb20_term_vref_sel_open(struct inode *inode, struct file *file)
  280. {
  281. return single_open(file, rg_usb20_term_vref_sel_show, inode->i_private);
  282. }
  283. static int rg_usb20_hstx_srctrl_open(struct inode *inode, struct file *file)
  284. {
  285. return single_open(file, rg_usb20_hstx_srctrl_show, inode->i_private);
  286. }
  287. static int rg_usb20_vrt_vref_sel_open(struct inode *inode, struct file *file)
  288. {
  289. return single_open(file, rg_usb20_vrt_vref_sel_show, inode->i_private);
  290. }
  291. static int rg_usb20_intr_en_open(struct inode *inode, struct file *file)
  292. {
  293. return single_open(file, rg_usb20_intr_en_show, inode->i_private);
  294. }
  295. void val_to_bstring_width3(u8 val, char *str)
  296. {
  297. if (val == VAL_0_WIDTH_3)
  298. memcpy(str, STRNG_0_WIDTH_3, BIT_WIDTH_3 + 1);
  299. if (val == VAL_1_WIDTH_3)
  300. memcpy(str, STRNG_1_WIDTH_3, BIT_WIDTH_3 + 1);
  301. if (val == VAL_2_WIDTH_3)
  302. memcpy(str, STRNG_2_WIDTH_3, BIT_WIDTH_3 + 1);
  303. if (val == VAL_3_WIDTH_3)
  304. memcpy(str, STRNG_3_WIDTH_3, BIT_WIDTH_3 + 1);
  305. if (val == VAL_4_WIDTH_3)
  306. memcpy(str, STRNG_4_WIDTH_3, BIT_WIDTH_3 + 1);
  307. if (val == VAL_5_WIDTH_3)
  308. memcpy(str, STRNG_5_WIDTH_3, BIT_WIDTH_3 + 1);
  309. if (val == VAL_6_WIDTH_3)
  310. memcpy(str, STRNG_6_WIDTH_3, BIT_WIDTH_3 + 1);
  311. if (val == VAL_7_WIDTH_3)
  312. memcpy(str, STRNG_7_WIDTH_3, BIT_WIDTH_3 + 1);
  313. MYDBG("val(%d), str(%s)\n", val, str);
  314. }
  315. static ssize_t usb_driving_capability_write(struct file *file,
  316. const char __user *ubuf, size_t count, loff_t *ppos)
  317. {
  318. char buf[18];
  319. u8 val, tmp_val;
  320. char str_rg_usb20_term_vref_sel[18], str_rg_usb20_vrt_vref_sel[18];
  321. memset(buf, 0x00, sizeof(buf));
  322. MYDBG("\n");
  323. if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
  324. return -EFAULT;
  325. if (kstrtol(buf, 10, (long *)&val) != 0) {
  326. MYDBG("kstrtol, err(%d)\n", kstrtol(buf, 10, (long *)&val));
  327. return count;
  328. }
  329. MYDBG("kstrtol, val(%d)\n", val);
  330. if (val > VAL_7_WIDTH_3 * 2) {
  331. MYDBG("wrong val set(%d), direct return\n", val);
  332. return count;
  333. }
  334. tmp_val = val;
  335. val /= 2;
  336. MYDBG("val(%d), tmp_val(%d)\n", val, tmp_val);
  337. val_to_bstring_width3(tmp_val - val, str_rg_usb20_term_vref_sel);
  338. val_to_bstring_width3(val, str_rg_usb20_vrt_vref_sel);
  339. usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
  340. str_rg_usb20_term_vref_sel);
  341. usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
  342. str_rg_usb20_vrt_vref_sel);
  343. return count;
  344. }
  345. static ssize_t rg_usb20_term_vref_sel_write(struct file *file,
  346. const char __user *ubuf, size_t count, loff_t *ppos)
  347. {
  348. char buf[18];
  349. memset(buf, 0x00, sizeof(buf));
  350. if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
  351. return -EFAULT;
  352. usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
  353. buf);
  354. return count;
  355. }
  356. static ssize_t rg_usb20_hstx_srctrl_write(struct file *file,
  357. const char __user *ubuf, size_t count, loff_t *ppos)
  358. {
  359. char buf[18];
  360. memset(buf, 0x00, sizeof(buf));
  361. if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
  362. return -EFAULT;
  363. usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_HSTX_SRCTRL, SHFT_RG_USB20_HSTX_SRCTRL, buf);
  364. return count;
  365. }
  366. static ssize_t rg_usb20_vrt_vref_sel_write(struct file *file,
  367. const char __user *ubuf, size_t count, loff_t *ppos)
  368. {
  369. char buf[18];
  370. memset(buf, 0x00, sizeof(buf));
  371. if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
  372. return -EFAULT;
  373. usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
  374. buf);
  375. return count;
  376. }
  377. static ssize_t rg_usb20_intr_en_write(struct file *file,
  378. const char __user *ubuf, size_t count, loff_t *ppos)
  379. {
  380. char buf[18];
  381. memset(buf, 0x00, sizeof(buf));
  382. if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
  383. return -EFAULT;
  384. usb20_phy_debugfs_write_width1(OFFSET_RG_USB20_INTR_EN, SHFT_RG_USB20_INTR_EN, buf);
  385. return count;
  386. }
  387. static const struct file_operations usb_driving_capability_fops = {
  388. .open = usb_driving_capability_open,
  389. .write = usb_driving_capability_write,
  390. .read = seq_read,
  391. .llseek = seq_lseek,
  392. .release = single_release,
  393. };
  394. static const struct file_operations rg_usb20_term_vref_sel_fops = {
  395. .open = rg_usb20_term_vref_sel_open,
  396. .write = rg_usb20_term_vref_sel_write,
  397. .read = seq_read,
  398. .llseek = seq_lseek,
  399. .release = single_release,
  400. };
  401. static const struct file_operations rg_usb20_hstx_srctrl_fops = {
  402. .open = rg_usb20_hstx_srctrl_open,
  403. .write = rg_usb20_hstx_srctrl_write,
  404. .read = seq_read,
  405. .llseek = seq_lseek,
  406. .release = single_release,
  407. };
  408. static const struct file_operations rg_usb20_vrt_vref_sel_fops = {
  409. .open = rg_usb20_vrt_vref_sel_open,
  410. .write = rg_usb20_vrt_vref_sel_write,
  411. .read = seq_read,
  412. .llseek = seq_lseek,
  413. .release = single_release,
  414. };
  415. static const struct file_operations rg_usb20_intr_en_fops = {
  416. .open = rg_usb20_intr_en_open,
  417. .write = rg_usb20_intr_en_write,
  418. .read = seq_read,
  419. .llseek = seq_lseek,
  420. .release = single_release,
  421. };
  422. int usb20_phy_init_debugfs(void)
  423. {
  424. struct dentry *root;
  425. struct dentry *file;
  426. int ret;
  427. root = debugfs_create_dir("usb20_phy", NULL);
  428. if (!root) {
  429. ret = -ENOMEM;
  430. goto err0;
  431. }
  432. file = debugfs_create_file(FILE_USB_DRIVING_CAPABILITY, S_IRUGO | S_IWUSR,
  433. root, NULL, &usb_driving_capability_fops);
  434. if (!file) {
  435. ret = -ENOMEM;
  436. goto err1;
  437. }
  438. file = debugfs_create_file(FILE_RG_USB20_TERM_VREF_SEL, S_IRUGO | S_IWUSR,
  439. root, NULL, &rg_usb20_term_vref_sel_fops);
  440. if (!file) {
  441. ret = -ENOMEM;
  442. goto err1;
  443. }
  444. file = debugfs_create_file(FILE_RG_USB20_HSTX_SRCTRL, S_IRUGO | S_IWUSR,
  445. root, NULL, &rg_usb20_hstx_srctrl_fops);
  446. if (!file) {
  447. ret = -ENOMEM;
  448. goto err1;
  449. }
  450. file = debugfs_create_file(FILE_RG_USB20_VRT_VREF_SEL, S_IRUGO | S_IWUSR,
  451. root, NULL, &rg_usb20_vrt_vref_sel_fops);
  452. if (!file) {
  453. ret = -ENOMEM;
  454. goto err1;
  455. }
  456. file = debugfs_create_file(FILE_RG_USB20_INTR_EN, S_IRUGO | S_IWUSR,
  457. root, NULL, &rg_usb20_intr_en_fops);
  458. if (!file) {
  459. ret = -ENOMEM;
  460. goto err1;
  461. }
  462. usb20_phy_debugfs_root = root;
  463. return 0;
  464. err1:
  465. debugfs_remove_recursive(root);
  466. err0:
  467. return ret;
  468. }
  469. void /* __init_or_exit */ usb20_phy_exit_debugfs(struct musb *musb)
  470. {
  471. debugfs_remove_recursive(usb20_phy_debugfs_root);
  472. }