blob: d9ce3ba0910fca973718c540c1493a91ffba5a0c [file] [log] [blame]
Steven Toth8d4f9d02008-05-22 18:05:26 -03001/*
2 * Driver for the Siano SMS10xx USB dongle
3 *
Michael Krufky85447062008-05-22 18:29:20 -03004 * author: Anatoly Greenblat
5 *
6 * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc.
Steven Toth8d4f9d02008-05-22 18:05:26 -03007 *
8 * This program is free software; you can redistribute it and/or modify
Michael Krufky85447062008-05-22 18:29:20 -03009 * it under the terms of the GNU General Public License version 3 as
10 * published by the Free Software Foundation;
Steven Toth8d4f9d02008-05-22 18:05:26 -030011 *
Michael Krufky85447062008-05-22 18:29:20 -030012 * Software distributed under the License is distributed on an "AS IS"
13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
Steven Toth8d4f9d02008-05-22 18:05:26 -030014 *
Michael Krufky85447062008-05-22 18:29:20 -030015 * See the GNU General Public License for more details.
Steven Toth8d4f9d02008-05-22 18:05:26 -030016 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030022#include <linux/kernel.h>
23#include <linux/init.h>
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030024#include <linux/usb.h>
25#include <linux/firmware.h>
26
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030027#include "smscoreapi.h"
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030028
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030029#define USB1_BUFFER_SIZE 0x1000
30#define USB2_BUFFER_SIZE 0x4000
31
32#define MAX_BUFFERS 50
33#define MAX_URBS 10
34
Michael Krufky73104fb2008-06-14 18:27:18 -030035/* TO DO: move these to a header file */
36#define USB_VID_SIANO 0x187f
37
38#define USB_PID_STELLAR 0x0100
39#define USB_PID_NOVA_A 0x0200
40#define USB_PID_NOVA_B 0x0201
41#define USB_PID_VEGA 0x0300
42
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030043typedef struct _smsusb_device smsusb_device_t;
44
45typedef struct _smsusb_urb
46{
47 smscore_buffer_t *cb;
48 smsusb_device_t *dev;
49
50 struct urb urb;
51} smsusb_urb_t;
52
53typedef struct _smsusb_device
54{
Michael Krufkya83ccdd2008-05-06 03:11:51 -030055 struct usb_device *udev;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030056 smscore_device_t *coredev;
57
58 smsusb_urb_t surbs[MAX_URBS];
59
Michael Krufky82237412008-06-15 15:14:13 -030060 int response_alignment;
61 int buffer_size;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030062} *psmsusb_device_t;
63
Michael Krufkya83ccdd2008-05-06 03:11:51 -030064int smsusb_submit_urb(smsusb_device_t *dev, smsusb_urb_t *surb);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030065
66void smsusb_onresponse(struct urb *urb)
67{
68 smsusb_urb_t *surb = (smsusb_urb_t *) urb->context;
69 smsusb_device_t *dev = surb->dev;
70
Michael Krufky82237412008-06-15 15:14:13 -030071 if (urb->status < 0) {
72 printk(KERN_INFO "%s error, urb status %d, %d bytes\n",
73 __func__, urb->status, urb->actual_length);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030074 return;
75 }
76
Michael Krufky82237412008-06-15 15:14:13 -030077 if (urb->actual_length > 0) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030078 SmsMsgHdr_ST *phdr = (SmsMsgHdr_ST *) surb->cb->p;
79
Michael Krufky82237412008-06-15 15:14:13 -030080 if (urb->actual_length >= phdr->msgLength) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030081 surb->cb->size = phdr->msgLength;
82
Michael Krufky82237412008-06-15 15:14:13 -030083 if (dev->response_alignment &&
84 (phdr->msgFlags & MSG_HDR_FLAG_SPLIT_MSG)) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030085
Michael Krufky82237412008-06-15 15:14:13 -030086 surb->cb->offset =
87 dev->response_alignment +
88 ((phdr->msgFlags >> 8) & 3);
89
90 /* sanity check */
91 if (((int) phdr->msgLength +
92 surb->cb->offset) > urb->actual_length) {
93 printk(KERN_INFO "%s: invalid "
94 "response msglen %d offset %d "
95 "size %d\n", __func__,
96 phdr->msgLength,
97 surb->cb->offset,
98 urb->actual_length);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -030099 goto exit_and_resubmit;
100 }
101
Michael Krufky82237412008-06-15 15:14:13 -0300102 /* move buffer pointer and
103 * copy header to its new location */
Michael Krufky55ad3102008-05-06 03:52:44 -0300104 memcpy((char *) phdr + surb->cb->offset,
105 phdr, sizeof(SmsMsgHdr_ST));
Michael Krufky82237412008-06-15 15:14:13 -0300106 } else
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300107 surb->cb->offset = 0;
108
109 smscore_onresponse(dev->coredev, surb->cb);
110 surb->cb = NULL;
Michael Krufky82237412008-06-15 15:14:13 -0300111 } else {
112 printk(KERN_INFO "%s invalid response "
113 "msglen %d actual %d\n", __func__,
114 phdr->msgLength, urb->actual_length);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300115 }
116 }
117
118exit_and_resubmit:
119 smsusb_submit_urb(dev, surb);
120}
121
Michael Krufkya83ccdd2008-05-06 03:11:51 -0300122int smsusb_submit_urb(smsusb_device_t *dev, smsusb_urb_t *surb)
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300123{
Michael Krufky82237412008-06-15 15:14:13 -0300124 if (!surb->cb) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300125 surb->cb = smscore_getbuffer(dev->coredev);
Michael Krufky82237412008-06-15 15:14:13 -0300126 if (!surb->cb) {
127 printk(KERN_INFO "%s smscore_getbuffer(...) "
128 "returned NULL\n", __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300129 return -ENOMEM;
130 }
131 }
132
133 usb_fill_bulk_urb(
134 &surb->urb,
135 dev->udev,
136 usb_rcvbulkpipe(dev->udev, 0x81),
137 surb->cb->p,
138 dev->buffer_size,
139 smsusb_onresponse,
140 surb
141 );
142 surb->urb.transfer_dma = surb->cb->phys;
143 surb->urb.transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
144
145 return usb_submit_urb(&surb->urb, GFP_ATOMIC);
146}
147
Michael Krufkya83ccdd2008-05-06 03:11:51 -0300148void smsusb_stop_streaming(smsusb_device_t *dev)
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300149{
150 int i;
151
Michael Krufky82237412008-06-15 15:14:13 -0300152 for (i = 0; i < MAX_URBS; i ++) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300153 usb_kill_urb(&dev->surbs[i].urb);
154
Michael Krufky82237412008-06-15 15:14:13 -0300155 if (dev->surbs[i].cb) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300156 smscore_putbuffer(dev->coredev, dev->surbs[i].cb);
157 dev->surbs[i].cb = NULL;
158 }
159 }
160}
161
Michael Krufkya83ccdd2008-05-06 03:11:51 -0300162int smsusb_start_streaming(smsusb_device_t *dev)
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300163{
164 int i, rc;
165
Michael Krufky82237412008-06-15 15:14:13 -0300166 for (i = 0; i < MAX_URBS; i ++) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300167 rc = smsusb_submit_urb(dev, &dev->surbs[i]);
Michael Krufky82237412008-06-15 15:14:13 -0300168 if (rc < 0) {
169 printk(KERN_INFO "%s smsusb_submit_urb(...) "
170 "failed\n", __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300171 smsusb_stop_streaming(dev);
172 break;
173 }
174 }
175
176 return rc;
177}
178
179int smsusb_sendrequest(void *context, void *buffer, size_t size)
180{
Michael Krufkya83ccdd2008-05-06 03:11:51 -0300181 smsusb_device_t *dev = (smsusb_device_t *) context;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300182 int dummy;
183
Michael Krufky82237412008-06-15 15:14:13 -0300184 return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2),
185 buffer, size, &dummy, 1000);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300186}
187
Michael Krufky82237412008-06-15 15:14:13 -0300188char *smsusb1_fw_lkup[] = {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300189 "dvbt_stellar_usb.inp",
190 "dvbh_stellar_usb.inp",
191 "tdmb_stellar_usb.inp",
192 "none",
193 "dvbt_bda_stellar_usb.inp",
194};
195
196int smsusb1_load_firmware(struct usb_device *udev, int id)
197{
198 const struct firmware *fw;
Michael Krufkya83ccdd2008-05-06 03:11:51 -0300199 u8 *fw_buffer;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300200 int rc, dummy;
201
Michael Krufky82237412008-06-15 15:14:13 -0300202 if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) {
203 printk(KERN_INFO "%s invalid firmware id specified %d\n",
204 __func__, id);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300205 return -EINVAL;
206 }
207
208 rc = request_firmware(&fw, smsusb1_fw_lkup[id], &udev->dev);
Michael Krufky82237412008-06-15 15:14:13 -0300209 if (rc < 0) {
210 printk(KERN_INFO "%s failed to open \"%s\" mode %d\n",
211 __func__, smsusb1_fw_lkup[id], id);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300212 return rc;
213 }
214
215 fw_buffer = kmalloc(fw->size, GFP_KERNEL);
Michael Krufky82237412008-06-15 15:14:13 -0300216 if (fw_buffer) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300217 memcpy(fw_buffer, fw->data, fw->size);
218
Michael Krufky82237412008-06-15 15:14:13 -0300219 rc = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 2),
220 fw_buffer, fw->size, &dummy, 1000);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300221
Michael Krufky82237412008-06-15 15:14:13 -0300222 printk(KERN_INFO "%s: sent %d(%d) bytes, rc %d\n",
223 __func__, fw->size, dummy, rc);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300224
225 kfree(fw_buffer);
Michael Krufky82237412008-06-15 15:14:13 -0300226 } else {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300227 printk(KERN_INFO "failed to allocate firmware buffer\n");
228 rc = -ENOMEM;
229 }
230
231 release_firmware(fw);
232
233 return rc;
234}
235
236void smsusb1_detectmode(void *context, int *mode)
237{
238 char *product_string = ((smsusb_device_t *) context)->udev->product;
239
240 *mode = DEVICE_MODE_NONE;
241
Michael Krufky82237412008-06-15 15:14:13 -0300242 if (!product_string) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300243 product_string = "none";
Michael Krufky18658112008-05-22 18:30:17 -0300244 printk("%s product string not found\n", __func__);
Michael Krufky82237412008-06-15 15:14:13 -0300245 } else if (strstr(product_string, "DVBH"))
246 *mode = 1;
247 else if (strstr(product_string, "BDA"))
248 *mode = 4;
249 else if (strstr(product_string, "DVBT"))
250 *mode = 0;
251 else if (strstr(product_string, "TDMB"))
252 *mode = 2;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300253
Michael Krufky18658112008-05-22 18:30:17 -0300254 printk("%s: %d \"%s\"\n", __func__, *mode, product_string);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300255}
256
257int smsusb1_setmode(void *context, int mode)
258{
Michael Krufky82237412008-06-15 15:14:13 -0300259 SmsMsgHdr_ST Msg = { MSG_SW_RELOAD_REQ, 0, HIF_TASK,
260 sizeof(SmsMsgHdr_ST), 0 };
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300261
Michael Krufky82237412008-06-15 15:14:13 -0300262 if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) {
263 printk(KERN_INFO "%s invalid firmware id specified %d\n",
264 __func__, mode);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300265 return -EINVAL;
266 }
267
268 return smsusb_sendrequest(context, &Msg, sizeof(Msg));
269}
270
271void smsusb_term_device(struct usb_interface *intf)
272{
Michael Krufky55ad3102008-05-06 03:52:44 -0300273 smsusb_device_t *dev = (smsusb_device_t *) usb_get_intfdata(intf);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300274
Michael Krufky82237412008-06-15 15:14:13 -0300275 if (dev) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300276 smsusb_stop_streaming(dev);
277
278 // unregister from smscore
279 if (dev->coredev)
280 smscore_unregister_device(dev->coredev);
281
282 kfree(dev);
283
Michael Krufky18658112008-05-22 18:30:17 -0300284 printk(KERN_INFO "%s device %p destroyed\n", __func__, dev);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300285 }
286
287 usb_set_intfdata(intf, NULL);
288}
289
290int smsusb_init_device(struct usb_interface *intf)
291{
292 smsdevice_params_t params;
Michael Krufkya83ccdd2008-05-06 03:11:51 -0300293 smsusb_device_t *dev;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300294 int i, rc;
295
296 // create device object
297 dev = kzalloc(sizeof(smsusb_device_t), GFP_KERNEL);
Michael Krufky82237412008-06-15 15:14:13 -0300298 if (!dev) {
299 printk(KERN_INFO "%s kzalloc(sizeof(smsusb_device_t) failed\n",
300 __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300301 return -ENOMEM;
302 }
303
304 memset(&params, 0, sizeof(params));
305 usb_set_intfdata(intf, dev);
306 dev->udev = interface_to_usbdev(intf);
307
Michael Krufkyf17407a2008-06-14 00:43:26 -0300308 switch (dev->udev->descriptor.idProduct) {
Michael Krufky73104fb2008-06-14 18:27:18 -0300309
310 case USB_PID_STELLAR:
Michael Krufkyf17407a2008-06-14 00:43:26 -0300311 dev->buffer_size = USB1_BUFFER_SIZE;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300312
Michael Krufkyf17407a2008-06-14 00:43:26 -0300313 params.setmode_handler = smsusb1_setmode;
314 params.detectmode_handler = smsusb1_detectmode;
315 params.device_type = SMS_STELLAR;
316 printk(KERN_INFO "%s stellar device found\n", __func__ );
317 break;
318 default:
Michael Krufky73104fb2008-06-14 18:27:18 -0300319 switch (dev->udev->descriptor.idProduct) {
320 case USB_PID_NOVA_A:
Michael Krufkyf17407a2008-06-14 00:43:26 -0300321 params.device_type = SMS_NOVA_A0;
Michael Krufky494d24c2008-06-14 07:40:41 -0300322 printk(KERN_INFO "%s nova A0 found\n", __func__ );
Michael Krufky73104fb2008-06-14 18:27:18 -0300323 break;
324 default:
325 case USB_PID_NOVA_B:
Michael Krufkyf17407a2008-06-14 00:43:26 -0300326 params.device_type = SMS_NOVA_B0;
Michael Krufky494d24c2008-06-14 07:40:41 -0300327 printk(KERN_INFO "%s nova B0 found\n", __func__);
Michael Krufky73104fb2008-06-14 18:27:18 -0300328 break;
329 case USB_PID_VEGA:
Michael Krufkyf17407a2008-06-14 00:43:26 -0300330 params.device_type = SMS_VEGA;
Michael Krufky494d24c2008-06-14 07:40:41 -0300331 printk(KERN_INFO "%s Vega found\n", __func__);
Michael Krufkyf17407a2008-06-14 00:43:26 -0300332 }
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300333
Michael Krufkyf17407a2008-06-14 00:43:26 -0300334 dev->buffer_size = USB2_BUFFER_SIZE;
Michael Krufky82237412008-06-15 15:14:13 -0300335 dev->response_alignment =
336 dev->udev->ep_in[1]->desc.wMaxPacketSize -
337 sizeof(SmsMsgHdr_ST);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300338
Michael Krufkyf17407a2008-06-14 00:43:26 -0300339 params.flags |= SMS_DEVICE_FAMILY2;
340 break;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300341 }
342
343 params.device = &dev->udev->dev;
344 params.buffer_size = dev->buffer_size;
345 params.num_buffers = MAX_BUFFERS;
346 params.sendrequest_handler = smsusb_sendrequest;
347 params.context = dev;
Michael Krufky82237412008-06-15 15:14:13 -0300348 snprintf(params.devpath, sizeof(params.devpath),
349 "usb\\%d-%s", dev->udev->bus->busnum, dev->udev->devpath);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300350
Michael Krufky82237412008-06-15 15:14:13 -0300351 /* register in smscore */
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300352 rc = smscore_register_device(&params, &dev->coredev);
Michael Krufky82237412008-06-15 15:14:13 -0300353 if (rc < 0) {
354 printk(KERN_INFO "%s smscore_register_device(...) failed, "
355 "rc %d\n", __func__, rc);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300356 smsusb_term_device(intf);
357 return rc;
358 }
359
360 // initialize urbs
Michael Krufky82237412008-06-15 15:14:13 -0300361 for (i = 0; i < MAX_URBS; i++) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300362 dev->surbs[i].dev = dev;
363 usb_init_urb(&dev->surbs[i].urb);
364 }
365
Michael Krufkyf17407a2008-06-14 00:43:26 -0300366 printk(KERN_INFO "%s smsusb_start_streaming(...).\n", __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300367 rc = smsusb_start_streaming(dev);
Michael Krufky82237412008-06-15 15:14:13 -0300368 if (rc < 0) {
369 printk(KERN_INFO "%s smsusb_start_streaming(...) failed\n",
370 __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300371 smsusb_term_device(intf);
372 return rc;
373 }
374
375 rc = smscore_start_device(dev->coredev);
Michael Krufky82237412008-06-15 15:14:13 -0300376 if (rc < 0) {
377 printk(KERN_INFO "%s smscore_start_device(...) failed\n",
378 __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300379 smsusb_term_device(intf);
380 return rc;
381 }
382
Michael Krufky18658112008-05-22 18:30:17 -0300383 printk(KERN_INFO "%s device %p created\n", __func__, dev);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300384
385 return rc;
386}
387
388int smsusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
389{
390 struct usb_device *udev = interface_to_usbdev(intf);
391 char devpath[32];
392 int i, rc;
393
Michael Krufkyf17407a2008-06-14 00:43:26 -0300394 rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81));
395 rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02));
396
Michael Krufky82237412008-06-15 15:14:13 -0300397 if (intf->num_altsetting > 0) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300398 rc = usb_set_interface(udev, intf->cur_altsetting->desc.bInterfaceNumber, 0);
Michael Krufky82237412008-06-15 15:14:13 -0300399 if (rc < 0) {
400 printk(KERN_INFO "%s usb_set_interface failed, "
401 "rc %d\n", __func__, rc);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300402 return rc;
403 }
404 }
405
Michael Krufky82237412008-06-15 15:14:13 -0300406 printk(KERN_INFO "smsusb_probe %d\n",
407 intf->cur_altsetting->desc.bInterfaceNumber);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300408 for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i ++)
Michael Krufky82237412008-06-15 15:14:13 -0300409 printk(KERN_INFO "endpoint %d %02x %02x %d\n", i,
410 intf->cur_altsetting->endpoint[i].desc.bEndpointAddress,
411 intf->cur_altsetting->endpoint[i].desc.bmAttributes,
412 intf->cur_altsetting->endpoint[i].desc.wMaxPacketSize);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300413
Michael Krufky82237412008-06-15 15:14:13 -0300414 if ((udev->actconfig->desc.bNumInterfaces == 2) &&
415 (intf->cur_altsetting->desc.bInterfaceNumber == 0)) {
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300416 printk(KERN_INFO "rom interface 0 is not used\n");
417 return -ENODEV;
418 }
419
Michael Krufky82237412008-06-15 15:14:13 -0300420 if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
421 snprintf(devpath, sizeof(devpath), "usb\\%d-%s",
422 udev->bus->busnum, udev->devpath);
Michael Krufkyf17407a2008-06-14 00:43:26 -0300423 printk(KERN_INFO "stellar device was found.\n");
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300424 return smsusb1_load_firmware(udev, smscore_registry_getmode(devpath));
425 }
426
Michael Krufkyf17407a2008-06-14 00:43:26 -0300427 rc = smsusb_init_device(intf);
Michael Krufky494d24c2008-06-14 07:40:41 -0300428 printk(KERN_INFO "%s rc %d\n", __func__, rc);
Michael Krufkyf17407a2008-06-14 00:43:26 -0300429 return rc;
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300430}
431
432void smsusb_disconnect(struct usb_interface *intf)
433{
434 smsusb_term_device(intf);
435}
436
Steven Toth7d18d2e2008-05-22 18:07:39 -0300437static struct usb_device_id smsusb_id_table [] = {
Michael Krufky73104fb2008-06-14 18:27:18 -0300438 { USB_DEVICE(USB_VID_SIANO, 0x0010) },
439 { USB_DEVICE(USB_VID_SIANO, USB_PID_STELLAR) },
440 { USB_DEVICE(USB_VID_SIANO, USB_PID_NOVA_A) },
Steven Toth7d18d2e2008-05-22 18:07:39 -0300441 { } /* Terminating entry */
442};
443MODULE_DEVICE_TABLE (usb, smsusb_id_table);
444
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300445static struct usb_driver smsusb_driver = {
446 .name = "smsusb",
447 .probe = smsusb_probe,
Michael Krufky82237412008-06-15 15:14:13 -0300448 .disconnect = smsusb_disconnect,
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300449 .id_table = smsusb_id_table,
450};
451
Steven Totheae55662008-05-22 18:04:36 -0300452int smsusb_register(void)
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300453{
454 int rc = usb_register(&smsusb_driver);
455 if (rc)
456 printk(KERN_INFO "usb_register failed. Error number %d\n", rc);
457
Michael Krufky18658112008-05-22 18:30:17 -0300458 printk(KERN_INFO "%s\n", __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300459
460 return rc;
461}
462
Steven Totheae55662008-05-22 18:04:36 -0300463void smsusb_unregister(void)
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300464{
Steven Toth3dd24372008-05-22 18:01:02 -0300465 /* Regular USB Cleanup */
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300466 usb_deregister(&smsusb_driver);
Michael Krufky18658112008-05-22 18:30:17 -0300467 printk(KERN_INFO "%s\n", __func__);
Michael Krufky2e5c1ec82008-05-19 18:56:13 -0300468}
469