Root/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ap94-pci.c

1/*
2 * Atheros AP94 reference board PCI initialization
3 *
4 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
5 *
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.
9 */
10
11#include <linux/pci.h>
12#include <linux/ath9k_platform.h>
13#include <linux/delay.h>
14
15#include <asm/mach-ar71xx/ar71xx.h>
16#include <asm/mach-ar71xx/pci.h>
17
18#include "dev-ap94-pci.h"
19#include "pci-ath9k-fixup.h"
20
21static struct ath9k_platform_data ap94_wmac0_data = {
22    .led_pin = -1,
23};
24static struct ath9k_platform_data ap94_wmac1_data = {
25    .led_pin = -1,
26};
27static char ap94_wmac0_mac[6];
28static char ap94_wmac1_mac[6];
29
30static struct ar71xx_pci_irq ap94_pci_irqs[] __initdata = {
31    {
32        .slot = 0,
33        .pin = 1,
34        .irq = AR71XX_PCI_IRQ_DEV0,
35    }, {
36        .slot = 1,
37        .pin = 1,
38        .irq = AR71XX_PCI_IRQ_DEV1,
39    }
40};
41
42static int ap94_pci_plat_dev_init(struct pci_dev *dev)
43{
44    switch (PCI_SLOT(dev->devfn)) {
45    case 17:
46        dev->dev.platform_data = &ap94_wmac0_data;
47        break;
48
49    case 18:
50        dev->dev.platform_data = &ap94_wmac1_data;
51        break;
52    }
53
54    return 0;
55}
56
57__init void ap94_pci_setup_wmac_led_pin(unsigned wmac, int pin)
58{
59    switch (wmac) {
60    case 0:
61        ap94_wmac0_data.led_pin = pin;
62        break;
63    case 1:
64        ap94_wmac1_data.led_pin = pin;
65        break;
66    }
67}
68
69__init void ap94_pci_setup_wmac_gpio(unsigned wmac, u32 mask, u32 val)
70{
71    switch (wmac) {
72    case 0:
73        ap94_wmac0_data.gpio_mask = mask;
74        ap94_wmac0_data.gpio_val = val;
75        break;
76    case 1:
77        ap94_wmac1_data.gpio_mask = mask;
78        ap94_wmac1_data.gpio_val = val;
79        break;
80    }
81}
82
83void __init ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
84              u8 *cal_data1, u8 *mac_addr1)
85{
86    if (cal_data0)
87        memcpy(ap94_wmac0_data.eeprom_data, cal_data0,
88               sizeof(ap94_wmac0_data.eeprom_data));
89
90    if (cal_data1)
91        memcpy(ap94_wmac1_data.eeprom_data, cal_data1,
92               sizeof(ap94_wmac1_data.eeprom_data));
93
94    if (mac_addr0) {
95        memcpy(ap94_wmac0_mac, mac_addr0, sizeof(ap94_wmac0_mac));
96        ap94_wmac0_data.macaddr = ap94_wmac0_mac;
97    }
98
99    if (mac_addr1) {
100        memcpy(ap94_wmac1_mac, mac_addr1, sizeof(ap94_wmac1_mac));
101        ap94_wmac1_data.macaddr = ap94_wmac1_mac;
102    }
103
104    ar71xx_pci_plat_dev_init = ap94_pci_plat_dev_init;
105    ar71xx_pci_init(ARRAY_SIZE(ap94_pci_irqs), ap94_pci_irqs);
106
107    pci_enable_ath9k_fixup(17, ap94_wmac0_data.eeprom_data);
108    pci_enable_ath9k_fixup(18, ap94_wmac1_data.eeprom_data);
109}
110

Archive Download this file



interactive