2 * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
3 * Copyright (c) 2004 Atheros Communications, Inc.
4 * Copyright (c) 2013 Qualcomm Atheros, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted (subject to the limitations in the
10 * disclaimer below) provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
20 * * Neither the name of Qualcomm Atheros nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * Alternatively, this software may be distributed under the terms of the
25 * GNU General Public License ("GPL") version 2 as published by the Free
26 * Software Foundation.
28 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
29 * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
30 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
37 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
39 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
40 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47 #include <adf_os_types.h>
48 #include <adf_os_dma.h>
49 #include <adf_os_pci.h>
50 #include <adf_os_timer.h>
51 #include <adf_os_lock.h>
52 #include <adf_os_io.h>
53 #include <adf_os_mem.h>
54 #include <adf_os_module.h>
55 #include <adf_os_util.h>
56 #include <adf_os_stdtypes.h>
57 #include <adf_os_defer.h>
58 #include <adf_os_atomic.h>
61 #include <adf_os_irq.h>
63 #include <adf_net_wcmd.h>
65 #include <ieee80211_var.h>
66 #include "if_athvar.h"
67 #include "if_ath_pci.h"
69 extern a_int32_t ath_tgt_attach(a_uint32_t devid, struct ath_softc_tgt *sc, adf_os_device_t osdev);
70 extern a_int32_t ath_detach(void *);
71 extern adf_os_irq_resp_t ath_intr(adf_drv_handle_t hdl);
73 struct ath_pci_softc {
74 struct ath_softc_tgt aps_sc;
81 * User a static table of PCI id's for now. While this is the
82 * "new way" to do things, we may want to switch back to having
83 * the HAL check them by defining a probe method.
85 #ifdef ATH_SUPPORT_XB_ONLY
86 static adf_os_pci_dev_id_t ath_pci_id_table[] = {
87 { 0x168c, 0x0024, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* PCI-E (XB) */
92 static adf_os_pci_dev_id_t ath_pci_id_table[] = {
93 { 0x168c, 0x0007, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
94 { 0x168c, 0x0012, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
95 { 0x168c, 0x0013, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
96 { 0xa727, 0x0013, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* 3com */
97 { 0x10b7, 0x0013, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* 3com 3CRDAG675 */
98 { 0x168c, 0x1014, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* IBM minipci 5212 */
99 { 0x168c, 0x101a, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* some Griffin-Lite */
100 { 0x168c, 0x0015, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
101 { 0x168c, 0x0016, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
102 { 0x168c, 0x0017, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
103 { 0x168c, 0x0018, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
104 { 0x168c, 0x0019, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
105 { 0x168c, 0x001a, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
106 { 0x168c, 0x001b, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
107 { 0x168c, 0x001c, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
108 { 0x168c, 0x001d, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID },
109 { 0x168c, 0xff1d, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* owl emulation */
110 { 0x168c, 0xff1c, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* owl emulation */
111 { 0x168c, 0x0023, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* PCI (MB/CB) */
112 { 0x168c, 0x0024, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* PCI-E (XB) */
113 { 0x168c, 0x0027, ADF_OS_PCI_ANY_ID, ADF_OS_PCI_ANY_ID }, /* Sowl PCI */
118 void exit_ath_pci(void);
119 a_int32_t init_ath_pci(void);
121 static adf_drv_handle_t
122 ath_pci_probe(adf_os_resource_t *res,a_int32_t count, adf_os_attach_data_t *data,
123 adf_os_device_t osdev)
125 struct ath_pci_softc *sc;
127 adf_os_pci_dev_id_t *id = (adf_os_pci_dev_id_t *)data;
129 adf_os_pci_config_write8(osdev, ATH_PCI_CACHE_LINE_SIZE, csz);
130 adf_os_pci_config_write8(osdev, ATH_PCI_LATENCY_TIMER, 0xa8);
132 sc = adf_os_mem_alloc(sizeof(struct ath_pci_softc));
135 adf_os_print("ath_pci: no memory for device state\n");
138 adf_os_mem_set(sc, 0, sizeof(struct ath_pci_softc));
141 * Mark the device as detached to avoid processing
142 * interrupts until setup is complete.
144 sc->aps_sc.sc_invalid = 1;
146 adf_os_print("ath_pci_probe %x\n",id->device);
148 if (ath_tgt_attach(id->device, &sc->aps_sc, osdev) != 0)
151 /* ready to process interrupts */
152 sc->aps_sc.sc_invalid = 0;
153 adf_os_setup_intr(osdev, ath_intr);
154 return (adf_drv_handle_t)sc;
161 ath_pci_remove(adf_drv_handle_t hdl)
163 struct ath_softc_tgt *sc = hdl;
165 ath_detach((struct ath_softc_tgt *)hdl);
166 adf_os_free_intr(sc->sc_dev);
170 ath_pci_suspend(adf_drv_handle_t hdl, adf_os_pm_t pm)
175 ath_pci_resume(adf_drv_handle_t hdl)
179 static adf_drv_info_t ath_drv_info = adf_os_pci_set_drv_info(ath_pci_tgt,&ath_pci_id_table[0], ath_pci_probe, ath_pci_remove, ath_pci_suspend, ath_pci_resume);
184 return adf_net_register_drv( &ath_drv_info );
190 adf_net_unregister_drv("ath_pci");
193 adf_os_pci_module_init(init_ath_pci);
194 adf_os_pci_module_exit(exit_ath_pci);
195 adf_os_module_dep(ath_pci_tgt, adf_net);
196 adf_os_module_dep(ath_pci_tgt, hal);
197 adf_os_module_dep(ath_pci_tgt, ath_pci);
198 adf_os_module_dep(ath_pci_tgt, wlan_tgt);
199 adf_os_module_dep(ath_pci_tgt, htc_tgt);
200 adf_os_module_dep(ath_pci_tgt, inproc_hif);