blob: 2640c5b326a493fff8f9b9fe0ddaf36b9e7a6e74 [file] [log] [blame]
Greg Kroah-Hartman1a79f222017-11-07 14:58:50 +01001// SPDX-License-Identifier: GPL-2.0
Christian Gromma4198cd2015-07-24 16:11:55 +02002/*
Christian Gromm6e01fc72017-11-21 15:04:41 +01003 * usb.c - Hardware dependent module for USB
Christian Gromma4198cd2015-07-24 16:11:55 +02004 *
5 * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG
Christian Gromma4198cd2015-07-24 16:11:55 +02006 */
7
Christian Gromma4198cd2015-07-24 16:11:55 +02008#include <linux/module.h>
9#include <linux/fs.h>
10#include <linux/usb.h>
11#include <linux/slab.h>
12#include <linux/init.h>
13#include <linux/cdev.h>
14#include <linux/device.h>
15#include <linux/list.h>
16#include <linux/completion.h>
17#include <linux/mutex.h>
18#include <linux/spinlock.h>
19#include <linux/interrupt.h>
20#include <linux/workqueue.h>
21#include <linux/sysfs.h>
22#include <linux/dma-mapping.h>
23#include <linux/etherdevice.h>
24#include <linux/uaccess.h>
Christian Grommb2765272020-03-10 14:02:40 +010025#include <linux/most.h>
Christian Gromma4198cd2015-07-24 16:11:55 +020026
27#define USB_MTU 512
28#define NO_ISOCHRONOUS_URB 0
29#define AV_PACKETS_PER_XACT 2
30#define BUF_CHAIN_SIZE 0xFFFF
31#define MAX_NUM_ENDPOINTS 30
32#define MAX_SUFFIX_LEN 10
33#define MAX_STRING_LEN 80
34#define MAX_BUF_SIZE 0xFFFF
Christian Gromma4198cd2015-07-24 16:11:55 +020035
36#define USB_VENDOR_ID_SMSC 0x0424 /* VID: SMSC */
37#define USB_DEV_ID_BRDG 0xC001 /* PID: USB Bridge */
Christian Gromm654f7ec2016-08-19 11:12:50 +020038#define USB_DEV_ID_OS81118 0xCF18 /* PID: USB OS81118 */
Christian Grommb50762e2016-08-19 11:12:49 +020039#define USB_DEV_ID_OS81119 0xCF19 /* PID: USB OS81119 */
Christian Gromm5bf9bd82016-08-19 11:13:01 +020040#define USB_DEV_ID_OS81210 0xCF30 /* PID: USB OS81210 */
Christian Gromma4198cd2015-07-24 16:11:55 +020041/* DRCI Addresses */
42#define DRCI_REG_NI_STATE 0x0100
43#define DRCI_REG_PACKET_BW 0x0101
44#define DRCI_REG_NODE_ADDR 0x0102
45#define DRCI_REG_NODE_POS 0x0103
46#define DRCI_REG_MEP_FILTER 0x0140
47#define DRCI_REG_HASH_TBL0 0x0141
48#define DRCI_REG_HASH_TBL1 0x0142
49#define DRCI_REG_HASH_TBL2 0x0143
50#define DRCI_REG_HASH_TBL3 0x0144
51#define DRCI_REG_HW_ADDR_HI 0x0145
52#define DRCI_REG_HW_ADDR_MI 0x0146
53#define DRCI_REG_HW_ADDR_LO 0x0147
Christian Grommd747e8e2015-09-28 17:18:38 +020054#define DRCI_REG_BASE 0x1100
55#define DRCI_COMMAND 0x02
Christian Gromma4198cd2015-07-24 16:11:55 +020056#define DRCI_READ_REQ 0xA0
57#define DRCI_WRITE_REQ 0xA1
58
59/**
Christian Gromma4198cd2015-07-24 16:11:55 +020060 * struct most_dci_obj - Direct Communication Interface
61 * @kobj:position in sysfs
62 * @usb_device: pointer to the usb device
Christian Grommc0554642016-09-09 15:25:35 +020063 * @reg_addr: register address for arbitrary DCI access
Christian Gromma4198cd2015-07-24 16:11:55 +020064 */
65struct most_dci_obj {
Christian Gromm4d5f0222017-11-21 15:04:43 +010066 struct device dev;
Christian Gromma4198cd2015-07-24 16:11:55 +020067 struct usb_device *usb_device;
Christian Grommc0554642016-09-09 15:25:35 +020068 u16 reg_addr;
Christian Gromma4198cd2015-07-24 16:11:55 +020069};
Christian Gromm9cbe5aa2015-10-21 17:50:45 +020070
Christian Gromm4d5f0222017-11-21 15:04:43 +010071#define to_dci_obj(p) container_of(p, struct most_dci_obj, dev)
Christian Gromma4198cd2015-07-24 16:11:55 +020072
Christian Grommcc289832016-08-19 11:12:47 +020073struct most_dev;
74
75struct clear_hold_work {
76 struct work_struct ws;
77 struct most_dev *mdev;
78 unsigned int channel;
79 int pipe;
80};
81
82#define to_clear_hold_work(w) container_of(w, struct clear_hold_work, ws)
83
Christian Gromma4198cd2015-07-24 16:11:55 +020084/**
85 * struct most_dev - holds all usb interface specific stuff
Christian Gromma4198cd2015-07-24 16:11:55 +020086 * @usb_device: pointer to usb device
87 * @iface: hardware interface
88 * @cap: channel capabilities
89 * @conf: channel configuration
90 * @dci: direct communication interface of hardware
Christian Gromma4198cd2015-07-24 16:11:55 +020091 * @ep_address: endpoint address table
Christian Gromma4198cd2015-07-24 16:11:55 +020092 * @description: device description
93 * @suffix: suffix for channel name
Christian Gromm88d18782016-09-19 17:40:25 +020094 * @channel_lock: synchronize channel access
Christian Gromma4198cd2015-07-24 16:11:55 +020095 * @padding_active: indicates channel uses padding
96 * @is_channel_healthy: health status table of each channel
Christian Gromm27e62452016-09-19 17:40:22 +020097 * @busy_urbs: list of anchored items
Christian Gromma4198cd2015-07-24 16:11:55 +020098 * @io_mutex: synchronize I/O with disconnect
99 * @link_stat_timer: timer for link status reports
100 * @poll_work_obj: work for polling link status
101 */
102struct most_dev {
Christian Gromm723de0f2020-01-23 16:38:17 +0100103 struct device dev;
Christian Gromma4198cd2015-07-24 16:11:55 +0200104 struct usb_device *usb_device;
105 struct most_interface iface;
106 struct most_channel_capability *cap;
107 struct most_channel_config *conf;
108 struct most_dci_obj *dci;
Christian Gromma4198cd2015-07-24 16:11:55 +0200109 u8 *ep_address;
Christian Gromma4198cd2015-07-24 16:11:55 +0200110 char description[MAX_STRING_LEN];
111 char suffix[MAX_NUM_ENDPOINTS][MAX_SUFFIX_LEN];
Christian Gromm88d18782016-09-19 17:40:25 +0200112 spinlock_t channel_lock[MAX_NUM_ENDPOINTS]; /* sync channel access */
Christian Gromma4198cd2015-07-24 16:11:55 +0200113 bool padding_active[MAX_NUM_ENDPOINTS];
114 bool is_channel_healthy[MAX_NUM_ENDPOINTS];
Christian Grommcc289832016-08-19 11:12:47 +0200115 struct clear_hold_work clear_work[MAX_NUM_ENDPOINTS];
Christian Gromm27e62452016-09-19 17:40:22 +0200116 struct usb_anchor *busy_urbs;
Christian Gromma4198cd2015-07-24 16:11:55 +0200117 struct mutex io_mutex;
118 struct timer_list link_stat_timer;
119 struct work_struct poll_work_obj;
Ravi Eluri9917b202017-12-22 15:39:02 +0530120 void (*on_netinfo)(struct most_interface *most_iface,
121 unsigned char link_state, unsigned char *addrs);
Christian Gromma4198cd2015-07-24 16:11:55 +0200122};
Christian Gromm9cbe5aa2015-10-21 17:50:45 +0200123
Christian Gromma4198cd2015-07-24 16:11:55 +0200124#define to_mdev(d) container_of(d, struct most_dev, iface)
Christian Gromm723de0f2020-01-23 16:38:17 +0100125#define to_mdev_from_dev(d) container_of(d, struct most_dev, dev)
Christian Gromma4198cd2015-07-24 16:11:55 +0200126#define to_mdev_from_work(w) container_of(w, struct most_dev, poll_work_obj)
127
Christian Gromma4198cd2015-07-24 16:11:55 +0200128static void wq_clear_halt(struct work_struct *wq_obj);
129static void wq_netinfo(struct work_struct *wq_obj);
130
131/**
Christian Gromma4198cd2015-07-24 16:11:55 +0200132 * drci_rd_reg - read a DCI register
133 * @dev: usb device
134 * @reg: register address
135 * @buf: buffer to store data
136 *
137 * This is reads data from INIC's direct register communication interface
138 */
Christian Gromm26370222015-09-28 17:18:43 +0200139static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
Christian Gromma4198cd2015-07-24 16:11:55 +0200140{
Christian Gromm26370222015-09-28 17:18:43 +0200141 int retval;
Christian Gromma0dbe1b2020-05-27 11:06:19 +0200142 __le16 *dma_buf;
Christian Gromm26370222015-09-28 17:18:43 +0200143 u8 req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
144
Christian Gromma0dbe1b2020-05-27 11:06:19 +0200145 dma_buf = kzalloc(sizeof(*dma_buf), GFP_KERNEL);
Christian Gromm26370222015-09-28 17:18:43 +0200146 if (!dma_buf)
147 return -ENOMEM;
148
149 retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
150 DRCI_READ_REQ, req_type,
151 0x0000,
Eric Salem5a103802017-01-10 19:38:35 -0600152 reg, dma_buf, sizeof(*dma_buf), 5 * HZ);
Christian Grommc81c9c32015-09-28 17:18:44 +0200153 *buf = le16_to_cpu(*dma_buf);
Christian Gromm26370222015-09-28 17:18:43 +0200154 kfree(dma_buf);
155
Christian Grommffd069e2020-05-27 11:06:20 +0200156 if (retval < 0)
157 return retval;
158 return 0;
Christian Gromma4198cd2015-07-24 16:11:55 +0200159}
160
161/**
162 * drci_wr_reg - write a DCI register
163 * @dev: usb device
164 * @reg: register address
165 * @data: data to write
166 *
167 * This is writes data to INIC's direct register communication interface
168 */
169static inline int drci_wr_reg(struct usb_device *dev, u16 reg, u16 data)
170{
171 return usb_control_msg(dev,
172 usb_sndctrlpipe(dev, 0),
173 DRCI_WRITE_REQ,
174 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
175 data,
176 reg,
177 NULL,
178 0,
179 5 * HZ);
180}
181
Andrey Shvetsove33269f2016-10-25 17:44:21 +0200182static inline int start_sync_ep(struct usb_device *usb_dev, u16 ep)
183{
184 return drci_wr_reg(usb_dev, DRCI_REG_BASE + DRCI_COMMAND + ep * 16, 1);
185}
186
Christian Gromma4198cd2015-07-24 16:11:55 +0200187/**
Christian Gromma4198cd2015-07-24 16:11:55 +0200188 * get_stream_frame_size - calculate frame size of current configuration
Christian Gromm1c538a42020-05-27 11:06:18 +0200189 * @dev: device structure
Christian Gromma4198cd2015-07-24 16:11:55 +0200190 * @cfg: channel configuration
191 */
Christian Gromm1c538a42020-05-27 11:06:18 +0200192static unsigned int get_stream_frame_size(struct device *dev,
193 struct most_channel_config *cfg)
Christian Gromma4198cd2015-07-24 16:11:55 +0200194{
Christian Gromm2c069b62020-05-27 11:06:21 +0200195 unsigned int frame_size;
Christian Gromma4198cd2015-07-24 16:11:55 +0200196 unsigned int sub_size = cfg->subbuffer_size;
197
198 if (!sub_size) {
Christian Gromm62573222020-05-15 11:20:59 +0200199 dev_warn(dev, "Misconfig: Subbuffer size zero.\n");
Christian Gromm2c069b62020-05-27 11:06:21 +0200200 return 0;
Christian Gromma4198cd2015-07-24 16:11:55 +0200201 }
202 switch (cfg->data_type) {
Andrey Shvetsov05406092016-09-21 14:49:10 +0200203 case MOST_CH_ISOC:
Christian Gromma4198cd2015-07-24 16:11:55 +0200204 frame_size = AV_PACKETS_PER_XACT * sub_size;
205 break;
206 case MOST_CH_SYNC:
207 if (cfg->packets_per_xact == 0) {
Christian Gromm62573222020-05-15 11:20:59 +0200208 dev_warn(dev, "Misconfig: Packets per XACT zero\n");
Christian Gromma4198cd2015-07-24 16:11:55 +0200209 frame_size = 0;
Christian Gromm9deba732015-10-21 17:50:44 +0200210 } else if (cfg->packets_per_xact == 0xFF) {
Christian Gromma4198cd2015-07-24 16:11:55 +0200211 frame_size = (USB_MTU / sub_size) * sub_size;
Christian Gromm9deba732015-10-21 17:50:44 +0200212 } else {
Christian Gromma4198cd2015-07-24 16:11:55 +0200213 frame_size = cfg->packets_per_xact * sub_size;
Christian Gromm9deba732015-10-21 17:50:44 +0200214 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200215 break;
216 default:
Christian Gromm62573222020-05-15 11:20:59 +0200217 dev_warn(dev, "Query frame size of non-streaming channel\n");
Christian Gromm11974ac2020-05-28 14:41:43 +0200218 frame_size = 0;
Christian Gromma4198cd2015-07-24 16:11:55 +0200219 break;
220 }
221 return frame_size;
222}
223
224/**
225 * hdm_poison_channel - mark buffers of this channel as invalid
226 * @iface: pointer to the interface
227 * @channel: channel ID
228 *
229 * This unlinks all URBs submitted to the HCD,
230 * calls the associated completion function of the core and removes
231 * them from the list.
232 *
233 * Returns 0 on success or error code otherwise.
234 */
Adrian Remonda23fe15f2015-08-14 12:18:02 +0200235static int hdm_poison_channel(struct most_interface *iface, int channel)
Christian Gromma4198cd2015-07-24 16:11:55 +0200236{
Christian Gromm089612f2016-08-19 11:12:59 +0200237 struct most_dev *mdev = to_mdev(iface);
Christian Grommb24c9fe2016-08-19 11:12:56 +0200238 unsigned long flags;
239 spinlock_t *lock; /* temp. lock */
Christian Gromma4198cd2015-07-24 16:11:55 +0200240
Christian Gromm188d5b42020-05-05 12:00:28 +0200241 if (channel < 0 || channel >= iface->num_channels) {
Christian Gromm59ed0482015-07-30 18:19:41 +0200242 dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n");
Christian Gromma4198cd2015-07-24 16:11:55 +0200243 return -ECHRNG;
244 }
245
Christian Gromm88d18782016-09-19 17:40:25 +0200246 lock = mdev->channel_lock + channel;
Christian Grommb24c9fe2016-08-19 11:12:56 +0200247 spin_lock_irqsave(lock, flags);
Christian Gromma4198cd2015-07-24 16:11:55 +0200248 mdev->is_channel_healthy[channel] = false;
Christian Grommb24c9fe2016-08-19 11:12:56 +0200249 spin_unlock_irqrestore(lock, flags);
Christian Gromma4198cd2015-07-24 16:11:55 +0200250
Christian Grommcc289832016-08-19 11:12:47 +0200251 cancel_work_sync(&mdev->clear_work[channel].ws);
252
Christian Gromma4198cd2015-07-24 16:11:55 +0200253 mutex_lock(&mdev->io_mutex);
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200254 usb_kill_anchored_urbs(&mdev->busy_urbs[channel]);
Sudip Mukherjeeec58d2a2015-09-04 16:22:06 +0530255 if (mdev->padding_active[channel])
Christian Gromma4198cd2015-07-24 16:11:55 +0200256 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 */
Adrian Remonda23fe15f2015-08-14 12:18:02 +0200275static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
Christian Gromma4198cd2015-07-24 16:11:55 +0200276{
277 struct most_channel_config *conf = &mdev->conf[channel];
Christian Gromm1c538a42020-05-27 11:06:18 +0200278 unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf);
Andrey Shvetsovac33fbb2016-09-09 15:25:41 +0200279 unsigned int j, num_frames;
Christian Gromma4198cd2015-07-24 16:11:55 +0200280
Christian Gromma4198cd2015-07-24 16:11:55 +0200281 if (!frame_size)
Christian Gromm441be562020-05-05 12:00:27 +0200282 return -EINVAL;
Christian Gromma4198cd2015-07-24 16:11:55 +0200283 num_frames = mbo->buffer_length / frame_size;
284
285 if (num_frames < 1) {
Christian Gromm59ed0482015-07-30 18:19:41 +0200286 dev_err(&mdev->usb_device->dev,
287 "Missed minimal transfer unit.\n");
Christian Gromm441be562020-05-05 12:00:27 +0200288 return -EINVAL;
Christian Gromma4198cd2015-07-24 16:11:55 +0200289 }
290
Andrey Shvetsov5c131552017-04-07 15:38:39 +0200291 for (j = num_frames - 1; j > 0; j--)
292 memmove(mbo->virt_address + j * USB_MTU,
293 mbo->virt_address + j * frame_size,
Christian Gromma4198cd2015-07-24 16:11:55 +0200294 frame_size);
Christian Gromma4198cd2015-07-24 16:11:55 +0200295 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 */
Christian Grommba170ee2015-10-15 13:28:56 +0200308static int hdm_remove_padding(struct most_dev *mdev, int channel,
309 struct mbo *mbo)
Christian Gromma4198cd2015-07-24 16:11:55 +0200310{
Christian Gromma4198cd2015-07-24 16:11:55 +0200311 struct most_channel_config *const conf = &mdev->conf[channel];
Christian Gromm1c538a42020-05-27 11:06:18 +0200312 unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf);
Andrey Shvetsovac33fbb2016-09-09 15:25:41 +0200313 unsigned int j, num_frames;
Christian Gromma4198cd2015-07-24 16:11:55 +0200314
Christian Gromma4198cd2015-07-24 16:11:55 +0200315 if (!frame_size)
Christian Gromm441be562020-05-05 12:00:27 +0200316 return -EINVAL;
Christian Gromma4198cd2015-07-24 16:11:55 +0200317 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 */
339static void hdm_write_completion(struct urb *urb)
340{
Christian Gromm089612f2016-08-19 11:12:59 +0200341 struct mbo *mbo = urb->context;
Christian Gromm089612f2016-08-19 11:12:59 +0200342 struct most_dev *mdev = to_mdev(mbo->ifp);
343 unsigned int channel = mbo->hdm_channel_id;
Christian Gromm88d18782016-09-19 17:40:25 +0200344 spinlock_t *lock = mdev->channel_lock + channel;
Christian Gromma4198cd2015-07-24 16:11:55 +0200345 unsigned long flags;
Christian Gromma4198cd2015-07-24 16:11:55 +0200346
Christian Grommb24c9fe2016-08-19 11:12:56 +0200347 spin_lock_irqsave(lock, flags);
Christian Gromma4198cd2015-07-24 16:11:55 +0200348
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200349 mbo->processed_length = 0;
350 mbo->status = MBO_E_INVAL;
351 if (likely(mdev->is_channel_healthy[channel])) {
Christian Gromma4198cd2015-07-24 16:11:55 +0200352 switch (urb->status) {
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200353 case 0:
354 case -ESHUTDOWN:
355 mbo->processed_length = urb->actual_length;
356 mbo->status = MBO_SUCCESS;
357 break;
Christian Gromma4198cd2015-07-24 16:11:55 +0200358 case -EPIPE:
Christian Grommbe8a8ca2018-05-08 11:45:16 +0200359 dev_warn(&mdev->usb_device->dev,
360 "Broken pipe on ep%02x\n",
Christian Gromm3b1a7742018-05-08 11:45:07 +0200361 mdev->ep_address[channel]);
Christian Gromm879c93fe2016-08-19 11:12:51 +0200362 mdev->is_channel_healthy[channel] = false;
Christian Grommcc289832016-08-19 11:12:47 +0200363 mdev->clear_work[channel].pipe = urb->pipe;
364 schedule_work(&mdev->clear_work[channel].ws);
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200365 break;
Christian Gromma4198cd2015-07-24 16:11:55 +0200366 case -ENODEV:
367 case -EPROTO:
368 mbo->status = MBO_E_CLOSE;
369 break;
Christian Gromma4198cd2015-07-24 16:11:55 +0200370 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200371 }
372
Christian Grommcf6a5992016-08-19 11:12:55 +0200373 spin_unlock_irqrestore(lock, flags);
Christian Gromma4198cd2015-07-24 16:11:55 +0200374
375 if (likely(mbo->complete))
376 mbo->complete(mbo);
377 usb_free_urb(urb);
378}
379
380/**
Masanari Iida9f175912015-10-10 13:42:49 +0900381 * hdm_read_completion - completion function for submitted Rx URBs
Christian Gromma4198cd2015-07-24 16:11:55 +0200382 * @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!
Christian Gromma4198cd2015-07-24 16:11:55 +0200390 */
391static void hdm_read_completion(struct urb *urb)
392{
Christian Gromm089612f2016-08-19 11:12:59 +0200393 struct mbo *mbo = urb->context;
Christian Gromm089612f2016-08-19 11:12:59 +0200394 struct most_dev *mdev = to_mdev(mbo->ifp);
395 unsigned int channel = mbo->hdm_channel_id;
396 struct device *dev = &mdev->usb_device->dev;
Christian Gromm88d18782016-09-19 17:40:25 +0200397 spinlock_t *lock = mdev->channel_lock + channel;
Christian Gromma4198cd2015-07-24 16:11:55 +0200398 unsigned long flags;
Christian Gromma4198cd2015-07-24 16:11:55 +0200399
Christian Grommb24c9fe2016-08-19 11:12:56 +0200400 spin_lock_irqsave(lock, flags);
Christian Gromma4198cd2015-07-24 16:11:55 +0200401
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200402 mbo->processed_length = 0;
403 mbo->status = MBO_E_INVAL;
404 if (likely(mdev->is_channel_healthy[channel])) {
Christian Gromma4198cd2015-07-24 16:11:55 +0200405 switch (urb->status) {
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200406 case 0:
407 case -ESHUTDOWN:
408 mbo->processed_length = urb->actual_length;
409 mbo->status = MBO_SUCCESS;
410 if (mdev->padding_active[channel] &&
411 hdm_remove_padding(mdev, channel, mbo)) {
412 mbo->processed_length = 0;
413 mbo->status = MBO_E_INVAL;
414 }
415 break;
Christian Gromma4198cd2015-07-24 16:11:55 +0200416 case -EPIPE:
Christian Gromm3b1a7742018-05-08 11:45:07 +0200417 dev_warn(dev, "Broken pipe on ep%02x\n",
418 mdev->ep_address[channel]);
Christian Gromm879c93fe2016-08-19 11:12:51 +0200419 mdev->is_channel_healthy[channel] = false;
Christian Grommcc289832016-08-19 11:12:47 +0200420 mdev->clear_work[channel].pipe = urb->pipe;
421 schedule_work(&mdev->clear_work[channel].ws);
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200422 break;
Christian Gromma4198cd2015-07-24 16:11:55 +0200423 case -ENODEV:
424 case -EPROTO:
425 mbo->status = MBO_E_CLOSE;
426 break;
427 case -EOVERFLOW:
Christian Gromm3b1a7742018-05-08 11:45:07 +0200428 dev_warn(dev, "Babble on ep%02x\n",
429 mdev->ep_address[channel]);
Christian Gromma4198cd2015-07-24 16:11:55 +0200430 break;
431 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200432 }
Christian Grommb24c9fe2016-08-19 11:12:56 +0200433
Christian Grommcf6a5992016-08-19 11:12:55 +0200434 spin_unlock_irqrestore(lock, flags);
Christian Gromma4198cd2015-07-24 16:11:55 +0200435
436 if (likely(mbo->complete))
437 mbo->complete(mbo);
438 usb_free_urb(urb);
439}
440
441/**
442 * hdm_enqueue - receive a buffer to be used for data transfer
443 * @iface: interface to enqueue to
444 * @channel: ID of the channel
445 * @mbo: pointer to the buffer object
446 *
447 * This allocates a new URB and fills it according to the channel
448 * that is being used for transmission of data. Before the URB is
449 * submitted it is stored in the private anchor list.
450 *
451 * Returns 0 on success. On any error the URB is freed and a error code
452 * is returned.
453 *
454 * Context: Could in _some_ cases be interrupt!
455 */
Christian Grommba170ee2015-10-15 13:28:56 +0200456static int hdm_enqueue(struct most_interface *iface, int channel,
457 struct mbo *mbo)
Christian Gromma4198cd2015-07-24 16:11:55 +0200458{
Christian Gromme3881eb2020-05-05 12:00:29 +0200459 struct most_dev *mdev = to_mdev(iface);
Christian Gromma4198cd2015-07-24 16:11:55 +0200460 struct most_channel_config *conf;
461 int retval = 0;
462 struct urb *urb;
Christian Gromma4198cd2015-07-24 16:11:55 +0200463 unsigned long length;
464 void *virt_address;
465
Christian Gromm188d5b42020-05-05 12:00:28 +0200466 if (!mbo)
Christian Gromm441be562020-05-05 12:00:27 +0200467 return -EINVAL;
Christian Gromm188d5b42020-05-05 12:00:28 +0200468 if (iface->num_channels <= channel || channel < 0)
Christian Gromma4198cd2015-07-24 16:11:55 +0200469 return -ECHRNG;
Christian Gromma4198cd2015-07-24 16:11:55 +0200470
Christian Gromm8bf56cf2020-05-27 11:06:22 +0200471 urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_KERNEL);
472 if (!urb)
473 return -ENOMEM;
474
Christian Gromma4198cd2015-07-24 16:11:55 +0200475 conf = &mdev->conf[channel];
Christian Grommc06b99e2018-05-08 11:45:15 +0200476
477 mutex_lock(&mdev->io_mutex);
478 if (!mdev->usb_device) {
479 retval = -ENODEV;
Christian Gromm8bf56cf2020-05-27 11:06:22 +0200480 goto err_free_urb;
Christian Grommc06b99e2018-05-08 11:45:15 +0200481 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200482
Christian Grommdd53ecb2016-08-19 11:12:58 +0200483 if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&
484 hdm_add_padding(mdev, channel, mbo)) {
Christian Gromm441be562020-05-05 12:00:27 +0200485 retval = -EINVAL;
Christian Grommbddd3c22018-09-21 11:28:51 +0200486 goto err_free_urb;
Christian Grommdd53ecb2016-08-19 11:12:58 +0200487 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200488
489 urb->transfer_dma = mbo->bus_address;
490 virt_address = mbo->virt_address;
491 length = mbo->buffer_length;
492
493 if (conf->direction & MOST_CH_TX) {
494 usb_fill_bulk_urb(urb, mdev->usb_device,
495 usb_sndbulkpipe(mdev->usb_device,
496 mdev->ep_address[channel]),
497 virt_address,
498 length,
499 hdm_write_completion,
500 mbo);
Christian Gromm9a323152018-05-08 11:45:14 +0200501 if (conf->data_type != MOST_CH_ISOC &&
502 conf->data_type != MOST_CH_SYNC)
Christian Gromma4198cd2015-07-24 16:11:55 +0200503 urb->transfer_flags |= URB_ZERO_PACKET;
504 } else {
505 usb_fill_bulk_urb(urb, mdev->usb_device,
506 usb_rcvbulkpipe(mdev->usb_device,
507 mdev->ep_address[channel]),
508 virt_address,
Christian Gromm9161e932015-09-28 17:18:34 +0200509 length + conf->extra_len,
Christian Gromma4198cd2015-07-24 16:11:55 +0200510 hdm_read_completion,
511 mbo);
512 }
513 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
514
Christian Gromm27e62452016-09-19 17:40:22 +0200515 usb_anchor_urb(urb, &mdev->busy_urbs[channel]);
Christian Grommec7e0a12016-07-18 17:25:27 +0200516
Christian Gromma4198cd2015-07-24 16:11:55 +0200517 retval = usb_submit_urb(urb, GFP_KERNEL);
518 if (retval) {
Christian Grommbe8a8ca2018-05-08 11:45:16 +0200519 dev_err(&mdev->usb_device->dev,
520 "URB submit failed with error %d.\n", retval);
Christian Grommbddd3c22018-09-21 11:28:51 +0200521 goto err_unanchor_urb;
Christian Gromma4198cd2015-07-24 16:11:55 +0200522 }
Christian Gromm6405fe22020-05-27 11:06:23 +0200523 mutex_unlock(&mdev->io_mutex);
524 return 0;
Christian Gromma4198cd2015-07-24 16:11:55 +0200525
Christian Grommbddd3c22018-09-21 11:28:51 +0200526err_unanchor_urb:
Christian Gromm27e62452016-09-19 17:40:22 +0200527 usb_unanchor_urb(urb);
Christian Grommbddd3c22018-09-21 11:28:51 +0200528err_free_urb:
Christian Gromma4198cd2015-07-24 16:11:55 +0200529 usb_free_urb(urb);
Christian Grommc06b99e2018-05-08 11:45:15 +0200530 mutex_unlock(&mdev->io_mutex);
Christian Gromma4198cd2015-07-24 16:11:55 +0200531 return retval;
532}
533
Christian Gromm3598cec2018-05-08 11:45:03 +0200534static void *hdm_dma_alloc(struct mbo *mbo, u32 size)
535{
536 struct most_dev *mdev = to_mdev(mbo->ifp);
537
538 return usb_alloc_coherent(mdev->usb_device, size, GFP_KERNEL,
539 &mbo->bus_address);
540}
541
542static void hdm_dma_free(struct mbo *mbo, u32 size)
543{
544 struct most_dev *mdev = to_mdev(mbo->ifp);
545
546 usb_free_coherent(mdev->usb_device, size, mbo->virt_address,
547 mbo->bus_address);
548}
549
Christian Gromma4198cd2015-07-24 16:11:55 +0200550/**
551 * hdm_configure_channel - receive channel configuration from core
552 * @iface: interface
553 * @channel: channel ID
554 * @conf: structure that holds the configuration information
Christian Gromm25e38542016-10-28 14:46:20 +0200555 *
556 * The attached network interface controller (NIC) supports a padding mode
557 * to avoid short packets on USB, hence increasing the performance due to a
558 * lower interrupt load. This mode is default for synchronous data and can
559 * be switched on for isochronous data. In case padding is active the
560 * driver needs to know the frame size of the payload in order to calculate
561 * the number of bytes it needs to pad when transmitting or to cut off when
562 * receiving data.
563 *
Christian Gromma4198cd2015-07-24 16:11:55 +0200564 */
Adrian Remonda23fe15f2015-08-14 12:18:02 +0200565static int hdm_configure_channel(struct most_interface *iface, int channel,
566 struct most_channel_config *conf)
Christian Gromma4198cd2015-07-24 16:11:55 +0200567{
568 unsigned int num_frames;
569 unsigned int frame_size;
Christian Gromm089612f2016-08-19 11:12:59 +0200570 struct most_dev *mdev = to_mdev(iface);
571 struct device *dev = &mdev->usb_device->dev;
Christian Gromma4198cd2015-07-24 16:11:55 +0200572
Christian Gromm188d5b42020-05-05 12:00:28 +0200573 if (!conf) {
Christian Gromm3e8621a2020-05-05 12:00:26 +0200574 dev_err(dev, "Bad config pointer.\n");
Christian Gromm59ed0482015-07-30 18:19:41 +0200575 return -EINVAL;
576 }
Christian Gromm188d5b42020-05-05 12:00:28 +0200577 if (channel < 0 || channel >= iface->num_channels) {
Christian Gromm59ed0482015-07-30 18:19:41 +0200578 dev_err(dev, "Channel ID out of range.\n");
579 return -EINVAL;
580 }
Colin Ian Kingd92e6992020-05-07 16:06:52 +0100581
582 mdev->is_channel_healthy[channel] = true;
583 mdev->clear_work[channel].channel = channel;
584 mdev->clear_work[channel].mdev = mdev;
585 INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt);
586
Christian Grommdd53ecb2016-08-19 11:12:58 +0200587 if (!conf->num_buffers || !conf->buffer_size) {
Christian Gromm59ed0482015-07-30 18:19:41 +0200588 dev_err(dev, "Misconfig: buffer size or #buffers zero.\n");
589 return -EINVAL;
590 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200591
Christian Grommdd53ecb2016-08-19 11:12:58 +0200592 if (conf->data_type != MOST_CH_SYNC &&
Andrey Shvetsov05406092016-09-21 14:49:10 +0200593 !(conf->data_type == MOST_CH_ISOC &&
Christian Grommdd53ecb2016-08-19 11:12:58 +0200594 conf->packets_per_xact != 0xFF)) {
Christian Gromma4198cd2015-07-24 16:11:55 +0200595 mdev->padding_active[channel] = false;
Christian Gromm25e38542016-10-28 14:46:20 +0200596 /*
597 * Since the NIC's padding mode is not going to be
598 * used, we can skip the frame size calculations and
599 * move directly on to exit.
600 */
Christian Gromma4198cd2015-07-24 16:11:55 +0200601 goto exit;
602 }
603
604 mdev->padding_active[channel] = true;
Christian Gromma4198cd2015-07-24 16:11:55 +0200605
Christian Gromm1c538a42020-05-27 11:06:18 +0200606 frame_size = get_stream_frame_size(&mdev->dev, conf);
Christian Grommdd53ecb2016-08-19 11:12:58 +0200607 if (frame_size == 0 || frame_size > USB_MTU) {
Christian Gromm59ed0482015-07-30 18:19:41 +0200608 dev_warn(dev, "Misconfig: frame size wrong\n");
Christian Gromma4198cd2015-07-24 16:11:55 +0200609 return -EINVAL;
610 }
611
Andrey Shvetsovf5001922017-04-07 15:38:38 +0200612 num_frames = conf->buffer_size / frame_size;
Christian Gromma4198cd2015-07-24 16:11:55 +0200613
Andrey Shvetsovf5001922017-04-07 15:38:38 +0200614 if (conf->buffer_size % frame_size) {
615 u16 old_size = conf->buffer_size;
616
617 conf->buffer_size = num_frames * frame_size;
618 dev_warn(dev, "%s: fixed buffer size (%d -> %d)\n",
619 mdev->suffix[channel], old_size, conf->buffer_size);
Christian Gromma4198cd2015-07-24 16:11:55 +0200620 }
621
Christian Gromma4198cd2015-07-24 16:11:55 +0200622 /* calculate extra length to comply w/ HW padding */
Andrey Shvetsovf5001922017-04-07 15:38:38 +0200623 conf->extra_len = num_frames * (USB_MTU - frame_size);
624
Christian Gromma4198cd2015-07-24 16:11:55 +0200625exit:
626 mdev->conf[channel] = *conf;
Andrey Shvetsov7c23baa2016-10-25 17:44:20 +0200627 if (conf->data_type == MOST_CH_ASYNC) {
628 u16 ep = mdev->ep_address[channel];
Andrey Shvetsov7c23baa2016-10-25 17:44:20 +0200629
Andrey Shvetsove33269f2016-10-25 17:44:21 +0200630 if (start_sync_ep(mdev->usb_device, ep) < 0)
Andrey Shvetsov7c23baa2016-10-25 17:44:20 +0200631 dev_warn(dev, "sync for ep%02x failed", ep);
632 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200633 return 0;
634}
635
636/**
Christian Gromma4198cd2015-07-24 16:11:55 +0200637 * hdm_request_netinfo - request network information
638 * @iface: pointer to interface
639 * @channel: channel ID
640 *
641 * This is used as trigger to set up the link status timer that
642 * polls for the NI state of the INIC every 2 seconds.
643 *
644 */
Andrey Shvetsovd35bbfa2017-05-12 12:59:54 +0200645static void hdm_request_netinfo(struct most_interface *iface, int channel,
646 void (*on_netinfo)(struct most_interface *,
647 unsigned char,
648 unsigned char *))
Christian Gromma4198cd2015-07-24 16:11:55 +0200649{
Christian Gromme3881eb2020-05-05 12:00:29 +0200650 struct most_dev *mdev = to_mdev(iface);
Christian Gromma4198cd2015-07-24 16:11:55 +0200651
Andrey Shvetsovd35bbfa2017-05-12 12:59:54 +0200652 mdev->on_netinfo = on_netinfo;
653 if (!on_netinfo)
654 return;
655
Christian Gromma4198cd2015-07-24 16:11:55 +0200656 mdev->link_stat_timer.expires = jiffies + HZ;
657 mod_timer(&mdev->link_stat_timer, mdev->link_stat_timer.expires);
658}
659
660/**
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200661 * link_stat_timer_handler - schedule work obtaining mac address and link status
Christian Gromma4198cd2015-07-24 16:11:55 +0200662 * @data: pointer to USB device instance
663 *
664 * The handler runs in interrupt context. That's why we need to defer the
665 * tasks to a work queue.
666 */
Kees Cooke99e88a2017-10-16 14:43:17 -0700667static void link_stat_timer_handler(struct timer_list *t)
Christian Gromma4198cd2015-07-24 16:11:55 +0200668{
Kees Cooke99e88a2017-10-16 14:43:17 -0700669 struct most_dev *mdev = from_timer(mdev, t, link_stat_timer);
Christian Gromma4198cd2015-07-24 16:11:55 +0200670
Amitoj Kaur Chawlae3479f72016-02-20 15:15:38 +0530671 schedule_work(&mdev->poll_work_obj);
Christian Gromma4198cd2015-07-24 16:11:55 +0200672 mdev->link_stat_timer.expires = jiffies + (2 * HZ);
673 add_timer(&mdev->link_stat_timer);
674}
675
676/**
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200677 * wq_netinfo - work queue function to deliver latest networking information
Christian Gromma4198cd2015-07-24 16:11:55 +0200678 * @wq_obj: object that holds data for our deferred work to do
679 *
680 * This retrieves the network interface status of the USB INIC
Christian Gromma4198cd2015-07-24 16:11:55 +0200681 */
682static void wq_netinfo(struct work_struct *wq_obj)
683{
Christian Gromm089612f2016-08-19 11:12:59 +0200684 struct most_dev *mdev = to_mdev_from_work(wq_obj);
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200685 struct usb_device *usb_device = mdev->usb_device;
686 struct device *dev = &usb_device->dev;
687 u16 hi, mi, lo, link;
688 u8 hw_addr[6];
Christian Gromma4198cd2015-07-24 16:11:55 +0200689
Christian Grommffd069e2020-05-27 11:06:20 +0200690 if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi)) {
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200691 dev_err(dev, "Vendor request 'hw_addr_hi' failed\n");
Christian Gromma4198cd2015-07-24 16:11:55 +0200692 return;
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200693 }
694
Christian Grommffd069e2020-05-27 11:06:20 +0200695 if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi)) {
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200696 dev_err(dev, "Vendor request 'hw_addr_mid' failed\n");
697 return;
698 }
699
Christian Grommffd069e2020-05-27 11:06:20 +0200700 if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo)) {
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200701 dev_err(dev, "Vendor request 'hw_addr_low' failed\n");
702 return;
703 }
704
Christian Grommffd069e2020-05-27 11:06:20 +0200705 if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link)) {
Andrey Shvetsovf28e6cd2016-10-04 17:10:19 +0200706 dev_err(dev, "Vendor request 'link status' failed\n");
707 return;
708 }
709
710 hw_addr[0] = hi >> 8;
711 hw_addr[1] = hi;
712 hw_addr[2] = mi >> 8;
713 hw_addr[3] = mi;
714 hw_addr[4] = lo >> 8;
715 hw_addr[5] = lo;
716
Andrey Shvetsovd35bbfa2017-05-12 12:59:54 +0200717 if (mdev->on_netinfo)
718 mdev->on_netinfo(&mdev->iface, link, hw_addr);
Christian Gromma4198cd2015-07-24 16:11:55 +0200719}
720
721/**
722 * wq_clear_halt - work queue function
723 * @wq_obj: work_struct object to execute
724 *
725 * This sends a clear_halt to the given USB pipe.
726 */
727static void wq_clear_halt(struct work_struct *wq_obj)
728{
Christian Grommcc289832016-08-19 11:12:47 +0200729 struct clear_hold_work *clear_work = to_clear_hold_work(wq_obj);
730 struct most_dev *mdev = clear_work->mdev;
731 unsigned int channel = clear_work->channel;
732 int pipe = clear_work->pipe;
Christian Gromm1fd4fb82020-05-27 11:06:24 +0200733 int snd_pipe;
734 int peer;
Christian Gromma4198cd2015-07-24 16:11:55 +0200735
Christian Grommcc289832016-08-19 11:12:47 +0200736 mutex_lock(&mdev->io_mutex);
Christian Grommbf9503f2016-08-19 11:12:54 +0200737 most_stop_enqueue(&mdev->iface, channel);
Andrey Shvetsov3a542002016-10-04 17:10:21 +0200738 usb_kill_anchored_urbs(&mdev->busy_urbs[channel]);
Christian Grommcc289832016-08-19 11:12:47 +0200739 if (usb_clear_halt(mdev->usb_device, pipe))
Christian Gromm59ed0482015-07-30 18:19:41 +0200740 dev_warn(&mdev->usb_device->dev, "Failed to reset endpoint.\n");
Christian Gromma4198cd2015-07-24 16:11:55 +0200741
Christian Gromm8f20f2d2017-11-21 15:05:15 +0100742 /* If the functional Stall condition has been set on an
743 * asynchronous rx channel, we need to clear the tx channel
744 * too, since the hardware runs its clean-up sequence on both
745 * channels, as they are physically one on the network.
746 *
747 * The USB interface that exposes the asynchronous channels
748 * contains always two endpoints, and two only.
749 */
750 if (mdev->conf[channel].data_type == MOST_CH_ASYNC &&
751 mdev->conf[channel].direction == MOST_CH_RX) {
Christian Gromm1fd4fb82020-05-27 11:06:24 +0200752 if (channel == 0)
753 peer = 1;
754 else
755 peer = 0;
756 snd_pipe = usb_sndbulkpipe(mdev->usb_device,
757 mdev->ep_address[peer]);
Christian Gromm8f20f2d2017-11-21 15:05:15 +0100758 usb_clear_halt(mdev->usb_device, snd_pipe);
759 }
Christian Gromm879c93fe2016-08-19 11:12:51 +0200760 mdev->is_channel_healthy[channel] = true;
Christian Gromm72df4a52016-08-19 11:12:48 +0200761 most_resume_enqueue(&mdev->iface, channel);
Christian Grommcc289832016-08-19 11:12:47 +0200762 mutex_unlock(&mdev->io_mutex);
Christian Gromma4198cd2015-07-24 16:11:55 +0200763}
764
765/**
766 * hdm_usb_fops - file operation table for USB driver
767 */
768static const struct file_operations hdm_usb_fops = {
769 .owner = THIS_MODULE,
770};
771
772/**
773 * usb_device_id - ID table for HCD device probing
774 */
Arvind Yadav27acb552017-08-08 22:53:13 +0530775static const struct usb_device_id usbid[] = {
Christian Gromma4198cd2015-07-24 16:11:55 +0200776 { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_BRDG), },
Christian Gromm654f7ec2016-08-19 11:12:50 +0200777 { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81118), },
Christian Grommb50762e2016-08-19 11:12:49 +0200778 { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81119), },
Christian Gromm5bf9bd82016-08-19 11:13:01 +0200779 { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81210), },
Christian Gromma4198cd2015-07-24 16:11:55 +0200780 { } /* Terminating entry */
781};
782
Christian Gromma747b422016-09-09 15:25:38 +0200783struct regs {
784 const char *name;
785 u16 reg;
786};
787
788static const struct regs ro_regs[] = {
789 { "ni_state", DRCI_REG_NI_STATE },
790 { "packet_bandwidth", DRCI_REG_PACKET_BW },
791 { "node_address", DRCI_REG_NODE_ADDR },
792 { "node_position", DRCI_REG_NODE_POS },
793};
794
795static const struct regs rw_regs[] = {
796 { "mep_filter", DRCI_REG_MEP_FILTER },
797 { "mep_hash0", DRCI_REG_HASH_TBL0 },
798 { "mep_hash1", DRCI_REG_HASH_TBL1 },
799 { "mep_hash2", DRCI_REG_HASH_TBL2 },
800 { "mep_hash3", DRCI_REG_HASH_TBL3 },
801 { "mep_eui48_hi", DRCI_REG_HW_ADDR_HI },
802 { "mep_eui48_mi", DRCI_REG_HW_ADDR_MI },
803 { "mep_eui48_lo", DRCI_REG_HW_ADDR_LO },
804};
805
806static int get_stat_reg_addr(const struct regs *regs, int size,
807 const char *name, u16 *reg_addr)
808{
809 int i;
810
811 for (i = 0; i < size; i++) {
Christian Gromm549d2db2020-05-27 11:06:27 +0200812 if (sysfs_streq(name, regs[i].name)) {
Christian Gromma747b422016-09-09 15:25:38 +0200813 *reg_addr = regs[i].reg;
814 return 0;
815 }
816 }
Christian Grommf470a5b2020-05-27 11:06:25 +0200817 return -EINVAL;
Christian Gromma747b422016-09-09 15:25:38 +0200818}
819
820#define get_static_reg_addr(regs, name, reg_addr) \
821 get_stat_reg_addr(regs, ARRAY_SIZE(regs), name, reg_addr)
822
Christian Gromm3d9c54b2017-11-21 15:05:24 +0100823static ssize_t value_show(struct device *dev, struct device_attribute *attr,
Christian Gromm4d5f0222017-11-21 15:04:43 +0100824 char *buf)
Christian Gromma4198cd2015-07-24 16:11:55 +0200825{
Christian Gromm98a3c4d2016-09-09 15:25:43 +0200826 const char *name = attr->attr.name;
Christian Gromm4d5f0222017-11-21 15:04:43 +0100827 struct most_dci_obj *dci_obj = to_dci_obj(dev);
Christian Gromm0e9b9d02016-09-09 15:25:40 +0200828 u16 val;
Christian Gromma4198cd2015-07-24 16:11:55 +0200829 u16 reg_addr;
830 int err;
831
Christian Gromm549d2db2020-05-27 11:06:27 +0200832 if (sysfs_streq(name, "arb_address"))
Christian Grommc0554642016-09-09 15:25:35 +0200833 return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);
Christian Gromm98a3c4d2016-09-09 15:25:43 +0200834
Christian Gromm549d2db2020-05-27 11:06:27 +0200835 if (sysfs_streq(name, "arb_value"))
Christian Grommc0554642016-09-09 15:25:35 +0200836 reg_addr = dci_obj->reg_addr;
Christian Gromm98a3c4d2016-09-09 15:25:43 +0200837 else if (get_static_reg_addr(ro_regs, name, &reg_addr) &&
838 get_static_reg_addr(rw_regs, name, &reg_addr))
Christian Grommf470a5b2020-05-27 11:06:25 +0200839 return -EINVAL;
Christian Gromma4198cd2015-07-24 16:11:55 +0200840
Christian Gromm0e9b9d02016-09-09 15:25:40 +0200841 err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val);
Christian Gromma4198cd2015-07-24 16:11:55 +0200842 if (err < 0)
843 return err;
844
Christian Gromm0e9b9d02016-09-09 15:25:40 +0200845 return snprintf(buf, PAGE_SIZE, "%04x\n", val);
Christian Gromma4198cd2015-07-24 16:11:55 +0200846}
847
Christian Gromm3d9c54b2017-11-21 15:05:24 +0100848static ssize_t value_store(struct device *dev, struct device_attribute *attr,
Christian Gromma4198cd2015-07-24 16:11:55 +0200849 const char *buf, size_t count)
850{
Christian Grommf1b9a842015-09-28 17:18:39 +0200851 u16 val;
Christian Gromma4198cd2015-07-24 16:11:55 +0200852 u16 reg_addr;
Christian Gromm98a3c4d2016-09-09 15:25:43 +0200853 const char *name = attr->attr.name;
Christian Gromm4d5f0222017-11-21 15:04:43 +0100854 struct most_dci_obj *dci_obj = to_dci_obj(dev);
Andrey Shvetsove33269f2016-10-25 17:44:21 +0200855 struct usb_device *usb_dev = dci_obj->usb_device;
Christian Gromma0dbe1b2020-05-27 11:06:19 +0200856 int err;
Christian Gromma4198cd2015-07-24 16:11:55 +0200857
Christian Gromma0dbe1b2020-05-27 11:06:19 +0200858 err = kstrtou16(buf, 16, &val);
Christian Grommc0554642016-09-09 15:25:35 +0200859 if (err)
860 return err;
861
Christian Gromm549d2db2020-05-27 11:06:27 +0200862 if (sysfs_streq(name, "arb_address")) {
Christian Grommc0554642016-09-09 15:25:35 +0200863 dci_obj->reg_addr = val;
864 return count;
865 }
Christian Gromm98a3c4d2016-09-09 15:25:43 +0200866
Christian Gromm549d2db2020-05-27 11:06:27 +0200867 if (sysfs_streq(name, "arb_value"))
Andrey Shvetsove33269f2016-10-25 17:44:21 +0200868 err = drci_wr_reg(usb_dev, dci_obj->reg_addr, val);
Christian Gromm549d2db2020-05-27 11:06:27 +0200869 else if (sysfs_streq(name, "sync_ep"))
Andrey Shvetsove33269f2016-10-25 17:44:21 +0200870 err = start_sync_ep(usb_dev, val);
Christian Grommb2e8aa52017-04-07 15:38:40 +0200871 else if (!get_static_reg_addr(rw_regs, name, &reg_addr))
Andrey Shvetsove33269f2016-10-25 17:44:21 +0200872 err = drci_wr_reg(usb_dev, reg_addr, val);
873 else
Christian Grommf470a5b2020-05-27 11:06:25 +0200874 return -EINVAL;
Christian Gromma4198cd2015-07-24 16:11:55 +0200875
Christian Gromma4198cd2015-07-24 16:11:55 +0200876 if (err < 0)
877 return err;
878
879 return count;
880}
881
Christian Grommf15e3ad2017-11-27 15:20:06 +0100882static DEVICE_ATTR(ni_state, 0444, value_show, NULL);
883static DEVICE_ATTR(packet_bandwidth, 0444, value_show, NULL);
884static DEVICE_ATTR(node_address, 0444, value_show, NULL);
885static DEVICE_ATTR(node_position, 0444, value_show, NULL);
886static DEVICE_ATTR(sync_ep, 0200, NULL, value_store);
887static DEVICE_ATTR(mep_filter, 0644, value_show, value_store);
888static DEVICE_ATTR(mep_hash0, 0644, value_show, value_store);
889static DEVICE_ATTR(mep_hash1, 0644, value_show, value_store);
890static DEVICE_ATTR(mep_hash2, 0644, value_show, value_store);
891static DEVICE_ATTR(mep_hash3, 0644, value_show, value_store);
892static DEVICE_ATTR(mep_eui48_hi, 0644, value_show, value_store);
893static DEVICE_ATTR(mep_eui48_mi, 0644, value_show, value_store);
894static DEVICE_ATTR(mep_eui48_lo, 0644, value_show, value_store);
895static DEVICE_ATTR(arb_address, 0644, value_show, value_store);
896static DEVICE_ATTR(arb_value, 0644, value_show, value_store);
Christian Gromma4198cd2015-07-24 16:11:55 +0200897
Christian Gromm4d5f0222017-11-21 15:04:43 +0100898static struct attribute *dci_attrs[] = {
899 &dev_attr_ni_state.attr,
900 &dev_attr_packet_bandwidth.attr,
901 &dev_attr_node_address.attr,
902 &dev_attr_node_position.attr,
903 &dev_attr_sync_ep.attr,
904 &dev_attr_mep_filter.attr,
905 &dev_attr_mep_hash0.attr,
906 &dev_attr_mep_hash1.attr,
907 &dev_attr_mep_hash2.attr,
908 &dev_attr_mep_hash3.attr,
909 &dev_attr_mep_eui48_hi.attr,
910 &dev_attr_mep_eui48_mi.attr,
911 &dev_attr_mep_eui48_lo.attr,
912 &dev_attr_arb_address.attr,
913 &dev_attr_arb_value.attr,
Christian Gromma4198cd2015-07-24 16:11:55 +0200914 NULL,
915};
916
Christian Grommdfeb9382020-05-15 11:21:04 +0200917ATTRIBUTE_GROUPS(dci);
Christian Gromma4198cd2015-07-24 16:11:55 +0200918
Christian Gromm869d3ac2018-09-28 23:37:19 +0200919static void release_dci(struct device *dev)
920{
921 struct most_dci_obj *dci = to_dci_obj(dev);
922
Christian Grommf1f48232020-05-27 11:06:26 +0200923 put_device(dev->parent);
Christian Gromm869d3ac2018-09-28 23:37:19 +0200924 kfree(dci);
925}
926
Christian Gromm723de0f2020-01-23 16:38:17 +0100927static void release_mdev(struct device *dev)
928{
929 struct most_dev *mdev = to_mdev_from_dev(dev);
930
931 kfree(mdev);
932}
Christian Gromma4198cd2015-07-24 16:11:55 +0200933/**
934 * hdm_probe - probe function of USB device driver
935 * @interface: Interface of the attached USB device
936 * @id: Pointer to the USB ID table.
937 *
938 * This allocates and initializes the device instance, adds the new
939 * entry to the internal list, scans the USB descriptors and registers
940 * the interface with the core.
941 * Additionally, the DCI objects are created and the hardware is sync'd.
942 *
943 * Return 0 on success. In case of an error a negative number is returned.
944 */
945static int
946hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
947{
Christian Gromm089612f2016-08-19 11:12:59 +0200948 struct usb_host_interface *usb_iface_desc = interface->cur_altsetting;
949 struct usb_device *usb_dev = interface_to_usbdev(interface);
950 struct device *dev = &usb_dev->dev;
Christian Gromma0dbe1b2020-05-27 11:06:19 +0200951 struct most_dev *mdev;
Christian Gromma4198cd2015-07-24 16:11:55 +0200952 unsigned int i;
953 unsigned int num_endpoints;
954 struct most_channel_capability *tmp_cap;
Christian Gromma4198cd2015-07-24 16:11:55 +0200955 struct usb_endpoint_descriptor *ep_desc;
Christian Grommc1a57be2020-05-15 11:21:01 +0200956 int ret = -ENOMEM;
Christian Gromma4198cd2015-07-24 16:11:55 +0200957
Christian Gromma0dbe1b2020-05-27 11:06:19 +0200958 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
Christian Gromma4198cd2015-07-24 16:11:55 +0200959 if (!mdev)
Christian Grommc1a57be2020-05-15 11:21:01 +0200960 return -ENOMEM;
Christian Gromma4198cd2015-07-24 16:11:55 +0200961
962 usb_set_intfdata(interface, mdev);
963 num_endpoints = usb_iface_desc->desc.bNumEndpoints;
Christian Grommc1a57be2020-05-15 11:21:01 +0200964 if (num_endpoints > MAX_NUM_ENDPOINTS) {
965 kfree(mdev);
966 return -EINVAL;
967 }
Christian Gromma4198cd2015-07-24 16:11:55 +0200968 mutex_init(&mdev->io_mutex);
969 INIT_WORK(&mdev->poll_work_obj, wq_netinfo);
Kees Cooke99e88a2017-10-16 14:43:17 -0700970 timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0);
Christian Gromma4198cd2015-07-24 16:11:55 +0200971
972 mdev->usb_device = usb_dev;
Christian Gromma4198cd2015-07-24 16:11:55 +0200973 mdev->link_stat_timer.expires = jiffies + (2 * HZ);
974
975 mdev->iface.mod = hdm_usb_fops.owner;
Christian Gromm723de0f2020-01-23 16:38:17 +0100976 mdev->iface.dev = &mdev->dev;
Christian Gromm69c90cf12018-05-08 11:45:04 +0200977 mdev->iface.driver_dev = &interface->dev;
Christian Gromma4198cd2015-07-24 16:11:55 +0200978 mdev->iface.interface = ITYPE_USB;
979 mdev->iface.configure = hdm_configure_channel;
980 mdev->iface.request_netinfo = hdm_request_netinfo;
981 mdev->iface.enqueue = hdm_enqueue;
982 mdev->iface.poison_channel = hdm_poison_channel;
Christian Gromm3598cec2018-05-08 11:45:03 +0200983 mdev->iface.dma_alloc = hdm_dma_alloc;
984 mdev->iface.dma_free = hdm_dma_free;
Christian Gromma4198cd2015-07-24 16:11:55 +0200985 mdev->iface.description = mdev->description;
986 mdev->iface.num_channels = num_endpoints;
987
988 snprintf(mdev->description, sizeof(mdev->description),
Christian Gromm5b082c22019-04-03 15:19:50 +0200989 "%d-%s:%d.%d",
Christian Gromma4198cd2015-07-24 16:11:55 +0200990 usb_dev->bus->busnum,
991 usb_dev->devpath,
992 usb_dev->config->desc.bConfigurationValue,
993 usb_iface_desc->desc.bInterfaceNumber);
994
Christian Gromm723de0f2020-01-23 16:38:17 +0100995 mdev->dev.init_name = mdev->description;
996 mdev->dev.parent = &interface->dev;
997 mdev->dev.release = release_mdev;
Christian Gromma4198cd2015-07-24 16:11:55 +0200998 mdev->conf = kcalloc(num_endpoints, sizeof(*mdev->conf), GFP_KERNEL);
999 if (!mdev->conf)
Christian Grommbddd3c22018-09-21 11:28:51 +02001000 goto err_free_mdev;
Christian Gromma4198cd2015-07-24 16:11:55 +02001001
1002 mdev->cap = kcalloc(num_endpoints, sizeof(*mdev->cap), GFP_KERNEL);
1003 if (!mdev->cap)
Christian Grommbddd3c22018-09-21 11:28:51 +02001004 goto err_free_conf;
Christian Gromma4198cd2015-07-24 16:11:55 +02001005
1006 mdev->iface.channel_vector = mdev->cap;
Christian Gromma4198cd2015-07-24 16:11:55 +02001007 mdev->ep_address =
1008 kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL);
1009 if (!mdev->ep_address)
Christian Grommbddd3c22018-09-21 11:28:51 +02001010 goto err_free_cap;
Christian Gromma4198cd2015-07-24 16:11:55 +02001011
Christian Gromm27e62452016-09-19 17:40:22 +02001012 mdev->busy_urbs =
1013 kcalloc(num_endpoints, sizeof(*mdev->busy_urbs), GFP_KERNEL);
1014 if (!mdev->busy_urbs)
Christian Grommbddd3c22018-09-21 11:28:51 +02001015 goto err_free_ep_address;
Christian Gromma4198cd2015-07-24 16:11:55 +02001016
1017 tmp_cap = mdev->cap;
1018 for (i = 0; i < num_endpoints; i++) {
1019 ep_desc = &usb_iface_desc->endpoint[i].desc;
1020 mdev->ep_address[i] = ep_desc->bEndpointAddress;
1021 mdev->padding_active[i] = false;
1022 mdev->is_channel_healthy[i] = true;
1023
1024 snprintf(&mdev->suffix[i][0], MAX_SUFFIX_LEN, "ep%02x",
1025 mdev->ep_address[i]);
1026
1027 tmp_cap->name_suffix = &mdev->suffix[i][0];
1028 tmp_cap->buffer_size_packet = MAX_BUF_SIZE;
1029 tmp_cap->buffer_size_streaming = MAX_BUF_SIZE;
1030 tmp_cap->num_buffers_packet = BUF_CHAIN_SIZE;
1031 tmp_cap->num_buffers_streaming = BUF_CHAIN_SIZE;
1032 tmp_cap->data_type = MOST_CH_CONTROL | MOST_CH_ASYNC |
Andrey Shvetsov05406092016-09-21 14:49:10 +02001033 MOST_CH_ISOC | MOST_CH_SYNC;
Sandhya Bankarafd14ce2016-03-06 15:50:35 +05301034 if (usb_endpoint_dir_in(ep_desc))
Christian Gromma4198cd2015-07-24 16:11:55 +02001035 tmp_cap->direction = MOST_CH_RX;
1036 else
1037 tmp_cap->direction = MOST_CH_TX;
1038 tmp_cap++;
Christian Gromm27e62452016-09-19 17:40:22 +02001039 init_usb_anchor(&mdev->busy_urbs[i]);
Christian Gromm88d18782016-09-19 17:40:25 +02001040 spin_lock_init(&mdev->channel_lock[i]);
Christian Gromma4198cd2015-07-24 16:11:55 +02001041 }
Christian Gromm3dcf93fe2020-05-15 11:21:02 +02001042 dev_dbg(dev, "claimed gadget: Vendor=%4.4x ProdID=%4.4x Bus=%02x Device=%02x\n",
1043 le16_to_cpu(usb_dev->descriptor.idVendor),
1044 le16_to_cpu(usb_dev->descriptor.idProduct),
1045 usb_dev->bus->busnum,
1046 usb_dev->devnum);
Christian Gromma4198cd2015-07-24 16:11:55 +02001047
Christian Gromm3dcf93fe2020-05-15 11:21:02 +02001048 dev_dbg(dev, "device path: /sys/bus/usb/devices/%d-%s:%d.%d\n",
1049 usb_dev->bus->busnum,
1050 usb_dev->devpath,
1051 usb_dev->config->desc.bConfigurationValue,
1052 usb_iface_desc->desc.bInterfaceNumber);
Christian Gromma4198cd2015-07-24 16:11:55 +02001053
Christian Gromm4d5f0222017-11-21 15:04:43 +01001054 ret = most_register_interface(&mdev->iface);
1055 if (ret)
Christian Grommbddd3c22018-09-21 11:28:51 +02001056 goto err_free_busy_urbs;
Christian Gromma4198cd2015-07-24 16:11:55 +02001057
1058 mutex_lock(&mdev->io_mutex);
Christian Gromm654f7ec2016-08-19 11:12:50 +02001059 if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 ||
Christian Gromm5bf9bd82016-08-19 11:13:01 +02001060 le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81119 ||
1061 le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81210) {
Christian Gromm4d5f0222017-11-21 15:04:43 +01001062 mdev->dci = kzalloc(sizeof(*mdev->dci), GFP_KERNEL);
Christian Gromma4198cd2015-07-24 16:11:55 +02001063 if (!mdev->dci) {
1064 mutex_unlock(&mdev->io_mutex);
1065 most_deregister_interface(&mdev->iface);
1066 ret = -ENOMEM;
Christian Grommbddd3c22018-09-21 11:28:51 +02001067 goto err_free_busy_urbs;
Christian Gromma4198cd2015-07-24 16:11:55 +02001068 }
1069
Christian Gromm4d5f0222017-11-21 15:04:43 +01001070 mdev->dci->dev.init_name = "dci";
Christian Gromm723de0f2020-01-23 16:38:17 +01001071 mdev->dci->dev.parent = get_device(mdev->iface.dev);
Christian Grommdfeb9382020-05-15 11:21:04 +02001072 mdev->dci->dev.groups = dci_groups;
Christian Gromm869d3ac2018-09-28 23:37:19 +02001073 mdev->dci->dev.release = release_dci;
Christian Gromm4d5f0222017-11-21 15:04:43 +01001074 if (device_register(&mdev->dci->dev)) {
1075 mutex_unlock(&mdev->io_mutex);
1076 most_deregister_interface(&mdev->iface);
1077 ret = -ENOMEM;
Christian Grommbddd3c22018-09-21 11:28:51 +02001078 goto err_free_dci;
Christian Gromm4d5f0222017-11-21 15:04:43 +01001079 }
Christian Gromma4198cd2015-07-24 16:11:55 +02001080 mdev->dci->usb_device = mdev->usb_device;
Christian Gromma4198cd2015-07-24 16:11:55 +02001081 }
1082 mutex_unlock(&mdev->io_mutex);
1083 return 0;
Christian Grommbddd3c22018-09-21 11:28:51 +02001084err_free_dci:
Christian Gromm723de0f2020-01-23 16:38:17 +01001085 put_device(&mdev->dci->dev);
Christian Grommbddd3c22018-09-21 11:28:51 +02001086err_free_busy_urbs:
Christian Gromm27e62452016-09-19 17:40:22 +02001087 kfree(mdev->busy_urbs);
Christian Grommbddd3c22018-09-21 11:28:51 +02001088err_free_ep_address:
Christian Gromma4198cd2015-07-24 16:11:55 +02001089 kfree(mdev->ep_address);
Christian Grommbddd3c22018-09-21 11:28:51 +02001090err_free_cap:
Christian Gromma4198cd2015-07-24 16:11:55 +02001091 kfree(mdev->cap);
Christian Grommbddd3c22018-09-21 11:28:51 +02001092err_free_conf:
Christian Gromma4198cd2015-07-24 16:11:55 +02001093 kfree(mdev->conf);
Christian Grommbddd3c22018-09-21 11:28:51 +02001094err_free_mdev:
Christian Gromm723de0f2020-01-23 16:38:17 +01001095 put_device(&mdev->dev);
Christian Gromma4198cd2015-07-24 16:11:55 +02001096 return ret;
1097}
1098
1099/**
1100 * hdm_disconnect - disconnect function of USB device driver
1101 * @interface: Interface of the attached USB device
1102 *
1103 * This deregisters the interface with the core, removes the kernel timer
1104 * and frees resources.
1105 *
1106 * Context: hub kernel thread
1107 */
1108static void hdm_disconnect(struct usb_interface *interface)
1109{
Christian Gromm089612f2016-08-19 11:12:59 +02001110 struct most_dev *mdev = usb_get_intfdata(interface);
Christian Gromma4198cd2015-07-24 16:11:55 +02001111
Christian Gromma4198cd2015-07-24 16:11:55 +02001112 mutex_lock(&mdev->io_mutex);
1113 usb_set_intfdata(interface, NULL);
1114 mdev->usb_device = NULL;
1115 mutex_unlock(&mdev->io_mutex);
1116
1117 del_timer_sync(&mdev->link_stat_timer);
1118 cancel_work_sync(&mdev->poll_work_obj);
1119
Christian Grommfc157992020-01-23 16:38:23 +01001120 if (mdev->dci)
1121 device_unregister(&mdev->dci->dev);
Christian Gromma4198cd2015-07-24 16:11:55 +02001122 most_deregister_interface(&mdev->iface);
1123
Christian Gromm27e62452016-09-19 17:40:22 +02001124 kfree(mdev->busy_urbs);
Christian Gromma4198cd2015-07-24 16:11:55 +02001125 kfree(mdev->cap);
1126 kfree(mdev->conf);
1127 kfree(mdev->ep_address);
Christian Grommf1f48232020-05-27 11:06:26 +02001128 put_device(&mdev->dci->dev);
Christian Gromm723de0f2020-01-23 16:38:17 +01001129 put_device(&mdev->dev);
Christian Gromma4198cd2015-07-24 16:11:55 +02001130}
1131
Christian Gromm08e1b422020-05-05 14:14:52 +02001132static int hdm_suspend(struct usb_interface *interface, pm_message_t message)
1133{
1134 struct most_dev *mdev = usb_get_intfdata(interface);
1135 int i;
1136
1137 mutex_lock(&mdev->io_mutex);
1138 for (i = 0; i < mdev->iface.num_channels; i++) {
1139 most_stop_enqueue(&mdev->iface, i);
1140 usb_kill_anchored_urbs(&mdev->busy_urbs[i]);
1141 }
1142 mutex_unlock(&mdev->io_mutex);
1143 return 0;
1144}
1145
1146static int hdm_resume(struct usb_interface *interface)
1147{
1148 struct most_dev *mdev = usb_get_intfdata(interface);
1149 int i;
1150
1151 mutex_lock(&mdev->io_mutex);
1152 for (i = 0; i < mdev->iface.num_channels; i++)
1153 most_resume_enqueue(&mdev->iface, i);
1154 mutex_unlock(&mdev->io_mutex);
1155 return 0;
1156}
1157
Christian Gromma4198cd2015-07-24 16:11:55 +02001158static struct usb_driver hdm_usb = {
1159 .name = "hdm_usb",
1160 .id_table = usbid,
1161 .probe = hdm_probe,
1162 .disconnect = hdm_disconnect,
Christian Gromm08e1b422020-05-05 14:14:52 +02001163 .resume = hdm_resume,
1164 .suspend = hdm_suspend,
Christian Gromma4198cd2015-07-24 16:11:55 +02001165};
1166
Alex Briskinb9d7adc2017-08-27 08:22:10 +03001167module_usb_driver(hdm_usb);
Christian Gromma4198cd2015-07-24 16:11:55 +02001168MODULE_LICENSE("GPL");
1169MODULE_AUTHOR("Christian Gromm <christian.gromm@microchip.com>");
1170MODULE_DESCRIPTION("HDM_4_USB");