aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShangbing Hu <shangbing.hu@mediatek.com>2016-07-12 20:46:35 +0800
committerShangbing Hu <shangbing.hu@mediatek.com>2016-07-12 20:46:35 +0800
commitb583eec6620cd9d5118a745848508b1017a7f8d0 (patch)
treeddd707aa307e824ac8de645e76724dafb2c2286f
parent66e1225e059e679ba0a726923b2f867adaf29ee8 (diff)
[ALPS02346757] USB:Jade driving capability porting
[Detail] Jade driving capability porting for HQA test [Solution] Jade driving capability porting for HQA test [Feature] USB MTK-Commit-Id: 114d9fca76743e5d033debaa969c0a393bfd7c35 Signed-off-by: Shangbing Hu <shangbing.hu@mediatek.com> Change-Id: Iec4590ca1f29b29757c51e7d52762beecdda510b CR-Id: ALPS02346757
-rw-r--r--drivers/misc/mediatek/mu3d/drv/musb_core.c5
-rw-r--r--drivers/misc/mediatek/mu3d/drv/musb_core.h5
-rw-r--r--drivers/misc/mediatek/mu3phy/Makefile2
-rw-r--r--drivers/misc/mediatek/mu3phy/usb20_phy_debugfs.c553
4 files changed, 563 insertions, 2 deletions
diff --git a/drivers/misc/mediatek/mu3d/drv/musb_core.c b/drivers/misc/mediatek/mu3d/drv/musb_core.c
index 9aae5a028cf8..0c156c503ed3 100644
--- a/drivers/misc/mediatek/mu3d/drv/musb_core.c
+++ b/drivers/misc/mediatek/mu3d/drv/musb_core.c
@@ -2112,6 +2112,11 @@ allocate_instance(struct device *dev, struct musb_hdrc_config *config, void __io
/* memset(musb->xceiv, 0, sizeof(struct otg_transceiver)); */
/* musb->xceiv->state = OTG_STATE_B_IDLE; //initial its value */
+#ifdef CONFIG_DEBUG_FS
+ if (usb20_phy_init_debugfs())
+ os_printk(K_ERR, "usb20_phy_init_debugfs fail!\n");
+#endif
+
return musb;
}
diff --git a/drivers/misc/mediatek/mu3d/drv/musb_core.h b/drivers/misc/mediatek/mu3d/drv/musb_core.h
index b9f5372eb408..1a606af4d7ae 100644
--- a/drivers/misc/mediatek/mu3d/drv/musb_core.h
+++ b/drivers/misc/mediatek/mu3d/drv/musb_core.h
@@ -137,7 +137,10 @@ extern void musb_g_suspend(struct musb *);
extern void musb_g_resume(struct musb *);
extern void musb_g_wakeup(struct musb *);
extern void musb_g_disconnect(struct musb *);
-
+#ifdef CONFIG_DEBUG_FS
+extern unsigned musb_uart_debug;
+extern int usb20_phy_init_debugfs(void);
+#endif
/****************************** HOST ROLE ***********************************/
#define is_host_capable() (1)
diff --git a/drivers/misc/mediatek/mu3phy/Makefile b/drivers/misc/mediatek/mu3phy/Makefile
index f92166737c40..b000b1b7652a 100644
--- a/drivers/misc/mediatek/mu3phy/Makefile
+++ b/drivers/misc/mediatek/mu3phy/Makefile
@@ -14,5 +14,5 @@ mu3phy-$(CONFIG_C60802_SUPPORT) += mtk-phy-c60802.o
mu3phy-$(CONFIG_D60802_SUPPORT) += mtk-phy-d60802.o
mu3phy-$(CONFIG_E60802_SUPPORT) += mtk-phy-e60802.o
mu3phy-$(CONFIG_A60810_SUPPORT) += mtk-phy-a60810.o
-
+mu3phy-$(CONFIG_DEBUG_FS) += usb20_phy_debugfs.o
obj-$(CONFIG_MU3_PHY) += $(subst ",,$(CONFIG_MTK_PLATFORM))/ \ No newline at end of file
diff --git a/drivers/misc/mediatek/mu3phy/usb20_phy_debugfs.c b/drivers/misc/mediatek/mu3phy/usb20_phy_debugfs.c
new file mode 100644
index 000000000000..083fc1f76f55
--- /dev/null
+++ b/drivers/misc/mediatek/mu3phy/usb20_phy_debugfs.c
@@ -0,0 +1,553 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <asm/uaccess.h>
+#include "musb_core.h"
+#include "mtk-phy.h"
+#define USBPHY_READ8(offset) U3PhyReadReg8((u3phy_addr_t)u3_sif2_base+0x800+offset)
+#define USBPHY_WRITE8(offset, value) U3PhyWriteReg8((u3phy_addr_t)u3_sif2_base+0x800+offset, value)
+#define USBPHY_SET8(offset, mask) \
+U3PhyWriteReg8((u3phy_addr_t)u3_sif2_base+0x800+offset, U3PhyReadReg8((u3phy_addr_t)u3_sif2_base+0x800+offset)|(mask))
+#define USBPHY_CLR8(offset, mask) \
+U3PhyWriteReg8((u3phy_addr_t)u3_sif2_base+0x800+offset, U3PhyReadReg8((u3phy_addr_t)u3_sif2_base+0x800+offset)&(~mask))
+#define MYDBG(fmt, args...) pr_warn("MTK_ICUSB [DBG], <%s(), %d> " fmt, __func__, __LINE__, ## args)
+
+/* general */
+#define BIT_WIDTH_1 1
+#define MSK_WIDTH_1 0x1
+#define VAL_MAX_WDITH_1 0x1
+#define VAL_0_WIDTH_1 0x0
+#define VAL_1_WIDTH_1 0x1
+#define STRNG_0_WIDTH_1 "0"
+#define STRNG_1_WIDTH_1 "1"
+
+#define BIT_WIDTH_3 3
+#define MSK_WIDTH_3 0x7
+#define VAL_MAX_WDITH_3 0x7
+#define VAL_0_WIDTH_3 0x0
+#define VAL_1_WIDTH_3 0x1
+#define VAL_2_WIDTH_3 0x2
+#define VAL_3_WIDTH_3 0x3
+#define VAL_4_WIDTH_3 0x4
+#define VAL_5_WIDTH_3 0x5
+#define VAL_6_WIDTH_3 0x6
+#define VAL_7_WIDTH_3 0x7
+#define STRNG_0_WIDTH_3 "000"
+#define STRNG_1_WIDTH_3 "001"
+#define STRNG_2_WIDTH_3 "010"
+#define STRNG_3_WIDTH_3 "011"
+#define STRNG_4_WIDTH_3 "100"
+#define STRNG_5_WIDTH_3 "101"
+#define STRNG_6_WIDTH_3 "110"
+#define STRNG_7_WIDTH_3 "111"
+
+/* specific */
+#define FILE_USB_DRIVING_CAPABILITY "USB_DRIVING_CAPABILITY"
+
+#define FILE_RG_USB20_TERM_VREF_SEL "RG_USB20_TERM_VREF_SEL"
+#define MSK_RG_USB20_TERM_VREF_SEL MSK_WIDTH_3
+#define SHFT_RG_USB20_TERM_VREF_SEL 0
+#define OFFSET_RG_USB20_TERM_VREF_SEL 0x5
+
+#define FILE_RG_USB20_HSTX_SRCTRL "RG_USB20_HSTX_SRCTRL"
+#define MSK_RG_USB20_HSTX_SRCTRL MSK_WIDTH_3
+#define SHFT_RG_USB20_HSTX_SRCTRL 4
+#define OFFSET_RG_USB20_HSTX_SRCTRL 0x15
+
+#define FILE_RG_USB20_VRT_VREF_SEL "RG_USB20_VRT_VREF_SEL"
+#define MSK_RG_USB20_VRT_VREF_SEL MSK_WIDTH_3
+#define SHFT_RG_USB20_VRT_VREF_SEL 4
+#define OFFSET_RG_USB20_VRT_VREF_SEL 0x5
+
+#define FILE_RG_USB20_INTR_EN "RG_USB20_INTR_EN"
+#define MSK_RG_USB20_INTR_EN MSK_WIDTH_1
+#define SHFT_RG_USB20_INTR_EN 5
+#define OFFSET_RG_USB20_INTR_EN 0x0
+
+static struct dentry *usb20_phy_debugfs_root;
+
+void usb20_phy_debugfs_write_width1(u8 offset, u8 shift, char *buf)
+{
+ u8 clr_val = 0, set_val = 0;
+
+ MYDBG("s(%s)\n", buf);
+ if (!strncmp(buf, STRNG_0_WIDTH_1, BIT_WIDTH_1)) {
+ MYDBG("%s case\n", STRNG_0_WIDTH_1);
+ clr_val = VAL_1_WIDTH_1;
+ }
+ if (!strncmp(buf, STRNG_1_WIDTH_1, BIT_WIDTH_1)) {
+ MYDBG("%s case\n", STRNG_1_WIDTH_1);
+ set_val = VAL_1_WIDTH_1;
+ }
+
+ if (clr_val || set_val) {
+ clr_val = VAL_MAX_WDITH_1 - set_val;
+ MYDBG("offset:%x, clr_val:%x, set_val:%x, before shft\n", offset, clr_val, set_val);
+ clr_val <<= shift;
+ set_val <<= shift;
+ MYDBG("offset:%x, clr_val:%x, set_val:%x, after shft\n", offset, clr_val, set_val);
+ USBPHY_CLR8(offset, clr_val);
+ USBPHY_SET8(offset, set_val);
+ } else {
+ MYDBG("do nothing\n");
+ }
+}
+
+void usb20_phy_debugfs_write_width3(u8 offset, u8 shift, char *buf)
+{
+ u8 clr_val = 0, set_val = 0;
+
+ MYDBG("s(%s)\n", buf);
+ if (!strncmp(buf, STRNG_0_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_0_WIDTH_3);
+ clr_val = VAL_7_WIDTH_3;
+ }
+ if (!strncmp(buf, STRNG_1_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_1_WIDTH_3);
+ set_val = VAL_1_WIDTH_3;
+ }
+ if (!strncmp(buf, STRNG_2_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_2_WIDTH_3);
+ set_val = VAL_2_WIDTH_3;
+ }
+ if (!strncmp(buf, STRNG_3_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_3_WIDTH_3);
+ set_val = VAL_3_WIDTH_3;
+ }
+ if (!strncmp(buf, STRNG_4_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_4_WIDTH_3);
+ set_val = VAL_4_WIDTH_3;
+ }
+ if (!strncmp(buf, STRNG_5_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_5_WIDTH_3);
+ set_val = VAL_5_WIDTH_3;
+ }
+ if (!strncmp(buf, STRNG_6_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_6_WIDTH_3);
+ set_val = VAL_6_WIDTH_3;
+ }
+ if (!strncmp(buf, STRNG_7_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_7_WIDTH_3);
+ set_val = VAL_7_WIDTH_3;
+ }
+ /* HS_100U_U3_EN = 0x50 */
+ USBPHY_WRITE8(0x15, 0x50);
+ msleep(50);
+ /* MYDBG("PHY Register 0x%x = 0x%x\n", 0x800+0x15, USBPHY_READ8(0x15)); */
+
+ if (clr_val || set_val) {
+ clr_val = VAL_MAX_WDITH_3 - set_val;
+ MYDBG("offset:%x, clr_val:%x, set_val:%x, before shft\n", offset, clr_val, set_val);
+ clr_val <<= shift;
+ set_val <<= shift;
+ MYDBG("offset:%x, clr_val:%x, set_val:%x, after shft\n", offset, clr_val, set_val);
+ USBPHY_CLR8(offset, clr_val);
+ USBPHY_SET8(offset, set_val);
+ MYDBG("PHY Register 0x%x = 0x%x\n", 0x800+offset, USBPHY_READ8(offset));
+ } else {
+ MYDBG("do nothing\n");
+ }
+}
+
+u8 usb20_phy_debugfs_read_val(u8 offset, u8 shft, u8 msk, u8 width, char *str)
+{
+ u8 val;
+ int i, temp;
+
+ val = USBPHY_READ8(offset);
+ MYDBG("offset:%x, val:%x, shft:%x, msk:%x\n", offset, val, shft, msk);
+ val = val >> shft;
+ MYDBG("offset:%x, val:%x, shft:%x, msk:%x\n", offset, val, shft, msk);
+ val = val & msk;
+ MYDBG("offset:%x, val:%x, shft:%x, msk:%x\n", offset, val, shft, msk);
+
+ temp = val;
+ str[width] = '\0';
+ for (i = (width - 1); i >= 0; i--) {
+ if (val % 2)
+ str[i] = '1';
+ else
+ str[i] = '0';
+ MYDBG("str[%d]:%c\n", i, str[i]);
+ val /= 2;
+ }
+ MYDBG("str(%s)\n", str);
+ return val;
+}
+
+static int usb_driving_capability_show(struct seq_file *s, void *unused)
+{
+ u8 val;
+ char str[16];
+ u8 combined_val, tmp_val = 0xff;
+
+ val = usb20_phy_debugfs_read_val(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
+ MSK_RG_USB20_TERM_VREF_SEL, BIT_WIDTH_3, str);
+ if (!strncmp(str, STRNG_0_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_0_WIDTH_3);
+ tmp_val = VAL_0_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_1_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_1_WIDTH_3);
+ tmp_val = VAL_1_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_2_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_2_WIDTH_3);
+ tmp_val = VAL_2_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_3_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_3_WIDTH_3);
+ tmp_val = VAL_3_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_4_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_4_WIDTH_3);
+ tmp_val = VAL_4_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_5_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_5_WIDTH_3);
+ tmp_val = VAL_5_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_6_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_6_WIDTH_3);
+ tmp_val = VAL_6_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_7_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_7_WIDTH_3);
+ tmp_val = VAL_7_WIDTH_3;
+ }
+
+ combined_val = tmp_val;
+
+ val = usb20_phy_debugfs_read_val(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
+ MSK_RG_USB20_VRT_VREF_SEL, BIT_WIDTH_3, str);
+ if (!strncmp(str, STRNG_0_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_0_WIDTH_3);
+ tmp_val = VAL_0_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_1_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_1_WIDTH_3);
+ tmp_val = VAL_1_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_2_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_2_WIDTH_3);
+ tmp_val = VAL_2_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_3_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_3_WIDTH_3);
+ tmp_val = VAL_3_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_4_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_4_WIDTH_3);
+ tmp_val = VAL_4_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_5_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_5_WIDTH_3);
+ tmp_val = VAL_5_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_6_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_6_WIDTH_3);
+ tmp_val = VAL_6_WIDTH_3;
+ }
+ if (!strncmp(str, STRNG_7_WIDTH_3, BIT_WIDTH_3)) {
+ MYDBG("%s case\n", STRNG_7_WIDTH_3);
+ tmp_val = VAL_7_WIDTH_3;
+ }
+
+ MYDBG("combined_val(%d), tmp_val(%d)\n", combined_val, tmp_val);
+ if ((tmp_val == (combined_val - 1)) || (tmp_val == combined_val))
+ combined_val += tmp_val;
+ else
+ combined_val = tmp_val * (VAL_MAX_WDITH_3 + 1) + combined_val;
+
+ MYDBG("combined_val(%d), tmp_val(%d)\n", combined_val, tmp_val);
+
+ seq_printf(s, "%d", combined_val);
+ return 0;
+}
+
+static int rg_usb20_term_vref_sel_show(struct seq_file *s, void *unused)
+{
+ u8 val;
+ char str[16];
+
+ val =
+ usb20_phy_debugfs_read_val(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
+ MSK_RG_USB20_TERM_VREF_SEL, BIT_WIDTH_3, str);
+ seq_printf(s, "%s", str);
+ return 0;
+}
+
+static int rg_usb20_hstx_srctrl_show(struct seq_file *s, void *unused)
+{
+ u8 val;
+ char str[16];
+
+ val =
+ usb20_phy_debugfs_read_val(OFFSET_RG_USB20_HSTX_SRCTRL, SHFT_RG_USB20_HSTX_SRCTRL,
+ MSK_RG_USB20_HSTX_SRCTRL, BIT_WIDTH_3, str);
+ seq_printf(s, "%s", str);
+ return 0;
+}
+
+static int rg_usb20_vrt_vref_sel_show(struct seq_file *s, void *unused)
+{
+ u8 val;
+ char str[16];
+
+ val =
+ usb20_phy_debugfs_read_val(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
+ MSK_RG_USB20_VRT_VREF_SEL, BIT_WIDTH_3, str);
+ seq_printf(s, "%s", str);
+ return 0;
+}
+
+static int rg_usb20_intr_en_show(struct seq_file *s, void *unused)
+{
+ u8 val;
+ char str[16];
+
+ val =
+ usb20_phy_debugfs_read_val(OFFSET_RG_USB20_INTR_EN, SHFT_RG_USB20_INTR_EN,
+ MSK_RG_USB20_INTR_EN, BIT_WIDTH_1, str);
+ seq_printf(s, "%s", str);
+ return 0;
+}
+
+static int usb_driving_capability_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, usb_driving_capability_show, inode->i_private);
+}
+
+static int rg_usb20_term_vref_sel_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rg_usb20_term_vref_sel_show, inode->i_private);
+}
+
+static int rg_usb20_hstx_srctrl_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rg_usb20_hstx_srctrl_show, inode->i_private);
+}
+
+static int rg_usb20_vrt_vref_sel_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rg_usb20_vrt_vref_sel_show, inode->i_private);
+}
+
+static int rg_usb20_intr_en_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, rg_usb20_intr_en_show, inode->i_private);
+}
+
+void val_to_bstring_width3(u8 val, char *str)
+{
+
+ if (val == VAL_0_WIDTH_3)
+ memcpy(str, STRNG_0_WIDTH_3, BIT_WIDTH_3 + 1);
+ if (val == VAL_1_WIDTH_3)
+ memcpy(str, STRNG_1_WIDTH_3, BIT_WIDTH_3 + 1);
+ if (val == VAL_2_WIDTH_3)
+ memcpy(str, STRNG_2_WIDTH_3, BIT_WIDTH_3 + 1);
+ if (val == VAL_3_WIDTH_3)
+ memcpy(str, STRNG_3_WIDTH_3, BIT_WIDTH_3 + 1);
+ if (val == VAL_4_WIDTH_3)
+ memcpy(str, STRNG_4_WIDTH_3, BIT_WIDTH_3 + 1);
+ if (val == VAL_5_WIDTH_3)
+ memcpy(str, STRNG_5_WIDTH_3, BIT_WIDTH_3 + 1);
+ if (val == VAL_6_WIDTH_3)
+ memcpy(str, STRNG_6_WIDTH_3, BIT_WIDTH_3 + 1);
+ if (val == VAL_7_WIDTH_3)
+ memcpy(str, STRNG_7_WIDTH_3, BIT_WIDTH_3 + 1);
+
+ MYDBG("val(%d), str(%s)\n", val, str);
+}
+
+static ssize_t usb_driving_capability_write(struct file *file,
+ const char __user *ubuf, size_t count, loff_t *ppos)
+{
+ char buf[18];
+ u8 val, tmp_val;
+ char str_rg_usb20_term_vref_sel[18], str_rg_usb20_vrt_vref_sel[18];
+
+ memset(buf, 0x00, sizeof(buf));
+ MYDBG("\n");
+ if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+ return -EFAULT;
+
+ if (kstrtol(buf, 10, (long *)&val) != 0) {
+ MYDBG("kstrtol, err(%d)\n", kstrtol(buf, 10, (long *)&val));
+ return count;
+ }
+ MYDBG("kstrtol, val(%d)\n", val);
+
+ if (val > VAL_7_WIDTH_3 * 2) {
+ MYDBG("wrong val set(%d), direct return\n", val);
+ return count;
+ }
+ tmp_val = val;
+ val /= 2;
+
+ MYDBG("val(%d), tmp_val(%d)\n", val, tmp_val);
+ val_to_bstring_width3(tmp_val - val, str_rg_usb20_term_vref_sel);
+ val_to_bstring_width3(val, str_rg_usb20_vrt_vref_sel);
+ MYDBG("Config TERM_VREF_SEL %s\n", str_rg_usb20_term_vref_sel);
+ usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
+ str_rg_usb20_term_vref_sel);
+ MYDBG("Config VRT_VREF_SEL %s\n", str_rg_usb20_vrt_vref_sel);
+ usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
+ str_rg_usb20_vrt_vref_sel);
+ return count;
+}
+
+static ssize_t rg_usb20_term_vref_sel_write(struct file *file,
+ const char __user *ubuf, size_t count, loff_t *ppos)
+{
+ char buf[18];
+
+ memset(buf, 0x00, sizeof(buf));
+
+ if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+ return -EFAULT;
+ usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_TERM_VREF_SEL, SHFT_RG_USB20_TERM_VREF_SEL,
+ buf);
+ return count;
+}
+
+static ssize_t rg_usb20_hstx_srctrl_write(struct file *file,
+ const char __user *ubuf, size_t count, loff_t *ppos)
+{
+ char buf[18];
+
+ memset(buf, 0x00, sizeof(buf));
+
+ if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+ return -EFAULT;
+ usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_HSTX_SRCTRL, SHFT_RG_USB20_HSTX_SRCTRL, buf);
+ return count;
+}
+
+static ssize_t rg_usb20_vrt_vref_sel_write(struct file *file,
+ const char __user *ubuf, size_t count, loff_t *ppos)
+{
+ char buf[18];
+
+ memset(buf, 0x00, sizeof(buf));
+
+ if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+ return -EFAULT;
+ usb20_phy_debugfs_write_width3(OFFSET_RG_USB20_VRT_VREF_SEL, SHFT_RG_USB20_VRT_VREF_SEL,
+ buf);
+ return count;
+}
+
+static ssize_t rg_usb20_intr_en_write(struct file *file,
+ const char __user *ubuf, size_t count, loff_t *ppos)
+{
+ char buf[18];
+
+ memset(buf, 0x00, sizeof(buf));
+
+ if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+ return -EFAULT;
+ usb20_phy_debugfs_write_width1(OFFSET_RG_USB20_INTR_EN, SHFT_RG_USB20_INTR_EN, buf);
+ return count;
+}
+
+static const struct file_operations usb_driving_capability_fops = {
+ .open = usb_driving_capability_open,
+ .write = usb_driving_capability_write,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static const struct file_operations rg_usb20_term_vref_sel_fops = {
+ .open = rg_usb20_term_vref_sel_open,
+ .write = rg_usb20_term_vref_sel_write,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static const struct file_operations rg_usb20_hstx_srctrl_fops = {
+ .open = rg_usb20_hstx_srctrl_open,
+ .write = rg_usb20_hstx_srctrl_write,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static const struct file_operations rg_usb20_vrt_vref_sel_fops = {
+ .open = rg_usb20_vrt_vref_sel_open,
+ .write = rg_usb20_vrt_vref_sel_write,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static const struct file_operations rg_usb20_intr_en_fops = {
+ .open = rg_usb20_intr_en_open,
+ .write = rg_usb20_intr_en_write,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+int usb20_phy_init_debugfs(void)
+{
+ struct dentry *root;
+ struct dentry *file;
+ int ret;
+
+ root = debugfs_create_dir("usb20_phy", NULL);
+ if (!root) {
+ ret = -ENOMEM;
+ goto err0;
+ }
+
+ file = debugfs_create_file(FILE_USB_DRIVING_CAPABILITY, S_IRUGO | S_IWUSR,
+ root, NULL, &usb_driving_capability_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+ file = debugfs_create_file(FILE_RG_USB20_TERM_VREF_SEL, S_IRUGO | S_IWUSR,
+ root, NULL, &rg_usb20_term_vref_sel_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+ file = debugfs_create_file(FILE_RG_USB20_HSTX_SRCTRL, S_IRUGO | S_IWUSR,
+ root, NULL, &rg_usb20_hstx_srctrl_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+ file = debugfs_create_file(FILE_RG_USB20_VRT_VREF_SEL, S_IRUGO | S_IWUSR,
+ root, NULL, &rg_usb20_vrt_vref_sel_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+ file = debugfs_create_file(FILE_RG_USB20_INTR_EN, S_IRUGO | S_IWUSR,
+ root, NULL, &rg_usb20_intr_en_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ usb20_phy_debugfs_root = root;
+ return 0;
+
+err1:
+ debugfs_remove_recursive(root);
+
+err0:
+ return ret;
+}
+
+void /* __init_or_exit */ usb20_phy_exit_debugfs(struct musb *musb)
+{
+ debugfs_remove_recursive(usb20_phy_debugfs_root);
+}