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

« back to all changes in this revision

Viewing changes to drivers/net/bna/bfa_ioc.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:
38
38
#define bfa_ioc_map_port(__ioc) ((__ioc)->ioc_hwif->ioc_map_port(__ioc))
39
39
#define bfa_ioc_notify_fail(__ioc)                      \
40
40
                        ((__ioc)->ioc_hwif->ioc_notify_fail(__ioc))
 
41
#define bfa_ioc_sync_start(__ioc)               \
 
42
                        ((__ioc)->ioc_hwif->ioc_sync_start(__ioc))
41
43
#define bfa_ioc_sync_join(__ioc)                        \
42
44
                        ((__ioc)->ioc_hwif->ioc_sync_join(__ioc))
43
45
#define bfa_ioc_sync_leave(__ioc)                       \
80
82
static void bfa_ioc_boot(struct bfa_ioc *ioc, u32 boot_type,
81
83
                         u32 boot_param);
82
84
static u32 bfa_ioc_smem_pgnum(struct bfa_ioc *ioc, u32 fmaddr);
83
 
static u32 bfa_ioc_smem_pgoff(struct bfa_ioc *ioc, u32 fmaddr);
84
85
static void bfa_ioc_get_adapter_serial_num(struct bfa_ioc *ioc,
85
86
                                                char *serial_num);
