iPXE
Functions | Variables
ath9k.c File Reference
#include <ipxe/pci.h>
#include "ath9k.h"

Go to the source code of this file.

Functions

static void ath_pci_read_cachesize (struct ath_common *common, int *csz)
static int ath_pci_eeprom_read (struct ath_common *common, u32 off, u16 *data)
static void ath_pci_extn_synch_enable (struct ath_common *common)
static int ath_pci_probe (struct pci_device *pdev)
static void ath_pci_remove (struct pci_device *pdev)

Variables

static struct pci_device_id ath_pci_id_table []
static struct ath_bus_ops ath_pci_bus_ops
struct pci_driver ath_pci_driver __pci_driver

Function Documentation

static void ath_pci_read_cachesize ( struct ath_common common,
int *  csz 
) [static]

Definition at line 40 of file ath9k.c.

References DEFAULT_CACHELINE, PCI_CACHE_LINE_SIZE, pci_read_config_byte(), ath_softc::pdev, and ath_common::priv.

{
        struct ath_softc *sc = (struct ath_softc *) common->priv;
        u8 u8tmp;

        pci_read_config_byte(sc->pdev, PCI_CACHE_LINE_SIZE, &u8tmp);
        *csz = (int)u8tmp;

        /*
         * This check was put in to avoid "unpleasant" consequences if
         * the bootrom has not fully initialized all PCI devices.
         * Sometimes the cache line size register is not set
         */

        if (*csz == 0)
                *csz = DEFAULT_CACHELINE >> 2;   /* Use the default size */
}
static int ath_pci_eeprom_read ( struct ath_common common,
u32  off,
u16 data 
) [static]
static void ath_pci_extn_synch_enable ( struct ath_common common) [static]
static int ath_pci_probe ( struct pci_device pdev) [static]

Definition at line 97 of file ath9k.c.

References adjust_pci_device(), ath9k_hw_name(), ath9k_init_device(), DBG, net_device::dev, ath_softc::dev, pci_device::device, EIO, ENOMEM, ioremap(), iounmap(), pci_device::irq, ath_softc::irq, ath_softc::mem, pci_device::membase, net80211_alloc(), net80211_free(), net80211_device::netdev, PCI_CACHE_LINE_SIZE, PCI_LATENCY_TIMER, pci_read_config_byte(), pci_read_config_dword(), pci_read_config_word(), pci_set_drvdata(), PCI_SUBSYSTEM_ID, pci_write_config_byte(), pci_write_config_dword(), ath_softc::pdev, net80211_device::priv, ret, ath_softc::sc_ah, ath_softc::sc_flags, SC_OP_INVALID, and val.

{
        void *mem;
        struct ath_softc *sc;
        struct net80211_device *dev;
        u8 csz;
        u16 subsysid;
        u32 val;
        int ret = 0;
        char hw_name[64];

        adjust_pci_device(pdev);

        /*
         * Cache line size is used to size and align various
         * structures used to communicate with the hardware.
         */
        pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &csz);
        if (csz == 0) {
                /*
                 * Linux 2.4.18 (at least) writes the cache line size
                 * register as a 16-bit wide register which is wrong.
                 * We must have this setup properly for rx buffer
                 * DMA to work so force a reasonable value here if it
                 * comes up zero.
                 */
                csz =16;
                pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, csz);
        }
        /*
         * The default setting of latency timer yields poor results,
         * set it to the value used by other systems. It may be worth
         * tweaking this setting more.
         */
        pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xa8);

        /*
         * Disable the RETRY_TIMEOUT register (0x41) to keep
         * PCI Tx retries from interfering with C3 CPU state.
         */
        pci_read_config_dword(pdev, 0x40, &val);
        if ((val & 0x0000ff00) != 0)
                pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);

        mem = ioremap(pdev->membase, 0x10000);
        if (!mem) {
                DBG("ath9K: PCI memory map error\n") ;
                ret = -EIO;
                goto err_iomap;
        }

        dev = net80211_alloc(sizeof(struct ath_softc));
        if (!dev) {
                DBG("ath9k: No memory for net80211_device\n");
                ret = -ENOMEM;
                goto err_alloc_hw;
        }

        pci_set_drvdata(pdev, dev);
        dev->netdev->dev = (struct device *)pdev;

        sc = dev->priv;
        sc->dev = dev;
        sc->pdev = pdev;
        sc->mem = mem;

        /* Will be cleared in ath9k_start() */
        sc->sc_flags |= SC_OP_INVALID;

        sc->irq = pdev->irq;

        pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsysid);
        ret = ath9k_init_device(pdev->device, sc, subsysid, &ath_pci_bus_ops);
        if (ret) {
                DBG("ath9k: Failed to initialize device\n");
                goto err_init;
        }

        ath9k_hw_name(sc->sc_ah, hw_name, sizeof(hw_name));
        DBG("ath9k: %s mem=0x%lx, irq=%d\n",
                   hw_name, (unsigned long)mem, pdev->irq);

        return 0;

err_init:
        net80211_free(dev);
err_alloc_hw:
        iounmap(mem);
err_iomap:
        return ret;
}
static void ath_pci_remove ( struct pci_device pdev) [static]

Variable Documentation

struct pci_device_id ath_pci_id_table[] [static]
Initial value:
 {
        PCI_ROM(0x168c, 0x0023, "ar5416", "Atheros 5416 PCI", 0),       
        PCI_ROM(0x168c, 0x0024, "ar5416", "Atheros 5416 PCI-E", 0),     
        PCI_ROM(0x168c, 0x0027, "ar9160", "Atheros 9160 PCI", 0),       
        PCI_ROM(0x168c, 0x0029, "ar9280", "Atheros 9280 PCI", 0),       
        PCI_ROM(0x168c, 0x002A, "ar9280", "Atheros 9280 PCI-E", 0),     
        PCI_ROM(0x168c, 0x002B, "ar9285", "Atheros 9285 PCI-E", 0),     
        PCI_ROM(0x168c, 0x002C, "ar2427", "Atheros 2427 PCI-E", 0),     
        PCI_ROM(0x168c, 0x002D, "ar9287", "Atheros 9287 PCI", 0),       
        PCI_ROM(0x168c, 0x002E, "ar9287", "Atheros 9287 PCI-E", 0),     
        PCI_ROM(0x168c, 0x0030, "ar9300", "Atheros 9300 PCI-E", 0),     
        PCI_ROM(0x168c, 0x0032, "ar9485", "Atheros 9485 PCI-E", 0),     
}

Definition at line 24 of file ath9k.c.

struct ath_bus_ops ath_pci_bus_ops [static]
Initial value:
 {
        .ath_bus_type = ATH_PCI,
        .read_cachesize = ath_pci_read_cachesize,
        .eeprom_read = ath_pci_eeprom_read,
        .extn_synch_en = ath_pci_extn_synch_enable,
}

Definition at line 90 of file ath9k.c.

struct pci_driver ath_pci_driver __pci_driver
Initial value:
 {
        .id_count   = ARRAY_SIZE(ath_pci_id_table),
        .ids        = ath_pci_id_table,
        .probe      = ath_pci_probe,
        .remove     = ath_pci_remove,
}

Definition at line 203 of file ath9k.c.