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