4 * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
5 * Copyright (c) 2017 Nicolò Veronese <nicveronese@gmail.com>
6 * Copyright (c) 2017 Federico Cappon <dududede371@gmail.com>
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <linux/gpio.h>
23 #include <linux/platform_device.h>
25 #include <asm/mach-ath79/ath79.h>
26 #include <asm/mach-ath79/ar71xx_regs.h>
30 #include "dev-gpio-buttons.h"
31 #include "dev-leds-gpio.h"
32 #include "dev-m25p80.h"
34 #include "machtypes.h"
37 #include <linux/kernel.h>
38 #include <linux/vmalloc.h>
39 #include <linux/errno.h>
40 #include <linux/init.h>
41 #include <linux/string.h>
43 #define DAP_1330_GPIO_LED_GREEN_POWER 13
44 #define DAP_1330_GPIO_LED_RED_POWER 3
45 #define DAP_1330_GPIO_LED_GREEN_WIFI 14
46 #define DAP_1330_GPIO_LED_RED_WIFI 11
47 #define DAP_1330_GPIO_LED_SIGNAL1 15
48 #define DAP_1330_GPIO_LED_SIGNAL2 16
50 #define DAP_1330_GPIO_BTN_WPS 2
51 #define DAP_1330_GPIO_BTN_RESET 17
53 #define DAP_1330_KEYS_POLL_INTERVAL 20 /* msecs */
54 #define DAP_1330_KEYS_DEBOUNCE_INTERVAL (3 * DAP_1330_KEYS_POLL_INTERVAL)
56 #define DAP1330_MAC_ADDR 0x1f020001
58 #define DAP1330_WMAC_CALDATA_ADDR 0x1f010000
59 #define DAP_1330_WMAC_CALDATA_OFFSET 0x1000
61 static struct gpio_led dap_1330_leds_gpio
[] __initdata
= {
63 .name
= "d-link:green:power",
64 .gpio
= DAP_1330_GPIO_LED_GREEN_POWER
,
68 .name
= "d-link:red:power",
69 .gpio
= DAP_1330_GPIO_LED_RED_POWER
,
73 .name
= "d-link:green:wifi",
74 .gpio
= DAP_1330_GPIO_LED_GREEN_WIFI
,
78 .name
= "d-link:red:wifi",
79 .gpio
= DAP_1330_GPIO_LED_RED_WIFI
,
83 .name
= "d-link:green:signal1",
84 .gpio
= DAP_1330_GPIO_LED_SIGNAL1
,
88 .name
= "d-link:green:signal2",
89 .gpio
= DAP_1330_GPIO_LED_SIGNAL2
,
94 static struct gpio_keys_button dap_1330_gpio_keys
[] __initdata
= {
98 .code
= KEY_WPS_BUTTON
,
99 .debounce_interval
= DAP_1330_KEYS_DEBOUNCE_INTERVAL
,
100 .gpio
= DAP_1330_GPIO_BTN_WPS
,
104 .desc
= "Reset button",
107 .debounce_interval
= DAP_1330_KEYS_DEBOUNCE_INTERVAL
,
108 .gpio
= DAP_1330_GPIO_BTN_RESET
,
113 static void __init
dap_1330_setup(void)
115 u8
*art
= (u8
*) KSEG1ADDR(DAP1330_WMAC_CALDATA_ADDR
);
116 u8
*mac_ptr
= (u8
*) KSEG1ADDR(DAP1330_MAC_ADDR
);
119 ath79_parse_ascii_mac((char *) mac_ptr
, mac
);
121 ath79_register_m25p80(NULL
);
123 ath79_register_leds_gpio(-1, ARRAY_SIZE(dap_1330_leds_gpio
),
126 ath79_register_gpio_keys_polled(-1, DAP_1330_KEYS_POLL_INTERVAL
,
127 ARRAY_SIZE(dap_1330_gpio_keys
),
130 ath79_register_wmac(art
+ DAP_1330_WMAC_CALDATA_OFFSET
, mac
);
132 ath79_register_mdio(0, 0x0);
134 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
137 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
138 ath79_eth1_data
.speed
= SPEED_1000
;
139 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
140 ath79_switch_data
.phy_poll_mask
|= BIT(4);
141 ath79_switch_data
.phy4_mii_en
= 1;
142 ath79_register_eth(1);
145 MIPS_MACHINE(ATH79_MACH_DAP_1330_A1
, "DAP-1330-A1",
146 "D-Link DAP-1330 Rev. A1", dap_1330_setup
);