342f8de28eb191664705752b0ec6b7d6752da25e
[openwrt/staging/yousong.git] / 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
25 static struct resource ar913x_wmac_resources[] = {
26 {
27 .start = AR91XX_WMAC_BASE,
28 .end = AR91XX_WMAC_BASE + AR91XX_WMAC_SIZE - 1,
29 .flags = IORESOURCE_MEM,
30 }, {
31 .start = AR71XX_CPU_IRQ_WMAC,
32 .end = AR71XX_CPU_IRQ_WMAC,
33 .flags = IORESOURCE_IRQ,
34 },
35 };
36
37 static struct ath9k_platform_data ar913x_wmac_data;
38
39 static struct platform_device ar913x_wmac_device = {
40 .name = "ath9k",
41 .id = -1,
42 .resource = ar913x_wmac_resources,
43 .num_resources = ARRAY_SIZE(ar913x_wmac_resources),
44 .dev = {
45 .platform_data = &ar913x_wmac_data,
46 },
47 };
48
49 void __init ar913x_add_device_wmac(void)
50 {
51 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
52
53 memcpy(ar913x_wmac_data.eeprom_data, ee,
54 sizeof(ar913x_wmac_data.eeprom_data));
55
56 ar71xx_device_stop(RESET_MODULE_AMBA2WMAC);
57 mdelay(10);
58
59 ar71xx_device_start(RESET_MODULE_AMBA2WMAC);
60 mdelay(10);
61
62 platform_device_register(&ar913x_wmac_device);
63 }