~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include <linux/firmware.h>
44
44
#include <linux/ethtool.h>
45
45
 
 
46
#include <pcmcia/cistpl.h>
 
47
#include <pcmcia/cisreg.h>
 
48
#include <pcmcia/ds.h>
 
49
 
46
50
#ifdef FT_DEBUG
47
51
#define DEBUG(n, args...) printk(KERN_DEBUG args);
48
52
#else
53
57
#include "ft1000_dev.h"
54
58
#include "ft1000.h"
55
59
 
56
 
int card_download(struct net_device *dev, void *pFileStart, UINT FileLength);
 
60
int card_download(struct net_device *dev, const u8 *pFileStart, UINT FileLength);
57
61
 
58
62
void ft1000InitProc(struct net_device *dev);
59
63
void ft1000CleanupProc(struct net_device *dev);
86
90
//---------------------------------------------------------------------------
87
91
//
88
92
// Function:   ft1000_asic_read
89
 
// Descripton: This function will retrieve the value of a specific ASIC
 
93
// Description: This function will retrieve the value of a specific ASIC
90
94
//             register.
91
95
// Input:
92
96
//    dev - network device structure
103
107
//---------------------------------------------------------------------------
104
108
//
105
109
// Function:   ft1000_asic_write
106
 
// Descripton: This function will set the value of a specific ASIC
 
110
// Description: This function will set the value of a specific ASIC
107
111
//             register.
108
112
// Input:
109
113
//    dev - network device structure
120
124
//---------------------------------------------------------------------------
121
125
//
122
126
// Function:   ft1000_read_fifo_len
123
 
// Descripton: This function will read the ASIC Uplink FIFO status register
 
127
// Description: This function will read the ASIC Uplink FIFO status register
124
128
//             which will return the number of bytes remaining in the Uplink FIFO.
125
129
//             Sixteen bytes are subtracted to make sure that the ASIC does not
126
130
//             reach its threshold.
144
148
//---------------------------------------------------------------------------
145
149
//
146
150
// Function:   ft1000_read_dpram
147
 
// Descripton: This function will read the specific area of dpram
 
151
// Description: This function will read the specific area of dpram
148
152
//             (Electrabuzz ASIC only)
149
153
// Input:
150
154
//     dev    - device structure
171
175
//---------------------------------------------------------------------------
172
176
//
173
177
// Function:   ft1000_write_dpram
174
 
// Descripton: This function will write to a specific area of dpram
 
178
// Description: This function will write to a specific area of dpram
175
179
//             (Electrabuzz ASIC only)
176
180
// Input:
177
181
//     dev    - device structure
197
201
//---------------------------------------------------------------------------
198
202
//
199
203
// Function:   ft1000_read_dpram_mag_16
200
 
// Descripton: This function will read the specific area of dpram
 
204
// Description: This function will read the specific area of dpram
201
205
//             (Magnemite ASIC only)
202
206
// Input:
203
207
//     dev    - device structure
229
233
//---------------------------------------------------------------------------
230
234
//
231
235
// Function:   ft1000_write_dpram_mag_16
232
 
// Descripton: This function will write to a specific area of dpram
 
236
// Description: This function will write to a specific area of dpram
233
237
//             (Magnemite ASIC only)
234
238
// Input:
235
239
//     dev    - device structure
259
263
//---------------------------------------------------------------------------
260
264
//
261
265
// Function:   ft1000_read_dpram_mag_32
262
 
// Descripton: This function will read the specific area of dpram
 
266
// Description: This function will read the specific area of dpram
263
267
//             (Magnemite ASIC only)
264
268
// Input:
265
269
//     dev    - device structure
286
290
//---------------------------------------------------------------------------
287
291
//
288
292
// Function:   ft1000_write_dpram_mag_32
289
 
// Descripton: This function will write to a specific area of dpram
 
293
// Description: This function will write to a specific area of dpram
290
294
//             (Magnemite ASIC only)
291
295
// Input:
292
296
//     dev    - device structure
311
315
//---------------------------------------------------------------------------
312
316
//
313
317
// Function:   ft1000_enable_interrupts
314
 
