1
2 /*
3 * linux/arch/arm/mach-sa1100/frodo.c
4 *
5 * Author: Abraham van der Merwe <abraham@2d3d.co.za>
6 *
7 * This file contains the 2d3D, Inc. SA-1110 Development Board tweaks.
8 *
9 * This source code is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * History:
14 *
15 * 2002/05/27 Setup GPIOs for all the onboard peripherals so
16 * that we don't have to do it in each driver
17 *
18 * 2002/01/31 Initial version
19 */
20
21 #include <linux/init.h>
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/tty.h>
25 #include <linux/spinlock.h>
26
27 #include <asm/setup.h>
28 #include <asm/hardware.h>
29 #include <asm/irq.h>
30 #include <asm/io.h>
31
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/serial_sa1100.h>
35
36 #include "generic.h"
37
38 static struct map_desc frodo_io_desc[] __initdata = {
39 /* virtual physical length domain r w c b */
40 { 0xe8000000, 0x00000000, 0x04000000, DOMAIN_IO, 0, 1, 0, 0 }, /* flash memory */
41 { 0xf0000000, 0x40000000, 0x00100000, DOMAIN_IO, 0, 1, 0, 0 }, /* 16-bit on-board devices (including CPLDs) */
42 { 0xf1000000, 0x18000000, 0x04000000, DOMAIN_IO, 0, 1, 0, 0 }, /* 32-bit daughter card */
43 LAST_DESC
44 };
45
46 static spinlock_t frodo_cpld_lock = SPIN_LOCK_UNLOCKED;
47 static volatile u16 *frodo_cpld_memory = (u16 *) 0xf0000000;
48
frodo_map_io(void)49 static void __init frodo_map_io (void)
50 {
51 sa1100_map_io ();
52 iotable_init (frodo_io_desc);
53
54 sa1100_register_uart (0,2); /* UART2 (serial console) */
55 sa1100_register_uart (1,1); /* UART1 (big kahuna flow control serial port) */
56
57 /*
58 * Set SUS bit in SDCR0 so serial port 1 acts as a UART.
59 * See Intel SA-1110 Developers Manual Section 11.9.2.1 (GPCLK/UART Select)
60 */
61 Ser1SDCR0 |= SDCR0_SUS;
62 }
63
frodo_init_irq(void)64 static int __init frodo_init_irq(void)
65 {
66 int i,gpio[] = {
67 FRODO_IDE_GPIO,
68 FRODO_ETH_GPIO,
69 FRODO_USB_DC_GPIO,
70 FRODO_USB_HC_GPIO,
71 FRODO_RTC_GPIO,
72 FRODO_UART1_GPIO,
73 FRODO_UART2_GPIO,
74 FRODO_PCMCIA_STATUS_GPIO,
75 FRODO_PCMCIA_RDYBSY_GPIO
76 };
77
78 for (i = 0; i < sizeof (gpio) / sizeof (gpio[0]); i++)
79 set_GPIO_IRQ_edge (gpio[i],GPIO_RISING_EDGE);
80
81 return (0);
82 }
83
84 __initcall(frodo_init_irq);
85 #if 0
86 static int __init frodo_init_cpld(void)
87 {
88 if ((frodo_cpld_memory = ioremap (FRODO_CPLD_BASE,FRODO_CPLD_LENGTH)) == NULL)
89 panic ("Couldn't map CPLD memory to a virtual address. We're screwed!\n");
90
91 return (0);
92 }
93
94 __initcall(frodo_init_cpld);
95 #endif
frodo_cpld_read(u32 reg)96 u16 frodo_cpld_read (u32 reg)
97 {
98 unsigned long flags;
99 u16 value;
100
101 spin_lock_irqsave (&frodo_cpld_lock,flags);
102 value = frodo_cpld_memory[reg / 2];
103 spin_unlock_irqrestore (&frodo_cpld_lock,flags);
104
105 return (value);
106 }
107
frodo_cpld_write(u32 reg,u16 value)108 void frodo_cpld_write (u32 reg,u16 value)
109 {
110 unsigned long flags;
111
112 spin_lock_irqsave (&frodo_cpld_lock,flags);
113 frodo_cpld_memory[reg / 2] = value;
114 spin_unlock_irqrestore (&frodo_cpld_lock,flags);
115 }
116
frodo_cpld_set(u32 reg,u16 mask)117 void frodo_cpld_set (u32 reg,u16 mask)
118 {
119 unsigned long flags;
120
121 spin_lock_irqsave (&frodo_cpld_lock,flags);
122 frodo_cpld_memory[reg / 2] |= mask;
123 spin_unlock_irqrestore (&frodo_cpld_lock,flags);
124 }
125
frodo_cpld_clear(u32 reg,u16 mask)126 void frodo_cpld_clear (u32 reg,u16 mask)
127 {
128 unsigned long flags;
129
130 spin_lock_irqsave (&frodo_cpld_lock,flags);
131 frodo_cpld_memory[reg / 2] &= ~mask;
132 spin_unlock_irqrestore (&frodo_cpld_lock,flags);
133 }
134
135 EXPORT_SYMBOL (frodo_cpld_read);
136 EXPORT_SYMBOL (frodo_cpld_write);
137 EXPORT_SYMBOL (frodo_cpld_set);
138 EXPORT_SYMBOL (frodo_cpld_clear);
139
140 MACHINE_START (FRODO,"2d3D, Inc. SA-1110 Development Board")
141 BOOT_MEM (0xc0000000,0x80000000,0xf8000000)
142 BOOT_PARAMS (0xc0000100)
143 MAPIO (frodo_map_io)
144 INITIRQ (sa1100_init_irq)
145 MACHINE_END
146
147