2 * Atheros AP9X reference board PCI initialization
4 * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/pci.h>
12 #include <linux/ath9k_platform.h>
13 #include <linux/delay.h>
15 #include <asm/mach-ath79/ath79.h>
16 #include <asm/mach-ath79/pci.h>
18 #include "dev-ap9x-pci.h"
19 #include "pci-ath9k-fixup.h"
22 static struct ath9k_platform_data ap9x_wmac0_data
= {
25 static struct ath9k_platform_data ap9x_wmac1_data
= {
28 static char ap9x_wmac0_mac
[6];
29 static char ap9x_wmac1_mac
[6];
31 __init
void ap9x_pci_setup_wmac_led_pin(unsigned wmac
, int pin
)
35 ap9x_wmac0_data
.led_pin
= pin
;
38 ap9x_wmac1_data
.led_pin
= pin
;
43 __init
void ap9x_pci_setup_wmac_gpio(unsigned wmac
, u32 mask
, u32 val
)
47 ap9x_wmac0_data
.gpio_mask
= mask
;
48 ap9x_wmac0_data
.gpio_val
= val
;
51 ap9x_wmac1_data
.gpio_mask
= mask
;
52 ap9x_wmac1_data
.gpio_val
= val
;
57 __init
void ap9x_pci_setup_wmac_leds(unsigned wmac
, struct gpio_led
*leds
,
62 ap9x_wmac0_data
.leds
= leds
;
63 ap9x_wmac0_data
.num_leds
= num_leds
;
66 ap9x_wmac1_data
.leds
= leds
;
67 ap9x_wmac1_data
.num_leds
= num_leds
;
72 static int ap91_pci_plat_dev_init(struct pci_dev
*dev
)
74 switch (PCI_SLOT(dev
->devfn
)) {
76 dev
->dev
.platform_data
= &ap9x_wmac0_data
;
83 __init
void ap91_pci_init(u8
*cal_data
, u8
*mac_addr
)
86 memcpy(ap9x_wmac0_data
.eeprom_data
, cal_data
,
87 sizeof(ap9x_wmac0_data
.eeprom_data
));
90 memcpy(ap9x_wmac0_mac
, mac_addr
, sizeof(ap9x_wmac0_mac
));
91 ap9x_wmac0_data
.macaddr
= ap9x_wmac0_mac
;
94 ath79_pci_set_plat_dev_init(ap91_pci_plat_dev_init
);
97 pci_enable_ath9k_fixup(0, ap9x_wmac0_data
.eeprom_data
);
100 static int ap94_pci_plat_dev_init(struct pci_dev
*dev
)
102 switch (PCI_SLOT(dev
->devfn
)) {
104 dev
->dev
.platform_data
= &ap9x_wmac0_data
;
108 dev
->dev
.platform_data
= &ap9x_wmac1_data
;
115 __init
void ap94_pci_init(u8
*cal_data0
, u8
*mac_addr0
,
116 u8
*cal_data1
, u8
*mac_addr1
)
119 memcpy(ap9x_wmac0_data
.eeprom_data
, cal_data0
,
120 sizeof(ap9x_wmac0_data
.eeprom_data
));
123 memcpy(ap9x_wmac1_data
.eeprom_data
, cal_data1
,
124 sizeof(ap9x_wmac1_data
.eeprom_data
));
127 memcpy(ap9x_wmac0_mac
, mac_addr0
, sizeof(ap9x_wmac0_mac
));
128 ap9x_wmac0_data
.macaddr
= ap9x_wmac0_mac
;
132 memcpy(ap9x_wmac1_mac
, mac_addr1
, sizeof(ap9x_wmac1_mac
));
133 ap9x_wmac1_data
.macaddr
= ap9x_wmac1_mac
;
136 ath79_pci_set_plat_dev_init(ap94_pci_plat_dev_init
);
137 ath79_register_pci();
139 pci_enable_ath9k_fixup(17, ap9x_wmac0_data
.eeprom_data
);
140 pci_enable_ath9k_fixup(18, ap9x_wmac1_data
.eeprom_data
);