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;
26static char ar913x_wmac_mac[6];
27
28static struct resource ar913x_wmac_resources[] = {
29    {
30        .start = AR91XX_WMAC_BASE,
31        .end = AR91XX_WMAC_BASE + AR91XX_WMAC_SIZE - 1,
32        .flags = IORESOURCE_MEM,
33    }, {
34        .start = AR71XX_CPU_IRQ_IP2,
35        .end = AR71XX_CPU_IRQ_IP2,
36        .flags = IORESOURCE_IRQ,
37    },
38};
39
40static struct platform_device ar913x_wmac_device = {
41    .name = "ath9k",
42    .id = -1,
43    .resource = ar913x_wmac_resources,
44    .num_resources = ARRAY_SIZE(ar913x_wmac_resources),
45    .dev = {
46        .platform_data = &ar913x_wmac_data,
47    },
48};
49
50void __init ar913x_add_device_wmac(u8 *cal_data, u8 *mac_addr)
51{
52    if (cal_data)
53        memcpy(ar913x_wmac_data.eeprom_data, cal_data,
54               sizeof(ar913x_wmac_data.eeprom_data));
55
56    if (mac_addr) {
57        memcpy(ar913x_wmac_mac, mac_addr, sizeof(ar913x_wmac_mac));
58        ar913x_wmac_data.macaddr = ar913x_wmac_mac;
59    }
60
61    ar71xx_device_stop(RESET_MODULE_AMBA2WMAC);
62    mdelay(10);
63
64    ar71xx_device_start(RESET_MODULE_AMBA2WMAC);
65    mdelay(10);
66
67    platform_device_register(&ar913x_wmac_device);
68}
69

Archive Download this file



interactive