Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 1 | /* |
Michael Krufky | 8f37356b | 2008-06-28 17:09:28 -0300 | [diff] [blame] | 2 | * Driver for the Siano SMS1xxx USB dongle |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 3 | * |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 4 | * author: Anatoly Greenblat |
| 5 | * |
| 6 | * Copyright (c), 2005-2008 Siano Mobile Silicon, Inc. |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
Michael Krufky | 09a29b7 | 2008-09-03 16:48:17 -0300 | [diff] [blame] | 9 | * it under the terms of the GNU General Public License version 2 as |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 10 | * published by the Free Software Foundation; |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 11 | * |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 12 | * Software distributed under the License is distributed on an "AS IS" |
| 13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 14 | * |
Michael Krufky | 8544706 | 2008-05-22 18:29:20 -0300 | [diff] [blame] | 15 | * See the GNU General Public License for more details. |
Steven Toth | 8d4f9d0 | 2008-05-22 18:05:26 -0300 | [diff] [blame] | 16 | * |
| 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 Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 22 | #include <linux/kernel.h> |
| 23 | #include <linux/init.h> |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 24 | #include <linux/usb.h> |
| 25 | #include <linux/firmware.h> |
| 26 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 27 | #include "smscoreapi.h" |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 28 | #include "sms-cards.h" |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 29 | |
Michael Krufky | 0d02efe | 2009-02-27 02:42:16 -0300 | [diff] [blame] | 30 | static int sms_dbg; |
| 31 | module_param_named(debug, sms_dbg, int, 0644); |
| 32 | MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))"); |
| 33 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 34 | #define USB1_BUFFER_SIZE 0x1000 |
| 35 | #define USB2_BUFFER_SIZE 0x4000 |
| 36 | |
| 37 | #define MAX_BUFFERS 50 |
| 38 | #define MAX_URBS 10 |
| 39 | |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 40 | struct smsusb_device_t; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 41 | |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 42 | struct smsusb_urb_t { |
| 43 | struct smscore_buffer_t *cb; |
| 44 | struct smsusb_device_t *dev; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 45 | |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 46 | struct urb urb; |
| 47 | }; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 48 | |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 49 | struct smsusb_device_t { |
Michael Krufky | a83ccdd | 2008-05-06 03:11:51 -0300 | [diff] [blame] | 50 | struct usb_device *udev; |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 51 | struct smscore_device_t *coredev; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 52 | |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 53 | struct smsusb_urb_t surbs[MAX_URBS]; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 54 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 55 | int response_alignment; |
| 56 | int buffer_size; |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 57 | }; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 58 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 59 | static int smsusb_submit_urb(struct smsusb_device_t *dev, |
| 60 | struct smsusb_urb_t *surb); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 61 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 62 | static void smsusb_onresponse(struct urb *urb) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 63 | { |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 64 | struct smsusb_urb_t *surb = (struct smsusb_urb_t *) urb->context; |
| 65 | struct smsusb_device_t *dev = surb->dev; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 66 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 67 | if (urb->status < 0) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 68 | sms_err("error, urb status %d, %d bytes", |
| 69 | urb->status, urb->actual_length); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 70 | return; |
| 71 | } |
| 72 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 73 | if (urb->actual_length > 0) { |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 74 | struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *) surb->cb->p; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 75 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 76 | if (urb->actual_length >= phdr->msgLength) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 77 | surb->cb->size = phdr->msgLength; |
| 78 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 79 | if (dev->response_alignment && |
| 80 | (phdr->msgFlags & MSG_HDR_FLAG_SPLIT_MSG)) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 81 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 82 | surb->cb->offset = |
| 83 | dev->response_alignment + |
| 84 | ((phdr->msgFlags >> 8) & 3); |
| 85 | |
| 86 | /* sanity check */ |
| 87 | if (((int) phdr->msgLength + |
| 88 | surb->cb->offset) > urb->actual_length) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 89 | sms_err("invalid response " |
| 90 | "msglen %d offset %d " |
| 91 | "size %d", |
| 92 | phdr->msgLength, |
| 93 | surb->cb->offset, |
| 94 | urb->actual_length); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 95 | goto exit_and_resubmit; |
| 96 | } |
| 97 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 98 | /* move buffer pointer and |
| 99 | * copy header to its new location */ |
Michael Krufky | 55ad310 | 2008-05-06 03:52:44 -0300 | [diff] [blame] | 100 | memcpy((char *) phdr + surb->cb->offset, |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 101 | phdr, sizeof(struct SmsMsgHdr_ST)); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 102 | } else |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 103 | surb->cb->offset = 0; |
| 104 | |
| 105 | smscore_onresponse(dev->coredev, surb->cb); |
| 106 | surb->cb = NULL; |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 107 | } else { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 108 | sms_err("invalid response " |
| 109 | "msglen %d actual %d", |
| 110 | phdr->msgLength, urb->actual_length); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 111 | } |
| 112 | } |
| 113 | |
| 114 | exit_and_resubmit: |
| 115 | smsusb_submit_urb(dev, surb); |
| 116 | } |
| 117 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 118 | static int smsusb_submit_urb(struct smsusb_device_t *dev, |
| 119 | struct smsusb_urb_t *surb) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 120 | { |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 121 | if (!surb->cb) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 122 | surb->cb = smscore_getbuffer(dev->coredev); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 123 | if (!surb->cb) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 124 | sms_err("smscore_getbuffer(...) returned NULL"); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 125 | return -ENOMEM; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | usb_fill_bulk_urb( |
| 130 | &surb->urb, |
| 131 | dev->udev, |
| 132 | usb_rcvbulkpipe(dev->udev, 0x81), |
| 133 | surb->cb->p, |
| 134 | dev->buffer_size, |
| 135 | smsusb_onresponse, |
| 136 | surb |
| 137 | ); |
| 138 | surb->urb.transfer_dma = surb->cb->phys; |
| 139 | surb->urb.transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
| 140 | |
| 141 | return usb_submit_urb(&surb->urb, GFP_ATOMIC); |
| 142 | } |
| 143 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 144 | static void smsusb_stop_streaming(struct smsusb_device_t *dev) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 145 | { |
| 146 | int i; |
| 147 | |
Michael Krufky | fa830e8 | 2008-06-15 15:52:43 -0300 | [diff] [blame] | 148 | for (i = 0; i < MAX_URBS; i++) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 149 | usb_kill_urb(&dev->surbs[i].urb); |
| 150 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 151 | if (dev->surbs[i].cb) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 152 | smscore_putbuffer(dev->coredev, dev->surbs[i].cb); |
| 153 | dev->surbs[i].cb = NULL; |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 158 | static int smsusb_start_streaming(struct smsusb_device_t *dev) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 159 | { |
| 160 | int i, rc; |
| 161 | |
Michael Krufky | fa830e8 | 2008-06-15 15:52:43 -0300 | [diff] [blame] | 162 | for (i = 0; i < MAX_URBS; i++) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 163 | rc = smsusb_submit_urb(dev, &dev->surbs[i]); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 164 | if (rc < 0) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 165 | sms_err("smsusb_submit_urb(...) failed"); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 166 | smsusb_stop_streaming(dev); |
| 167 | break; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | return rc; |
| 172 | } |
| 173 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 174 | static int smsusb_sendrequest(void *context, void *buffer, size_t size) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 175 | { |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 176 | struct smsusb_device_t *dev = (struct smsusb_device_t *) context; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 177 | int dummy; |
| 178 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 179 | return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2), |
| 180 | buffer, size, &dummy, 1000); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 181 | } |
| 182 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 183 | static char *smsusb1_fw_lkup[] = { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 184 | "dvbt_stellar_usb.inp", |
| 185 | "dvbh_stellar_usb.inp", |
| 186 | "tdmb_stellar_usb.inp", |
| 187 | "none", |
| 188 | "dvbt_bda_stellar_usb.inp", |
| 189 | }; |
| 190 | |
Michael Krufky | 1fbc3ca | 2008-07-01 04:35:26 -0300 | [diff] [blame] | 191 | static inline char *sms_get_fw_name(int mode, int board_id) |
| 192 | { |
| 193 | char **fw = sms_get_board(board_id)->fw; |
| 194 | return (fw && fw[mode]) ? fw[mode] : smsusb1_fw_lkup[mode]; |
| 195 | } |
| 196 | |
| 197 | static int smsusb1_load_firmware(struct usb_device *udev, int id, int board_id) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 198 | { |
| 199 | const struct firmware *fw; |
Michael Krufky | a83ccdd | 2008-05-06 03:11:51 -0300 | [diff] [blame] | 200 | u8 *fw_buffer; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 201 | int rc, dummy; |
Michael Krufky | 1fbc3ca | 2008-07-01 04:35:26 -0300 | [diff] [blame] | 202 | char *fw_filename; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 203 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 204 | if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 205 | sms_err("invalid firmware id specified %d", id); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 206 | return -EINVAL; |
| 207 | } |
| 208 | |
Michael Krufky | 1fbc3ca | 2008-07-01 04:35:26 -0300 | [diff] [blame] | 209 | fw_filename = sms_get_fw_name(id, board_id); |
| 210 | |
| 211 | rc = request_firmware(&fw, fw_filename, &udev->dev); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 212 | if (rc < 0) { |
Michael Krufky | 1fbc3ca | 2008-07-01 04:35:26 -0300 | [diff] [blame] | 213 | sms_warn("failed to open \"%s\" mode %d, " |
| 214 | "trying again with default firmware", fw_filename, id); |
| 215 | |
| 216 | fw_filename = smsusb1_fw_lkup[id]; |
| 217 | rc = request_firmware(&fw, fw_filename, &udev->dev); |
| 218 | if (rc < 0) { |
| 219 | sms_warn("failed to open \"%s\" mode %d", |
| 220 | fw_filename, id); |
| 221 | |
| 222 | return rc; |
| 223 | } |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | fw_buffer = kmalloc(fw->size, GFP_KERNEL); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 227 | if (fw_buffer) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 228 | memcpy(fw_buffer, fw->data, fw->size); |
| 229 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 230 | rc = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 2), |
| 231 | fw_buffer, fw->size, &dummy, 1000); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 232 | |
Michael Krufky | 0f2a1ee | 2008-06-28 20:53:45 -0300 | [diff] [blame] | 233 | sms_info("sent %zd(%d) bytes, rc %d", fw->size, dummy, rc); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 234 | |
| 235 | kfree(fw_buffer); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 236 | } else { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 237 | sms_err("failed to allocate firmware buffer"); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 238 | rc = -ENOMEM; |
| 239 | } |
Michael Krufky | 1fbc3ca | 2008-07-01 04:35:26 -0300 | [diff] [blame] | 240 | sms_info("read FW %s, size=%zd", fw_filename, fw->size); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 241 | |
| 242 | release_firmware(fw); |
| 243 | |
| 244 | return rc; |
| 245 | } |
| 246 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 247 | static void smsusb1_detectmode(void *context, int *mode) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 248 | { |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 249 | char *product_string = |
| 250 | ((struct smsusb_device_t *) context)->udev->product; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 251 | |
| 252 | *mode = DEVICE_MODE_NONE; |
| 253 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 254 | if (!product_string) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 255 | product_string = "none"; |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 256 | sms_err("product string not found"); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 257 | } else if (strstr(product_string, "DVBH")) |
| 258 | *mode = 1; |
| 259 | else if (strstr(product_string, "BDA")) |
| 260 | *mode = 4; |
| 261 | else if (strstr(product_string, "DVBT")) |
| 262 | *mode = 0; |
| 263 | else if (strstr(product_string, "TDMB")) |
| 264 | *mode = 2; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 265 | |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 266 | sms_info("%d \"%s\"", *mode, product_string); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 267 | } |
| 268 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 269 | static int smsusb1_setmode(void *context, int mode) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 270 | { |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 271 | struct SmsMsgHdr_ST Msg = { MSG_SW_RELOAD_REQ, 0, HIF_TASK, |
| 272 | sizeof(struct SmsMsgHdr_ST), 0 }; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 273 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 274 | if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 275 | sms_err("invalid firmware id specified %d", mode); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 276 | return -EINVAL; |
| 277 | } |
| 278 | |
| 279 | return smsusb_sendrequest(context, &Msg, sizeof(Msg)); |
| 280 | } |
| 281 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 282 | static void smsusb_term_device(struct usb_interface *intf) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 283 | { |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 284 | struct smsusb_device_t *dev = |
| 285 | (struct smsusb_device_t *) usb_get_intfdata(intf); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 286 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 287 | if (dev) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 288 | smsusb_stop_streaming(dev); |
| 289 | |
Michael Krufky | fa830e8 | 2008-06-15 15:52:43 -0300 | [diff] [blame] | 290 | /* unregister from smscore */ |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 291 | if (dev->coredev) |
| 292 | smscore_unregister_device(dev->coredev); |
| 293 | |
| 294 | kfree(dev); |
| 295 | |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 296 | sms_info("device %p destroyed", dev); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | usb_set_intfdata(intf, NULL); |
| 300 | } |
| 301 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 302 | static int smsusb_init_device(struct usb_interface *intf, int board_id) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 303 | { |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 304 | struct smsdevice_params_t params; |
| 305 | struct smsusb_device_t *dev; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 306 | int i, rc; |
| 307 | |
Michael Krufky | fa830e8 | 2008-06-15 15:52:43 -0300 | [diff] [blame] | 308 | /* create device object */ |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 309 | dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 310 | if (!dev) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 311 | sms_err("kzalloc(sizeof(struct smsusb_device_t) failed"); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 312 | return -ENOMEM; |
| 313 | } |
| 314 | |
| 315 | memset(¶ms, 0, sizeof(params)); |
| 316 | usb_set_intfdata(intf, dev); |
| 317 | dev->udev = interface_to_usbdev(intf); |
| 318 | |
Michael Krufky | 2708e88 | 2008-06-21 05:24:38 -0300 | [diff] [blame] | 319 | params.device_type = sms_get_board(board_id)->type; |
Michael Krufky | 73104fb | 2008-06-14 18:27:18 -0300 | [diff] [blame] | 320 | |
Michael Krufky | 2708e88 | 2008-06-21 05:24:38 -0300 | [diff] [blame] | 321 | switch (params.device_type) { |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 322 | case SMS_STELLAR: |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 323 | dev->buffer_size = USB1_BUFFER_SIZE; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 324 | |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 325 | params.setmode_handler = smsusb1_setmode; |
| 326 | params.detectmode_handler = smsusb1_detectmode; |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 327 | break; |
| 328 | default: |
Michael Krufky | 2708e88 | 2008-06-21 05:24:38 -0300 | [diff] [blame] | 329 | sms_err("Unspecified sms device type!"); |
| 330 | /* fall-thru */ |
| 331 | case SMS_NOVA_A0: |
| 332 | case SMS_NOVA_B0: |
| 333 | case SMS_VEGA: |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 334 | dev->buffer_size = USB2_BUFFER_SIZE; |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 335 | dev->response_alignment = |
| 336 | dev->udev->ep_in[1]->desc.wMaxPacketSize - |
Michael Krufky | 18245e1 | 2008-06-15 17:52:24 -0300 | [diff] [blame] | 337 | sizeof(struct SmsMsgHdr_ST); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 338 | |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 339 | params.flags |= SMS_DEVICE_FAMILY2; |
| 340 | break; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 341 | } |
| 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 Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 348 | snprintf(params.devpath, sizeof(params.devpath), |
| 349 | "usb\\%d-%s", dev->udev->bus->busnum, dev->udev->devpath); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 350 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 351 | /* register in smscore */ |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 352 | rc = smscore_register_device(¶ms, &dev->coredev); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 353 | if (rc < 0) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 354 | sms_err("smscore_register_device(...) failed, rc %d", rc); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 355 | smsusb_term_device(intf); |
| 356 | return rc; |
| 357 | } |
| 358 | |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 359 | smscore_set_board_id(dev->coredev, board_id); |
| 360 | |
Michael Krufky | fa830e8 | 2008-06-15 15:52:43 -0300 | [diff] [blame] | 361 | /* initialize urbs */ |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 362 | for (i = 0; i < MAX_URBS; i++) { |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 363 | dev->surbs[i].dev = dev; |
| 364 | usb_init_urb(&dev->surbs[i].urb); |
| 365 | } |
| 366 | |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 367 | sms_info("smsusb_start_streaming(...)."); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 368 | rc = smsusb_start_streaming(dev); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 369 | if (rc < 0) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 370 | sms_err("smsusb_start_streaming(...) failed"); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 371 | smsusb_term_device(intf); |
| 372 | return rc; |
| 373 | } |
| 374 | |
| 375 | rc = smscore_start_device(dev->coredev); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 376 | if (rc < 0) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 377 | sms_err("smscore_start_device(...) failed"); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 378 | smsusb_term_device(intf); |
| 379 | return rc; |
| 380 | } |
| 381 | |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 382 | sms_info("device %p created", dev); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 383 | |
| 384 | return rc; |
| 385 | } |
| 386 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 387 | static int smsusb_probe(struct usb_interface *intf, |
| 388 | const struct usb_device_id *id) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 389 | { |
| 390 | struct usb_device *udev = interface_to_usbdev(intf); |
| 391 | char devpath[32]; |
| 392 | int i, rc; |
| 393 | |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 394 | rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81)); |
| 395 | rc = usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02)); |
| 396 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 397 | if (intf->num_altsetting > 0) { |
Michael Krufky | 59bf6b8 | 2008-06-15 16:50:11 -0300 | [diff] [blame] | 398 | rc = usb_set_interface( |
| 399 | udev, intf->cur_altsetting->desc.bInterfaceNumber, 0); |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 400 | if (rc < 0) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 401 | sms_err("usb_set_interface failed, rc %d", rc); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 402 | return rc; |
| 403 | } |
| 404 | } |
| 405 | |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 406 | sms_info("smsusb_probe %d", |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 407 | intf->cur_altsetting->desc.bInterfaceNumber); |
Michael Krufky | fa830e8 | 2008-06-15 15:52:43 -0300 | [diff] [blame] | 408 | for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 409 | sms_info("endpoint %d %02x %02x %d", i, |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 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 Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 413 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 414 | if ((udev->actconfig->desc.bNumInterfaces == 2) && |
| 415 | (intf->cur_altsetting->desc.bInterfaceNumber == 0)) { |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 416 | sms_err("rom interface 0 is not used"); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 417 | return -ENODEV; |
| 418 | } |
| 419 | |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 420 | if (intf->cur_altsetting->desc.bInterfaceNumber == 1) { |
| 421 | snprintf(devpath, sizeof(devpath), "usb\\%d-%s", |
| 422 | udev->bus->busnum, udev->devpath); |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 423 | sms_info("stellar device was found."); |
Michael Krufky | 59bf6b8 | 2008-06-15 16:50:11 -0300 | [diff] [blame] | 424 | return smsusb1_load_firmware( |
Michael Krufky | 1fbc3ca | 2008-07-01 04:35:26 -0300 | [diff] [blame] | 425 | udev, smscore_registry_getmode(devpath), |
| 426 | id->driver_info); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 427 | } |
| 428 | |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 429 | rc = smsusb_init_device(intf, id->driver_info); |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 430 | sms_info("rc %d", rc); |
Michael Krufky | 05860f2 | 2008-08-31 17:39:58 -0300 | [diff] [blame] | 431 | sms_board_load_modules(id->driver_info); |
Michael Krufky | f17407a | 2008-06-14 00:43:26 -0300 | [diff] [blame] | 432 | return rc; |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 433 | } |
| 434 | |
Michael Krufky | 0c071f3 | 2008-06-21 02:44:02 -0300 | [diff] [blame] | 435 | static void smsusb_disconnect(struct usb_interface *intf) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 436 | { |
| 437 | smsusb_term_device(intf); |
| 438 | } |
| 439 | |
Uri Shkolnik | 2f56c34 | 2008-11-22 14:08:46 -0300 | [diff] [blame] | 440 | static int smsusb_suspend(struct usb_interface *intf, pm_message_t msg) |
| 441 | { |
| 442 | struct smsusb_device_t *dev = |
| 443 | (struct smsusb_device_t *)usb_get_intfdata(intf); |
Michael Krufky | b9391f4 | 2008-08-31 16:08:15 -0300 | [diff] [blame] | 444 | printk(KERN_INFO "%s: Entering status %d.\n", __func__, msg.event); |
Uri Shkolnik | 2f56c34 | 2008-11-22 14:08:46 -0300 | [diff] [blame] | 445 | smsusb_stop_streaming(dev); |
| 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | static int smsusb_resume(struct usb_interface *intf) |
| 450 | { |
| 451 | int rc, i; |
| 452 | struct smsusb_device_t *dev = |
| 453 | (struct smsusb_device_t *)usb_get_intfdata(intf); |
| 454 | struct usb_device *udev = interface_to_usbdev(intf); |
| 455 | |
Michael Krufky | b9391f4 | 2008-08-31 16:08:15 -0300 | [diff] [blame] | 456 | printk(KERN_INFO "%s: Entering.\n", __func__); |
Uri Shkolnik | 2f56c34 | 2008-11-22 14:08:46 -0300 | [diff] [blame] | 457 | usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x81)); |
| 458 | usb_clear_halt(udev, usb_rcvbulkpipe(udev, 0x02)); |
| 459 | |
| 460 | for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) |
| 461 | printk(KERN_INFO "endpoint %d %02x %02x %d\n", i, |
| 462 | intf->cur_altsetting->endpoint[i].desc.bEndpointAddress, |
| 463 | intf->cur_altsetting->endpoint[i].desc.bmAttributes, |
| 464 | intf->cur_altsetting->endpoint[i].desc.wMaxPacketSize); |
| 465 | |
| 466 | if (intf->num_altsetting > 0) { |
| 467 | rc = usb_set_interface(udev, |
| 468 | intf->cur_altsetting->desc. |
| 469 | bInterfaceNumber, 0); |
| 470 | if (rc < 0) { |
Michael Krufky | b9391f4 | 2008-08-31 16:08:15 -0300 | [diff] [blame] | 471 | printk(KERN_INFO "%s usb_set_interface failed, " |
| 472 | "rc %d\n", __func__, rc); |
Uri Shkolnik | 2f56c34 | 2008-11-22 14:08:46 -0300 | [diff] [blame] | 473 | return rc; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | smsusb_start_streaming(dev); |
| 478 | return 0; |
| 479 | } |
| 480 | |
Michael Krufky | 841a3f0 | 2008-08-31 17:03:15 -0300 | [diff] [blame] | 481 | struct usb_device_id smsusb_id_table[] = { |
| 482 | #ifdef CONFIG_DVB_SIANO_SMS1XXX_SMS_IDS |
| 483 | { USB_DEVICE(0x187f, 0x0010), |
| 484 | .driver_info = SMS1XXX_BOARD_SIANO_STELLAR }, |
| 485 | { USB_DEVICE(0x187f, 0x0100), |
| 486 | .driver_info = SMS1XXX_BOARD_SIANO_STELLAR }, |
| 487 | { USB_DEVICE(0x187f, 0x0200), |
| 488 | .driver_info = SMS1XXX_BOARD_SIANO_NOVA_A }, |
| 489 | { USB_DEVICE(0x187f, 0x0201), |
| 490 | .driver_info = SMS1XXX_BOARD_SIANO_NOVA_B }, |
| 491 | { USB_DEVICE(0x187f, 0x0300), |
| 492 | .driver_info = SMS1XXX_BOARD_SIANO_VEGA }, |
| 493 | #endif |
| 494 | { USB_DEVICE(0x2040, 0x1700), |
| 495 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT }, |
| 496 | { USB_DEVICE(0x2040, 0x1800), |
| 497 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A }, |
| 498 | { USB_DEVICE(0x2040, 0x1801), |
| 499 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B }, |
| 500 | { USB_DEVICE(0x2040, 0x2000), |
| 501 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD }, |
| 502 | { USB_DEVICE(0x2040, 0x2009), |
| 503 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2 }, |
| 504 | { USB_DEVICE(0x2040, 0x200a), |
| 505 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD }, |
| 506 | { USB_DEVICE(0x2040, 0x2010), |
| 507 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD }, |
| 508 | { USB_DEVICE(0x2040, 0x2011), |
| 509 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD }, |
| 510 | { USB_DEVICE(0x2040, 0x2019), |
| 511 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD }, |
| 512 | { USB_DEVICE(0x2040, 0x5500), |
| 513 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, |
| 514 | { USB_DEVICE(0x2040, 0x5510), |
| 515 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, |
| 516 | { USB_DEVICE(0x2040, 0x5520), |
| 517 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, |
| 518 | { USB_DEVICE(0x2040, 0x5530), |
| 519 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, |
| 520 | { USB_DEVICE(0x2040, 0x5580), |
| 521 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, |
| 522 | { USB_DEVICE(0x2040, 0x5590), |
| 523 | .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, |
| 524 | { } /* Terminating entry */ |
| 525 | }; |
| 526 | MODULE_DEVICE_TABLE(usb, smsusb_id_table); |
| 527 | |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 528 | static struct usb_driver smsusb_driver = { |
Uri Shkolnik | dba843a | 2008-08-31 00:44:04 -0300 | [diff] [blame] | 529 | .name = "smsusb", |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 530 | .probe = smsusb_probe, |
Michael Krufky | 8223741 | 2008-06-15 15:14:13 -0300 | [diff] [blame] | 531 | .disconnect = smsusb_disconnect, |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 532 | .id_table = smsusb_id_table, |
Uri Shkolnik | 2f56c34 | 2008-11-22 14:08:46 -0300 | [diff] [blame] | 533 | |
| 534 | .suspend = smsusb_suspend, |
| 535 | .resume = smsusb_resume, |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 536 | }; |
| 537 | |
Uri Shkolnik | e0f14c2 | 2008-08-31 00:44:04 -0300 | [diff] [blame] | 538 | int smsusb_module_init(void) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 539 | { |
| 540 | int rc = usb_register(&smsusb_driver); |
| 541 | if (rc) |
Michael Krufky | eb25094 | 2008-06-19 22:07:23 -0300 | [diff] [blame] | 542 | sms_err("usb_register failed. Error number %d", rc); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 543 | |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 544 | sms_debug(""); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 545 | |
| 546 | return rc; |
| 547 | } |
| 548 | |
Uri Shkolnik | e0f14c2 | 2008-08-31 00:44:04 -0300 | [diff] [blame] | 549 | void smsusb_module_exit(void) |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 550 | { |
Michael Krufky | a0c0abc | 2008-06-19 20:35:21 -0300 | [diff] [blame] | 551 | sms_debug(""); |
Steven Toth | 3dd2437 | 2008-05-22 18:01:02 -0300 | [diff] [blame] | 552 | /* Regular USB Cleanup */ |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 553 | usb_deregister(&smsusb_driver); |
Michael Krufky | 2e5c1ec8 | 2008-05-19 18:56:13 -0300 | [diff] [blame] | 554 | } |
| 555 | |
Uri Shkolnik | e0f14c2 | 2008-08-31 00:44:04 -0300 | [diff] [blame] | 556 | module_init(smsusb_module_init); |
| 557 | module_exit(smsusb_module_exit); |
| 558 | |
| 559 | MODULE_DESCRIPTION("Driver for the Siano SMS1XXX USB dongle"); |
| 560 | MODULE_AUTHOR("Siano Mobile Silicon, INC. (uris@siano-ms.com)"); |
| 561 | MODULE_LICENSE("GPL"); |