diff options
author | Rene Buergel <rene.buergel@sohard.de> | 2012-09-26 16:20:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-26 17:20:28 -0400 |
commit | 70c048a238c780c226eb4b115ebaa908cb3b34ec (patch) | |
tree | 0aef8cbb8b4b9e2172a4444060df5e2a473998af /drivers/usb/serial | |
parent | e0423dee897734576cf4cc021165dd4521e9d3cc (diff) |
USB: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc
This patch
- moves drivers/usb/serial/ezusb.c to drivers/usb/misc/
- renamed CONFIG_USB_EZUSB to CONFIG_USB_EZUSB_FX2 to avoid build errors
- adapts Makefiles and Kconfigs switching from bool to tristate for CONFIG_USB_EZUSB_FX2
Signed-off-by: René Bürgel <rene.buergel@sohard.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r-- | drivers/usb/serial/Kconfig | 13 | ||||
-rw-r--r-- | drivers/usb/serial/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/serial/ezusb.c | 160 |
3 files changed, 4 insertions, 170 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index f604f707a058..76f462241738 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -42,11 +42,6 @@ config USB_SERIAL_CONSOLE | |||
42 | 42 | ||
43 | If unsure, say N. | 43 | If unsure, say N. |
44 | 44 | ||
45 | config USB_EZUSB | ||
46 | bool "Functions for loading firmware on EZUSB chips" | ||
47 | help | ||
48 | Say Y here if you need EZUSB device support. | ||
49 | |||
50 | config USB_SERIAL_GENERIC | 45 | config USB_SERIAL_GENERIC |
51 | bool "USB Generic Serial Driver" | 46 | bool "USB Generic Serial Driver" |
52 | help | 47 | help |
@@ -94,7 +89,7 @@ config USB_SERIAL_CH341 | |||
94 | 89 | ||
95 | config USB_SERIAL_WHITEHEAT | 90 | config USB_SERIAL_WHITEHEAT |
96 | tristate "USB ConnectTech WhiteHEAT Serial Driver" | 91 | tristate "USB ConnectTech WhiteHEAT Serial Driver" |
97 | select USB_EZUSB | 92 | select USB_EZUSB_FX2 |
98 | help | 93 | help |
99 | Say Y here if you want to use a ConnectTech WhiteHEAT 4 port | 94 | Say Y here if you want to use a ConnectTech WhiteHEAT 4 port |
100 | USB to serial converter device. | 95 | USB to serial converter device. |
@@ -281,7 +276,7 @@ config USB_SERIAL_IUU | |||
281 | 276 | ||
282 | config USB_SERIAL_KEYSPAN_PDA | 277 | config USB_SERIAL_KEYSPAN_PDA |
283 | tristate "USB Keyspan PDA Single Port Serial Driver" | 278 | tristate "USB Keyspan PDA Single Port Serial Driver" |
284 | select USB_EZUSB | 279 | select USB_EZUSB_FX2 |
285 | help | 280 | help |
286 | Say Y here if you want to use a Keyspan PDA single port USB to | 281 | Say Y here if you want to use a Keyspan PDA single port USB to |
287 | serial converter device. This driver makes use of firmware | 282 | serial converter device. This driver makes use of firmware |
@@ -292,7 +287,7 @@ config USB_SERIAL_KEYSPAN_PDA | |||
292 | 287 | ||
293 | config USB_SERIAL_KEYSPAN | 288 | config USB_SERIAL_KEYSPAN |
294 | tristate "USB Keyspan USA-xxx Serial Driver" | 289 | tristate "USB Keyspan USA-xxx Serial Driver" |
295 | select USB_EZUSB | 290 | select USB_EZUSB_FX2 |
296 | ---help--- | 291 | ---help--- |
297 | Say Y here if you want to use Keyspan USB to serial converter | 292 | Say Y here if you want to use Keyspan USB to serial converter |
298 | devices. This driver makes use of Keyspan's official firmware | 293 | devices. This driver makes use of Keyspan's official firmware |
@@ -596,7 +591,7 @@ config USB_SERIAL_CYBERJACK | |||
596 | 591 | ||
597 | config USB_SERIAL_XIRCOM | 592 | config USB_SERIAL_XIRCOM |
598 | tristate "USB Xircom / Entregra Single Port Serial Driver" | 593 | tristate "USB Xircom / Entregra Single Port Serial Driver" |
599 | select USB_EZUSB | 594 | select USB_EZUSB_FX2 |
600 | help | 595 | help |
601 | Say Y here if you want to use a Xircom or Entregra single port USB to | 596 | Say Y here if you want to use a Xircom or Entregra single port USB to |
602 | serial converter device. This driver makes use of firmware | 597 | serial converter device. This driver makes use of firmware |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 45871f9ad1e1..3b3e7308d476 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -9,7 +9,6 @@ obj-$(CONFIG_USB_SERIAL) += usbserial.o | |||
9 | usbserial-y := usb-serial.o generic.o bus.o | 9 | usbserial-y := usb-serial.o generic.o bus.o |
10 | 10 | ||
11 | usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o | 11 | usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o |
12 | usbserial-$(CONFIG_USB_EZUSB) += ezusb.o | ||
13 | 12 | ||
14 | obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o | 13 | obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o |
15 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o | 14 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o |
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c deleted file mode 100644 index 4223d761223d..000000000000 --- a/drivers/usb/serial/ezusb.c +++ /dev/null | |||
@@ -1,160 +0,0 @@ | |||
1 | /* | ||
2 | * EZ-USB specific functions used by some of the USB to Serial drivers. | ||
3 | * | ||
4 | * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com) | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License version | ||
8 | * 2 as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/usb.h> | ||
16 | #include <linux/firmware.h> | ||
17 | #include <linux/ihex.h> | ||
18 | |||
19 | struct ezusb_fx_type { | ||
20 | /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ | ||
21 | unsigned short cpucs_reg; | ||
22 | unsigned short max_internal_adress; | ||
23 | }; | ||
24 | |||
25 | struct ezusb_fx_type ezusb_fx1 = { | ||
26 | .cpucs_reg = 0x7F92, | ||
27 | .max_internal_adress = 0x1B3F, | ||
28 | }; | ||
29 | |||
30 | struct ezusb_fx_type ezusb_fx2 = { | ||
31 | .cpucs_reg = 0xE600, | ||
32 | .max_internal_adress = 0x3FFF, | ||
33 | }; | ||
34 | |||
35 | /* Commands for writing to memory */ | ||
36 | #define WRITE_INT_RAM 0xA0 | ||
37 | #define WRITE_EXT_RAM 0xA3 | ||
38 | |||
39 | int ezusb_writememory(struct usb_device *dev, int address, | ||
40 | unsigned char *data, int length, __u8 request) | ||
41 | { | ||
42 | int result; | ||
43 | unsigned char *transfer_buffer; | ||
44 | |||
45 | if (!dev) | ||
46 | return -ENODEV; | ||
47 | |||
48 | transfer_buffer = kmemdup(data, length, GFP_KERNEL); | ||
49 | if (!transfer_buffer) { | ||
50 | dev_err(&dev->dev, "%s - kmalloc(%d) failed.\n", | ||
51 | __func__, length); | ||
52 | return -ENOMEM; | ||
53 | } | ||
54 | result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, | ||
55 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
56 | address, 0, transfer_buffer, length, 3000); | ||
57 | |||
58 | kfree(transfer_buffer); | ||
59 | return result; | ||
60 | } | ||
61 | EXPORT_SYMBOL_GPL(ezusb_writememory); | ||
62 | |||
63 | int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg, | ||
64 | unsigned char reset_bit) | ||
65 | { | ||
66 | int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM); | ||
67 | if (response < 0) | ||
68 | dev_err(&dev->dev, "%s-%d failed: %d\n", | ||
69 | __func__, reset_bit, response); | ||
70 | return response; | ||
71 | } | ||
72 | |||
73 | int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit) | ||
74 | { | ||
75 | return ezusb_set_reset(dev, ezusb_fx1.cpucs_reg, reset_bit); | ||
76 | } | ||
77 | EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset); | ||
78 | |||
79 | int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit) | ||
80 | { | ||
81 | return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit); | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset); | ||
84 | |||
85 | static int ezusb_ihex_firmware_download(struct usb_device *dev, | ||
86 | struct ezusb_fx_type fx, | ||
87 | const char *firmware_path) | ||
88 | { | ||
89 | int ret = -ENOENT; | ||
90 | const struct firmware *firmware = NULL; | ||
91 | const struct ihex_binrec *record; | ||
92 | |||
93 | if (request_ihex_firmware(&firmware, firmware_path, | ||
94 | &dev->dev)) { | ||
95 | dev_err(&dev->dev, | ||
96 | "%s - request \"%s\" failed\n", | ||
97 | __func__, firmware_path); | ||
98 | goto out; | ||
99 | } | ||
100 | |||
101 | ret = ezusb_set_reset(dev, fx.cpucs_reg, 0); | ||
102 | if (ret < 0) | ||
103 | goto out; | ||
104 | |||
105 | record = (const struct ihex_binrec *)firmware->data; | ||
106 | for (; record; record = ihex_next_binrec(record)) { | ||
107 | if (be32_to_cpu(record->addr) > fx.max_internal_adress) { | ||
108 | ret = ezusb_writememory(dev, be32_to_cpu(record->addr), | ||
109 | (unsigned char *)record->data, | ||
110 | be16_to_cpu(record->len), WRITE_EXT_RAM); | ||
111 | if (ret < 0) { | ||
112 | dev_err(&dev->dev, "%s - ezusb_writememory " | ||
113 | "failed writing internal memory " | ||
114 | "(%d %04X %p %d)\n", __func__, ret, | ||
115 | be32_to_cpu(record->addr), record->data, | ||
116 | be16_to_cpu(record->len)); | ||
117 | goto out; | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | |||
122 | ret = ezusb_set_reset(dev, fx.cpucs_reg, 1); | ||
123 | if (ret < 0) | ||
124 | goto out; | ||
125 | record = (const struct ihex_binrec *)firmware->data; | ||
126 | for (; record; record = ihex_next_binrec(record)) { | ||
127 | if (be32_to_cpu(record->addr) <= fx.max_internal_adress) { | ||
128 | ret = ezusb_writememory(dev, be32_to_cpu(record->addr), | ||
129 | (unsigned char *)record->data, | ||
130 | be16_to_cpu(record->len), WRITE_INT_RAM); | ||
131 | if (ret < 0) { | ||
132 | dev_err(&dev->dev, "%s - ezusb_writememory " | ||
133 | "failed writing external memory " | ||
134 | "(%d %04X %p %d)\n", __func__, ret, | ||
135 | be32_to_cpu(record->addr), record->data, | ||
136 | be16_to_cpu(record->len)); | ||
137 | goto out; | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | ret = ezusb_set_reset(dev, fx.cpucs_reg, 0); | ||
142 | out: | ||
143 | release_firmware(firmware); | ||
144 | return ret; | ||
145 | } | ||
146 | |||
147 | int ezusb_fx1_ihex_firmware_download(struct usb_device *dev, | ||
148 | const char *firmware_path) | ||
149 | { | ||
150 | return ezusb_ihex_firmware_download(dev, ezusb_fx1, firmware_path); | ||
151 | } | ||
152 | EXPORT_SYMBOL_GPL(ezusb_fx1_ihex_firmware_download); | ||
153 | |||
154 | int ezusb_fx2_ihex_firmware_download(struct usb_device *dev, | ||
155 | const char *firmware_path) | ||
156 | { | ||
157 | return ezusb_ihex_firmware_download(dev, ezusb_fx2, firmware_path); | ||
158 | } | ||
159 | EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download); | ||
160 | |||