OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * AVM FRITZ!WLAN Repeater 300E board support |
||
3 | * |
||
4 | * Copyright (C) 2017 Mathias Kresin <dev@kresin.me> |
||
5 | * |
||
6 | * This program is free software; you can redistribute it and/or modify it |
||
7 | * under the terms of the GNU General Public License version 2 as published |
||
8 | * by the Free Software Foundation. |
||
9 | */ |
||
10 | |||
11 | #include <linux/gpio.h> |
||
12 | #include <linux/mtd/mtd.h> |
||
13 | #include <linux/mtd/partitions.h> |
||
14 | |||
15 | #include "dev-ap9x-pci.h" |
||
16 | #include "dev-eth.h" |
||
17 | #include "dev-gpio-buttons.h" |
||
18 | #include "dev-leds-gpio.h" |
||
19 | #include "dev-m25p80.h" |
||
20 | #include "machtypes.h" |
||
21 | |||
22 | #define FRITZ300E_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
23 | #define FRITZ300E_KEYS_DEBOUNCE_INTERVAL (3 * FRITZ300E_KEYS_POLL_INTERVAL) |
||
24 | |||
25 | static struct mtd_partition fritz300e_flash_partitions[] = { |
||
26 | { |
||
27 | .name = "urloader", |
||
28 | .offset = 0, |
||
29 | .size = 0x0020000, |
||
30 | .mask_flags = MTD_WRITEABLE, |
||
31 | }, { |
||
32 | .name = "firmware", |
||
33 | .offset = 0x0020000, |
||
34 | .size = 0x0ee0000, |
||
35 | }, { |
||
36 | .name = "tffs (1)", |
||
37 | .offset = 0x0f00000, |
||
38 | .size = 0x0080000, |
||
39 | .mask_flags = MTD_WRITEABLE, |
||
40 | }, { |
||
41 | .name = "tffs (2)", |
||
42 | .offset = 0x0f80000, |
||
43 | .size = 0x0080000, |
||
44 | .mask_flags = MTD_WRITEABLE, |
||
45 | } |
||
46 | }; |
||
47 | |||
48 | static struct flash_platform_data fritz300e_flash_data = { |
||
49 | .parts = fritz300e_flash_partitions, |
||
50 | .nr_parts = ARRAY_SIZE(fritz300e_flash_partitions), |
||
51 | }; |
||
52 | |||
53 | static struct gpio_led fritz300e_leds_gpio[] __initdata = { |
||
54 | { |
||
55 | .name = "fritz300e:green:power", |
||
56 | .gpio = 13, |
||
57 | .active_low = 1, |
||
58 | }, { |
||
59 | .name = "fritz300e:green:lan", |
||
60 | .gpio = 15, |
||
61 | .active_low = 1, |
||
62 | }, { |
||
63 | .name = "fritz300e:green:wlan", |
||
64 | .gpio = 16, |
||
65 | .active_low = 1, |
||
66 | } |
||
67 | }; |
||
68 | |||
69 | static struct gpio_led fritz300e_wmac_leds_gpio[] = { |
||
70 | { |
||
71 | .name = "fritz300e:green:rssi0", |
||
72 | .gpio = 10, |
||
73 | .active_low = 1, |
||
74 | }, { |
||
75 | .name = "fritz300e:green:rssi1", |
||
76 | .gpio = 4, |
||
77 | .active_low = 1, |
||
78 | }, { |
||
79 | .name = "fritz300e:green:rssi2", |
||
80 | .gpio = 6, |
||
81 | .active_low = 1, |
||
82 | }, { |
||
83 | .name = "fritz300e:green:rssi3", |
||
84 | .gpio = 7, |
||
85 | .active_low = 1, |
||
86 | }, { |
||
87 | .name = "fritz300e:green:rssi4", |
||
88 | .gpio = 5, |
||
89 | .active_low = 1, |
||
90 | } |
||
91 | }; |
||
92 | |||
93 | static struct gpio_keys_button fritz300e_gpio_keys[] __initdata = { |
||
94 | { |
||
95 | .desc = "wps", |
||
96 | .type = EV_KEY, |
||
97 | .code = KEY_WPS_BUTTON, |
||
98 | .debounce_interval = FRITZ300E_KEYS_DEBOUNCE_INTERVAL, |
||
99 | .gpio = 12, |
||
100 | .active_low = 1, |
||
101 | }, |
||
102 | }; |
||
103 | |||
104 | static void __init fritz300e_setup(void) |
||
105 | { |
||
106 | /* get the Lantiq PEF7071V phy out of reset */ |
||
107 | gpio_request_one(11, GPIOF_OUT_INIT_HIGH, "phy reset"); |
||
108 | |||
109 | ath79_register_m25p80(&fritz300e_flash_data); |
||
110 | |||
111 | ath79_register_mdio(0, ~(BIT(0))); |
||
112 | |||
113 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
114 | ath79_eth0_data.speed = SPEED_1000; |
||
115 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
116 | ath79_eth0_data.phy_mask = BIT(0); |
||
117 | |||
118 | ath79_register_eth(0); |
||
119 | |||
120 | ath79_register_leds_gpio(-1, ARRAY_SIZE(fritz300e_leds_gpio), |
||
121 | fritz300e_leds_gpio); |
||
122 | ath79_register_gpio_keys_polled(-1, FRITZ300E_KEYS_POLL_INTERVAL, |
||
123 | ARRAY_SIZE(fritz300e_gpio_keys), |
||
124 | fritz300e_gpio_keys); |
||
125 | |||
126 | ap9x_pci_setup_wmac_leds(0, fritz300e_wmac_leds_gpio, |
||
127 | ARRAY_SIZE(fritz300e_wmac_leds_gpio)); |
||
128 | ap91_pci_init_simple(); |
||
129 | } |
||
130 | |||
131 | MIPS_MACHINE(ATH79_MACH_FRITZ300E, "FRITZ300E", |
||
132 | "AVM FRITZ!WLAN Repeater 300E", fritz300e_setup); |