summaryrefslogtreecommitdiffstats
path: root/target/linux/mpc83xx/patches-2.6.33/020-rb333-support.patch
blob: caffe855f5cc5b69471c2bcb0f35b76b6d6dafdd (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
--- a/arch/powerpc/platforms/83xx/rbppc.c
+++ b/arch/powerpc/platforms/83xx/rbppc.c
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2010 Alexandros C. Couloumbis <alex@ozo.com>
  * Copyright (C) 2008-2009 Noah Fontes <nfontes@transtruct.org>
  * Copyright (C) 2009 Michael Guntsche <mike@it-loops.com>
  * Copyright (C) Mikrotik 2007
@@ -167,6 +168,9 @@
 	if (!model)
 		return 0;
 
+	if (strcmp(model, "RB333") == 0)
+		return 1;
+
 	if (strcmp(model, "RB600") == 0)
 		return 1;
 
@@ -227,6 +231,9 @@
 #define SBIT(x) (0x80000000 >> (x))
 #define DBIT(x, y) ((y) << (32 - (((x % 16) + 1) * 2)))
 
+#define GPIO_DIR_RB333(x) ((x) + (0x1408 >> 2))
+#define GPIO_DATA_RB333(x) ((x) + (0x1404 >> 2))
+
 #define SICRL_RB600(x) ((x) + (0x114 >> 2))
 #define GPIO_DIR_RB600(x) ((x) + (0xc00 >> 2))
 #define GPIO_DATA_RB600(x) ((x) + (0xc08 >> 2))
@@ -234,14 +241,38 @@
 static void rbppc_restart(char *cmd)
 {
 	__be32 __iomem *reg;
-
-	reg = ioremap(get_immrbase(), 0x1000);
-	local_irq_disable();
-	out_be32(SICRL_RB600(reg), in_be32(SICRL_RB600(reg)) & ~0x00800000);
-	out_be32(GPIO_DIR_RB600(reg), in_be32(GPIO_DIR_RB600(reg)) | SBIT(2));
-	out_be32(GPIO_DATA_RB600(reg), in_be32(GPIO_DATA_RB600(reg)) & ~SBIT(2));
-
-	while (1);
+	unsigned rb_model;
+	struct device_node *root;
+	unsigned int size;    
+
+	root = of_find_node_by_path("/");
+	if (root) {
+		const char *prop = (char *) of_get_property(root, "model", &size);
+		rb_model = prop[sizeof("RB") - 1] - '0';
+		of_node_put(root);
+		switch (rb_model) {
+		case 3:
+			reg = ioremap(get_immrbase(), 0x2000);
+			local_irq_disable();
+			out_be32(GPIO_DIR_RB333(reg),
+			(in_be32(GPIO_DIR_RB333(reg)) & ~DBIT(4, 3)) | DBIT(4, 1));
+			out_be32(GPIO_DATA_RB333(reg), in_be32(GPIO_DATA_RB333(reg)) & ~SBIT(4));
+			break;
+		case 6:
+			reg = ioremap(get_immrbase(), 0x1000);
+			local_irq_disable();
+			out_be32(SICRL_RB600(reg), in_be32(SICRL_RB600(reg)) & ~0x00800000);
+			out_be32(GPIO_DIR_RB600(reg), in_be32(GPIO_DIR_RB600(reg)) | SBIT(2));
+			out_be32(GPIO_DATA_RB600(reg), in_be32(GPIO_DATA_RB600(reg)) & ~SBIT(2));
+			break;
+		default:
+			mpc83xx_restart(cmd);
+			break;
+		}
+	}
+	else mpc83xx_restart(cmd);
+    
+	for (;;) ;
 }
 
 static void rbppc_halt(void)
@@ -301,10 +332,10 @@
 
 	return 0;
 }
-device_initcall(rbppc_declare_of_platform_devices);
+machine_device_initcall(rb600, rbppc_declare_of_platform_devices);
 
 define_machine(rb600) {
-	.name 				= "MikroTik RouterBOARD 600 series",
+	.name 				= "MikroTik RouterBOARD 333/600 series",
 	.probe 				= rbppc_probe,
 	.setup_arch 			= rbppc_setup_arch,
 	.init_IRQ 			= rbppc_init_IRQ,
@@ -314,3 +345,31 @@
 	.time_init 			= mpc83xx_time_init,
 	.calibrate_decr			= generic_calibrate_decr,
 };
+
+static void fixup_pcibridge(struct pci_dev *dev)
+{
+	if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
+		/* let the kernel itself set right memory windows */
+		pci_write_config_word(dev, PCI_MEMORY_BASE, 0);
+		pci_write_config_word(dev, PCI_MEMORY_LIMIT, 0);
+		pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0);
+		pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
+		pci_write_config_byte(dev, PCI_IO_BASE, 0);
+		pci_write_config_byte(dev, PCI_IO_LIMIT, 4 << 4);
+
+		pci_write_config_byte(
+			dev, PCI_COMMAND,
+			PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
+		pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 8);
+	}
+}
+
+
+static void fixup_rb604(struct pci_dev *dev)
+{
+	pci_write_config_byte(dev, 0xC0, 0x01);
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_pcibridge)
+DECLARE_PCI_FIXUP_HEADER(0x3388, 0x0021, fixup_rb604)
+
--- a/drivers/mtd/nand/Kconfig	2010-03-19 12:30:12.000000000 +0200
+++ b/drivers/mtd/nand/Kconfig	2010-03-19 12:30:28.000000000 +0200
@@ -387,11 +387,11 @@
 	  via platform_data.
 
 config MTD_NAND_RB_PPC
