aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/ft1000/Kconfig2
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c263
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.h1
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c2
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c34
5 files changed, 55 insertions, 247 deletions
diff --git a/drivers/staging/ft1000/Kconfig b/drivers/staging/ft1000/Kconfig
index d6da1304b45..c54b4e83d6e 100644
--- a/drivers/staging/ft1000/Kconfig
+++ b/drivers/staging/ft1000/Kconfig
@@ -13,7 +13,7 @@ config FT1000_USB
13 13
14config FT1000_PCMCIA 14config FT1000_PCMCIA
15 tristate "Driver for ft1000 pcmcia device." 15 tristate "Driver for ft1000 pcmcia device."
16 depends on PCMCIA && BROKEN 16 depends on PCMCIA
17 depends on NET 17 depends on NET
18 help 18 help
19 Say Y if you want to have support for Flarion card also called 19 Say Y if you want to have support for Flarion card also called
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c
index 2163eae295f..874919cf596 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.c
@@ -39,9 +39,6 @@
39#include <linux/netdevice.h> 39#include <linux/netdevice.h>
40#include <linux/etherdevice.h> 40#include <linux/etherdevice.h>
41 41
42//#include <pcmcia/version.h> // Slavius 21.10.2009 removed from kernel
43#include <pcmcia/cs_types.h>
44#include <pcmcia/cs.h>
45#include <pcmcia/cistpl.h> 42#include <pcmcia/cistpl.h>
46#include <pcmcia/cisreg.h> 43#include <pcmcia/cisreg.h>
47#include <pcmcia/ds.h> 44#include <pcmcia/ds.h>
@@ -51,8 +48,6 @@
51#include <asm/byteorder.h> 48#include <asm/byteorder.h>
52#include <asm/uaccess.h> 49#include <asm/uaccess.h>
53 50
54#include "ft1000_cs.h" // Slavius 21.10.2009 because CS_SUCCESS constant is missing due to removed pcmcia/version.h
55
56/*====================================================================*/ 51/*====================================================================*/
57 52
58/* Module parameters */ 53/* Module parameters */
@@ -82,9 +77,8 @@ MODULE_LICENSE("GPL");
82 77
83/*====================================================================*/ 78/*====================================================================*/
84 79
85struct net_device *init_ft1000_card(int, int, unsigned char *, 80struct net_device *init_ft1000_card(struct pcmcia_device *link,
86 void *ft1000_reset, struct pcmcia_device * link, 81 void *ft1000_reset);
87 struct device *fdev);
88void stop_ft1000_card(struct net_device *); 82void stop_ft1000_card(struct net_device *);
89 83
90static int ft1000_config(struct pcmcia_device *link); 84static int ft1000_config(struct pcmcia_device *link);
@@ -111,73 +105,7 @@ typedef struct local_info_t {
111 105
112static void ft1000_reset(struct pcmcia_device * link) 106static void ft1000_reset(struct pcmcia_device * link)
113{ 107{
114 conf_reg_t reg; 108 pcmcia_reset_card(link->socket);
115
116 DEBUG(0, "ft1000_cs:ft1000_reset is called................\n");
117
118 /* Soft-Reset card */
119 reg.Action = CS_WRITE;
120 reg.Offset = CISREG_COR;
121 reg.Value = COR_SOFT_RESET;
122 pcmcia_access_configuration_register(link, &reg);
123
124 /* Wait until the card has acknowledged our reset */
125 udelay(2);
126
127 /* Restore original COR configuration index */
128 /* Need at least 2 write to respond */
129 reg.Action = CS_WRITE;
130 reg.Offset = CISREG_COR;
131 reg.Value = COR_DEFAULT;
132 pcmcia_access_configuration_register(link, &reg);
133
134 /* Wait until the card has finished restarting */
135 udelay(1);
136
137 reg.Action = CS_WRITE;
138 reg.Offset = CISREG_COR;
139 reg.Value = COR_DEFAULT;
140 pcmcia_access_configuration_register(link, &reg);
141
142 /* Wait until the card has finished restarting */
143 udelay(1);
144
145 reg.Action = CS_WRITE;
146 reg.Offset = CISREG_COR;
147 reg.Value = COR_DEFAULT;
148 pcmcia_access_configuration_register(link, &reg);
149
150 /* Wait until the card has finished restarting */
151 udelay(1);
152
153}
154
155/*====================================================================*/
156
157static int get_tuple_first(struct pcmcia_device *link, tuple_t * tuple,
158 cisparse_t * parse)
159{
160 int i;
161 i = pcmcia_get_first_tuple(link, tuple);
162 if (i != CS_SUCCESS)
163 return i;
164 i = pcmcia_get_tuple_data(link, tuple);
165 if (i != CS_SUCCESS)
166 return i;
167 return pcmcia_parse_tuple(tuple, parse); // Slavius 21.10.2009 removed unused link parameter
168}
169
170static int get_tuple_next(struct pcmcia_device *link, tuple_t * tuple,
171 cisparse_t * parse)
172{
173 int i;
174 i = pcmcia_get_next_tuple(link, tuple);
175 if (i != CS_SUCCESS)
176 return i;
177 i = pcmcia_get_tuple_data(link, tuple);
178 if (i != CS_SUCCESS)
179 return i;
180 return pcmcia_parse_tuple(tuple, parse); // Slavius 21.10.2009 removed unused link parameter
181} 109}
182 110
183/*====================================================================== 111/*======================================================================
@@ -202,13 +130,10 @@ static int ft1000_attach(struct pcmcia_device *link)
202 link->priv = local; 130 link->priv = local;
203 local->dev = NULL; 131 local->dev = NULL;
204 132
205 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 133 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
206 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
207 link->conf.Attributes = CONF_ENABLE_IRQ;
208 link->conf.IntType = INT_MEMORY_AND_IO;
209 link->irq.Handler = NULL;
210 134
211 return ft1000_config(link); 135 return ft1000_config(link);
136
212} /* ft1000_attach */ 137} /* ft1000_attach */
213 138
214/*====================================================================== 139/*======================================================================
@@ -235,7 +160,7 @@ static void ft1000_detach(struct pcmcia_device *link)
235 stop_ft1000_card(dev); 160 stop_ft1000_card(dev);
236 } 161 }
237 162
238 ft1000_release(link); 163 pcmcia_disable_device(link);
239 164
240 /* This points to the parent local_info_t struct */ 165 /* This points to the parent local_info_t struct */
241 free_netdev(dev); 166 free_netdev(dev);
@@ -244,166 +169,53 @@ static void ft1000_detach(struct pcmcia_device *link)
244 169
245/*====================================================================== 170/*======================================================================
246 171
172 Check if the io window is configured
173
174======================================================================*/
175int ft1000_confcheck(struct pcmcia_device *link, void *priv_data)
176{
177
178 return pcmcia_request_io(link);
179} /* ft1000_confcheck */
180
181/*======================================================================
182
247 ft1000_config() is scheduled to run after a CARD_INSERTION event 183 ft1000_config() is scheduled to run after a CARD_INSERTION event
248 is received, to configure the PCMCIA socket, and to make the 184 is received, to configure the PCMCIA socket, and to make the
249 device available to the system. 185 device available to the system.
250 186
251======================================================================*/ 187======================================================================*/
252 188
253#define CS_CHECK(fn, ret) \ 189static int ft1000_config(struct pcmcia_device *link)
254 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
255
256#define CFG_CHECK(fn, ret) \
257 last_fn = (fn); if ((last_ret = (ret)) != 0) goto next_entry
258
259static int ft1000_config(struct pcmcia_device * link)
260{ 190{
261 tuple_t tuple; 191 int ret;
262 cisparse_t parse;
263 int last_fn, last_ret, i;
264 u_char buf[64];
265 cistpl_lan_node_id_t *node_id;
266 cistpl_cftable_entry_t dflt = { 0 };
267 cistpl_cftable_entry_t *cfg;
268 unsigned char mac_address[6];
269 192
270 DEBUG(0, "ft1000_cs: ft1000_config(0x%p)\n", link); 193 dev_dbg(&link->dev, "ft1000_cs: ft1000_config(0x%p)\n", link);
271
272 /*
273 This reads the card's CONFIG tuple to find its configuration
274 registers.
275 */
276// tuple.DesiredTuple = CISTPL_CONFIG;
277// tuple.Attributes = 0;
278 tuple.TupleData = buf;
279 tuple.TupleDataMax = sizeof(buf);
280 tuple.TupleOffset = 0;
281// CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
282// CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
283// CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
284// link->conf.ConfigBase = parse.config.base;
285// link->conf.Present = parse.config.rmask[0];
286 194
287 /* 195 /* setup IO window */
288 In this loop, we scan the CIS for configuration table entries, 196 ret = pcmcia_loop_config(link, ft1000_confcheck, NULL);
289 each of which describes a valid card configuration, including 197 if (ret) {
290 voltage, IO window, memory window, and interrupt settings. 198 printk(KERN_INFO "ft1000: Could not configure pcmcia\n");
291 199 return -ENODEV;
292 We make no assumptions about the card to be configured: we use
293 just the information available in the CIS. In an ideal world,
294 this would work for any PCMCIA card, but it requires a complete
295 and accurate CIS. In practice, a driver usually "knows" most of
296 these things without consulting the CIS, and most client drivers
297 will only use the CIS to fill in implementation-defined details.
298 */
299 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
300 tuple.Attributes = 0;
301 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
302 while (1) {
303 cfg = &(parse.cftable_entry);
304 CFG_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
305 CFG_CHECK(ParseTuple,
306 pcmcia_parse_tuple(&tuple, &parse)); // Slavius 21.10.2009 removed unused link parameter
307
308 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
309 dflt = *cfg;
310 if (cfg->index == 0)
311 goto next_entry;
312 link->conf.ConfigIndex = cfg->index;
313
314 /* Do we need to allocate an interrupt? */
315 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
316 link->conf.Attributes |= CONF_ENABLE_IRQ;
317
318 /* IO window settings */
319 link->io.NumPorts1 = link->io.NumPorts2 = 0;
320 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
321 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
322 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
323 if (!(io->flags & CISTPL_IO_8BIT)) {
324 DEBUG(0, "ft1000_cs: IO_DATA_PATH_WIDTH_16\n");
325 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
326 }
327 if (!(io->flags & CISTPL_IO_16BIT)) {
328 DEBUG(0, "ft1000_cs: IO_DATA_PATH_WIDTH_8\n");
329 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
330 }
331 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
332 link->io.BasePort1 = io->win[0].base;
333 link->io.NumPorts1 = io->win[0].len;
334 if (io->nwin > 1) {
335 link->io.Attributes2 = link->io.Attributes1;
336 link->io.BasePort2 = io->win[1].base;
337 link->io.NumPorts2 = io->win[1].len;
338 }
339 /* This reserves IO space but doesn't actually enable it */
340 pcmcia_request_io(link, &link->io);
341 }
342
343 break;
344
345 next_entry:
346 last_ret = pcmcia_get_next_tuple(link, &tuple);
347 }
348 if (last_ret != CS_SUCCESS) {
349 cs_error(link, RequestIO, last_ret);
350 goto failed;
351 } 200 }
352 201
353 /* 202 /* configure device */
354 Allocate an interrupt line. Note that this does not assign a 203 ret = pcmcia_enable_device(link);
355 handler to the interrupt, unless the 'Handler' member of the 204 if (ret) {
356 irq structure is initialized. 205 printk(KERN_INFO "ft1000: could not enable pcmcia\n");
357 */ 206 goto failed;
358 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
359
360 /*
361 This actually configures the PCMCIA socket -- setting up
362 the I/O windows and the interrupt mapping, and putting the
363 card and host interface into "Memory and IO" mode.
364 */
365 CS_CHECK(RequestConfiguration,
366 pcmcia_request_configuration(link, &link->conf));
367
368 /* Get MAC address from tuples */
369
370 tuple.Attributes = tuple.TupleOffset = 0;
371 tuple.TupleData = buf;
372 tuple.TupleDataMax = sizeof(buf);
373
374 /* Check for a LAN function extension tuple */
375 tuple.DesiredTuple = CISTPL_FUNCE;
376 i = get_tuple_first(link, &tuple, &parse);
377 while (i == CS_SUCCESS) {
378 if (parse.funce.type == CISTPL_FUNCE_LAN_NODE_ID)
379 break;
380 i = get_tuple_next(link, &tuple, &parse);
381 } 207 }
382 208
383 if (i == CS_SUCCESS) { 209 ((local_info_t *) link->priv)->dev = init_ft1000_card(link,
384 node_id = (cistpl_lan_node_id_t *) parse.funce.data; 210 &ft1000_reset);
385 if (node_id->nb == 6) { 211 if (((local_info_t *) link->priv)->dev == NULL) {
386 for (i = 0; i < 6; i++) 212 printk(KERN_INFO "ft1000: Could not register as network device\n");
387 mac_address[i] = node_id->id[i]; 213 goto failed;
388 }
389 } 214 }
390 215
391 ((local_info_t *) link->priv)->dev =
392 init_ft1000_card(link->irq.AssignedIRQ, link->io.BasePort1,
393 &mac_address[0], ft1000_reset, link,
394 &handle_to_dev(link));
395
396 /*
397 At this point, the dev_node_t structure(s) need to be
398 initialized and arranged in a linked list at link->dev.
399 */
400
401 /* Finally, report what we've done */ 216 /* Finally, report what we've done */
402 217
403 return 0; 218 return 0;
404
405cs_failed:
406 cs_error(link, last_fn, last_ret);
407failed: 219failed:
408 ft1000_release(link); 220 ft1000_release(link);
409 return -ENODEV; 221 return -ENODEV;
@@ -429,14 +241,11 @@ static void ft1000_release(struct pcmcia_device * link)
429 no one will try to access the device or its data structures. 241 no one will try to access the device or its data structures.
430 */ 242 */
431 243
432 /* Unlink the device chain */
433 link->dev_node = NULL;
434
435 /* 244 /*
436 In a normal driver, additional code may be needed to release 245 In a normal driver, additional code may be needed to release
437 other kernel data structures associated with this device. 246 other kernel data structures associated with this device.
438 */ 247 */
439 248 kfree((local_info_t *) link->priv);
440 /* Don't bother checking to see if these succeed or not */ 249 /* Don't bother checking to see if these succeed or not */
441 250
442 pcmcia_disable_device(link); 251 pcmcia_disable_device(link);
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.h b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.h
deleted file mode 100644
index 2b5e383631f..00000000000
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_cs.h
+++ /dev/null
@@ -1 +0,0 @@
1#define CS_SUCCESS 0x00
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c
index 0bf398d570d..c56f588a790 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_dnld.c
@@ -310,7 +310,7 @@ USHORT hdr_checksum(PPSEUDO_HDR pHdr)
310 return chksum; 310 return chksum;
311} 311}
312 312
313int card_download(struct net_device *dev, void *pFileStart, UINT FileLength) 313int card_download(struct net_device *dev, const u8 *pFileStart, UINT FileLength)
314{ 314{
315 FT1000_INFO *info = (PFT1000_INFO) netdev_priv(dev); 315 FT1000_INFO *info = (PFT1000_INFO) netdev_priv(dev);
316 int Status = SUCCESS; 316 int Status = SUCCESS;
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
index 588afd5a5dd..5bc6811513d 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
@@ -43,6 +43,10 @@
43#include <linux/firmware.h> 43#include <linux/firmware.h>
44#include <linux/ethtool.h> 44#include <linux/ethtool.h>
45 45
46#include <pcmcia/cistpl.h>
47#include <pcmcia/cisreg.h>
48#include <pcmcia/ds.h>
49
46#ifdef FT_DEBUG 50#ifdef FT_DEBUG
47#define DEBUG(n, args...) printk(KERN_DEBUG args); 51#define DEBUG(n, args...) printk(KERN_DEBUG args);
48#else 52#else
@@ -53,7 +57,7 @@
53#include "ft1000_dev.h" 57#include "ft1000_dev.h"
54#include "ft1000.h" 58#include "ft1000.h"
55 59
56int card_download(struct net_device *dev, void *pFileStart, UINT FileLength); 60int card_download(struct net_device *dev, const u8 *pFileStart, UINT FileLength);
57 61
58void ft1000InitProc(struct net_device *dev); 62void ft1000InitProc(struct net_device *dev);
59void ft1000CleanupProc(struct net_device *dev); 63void ft1000CleanupProc(struct net_device *dev);
@@ -2148,13 +2152,11 @@ static const struct ethtool_ops ops = {
2148 .get_link = ft1000_get_link 2152 .get_link = ft1000_get_link
2149}; 2153};
2150 2154
2151struct net_device *init_ft1000_card(unsigned short irq, int port, 2155struct net_device *init_ft1000_card(struct pcmcia_device *link,
2152 unsigned char *mac_addr, void *ft1000_reset, 2156 void *ft1000_reset)
2153 void *link, struct device *fdev)
2154{ 2157{
2155 FT1000_INFO *info; 2158 FT1000_INFO *info;
2156 struct net_device *dev; 2159 struct net_device *dev;
2157 int i;
2158 2160
2159 static const struct net_device_ops ft1000ops = // Slavius 21.10.2009 due to kernel changes 2161 static const struct net_device_ops ft1000ops = // Slavius 21.10.2009 due to kernel changes
2160 { 2162 {
@@ -2165,8 +2167,8 @@ struct net_device *init_ft1000_card(unsigned short irq, int port,
2165 }; 2167 };
2166 2168
2167 DEBUG(1, "ft1000_hw: init_ft1000_card()\n"); 2169 DEBUG(1, "ft1000_hw: init_ft1000_card()\n");
2168 DEBUG(1, "ft1000_hw: irq = %d\n", irq); 2170 DEBUG(1, "ft1000_hw: irq = %d\n", link->irq);
2169 DEBUG(1, "ft1000_hw: port = 0x%04x\n", port); 2171 DEBUG(1, "ft1000_hw: port = 0x%04x\n", link->resource[0]->start);
2170 2172
2171 flarion_ft1000_cnt++; 2173 flarion_ft1000_cnt++;
2172 2174
@@ -2184,7 +2186,7 @@ struct net_device *init_ft1000_card(unsigned short irq, int port,
2184 return NULL; 2186 return NULL;
2185 } 2187 }
2186 2188
2187 SET_NETDEV_DEV(dev, fdev); 2189 SET_NETDEV_DEV(dev, &link->dev);
2188 info = netdev_priv(dev); 2190 info = netdev_priv(dev);
2189 2191
2190 memset(info, 0, sizeof(FT1000_INFO)); 2192 memset(info, 0, sizeof(FT1000_INFO));
@@ -2227,15 +2229,13 @@ struct net_device *init_ft1000_card(unsigned short irq, int port,
2227 2229
2228 DEBUG(0, "device name = %s\n", dev->name); 2230 DEBUG(0, "device name = %s\n", dev->name);
2229 2231
2230 for (i = 0; i < 6; i++) { 2232 dev->irq = link->irq;
2231 dev->dev_addr[i] = mac_addr[i]; 2233 dev->base_addr = link->resource[0]->start;
2232 DEBUG(1, "ft1000_hw: mac_addr %d = 0x%02x\n", i, mac_addr[i]); 2234 if (pcmcia_get_mac_from_cis(link, dev)) {
2235 printk(KERN_ERR "ft1000: Could not read mac address\n");
2236 goto err_dev;
2233 } 2237 }
2234 2238
2235 netif_stop_queue(dev);
2236 dev->irq = irq;
2237 dev->base_addr = port;
2238
2239 if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) { 2239 if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
2240 printk(KERN_ERR "ft1000: Could not request_irq\n"); 2240 printk(KERN_ERR "ft1000: Could not request_irq\n");
2241 goto err_dev; 2241 goto err_dev;
@@ -2254,13 +2254,13 @@ struct net_device *init_ft1000_card(unsigned short irq, int port,
2254 info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID); 2254 info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
2255 if (info->AsicID == ELECTRABUZZ_ID) { 2255 if (info->AsicID == ELECTRABUZZ_ID) {
2256 DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n"); 2256 DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n");
2257 if (request_firmware(&fw_entry, "ft1000.img", fdev) != 0) { 2257 if (request_firmware(&fw_entry, "ft1000.img", &link->dev) != 0) {
2258 printk(KERN_INFO "ft1000: Could not open ft1000.img\n"); 2258 printk(KERN_INFO "ft1000: Could not open ft1000.img\n");
2259 goto err_unreg; 2259 goto err_unreg;
2260 } 2260 }
2261 } else { 2261 } else {
2262 DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n"); 2262 DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n");
2263 if (request_firmware(&fw_entry, "ft2000.img", fdev) != 0) { 2263 if (request_firmware(&fw_entry, "ft2000.img", &link->dev) != 0) {
2264 printk(KERN_INFO "ft1000: Could not open ft2000.img\n"); 2264 printk(KERN_INFO "ft1000: Could not open ft2000.img\n");
2265 goto err_unreg; 2265 goto err_unreg;
2266 } 2266 }