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