// Descripton: This function will enable interrupts base on the current interrupt mask.
 
318
// Description: This function will enable interrupts base on the current interrupt mask.
315
319
// Input:
316
320
//     dev    - device structure
317
321
// Output:
336
340
//---------------------------------------------------------------------------
337
341
//
338
342
// Function:   ft1000_disable_interrupts
339
 
// Descripton: This function will disable all interrupts.
 
343
// Description: This function will disable all interrupts.
340
344
// Input:
341
345
//     dev    - device structure
342
346
// Output:
360
364
//---------------------------------------------------------------------------
361
365
//
362
366
// Function:   ft1000_reset_asic
363
 
// Descripton: This function will call the Card Service function to reset the
 
367
// Description: This function will call the Card Service function to reset the
364
368
//             ASIC.
365
369
// Input:
366
370
//     dev    - device structure
404
408
//---------------------------------------------------------------------------
405
409
//
406
410
// Function:   ft1000_reset_card
407
 
// Descripton: This function will reset the card
 
411
// Description: This function will reset the card
408
412
// Input:
409
413
//     dev    - device structure
410
414
// Output:
567
571
//---------------------------------------------------------------------------
568
572
//
569
573
// Function:   ft1000_chkcard
570
 
// Descripton: This function will check if the device is presently available on
 
574
// Description: This function will check if the device is presently available on
571
575
//             the system.
572
576
// Input:
573
577
//     dev    - device structure
603
607
//---------------------------------------------------------------------------
604
608
//
605
609
// Function:   ft1000_hbchk
606
 
// Descripton: This function will perform the heart beat check of the DSP as
 
610
// Description: This function will perform the heart beat check of the DSP as
607
611
//             well as the ASIC.
608
612
// Input:
609
613
//     dev    - device structure
824
828
//---------------------------------------------------------------------------
825
829
//
826
830
// Function:   ft1000_send_cmd
827
 
// Descripton:
 
831
// Description:
828
832
// Input:
829
833
// Output:
830
834
//
904
908
//---------------------------------------------------------------------------
905
909
//
906
910
// Function:   ft1000_receive_cmd
907
 
// Descripton: This function will read a message from the dpram area.
 
911
// Description: This function will read a message from the dpram area.
908
912
// Input:
909
913
//    dev - network device structure
910
914
//    pbuffer - caller supply address to buffer
999
1003
//---------------------------------------------------------------------------
1000
1004
//
1001
1005
// Function:   ft1000_proc_drvmsg
1002
 
// Descripton: This function will process the various driver messages.
 
1006
// Description: This function will process the various driver messages.
1003
1007
// Input:
1004
1008
//     dev    - device structure
1005
1009
//     pnxtph - pointer to next pseudo header
1281
1285
//---------------------------------------------------------------------------
1282
1286
//
1283
1287
// Function:   ft1000_parse_dpram_msg
1284
 
// Descripton: This function will parse the message received from the DSP
 
1288
// Description: This function will parse the message received from the DSP
1285
1289
//             via the DPRAM interface.
1286
1290
// Input:
1287
1291
//     dev    - device structure
1438
1442
//---------------------------------------------------------------------------
1439
1443
//
1440
1444
// Function:   ft1000_flush_fifo
1441
 
// Descripton: This function will flush one packet from the downlink
 
1445
// Description: This function will flush one packet from the downlink
1442
1446
//             FIFO.
1443
1447
// Input:
1444
1448
//     dev      - device structure
1583
1587
//---------------------------------------------------------------------------
1584
1588
//
1585
1589
// Function:   ft1000_copy_up_pkt
1586
 
// Descripton: This function will pull Flarion packets out of the Downlink
 
