Merge tag 'staging-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[linux-2.6-microblaze.git] / drivers / staging / most / usb / usb.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * usb.c - Hardware dependent module for USB
4  *
5  * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG
6  */
7
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9 #include <linux/module.h>
10 #include <linux/fs.h>
11 #include <linux/usb.h>
12 #include <linux/slab.h>
13 #include <linux/init.h>
14 #include <linux/cdev.h>
15 #include <linux/device.h>
16 #include <linux/list.h>
17 #include <linux/completion.h>
18 #include <linux/mutex.h>
19 #include <linux/spinlock.h>
20 #include <linux/interrupt.h>
21 #include <linux/workqueue.h>
22 #include <linux/sysfs.h>
23 #include <linux/dma-mapping.h>
24 #include <linux/etherdevice.h>
25 #include <linux/uaccess.h>
26
27 #include "../most.h"
28
29 #define USB_MTU                 512
30 #define NO_ISOCHRONOUS_URB      0
31 #define AV_PACKETS_PER_XACT     2
32 #define BUF_CHAIN_SIZE          0xFFFF
33 #define MAX_NUM_ENDPOINTS       30
34 #define MAX_SUFFIX_LEN          10
35 #define MAX_STRING_LEN          80
36 #define MAX_BUF_SIZE            0xFFFF
37
38 #define USB_VENDOR_ID_SMSC      0x0424  /* VID: SMSC */
39 #define USB_DEV_ID_BRDG         0xC001  /* PID: USB Bridge */
40 #define USB_DEV_ID_OS81118      0xCF18  /* PID: USB OS81118 */
41 #define USB_DEV_ID_OS81119      0xCF19  /* PID: USB OS81119 */
42 #define USB_DEV_ID_OS81210      0xCF30  /* PID: USB OS81210 */
43 /* DRCI Addresses */
44 #define DRCI_REG_NI_STATE       0x0100
45 #define DRCI_REG_PACKET_BW      0x0101
46 #define DRCI_REG_NODE_ADDR      0x0102
47 #define DRCI_REG_NODE_POS       0x0103
48 #define DRCI_REG_MEP_FILTER     0x0140
49 #define DRCI_REG_HASH_TBL0      0x0141
50 #define DRCI_REG_HASH_TBL1      0x0142
51 #define DRCI_REG_HASH_TBL2      0x0143
52 #define DRCI_REG_HASH_TBL3      0x0144
53 #define DRCI_REG_HW_ADDR_HI     0x0145
54 #define DRCI_REG_HW_ADDR_MI     0x0146
55 #define DRCI_REG_HW_ADDR_LO     0x0147
56 #define DRCI_REG_BASE           0x1100
57 #define DRCI_COMMAND            0x02
58 #define DRCI_READ_REQ           0xA0
59 #define DRCI_WRITE_REQ          0xA1
60
61 /**
62  * struct most_dci_obj - Direct Communication Interface
63  * @kobj:position in sysfs
64  * @usb_device: pointer to the usb device
65  * @reg_addr: register address for arbitrary DCI access
66  */
67 struct most_dci_obj {
68         struct device dev;
69         struct usb_device *usb_device;
70         u16 reg_addr;
71 };
72
73 #define to_dci_obj(p) container_of(p, struct most_dci_obj, dev)
74
75 struct most_dev;
76
77 struct clear_hold_work {
78         struct work_struct ws;
79         struct most_dev *mdev;
80         unsigned int channel;
81         int pipe;
82 };
83
84 #define to_clear_hold_work(w) container_of(w, struct clear_hold_work, ws)
85
86 /**
87  * struct most_dev - holds all usb interface specific stuff
88  * @usb_device: pointer to usb device
89  * @iface: hardware interface
90  * @cap: channel capabilities
91  * @conf: channel configuration
92  * @dci: direct communication interface of hardware
93  * @ep_address: endpoint address table
94  * @description: device description
95  * @suffix: suffix for channel name
96  * @channel_lock: synchronize channel access
97  * @padding_active: indicates channel uses padding
98  * @is_channel_healthy: health status table of each channel
99  * @busy_urbs: list of anchored items
100  * @io_mutex: synchronize I/O with disconnect
101  * @link_stat_timer: timer for link status reports
102  * @poll_work_obj: work for polling link status
103  */
104 struct most_dev {
105         struct device dev;
106         struct usb_device *usb_device;
107         struct most_interface iface;
108         struct most_channel_capability *cap;
109         struct most_channel_config *conf;
110         struct most_dci_obj *dci;
111         u8 *ep_address;
112         char description[MAX_STRING_LEN];
113         char suffix[MAX_NUM_ENDPOINTS][MAX_SUFFIX_LEN];
114         spinlock_t channel_lock[MAX_NUM_ENDPOINTS]; /* sync channel access */
115         bool padding_active[MAX_NUM_ENDPOINTS];
116         bool is_channel_healthy[MAX_NUM_ENDPOINTS];
117         struct clear_hold_work clear_work[MAX_NUM_ENDPOINTS];
118         struct usb_anchor *busy_urbs;
119         struct mutex io_mutex;
120         struct timer_list link_stat_timer;
121         struct work_struct poll_work_obj;
122         void (*on_netinfo)(struct most_interface *most_iface,
123                            unsigned char link_state, unsigned char *addrs);
124 };
125
126 #define to_mdev(d) container_of(d, struct most_dev, iface)
127 #define to_mdev_from_dev(d) container_of(d, struct most_dev, dev)
128 #define to_mdev_from_work(w) container_of(w, struct most_dev, poll_work_obj)
129
130 static void wq_clear_halt(struct work_struct *wq_obj);
131 static void wq_netinfo(struct work_struct *wq_obj);
132
133 /**
134  * drci_rd_reg - read a DCI register
135  * @dev: usb device
136  * @reg: register address
137  * @buf: buffer to store data
138  *
139  * This is reads data from INIC's direct register communication interface
140  */
141 static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
142 {
143         int retval;
144         __le16 *dma_buf = kzalloc(sizeof(*dma_buf), GFP_KERNEL);
145         u8 req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
146
147         if (!dma_buf)
148                 return -ENOMEM;
149
150         retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
151                                  DRCI_READ_REQ, req_type,
152                                  0x0000,
153                                  reg, dma_buf, sizeof(*dma_buf), 5 * HZ);
154         *buf = le16_to_cpu(*dma_buf);
155         kfree(dma_buf);
156
157         return retval;
158 }
159
160 /**
161  * drci_wr_reg - write a DCI register
162  * @dev: usb device
163  * @reg: register address
164  * @data: data to write
165  *
166  * This is writes data to INIC's direct register communication interface
167  */
168 static inline int drci_wr_reg(struct usb_device *dev, u16 reg, u16 data)
169 {
170         return usb_control_msg(dev,
171                                usb_sndctrlpipe(dev, 0),
172                                DRCI_WRITE_REQ,
173                                USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
174                                data,
175                                reg,
176                                NULL,
177                                0,
178                                5 * HZ);
179 }
180
181 static inline int start_sync_ep(struct usb_device *usb_dev, u16 ep)
182 {
183         return drci_wr_reg(usb_dev, DRCI_REG_BASE + DRCI_COMMAND + ep * 16, 1);
184 }
185
186 /**
187  * get_stream_frame_size - calculate frame size of current configuration
188  * @cfg: channel configuration
189  */
190 static unsigned int get_stream_frame_size(struct most_channel_config *cfg)
191 {
192         unsigned int frame_size = 0;
193         unsigned int sub_size = cfg->subbuffer_size;
194
195         if (!sub_size) {
196                 pr_warn("Misconfig: Subbuffer size zero.\n");
197                 return frame_size;
198         }
199         switch (cfg->data_type) {
200         case MOST_CH_ISOC:
201                 frame_size = AV_PACKETS_PER_XACT * sub_size;
202                 break;
203         case MOST_CH_SYNC:
204                 if (cfg->packets_per_xact == 0) {
205                         pr_warn("Misconfig: Packets per XACT zero\n");
206                         frame_size = 0;
207                 } else if (cfg->packets_per_xact == 0xFF) {
208                         frame_size = (USB_MTU / sub_size) * sub_size;
209                 } else {
210                         frame_size = cfg->packets_per_xact * sub_size;
211                 }
212                 break;
213         default:
214                 pr_warn("Query frame size of non-streaming channel\n");
215                 break;
216         }
217         return frame_size;
218 }
219
220 /**
221  * hdm_poison_channel - mark buffers of this channel as invalid
222  * @iface: pointer to the interface
223  * @channel: channel ID
224  *
225  * This unlinks all URBs submitted to the HCD,
226  * calls the associated completion function of the core and removes
227  * them from the list.
228  *
229  * Returns 0 on success or error code otherwise.
230  */
231 static int hdm_poison_channel(struct most_interface *iface, int channel)
232 {
233         struct most_dev *mdev = to_mdev(iface);
234         unsigned long flags;
235         spinlock_t *lock; /* temp. lock */
236
237         if (unlikely(!iface)) {
238                 dev_warn(&mdev->usb_device->dev, "Poison: Bad interface.\n");
239                 return -EIO;
240         }
241         if (unlikely(channel < 0 || channel >= iface->num_channels)) {
242                 dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n");
243                 return -ECHRNG;
244         }
245
246         lock = mdev->channel_lock + channel;
247         spin_lock_irqsave(lock, flags);
248         mdev->is_channel_healthy[channel] = false;
249         spin_unlock_irqrestore(lock, flags);
250
251         cancel_work_sync(&mdev->clear_work[channel].ws);
252
253         mutex_lock(&mdev->io_mutex);
254         usb_kill_anchored_urbs(&mdev->busy_urbs[channel]);
255         if (mdev->padding_active[channel])
256                 mdev->padding_active[channel] = false;
257
258         if (mdev->conf[channel].data_type == MOST_CH_ASYNC) {
259                 del_timer_sync(&mdev->link_stat_timer);
260                 cancel_work_sync(&mdev->poll_work_obj);
261         }
262         mutex_unlock(&mdev->io_mutex);
263         return 0;
264 }
265
266 /**
267  * hdm_add_padding - add padding bytes
268  * @mdev: most device
269  * @channel: channel ID
270  * @mbo: buffer object
271  *
272  * This inserts the INIC hardware specific padding bytes into a streaming
273  * channel's buffer
274  */
275 static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
276 {
277         struct most_channel_config *conf = &mdev->conf[channel];
278         unsigned int frame_size = get_stream_frame_size(conf);
279         unsigned int j, num_frames;
280
281         if (!frame_size)
282                 return -EIO;
283         num_frames = mbo->buffer_length / frame_size;
284
285         if (num_frames < 1) {
286                 dev_err(&mdev->usb_device->dev,
287                         "Missed minimal transfer unit.\n");
288                 return -EIO;
289         }
290
291         for (j = num_frames - 1; j > 0; j--)
292                 memmove(mbo->virt_address + j * USB_MTU,
293                         mbo->virt_address + j * frame_size,
294                         frame_size);
295         mbo->buffer_length = num_frames * USB_MTU;
296         return 0;
297 }
298
299 /**
300  * hdm_remove_padding - remove padding bytes
301  * @mdev: most device
302  * @channel: channel ID
303  * @mbo: buffer object
304  *
305  * This takes the INIC hardware specific padding bytes off a streaming
306  * channel's buffer.
307  */
308 static int hdm_remove_padding(struct most_dev *mdev, int channel,
309                               struct mbo *mbo)
310 {
311         struct most_channel_config *const conf = &mdev->conf[channel];
312         unsigned int frame_size = get_stream_frame_size(conf);
313         unsigned int j, num_frames;
314
315         if (!frame_size)
316                 return -EIO;
317         num_frames = mbo->processed_length / USB_MTU;
318
319         for (j = 1; j < num_frames; j++)
320                 memmove(mbo->virt_address + frame_size * j,
321                         mbo->virt_address + USB_MTU * j,
322                         frame_size);
323
324         mbo->processed_length = frame_size * num_frames;
325         return 0;
326 }
327
328 /**
329  * hdm_write_completion - completion function for submitted Tx URBs
330  * @urb: the URB that has been completed
331  *
332  * This checks the status of the completed URB. In case the URB has been
333  * unlinked before, it is immediately freed. On any other error the MBO
334  * transfer flag is set. On success it frees allocated resources and calls
335  * the completion function.
336  *
337  * Context: interrupt!
338  */
339 static void hdm_write_completion(struct urb *urb)
340 {
341         struct mbo *mbo = urb->context;
342         struct most_dev *mdev = to_mdev(mbo->ifp);
343         unsigned int channel = mbo->hdm_channel_id;
344         spinlock_t *lock = mdev->channel_lock + channel;
345         unsigned long flags;
346
347         spin_lock_irqsave(lock, flags);
348
349         mbo->processed_length = 0;
350         mbo->status = MBO_E_INVAL;
351         if (likely(mdev->is_channel_healthy[channel])) {
352                 switch (urb->status) {
353                 case 0:
354                 case -ESHUTDOWN:
355                         mbo->processed_length = urb->actual_length;
356                         mbo->status = MBO_SUCCESS;
357                         break;
358                 case -EPIPE:
359                         dev_warn(&mdev->usb_device->dev,
360                                  "Broken pipe on ep%02x\n",
361                                  mdev->ep_address[channel]);
362                         mdev->is_channel_healthy[channel] = false;
363                         mdev->clear_work[channel].pipe = urb->pipe;
364                         schedule_work(&mdev->clear_work[channel].ws);
365                         break;
366                 case -ENODEV:
367                 case -EPROTO:
368                         mbo->status = MBO_E_CLOSE;
369                         break;
370                 }
371         }
372
373         spin_unlock_irqrestore(lock, flags);
374
375         if (likely(mbo->complete))
376                 mbo->complete(mbo);
377         usb_free_urb(urb);
378 }
379
380 /**
381  * hdm_read_completion - completion function for submitted Rx URBs
382  * @urb: the URB that has been completed
383  *
384  * This checks the status of the completed URB. In case the URB has been
385  * unlinked before it is immediately freed. On any other error the MBO transfer
386  * flag is set. On success it frees allocated resources, removes
387  * padding bytes -if necessary- and calls the completion function.
388  *
389  * Context: interrupt!
390  *
391  * **************************************************************************
392  *                   Error codes returned by in urb->status
393  *                   or in iso_frame_desc[n].status (for ISO)
394  * *************************************************************************
395  *
396  * USB device drivers may only test urb status values in completion handlers.
397  * This is because otherwise there would be a race between HCDs updating
398  * these values on one CPU, and device drivers testing them on another CPU.
399  *
400  * A transfer's actual_length may be positive even when an error has been
401  * reported.  That's because transfers often involve several packets, so that
402  * one or more packets could finish before an error stops further endpoint I/O.
403  *
404  * For isochronous URBs, the urb status value is non-zero only if the URB is
405  * unlinked, the device is removed, the host controller is disabled or the total
406  * transferred length is less than the requested length and the URB_SHORT_NOT_OK
407  * flag is set.  Completion handlers for isochronous URBs should only see
408  * urb->status set to zero, -ENOENT, -ECONNRESET, -ESHUTDOWN, or -EREMOTEIO.
409  * Individual frame descriptor status fields may report more status codes.
410  *
411  *
412  * 0                    Transfer completed successfully
413  *
414  * -ENOENT              URB was synchronously unlinked by usb_unlink_urb
415  *
416  * -EINPROGRESS         URB still pending, no results yet
417  *                      (That is, if drivers see this it's a bug.)
418  *
419  * -EPROTO (*, **)      a) bitstuff error
420  *                      b) no response packet received within the
421  *                         prescribed bus turn-around time
422  *                      c) unknown USB error
423  *
424  * -EILSEQ (*, **)      a) CRC mismatch
425  *                      b) no response packet received within the
426  *                         prescribed bus turn-around time
427  *                      c) unknown USB error
428  *
429  *                      Note that often the controller hardware does not
430  *                      distinguish among cases a), b), and c), so a
431  *                      driver cannot tell whether there was a protocol
432  *                      error, a failure to respond (often caused by
433  *                      device disconnect), or some other fault.
434  *
435  * -ETIME (**)          No response packet received within the prescribed
436  *                      bus turn-around time.  This error may instead be
437  *                      reported as -EPROTO or -EILSEQ.
438  *
439  * -ETIMEDOUT           Synchronous USB message functions use this code
440  *                      to indicate timeout expired before the transfer
441  *                      completed, and no other error was reported by HC.
442  *
443  * -EPIPE (**)          Endpoint stalled.  For non-control endpoints,
444  *                      reset this status with usb_clear_halt().
445  *
446  * -ECOMM               During an IN transfer, the host controller
447  *                      received data from an endpoint faster than it
448  *                      could be written to system memory
449  *
450  * -ENOSR               During an OUT transfer, the host controller
451  *                      could not retrieve data from system memory fast
452  *                      enough to keep up with the USB data rate
453  *
454  * -EOVERFLOW (*)       The amount of data returned by the endpoint was
455  *                      greater than either the max packet size of the
456  *                      endpoint or the remaining buffer size.  "Babble".
457  *
458  * -EREMOTEIO           The data read from the endpoint did not fill the
459  *                      specified buffer, and URB_SHORT_NOT_OK was set in
460  *                      urb->transfer_flags.
461  *
462  * -ENODEV              Device was removed.  Often preceded by a burst of
463  *                      other errors, since the hub driver doesn't detect
464  *                      device removal events immediately.
465  *
466  * -EXDEV               ISO transfer only partially completed
467  *                      (only set in iso_frame_desc[n].status, not urb->status)
468  *
469  * -EINVAL              ISO madness, if this happens: Log off and go home
470  *
471  * -ECONNRESET          URB was asynchronously unlinked by usb_unlink_urb
472  *
473  * -ESHUTDOWN           The device or host controller has been disabled due
474  *                      to some problem that could not be worked around,
475  *                      such as a physical disconnect.
476  *
477  *
478  * (*) Error codes like -EPROTO, -EILSEQ and -EOVERFLOW normally indicate
479  * hardware problems such as bad devices (including firmware) or cables.
480  *
481  * (**) This is also one of several codes that different kinds of host
482  * controller use to indicate a transfer has failed because of device
483  * disconnect.  In the interval before the hub driver starts disconnect
484  * processing, devices may receive such fault reports for every request.
485  *
486  * See <https://www.kernel.org/doc/Documentation/driver-api/usb/error-codes.rst>
487  */
488 static void hdm_read_completion(struct urb *urb)
489 {
490         struct mbo *mbo = urb->context;
491         struct most_dev *mdev = to_mdev(mbo->ifp);
492         unsigned int channel = mbo->hdm_channel_id;
493         struct device *dev = &mdev->usb_device->dev;
494         spinlock_t *lock = mdev->channel_lock + channel;
495         unsigned long flags;
496
497         spin_lock_irqsave(lock, flags);
498
499         mbo->processed_length = 0;
500         mbo->status = MBO_E_INVAL;
501         if (likely(mdev->is_channel_healthy[channel])) {
502                 switch (urb->status) {
503                 case 0:
504                 case -ESHUTDOWN:
505                         mbo->processed_length = urb->actual_length;
506                         mbo->status = MBO_SUCCESS;
507                         if (mdev->padding_active[channel] &&
508                             hdm_remove_padding(mdev, channel, mbo)) {
509                                 mbo->processed_length = 0;
510                                 mbo->status = MBO_E_INVAL;
511                         }
512                         break;
513                 case -EPIPE:
514                         dev_warn(dev, "Broken pipe on ep%02x\n",
515                                  mdev->ep_address[channel]);
516                         mdev->is_channel_healthy[channel] = false;
517                         mdev->clear_work[channel].pipe = urb->pipe;
518                         schedule_work(&mdev->clear_work[channel].ws);
519                         break;
520                 case -ENODEV:
521                 case -EPROTO:
522                         mbo->status = MBO_E_CLOSE;
523                         break;
524                 case -EOVERFLOW:
525                         dev_warn(dev, "Babble on ep%02x\n",
526                                  mdev->ep_address[channel]);
527                         break;
528                 }
529         }
530
531         spin_unlock_irqrestore(lock, flags);
532
533         if (likely(mbo->complete))
534                 mbo->complete(mbo);
535         usb_free_urb(urb);
536 }
537
538 /**
539  * hdm_enqueue - receive a buffer to be used for data transfer
540  * @iface: interface to enqueue to
541  * @channel: ID of the channel
542  * @mbo: pointer to the buffer object
543  *
544  * This allocates a new URB and fills it according to the channel
545  * that is being used for transmission of data. Before the URB is
546  * submitted it is stored in the private anchor list.
547  *
548  * Returns 0 on success. On any error the URB is freed and a error code
549  * is returned.
550  *
551  * Context: Could in _some_ cases be interrupt!
552  */
553 static int hdm_enqueue(struct most_interface *iface, int channel,
554                        struct mbo *mbo)
555 {
556         struct most_dev *mdev;
557         struct most_channel_config *conf;
558         int retval = 0;
559         struct urb *urb;
560         unsigned long length;
561         void *virt_address;
562
563         if (unlikely(!iface || !mbo))
564                 return -EIO;
565         if (unlikely(iface->num_channels <= channel || channel < 0))
566                 return -ECHRNG;
567
568         mdev = to_mdev(iface);
569         conf = &mdev->conf[channel];
570
571         mutex_lock(&mdev->io_mutex);
572         if (!mdev->usb_device) {
573                 retval = -ENODEV;
574                 goto unlock_io_mutex;
575         }
576
577         urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_ATOMIC);
578         if (!urb) {
579                 retval = -ENOMEM;
580                 goto unlock_io_mutex;
581         }
582
583         if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&
584             hdm_add_padding(mdev, channel, mbo)) {
585                 retval = -EIO;
586                 goto err_free_urb;
587         }
588
589         urb->transfer_dma = mbo->bus_address;
590         virt_address = mbo->virt_address;
591         length = mbo->buffer_length;
592
593         if (conf->direction & MOST_CH_TX) {
594                 usb_fill_bulk_urb(urb, mdev->usb_device,
595                                   usb_sndbulkpipe(mdev->usb_device,
596                                                   mdev->ep_address[channel]),
597                                   virt_address,
598                                   length,
599                                   hdm_write_completion,
600                                   mbo);
601                 if (conf->data_type != MOST_CH_ISOC &&
602                     conf->data_type != MOST_CH_SYNC)
603                         urb->transfer_flags |= URB_ZERO_PACKET;
604         } else {
605                 usb_fill_bulk_urb(urb, mdev->usb_device,
606                                   usb_rcvbulkpipe(mdev->usb_device,
607                                                   mdev->ep_address[channel]),
608                                   virt_address,
609                                   length + conf->extra_len,
610                                   hdm_read_completion,
611                                   mbo);
612         }
613         urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
614
615         usb_anchor_urb(urb, &mdev->busy_urbs[channel]);
616
617         retval = usb_submit_urb(urb, GFP_KERNEL);
618         if (retval) {
619                 dev_err(&mdev->usb_device->dev,
620                         "URB submit failed with error %d.\n", retval);
621                 goto err_unanchor_urb;
622         }
623         goto unlock_io_mutex;
624
625 err_unanchor_urb:
626         usb_unanchor_urb(urb);
627 err_free_urb:
628         usb_free_urb(urb);
629 unlock_io_mutex:
630         mutex_unlock(&mdev->io_mutex);
631         return retval;
632 }
633
634 static void *hdm_dma_alloc(struct mbo *mbo, u32 size)
635 {
636         struct most_dev *mdev = to_mdev(mbo->ifp);
637
638         return usb_alloc_coherent(mdev->usb_device, size, GFP_KERNEL,
639                                   &mbo->bus_address);
640 }
641
642 static void hdm_dma_free(struct mbo *mbo, u32 size)
643 {
644         struct most_dev *mdev = to_mdev(mbo->ifp);
645
646         usb_free_coherent(mdev->usb_device, size, mbo->virt_address,
647                           mbo->bus_address);
648 }
649
650 /**
651  * hdm_configure_channel - receive channel configuration from core
652  * @iface: interface
653  * @channel: channel ID
654  * @conf: structure that holds the configuration information
655  *
656  * The attached network interface controller (NIC) supports a padding mode
657  * to avoid short packets on USB, hence increasing the performance due to a
658  * lower interrupt load. This mode is default for synchronous data and can
659  * be switched on for isochronous data. In case padding is active the
660  * driver needs to know the frame size of the payload in order to calculate
661  * the number of bytes it needs to pad when transmitting or to cut off when
662  * receiving data.
663  *
664  */
665 static int hdm_configure_channel(struct most_interface *iface, int channel,
666                                  struct most_channel_config *conf)
667 {
668         unsigned int num_frames;
669         unsigned int frame_size;
670         struct most_dev *mdev = to_mdev(iface);
671         struct device *dev = &mdev->usb_device->dev;
672
673         mdev->is_channel_healthy[channel] = true;
674         mdev->clear_work[channel].channel = channel;
675         mdev->clear_work[channel].mdev = mdev;
676         INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt);
677
678         if (unlikely(!iface || !conf)) {
679                 dev_err(dev, "Bad interface or config pointer.\n");
680                 return -EINVAL;
681         }
682         if (unlikely(channel < 0 || channel >= iface->num_channels)) {
683                 dev_err(dev, "Channel ID out of range.\n");
684                 return -EINVAL;
685         }
686         if (!conf->num_buffers || !conf->buffer_size) {
687                 dev_err(dev, "Misconfig: buffer size or #buffers zero.\n");
688                 return -EINVAL;
689         }
690
691         if (conf->data_type != MOST_CH_SYNC &&
692             !(conf->data_type == MOST_CH_ISOC &&
693               conf->packets_per_xact != 0xFF)) {
694                 mdev->padding_active[channel] = false;
695                 /*
696                  * Since the NIC's padding mode is not going to be
697                  * used, we can skip the frame size calculations and
698                  * move directly on to exit.
699                  */
700                 goto exit;
701         }
702
703         mdev->padding_active[channel] = true;
704
705         frame_size = get_stream_frame_size(conf);
706         if (frame_size == 0 || frame_size > USB_MTU) {
707                 dev_warn(dev, "Misconfig: frame size wrong\n");
708                 return -EINVAL;
709         }
710
711         num_frames = conf->buffer_size / frame_size;
712
713         if (conf->buffer_size % frame_size) {
714                 u16 old_size = conf->buffer_size;
715
716                 conf->buffer_size = num_frames * frame_size;
717                 dev_warn(dev, "%s: fixed buffer size (%d -> %d)\n",
718                          mdev->suffix[channel], old_size, conf->buffer_size);
719         }
720
721         /* calculate extra length to comply w/ HW padding */
722         conf->extra_len = num_frames * (USB_MTU - frame_size);
723
724 exit:
725         mdev->conf[channel] = *conf;
726         if (conf->data_type == MOST_CH_ASYNC) {
727                 u16 ep = mdev->ep_address[channel];
728
729                 if (start_sync_ep(mdev->usb_device, ep) < 0)
730                         dev_warn(dev, "sync for ep%02x failed", ep);
731         }
732         return 0;
733 }
734
735 /**
736  * hdm_request_netinfo - request network information
737  * @iface: pointer to interface
738  * @channel: channel ID
739  *
740  * This is used as trigger to set up the link status timer that
741  * polls for the NI state of the INIC every 2 seconds.
742  *
743  */
744 static void hdm_request_netinfo(struct most_interface *iface, int channel,
745                                 void (*on_netinfo)(struct most_interface *,
746                                                    unsigned char,
747                                                    unsigned char *))
748 {
749         struct most_dev *mdev;
750
751         BUG_ON(!iface);
752         mdev = to_mdev(iface);
753         mdev->on_netinfo = on_netinfo;
754         if (!on_netinfo)
755                 return;
756
757         mdev->link_stat_timer.expires = jiffies + HZ;
758         mod_timer(&mdev->link_stat_timer, mdev->link_stat_timer.expires);
759 }
760
761 /**
762  * link_stat_timer_handler - schedule work obtaining mac address and link status
763  * @data: pointer to USB device instance
764  *
765  * The handler runs in interrupt context. That's why we need to defer the
766  * tasks to a work queue.
767  */
768 static void link_stat_timer_handler(struct timer_list *t)
769 {
770         struct most_dev *mdev = from_timer(mdev, t, link_stat_timer);
771
772         schedule_work(&mdev->poll_work_obj);
773         mdev->link_stat_timer.expires = jiffies + (2 * HZ);
774         add_timer(&mdev->link_stat_timer);
775 }
776
777 /**
778  * wq_netinfo - work queue function to deliver latest networking information
779  * @wq_obj: object that holds data for our deferred work to do
780  *
781  * This retrieves the network interface status of the USB INIC
782  */
783 static void wq_netinfo(struct work_struct *wq_obj)
784 {
785         struct most_dev *mdev = to_mdev_from_work(wq_obj);
786         struct usb_device *usb_device = mdev->usb_device;
787         struct device *dev = &usb_device->dev;
788         u16 hi, mi, lo, link;
789         u8 hw_addr[6];
790
791         if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi) < 0) {
792                 dev_err(dev, "Vendor request 'hw_addr_hi' failed\n");
793                 return;
794         }
795
796         if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi) < 0) {
797                 dev_err(dev, "Vendor request 'hw_addr_mid' failed\n");
798                 return;
799         }
800
801         if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo) < 0) {
802                 dev_err(dev, "Vendor request 'hw_addr_low' failed\n");
803                 return;
804         }
805
806         if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link) < 0) {
807                 dev_err(dev, "Vendor request 'link status' failed\n");
808                 return;
809         }
810
811         hw_addr[0] = hi >> 8;
812         hw_addr[1] = hi;
813         hw_addr[2] = mi >> 8;
814         hw_addr[3] = mi;
815         hw_addr[4] = lo >> 8;
816         hw_addr[5] = lo;
817
818         if (mdev->on_netinfo)
819                 mdev->on_netinfo(&mdev->iface, link, hw_addr);
820 }
821
822 /**
823  * wq_clear_halt - work queue function
824  * @wq_obj: work_struct object to execute
825  *
826  * This sends a clear_halt to the given USB pipe.
827  */
828 static void wq_clear_halt(struct work_struct *wq_obj)
829 {
830         struct clear_hold_work *clear_work = to_clear_hold_work(wq_obj);
831         struct most_dev *mdev = clear_work->mdev;
832         unsigned int channel = clear_work->channel;
833         int pipe = clear_work->pipe;
834
835         mutex_lock(&mdev->io_mutex);
836         most_stop_enqueue(&mdev->iface, channel);
837         usb_kill_anchored_urbs(&mdev->busy_urbs[channel]);
838         if (usb_clear_halt(mdev->usb_device, pipe))
839                 dev_warn(&mdev->usb_device->dev, "Failed to reset endpoint.\n");
840
841         /* If the functional Stall condition has been set on an
842          * asynchronous rx channel, we need to clear the tx channel
843          * too, since the hardware runs its clean-up sequence on both
844          * channels, as they are physically one on the network.
845          *
846          * The USB interface that exposes the asynchronous channels
847          * contains always two endpoints, and two only.
848          */
849         if (mdev->conf[channel].data_type == MOST_CH_ASYNC &&
850             mdev->conf[channel].direction == MOST_CH_RX) {
851                 int peer = 1 - channel;
852                 int snd_pipe = usb_sndbulkpipe(mdev->usb_device,
853                                                mdev->ep_address[peer]);
854                 usb_clear_halt(mdev->usb_device, snd_pipe);
855         }
856         mdev->is_channel_healthy[channel] = true;
857         most_resume_enqueue(&mdev->iface, channel);
858         mutex_unlock(&mdev->io_mutex);
859 }
860
861 /**
862  * hdm_usb_fops - file operation table for USB driver
863  */
864 static const struct file_operations hdm_usb_fops = {
865         .owner = THIS_MODULE,
866 };
867
868 /**
869  * usb_device_id - ID table for HCD device probing
870  */
871 static const struct usb_device_id usbid[] = {
872         { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_BRDG), },
873         { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81118), },
874         { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81119), },
875         { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81210), },
876         { } /* Terminating entry */
877 };
878
879 struct regs {
880         const char *name;
881         u16 reg;
882 };
883
884 static const struct regs ro_regs[] = {
885         { "ni_state", DRCI_REG_NI_STATE },
886         { "packet_bandwidth", DRCI_REG_PACKET_BW },
887         { "node_address", DRCI_REG_NODE_ADDR },
888         { "node_position", DRCI_REG_NODE_POS },
889 };
890
891 static const struct regs rw_regs[] = {
892         { "mep_filter", DRCI_REG_MEP_FILTER },
893         { "mep_hash0", DRCI_REG_HASH_TBL0 },
894         { "mep_hash1", DRCI_REG_HASH_TBL1 },
895         { "mep_hash2", DRCI_REG_HASH_TBL2 },
896         { "mep_hash3", DRCI_REG_HASH_TBL3 },
897         { "mep_eui48_hi", DRCI_REG_HW_ADDR_HI },
898         { "mep_eui48_mi", DRCI_REG_HW_ADDR_MI },
899         { "mep_eui48_lo", DRCI_REG_HW_ADDR_LO },
900 };
901
902 static int get_stat_reg_addr(const struct regs *regs, int size,
903                              const char *name, u16 *reg_addr)
904 {
905         int i;
906
907         for (i = 0; i < size; i++) {
908                 if (!strcmp(name, regs[i].name)) {
909                         *reg_addr = regs[i].reg;
910                         return 0;
911                 }
912         }
913         return -EFAULT;
914 }
915
916 #define get_static_reg_addr(regs, name, reg_addr) \
917         get_stat_reg_addr(regs, ARRAY_SIZE(regs), name, reg_addr)
918
919 static ssize_t value_show(struct device *dev, struct device_attribute *attr,
920                           char *buf)
921 {
922         const char *name = attr->attr.name;
923         struct most_dci_obj *dci_obj = to_dci_obj(dev);
924         u16 val;
925         u16 reg_addr;
926         int err;
927
928         if (!strcmp(name, "arb_address"))
929                 return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
930
931         if (!strcmp(name, "arb_value"))
932                 reg_addr = dci_obj->reg_addr;
933         else if (get_static_reg_addr(ro_regs, name, &reg_addr) &&
934                  get_static_reg_addr(rw_regs, name, &reg_addr))
935                 return -EFAULT;
936
937         err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val);
938         if (err < 0)
939                 return err;
940
941         return snprintf(buf, PAGE_SIZE, "%04x\n", val);
942 }
943
944 static ssize_t value_store(struct device *dev, struct device_attribute *attr,
945                            const char *buf, size_t count)
946 {
947         u16 val;
948         u16 reg_addr;
949         const char *name = attr->attr.name;
950         struct most_dci_obj *dci_obj = to_dci_obj(dev);
951         struct usb_device *usb_dev = dci_obj->usb_device;
952         int err = kstrtou16(buf, 16, &val);
953
954         if (err)
955                 return err;
956
957         if (!strcmp(name, "arb_address")) {
958                 dci_obj->reg_addr = val;
959                 return count;
960         }
961
962         if (!strcmp(name, "arb_value"))
963                 err = drci_wr_reg(usb_dev, dci_obj->reg_addr, val);
964         else if (!strcmp(name, "sync_ep"))
965                 err = start_sync_ep(usb_dev, val);
966         else if (!get_static_reg_addr(rw_regs, name, &reg_addr))
967                 err = drci_wr_reg(usb_dev, reg_addr, val);
968         else
969                 return -EFAULT;
970
971         if (err < 0)
972                 return err;
973
974         return count;
975 }
976
977 static DEVICE_ATTR(ni_state, 0444, value_show, NULL);
978 static DEVICE_ATTR(packet_bandwidth, 0444, value_show, NULL);
979 static DEVICE_ATTR(node_address, 0444, value_show, NULL);
980 static DEVICE_ATTR(node_position, 0444, value_show, NULL);
981 static DEVICE_ATTR(sync_ep, 0200, NULL, value_store);
982 static DEVICE_ATTR(mep_filter, 0644, value_show, value_store);
983 static DEVICE_ATTR(mep_hash0, 0644, value_show, value_store);
984 static DEVICE_ATTR(mep_hash1, 0644, value_show, value_store);
985 static DEVICE_ATTR(mep_hash2, 0644, value_show, value_store);
986 static DEVICE_ATTR(mep_hash3, 0644, value_show, value_store);
987 static DEVICE_ATTR(mep_eui48_hi, 0644, value_show, value_store);
988 static DEVICE_ATTR(mep_eui48_mi, 0644, value_show, value_store);
989 static DEVICE_ATTR(mep_eui48_lo, 0644, value_show, value_store);
990 static DEVICE_ATTR(arb_address, 0644, value_show, value_store);
991 static DEVICE_ATTR(arb_value, 0644, value_show, value_store);
992
993 static struct attribute *dci_attrs[] = {
994         &dev_attr_ni_state.attr,
995         &dev_attr_packet_bandwidth.attr,
996         &dev_attr_node_address.attr,
997         &dev_attr_node_position.attr,
998         &dev_attr_sync_ep.attr,
999         &dev_attr_mep_filter.attr,
1000         &dev_attr_mep_hash0.attr,
1001         &dev_attr_mep_hash1.attr,
1002         &dev_attr_mep_hash2.attr,
1003         &dev_attr_mep_hash3.attr,
1004         &dev_attr_mep_eui48_hi.attr,
1005         &dev_attr_mep_eui48_mi.attr,
1006         &dev_attr_mep_eui48_lo.attr,
1007         &dev_attr_arb_address.attr,
1008         &dev_attr_arb_value.attr,
1009         NULL,
1010 };
1011
1012 static struct attribute_group dci_attr_group = {
1013         .attrs = dci_attrs,
1014 };
1015
1016 static const struct attribute_group *dci_attr_groups[] = {
1017         &dci_attr_group,
1018         NULL,
1019 };
1020
1021 static void release_dci(struct device *dev)
1022 {
1023         struct most_dci_obj *dci = to_dci_obj(dev);
1024
1025         kfree(dci);
1026 }
1027
1028 static void release_mdev(struct device *dev)
1029 {
1030         struct most_dev *mdev = to_mdev_from_dev(dev);
1031
1032         kfree(mdev);
1033 }
1034 /**
1035  * hdm_probe - probe function of USB device driver
1036  * @interface: Interface of the attached USB device
1037  * @id: Pointer to the USB ID table.
1038  *
1039  * This allocates and initializes the device instance, adds the new
1040  * entry to the internal list, scans the USB descriptors and registers
1041  * the interface with the core.
1042  * Additionally, the DCI objects are created and the hardware is sync'd.
1043  *
1044  * Return 0 on success. In case of an error a negative number is returned.
1045  */
1046 static int
1047 hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
1048 {
1049         struct usb_host_interface *usb_iface_desc = interface->cur_altsetting;
1050         struct usb_device *usb_dev = interface_to_usbdev(interface);
1051         struct device *dev = &usb_dev->dev;
1052         struct most_dev *mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
1053         unsigned int i;
1054         unsigned int num_endpoints;
1055         struct most_channel_capability *tmp_cap;
1056         struct usb_endpoint_descriptor *ep_desc;
1057         int ret = 0;
1058
1059         if (!mdev)
1060                 goto err_out_of_memory;
1061
1062         usb_set_intfdata(interface, mdev);
1063         num_endpoints = usb_iface_desc->desc.bNumEndpoints;
1064         mutex_init(&mdev->io_mutex);
1065         INIT_WORK(&mdev->poll_work_obj, wq_netinfo);
1066         timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0);
1067
1068         mdev->usb_device = usb_dev;
1069         mdev->link_stat_timer.expires = jiffies + (2 * HZ);
1070
1071         mdev->iface.mod = hdm_usb_fops.owner;
1072         mdev->iface.dev = &mdev->dev;
1073         mdev->iface.driver_dev = &interface->dev;
1074         mdev->iface.interface = ITYPE_USB;
1075         mdev->iface.configure = hdm_configure_channel;
1076         mdev->iface.request_netinfo = hdm_request_netinfo;
1077         mdev->iface.enqueue = hdm_enqueue;
1078         mdev->iface.poison_channel = hdm_poison_channel;
1079         mdev->iface.dma_alloc = hdm_dma_alloc;
1080         mdev->iface.dma_free = hdm_dma_free;
1081         mdev->iface.description = mdev->description;
1082         mdev->iface.num_channels = num_endpoints;
1083
1084         snprintf(mdev->description, sizeof(mdev->description),
1085                  "%d-%s:%d.%d",
1086                  usb_dev->bus->busnum,
1087                  usb_dev->devpath,
1088                  usb_dev->config->desc.bConfigurationValue,
1089                  usb_iface_desc->desc.bInterfaceNumber);
1090
1091         mdev->dev.init_name = mdev->description;
1092         mdev->dev.parent = &interface->dev;
1093         mdev->dev.release = release_mdev;
1094         mdev->conf = kcalloc(num_endpoints, sizeof(*mdev->conf), GFP_KERNEL);
1095         if (!mdev->conf)
1096                 goto err_free_mdev;
1097
1098         mdev->cap = kcalloc(num_endpoints, sizeof(*mdev->cap), GFP_KERNEL);
1099         if (!mdev->cap)
1100                 goto err_free_conf;
1101
1102         mdev->iface.channel_vector = mdev->cap;
1103         mdev->ep_address =
1104                 kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL);
1105         if (!mdev->ep_address)
1106                 goto err_free_cap;
1107
1108         mdev->busy_urbs =
1109                 kcalloc(num_endpoints, sizeof(*mdev->busy_urbs), GFP_KERNEL);
1110         if (!mdev->busy_urbs)
1111                 goto err_free_ep_address;
1112
1113         tmp_cap = mdev->cap;
1114         for (i = 0; i < num_endpoints; i++) {
1115                 ep_desc = &usb_iface_desc->endpoint[i].desc;
1116                 mdev->ep_address[i] = ep_desc->bEndpointAddress;
1117                 mdev->padding_active[i] = false;
1118                 mdev->is_channel_healthy[i] = true;
1119
1120                 snprintf(&mdev->suffix[i][0], MAX_SUFFIX_LEN, "ep%02x",
1121                          mdev->ep_address[i]);
1122
1123                 tmp_cap->name_suffix = &mdev->suffix[i][0];
1124                 tmp_cap->buffer_size_packet = MAX_BUF_SIZE;
1125                 tmp_cap->buffer_size_streaming = MAX_BUF_SIZE;
1126                 tmp_cap->num_buffers_packet = BUF_CHAIN_SIZE;
1127                 tmp_cap->num_buffers_streaming = BUF_CHAIN_SIZE;
1128                 tmp_cap->data_type = MOST_CH_CONTROL | MOST_CH_ASYNC |
1129                                      MOST_CH_ISOC | MOST_CH_SYNC;
1130                 if (usb_endpoint_dir_in(ep_desc))
1131                         tmp_cap->direction = MOST_CH_RX;
1132                 else
1133                         tmp_cap->direction = MOST_CH_TX;
1134                 tmp_cap++;
1135                 init_usb_anchor(&mdev->busy_urbs[i]);
1136                 spin_lock_init(&mdev->channel_lock[i]);
1137         }
1138         dev_notice(dev, "claimed gadget: Vendor=%4.4x ProdID=%4.4x Bus=%02x Device=%02x\n",
1139                    le16_to_cpu(usb_dev->descriptor.idVendor),
1140                    le16_to_cpu(usb_dev->descriptor.idProduct),
1141                    usb_dev->bus->busnum,
1142                    usb_dev->devnum);
1143
1144         dev_notice(dev, "device path: /sys/bus/usb/devices/%d-%s:%d.%d\n",
1145                    usb_dev->bus->busnum,
1146                    usb_dev->devpath,
1147                    usb_dev->config->desc.bConfigurationValue,
1148                    usb_iface_desc->desc.bInterfaceNumber);
1149
1150         ret = most_register_interface(&mdev->iface);
1151         if (ret)
1152                 goto err_free_busy_urbs;
1153
1154         mutex_lock(&mdev->io_mutex);
1155         if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 ||
1156             le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81119 ||
1157             le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81210) {
1158                 mdev->dci = kzalloc(sizeof(*mdev->dci), GFP_KERNEL);
1159                 if (!mdev->dci) {
1160                         mutex_unlock(&mdev->io_mutex);
1161                         most_deregister_interface(&mdev->iface);
1162                         ret = -ENOMEM;
1163                         goto err_free_busy_urbs;
1164                 }
1165
1166                 mdev->dci->dev.init_name = "dci";
1167                 mdev->dci->dev.parent = get_device(mdev->iface.dev);
1168                 mdev->dci->dev.groups = dci_attr_groups;
1169                 mdev->dci->dev.release = release_dci;
1170                 if (device_register(&mdev->dci->dev)) {
1171                         mutex_unlock(&mdev->io_mutex);
1172                         most_deregister_interface(&mdev->iface);
1173                         ret = -ENOMEM;
1174                         goto err_free_dci;
1175                 }
1176                 mdev->dci->usb_device = mdev->usb_device;
1177         }
1178         mutex_unlock(&mdev->io_mutex);
1179         return 0;
1180 err_free_dci:
1181         put_device(&mdev->dci->dev);
1182 err_free_busy_urbs:
1183         kfree(mdev->busy_urbs);
1184 err_free_ep_address:
1185         kfree(mdev->ep_address);
1186 err_free_cap:
1187         kfree(mdev->cap);
1188 err_free_conf:
1189         kfree(mdev->conf);
1190 err_free_mdev:
1191         put_device(&mdev->dev);
1192 err_out_of_memory:
1193         if (ret == 0 || ret == -ENOMEM) {
1194                 ret = -ENOMEM;
1195                 dev_err(dev, "out of memory\n");
1196         }
1197         return ret;
1198 }
1199
1200 /**
1201  * hdm_disconnect - disconnect function of USB device driver
1202  * @interface: Interface of the attached USB device
1203  *
1204  * This deregisters the interface with the core, removes the kernel timer
1205  * and frees resources.
1206  *
1207  * Context: hub kernel thread
1208  */
1209 static void hdm_disconnect(struct usb_interface *interface)
1210 {
1211         struct most_dev *mdev = usb_get_intfdata(interface);
1212
1213         mutex_lock(&mdev->io_mutex);
1214         usb_set_intfdata(interface, NULL);
1215         mdev->usb_device = NULL;
1216         mutex_unlock(&mdev->io_mutex);
1217
1218         del_timer_sync(&mdev->link_stat_timer);
1219         cancel_work_sync(&mdev->poll_work_obj);
1220
1221         if (mdev->dci)
1222                 device_unregister(&mdev->dci->dev);
1223         most_deregister_interface(&mdev->iface);
1224
1225         kfree(mdev->busy_urbs);
1226         kfree(mdev->cap);
1227         kfree(mdev->conf);
1228         kfree(mdev->ep_address);
1229         put_device(&mdev->dev);
1230 }
1231
1232 static struct usb_driver hdm_usb = {
1233         .name = "hdm_usb",
1234         .id_table = usbid,
1235         .probe = hdm_probe,
1236         .disconnect = hdm_disconnect,
1237 };
1238
1239 module_usb_driver(hdm_usb);
1240 MODULE_LICENSE("GPL");
1241 MODULE_AUTHOR("Christian Gromm <christian.gromm@microchip.com>");
1242 MODULE_DESCRIPTION("HDM_4_USB");