blob: 21118fb461ab12e9c9020bdc0fae3dca5d0ac272 [file] [log] [blame]
Gabor Juhosf5b35d02011-01-04 21:28:29 +01001/*
2 * Atheros AR913X SoC built-in WMAC device support
3 *
4 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12#include <linux/init.h>
13#include <linux/delay.h>
14#include <linux/irq.h>
15#include <linux/platform_device.h>
16#include <linux/ath9k_platform.h>
17
18#include <asm/mach-ath79/ath79.h>
19#include <asm/mach-ath79/ar71xx_regs.h>
20#include "dev-ar913x-wmac.h"
21
Gabor Juhos67b0f0f2011-11-18 00:17:53 +000022static struct ath9k_platform_data ath79_wmac_data;
Gabor Juhosf5b35d02011-01-04 21:28:29 +010023
Gabor Juhos67b0f0f2011-11-18 00:17:53 +000024static struct resource ath79_wmac_resources[] = {
Gabor Juhosf5b35d02011-01-04 21:28:29 +010025 {
Gabor Juhos6903bb42011-11-18 00:17:53 +000026 /* .start and .end fields are filled dynamically */
Gabor Juhosf5b35d02011-01-04 21:28:29 +010027 .flags = IORESOURCE_MEM,
28 }, {
29 .start = ATH79_CPU_IRQ_IP2,
30 .end = ATH79_CPU_IRQ_IP2,
31 .flags = IORESOURCE_IRQ,
32 },
33};
34
Gabor Juhos67b0f0f2011-11-18 00:17:53 +000035static struct platform_device ath79_wmac_device = {
Gabor Juhosf5b35d02011-01-04 21:28:29 +010036 .name = "ath9k",
37 .id = -1,
Gabor Juhos67b0f0f2011-11-18 00:17:53 +000038 .resource = ath79_wmac_resources,
39 .num_resources = ARRAY_SIZE(ath79_wmac_resources),
Gabor Juhosf5b35d02011-01-04 21:28:29 +010040 .dev = {
Gabor Juhos67b0f0f2011-11-18 00:17:53 +000041 .platform_data = &ath79_wmac_data,
Gabor Juhosf5b35d02011-01-04 21:28:29 +010042 },
43};
44
Gabor Juhos6903bb42011-11-18 00:17:53 +000045static void __init ar913x_wmac_setup(void)
Gabor Juhosf5b35d02011-01-04 21:28:29 +010046{
Gabor Juhosf5b35d02011-01-04 21:28:29 +010047 /* reset the WMAC */
48 ath79_device_reset_set(AR913X_RESET_AMBA2WMAC);
49 mdelay(10);
50
51 ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC);
52 mdelay(10);
53
Gabor Juhos6903bb42011-11-18 00:17:53 +000054 ath79_wmac_resources[0].start = AR913X_WMAC_BASE;
55 ath79_wmac_resources[0].end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1;
56}
57
58void __init ath79_register_wmac(u8 *cal_data)
59{
60 if (soc_is_ar913x())
61 ar913x_wmac_setup();
62 else
63 BUG();
64
65 if (cal_data)
66 memcpy(ath79_wmac_data.eeprom_data, cal_data,
67 sizeof(ath79_wmac_data.eeprom_data));
68
Gabor Juhos67b0f0f2011-11-18 00:17:53 +000069 platform_device_register(&ath79_wmac_device);
Gabor Juhosf5b35d02011-01-04 21:28:29 +010070}