Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
| 4 | * linux/arch/m68knommu/platform/5272/config.c |
| 5 | * |
| 6 | * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com) |
| 7 | * Copyright (C) 2001-2002, SnapGear Inc. (www.snapgear.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 | 84e6def | 2008-02-01 17:34:32 +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 | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 19 | #include <asm/mcfuart.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | /***************************************************************************/ |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* |
| 24 | * Some platforms need software versions of the GPIO data registers. |
| 25 | */ |
| 26 | unsigned short ppdata; |
| 27 | unsigned char ledbank = 0xff; |
| 28 | |
| 29 | /***************************************************************************/ |
| 30 | |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 31 | static struct mcf_platform_uart m5272_uart_platform[] = { |
| 32 | { |
| 33 | .mapbase = MCF_MBAR + MCFUART_BASE1, |
| 34 | .irq = 73, |
| 35 | }, |
| 36 | { |
| 37 | .mapbase = MCF_MBAR + MCFUART_BASE2, |
| 38 | .irq = 74, |
| 39 | }, |
| 40 | { }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 43 | static struct platform_device m5272_uart = { |
| 44 | .name = "mcfuart", |
| 45 | .id = 0, |
| 46 | .dev.platform_data = m5272_uart_platform, |
| 47 | }; |
| 48 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 49 | static struct resource m5272_fec_resources[] = { |
| 50 | { |
| 51 | .start = MCF_MBAR + 0x840, |
| 52 | .end = MCF_MBAR + 0x840 + 0x1cf, |
| 53 | .flags = IORESOURCE_MEM, |
| 54 | }, |
| 55 | { |
| 56 | .start = 86, |
| 57 | .end = 86, |
| 58 | .flags = IORESOURCE_IRQ, |
| 59 | }, |
| 60 | { |
| 61 | .start = 87, |
| 62 | .end = 87, |
| 63 | .flags = IORESOURCE_IRQ, |
| 64 | }, |
| 65 | { |
| 66 | .start = 88, |
| 67 | .end = 88, |
| 68 | .flags = IORESOURCE_IRQ, |
| 69 | }, |
| 70 | }; |
| 71 | |
| 72 | static struct platform_device m5272_fec = { |
| 73 | .name = "fec", |
| 74 | .id = 0, |
| 75 | .num_resources = ARRAY_SIZE(m5272_fec_resources), |
| 76 | .resource = m5272_fec_resources, |
| 77 | }; |
| 78 | |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 79 | static struct platform_device *m5272_devices[] __initdata = { |
| 80 | &m5272_uart, |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 81 | &m5272_fec, |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | /***************************************************************************/ |
| 85 | |
| 86 | static void __init m5272_uart_init_line(int line, int irq) |
| 87 | { |
| 88 | u32 v; |
| 89 | |
| 90 | if ((line >= 0) && (line < 2)) { |
| 91 | v = (line) ? 0x0e000000 : 0xe0000000; |
| 92 | writel(v, MCF_MBAR + MCFSIM_ICR2); |
| 93 | |
| 94 | /* Enable the output lines for the serial ports */ |
| 95 | v = readl(MCF_MBAR + MCFSIM_PBCNT); |
| 96 | v = (v & ~0x000000ff) | 0x00000055; |
| 97 | writel(v, MCF_MBAR + MCFSIM_PBCNT); |
| 98 | |
| 99 | v = readl(MCF_MBAR + MCFSIM_PDCNT); |
| 100 | v = (v & ~0x000003fc) | 0x000002a8; |
| 101 | writel(v, MCF_MBAR + MCFSIM_PDCNT); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | static void __init m5272_uarts_init(void) |
| 106 | { |
| 107 | const int nrlines = ARRAY_SIZE(m5272_uart_platform); |
| 108 | int line; |
| 109 | |
| 110 | for (line = 0; (line < nrlines); line++) |
| 111 | m5272_uart_init_line(line, m5272_uart_platform[line].irq); |
| 112 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | /***************************************************************************/ |
| 115 | |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 116 | static void __init m5272_fec_init(void) |
| 117 | { |
| 118 | u32 imr; |
| 119 | |
| 120 | /* Unmask FEC interrupts at ColdFire interrupt controller */ |
| 121 | imr = readl(MCF_MBAR + MCFSIM_ICR3); |
| 122 | imr = (imr & ~0x00000fff) | 0x00000ddd; |
| 123 | writel(imr, MCF_MBAR + MCFSIM_ICR3); |
| 124 | |
| 125 | imr = readl(MCF_MBAR + MCFSIM_ICR1); |
| 126 | imr = (imr & ~0x0f000000) | 0x0d000000; |
| 127 | writel(imr, MCF_MBAR + MCFSIM_ICR1); |
| 128 | } |
| 129 | |
| 130 | /***************************************************************************/ |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | void mcf_disableall(void) |
| 133 | { |
| 134 | volatile unsigned long *icrp; |
| 135 | |
| 136 | icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); |
| 137 | icrp[0] = 0x88888888; |
| 138 | icrp[1] = 0x88888888; |
| 139 | icrp[2] = 0x88888888; |
| 140 | icrp[3] = 0x88888888; |
| 141 | } |
| 142 | |
| 143 | /***************************************************************************/ |
| 144 | |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 145 | static void __init m5272_timers_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | { |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 147 | /* Timer1 @ level6 is always used as system timer */ |
| 148 | writel((0x8 | 0x6) << ((4 - 1) * 4), MCF_MBAR + MCFSIM_ICR1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 150 | #ifdef CONFIG_HIGHPROFILE |
| 151 | /* Timer2 @ level7 is to be used as a high speed profile timer */ |
| 152 | writel((0x8 | 0x7) << ((4 - 2) * 4), MCF_MBAR + MCFSIM_ICR1); |
| 153 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | /***************************************************************************/ |
| 157 | |
Greg Ungerer | 05728ae | 2009-04-30 23:32:52 +1000 | [diff] [blame] | 158 | static void m5272_cpu_reset(void) |
| 159 | { |
| 160 | local_irq_disable(); |
| 161 | /* Set watchdog to reset, and enabled */ |
| 162 | __raw_writew(0, MCF_MBAR + MCFSIM_WIRR); |
| 163 | __raw_writew(1, MCF_MBAR + MCFSIM_WRRR); |
| 164 | __raw_writew(0, MCF_MBAR + MCFSIM_WCR); |
| 165 | for (;;) |
| 166 | /* wait for watchdog to timeout */; |
| 167 | } |
| 168 | |
| 169 | /***************************************************************************/ |
| 170 | |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 171 | void __init config_BSP(char *commandp, int size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | { |
Greg Ungerer | a796266 | 2005-09-09 09:32:14 +1000 | [diff] [blame] | 173 | #if defined (CONFIG_MOD5272) |
| 174 | volatile unsigned char *pivrp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
| 176 | /* Set base of device vectors to be 64 */ |
Greg Ungerer | a796266 | 2005-09-09 09:32:14 +1000 | [diff] [blame] | 177 | pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | *pivrp = 0x40; |
| 179 | #endif |
| 180 | |
| 181 | mcf_disableall(); |
| 182 | |
Greg Ungerer | bc72450 | 2007-07-25 22:07:20 +1000 | [diff] [blame] | 183 | #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | /* Copy command line from FLASH to local buffer... */ |
| 185 | memcpy(commandp, (char *) 0xf0004000, size); |
| 186 | commandp[size-1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | #elif defined(CONFIG_CANCam) |
| 188 | /* Copy command line from FLASH to local buffer... */ |
| 189 | memcpy(commandp, (char *) 0xf0010000, size); |
| 190 | commandp[size-1] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | #endif |
| 192 | |
Greg Ungerer | 05728ae | 2009-04-30 23:32:52 +1000 | [diff] [blame] | 193 | mach_reset = m5272_cpu_reset; |
Greg Ungerer | 04b75b1 | 2009-05-19 14:52:40 +1000 | [diff] [blame^] | 194 | m5272_timers_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /***************************************************************************/ |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 198 | |
| 199 | static int __init init_BSP(void) |
| 200 | { |
| 201 | m5272_uarts_init(); |
Greg Ungerer | ffba3f4 | 2009-02-26 22:40:38 -0800 | [diff] [blame] | 202 | m5272_fec_init(); |
Greg Ungerer | 84e6def | 2008-02-01 17:34:32 +1000 | [diff] [blame] | 203 | platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices)); |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | arch_initcall(init_BSP); |
| 208 | |
| 209 | /***************************************************************************/ |