Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * linux/arch/arm/mach-sa1100/hackkit.c |
| 4 | * |
| 5 | * Copyright (C) 2002 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de> |
| 6 | * |
| 7 | * This file contains all HackKit tweaks. Based on original work from |
| 8 | * Nicolas Pitre's assabet fixes |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/sched.h> |
| 13 | #include <linux/tty.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/errno.h> |
| 16 | #include <linux/cpufreq.h> |
Russell King | 6920b5a | 2012-09-21 10:18:58 +0100 | [diff] [blame] | 17 | #include <linux/platform_data/sa11x0-serial.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/serial_core.h> |
| 19 | #include <linux/mtd/mtd.h> |
| 20 | #include <linux/mtd/partitions.h> |
Bryan Wu | 18775a7 | 2012-03-14 02:22:03 +0800 | [diff] [blame] | 21 | #include <linux/tty.h> |
| 22 | #include <linux/gpio.h> |
| 23 | #include <linux/leds.h> |
| 24 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/mach-types.h> |
| 27 | #include <asm/setup.h> |
| 28 | #include <asm/page.h> |
| 29 | #include <asm/pgtable.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | #include <asm/mach/arch.h> |
| 32 | #include <asm/mach/flash.h> |
| 33 | #include <asm/mach/map.h> |
| 34 | #include <asm/mach/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 36 | #include <mach/hardware.h> |
| 37 | #include <mach/irqs.h> |
| 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include "generic.h" |
| 40 | |
| 41 | /********************************************************************** |
| 42 | * prototypes |
| 43 | */ |
| 44 | |
| 45 | /* init funcs */ |
| 46 | static void __init hackkit_map_io(void); |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate); |
| 49 | |
| 50 | /********************************************************************** |
| 51 | * global data |
| 52 | */ |
| 53 | |
| 54 | /********************************************************************** |
| 55 | * static data |
| 56 | */ |
| 57 | |
| 58 | static struct map_desc hackkit_io_desc[] __initdata = { |
Deepak Saxena | 92519d8 | 2005-10-28 15:19:04 +0100 | [diff] [blame] | 59 | { /* Flash bank 0 */ |
| 60 | .virtual = 0xe8000000, |
| 61 | .pfn = __phys_to_pfn(0x00000000), |
| 62 | .length = 0x01000000, |
| 63 | .type = MT_DEVICE |
| 64 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | static struct sa1100_port_fns hackkit_port_fns __initdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | .pm = hackkit_uart_pm, |
| 69 | }; |
| 70 | |
| 71 | /********************************************************************** |
| 72 | * Static functions |
| 73 | */ |
| 74 | |
| 75 | static void __init hackkit_map_io(void) |
| 76 | { |
| 77 | sa1100_map_io(); |
| 78 | iotable_init(hackkit_io_desc, ARRAY_SIZE(hackkit_io_desc)); |
| 79 | |
| 80 | sa1100_register_uart_fns(&hackkit_port_fns); |
| 81 | sa1100_register_uart(0, 1); /* com port */ |
| 82 | sa1100_register_uart(1, 2); |
| 83 | sa1100_register_uart(2, 3); /* radio module */ |
| 84 | |
| 85 | Ser1SDCR0 |= SDCR0_SUS; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * hackkit_uart_pm - powermgmt callback function for system 3 UART |
| 90 | * @port: uart port structure |
| 91 | * @state: pm state |
| 92 | * @oldstate: old pm state |
| 93 | * |
| 94 | */ |
| 95 | static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate) |
| 96 | { |
| 97 | /* TODO: switch on/off uart in powersave mode */ |
| 98 | } |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | static struct mtd_partition hackkit_partitions[] = { |
| 101 | { |
| 102 | .name = "BLOB", |
| 103 | .size = 0x00040000, |
| 104 | .offset = 0x00000000, |
| 105 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 106 | }, { |
| 107 | .name = "config", |
| 108 | .size = 0x00040000, |
| 109 | .offset = MTDPART_OFS_APPEND, |
| 110 | }, { |
| 111 | .name = "kernel", |
| 112 | .size = 0x00100000, |
| 113 | .offset = MTDPART_OFS_APPEND, |
| 114 | }, { |
| 115 | .name = "initrd", |
| 116 | .size = 0x00180000, |
| 117 | .offset = MTDPART_OFS_APPEND, |
| 118 | }, { |
| 119 | .name = "rootfs", |
| 120 | .size = 0x700000, |
| 121 | .offset = MTDPART_OFS_APPEND, |
| 122 | }, { |
| 123 | .name = "data", |
| 124 | .size = MTDPART_SIZ_FULL, |
| 125 | .offset = MTDPART_OFS_APPEND, |
| 126 | } |
| 127 | }; |
| 128 | |
| 129 | static struct flash_platform_data hackkit_flash_data = { |
| 130 | .map_name = "cfi_probe", |
| 131 | .parts = hackkit_partitions, |
| 132 | .nr_parts = ARRAY_SIZE(hackkit_partitions), |
| 133 | }; |
| 134 | |
Russell King | a181099 | 2012-01-12 10:25:29 +0000 | [diff] [blame] | 135 | static struct resource hackkit_flash_resource = |
| 136 | DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | |
Bryan Wu | 18775a7 | 2012-03-14 02:22:03 +0800 | [diff] [blame] | 138 | /* LEDs */ |
| 139 | struct gpio_led hackkit_gpio_leds[] = { |
| 140 | { |
| 141 | .name = "hackkit:red", |
| 142 | .default_trigger = "cpu0", |
| 143 | .gpio = 22, |
| 144 | }, |
| 145 | { |
| 146 | .name = "hackkit:green", |
| 147 | .default_trigger = "heartbeat", |
| 148 | .gpio = 23, |
| 149 | }, |
| 150 | }; |
| 151 | |
| 152 | static struct gpio_led_platform_data hackkit_gpio_led_info = { |
| 153 | .leds = hackkit_gpio_leds, |
| 154 | .num_leds = ARRAY_SIZE(hackkit_gpio_leds), |
| 155 | }; |
| 156 | |
| 157 | static struct platform_device hackkit_leds = { |
| 158 | .name = "leds-gpio", |
| 159 | .id = -1, |
| 160 | .dev = { |
| 161 | .platform_data = &hackkit_gpio_led_info, |
| 162 | } |
| 163 | }; |
| 164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | static void __init hackkit_init(void) |
| 166 | { |
Russell King | 7a5b4e1 | 2009-10-06 14:55:53 +0100 | [diff] [blame] | 167 | sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1); |
Bryan Wu | 18775a7 | 2012-03-14 02:22:03 +0800 | [diff] [blame] | 168 | platform_device_register(&hackkit_leds); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /********************************************************************** |
| 172 | * Exported Functions |
| 173 | */ |
| 174 | |
| 175 | MACHINE_START(HACKKIT, "HackKit Cpu Board") |
Nicolas Pitre | 17f4425 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 176 | .atag_offset = 0x100, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 177 | .map_io = hackkit_map_io, |
Rob Herring | f314f33 | 2012-02-24 00:06:51 +0100 | [diff] [blame] | 178 | .nr_irqs = SA1100_NR_IRQS, |
Russell King | e9dea0c | 2005-07-03 17:38:58 +0100 | [diff] [blame] | 179 | .init_irq = sa1100_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 180 | .init_time = sa1100_timer_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | .init_machine = hackkit_init, |
Shawn Guo | 7fea1ba | 2012-04-26 21:22:45 +0800 | [diff] [blame] | 182 | .init_late = sa11x0_init_late, |
Russell King | d9ca583 | 2011-11-05 10:28:50 +0000 | [diff] [blame] | 183 | .restart = sa11x0_restart, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | MACHINE_END |