1590
// Description: This function will pull Flarion packets out of the Downlink
1587
1591
//             FIFO and convert it to an ethernet packet.  The ethernet packet will
1588
1592
//             then be deliver to the TCP/IP stack.
1589
1593
// Input:
1769
1773
//---------------------------------------------------------------------------
1770
1774
//
1771
1775
// Function:   ft1000_copy_down_pkt
1772
 
// Descripton: This function will take an ethernet packet and convert it to
 
1776
// Description: This function will take an ethernet packet and convert it to
1773
1777
//             a Flarion packet prior to sending it to the ASIC Downlink
1774
1778
//             FIFO.
1775
1779
// Input:
1936
1940
        }
1937
1941
 
1938
1942
        info->stats.tx_packets++;
1939
 
        // Add 14 bytes for MAC adddress plus ethernet type
 
1943
        // Add 14 bytes for MAC address plus ethernet type
1940
1944
        info->stats.tx_bytes += (len + 14);
1941
1945
        return SUCCESS;
1942
1946
}
2148
2152
        .get_link = ft1000_get_link
2149
2153
};
2150
2154
 
2151
 
struct net_device *init_ft1000_card(unsigned short irq, int port,
2152
 
                                        unsigned char *mac_addr, void *ft1000_reset,
2153
 
                                        void *link, struct device *fdev)
 
2155
struct net_device *init_ft1000_card(struct pcmcia_device *link,
 
2156
                                        void *ft1000_reset)
2154
2157
{
2155
2158
        FT1000_INFO *info;
2156
2159
        struct net_device *dev;
2157
 
        int i;
2158
2160
 
2159
2161
        static const struct net_device_ops ft1000ops =          // Slavius 21.10.2009 due to kernel changes
2160
2162
        {
2165
2167
        };
2166
2168
 
2167
2169
        DEBUG(1, "ft1000_hw: init_ft1000_card()\n");
2168
 
        DEBUG(1, "ft1000_hw: irq = %d\n", irq);
2169
 
        DEBUG(1, "ft1000_hw: port = 0x%04x\n", port);
 
2170
        DEBUG(1, "ft1000_hw: irq = %d\n", link->irq);
 
2171
        DEBUG(1, "ft1000_hw: port = 0x%04x\n", link->resource[0]->start);
2170
2172
 
2171
2173
        flarion_ft1000_cnt++;
2172
2174
 
2184
2186
                return NULL;
2185
2187
        }
2186
2188
 
2187
 
        SET_NETDEV_DEV(dev, fdev);
 
2189
        SET_NETDEV_DEV(dev, &link->dev);
2188
2190
        info = netdev_priv(dev);
2189
2191
 
2190
2192
        memset(info, 0, sizeof(FT1000_INFO));
2227
2229
 
2228
2230
        DEBUG(0, "device name = %s\n", dev->name);
2229
2231
 
2230
 
        for (i = 0; i < 6; i++) {
2231
 
                dev->dev_addr[i] = mac_addr[i];
2232
 
                DEBUG(1, "ft1000_hw: mac_addr %d = 0x%02x\n", i, mac_addr[i]);
 
2232
        dev->irq = link->irq;
 
2233
        dev->base_addr = link->resource[0]->start;
 
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
2239
        if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
2240
2240
                printk(KERN_ERR "ft1000: Could not request_irq\n");
2241
2241
                goto err_dev;
2254
2254
        info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
2255
2255
        if (info->AsicID == ELECTRABUZZ_ID) {
2256
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
2258
                        printk(KERN_INFO "ft1000: Could not open ft1000.img\n");
2259
2259
                        goto err_unreg;
2260
2260
                }
2261
2261
        } else {
2262
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
2264
                        printk(KERN_INFO "ft1000: Could not open ft2000.img\n");
2265
2265
                        goto err_unreg;
2266
2266
                }
2288
2288
        free_netdev(dev);
2289
2289
        return NULL;
2290
2290
}
2291
 
 
2292
 
EXPORT_SYMBOL(init_ft1000_card);
2293
 
EXPORT_SYMBOL(stop_ft1000_card);
2294
 
EXPORT_SYMBOL(flarion_ft1000_cnt);