Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * linux/arch/arm/mach-sa1100/pleb.c |
| 4 | */ |
| 5 | |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/kernel.h> |
| 8 | #include <linux/tty.h> |
| 9 | #include <linux/ioport.h> |
Russell King | 6920b5a | 2012-09-21 10:18:58 +0100 | [diff] [blame] | 10 | #include <linux/platform_data/sa11x0-serial.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 11 | #include <linux/platform_device.h> |
Thomas Gleixner | 119c641 | 2006-07-01 22:32:38 +0100 | [diff] [blame] | 12 | #include <linux/irq.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 13 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/mtd/partitions.h> |
Arnd Bergmann | b70661c | 2015-02-25 16:31:57 +0100 | [diff] [blame] | 15 | #include <linux/smc91x.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 17 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/setup.h> |
| 19 | #include <asm/mach-types.h> |
| 20 | |
| 21 | #include <asm/mach/arch.h> |
| 22 | #include <asm/mach/map.h> |
| 23 | #include <asm/mach/flash.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 24 | #include <mach/irqs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #include "generic.h" |
| 27 | |
| 28 | |
| 29 | /* |
| 30 | * Ethernet IRQ mappings |
| 31 | */ |
| 32 | |
| 33 | #define PLEB_ETH0_P (0x20000300) /* Ethernet 0 in PCMCIA0 IO */ |
| 34 | #define PLEB_ETH0_V (0xf6000300) |
| 35 | |
| 36 | #define GPIO_ETH0_IRQ GPIO_GPIO(21) |
| 37 | #define GPIO_ETH0_EN GPIO_GPIO(26) |
| 38 | |
| 39 | #define IRQ_GPIO_ETH0_IRQ IRQ_GPIO21 |
| 40 | |
| 41 | static struct resource smc91x_resources[] = { |
Russell King | a181099 | 2012-01-12 10:25:29 +0000 | [diff] [blame] | 42 | [0] = DEFINE_RES_MEM(PLEB_ETH0_P, 0x04000000), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */ |
Russell King | a181099 | 2012-01-12 10:25:29 +0000 | [diff] [blame] | 44 | [1] = DEFINE_RES_IRQ(IRQ_GPIO_ETH0_IRQ), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #endif |
| 46 | }; |
| 47 | |
Arnd Bergmann | b70661c | 2015-02-25 16:31:57 +0100 | [diff] [blame] | 48 | static struct smc91x_platdata smc91x_platdata = { |
Russell King | 2fb04fd | 2016-08-27 17:33:03 +0100 | [diff] [blame] | 49 | .flags = SMC91X_USE_16BIT | SMC91X_USE_8BIT | SMC91X_NOWAIT, |
Arnd Bergmann | b70661c | 2015-02-25 16:31:57 +0100 | [diff] [blame] | 50 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | static struct platform_device smc91x_device = { |
| 53 | .name = "smc91x", |
| 54 | .id = 0, |
| 55 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 56 | .resource = smc91x_resources, |
Arnd Bergmann | b70661c | 2015-02-25 16:31:57 +0100 | [diff] [blame] | 57 | .dev = { |
Arnd Bergmann | 04b9170 | 2015-03-04 23:39:18 +0100 | [diff] [blame] | 58 | .platform_data = &smc91x_platdata, |
Arnd Bergmann | b70661c | 2015-02-25 16:31:57 +0100 | [diff] [blame] | 59 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | static struct platform_device *devices[] __initdata = { |
| 63 | &smc91x_device, |
| 64 | }; |
| 65 | |
| 66 | |
| 67 | /* |
| 68 | * Pleb's memory map |
| 69 | * has flash memory (typically 4 or 8 meg) selected by |
| 70 | * the two SA1100 lowest chip select outputs. |
| 71 | */ |
| 72 | static struct resource pleb_flash_resources[] = { |
Russell King | a181099 | 2012-01-12 10:25:29 +0000 | [diff] [blame] | 73 | [0] = DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_8M), |
| 74 | [1] = DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_8M), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | |
| 78 | static struct mtd_partition pleb_partitions[] = { |
| 79 | { |
| 80 | .name = "blob", |
Kristoffer Ericson | bda0308 | 2008-09-29 17:09:10 +0100 | [diff] [blame] | 81 | .offset = 0, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | .size = 0x00020000, |
| 83 | }, { |
| 84 | .name = "kernel", |
Kristoffer Ericson | bda0308 | 2008-09-29 17:09:10 +0100 | [diff] [blame] | 85 | .offset = MTDPART_OFS_APPEND, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | .size = 0x000e0000, |
| 87 | }, { |
| 88 | .name = "rootfs", |
Kristoffer Ericson | bda0308 | 2008-09-29 17:09:10 +0100 | [diff] [blame] | 89 | .offset = MTDPART_OFS_APPEND, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | .size = 0x00300000, |
| 91 | } |
| 92 | }; |
| 93 | |
| 94 | |
| 95 | static struct flash_platform_data pleb_flash_data = { |
| 96 | .map_name = "cfi_probe", |
| 97 | .parts = pleb_partitions, |
| 98 | .nr_parts = ARRAY_SIZE(pleb_partitions), |
| 99 | }; |
| 100 | |
| 101 | |
| 102 | static void __init pleb_init(void) |
| 103 | { |
Russell King | 7a5b4e1 | 2009-10-06 14:55:53 +0100 | [diff] [blame] | 104 | sa11x0_register_mtd(&pleb_flash_data, pleb_flash_resources, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | ARRAY_SIZE(pleb_flash_resources)); |
| 106 | |
| 107 | |
| 108 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 109 | } |
| 110 | |
| 111 | |
| 112 | static void __init pleb_map_io(void) |
| 113 | { |
| 114 | sa1100_map_io(); |
| 115 | |
| 116 | sa1100_register_uart(0, 3); |
Kristoffer Ericson | 9398253 | 2008-11-26 20:58:43 +0100 | [diff] [blame] | 117 | sa1100_register_uart(1, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | |
Kristoffer Ericson | 9398253 | 2008-11-26 20:58:43 +0100 | [diff] [blame] | 119 | GAFR |= (GPIO_UART_TXD | GPIO_UART_RXD); |
| 120 | GPDR |= GPIO_UART_TXD; |
| 121 | GPDR &= ~GPIO_UART_RXD; |
| 122 | PPAR |= PPAR_UPR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
| 124 | /* |
| 125 | * Fix expansion memory timing for network card |
| 126 | */ |
| 127 | MECR = ((2<<10) | (2<<5) | (2<<0)); |
| 128 | |
| 129 | /* |
| 130 | * Enable the SMC ethernet controller |
| 131 | */ |
| 132 | GPDR |= GPIO_ETH0_EN; /* set to output */ |
| 133 | GPCR = GPIO_ETH0_EN; /* clear MCLK (enable smc) */ |
| 134 | |
| 135 | GPDR &= ~GPIO_ETH0_IRQ; |
| 136 | |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 137 | irq_set_irq_type(GPIO_ETH0_IRQ, IRQ_TYPE_EDGE_FALLING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | MACHINE_START(PLEB, "PLEB") |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 141 | .map_io = pleb_map_io, |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 142 | .nr_irqs = SA1100_NR_IRQS, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 143 | .init_irq = sa1100_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 144 | .init_time = sa1100_timer_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | .init_machine = pleb_init, |
Shawn Guo | 7fea1ba | 2012-04-26 21:22:45 +0800 | [diff] [blame] | 146 | .init_late = sa11x0_init_late, |
Russell King | d9ca583 | 2011-11-05 10:28:50 +0000 | [diff] [blame] | 147 | .restart = sa11x0_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | MACHINE_END |