Root/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ar913x-wmac.c

1/*
2 * Atheros AR913x SoC built-in WMAC device support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * Parts of this file are based on Atheros' 2.6.15 BSP
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/etherdevice.h>
18#include <linux/platform_device.h>
19#include <linux/ath9k_platform.h>
20
21#include <asm/mach-ar71xx/ar71xx.h>
22
23#include "dev-ar913x-wmac.h"
24
25static struct ath9k_platform_data ar913x_wmac_data = {
26    .led_pin = -1,
27};
28static char ar913x_wmac_mac[6];
29
30static struct resource ar913x_wmac_resources[] = {
31    {
32        .start = AR91XX_WMAC_BASE,
33        .end = AR91XX_WMAC_BASE + AR91XX_WMAC_SIZE - 1,
34        .flags = IORESOURCE_MEM,
35    }, {
36        .start = AR71XX_CPU_IRQ_IP2,
37        .end = AR71XX_CPU_IRQ_IP2,
38        .flags = IORESOURCE_IRQ,
39    },
40};
41
42static struct platform_device ar913x_wmac_device = {
43    .name = "ath9k",
44    .id = -1,
45    .resource = ar913x_wmac_resources,
46    .num_resources = ARRAY_SIZE(ar913x_wmac_resources),
47    .dev = {
48        .platform_data = &ar913x_wmac_data,
49    },
50};
51
52void __init ar913x_add_device_wmac(u8 *cal_data, u8 *mac_addr)
53{
54    if (cal_data)
55        memcpy(ar913x_wmac_data.eeprom_data, cal_data,
56               sizeof(ar913x_wmac_data.eeprom_data));
57
58    if (mac_addr) {
59        memcpy(ar913x_wmac_mac, mac_addr, sizeof(ar913x_wmac_mac));
60        ar913x_wmac_data.macaddr = ar913x_wmac_mac;
61    }
62
63    ar71xx_device_stop(RESET_MODULE_AMBA2WMAC);
64    mdelay(10);
65
66    ar71xx_device_start(RESET_MODULE_AMBA2WMAC);
67    mdelay(10);
68
69    platform_device_register(&ar913x_wmac_device);
70}
71

Archive Download this file



interactive