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 | extern unsigned int mcf_timervector; |
| 25 | extern unsigned int mcf_profilevector; |
| 26 | extern unsigned int mcf_timerlevel; |
| 27 | |
| 28 | /***************************************************************************/ |
| 29 | |
| 30 | /* |
| 31 | * Some platforms need software versions of the GPIO data registers. |
| 32 | */ |
| 33 | unsigned short ppdata; |
| 34 | unsigned char ledbank = 0xff; |
| 35 | |
| 36 | /***************************************************************************/ |
| 37 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 38 | static struct mcf_platform_uart m5307_uart_platform[] = { |
| 39 | { |
| 40 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 41 | .irq = 73, |
| 42 | }, |
| 43 | { |
| 44 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 45 | .irq = 74, |
| 46 | }, |
| 47 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 50 | static struct platform_device m5307_uart = { |
| 51 | .name = "mcfuart", |
| 52 | .id = 0, |
| 53 | .dev.platform_data = m5307_uart_platform, |
| 54 | }; |
| 55 | |
| 56 | static struct platform_device *m5307_devices[] __initdata = { |
| 57 | &m5307_uart, |
| 58 | }; |
| 59 | |
| 60 | /***************************************************************************/ |
| 61 | |
| 62 | static void __init m5307_uart_init_line(int line, int irq) |
| 63 | { |
| 64 | if (line == 0) { |
Greg Ungerer | 9242ef1 | 2009-03-24 17:22:05 +1000 | [diff] [blame] | 65 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
| 66 | writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR); |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 67 | mcf_clrimr(MCFINTC_UART0); |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 68 | } else if (line == 1) { |
Greg Ungerer | 9242ef1 | 2009-03-24 17:22:05 +1000 | [diff] [blame] | 69 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR); |
| 70 | writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR); |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 71 | mcf_clrimr(MCFINTC_UART1); |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | |
| 75 | static void __init m5307_uarts_init(void) |
| 76 | { |
| 77 | const int nrlines = ARRAY_SIZE(m5307_uart_platform); |
| 78 | int line; |
| 79 | |
| 80 | for (line = 0; (line < nrlines); line++) |
| 81 | m5307_uart_init_line(line, m5307_uart_platform[line].irq); |
| 82 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
| 84 | /***************************************************************************/ |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | void mcf_settimericr(unsigned int timer, unsigned int level) |
| 87 | { |
| 88 | volatile unsigned char *icrp; |
| 89 | unsigned int icr, imr; |
| 90 | |
| 91 | if (timer <= 2) { |
| 92 | switch (timer) { |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 93 | case 2: icr = MCFSIM_TIMER2ICR; imr = MCFINTC_TIMER2; break; |
| 94 | default: icr = MCFSIM_TIMER1ICR; imr = MCFINTC_TIMER1; break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | icrp = (volatile unsigned char *) (MCF_MBAR + icr); |
| 98 | *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3; |
Greg Ungerer | f2154be | 2009-05-19 14:38:08 +1000 | [diff] [blame] | 99 | mcf_clrimr(imr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | |
| 103 | /***************************************************************************/ |
| 104 | |
Greg Ungerer | c18e52c | 2009-04-30 17:03:09 +1000 | [diff] [blame] | 105 | void m5307_cpu_reset(void) |
| 106 | { |
| 107 | local_irq_disable(); |
| 108 | /* Set watchdog to soft reset, and enabled */ |
| 109 | __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR); |
| 110 | for (;;) |
| 111 | /* wait for watchdog to timeout */; |
| 112 | } |
| 113 | |
| 114 | /***************************************************************************/ |
| 115 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 116 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | { |
Adrian Bunk | 3947fca | 2009-01-13 14:20:01 +1000 | [diff] [blame] | 118 | #if defined(CONFIG_NETtel) || \ |
Greg Ungerer | cff28b5 | 2008-05-01 12:17:21 +1000 | [diff] [blame] | 119 | defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | /* Copy command line from FLASH to local buffer... */ |
| 121 | memcpy(commandp, (char *) 0xf0004000, size); |
| 122 | commandp[size-1] = 0; |
| 123 | /* Different timer setup - to prevent device clash */ |
| 124 | mcf_timervector = 30; |
| 125 | mcf_profilevector = 31; |
| 126 | mcf_timerlevel = 6; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | #endif |
| 128 | |
Greg Ungerer | c18e52c | 2009-04-30 17:03:09 +1000 | [diff] [blame] | 129 | mach_reset = m5307_cpu_reset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 131 | #ifdef CONFIG_BDM_DISABLE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | /* |
| 133 | * Disable the BDM clocking. This also turns off most of the rest of |
| 134 | * the BDM device. This is good for EMC reasons. This option is not |
| 135 | * incompatible with the memory protection option. |
| 136 | */ |
| 137 | wdebug(MCFDEBUG_CSR, MCFDEBUG_CSR_PSTCLK); |
| 138 | #endif |
| 139 | } |
| 140 | |
| 141 | /***************************************************************************/ |
Greg Ungerer | 96db271 | 2008-02-01 17:34:55 +1000 | [diff] [blame] | 142 | |
| 143 | static int __init init_BSP(void) |
| 144 | { |
| 145 | m5307_uarts_init(); |
| 146 | platform_add_devices(m5307_devices, ARRAY_SIZE(m5307_devices)); |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | arch_initcall(init_BSP); |
| 151 | |
| 152 | /***************************************************************************/ |