source: trunk/target/linux/ar71xx/files/arch/mips/ar71xx/dev-ar9xxx-wmac.c @ 26595

Last change on this file since 26595 was 26595, checked in by juhosg, 6 years ago

ar71xx: merge dev-ar9{13,34}x-wmac into dev-ar9xxx-wmac

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1/*
2 *  Atheros AR9XXX SoCs built-in WMAC device support
3 *
4 *  Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
5 *  Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
6 *  Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 *
8 *  Parts of this file are based on Atheros 2.6.15/2.6.31 BSP
9 *
10 *  This program is free software; you can redistribute it and/or modify it
11 *  under the terms of the GNU General Public License version 2 as published
12 *  by the Free Software Foundation.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/etherdevice.h>
19#include <linux/platform_device.h>
20#include <linux/ath9k_platform.h>
21
22#include <asm/mach-ar71xx/ar71xx.h>
23
24#include "dev-ar9xxx-wmac.h"
25
26static struct ath9k_platform_data ar9xxx_wmac_data = {
27        .led_pin = -1,
28};
29static char ar9xxx_wmac_mac[6];
30
31static struct resource ar9xxx_wmac_resources[] = {
32        {
33                /* .start and .end fields are filled dynamically */
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 ar9xxx_wmac_device = {
43        .name           = "ath9k",
44        .id             = -1,
45        .resource       = ar9xxx_wmac_resources,
46        .num_resources  = ARRAY_SIZE(ar9xxx_wmac_resources),
47        .dev = {
48                .platform_data = &ar9xxx_wmac_data,
49        },
50};
51
52static void ar913x_wmac_init(void)
53{
54        ar71xx_device_stop(RESET_MODULE_AMBA2WMAC);
55        mdelay(10);
56
57        ar71xx_device_start(RESET_MODULE_AMBA2WMAC);
58        mdelay(10);
59
60        ar9xxx_wmac_resources[0].start = AR91XX_WMAC_BASE;
61        ar9xxx_wmac_resources[0].end = AR91XX_WMAC_BASE + AR91XX_WMAC_SIZE - 1;
62}
63
64static void ar934x_wmac_init(void)
65{
66        ar9xxx_wmac_resources[0].start = AR934X_WMAC_BASE;
67        ar9xxx_wmac_resources[0].end = AR934X_WMAC_BASE + AR934X_WMAC_SIZE - 1;
68}
69
70void __init ar9xxx_add_device_wmac(u8 *cal_data, u8 *mac_addr)
71{
72        switch (ar71xx_soc) {
73        case AR71XX_SOC_AR9130:
74        case AR71XX_SOC_AR9132:
75                ar913x_wmac_init();
76                break;
77
78        case AR71XX_SOC_AR9341:
79        case AR71XX_SOC_AR9342:
80        case AR71XX_SOC_AR9344:
81                ar934x_wmac_init();
82                break;
83
84        default:
85                BUG();
86        }
87
88        if (cal_data)
89                memcpy(ar9xxx_wmac_data.eeprom_data, cal_data,
90                       sizeof(ar9xxx_wmac_data.eeprom_data));
91
92        if (mac_addr) {
93                memcpy(ar9xxx_wmac_mac, mac_addr, sizeof(ar9xxx_wmac_mac));
94                ar9xxx_wmac_data.macaddr = ar9xxx_wmac_mac;
95        }
96
97        platform_device_register(&ar9xxx_wmac_device);
98}
Note: See TracBrowser for help on using the repository browser.