Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/5307/config.c |
| 5 | * |
| 6 | * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com) |
| 7 | * Copyright (C) 2000, Lineo (www.lineo.com) |
| 8 | */ |
| 9 | |
| 10 | /***************************************************************************/ |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/param.h> |
| 14 | #include <linux/init.h> |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 15 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/machdep.h> |
| 17 | #include <asm/coldfire.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/mcfsim.h> |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 19 | #include <asm/mcfuart.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include <asm/mcfwdebug.h> |
| 21 | |
| 22 | /***************************************************************************/ |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | /* |
| 25 | * Some platforms need software versions of the GPIO data registers. |
| 26 | */ |
| 27 | unsigned short ppdata; |
| 28 | unsigned char ledbank = 0xff; |
| 29 | |
| 30 | /***************************************************************************/ |
| 31 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 32 | static struct mcf_platform_uart m5307_uart_platform[] = { |
| 33 | { |
| 34 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 35 | .irq = 73, |
| 36 | }, |
| 37 | { |
| 38 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 39 | .irq = 74, |
| 40 | }, |
| 41 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 44 | static struct platform_device m5307_uart = { |
| 45 | .name = "mcfuart", |
| 46 | .id = 0, |
| 47 | .dev.platform_data = m5307_uart_platform, |
| 48 | }; |
| 49 | |
| 50 | static struct platform_device *m5307_devices[] __initdata = { |
| 51 | &m5307_uart, |
| 52 | }; |
| 53 | |
| 54 | /***************************************************************************/ |
| 55 | |
| 56 | static void __init m5307_uart_init_line(int line, int irq) |
| 57 | { |
| 58 | if (line == 0) { |
Greg Ungerer | 9242ef1 | 2009-03-24 17:22:05 +1000 | [diff] [blame] | 59 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
| 60 | writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR); |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 61 | mcf_clrimr(MCFINTC_UART0); |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 62 | } else if (line == 1) { |
Greg Ungerer | 9242ef1 | 2009-03-24 17:22:05 +1000 | [diff] [blame] | 63 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR); |
| 64 | writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR); |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 65 | mcf_clrimr(MCFINTC_UART1); |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | |
| 69 | static void __init m5307_uarts_init(void) |
| 70 | { |
| 71 | const int nrlines = ARRAY_SIZE(m5307_uart_platform); |
| 72 | int line; |
| 73 | |
| 74 | for (line = 0; (line < nrlines); line++) |
| 75 | m5307_uart_init_line(line, m5307_uart_platform[line].irq); |
| 76 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
| 78 | /***************************************************************************/ |
| 79 | |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 80 | static void __init m5307_timers_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | { |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 82 | /* Timer1 is always used as system timer */ |
| 83 | writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI3, |
| 84 | MCF_MBAR + MCFSIM_TIMER1ICR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 86 | #ifdef CONFIG_HIGHPROFILE |
| 87 | /* Timer2 is to be used as a high speed profile timer */ |
| 88 | writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL7 | MCFSIM_ICR_PRI3, |
| 89 | MCF_MBAR + MCFSIM_TIMER2ICR); |
| 90 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | /***************************************************************************/ |
| 94 | |
Greg Ungerer | c18e52c | 2009-04-30 17:03:09 +1000 | [diff] [blame] | 95 | void m5307_cpu_reset(void) |
| 96 | { |
| 97 | local_irq_disable(); |
| 98 | /* Set watchdog to soft reset, and enabled */ |
| 99 | __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR); |
| 100 | for (;;) |
| 101 | /* wait for watchdog to timeout */; |
| 102 | } |
| 103 | |
| 104 | /***************************************************************************/ |
| 105 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 106 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
Adrian Bunk | 3947fca | 2009-01-13 14:20:01 +1000 | [diff] [blame] | 108 | #if defined(CONFIG_NETtel) || \ |
Greg Ungerer | cff28b5 | 2008-05-01 12:17:21 +1000 | [diff] [blame] | 109 | defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | /* Copy command line from FLASH to local buffer... */ |
| 111 | memcpy(commandp, (char *) 0xf0004000, size); |
| 112 | commandp[size-1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | #endif |
| 114 | |
Greg Ungerer | c18e52c | 2009-04-30 17:03:09 +1000 | [diff] [blame] | 115 | mach_reset = m5307_cpu_reset; |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 116 | m5307_timers_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 118 | #ifdef CONFIG_BDM_DISABLE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | /* |
| 120 | * Disable the BDM clocking. This also turns off most of the rest of |
| 121 | * the BDM device. This is good for EMC reasons. This option is not |
| 122 | * incompatible with the memory protection option. |
| 123 | */ |
| 124 | wdebug(MCFDEBUG_CSR, MCFDEBUG_CSR_PSTCLK); |
| 125 | #endif |
| 126 | } |
| 127 | |
| 128 | /***************************************************************************/ |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 129 | |
| 130 | static int __init init_BSP(void) |
| 131 | { |
| 132 | m5307_uarts_init(); |
| 133 | platform_add_devices(m5307_devices, ARRAY_SIZE(m5307_devices)); |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | arch_initcall(init_BSP); |
| 138 | |
| 139 | /***************************************************************************/ |