aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/rb532
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/rb532')
-rw-r--r--arch/mips/rb532/devices.c22
-rw-r--r--arch/mips/rb532/gpio.c238
-rw-r--r--arch/mips/rb532/irq.c2
-rw-r--r--arch/mips/rb532/prom.c12
-rw-r--r--arch/mips/rb532/serial.c6
-rw-r--r--arch/mips/rb532/setup.c4
6 files changed, 177 insertions, 107 deletions
diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index 82ab395efa33..31619c601b11 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -34,21 +34,11 @@
34#include <asm/mach-rc32434/rb.h> 34#include <asm/mach-rc32434/rb.h>
35#include <asm/mach-rc32434/integ.h> 35#include <asm/mach-rc32434/integ.h>
36#include <asm/mach-rc32434/gpio.h> 36#include <asm/mach-rc32434/gpio.h>
37 37#include <asm/mach-rc32434/irq.h>
38#define ETH0_DMA_RX_IRQ (GROUP1_IRQ_BASE + 0)
39#define ETH0_DMA_TX_IRQ (GROUP1_IRQ_BASE + 1)
40#define ETH0_RX_OVR_IRQ (GROUP3_IRQ_BASE + 9)
41#define ETH0_TX_UND_IRQ (GROUP3_IRQ_BASE + 10)
42 38
43#define ETH0_RX_DMA_ADDR (DMA0_BASE_ADDR + 0 * DMA_CHAN_OFFSET) 39#define ETH0_RX_DMA_ADDR (DMA0_BASE_ADDR + 0 * DMA_CHAN_OFFSET)
44#define ETH0_TX_DMA_ADDR (DMA0_BASE_ADDR + 1 * DMA_CHAN_OFFSET) 40#define ETH0_TX_DMA_ADDR (DMA0_BASE_ADDR + 1 * DMA_CHAN_OFFSET)
45 41
46/* NAND definitions */
47#define GPIO_RDY (1 << 0x08)
48#define GPIO_WPX (1 << 0x09)
49#define GPIO_ALE (1 << 0x0a)
50#define GPIO_CLE (1 << 0x0b)
51
52static struct resource korina_dev0_res[] = { 42static struct resource korina_dev0_res[] = {
53 { 43 {
54 .name = "korina_regs", 44 .name = "korina_regs",
@@ -94,15 +84,13 @@ static struct korina_device korina_dev0_data = {
94}; 84};
95 85
96static struct platform_device korina_dev0 = { 86static struct platform_device korina_dev0 = {
97 .id = 0, 87 .id = -1,
98 .name = "korina", 88 .name = "korina",
99 .dev.platform_data = &korina_dev0_data, 89 .dev.platform_data = &korina_dev0_data,
100 .resource = korina_dev0_res, 90 .resource = korina_dev0_res,
101 .num_resources = ARRAY_SIZE(korina_dev0_res), 91 .num_resources = ARRAY_SIZE(korina_dev0_res),
102}; 92};
103 93
104#define CF_GPIO_NUM 13
105
106static struct resource cf_slot0_res[] = { 94static struct resource cf_slot0_res[] = {
107 { 95 {
108 .name = "cf_membase", 96 .name = "cf_membase",
@@ -116,11 +104,11 @@ static struct resource cf_slot0_res[] = {
116}; 104};
117 105
118static struct cf_device cf_slot0_data = { 106static struct cf_device cf_slot0_data = {
119 .gpio_pin = 13 107 .gpio_pin = CF_GPIO_NUM
120}; 108};
121 109
122static struct platform_device cf_slot0 = { 110static struct platform_device cf_slot0 = {
123 .id = 0, 111 .id = -1,
124 .name = "pata-rb532-cf", 112 .name = "pata-rb532-cf",
125 .dev.platform_data = &cf_slot0_data, 113 .dev.platform_data = &cf_slot0_data,
126 .resource = cf_slot0_res, 114 .resource = cf_slot0_res,
@@ -185,7 +173,7 @@ static struct mtd_partition rb532_partition_info[] = {
185 173
186static struct platform_device rb532_led = { 174static struct platform_device rb532_led = {
187 .name = "rb532-led", 175 .name = "rb532-led",
188 .id = 0, 176 .id = -1,
189}; 177};
190 178
191static struct gpio_keys_button rb532_gpio_btn[] = { 179static struct gpio_keys_button rb532_gpio_btn[] = {
diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c
index 00a1c7877bf4..76a7fd96d564 100644
--- a/arch/mips/rb532/gpio.c
+++ b/arch/mips/rb532/gpio.c
@@ -27,28 +27,31 @@
27 */ 27 */
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/gpio.h>
31#include <linux/init.h> 30#include <linux/init.h>
32#include <linux/types.h> 31#include <linux/types.h>
33#include <linux/pci.h>
34#include <linux/spinlock.h> 32#include <linux/spinlock.h>
35#include <linux/io.h>
36#include <linux/platform_device.h> 33#include <linux/platform_device.h>
37 34#include <linux/gpio.h>
38#include <asm/addrspace.h>
39 35
40#include <asm/mach-rc32434/rb.h> 36#include <asm/mach-rc32434/rb.h>
41 37#include <asm/mach-rc32434/gpio.h>
42struct rb532_gpio_reg __iomem *rb532_gpio_reg0; 38
43EXPORT_SYMBOL(rb532_gpio_reg0); 39struct rb532_gpio_chip {
40 struct gpio_chip chip;
41 void __iomem *regbase;
42 void (*set_int_level)(struct gpio_chip *chip, unsigned offset, int value);
43 int (*get_int_level)(struct gpio_chip *chip, unsigned offset);
44 void (*set_int_status)(struct gpio_chip *chip, unsigned offset, int value);
45 int (*get_int_status)(struct gpio_chip *chip, unsigned offset);
46};
44 47
45struct mpmc_device dev3; 48struct mpmc_device dev3;
46 49
47static struct resource rb532_gpio_reg0_res[] = { 50static struct resource rb532_gpio_reg0_res[] = {
48 { 51 {
49 .name = "gpio_reg0", 52 .name = "gpio_reg0",
50 .start = (u32)(IDT434_REG_BASE + GPIOBASE), 53 .start = REGBASE + GPIOBASE,
51 .end = (u32)(IDT434_REG_BASE + GPIOBASE + sizeof(struct rb532_gpio_reg)), 54 .end = REGBASE + GPIOBASE + sizeof(struct rb532_gpio_reg) - 1,
52 .flags = IORESOURCE_MEM, 55 .flags = IORESOURCE_MEM,
53 } 56 }
54}; 57};
@@ -56,8 +59,8 @@ static struct resource rb532_gpio_reg0_res[] = {
56static struct resource rb532_dev3_ctl_res[] = { 59static struct resource rb532_dev3_ctl_res[] = {
57 { 60 {
58 .name = "dev3_ctl", 61 .name = "dev3_ctl",
59 .start = (u32)(IDT434_REG_BASE + DEV3BASE), 62 .start = REGBASE + DEV3BASE,
60 .end = (u32)(IDT434_REG_BASE + DEV3BASE + sizeof(struct dev_reg)), 63 .end = REGBASE + DEV3BASE + sizeof(struct dev_reg) - 1,
61 .flags = IORESOURCE_MEM, 64 .flags = IORESOURCE_MEM,
62 } 65 }
63}; 66};
@@ -70,7 +73,7 @@ void set_434_reg(unsigned reg_offs, unsigned bit, unsigned len, unsigned val)
70 73
71 spin_lock_irqsave(&dev3.lock, flags); 74 spin_lock_irqsave(&dev3.lock, flags);
72 75
73 data = *(volatile unsigned *) (IDT434_REG_BASE + reg_offs); 76 data = readl(IDT434_REG_BASE + reg_offs);
74 for (i = 0; i != len; ++i) { 77 for (i = 0; i != len; ++i) {
75 if (val & (1 << i)) 78 if (val & (1 << i))
76 data |= (1 << (i + bit)); 79 data |= (1 << (i + bit));
@@ -108,108 +111,199 @@ unsigned char get_latch_u5(void)
108} 111}
109EXPORT_SYMBOL(get_latch_u5); 112EXPORT_SYMBOL(get_latch_u5);
110 113
111int rb532_gpio_get_value(unsigned gpio) 114/*
115 * Return GPIO level */
116static int rb532_gpio_get(struct gpio_chip *chip, unsigned offset)
112{ 117{
113 return readl(&rb532_gpio_reg0->gpiod) & (1 << gpio); 118 u32 mask = 1 << offset;
119 struct rb532_gpio_chip *gpch;
120
121 gpch = container_of(chip, struct rb532_gpio_chip, chip);
122 return readl(gpch->regbase + GPIOD) & mask;
114} 123}
115EXPORT_SYMBOL(rb532_gpio_get_value);
116 124
117void rb532_gpio_set_value(unsigned gpio, int value) 125/*
126 * Set output GPIO level
127 */
128static void rb532_gpio_set(struct gpio_chip *chip,
129 unsigned offset, int value)
118{ 130{
119 unsigned tmp; 131 unsigned long flags;
132 u32 mask = 1 << offset;
133 u32 tmp;
134 struct rb532_gpio_chip *gpch;
135 void __iomem *gpvr;
120 136
121 tmp = readl(&rb532_gpio_reg0->gpiod) & ~(1 << gpio); 137 gpch = container_of(chip, struct rb532_gpio_chip, chip);
122 if (value) 138 gpvr = gpch->regbase + GPIOD;
123 tmp |= 1 << gpio;
124 139
125 writel(tmp, (void *)&rb532_gpio_reg0->gpiod); 140 local_irq_save(flags);
141 tmp = readl(gpvr);
142 if (value)
143 tmp |= mask;
144 else
145 tmp &= ~mask;
146 writel(tmp, gpvr);
147 local_irq_restore(flags);
126} 148}
127EXPORT_SYMBOL(rb532_gpio_set_value);
128 149
129int rb532_gpio_direction_input(unsigned gpio) 150/*
151 * Set GPIO direction to input
152 */
153static int rb532_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
130{ 154{
131 writel(readl(&rb532_gpio_reg0->gpiocfg) & ~(1 << gpio), 155 unsigned long flags;
132 (void *)&rb532_gpio_reg0->gpiocfg); 156 u32 mask = 1 << offset;
157 u32 value;
158 struct rb532_gpio_chip *gpch;
159 void __iomem *gpdr;
133 160
134 return 0; 161 gpch = container_of(chip, struct rb532_gpio_chip, chip);
135} 162 gpdr = gpch->regbase + GPIOCFG;
136EXPORT_SYMBOL(rb532_gpio_direction_input);
137 163
138int rb532_gpio_direction_output(unsigned gpio, int value) 164 local_irq_save(flags);
139{ 165 value = readl(gpdr);
140 gpio_set_value(gpio, value); 166 value &= ~mask;
141 writel(readl(&rb532_gpio_reg0->gpiocfg) | (1 << gpio), 167 writel(value, gpdr);
142 (void *)&rb532_gpio_reg0->gpiocfg); 168 local_irq_restore(flags);
143 169
144 return 0; 170 return 0;
145} 171}
146EXPORT_SYMBOL(rb532_gpio_direction_output);
147 172
148void rb532_gpio_set_int_level(unsigned gpio, int value) 173/*
174 * Set GPIO direction to output
175 */
176static int rb532_gpio_direction_output(struct gpio_chip *chip,
177 unsigned offset, int value)
149{ 178{
150 unsigned tmp; 179 unsigned long flags;
180 u32 mask = 1 << offset;
181 u32 tmp;
182 struct rb532_gpio_chip *gpch;
183 void __iomem *gpdr;
184
185 gpch = container_of(chip, struct rb532_gpio_chip, chip);
186 writel(mask, gpch->regbase + GPIOD);
187 gpdr = gpch->regbase + GPIOCFG;
188
189 local_irq_save(flags);
190 tmp = readl(gpdr);
191 tmp |= mask;
192 writel(tmp, gpdr);
193 local_irq_restore(flags);
151 194
152 tmp = readl(&rb532_gpio_reg0->gpioilevel) & ~(1 << gpio); 195 return 0;
153 if (value)
154 tmp |= 1 << gpio;
155 writel(tmp, (void *)&rb532_gpio_reg0->gpioilevel);
156} 196}
157EXPORT_SYMBOL(rb532_gpio_set_int_level);
158 197
159int rb532_gpio_get_int_level(unsigned gpio) 198/*
199 * Set the GPIO interrupt level
200 */
201static void rb532_gpio_set_int_level(struct gpio_chip *chip,
202 unsigned offset, int value)
160{ 203{
161 return readl(&rb532_gpio_reg0->gpioilevel) & (1 << gpio); 204 unsigned long flags;
162} 205 u32 mask = 1 << offset;
163EXPORT_SYMBOL(rb532_gpio_get_int_level); 206 u32 tmp;
207 struct rb532_gpio_chip *gpch;
208 void __iomem *gpil;
164 209
165void rb532_gpio_set_int_status(unsigned gpio, int value) 210 gpch = container_of(chip, struct rb532_gpio_chip, chip);
166{ 211 gpil = gpch->regbase + GPIOILEVEL;
167 unsigned tmp;
168 212
169 tmp = readl(&rb532_gpio_reg0->gpioistat); 213 local_irq_save(flags);
214 tmp = readl(gpil);
170 if (value) 215 if (value)
171 tmp |= 1 << gpio; 216 tmp |= mask;
172 writel(tmp, (void *)&rb532_gpio_reg0->gpioistat); 217 else
218 tmp &= ~mask;
219 writel(tmp, gpil);
220 local_irq_restore(flags);
173} 221}
174EXPORT_SYMBOL(rb532_gpio_set_int_status);
175 222
176int rb532_gpio_get_int_status(unsigned gpio) 223/*
224 * Get the GPIO interrupt level
225 */
226static int rb532_gpio_get_int_level(struct gpio_chip *chip, unsigned offset)
177{ 227{
178 return readl(&rb532_gpio_reg0->gpioistat) & (1 << gpio); 228 u32 mask = 1 << offset;
229 struct rb532_gpio_chip *gpch;
230
231 gpch = container_of(chip, struct rb532_gpio_chip, chip);
232 return readl(gpch->regbase + GPIOILEVEL) & mask;
179} 233}
180EXPORT_SYMBOL(rb532_gpio_get_int_status);
181 234
182void rb532_gpio_set_func(unsigned gpio, int value) 235/*
236 * Set the GPIO interrupt status
237 */
238static void rb532_gpio_set_int_status(struct gpio_chip *chip,
239 unsigned offset, int value)
183{ 240{
184 unsigned tmp; 241 unsigned long flags;
242 u32 mask = 1 << offset;
243 u32 tmp;
244 struct rb532_gpio_chip *gpch;
245 void __iomem *gpis;
246
247 gpch = container_of(chip, struct rb532_gpio_chip, chip);
248 gpis = gpch->regbase + GPIOISTAT;
185 249
186 tmp = readl(&rb532_gpio_reg0->gpiofunc); 250 local_irq_save(flags);
251 tmp = readl(gpis);
187 if (value) 252 if (value)
188 tmp |= 1 << gpio; 253 tmp |= mask;
189 writel(tmp, (void *)&rb532_gpio_reg0->gpiofunc); 254 else
255 tmp &= ~mask;
256 writel(tmp, gpis);
257 local_irq_restore(flags);
190} 258}
191EXPORT_SYMBOL(rb532_gpio_set_func);
192 259
193int rb532_gpio_get_func(unsigned gpio) 260/*
261 * Get the GPIO interrupt status
262 */
263static int rb532_gpio_get_int_status(struct gpio_chip *chip, unsigned offset)
194{ 264{
195 return readl(&rb532_gpio_reg0->gpiofunc) & (1 << gpio); 265 u32 mask = 1 << offset;
266 struct rb532_gpio_chip *gpch;
267
268 gpch = container_of(chip, struct rb532_gpio_chip, chip);
269 return readl(gpch->regbase + GPIOISTAT) & mask;
196} 270}
197EXPORT_SYMBOL(rb532_gpio_get_func); 271
272static struct rb532_gpio_chip rb532_gpio_chip[] = {
273 [0] = {
274 .chip = {
275 .label = "gpio0",
276 .direction_input = rb532_gpio_direction_input,
277 .direction_output = rb532_gpio_direction_output,
278 .get = rb532_gpio_get,
279 .set = rb532_gpio_set,
280 .base = 0,
281 .ngpio = 32,
282 },
283 .get_int_level = rb532_gpio_get_int_level,
284 .set_int_level = rb532_gpio_set_int_level,
285 .get_int_status = rb532_gpio_get_int_status,
286 .set_int_status = rb532_gpio_set_int_status,
287 },
288};
198 289
199int __init rb532_gpio_init(void) 290int __init rb532_gpio_init(void)
200{ 291{
201 rb532_gpio_reg0 = ioremap_nocache(rb532_gpio_reg0_res[0].start, 292 struct resource *r;
202 rb532_gpio_reg0_res[0].end -
203 rb532_gpio_reg0_res[0].start);
204 293
205 if (!rb532_gpio_reg0) { 294 r = rb532_gpio_reg0_res;
295 rb532_gpio_chip->regbase = ioremap_nocache(r->start, r->end - r->start);
296
297 if (!rb532_gpio_chip->regbase) {
206 printk(KERN_ERR "rb532: cannot remap GPIO register 0\n"); 298 printk(KERN_ERR "rb532: cannot remap GPIO register 0\n");
207 return -ENXIO; 299 return -ENXIO;
208 } 300 }
209 301
210 dev3.base = ioremap_nocache(rb532_dev3_ctl_res[0].start, 302 /* Register our GPIO chip */
211 rb532_dev3_ctl_res[0].end - 303 gpiochip_add(&rb532_gpio_chip->chip);
212 rb532_dev3_ctl_res[0].start); 304
305 r = rb532_dev3_ctl_res;
306 dev3.base = ioremap_nocache(r->start, r->end - r->start);
213 307
214 if (!dev3.base) { 308 if (!dev3.base) {
215 printk(KERN_ERR "rb532: cannot remap device controller 3\n"); 309 printk(KERN_ERR "rb532: cannot remap device controller 3\n");
diff --git a/arch/mips/rb532/irq.c b/arch/mips/rb532/irq.c
index c0d0f950caf2..549b46d2fcee 100644
--- a/arch/mips/rb532/irq.c
+++ b/arch/mips/rb532/irq.c
@@ -45,7 +45,7 @@
45#include <asm/mipsregs.h> 45#include <asm/mipsregs.h>
46#include <asm/system.h> 46#include <asm/system.h>
47 47
48#include <asm/mach-rc32434/rc32434.h> 48#include <asm/mach-rc32434/irq.h>
49 49
50struct intr_group { 50struct intr_group {
51 u32 mask; /* mask of valid bits in pending/mask registers */ 51 u32 mask; /* mask of valid bits in pending/mask registers */
diff --git a/arch/mips/rb532/prom.c b/arch/mips/rb532/prom.c
index 1bc0af8febf4..46ca24dbcc2d 100644
--- a/arch/mips/rb532/prom.c
+++ b/arch/mips/rb532/prom.c
@@ -37,12 +37,8 @@
37#include <asm/mach-rc32434/ddr.h> 37#include <asm/mach-rc32434/ddr.h>
38#include <asm/mach-rc32434/prom.h> 38#include <asm/mach-rc32434/prom.h>
39 39
40extern void __init setup_serial_port(void);
41
42unsigned int idt_cpu_freq = 132000000; 40unsigned int idt_cpu_freq = 132000000;
43EXPORT_SYMBOL(idt_cpu_freq); 41EXPORT_SYMBOL(idt_cpu_freq);
44unsigned int gpio_bootup_state;
45EXPORT_SYMBOL(gpio_bootup_state);
46 42
47static struct resource ddr_reg[] = { 43static struct resource ddr_reg[] = {
48 { 44 {
@@ -108,9 +104,6 @@ void __init prom_setup_cmdline(void)
108 mips_machtype = MACH_MIKROTIK_RB532; 104 mips_machtype = MACH_MIKROTIK_RB532;
109 } 105 }
110 106
111 if (match_tag(prom_argv[i], GPIO_TAG))
112 gpio_bootup_state = tag2ul(prom_argv[i], GPIO_TAG);
113
114 strcpy(cp, prom_argv[i]); 107 strcpy(cp, prom_argv[i]);
115 cp += strlen(prom_argv[i]); 108 cp += strlen(prom_argv[i]);
116 } 109 }
@@ -122,11 +115,6 @@ void __init prom_setup_cmdline(void)
122 strcpy(cp, arcs_cmdline); 115 strcpy(cp, arcs_cmdline);
123 cp += strlen(arcs_cmdline); 116 cp += strlen(arcs_cmdline);
124 } 117 }
125 if (gpio_bootup_state & 0x02)
126 strcpy(cp, GPIO_INIT_NOBUTTON);
127 else
128 strcpy(cp, GPIO_INIT_BUTTON);
129
130 cmd_line[CL_SIZE-1] = '\0'; 118 cmd_line[CL_SIZE-1] = '\0';
131 119
132 strcpy(arcs_cmdline, cmd_line); 120 strcpy(arcs_cmdline, cmd_line);
diff --git a/arch/mips/rb532/serial.c b/arch/mips/rb532/serial.c
index 1a05b5ddee09..3e0d7ec3a579 100644
--- a/arch/mips/rb532/serial.c
+++ b/arch/mips/rb532/serial.c
@@ -31,16 +31,16 @@
31#include <linux/serial_8250.h> 31#include <linux/serial_8250.h>
32 32
33#include <asm/serial.h> 33#include <asm/serial.h>
34#include <asm/mach-rc32434/rc32434.h> 34#include <asm/mach-rc32434/rb.h>
35 35
36extern unsigned int idt_cpu_freq; 36extern unsigned int idt_cpu_freq;
37 37
38static struct uart_port rb532_uart = { 38static struct uart_port rb532_uart = {
39 .type = PORT_16550A, 39 .type = PORT_16550A,
40 .line = 0, 40 .line = 0,
41 .irq = RC32434_UART0_IRQ, 41 .irq = UART0_IRQ,
42 .iotype = UPIO_MEM, 42 .iotype = UPIO_MEM,
43 .membase = (char *)KSEG1ADDR(RC32434_UART0_BASE), 43 .membase = (char *)KSEG1ADDR(REGBASE + UART0BASE),
44 .regshift = 2 44 .regshift = 2
45}; 45};
46 46
diff --git a/arch/mips/rb532/setup.c b/arch/mips/rb532/setup.c
index 7aafa95ac20b..50f530f5b602 100644
--- a/arch/mips/rb532/setup.c
+++ b/arch/mips/rb532/setup.c
@@ -9,7 +9,7 @@
9#include <asm/time.h> 9#include <asm/time.h>
10#include <linux/ioport.h> 10#include <linux/ioport.h>
11 11
12#include <asm/mach-rc32434/rc32434.h> 12#include <asm/mach-rc32434/rb.h>
13#include <asm/mach-rc32434/pci.h> 13#include <asm/mach-rc32434/pci.h>
14 14
15struct pci_reg __iomem *pci_reg; 15struct pci_reg __iomem *pci_reg;
@@ -27,7 +27,7 @@ static struct resource pci0_res[] = {
27static void rb_machine_restart(char *command) 27static void rb_machine_restart(char *command)
28{ 28{
29 /* just jump to the reset vector */ 29 /* just jump to the reset vector */
30 writel(0x80000001, (void *)KSEG1ADDR(RC32434_REG_BASE + RC32434_RST)); 30 writel(0x80000001, IDT434_REG_BASE + RST);
31 ((void (*)(void)) KSEG1ADDR(0x1FC00000u))(); 31 ((void (*)(void)) KSEG1ADDR(0x1FC00000u))();
32} 32}
33 33