-	tristate "MikroTik RB600 NAND support"
+	tristate "MikroTik RB 333/600 NAND support"
 	depends on MTD_NAND && MTD_PARTITIONS && RB_PPC
 	help
 	  This option enables support for the NAND device on MikroTik
-	  RouterBOARD 600 series boards.
+	  RouterBOARD 333/600 series boards.
 
 config MTD_ALAUDA
 	tristate "MTD driver for Olympus MAUSB-10 and Fujifilm DPC-R1"
--- a/drivers/mtd/nand/rbppc_nand.c	2010-03-19 12:43:48.000000000 +0200
+++ b/drivers/mtd/nand/rbppc_nand.c	2010-03-19 12:44:17.000000000 +0200
@@ -126,7 +126,7 @@
 	void *baddr;
 	const unsigned *rdy, *nce, *cle, *ale;
 
-	printk(KERN_INFO "rbppc_nand_probe: MikroTik RouterBOARD 600 series NAND driver, version " DRV_VERSION "\n");
+	printk(KERN_INFO "rbppc_nand_probe: MikroTik RouterBOARD 333/600 series NAND driver, version " DRV_VERSION "\n");
 
 	info = kmalloc(sizeof(*info), GFP_KERNEL);
 
@@ -244,7 +244,7 @@
 MODULE_AUTHOR("Mikrotikls SIA");
 MODULE_AUTHOR("Noah Fontes");
 MODULE_AUTHOR("Michael Guntsche");
-MODULE_DESCRIPTION("MikroTik RouterBOARD 600 series NAND driver");
+MODULE_DESCRIPTION("MikroTik RouterBOARD 333/600 series NAND driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
--- a/arch/powerpc/platforms/83xx/Kconfig	2010-03-19 12:47:36.000000000 +0200
+++ b/arch/powerpc/platforms/83xx/Kconfig	2010-03-19 12:50:07.000000000 +0200
@@ -31,9 +31,10 @@
 	  This option enables support for the MPC8323 RDB board.
 
 config RB_PPC
-	bool "MikroTik RouterBOARD 600 series"
+	bool "MikroTik RouterBOARD 333/600 series"
 	select DEFAULT_UIMAGE
 	select QUICC_ENGINE
+	select PPC_MPC832x
 	select PPC_MPC834x
 	select RB_IOMAP
 	help
@@ -38,7 +38,7 @@
 	select PPC_MPC834x
 	select RB_IOMAP
 	help
-	  This option enables support for MikroTik RouterBOARD 600 series boards.
+	  This option enables support for MikroTik RouterBOARD 333/600 series boards.
 
 config MPC834x_MDS
 	bool "Freescale MPC834x MDS"
--- a/arch/powerpc/boot/Makefile	2010-03-18 21:32:32.000000000 +0200
+++ b/arch/powerpc/boot/Makefile	2010-03-18 21:32:53.000000000 +0200
@@ -72,7 +72,7 @@
 		cuboot-pq2.c cuboot-sequoia.c treeboot-walnut.c \
 		cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \
 		fixed-head.S ep88xc.c ep405.c cuboot-c2k.c \
-		cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c rb600.c \
+		cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c rb600.c rb333.c \
 		cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
 		virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
 		cuboot-acadia.c cuboot-amigaone.c
@@ -229,7 +229,8 @@
 image-$(CONFIG_MPC834x_MDS)		+= cuImage.mpc834x_mds
 image-$(CONFIG_MPC836x_MDS)		+= cuImage.mpc836x_mds
 image-$(CONFIG_ASP834x)			+= dtbImage.asp834x-redboot
-image-$(CONFIG_RB_PPC)			+= dtbImage.rb600
+image-$(CONFIG_RB_PPC)			+= dtbImage.rb600 \
+					   dtbImage.rb333
 
 # Board ports in arch/powerpc/platform/85xx/Kconfig
 image-$(CONFIG_MPC8540_ADS)		+= cuImage.mpc8540ads
--- a/arch/powerpc/boot/wrapper	2010-03-18 21:34:24.000000000 +0200
+++ b/arch/powerpc/boot/wrapper	2010-03-18 21:34:45.000000000 +0200
@@ -201,7 +201,7 @@
     isection=.kernel:initrd
     link_address=''
     ;;
-ep88xc|ep405|ep8248e|rb600)
+ep88xc|ep405|ep8248e|rb600|rb333)
     platformo="$object/fixed-head.o $object/$platform.o"
     binary=y
     ;;