Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/5249/config.c |
| 5 | * |
| 6 | * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com) |
| 7 | */ |
| 8 | |
| 9 | /***************************************************************************/ |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/param.h> |
| 13 | #include <linux/init.h> |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 14 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/machdep.h> |
| 16 | #include <asm/coldfire.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <asm/mcfsim.h> |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 18 | #include <asm/mcfuart.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | /***************************************************************************/ |
| 21 | |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 22 | static struct mcf_platform_uart m5249_uart_platform[] = { |
| 23 | { |
| 24 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 25 | .irq = 73, |
| 26 | }, |
| 27 | { |
| 28 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 29 | .irq = 74, |
Greg Ungerer | 4ce2cba | 2009-03-24 15:15:14 +1000 | [diff] [blame] | 30 | }, |
| 31 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 34 | static struct platform_device m5249_uart = { |
| 35 | .name = "mcfuart", |
| 36 | .id = 0, |
| 37 | .dev.platform_data = m5249_uart_platform, |
| 38 | }; |
| 39 | |
| 40 | static struct platform_device *m5249_devices[] __initdata = { |
| 41 | &m5249_uart, |
| 42 | }; |
| 43 | |
| 44 | /***************************************************************************/ |
| 45 | |
| 46 | static void __init m5249_uart_init_line(int line, int irq) |
| 47 | { |
| 48 | if (line == 0) { |
Greg Ungerer | de1fc5c | 2009-03-24 16:50:09 +1000 | [diff] [blame] | 49 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
Greg Ungerer | d62db60 | 2009-03-24 17:14:32 +1000 | [diff] [blame] | 50 | writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR); |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 51 | mcf_clrimr(MCFINTC_UART0); |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 52 | } else if (line == 1) { |
Greg Ungerer | de1fc5c | 2009-03-24 16:50:09 +1000 | [diff] [blame] | 53 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR); |
Greg Ungerer | d62db60 | 2009-03-24 17:14:32 +1000 | [diff] [blame] | 54 | writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR); |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 55 | mcf_clrimr(MCFINTC_UART1); |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 56 | } |
| 57 | } |
| 58 | |
| 59 | static void __init m5249_uarts_init(void) |
| 60 | { |
| 61 | const int nrlines = ARRAY_SIZE(m5249_uart_platform); |
| 62 | int line; |
| 63 | |
| 64 | for (line = 0; (line < nrlines); line++) |
| 65 | m5249_uart_init_line(line, m5249_uart_platform[line].irq); |
| 66 | } |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | /***************************************************************************/ |
| 69 | |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 70 | static void __init m5249_timers_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 72 | /* Timer1 is always used as system timer */ |
| 73 | writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI3, |
| 74 | MCF_MBAR + MCFSIM_TIMER1ICR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 76 | #ifdef CONFIG_HIGHPROFILE |
| 77 | /* Timer2 is to be used as a high speed profile timer */ |
| 78 | writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL7 | MCFSIM_ICR_PRI3, |
| 79 | MCF_MBAR + MCFSIM_TIMER2ICR); |
| 80 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | /***************************************************************************/ |
| 84 | |
Greg Ungerer | 6f5aa7c | 2009-04-30 17:31:19 +1000 | [diff] [blame] | 85 | void m5249_cpu_reset(void) |
| 86 | { |
| 87 | local_irq_disable(); |
| 88 | /* Set watchdog to soft reset, and enabled */ |
| 89 | __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR); |
| 90 | for (;;) |
| 91 | /* wait for watchdog to timeout */; |
| 92 | } |
| 93 | |
| 94 | /***************************************************************************/ |
| 95 | |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 96 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | { |
Greg Ungerer | 6f5aa7c | 2009-04-30 17:31:19 +1000 | [diff] [blame] | 98 | mach_reset = m5249_cpu_reset; |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 99 | m5249_timers_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /***************************************************************************/ |
Greg Ungerer | 5f84bd5 | 2008-02-01 17:34:30 +1000 | [diff] [blame] | 103 | |
| 104 | static int __init init_BSP(void) |
| 105 | { |
| 106 | m5249_uarts_init(); |
| 107 | platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices)); |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | arch_initcall(init_BSP); |
| 112 | |
| 113 | /***************************************************************************/ |