.. | .. |
---|
65 | 65 | |
---|
66 | 66 | static struct list_head active_timers; |
---|
67 | 67 | |
---|
68 | | -static struct fsl_otg_config fsl_otg_initdata = { |
---|
| 68 | +static const struct fsl_otg_config fsl_otg_initdata = { |
---|
69 | 69 | .otg_port = 1, |
---|
70 | 70 | }; |
---|
71 | 71 | |
---|
.. | .. |
---|
913 | 913 | break; |
---|
914 | 914 | case FSL_USB2_PHY_UTMI_WIDE: |
---|
915 | 915 | temp |= PORTSC_PTW_16BIT; |
---|
916 | | - /* fall through */ |
---|
| 916 | + fallthrough; |
---|
917 | 917 | case FSL_USB2_PHY_UTMI: |
---|
918 | 918 | temp |= PORTSC_PTS_UTMI; |
---|
919 | | - /* fall through */ |
---|
| 919 | + fallthrough; |
---|
920 | 920 | default: |
---|
921 | 921 | break; |
---|
922 | 922 | } |
---|
.. | .. |
---|
959 | 959 | return 0; |
---|
960 | 960 | } |
---|
961 | 961 | |
---|
962 | | -/* |
---|
963 | | - * state file in sysfs |
---|
964 | | - */ |
---|
965 | | -static ssize_t show_fsl_usb2_otg_state(struct device *dev, |
---|
966 | | - struct device_attribute *attr, char *buf) |
---|
967 | | -{ |
---|
968 | | - struct otg_fsm *fsm = &fsl_otg_dev->fsm; |
---|
969 | | - char *next = buf; |
---|
970 | | - unsigned size = PAGE_SIZE; |
---|
971 | | - int t; |
---|
972 | | - |
---|
973 | | - mutex_lock(&fsm->lock); |
---|
974 | | - |
---|
975 | | - /* basic driver infomation */ |
---|
976 | | - t = scnprintf(next, size, |
---|
977 | | - DRIVER_DESC "\n" "fsl_usb2_otg version: %s\n\n", |
---|
978 | | - DRIVER_VERSION); |
---|
979 | | - size -= t; |
---|
980 | | - next += t; |
---|
981 | | - |
---|
982 | | - /* Registers */ |
---|
983 | | - t = scnprintf(next, size, |
---|
984 | | - "OTGSC: 0x%08x\n" |
---|
985 | | - "PORTSC: 0x%08x\n" |
---|
986 | | - "USBMODE: 0x%08x\n" |
---|
987 | | - "USBCMD: 0x%08x\n" |
---|
988 | | - "USBSTS: 0x%08x\n" |
---|
989 | | - "USBINTR: 0x%08x\n", |
---|
990 | | - fsl_readl(&usb_dr_regs->otgsc), |
---|
991 | | - fsl_readl(&usb_dr_regs->portsc), |
---|
992 | | - fsl_readl(&usb_dr_regs->usbmode), |
---|
993 | | - fsl_readl(&usb_dr_regs->usbcmd), |
---|
994 | | - fsl_readl(&usb_dr_regs->usbsts), |
---|
995 | | - fsl_readl(&usb_dr_regs->usbintr)); |
---|
996 | | - size -= t; |
---|
997 | | - next += t; |
---|
998 | | - |
---|
999 | | - /* State */ |
---|
1000 | | - t = scnprintf(next, size, |
---|
1001 | | - "OTG state: %s\n\n", |
---|
1002 | | - usb_otg_state_string(fsl_otg_dev->phy.otg->state)); |
---|
1003 | | - size -= t; |
---|
1004 | | - next += t; |
---|
1005 | | - |
---|
1006 | | - /* State Machine Variables */ |
---|
1007 | | - t = scnprintf(next, size, |
---|
1008 | | - "a_bus_req: %d\n" |
---|
1009 | | - "b_bus_req: %d\n" |
---|
1010 | | - "a_bus_resume: %d\n" |
---|
1011 | | - "a_bus_suspend: %d\n" |
---|
1012 | | - "a_conn: %d\n" |
---|
1013 | | - "a_sess_vld: %d\n" |
---|
1014 | | - "a_srp_det: %d\n" |
---|
1015 | | - "a_vbus_vld: %d\n" |
---|
1016 | | - "b_bus_resume: %d\n" |
---|
1017 | | - "b_bus_suspend: %d\n" |
---|
1018 | | - "b_conn: %d\n" |
---|
1019 | | - "b_se0_srp: %d\n" |
---|
1020 | | - "b_ssend_srp: %d\n" |
---|
1021 | | - "b_sess_vld: %d\n" |
---|
1022 | | - "id: %d\n", |
---|
1023 | | - fsm->a_bus_req, |
---|
1024 | | - fsm->b_bus_req, |
---|
1025 | | - fsm->a_bus_resume, |
---|
1026 | | - fsm->a_bus_suspend, |
---|
1027 | | - fsm->a_conn, |
---|
1028 | | - fsm->a_sess_vld, |
---|
1029 | | - fsm->a_srp_det, |
---|
1030 | | - fsm->a_vbus_vld, |
---|
1031 | | - fsm->b_bus_resume, |
---|
1032 | | - fsm->b_bus_suspend, |
---|
1033 | | - fsm->b_conn, |
---|
1034 | | - fsm->b_se0_srp, |
---|
1035 | | - fsm->b_ssend_srp, |
---|
1036 | | - fsm->b_sess_vld, |
---|
1037 | | - fsm->id); |
---|
1038 | | - size -= t; |
---|
1039 | | - next += t; |
---|
1040 | | - |
---|
1041 | | - mutex_unlock(&fsm->lock); |
---|
1042 | | - |
---|
1043 | | - return PAGE_SIZE - size; |
---|
1044 | | -} |
---|
1045 | | - |
---|
1046 | | -static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL); |
---|
1047 | | - |
---|
1048 | | - |
---|
1049 | | -/* Char driver interface to control some OTG input */ |
---|
1050 | | - |
---|
1051 | | -/* |
---|
1052 | | - * Handle some ioctl command, such as get otg |
---|
1053 | | - * status and set host suspend |
---|
1054 | | - */ |
---|
1055 | | -static long fsl_otg_ioctl(struct file *file, unsigned int cmd, |
---|
1056 | | - unsigned long arg) |
---|
1057 | | -{ |
---|
1058 | | - u32 retval = 0; |
---|
1059 | | - |
---|
1060 | | - switch (cmd) { |
---|
1061 | | - case GET_OTG_STATUS: |
---|
1062 | | - retval = fsl_otg_dev->host_working; |
---|
1063 | | - break; |
---|
1064 | | - |
---|
1065 | | - case SET_A_SUSPEND_REQ: |
---|
1066 | | - fsl_otg_dev->fsm.a_suspend_req_inf = arg; |
---|
1067 | | - break; |
---|
1068 | | - |
---|
1069 | | - case SET_A_BUS_DROP: |
---|
1070 | | - fsl_otg_dev->fsm.a_bus_drop = arg; |
---|
1071 | | - break; |
---|
1072 | | - |
---|
1073 | | - case SET_A_BUS_REQ: |
---|
1074 | | - fsl_otg_dev->fsm.a_bus_req = arg; |
---|
1075 | | - break; |
---|
1076 | | - |
---|
1077 | | - case SET_B_BUS_REQ: |
---|
1078 | | - fsl_otg_dev->fsm.b_bus_req = arg; |
---|
1079 | | - break; |
---|
1080 | | - |
---|
1081 | | - default: |
---|
1082 | | - break; |
---|
1083 | | - } |
---|
1084 | | - |
---|
1085 | | - otg_statemachine(&fsl_otg_dev->fsm); |
---|
1086 | | - |
---|
1087 | | - return retval; |
---|
1088 | | -} |
---|
1089 | | - |
---|
1090 | | -static int fsl_otg_open(struct inode *inode, struct file *file) |
---|
1091 | | -{ |
---|
1092 | | - return 0; |
---|
1093 | | -} |
---|
1094 | | - |
---|
1095 | | -static int fsl_otg_release(struct inode *inode, struct file *file) |
---|
1096 | | -{ |
---|
1097 | | - return 0; |
---|
1098 | | -} |
---|
1099 | | - |
---|
1100 | | -static const struct file_operations otg_fops = { |
---|
1101 | | - .owner = THIS_MODULE, |
---|
1102 | | - .llseek = NULL, |
---|
1103 | | - .read = NULL, |
---|
1104 | | - .write = NULL, |
---|
1105 | | - .unlocked_ioctl = fsl_otg_ioctl, |
---|
1106 | | - .open = fsl_otg_open, |
---|
1107 | | - .release = fsl_otg_release, |
---|
1108 | | -}; |
---|
1109 | | - |
---|
1110 | 962 | static int fsl_otg_probe(struct platform_device *pdev) |
---|
1111 | 963 | { |
---|
1112 | 964 | int ret; |
---|
.. | .. |
---|
1128 | 980 | return ret; |
---|
1129 | 981 | } |
---|
1130 | 982 | |
---|
1131 | | - ret = register_chrdev(FSL_OTG_MAJOR, FSL_OTG_NAME, &otg_fops); |
---|
1132 | | - if (ret) { |
---|
1133 | | - dev_err(&pdev->dev, "unable to register FSL OTG device\n"); |
---|
1134 | | - return ret; |
---|
1135 | | - } |
---|
1136 | | - |
---|
1137 | | - ret = device_create_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); |
---|
1138 | | - if (ret) |
---|
1139 | | - dev_warn(&pdev->dev, "Can't register sysfs attribute\n"); |
---|
1140 | | - |
---|
1141 | 983 | return ret; |
---|
1142 | 984 | } |
---|
1143 | 985 | |
---|
.. | .. |
---|
1153 | 995 | fsl_otg_uninit_timers(); |
---|
1154 | 996 | kfree(fsl_otg_dev->phy.otg); |
---|
1155 | 997 | kfree(fsl_otg_dev); |
---|
1156 | | - |
---|
1157 | | - device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); |
---|
1158 | | - |
---|
1159 | | - unregister_chrdev(FSL_OTG_MAJOR, FSL_OTG_NAME); |
---|
1160 | 998 | |
---|
1161 | 999 | if (pdata->exit) |
---|
1162 | 1000 | pdata->exit(pdev); |
---|