#define EMULATE_PCI_CONFIG
#endif
-#define PCI_CONFIG_BASE_ADDR 0x14000000
+#define PCI_CONFIG_BASE_ADDR 0x14000000
extern A_PCI_INIT_FUNC g_pci_init_func;
adf_drv_info_t* g_wlan_drv = NULL;
}
#define ATHEROS_VENDOR_ID 0x168c
-#define AR5416_DEVID_PCIE 0x24
+#define AR5416_DEVID_PCIE 0x24
void wlan_pci_probe(void)
{
__adf_softc_t *sc;
adf_os_resource_t drv_res = {0};
- adf_os_attach_data_t drv_data = {{0}};
+ adf_os_attach_data_t drv_data = {{0}};
int vendor_id;
int device_id;
#if MAGPIE_ENABLE_PCIE == 0
vendor_id = ATHEROS_VENDOR_ID;
device_id = AR5416_DEVID_PCIE;
-#else
+#else
vendor_id = wlan_pci_config_read(0, 2);
device_id = wlan_pci_config_read(2, 2);
-#endif
- A_PRINTF("<wlan_pci_probe>: Vendor id 0x%x Dev id 0x%x\n", vendor_id, device_id);
-
+#endif
+ A_PRINTF("<wlan_pci_probe>: Vendor id 0x%x Dev id 0x%x\n", vendor_id, device_id);
+
if (vendor_id != ATHEROS_VENDOR_ID) {
- A_PRINTF("<wlan_pci_probe>: Atheros card not found\n");
+ A_PRINTF("<wlan_pci_probe>: Atheros card not found\n");
return;
}
-
+
/**
* Allocate the sc & zero down
*/
A_PRINTF("Cannot malloc softc\n");
goto mem_fail;
}
-
-#define AR5416_DEVID_PCIE 0x24
+
+#define AR5416_DEVID_PCIE 0x24
drv_data.pci.device = AR5416_DEVID_PCIE;
drv_data.pci.vendor = 0x168c;
drv_data.pci.subvendor = 0;
drv_data.pci.subdevice = 0;
-
+
drv_res.start = (a_uint32_t) 0;
drv_res.end = 0;
drv_res.type = ADF_OS_RESOURCE_TYPE_MEM;
-
+
g_wlan_drv_handle = g_wlan_drv->drv_attach(&drv_res, 1, &drv_data, NULL);
-
+
return;
mem_fail:
- return;
+ return;
}
int wlan_pci_config_write(int offset, a_uint32_t val, int width)
{
-#if MAGPIE_ENABLE_PCIE == 1
+#if MAGPIE_ENABLE_PCIE == 1
unsigned long addr = ( PCI_CONFIG_BASE_ADDR + offset ) & 0xfffffffc;
- A_UINT8 *ptr = (A_UINT8 *)addr;
- A_UINT8 *valptr = (A_UINT8 *)&val;
+ A_UINT8 *ptr = (A_UINT8 *)addr;
+ A_UINT8 *valptr = (A_UINT8 *)&val;
int idx = offset & 0x3;
int i;
-
+
for (i = 0; i < width; i++) {
ptr[idx + i] = valptr[3-i];
- }
+ }
#endif
-
- return 0;
+
+ return 0;
}
int wlan_pci_config_read(int offset, int width)
{
-#if MAGPIE_ENABLE_PCIE == 0
- return 0;
+#if MAGPIE_ENABLE_PCIE == 0
+ return 0;
#else
unsigned long addr = ( PCI_CONFIG_BASE_ADDR + offset ) & 0xfffffffc;
unsigned long value = *((unsigned long *)addr);
- A_UINT8 *ptr = (A_UINT8 *)&value;
+ A_UINT8 *ptr = (A_UINT8 *)&value;
int idx = offset & 0x3;
int result = 0;
int i;
-
+
for (i = 0; i < width; i++) {
result |= (ptr[ 3 - (idx + i)] << (8*i));
- }
-
- return result;
-#endif
+ }
+
+ return result;
+#endif
}
void wlan_pci_isr()