0dc1564ad24dcc501f42f568d553ce34de2a36e8
[openwrt/openwrt.git] / target / linux / brcm47xx / patches-3.6 / 812-disable_wgt634u_crap.patch
1 --- a/arch/mips/bcm47xx/Makefile
2 +++ b/arch/mips/bcm47xx/Makefile
3 @@ -5,4 +5,3 @@
4
5 obj-y += irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
6 obj-y += gpio.o
7 -obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o
8 --- a/arch/mips/bcm47xx/wgt634u.c
9 +++ /dev/null
10 @@ -1,174 +0,0 @@
11 -/*
12 - * This file is subject to the terms and conditions of the GNU General Public
13 - * License. See the file "COPYING" in the main directory of this archive
14 - * for more details.
15 - *
16 - * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
17 - */
18 -
19 -#include <linux/platform_device.h>
20 -#include <linux/module.h>
21 -#include <linux/leds.h>
22 -#include <linux/mtd/physmap.h>
23 -#include <linux/ssb/ssb.h>
24 -#include <linux/ssb/ssb_embedded.h>
25 -#include <linux/interrupt.h>
26 -#include <linux/reboot.h>
27 -#include <linux/gpio.h>
28 -#include <asm/mach-bcm47xx/bcm47xx.h>
29 -
30 -/* GPIO definitions for the WGT634U */
31 -#define WGT634U_GPIO_LED 3
32 -#define WGT634U_GPIO_RESET 2
33 -#define WGT634U_GPIO_TP1 7
34 -#define WGT634U_GPIO_TP2 6
35 -#define WGT634U_GPIO_TP3 5
36 -#define WGT634U_GPIO_TP4 4
37 -#define WGT634U_GPIO_TP5 1
38 -
39 -static struct gpio_led wgt634u_leds[] = {
40 - {
41 - .name = "power",
42 - .gpio = WGT634U_GPIO_LED,
43 - .active_low = 1,
44 - .default_trigger = "heartbeat",
45 - },
46 -};
47 -
48 -static struct gpio_led_platform_data wgt634u_led_data = {
49 - .num_leds = ARRAY_SIZE(wgt634u_leds),
50 - .leds = wgt634u_leds,
51 -};
52 -
53 -static struct platform_device wgt634u_gpio_leds = {
54 - .name = "leds-gpio",
55 - .id = -1,
56 - .dev = {
57 - .platform_data = &wgt634u_led_data,
58 - }
59 -};
60 -
61 -
62 -/* 8MiB flash. The struct mtd_partition matches original Netgear WGT634U
63 - firmware. */
64 -static struct mtd_partition wgt634u_partitions[] = {
65 - {
66 - .name = "cfe",
67 - .offset = 0,
68 - .size = 0x60000, /* 384k */
69 - .mask_flags = MTD_WRITEABLE /* force read-only */
70 - },
71 - {
72 - .name = "config",
73 - .offset = 0x60000,
74 - .size = 0x20000 /* 128k */
75 - },
76 - {
77 - .name = "linux",
78 - .offset = 0x80000,
79 - .size = 0x140000 /* 1280k */
80 - },
81 - {
82 - .name = "jffs",
83 - .offset = 0x1c0000,
84 - .size = 0x620000 /* 6272k */
85 - },
86 - {
87 - .name = "nvram",
88 - .offset = 0x7e0000,
89 - .size = 0x20000 /* 128k */
90 - },
91 -};
92 -
93 -static struct physmap_flash_data wgt634u_flash_data = {
94 - .parts = wgt634u_partitions,
95 - .nr_parts = ARRAY_SIZE(wgt634u_partitions)
96 -};
97 -
98 -static struct resource wgt634u_flash_resource = {
99 - .flags = IORESOURCE_MEM,
100 -};
101 -
102 -static struct platform_device wgt634u_flash = {
103 - .name = "physmap-flash",
104 - .id = 0,
105 - .dev = { .platform_data = &wgt634u_flash_data, },
106 - .resource = &wgt634u_flash_resource,
107 - .num_resources = 1,
108 -};
109 -
110 -/* Platform devices */
111 -static struct platform_device *wgt634u_devices[] __initdata = {
112 - &wgt634u_flash,
113 - &wgt634u_gpio_leds,
114 -};
115 -
116 -static irqreturn_t gpio_interrupt(int irq, void *ignored)
117 -{
118 - int state;
119 -
120 - /* Interrupts are shared, check if the current one is
121 - a GPIO interrupt. */
122 - if (!ssb_chipco_irq_status(&bcm47xx_bus.ssb.chipco,
123 - SSB_CHIPCO_IRQ_GPIO))
124 - return IRQ_NONE;
125 -
126 - state = gpio_get_value(WGT634U_GPIO_RESET);
127 -
128 - /* Interrupt are level triggered, revert the interrupt polarity
129 - to clear the interrupt. */
130 - ssb_gpio_polarity(&bcm47xx_bus.ssb, 1 << WGT634U_GPIO_RESET,
131 - state ? 1 << WGT634U_GPIO_RESET : 0);
132 -
133 - if (!state) {
134 - printk(KERN_INFO "Reset button pressed");
135 - ctrl_alt_del();
136 - }
137 -
138 - return IRQ_HANDLED;
139 -}
140 -
141 -static int __init wgt634u_init(void)
142 -{
143 - /* There is no easy way to detect that we are running on a WGT634U
144 - * machine. Use the MAC address as an heuristic. Netgear Inc. has
145 - * been allocated ranges 00:09:5b:xx:xx:xx and 00:0f:b5:xx:xx:xx.
146 - */
147 - u8 *et0mac;
148 -
149 - if (bcm47xx_bus_type != BCM47XX_BUS_TYPE_SSB)
150 - return -ENODEV;
151 -
152 - et0mac = bcm47xx_bus.ssb.sprom.et0mac;
153 -
154 - if (et0mac[0] == 0x00 &&
155 - ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
156 - (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) {
157 - struct ssb_mipscore *mcore = &bcm47xx_bus.ssb.mipscore;
158 -
159 - printk(KERN_INFO "WGT634U machine detected.\n");
160 -
161 - if (!request_irq(gpio_to_irq(WGT634U_GPIO_RESET),
162 - gpio_interrupt, IRQF_SHARED,
163 - "WGT634U GPIO", &bcm47xx_bus.ssb.chipco)) {
164 - gpio_direction_input(WGT634U_GPIO_RESET);
165 - ssb_gpio_intmask(&bcm47xx_bus.ssb,
166 - 1 << WGT634U_GPIO_RESET,
167 - 1 << WGT634U_GPIO_RESET);
168 - ssb_chipco_irq_mask(&bcm47xx_bus.ssb.chipco,
169 - SSB_CHIPCO_IRQ_GPIO,
170 - SSB_CHIPCO_IRQ_GPIO);
171 - }
172 -
173 - wgt634u_flash_data.width = mcore->pflash.buswidth;
174 - wgt634u_flash_resource.start = mcore->pflash.window;
175 - wgt634u_flash_resource.end = mcore->pflash.window
176 - + mcore->pflash.window_size
177 - - 1;
178 - return platform_add_devices(wgt634u_devices,
179 - ARRAY_SIZE(wgt634u_devices));
180 - } else
181 - return -ENODEV;
182 -}
183 -
184 -module_init(wgt634u_init);