Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 1 | /* |
| 2 | * device.c -- common ColdFire SoC device support |
| 3 | * |
| 4 | * (C) Copyright 2011, Greg Ungerer <gerg@uclinux.org> |
| 5 | * |
| 6 | * This file is subject to the terms and conditions of the GNU General Public |
| 7 | * License. See the file COPYING in the main directory of this archive |
| 8 | * for more details. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/io.h> |
| 14 | #include <asm/traps.h> |
| 15 | #include <asm/coldfire.h> |
| 16 | #include <asm/mcfsim.h> |
| 17 | #include <asm/mcfuart.h> |
| 18 | |
Greg Ungerer | b7ce7f0 | 2011-12-24 10:30:36 +1000 | [diff] [blame^] | 19 | /* |
| 20 | * All current ColdFire parts contain from 2, 3 or 4 UARTS. |
| 21 | */ |
Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 22 | static struct mcf_platform_uart mcf_uart_platform_data[] = { |
| 23 | { |
| 24 | .mapbase = MCFUART_BASE0, |
| 25 | .irq = MCF_IRQ_UART0, |
| 26 | }, |
| 27 | { |
| 28 | .mapbase = MCFUART_BASE1, |
| 29 | .irq = MCF_IRQ_UART1, |
| 30 | }, |
| 31 | #ifdef MCFUART_BASE2 |
| 32 | { |
| 33 | .mapbase = MCFUART_BASE2, |
| 34 | .irq = MCF_IRQ_UART2, |
| 35 | }, |
| 36 | #endif |
| 37 | #ifdef MCFUART_BASE3 |
| 38 | { |
| 39 | .mapbase = MCFUART_BASE3, |
| 40 | .irq = MCF_IRQ_UART3, |
| 41 | }, |
| 42 | #endif |
| 43 | { }, |
| 44 | }; |
| 45 | |
| 46 | static struct platform_device mcf_uart = { |
| 47 | .name = "mcfuart", |
| 48 | .id = 0, |
| 49 | .dev.platform_data = mcf_uart_platform_data, |
| 50 | }; |
| 51 | |
Greg Ungerer | b7ce7f0 | 2011-12-24 10:30:36 +1000 | [diff] [blame^] | 52 | #ifdef CONFIG_FEC |
| 53 | /* |
| 54 | * Some ColdFire cores contain the Fast Ethernet Controller (FEC) |
| 55 | * block. It is Freescale's own hardware block. Some ColdFires |
| 56 | * have 2 of these. |
| 57 | */ |
| 58 | static struct resource mcf_fec0_resources[] = { |
| 59 | { |
| 60 | .start = MCFFEC_BASE0, |
| 61 | .end = MCFFEC_BASE0 + MCFFEC_SIZE0 - 1, |
| 62 | .flags = IORESOURCE_MEM, |
| 63 | }, |
| 64 | { |
| 65 | .start = MCF_IRQ_FECRX0, |
| 66 | .end = MCF_IRQ_FECRX0, |
| 67 | .flags = IORESOURCE_IRQ, |
| 68 | }, |
| 69 | { |
| 70 | .start = MCF_IRQ_FECTX0, |
| 71 | .end = MCF_IRQ_FECTX0, |
| 72 | .flags = IORESOURCE_IRQ, |
| 73 | }, |
| 74 | { |
| 75 | .start = MCF_IRQ_FECENTC0, |
| 76 | .end = MCF_IRQ_FECENTC0, |
| 77 | .flags = IORESOURCE_IRQ, |
| 78 | }, |
| 79 | }; |
| 80 | |
| 81 | static struct platform_device mcf_fec0 = { |
| 82 | .name = "fec", |
| 83 | .id = 0, |
| 84 | .num_resources = ARRAY_SIZE(mcf_fec0_resources), |
| 85 | .resource = mcf_fec0_resources, |
| 86 | }; |
| 87 | |
| 88 | #ifdef MCFFEC_BASE1 |
| 89 | static struct resource mcf_fec1_resources[] = { |
| 90 | { |
| 91 | .start = MCFFEC_BASE1, |
| 92 | .end = MCFFEC_BASE1 + MCFFEC_SIZE1 - 1, |
| 93 | .flags = IORESOURCE_MEM, |
| 94 | }, |
| 95 | { |
| 96 | .start = MCF_IRQ_FECRX1, |
| 97 | .end = MCF_IRQ_FECRX1, |
| 98 | .flags = IORESOURCE_IRQ, |
| 99 | }, |
| 100 | { |
| 101 | .start = MCF_IRQ_FECTX1, |
| 102 | .end = MCF_IRQ_FECTX1, |
| 103 | .flags = IORESOURCE_IRQ, |
| 104 | }, |
| 105 | { |
| 106 | .start = MCF_IRQ_FECENTC1, |
| 107 | .end = MCF_IRQ_FECENTC1, |
| 108 | .flags = IORESOURCE_IRQ, |
| 109 | }, |
| 110 | }; |
| 111 | |
| 112 | static struct platform_device mcf_fec1 = { |
| 113 | .name = "fec", |
| 114 | .id = 0, |
| 115 | .num_resources = ARRAY_SIZE(mcf_fec1_resources), |
| 116 | .resource = mcf_fec1_resources, |
| 117 | }; |
| 118 | #endif /* MCFFEC_BASE1 */ |
| 119 | #endif /* CONFIG_FEC */ |
| 120 | |
Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 121 | static struct platform_device *mcf_devices[] __initdata = { |
| 122 | &mcf_uart, |
Greg Ungerer | b7ce7f0 | 2011-12-24 10:30:36 +1000 | [diff] [blame^] | 123 | #ifdef CONFIG_FEC |
| 124 | &mcf_fec0, |
| 125 | #ifdef MCFFEC_BASE1 |
| 126 | &mcf_fec1, |
| 127 | #endif |
| 128 | #endif |
Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 129 | }; |
| 130 | |
Greg Ungerer | 55148f6 | 2011-12-24 01:23:35 +1000 | [diff] [blame] | 131 | |
| 132 | /* |
| 133 | * Some ColdFire UARTs let you set the IRQ line to use. |
| 134 | */ |
| 135 | static void __init mcf_uart_set_irq(void) |
| 136 | { |
| 137 | #ifdef MCFUART_UIVR |
| 138 | /* UART0 interrupt setup */ |
| 139 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR); |
| 140 | writeb(MCF_IRQ_UART0, MCFUART_BASE0 + MCFUART_UIVR); |
| 141 | mcf_mapirq2imr(MCF_IRQ_UART0, MCFINTC_UART0); |
| 142 | |
| 143 | /* UART1 interrupt setup */ |
| 144 | writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR); |
| 145 | writeb(MCF_IRQ_UART1, MCFUART_BASE1 + MCFUART_UIVR); |
| 146 | mcf_mapirq2imr(MCF_IRQ_UART1, MCFINTC_UART1); |
| 147 | #endif |
| 148 | } |
| 149 | |
Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 150 | static int __init mcf_init_devices(void) |
| 151 | { |
Greg Ungerer | 55148f6 | 2011-12-24 01:23:35 +1000 | [diff] [blame] | 152 | mcf_uart_set_irq(); |
Greg Ungerer | 0d2fe94 | 2011-12-24 01:17:10 +1000 | [diff] [blame] | 153 | platform_add_devices(mcf_devices, ARRAY_SIZE(mcf_devices)); |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | arch_initcall(mcf_init_devices); |
| 158 | |