ar71xx: add support for the built-in WMAC of the AR934x
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ar71xx / dev-ar934x-wmac.c
1 /*
2 * Atheros AR934x SoC built-in WMAC device support
3 *
4 * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
5 *
6 * Parts of this file are based on Atheros 2.6.31 BSP
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/delay.h>
16 #include <linux/etherdevice.h>
17 #include <linux/platform_device.h>
18 #include <linux/ath9k_platform.h>
19
20 #include <asm/mach-ar71xx/ar71xx.h>
21
22 #include "dev-ar934x-wmac.h"
23
24 static struct ath9k_platform_data ar934x_wmac_data = {
25 .led_pin = -1,
26 };
27
28 static u8 ar934x_wmac_mac[6];
29
30 static struct resource ar934x_wmac_resources[] = {
31 {
32 .start = AR934X_WMAC_BASE,
33 .end = AR934X_WMAC_BASE + AR934X_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
42 static struct platform_device ar934x_wmac_device = {
43 .name = "ath9k",
44 .id = -1,
45 .resource = ar934x_wmac_resources,
46 .num_resources = ARRAY_SIZE(ar934x_wmac_resources),
47 .dev = {
48 .platform_data = &ar934x_wmac_data,
49 },
50 };
51
52 void __init ar934x_add_device_wmac(u8 *cal_data, u8 *mac_addr)
53 {
54 if (cal_data)
55 memcpy(ar934x_wmac_data.eeprom_data, cal_data,
56 sizeof(ar934x_wmac_data.eeprom_data));
57
58 if (mac_addr) {
59 memcpy(ar934x_wmac_mac, mac_addr, sizeof(ar934x_wmac_mac));
60 ar934x_wmac_data.macaddr = ar934x_wmac_mac;
61 }
62
63 platform_device_register(&ar934x_wmac_device);
64 }