diff options
Diffstat (limited to 'drivers/usb/gadget/goku_udc.c')
-rw-r--r-- | drivers/usb/gadget/goku_udc.c | 89 |
1 files changed, 39 insertions, 50 deletions
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 991aba390d9d..480eeb7cfd92 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/list.h> | 35 | #include <linux/list.h> |
36 | #include <linux/interrupt.h> | 36 | #include <linux/interrupt.h> |
37 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
38 | #include <linux/seq_file.h> | ||
38 | #include <linux/device.h> | 39 | #include <linux/device.h> |
39 | #include <linux/usb/ch9.h> | 40 | #include <linux/usb/ch9.h> |
40 | #include <linux/usb/gadget.h> | 41 | #include <linux/usb/gadget.h> |
@@ -1005,7 +1006,7 @@ static const struct usb_gadget_ops goku_ops = { | |||
1005 | 1006 | ||
1006 | /*-------------------------------------------------------------------------*/ | 1007 | /*-------------------------------------------------------------------------*/ |
1007 | 1008 | ||
1008 | static inline char *dmastr(void) | 1009 | static inline const char *dmastr(void) |
1009 | { | 1010 | { |
1010 | if (use_dma == 0) | 1011 | if (use_dma == 0) |
1011 | return "(dma disabled)"; | 1012 | return "(dma disabled)"; |
@@ -1022,13 +1023,10 @@ static const char proc_node_name [] = "driver/udc"; | |||
1022 | #define FOURBITS "%s%s%s%s" | 1023 | #define FOURBITS "%s%s%s%s" |
1023 | #define EIGHTBITS FOURBITS FOURBITS | 1024 | #define EIGHTBITS FOURBITS FOURBITS |
1024 | 1025 | ||
1025 | static void | 1026 | static void dump_intmask(struct seq_file *m, const char *label, u32 mask) |
1026 | dump_intmask(const char *label, u32 mask, char **next, unsigned *size) | ||
1027 | { | 1027 | { |
1028 | int t; | ||
1029 | |||
1030 | /* int_status is the same format ... */ | 1028 | /* int_status is the same format ... */ |
1031 | t = scnprintf(*next, *size, | 1029 | seq_printf(m, |
1032 | "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", | 1030 | "%s %05X =" FOURBITS EIGHTBITS EIGHTBITS "\n", |
1033 | label, mask, | 1031 | label, mask, |
1034 | (mask & INT_PWRDETECT) ? " power" : "", | 1032 | (mask & INT_PWRDETECT) ? " power" : "", |
@@ -1055,33 +1053,23 @@ dump_intmask(const char *label, u32 mask, char **next, unsigned *size) | |||
1055 | (mask & INT_ENDPOINT0) ? " ep0" : "", | 1053 | (mask & INT_ENDPOINT0) ? " ep0" : "", |
1056 | (mask & INT_USBRESET) ? " reset" : "", | 1054 | (mask & INT_USBRESET) ? " reset" : "", |
1057 | (mask & INT_SUSPEND) ? " suspend" : ""); | 1055 | (mask & INT_SUSPEND) ? " suspend" : ""); |
1058 | *size -= t; | ||
1059 | *next += t; | ||
1060 | } | 1056 | } |
1061 | 1057 | ||
1062 | 1058 | ||
1063 | static int | 1059 | static int udc_proc_read(struct seq_file *m, void *v) |
1064 | udc_proc_read(char *buffer, char **start, off_t off, int count, | ||
1065 | int *eof, void *_dev) | ||
1066 | { | 1060 | { |
1067 | char *buf = buffer; | 1061 | struct goku_udc *dev = m->private; |
1068 | struct goku_udc *dev = _dev; | ||
1069 | struct goku_udc_regs __iomem *regs = dev->regs; | 1062 | struct goku_udc_regs __iomem *regs = dev->regs; |
1070 | char *next = buf; | ||
1071 | unsigned size = count; | ||
1072 | unsigned long flags; | 1063 | unsigned long flags; |
1073 | int i, t, is_usb_connected; | 1064 | int i, is_usb_connected; |
1074 | u32 tmp; | 1065 | u32 tmp; |
1075 | 1066 | ||
1076 | if (off != 0) | ||
1077 | return 0; | ||
1078 | |||
1079 | local_irq_save(flags); | 1067 | local_irq_save(flags); |
1080 | 1068 | ||
1081 | /* basic device status */ | 1069 | /* basic device status */ |
1082 | tmp = readl(®s->power_detect); | 1070 | tmp = readl(®s->power_detect); |
1083 | is_usb_connected = tmp & PW_DETECT; | 1071 | is_usb_connected = tmp & PW_DETECT; |
1084 | t = scnprintf(next, size, | 1072 | seq_printf(m, |
1085 | "%s - %s\n" | 1073 | "%s - %s\n" |
1086 | "%s version: %s %s\n" | 1074 | "%s version: %s %s\n" |
1087 | "Gadget driver: %s\n" | 1075 | "Gadget driver: %s\n" |
@@ -1093,7 +1081,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, | |||
1093 | is_usb_connected | 1081 | is_usb_connected |
1094 | ? ((tmp & PW_PULLUP) ? "full speed" : "powered") | 1082 | ? ((tmp & PW_PULLUP) ? "full speed" : "powered") |
1095 | : "disconnected", | 1083 | : "disconnected", |
1096 | ({char *state; | 1084 | ({const char *state; |
1097 | switch(dev->ep0state){ | 1085 | switch(dev->ep0state){ |
1098 | case EP0_DISCONNECT: state = "ep0_disconnect"; break; | 1086 | case EP0_DISCONNECT: state = "ep0_disconnect"; break; |
1099 | case EP0_IDLE: state = "ep0_idle"; break; | 1087 | case EP0_IDLE: state = "ep0_idle"; break; |
@@ -1105,27 +1093,24 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, | |||
1105 | default: state = "ep0_?"; break; | 1093 | default: state = "ep0_?"; break; |
1106 | } state; }) | 1094 | } state; }) |
1107 | ); | 1095 | ); |
1108 | size -= t; | ||
1109 | next += t; | ||
1110 | 1096 | ||
1111 | dump_intmask("int_status", readl(®s->int_status), &next, &size); | 1097 | dump_intmask(m, "int_status", readl(®s->int_status)); |
1112 | dump_intmask("int_enable", readl(®s->int_enable), &next, &size); | 1098 | dump_intmask(m, "int_enable", readl(®s->int_enable)); |
1113 | 1099 | ||
1114 | if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0) | 1100 | if (!is_usb_connected || !dev->driver || (tmp & PW_PULLUP) == 0) |
1115 | goto done; | 1101 | goto done; |
1116 | 1102 | ||
1117 | /* registers for (active) device and ep0 */ | 1103 | /* registers for (active) device and ep0 */ |
1118 | t = scnprintf(next, size, "\nirqs %lu\ndataset %02x " | 1104 | if (seq_printf(m, "\nirqs %lu\ndataset %02x " |
1119 | "single.bcs %02x.%02x state %x addr %u\n", | 1105 | "single.bcs %02x.%02x state %x addr %u\n", |
1120 | dev->irqs, readl(®s->DataSet), | 1106 | dev->irqs, readl(®s->DataSet), |
1121 | readl(®s->EPxSingle), readl(®s->EPxBCS), | 1107 | readl(®s->EPxSingle), readl(®s->EPxBCS), |
1122 | readl(®s->UsbState), | 1108 | readl(®s->UsbState), |
1123 | readl(®s->address)); | 1109 | readl(®s->address)) < 0) |
1124 | size -= t; | 1110 | goto done; |
1125 | next += t; | ||
1126 | 1111 | ||
1127 | tmp = readl(®s->dma_master); | 1112 | tmp = readl(®s->dma_master); |
1128 | t = scnprintf(next, size, | 1113 | if (seq_printf(m, |
1129 | "dma %03X =" EIGHTBITS "%s %s\n", tmp, | 1114 | "dma %03X =" EIGHTBITS "%s %s\n", tmp, |
1130 | (tmp & MST_EOPB_DIS) ? " eopb-" : "", | 1115 | (tmp & MST_EOPB_DIS) ? " eopb-" : "", |
1131 | (tmp & MST_EOPB_ENA) ? " eopb+" : "", | 1116 | (tmp & MST_EOPB_ENA) ? " eopb+" : "", |
@@ -1140,9 +1125,8 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, | |||
1140 | (tmp & MST_WR_ENA) ? " OUT" : "", | 1125 | (tmp & MST_WR_ENA) ? " OUT" : "", |
1141 | (tmp & MST_CONNECTION) | 1126 | (tmp & MST_CONNECTION) |
1142 | ? "ep1in/ep2out" | 1127 | ? "ep1in/ep2out" |
1143 | : "ep1out/ep2in"); | 1128 | : "ep1out/ep2in") < 0) |
1144 | size -= t; | 1129 | goto done; |
1145 | next += t; | ||
1146 | 1130 | ||
1147 | /* dump endpoint queues */ | 1131 | /* dump endpoint queues */ |
1148 | for (i = 0; i < 4; i++) { | 1132 | for (i = 0; i < 4; i++) { |
@@ -1153,7 +1137,7 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, | |||
1153 | continue; | 1137 | continue; |
1154 | 1138 | ||
1155 | tmp = readl(ep->reg_status); | 1139 | tmp = readl(ep->reg_status); |
1156 | t = scnprintf(next, size, | 1140 | if (seq_printf(m, |
1157 | "%s %s max %u %s, irqs %lu, " | 1141 | "%s %s max %u %s, irqs %lu, " |
1158 | "status %02x (%s) " FOURBITS "\n", | 1142 | "status %02x (%s) " FOURBITS "\n", |
1159 | ep->ep.name, | 1143 | ep->ep.name, |
@@ -1186,18 +1170,12 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, | |||
1186 | (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", | 1170 | (tmp & EPxSTATUS_SUSPEND) ? " suspend" : "", |
1187 | (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", | 1171 | (tmp & EPxSTATUS_FIFO_DISABLE) ? " disable" : "", |
1188 | (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" | 1172 | (tmp & EPxSTATUS_STAGE_ERROR) ? " ep0stat" : "" |
1189 | ); | 1173 | ) < 0) |
1190 | if (t <= 0 || t > size) | ||
1191 | goto done; | 1174 | goto done; |
1192 | size -= t; | ||
1193 | next += t; | ||
1194 | 1175 | ||
1195 | if (list_empty(&ep->queue)) { | 1176 | if (list_empty(&ep->queue)) { |
1196 | t = scnprintf(next, size, "\t(nothing queued)\n"); | 1177 | if (seq_puts(m, "\t(nothing queued)\n") < 0) |
1197 | if (t <= 0 || t > size) | ||
1198 | goto done; | 1178 | goto done; |
1199 | size -= t; | ||
1200 | next += t; | ||
1201 | continue; | 1179 | continue; |
1202 | } | 1180 | } |
1203 | list_for_each_entry(req, &ep->queue, queue) { | 1181 | list_for_each_entry(req, &ep->queue, queue) { |
@@ -1211,23 +1189,34 @@ udc_proc_read(char *buffer, char **start, off_t off, int count, | |||
1211 | } else | 1189 | } else |
1212 | tmp = req->req.actual; | 1190 | tmp = req->req.actual; |
1213 | 1191 | ||
1214 | t = scnprintf(next, size, | 1192 | if (seq_printf(m, |
1215 | "\treq %p len %u/%u buf %p\n", | 1193 | "\treq %p len %u/%u buf %p\n", |
1216 | &req->req, tmp, req->req.length, | 1194 | &req->req, tmp, req->req.length, |
1217 | req->req.buf); | 1195 | req->req.buf) < 0) |
1218 | if (t <= 0 || t > size) | ||
1219 | goto done; | 1196 | goto done; |
1220 | size -= t; | ||
1221 | next += t; | ||
1222 | } | 1197 | } |
1223 | } | 1198 | } |
1224 | 1199 | ||
1225 | done: | 1200 | done: |
1226 | local_irq_restore(flags); | 1201 | local_irq_restore(flags); |
1227 | *eof = 1; | 1202 | return 0; |
1228 | return count - size; | 1203 | } |
1204 | |||
1205 | /* | ||
1206 | * seq_file wrappers for procfile show routines. | ||
1207 | */ | ||
1208 | static int udc_proc_open(struct inode *inode, struct file *file) | ||
1209 | { | ||
1210 | return single_open(file, udc_proc_read, PDE_DATA(file_inode(file))); | ||
1229 | } | 1211 | } |
1230 | 1212 | ||
1213 | static const struct file_operations udc_proc_fops = { | ||
1214 | .open = udc_proc_open, | ||
1215 | .read = seq_read, | ||
1216 | .llseek = seq_lseek, | ||
1217 | .release = seq_release, | ||
1218 | }; | ||
1219 | |||
1231 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ | 1220 | #endif /* CONFIG_USB_GADGET_DEBUG_FILES */ |
1232 | 1221 | ||
1233 | /*-------------------------------------------------------------------------*/ | 1222 | /*-------------------------------------------------------------------------*/ |
@@ -1796,7 +1785,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1796 | 1785 | ||
1797 | 1786 | ||
1798 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 1787 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
1799 | create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev); | 1788 | proc_create_data(proc_node_name, 0, NULL, &udc_proc_fops, dev); |
1800 | #endif | 1789 | #endif |
1801 | 1790 | ||
1802 | retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget, | 1791 | retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget, |