Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp4xx/common.c |
| 3 | * |
| 4 | * Generic code shared across all IXP4XX platforms |
| 5 | * |
| 6 | * Maintainer: Deepak Saxena <dsaxena@plexity.net> |
| 7 | * |
| 8 | * Copyright 2002 (c) Intel Corporation |
| 9 | * Copyright 2003-2004 (c) MontaVista, Software, Inc. |
| 10 | * |
| 11 | * This file is licensed under the terms of the GNU General Public |
| 12 | * License version 2. This program is licensed "as is" without any |
| 13 | * warranty of any kind, whether express or implied. |
| 14 | */ |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/mm.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/serial.h> |
| 20 | #include <linux/sched.h> |
| 21 | #include <linux/tty.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/serial_core.h> |
| 24 | #include <linux/bootmem.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/bitops.h> |
| 27 | #include <linux/time.h> |
| 28 | #include <linux/timex.h> |
Kevin Hilman | 84904d0 | 2006-09-22 00:58:57 +0100 | [diff] [blame] | 29 | #include <linux/clocksource.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
Milan Svoboda | e520a36 | 2006-12-01 11:36:41 +0100 | [diff] [blame^] | 31 | #include <asm/arch/udc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/hardware.h> |
| 33 | #include <asm/uaccess.h> |
| 34 | #include <asm/io.h> |
| 35 | #include <asm/pgtable.h> |
| 36 | #include <asm/page.h> |
| 37 | #include <asm/irq.h> |
| 38 | |
| 39 | #include <asm/mach/map.h> |
| 40 | #include <asm/mach/irq.h> |
| 41 | #include <asm/mach/time.h> |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | /************************************************************************* |
| 44 | * IXP4xx chipset I/O mapping |
| 45 | *************************************************************************/ |
| 46 | static struct map_desc ixp4xx_io_desc[] __initdata = { |
| 47 | { /* UART, Interrupt ctrl, GPIO, timers, NPEs, MACs, USB .... */ |
| 48 | .virtual = IXP4XX_PERIPHERAL_BASE_VIRT, |
Deepak Saxena | 87fe04b | 2005-10-28 15:18:59 +0100 | [diff] [blame] | 49 | .pfn = __phys_to_pfn(IXP4XX_PERIPHERAL_BASE_PHYS), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | .length = IXP4XX_PERIPHERAL_REGION_SIZE, |
| 51 | .type = MT_DEVICE |
| 52 | }, { /* Expansion Bus Config Registers */ |
| 53 | .virtual = IXP4XX_EXP_CFG_BASE_VIRT, |
Deepak Saxena | 87fe04b | 2005-10-28 15:18:59 +0100 | [diff] [blame] | 54 | .pfn = __phys_to_pfn(IXP4XX_EXP_CFG_BASE_PHYS), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | .length = IXP4XX_EXP_CFG_REGION_SIZE, |
| 56 | .type = MT_DEVICE |
| 57 | }, { /* PCI Registers */ |
| 58 | .virtual = IXP4XX_PCI_CFG_BASE_VIRT, |
Deepak Saxena | 87fe04b | 2005-10-28 15:18:59 +0100 | [diff] [blame] | 59 | .pfn = __phys_to_pfn(IXP4XX_PCI_CFG_BASE_PHYS), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | .length = IXP4XX_PCI_CFG_REGION_SIZE, |
| 61 | .type = MT_DEVICE |
Deepak Saxena | 5932ae3 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 62 | }, |
| 63 | #ifdef CONFIG_DEBUG_LL |
| 64 | { /* Debug UART mapping */ |
| 65 | .virtual = IXP4XX_DEBUG_UART_BASE_VIRT, |
Deepak Saxena | 87fe04b | 2005-10-28 15:18:59 +0100 | [diff] [blame] | 66 | .pfn = __phys_to_pfn(IXP4XX_DEBUG_UART_BASE_PHYS), |
Deepak Saxena | 5932ae3 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 67 | .length = IXP4XX_DEBUG_UART_REGION_SIZE, |
| 68 | .type = MT_DEVICE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | } |
Deepak Saxena | 5932ae3 | 2005-06-24 20:54:35 +0100 | [diff] [blame] | 70 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | void __init ixp4xx_map_io(void) |
| 74 | { |
| 75 | iotable_init(ixp4xx_io_desc, ARRAY_SIZE(ixp4xx_io_desc)); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /************************************************************************* |
| 80 | * IXP4xx chipset IRQ handling |
| 81 | * |
| 82 | * TODO: GPIO IRQs should be marked invalid until the user of the IRQ |
| 83 | * (be it PCI or something else) configures that GPIO line |
| 84 | * as an IRQ. |
| 85 | **************************************************************************/ |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 86 | enum ixp4xx_irq_type { |
| 87 | IXP4XX_IRQ_LEVEL, IXP4XX_IRQ_EDGE |
| 88 | }; |
| 89 | |
Kevin Hilman | 984d115 | 2006-11-03 01:47:20 +0100 | [diff] [blame] | 90 | /* Each bit represents an IRQ: 1: edge-triggered, 0: level triggered */ |
| 91 | static unsigned long long ixp4xx_irq_edge = 0; |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 92 | |
| 93 | /* |
| 94 | * IRQ -> GPIO mapping table |
| 95 | */ |
Lennert Buytenhek | 6cc1b65 | 2006-04-20 21:24:38 +0100 | [diff] [blame] | 96 | static signed char irq2gpio[32] = { |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 97 | -1, -1, -1, -1, -1, -1, 0, 1, |
| 98 | -1, -1, -1, -1, -1, -1, -1, -1, |
| 99 | -1, -1, -1, 2, 3, 4, 5, 6, |
| 100 | 7, 8, 9, 10, 11, 12, -1, -1, |
| 101 | }; |
| 102 | |
| 103 | static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type) |
| 104 | { |
| 105 | int line = irq2gpio[irq]; |
| 106 | u32 int_style; |
| 107 | enum ixp4xx_irq_type irq_type; |
| 108 | volatile u32 *int_reg; |
| 109 | |
| 110 | /* |
| 111 | * Only for GPIO IRQs |
| 112 | */ |
| 113 | if (line < 0) |
| 114 | return -EINVAL; |
| 115 | |
Mårten Wikström | 06e4479 | 2006-02-22 22:27:23 +0000 | [diff] [blame] | 116 | switch (type){ |
| 117 | case IRQT_BOTHEDGE: |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 118 | int_style = IXP4XX_GPIO_STYLE_TRANSITIONAL; |
| 119 | irq_type = IXP4XX_IRQ_EDGE; |
Mårten Wikström | 06e4479 | 2006-02-22 22:27:23 +0000 | [diff] [blame] | 120 | break; |
| 121 | case IRQT_RISING: |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 122 | int_style = IXP4XX_GPIO_STYLE_RISING_EDGE; |
| 123 | irq_type = IXP4XX_IRQ_EDGE; |
Mårten Wikström | 06e4479 | 2006-02-22 22:27:23 +0000 | [diff] [blame] | 124 | break; |
| 125 | case IRQT_FALLING: |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 126 | int_style = IXP4XX_GPIO_STYLE_FALLING_EDGE; |
| 127 | irq_type = IXP4XX_IRQ_EDGE; |
Mårten Wikström | 06e4479 | 2006-02-22 22:27:23 +0000 | [diff] [blame] | 128 | break; |
| 129 | case IRQT_HIGH: |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 130 | int_style = IXP4XX_GPIO_STYLE_ACTIVE_HIGH; |
| 131 | irq_type = IXP4XX_IRQ_LEVEL; |
Mårten Wikström | 06e4479 | 2006-02-22 22:27:23 +0000 | [diff] [blame] | 132 | break; |
| 133 | case IRQT_LOW: |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 134 | int_style = IXP4XX_GPIO_STYLE_ACTIVE_LOW; |
| 135 | irq_type = IXP4XX_IRQ_LEVEL; |
Mårten Wikström | 06e4479 | 2006-02-22 22:27:23 +0000 | [diff] [blame] | 136 | break; |
| 137 | default: |
David Vrabel | 6132f9e | 2005-09-26 19:52:56 +0100 | [diff] [blame] | 138 | return -EINVAL; |
Mårten Wikström | 06e4479 | 2006-02-22 22:27:23 +0000 | [diff] [blame] | 139 | } |
Kevin Hilman | 984d115 | 2006-11-03 01:47:20 +0100 | [diff] [blame] | 140 | |
| 141 | if (irq_type == IXP4XX_IRQ_EDGE) |
| 142 | ixp4xx_irq_edge |= (1 << irq); |
| 143 | else |
| 144 | ixp4xx_irq_edge &= ~(1 << irq); |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 145 | |
| 146 | if (line >= 8) { /* pins 8-15 */ |
| 147 | line -= 8; |
| 148 | int_reg = IXP4XX_GPIO_GPIT2R; |
| 149 | } else { /* pins 0-7 */ |
| 150 | int_reg = IXP4XX_GPIO_GPIT1R; |
| 151 | } |
| 152 | |
| 153 | /* Clear the style for the appropriate pin */ |
| 154 | *int_reg &= ~(IXP4XX_GPIO_STYLE_CLEAR << |
| 155 | (line * IXP4XX_GPIO_STYLE_SIZE)); |
| 156 | |
Deepak Saxena | f7e8bbb8 | 2006-01-04 17:17:10 +0000 | [diff] [blame] | 157 | *IXP4XX_GPIO_GPISR = (1 << line); |
| 158 | |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 159 | /* Set the new style */ |
| 160 | *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE)); |
David Vrabel | 6132f9e | 2005-09-26 19:52:56 +0100 | [diff] [blame] | 161 | |
Alessandro Zummo | 73deb7d | 2006-03-20 17:10:12 +0000 | [diff] [blame] | 162 | /* Configure the line as an input */ |
| 163 | gpio_line_config(line, IXP4XX_GPIO_IN); |
| 164 | |
David Vrabel | 6132f9e | 2005-09-26 19:52:56 +0100 | [diff] [blame] | 165 | return 0; |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 166 | } |
| 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | static void ixp4xx_irq_mask(unsigned int irq) |
| 169 | { |
| 170 | if (cpu_is_ixp46x() && irq >= 32) |
| 171 | *IXP4XX_ICMR2 &= ~(1 << (irq - 32)); |
| 172 | else |
| 173 | *IXP4XX_ICMR &= ~(1 << irq); |
| 174 | } |
| 175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | static void ixp4xx_irq_ack(unsigned int irq) |
| 177 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | int line = (irq < 32) ? irq2gpio[irq] : -1; |
| 179 | |
| 180 | if (line >= 0) |
Deepak Saxena | f7e8bbb8 | 2006-01-04 17:17:10 +0000 | [diff] [blame] | 181 | *IXP4XX_GPIO_GPISR = (1 << line); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /* |
| 185 | * Level triggered interrupts on GPIO lines can only be cleared when the |
| 186 | * interrupt condition disappears. |
| 187 | */ |
Kevin Hilman | 984d115 | 2006-11-03 01:47:20 +0100 | [diff] [blame] | 188 | static void ixp4xx_irq_unmask(unsigned int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | { |
Kevin Hilman | 984d115 | 2006-11-03 01:47:20 +0100 | [diff] [blame] | 190 | if (!(ixp4xx_irq_edge & (1 << irq))) |
| 191 | ixp4xx_irq_ack(irq); |
| 192 | |
| 193 | if (cpu_is_ixp46x() && irq >= 32) |
| 194 | *IXP4XX_ICMR2 |= (1 << (irq - 32)); |
| 195 | else |
| 196 | *IXP4XX_ICMR |= (1 << irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 199 | static struct irq_chip ixp4xx_irq_chip = { |
Kevin Hilman | 984d115 | 2006-11-03 01:47:20 +0100 | [diff] [blame] | 200 | .name = "IXP4xx", |
Russell King | 2be863c | 2005-09-06 23:13:17 +0100 | [diff] [blame] | 201 | .ack = ixp4xx_irq_ack, |
| 202 | .mask = ixp4xx_irq_mask, |
| 203 | .unmask = ixp4xx_irq_unmask, |
| 204 | .set_type = ixp4xx_set_irq_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | }; |
| 206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | void __init ixp4xx_init_irq(void) |
| 208 | { |
| 209 | int i = 0; |
| 210 | |
| 211 | /* Route all sources to IRQ instead of FIQ */ |
| 212 | *IXP4XX_ICLR = 0x0; |
| 213 | |
| 214 | /* Disable all interrupt */ |
| 215 | *IXP4XX_ICMR = 0x0; |
| 216 | |
| 217 | if (cpu_is_ixp46x()) { |
| 218 | /* Route upper 32 sources to IRQ instead of FIQ */ |
| 219 | *IXP4XX_ICLR2 = 0x00; |
| 220 | |
| 221 | /* Disable upper 32 interrupts */ |
| 222 | *IXP4XX_ICMR2 = 0x00; |
| 223 | } |
| 224 | |
| 225 | /* Default to all level triggered */ |
Kevin Hilman | 984d115 | 2006-11-03 01:47:20 +0100 | [diff] [blame] | 226 | for(i = 0; i < NR_IRQS; i++) { |
| 227 | set_irq_chip(i, &ixp4xx_irq_chip); |
Russell King | 10dd5ce | 2006-11-23 11:41:32 +0000 | [diff] [blame] | 228 | set_irq_handler(i, handle_level_irq); |
Kevin Hilman | 984d115 | 2006-11-03 01:47:20 +0100 | [diff] [blame] | 229 | set_irq_flags(i, IRQF_VALID); |
| 230 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | |
| 234 | /************************************************************************* |
| 235 | * IXP4xx timer tick |
| 236 | * We use OS timer1 on the CPU for the timer tick and the timestamp |
| 237 | * counter as a source of real clock ticks to account for missed jiffies. |
| 238 | *************************************************************************/ |
| 239 | |
| 240 | static unsigned volatile last_jiffy_time; |
| 241 | |
| 242 | #define CLOCK_TICKS_PER_USEC ((CLOCK_TICK_RATE + USEC_PER_SEC/2) / USEC_PER_SEC) |
| 243 | |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 244 | static irqreturn_t ixp4xx_timer_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | { |
| 246 | write_seqlock(&xtime_lock); |
| 247 | |
| 248 | /* Clear Pending Interrupt by writing '1' to it */ |
| 249 | *IXP4XX_OSST = IXP4XX_OSST_TIMER_1_PEND; |
| 250 | |
| 251 | /* |
| 252 | * Catch up with the real idea of time |
| 253 | */ |
Lennert Buytenhek | f869afa | 2006-06-22 10:30:53 +0100 | [diff] [blame] | 254 | while ((signed long)(*IXP4XX_OSTS - last_jiffy_time) >= LATCH) { |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 255 | timer_tick(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | last_jiffy_time += LATCH; |
| 257 | } |
| 258 | |
| 259 | write_sequnlock(&xtime_lock); |
| 260 | |
| 261 | return IRQ_HANDLED; |
| 262 | } |
| 263 | |
| 264 | static struct irqaction ixp4xx_timer_irq = { |
| 265 | .name = "IXP4xx Timer Tick", |
Thomas Gleixner | 52e405e | 2006-07-03 02:20:05 +0200 | [diff] [blame] | 266 | .flags = IRQF_DISABLED | IRQF_TIMER, |
Russell King | 09b8b5f | 2005-06-26 17:06:36 +0100 | [diff] [blame] | 267 | .handler = ixp4xx_timer_interrupt, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | static void __init ixp4xx_timer_init(void) |
| 271 | { |
| 272 | /* Clear Pending Interrupt by writing '1' to it */ |
| 273 | *IXP4XX_OSST = IXP4XX_OSST_TIMER_1_PEND; |
| 274 | |
| 275 | /* Setup the Timer counter value */ |
| 276 | *IXP4XX_OSRT1 = (LATCH & ~IXP4XX_OST_RELOAD_MASK) | IXP4XX_OST_ENABLE; |
| 277 | |
| 278 | /* Reset time-stamp counter */ |
| 279 | *IXP4XX_OSTS = 0; |
| 280 | last_jiffy_time = 0; |
| 281 | |
| 282 | /* Connect the interrupt handler and enable the interrupt */ |
| 283 | setup_irq(IRQ_IXP4XX_TIMER1, &ixp4xx_timer_irq); |
| 284 | } |
| 285 | |
| 286 | struct sys_timer ixp4xx_timer = { |
| 287 | .init = ixp4xx_timer_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | }; |
| 289 | |
Milan Svoboda | e520a36 | 2006-12-01 11:36:41 +0100 | [diff] [blame^] | 290 | static struct pxa2xx_udc_mach_info ixp4xx_udc_info; |
| 291 | |
| 292 | void __init ixp4xx_set_udc_info(struct pxa2xx_udc_mach_info *info) |
| 293 | { |
| 294 | memcpy(&ixp4xx_udc_info, info, sizeof *info); |
| 295 | } |
| 296 | |
| 297 | static struct resource ixp4xx_udc_resources[] = { |
| 298 | [0] = { |
| 299 | .start = 0xc800b000, |
| 300 | .end = 0xc800bfff, |
| 301 | .flags = IORESOURCE_MEM, |
| 302 | }, |
| 303 | [1] = { |
| 304 | .start = IRQ_IXP4XX_USB, |
| 305 | .end = IRQ_IXP4XX_USB, |
| 306 | .flags = IORESOURCE_IRQ, |
| 307 | }, |
| 308 | }; |
| 309 | |
| 310 | /* |
| 311 | * USB device controller. The IXP4xx uses the same controller as PXA2XX, |
| 312 | * so we just use the same device. |
| 313 | */ |
| 314 | static struct platform_device ixp4xx_udc_device = { |
| 315 | .name = "pxa2xx-udc", |
| 316 | .id = -1, |
| 317 | .num_resources = 2, |
| 318 | .resource = ixp4xx_udc_resources, |
| 319 | .dev = { |
| 320 | .platform_data = &ixp4xx_udc_info, |
| 321 | }, |
| 322 | }; |
| 323 | |
| 324 | static struct platform_device *ixp4xx_devices[] __initdata = { |
| 325 | &ixp4xx_udc_device, |
| 326 | }; |
| 327 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | static struct resource ixp46x_i2c_resources[] = { |
| 329 | [0] = { |
| 330 | .start = 0xc8011000, |
| 331 | .end = 0xc801101c, |
| 332 | .flags = IORESOURCE_MEM, |
| 333 | }, |
| 334 | [1] = { |
| 335 | .start = IRQ_IXP4XX_I2C, |
| 336 | .end = IRQ_IXP4XX_I2C, |
| 337 | .flags = IORESOURCE_IRQ |
| 338 | } |
| 339 | }; |
| 340 | |
| 341 | /* |
| 342 | * I2C controller. The IXP46x uses the same block as the IOP3xx, so |
| 343 | * we just use the same device name. |
| 344 | */ |
| 345 | static struct platform_device ixp46x_i2c_controller = { |
| 346 | .name = "IOP3xx-I2C", |
| 347 | .id = 0, |
| 348 | .num_resources = 2, |
| 349 | .resource = ixp46x_i2c_resources |
| 350 | }; |
| 351 | |
| 352 | static struct platform_device *ixp46x_devices[] __initdata = { |
| 353 | &ixp46x_i2c_controller |
| 354 | }; |
| 355 | |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 356 | unsigned long ixp4xx_exp_bus_size; |
David Vrabel | 1e74c89 | 2006-01-18 22:46:43 +0000 | [diff] [blame] | 357 | EXPORT_SYMBOL(ixp4xx_exp_bus_size); |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 358 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | void __init ixp4xx_sys_init(void) |
| 360 | { |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 361 | ixp4xx_exp_bus_size = SZ_16M; |
| 362 | |
Milan Svoboda | e520a36 | 2006-12-01 11:36:41 +0100 | [diff] [blame^] | 363 | platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices)); |
| 364 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | if (cpu_is_ixp46x()) { |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 366 | int region; |
| 367 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | platform_add_devices(ixp46x_devices, |
| 369 | ARRAY_SIZE(ixp46x_devices)); |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 370 | |
| 371 | for (region = 0; region < 7; region++) { |
| 372 | if((*(IXP4XX_EXP_REG(0x4 * region)) & 0x200)) { |
| 373 | ixp4xx_exp_bus_size = SZ_32M; |
| 374 | break; |
| 375 | } |
| 376 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | } |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 378 | |
David Vrabel | 1e74c89 | 2006-01-18 22:46:43 +0000 | [diff] [blame] | 379 | printk("IXP4xx: Using %luMiB expansion bus window size\n", |
Deepak Saxena | 54e269e | 2006-01-05 20:59:29 +0000 | [diff] [blame] | 380 | ixp4xx_exp_bus_size >> 20); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Kevin Hilman | 84904d0 | 2006-09-22 00:58:57 +0100 | [diff] [blame] | 383 | cycle_t ixp4xx_get_cycles(void) |
| 384 | { |
| 385 | return *IXP4XX_OSTS; |
| 386 | } |
| 387 | |
| 388 | static struct clocksource clocksource_ixp4xx = { |
| 389 | .name = "OSTS", |
| 390 | .rating = 200, |
| 391 | .read = ixp4xx_get_cycles, |
| 392 | .mask = CLOCKSOURCE_MASK(32), |
| 393 | .shift = 20, |
| 394 | .is_continuous = 1, |
| 395 | }; |
| 396 | |
| 397 | unsigned long ixp4xx_timer_freq = FREQ; |
| 398 | static int __init ixp4xx_clocksource_init(void) |
| 399 | { |
| 400 | clocksource_ixp4xx.mult = |
| 401 | clocksource_hz2mult(ixp4xx_timer_freq, |
| 402 | clocksource_ixp4xx.shift); |
| 403 | clocksource_register(&clocksource_ixp4xx); |
| 404 | |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | device_initcall(ixp4xx_clocksource_init); |