86
87
static void bfa_ioc_get_adapter_fw_ver(struct bfa_ioc *ioc,
602
603
        switch (event) {
603
604
        case IOCPF_E_SEMLOCKED:
604
605
                if (bfa_ioc_firmware_lock(ioc)) {
605
 
                        if (bfa_ioc_sync_complete(ioc)) {
 
606
                        if (bfa_ioc_sync_start(ioc)) {
606
607
                                iocpf->retry_count = 0;
607
608
                                bfa_ioc_sync_join(ioc);
608
609
                                bfa_fsm_set_state(iocpf, bfa_iocpf_sm_hwinit);
1272
1273
void
1273
1274
bfa_nw_ioc_fwver_get(struct bfa_ioc *ioc, struct bfi_ioc_image_hdr *fwhdr)
1274
1275
{
1275
 
        u32     pgnum, pgoff;
 
1276
        u32     pgnum;
1276
1277
        u32     loff = 0;
1277
1278
        int             i;
1278
1279
        u32     *fwsig = (u32 *) fwhdr;
1279
1280
 
1280
1281
        pgnum = bfa_ioc_smem_pgnum(ioc, loff);
1281
 
        pgoff = bfa_ioc_smem_pgoff(ioc, loff);
1282
1282
        writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1283
1283
 
1284
1284
        for (i = 0; i < (sizeof(struct bfi_ioc_image_hdr) / sizeof(u32));
1314
1314
 * execution context (driver/bios) must match.
1315
1315
 */
1316
1316
static bool
1317
 
bfa_ioc_fwver_valid(struct bfa_ioc *ioc)
 
1317
bfa_ioc_fwver_valid(struct bfa_ioc *ioc, u32 boot_env)
1318
1318
{
1319
1319
        struct bfi_ioc_image_hdr fwhdr, *drv_fwhdr;
1320
1320
 
1325
1325
        if (fwhdr.signature != drv_fwhdr->signature)
1326
1326
                return false;
1327
1327
 
1328
 
        if (fwhdr.exec != drv_fwhdr->exec)
 
1328
        if (swab32(fwhdr.param) != boot_env)
1329
1329
                return false;
1330
1330
 
1331
1331
        return bfa_nw_ioc_fwver_cmp(ioc, &fwhdr);
1352
1352
{
1353
1353
        enum bfi_ioc_state ioc_fwstate;
1354
1354
        bool fwvalid;
 
1355
        u32 boot_env;
1355
1356
 
1356
1357
        ioc_fwstate = readl(ioc->ioc_regs.ioc_fwstate);
1357
1358
 
 
1359
        boot_env = BFI_BOOT_LOADER_OS;
 
1360
 
1358
1361
        if (force)
1359
1362
                ioc_fwstate = BFI_IOC_UNINIT;
1360
1363
 
1362
1365
         * check if firmware is valid
1363
1366
         */
1364
1367
        fwvalid = (ioc_fwstate == BFI_IOC_UNINIT) ?
1365
 
                false : bfa_ioc_fwver_valid(ioc);
 
1368
                false : bfa_ioc_fwver_valid(ioc, boot_env);
1366
1369
 
1367
1370
        if (!fwvalid) {
1368
 
                bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, ioc->pcidev.device_id);
 
1371
                bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, boot_env);
1369
1372
                return;
1370
1373
        }
1371
1374
 
1396
1399
        /**
1397
1400
         * Initialize the h/w for any other states.
1398
1401
         */
1399
 
        bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, ioc->pcidev.device_id);
 
1402
        bfa_ioc_boot(ioc, BFI_BOOT_TYPE_NORMAL, boot_env);
1400
1403
}
1401
1404
 
1402
1405
void
1506
1509
 */
1507
1510
static void
1508
1511
bfa_ioc_download_fw(struct bfa_ioc *ioc, u32 boot_type,
1509
 
                    u32 boot_param)
 
1512
                    u32 boot_env)
1510
1513
{
1511
1514
        u32 *fwimg;
1512
 
        u32 pgnum, pgoff;
 
1515
        u32 pgnum;
1513
1516
        u32 loff = 0;
1514
1517
        u32 chunkno = 0;
1515
1518
        u32 i;
1522
1525
        fwimg = bfa_cb_image_get_chunk(BFA_IOC_FWIMG_TYPE(ioc), chunkno);
1523
1526
 
1524
1527
        pgnum = bfa_ioc_smem_pgnum(ioc, loff);
1525
 
        pgoff = bfa_ioc_smem_pgoff(ioc, loff);
1526
1528
 
1527
1529
        writel(pgnum, ioc->ioc_regs.host_page_num_fn);
1528
1530
 
1558
1560
        /*
1559
1561
         * Set boot type and boot param at the end.
1560
1562
        */
1561
 
        writel((swab32(swab32(boot_type))), ((ioc->ioc_regs.smem_page_start)
 
1563
        writel(boot_type, ((ioc->ioc_regs.smem_page_start)
1562
1564
                        + (BFI_BOOT_TYPE_OFF)));
1563
 
        writel((swab32(swab32(boot_param))), ((ioc->ioc_regs.smem_page_start)
1564
 
                        + (BFI_BOOT_PARAM_OFF)));
 
1565
        writel(boot_env, ((ioc->ioc_regs.smem_page_start)
 
1566
                        + (BFI_BOOT_LOADER_OFF)));
1565
1567
}
1566
1568
 
1567
1569
static void
1721
1723
 * as the entry vector.
1722
1724
 */
1723
1725
static void
1724
 
bfa_ioc_boot(struct bfa_ioc *ioc, u32 boot_type, u32 boot_param)
 
1726
bfa_ioc_boot(struct bfa_ioc *ioc, u32 boot_type, u32 boot_env)
1725
1727
{
1726
1728
        void __iomem *rb;
1727
1729
 
1734
1736
         * Initialize IOC state of all functions on a chip reset.
1735
1737
         */
1736
1738
        rb = ioc->pcidev.pci_bar_kva;
1737
 
        if (boot_param == BFI_BOOT_TYPE_MEMTEST) {
 
1739
        if (boot_type == BFI_BOOT_TYPE_MEMTEST) {
1738
1740
                writel(BFI_IOC_MEMTEST, (rb + BFA_IOC0_STATE_REG));
1739
1741
                writel(BFI_IOC_MEMTEST, (rb + BFA_IOC1_STATE_REG));
1740
1742
        } else {
1743
1745
        }
1744
1746
 
1745
1747
        bfa_ioc_msgflush(ioc);
1746
 
        bfa_ioc_download_fw(ioc, boot_type, boot_param);
 
1748
        bfa_ioc_download_fw(ioc, boot_type, boot_env);
1747
1749
 
1748
1750
        /**
1749
1751
         * Enable interrupts just before starting LPU
1920
1922
        return PSS_SMEM_PGNUM(ioc->ioc_regs.smem_pg0, fmaddr);
1921
1923
}
1922
1924
 
1923
 
static u32
1924
 
bfa_ioc_smem_pgoff(struct bfa_ioc *ioc, u32 fmaddr)
1925
 
{
1926
 
        return PSS_SMEM_PGOFF(fmaddr);
1927
 
}
1928
 
 
1929
1925
/**
1930
1926
 * Register mailbox message handler function, to be called by common modules
1931
1927
 */
2219
2215
static void
2220
2216
bfa_ioc_recover(struct bfa_ioc *ioc)
2221
2217
{
2222
 
        u16 bdf;
2223
 
 
2224
 
        bdf = (ioc->pcidev.pci_slot << 8 | ioc->pcidev.pci_func << 3 |
2225
 
                                        ioc->pcidev.device_id);
2226
 
 
2227
 
        pr_crit("Firmware heartbeat failure at %d", bdf);
2228
 
        BUG_ON(1);
 
2218
        pr_crit("Heart Beat of IOC has failed\n");
 
2219
        bfa_ioc_stats(ioc, ioc_hbfails);
 
2220
        bfa_fsm_send_event(ioc, IOC_E_HBFAIL);
2229
2221
}
2230
2222
 
2231
2223
static void