summaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx/files/arch/mips/ar71xx/mach-ap96.c
blob: 6a7b6ff1cb36ab35a097154db391094f51400437 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
 *  Atheros AP96 board support
 *
 *  Copyright (C) 2009 Marco Porsch
 *  Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
 *  Copyright (C) 2010 Atheros Communications
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License version 2 as published
 *  by the Free Software Foundation.
 */

#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/delay.h>

#include <asm/mach-ar71xx/ar71xx.h>

#include "machtype.h"
#include "devices.h"
#include "dev-m25p80.h"
#include "dev-ap94-pci.h"
#include "dev-gpio-buttons.h"
#include "dev-leds-gpio.h"
#include "dev-usb.h"

#define AP96_GPIO_LED_12_GREEN		0
#define AP96_GPIO_LED_3_GREEN		1
#define AP96_GPIO_LED_2_GREEN		2
#define AP96_GPIO_LED_WPS_GREEN		4
#define AP96_GPIO_LED_5_GREEN		5
#define AP96_GPIO_LED_4_ORANGE		6

/* Reset button - next to the power connector */
#define AP96_GPIO_BTN_RESET		3
/* WPS button - next to a led on right */
#define AP96_GPIO_BTN_WPS		8

#define AP96_BUTTONS_POLL_INTERVAL    20

#define AP96_WMAC0_MAC_OFFSET		0x120c
#define AP96_WMAC1_MAC_OFFSET		0x520c
#define AP96_CALDATA0_OFFSET		0x1000
#define AP96_CALDATA1_OFFSET		0x5000

#ifdef CONFIG_MTD_PARTITIONS
static struct mtd_partition ap96_partitions[] = {
	{
		.name		= "uboot",
		.offset		= 0,
		.size		= 0x030000,
		.mask_flags	= MTD_WRITEABLE,
	} , {
		.name		= "env",
		.offset		= 0x030000,
		.size		= 0x010000,
		.mask_flags	= MTD_WRITEABLE,
	} , {
		.name		= "rootfs",
		.offset		= 0x040000,
		.size		= 0x600000,
	} , {
		.name		= "uImage",
		.offset		= 0x640000,
		.size		= 0x1b0000,
	} , {
		.name		= "caldata",
		.offset		= 0x7f0000,
		.size		= 0x010000,
		.mask_flags	= MTD_WRITEABLE,
	}
};
#endif /* CONFIG_MTD_PARTITIONS */

static struct flash_platform_data ap96_flash_data = {
#ifdef CONFIG_MTD_PARTITIONS
        .parts          = ap96_partitions,
        .nr_parts       = ARRAY_SIZE(ap96_partitions),
#endif
};

/*
 * AP96 has 12 unlabeled leds in the front; these are numbered from 1 to 12
 * below (from left to right on the board). Led 1 seems to be on whenever the
 * board is powered. Led 11 shows LAN link activity actity. Led 3 is orange;
 * others are green.
 *
 * In addition, there is one led next to a button on the right side for WPS.
 */
static struct gpio_led ap96_leds_gpio[] __initdata = {
	{
		.name		= "ap96:green:led2",
		.gpio		= AP96_GPIO_LED_2_GREEN,
		.active_low	= 1,
	}, {
		.name		= "ap96:green:led3",
		.gpio		= AP96_GPIO_LED_3_GREEN,
		.active_low	= 1,
	}, {
		.name		= "ap96:orange:led4",
		.gpio		= AP96_GPIO_LED_4_ORANGE,
		.active_low	= 1,
	}, {
		.name		= "ap96:green:led5",
		.gpio		= AP96_GPIO_LED_5_GREEN,
		.active_low	= 1,
	}, {
		.name		= "ap96:green:led12",
		.gpio		= AP96_GPIO_LED_12_GREEN,
		.active_low	= 1,
	}, { /* next to a button on right */
		.name		= "ap96:green:wps",
		.gpio		= AP96_GPIO_LED_WPS_GREEN,
		.active_low	= 1,
	}
};

static struct gpio_button ap96_gpio_buttons[] __initdata = {
	{
		.desc		= "reset",
		.type		= EV_KEY,
		.code		= KEY_RESTART,
		.threshold	= 3,
		.gpio		= AP96_GPIO_BTN_RESET,
		.active_low	= 1,
	}, {
		.desc		= "wps",
		.type		= EV_KEY,
		.code		= KEY_WPS_BUTTON,
		.threshold	= 3,
		.gpio		= AP96_GPIO_BTN_WPS,
		.active_low	= 1,
	}
};

static void __init ap96_setup(void)
{
	u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);

	ar71xx_add_device_mdio(0xfffffffe);

	ar71xx_init_mac(ar71xx_eth0_data.mac_addr, art, 0);
	ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
	ar71xx_eth0_data.phy_mask = 0x1;

	ar71xx_add_device_eth(0);

	ar71xx_init_mac(ar71xx_eth1_data.mac_addr, art, 1);
	ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
	ar71xx_eth1_data.speed = SPEED_1000;
	ar71xx_eth1_data.duplex = DUPLEX_FULL;

	ar71xx_eth1_pll_data.pll_1000 = 0x1f000000;

	ar71xx_add_device_eth(1);

	ar71xx_add_device_usb();

	ar71xx_add_device_m25p80(&ap96_flash_data);

        ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(ap96_leds_gpio),
				    ap96_leds_gpio);

	ar71xx_add_device_gpio_buttons(-1, AP96_BUTTONS_POLL_INTERVAL,
				      ARRAY_SIZE(ap96_gpio_buttons),
				      ap96_gpio_buttons);

	ap94_pci_init(art + AP96_CALDATA0_OFFSET,
		      art + AP96_WMAC0_MAC_OFFSET,
		      art + AP96_CALDATA1_OFFSET,
		      art + AP96_WMAC1_MAC_OFFSET);
}

MIPS_MACHINE(AR71XX_MACH_AP96, "AP96", "Atheros AP96", ap96_setup);