Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-sa1100/hackkit.c
0004  *
0005  * Copyright (C) 2002 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
0006  *
0007  * This file contains all HackKit tweaks. Based on original work from
0008  * Nicolas Pitre's assabet fixes
0009  */
0010 #include <linux/init.h>
0011 #include <linux/kernel.h>
0012 #include <linux/sched.h>
0013 #include <linux/tty.h>
0014 #include <linux/module.h>
0015 #include <linux/errno.h>
0016 #include <linux/cpufreq.h>
0017 #include <linux/platform_data/sa11x0-serial.h>
0018 #include <linux/serial_core.h>
0019 #include <linux/mtd/mtd.h>
0020 #include <linux/mtd/partitions.h>
0021 #include <linux/tty.h>
0022 #include <linux/gpio.h>
0023 #include <linux/leds.h>
0024 #include <linux/platform_device.h>
0025 #include <linux/pgtable.h>
0026 
0027 #include <asm/mach-types.h>
0028 #include <asm/setup.h>
0029 #include <asm/page.h>
0030 
0031 #include <asm/mach/arch.h>
0032 #include <asm/mach/flash.h>
0033 #include <asm/mach/map.h>
0034 #include <asm/mach/irq.h>
0035 
0036 #include <mach/hardware.h>
0037 #include <mach/irqs.h>
0038 
0039 #include "generic.h"
0040 
0041 /**********************************************************************
0042  *  prototypes
0043  */
0044 
0045 /* init funcs */
0046 static void __init hackkit_map_io(void);
0047 
0048 static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
0049 
0050 /**********************************************************************
0051  *  global data
0052  */
0053 
0054 /**********************************************************************
0055  *  static data
0056  */
0057 
0058 static struct map_desc hackkit_io_desc[] __initdata = {
0059     {   /* Flash bank 0 */
0060         .virtual    =  0xe8000000,
0061         .pfn        = __phys_to_pfn(0x00000000),
0062         .length     = 0x01000000,
0063         .type       = MT_DEVICE
0064     },
0065 };
0066 
0067 static struct sa1100_port_fns hackkit_port_fns __initdata = {
0068     .pm     = hackkit_uart_pm,
0069 };
0070 
0071 /**********************************************************************
0072  *  Static functions
0073  */
0074 
0075 static void __init hackkit_map_io(void)
0076 {
0077     sa1100_map_io();
0078     iotable_init(hackkit_io_desc, ARRAY_SIZE(hackkit_io_desc));
0079 
0080     sa1100_register_uart_fns(&hackkit_port_fns);
0081     sa1100_register_uart(0, 1); /* com port */
0082     sa1100_register_uart(1, 2);
0083     sa1100_register_uart(2, 3); /* radio module */
0084 
0085     Ser1SDCR0 |= SDCR0_SUS;
0086 }
0087 
0088 /**
0089  *  hackkit_uart_pm - powermgmt callback function for system 3 UART
0090  *  @port: uart port structure
0091  *  @state: pm state
0092  *  @oldstate: old pm state
0093  *
0094  */
0095 static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
0096 {
0097     /* TODO: switch on/off uart in powersave mode */
0098 }
0099 
0100 static struct mtd_partition hackkit_partitions[] = {
0101     {
0102         .name       = "BLOB",
0103         .size       = 0x00040000,
0104         .offset     = 0x00000000,
0105         .mask_flags = MTD_WRITEABLE,  /* force read-only */
0106     }, {
0107         .name       = "config",
0108         .size       = 0x00040000,
0109         .offset     = MTDPART_OFS_APPEND,
0110     }, {
0111         .name       = "kernel",
0112         .size       = 0x00100000,
0113         .offset     = MTDPART_OFS_APPEND,
0114     }, {
0115         .name       = "initrd",
0116         .size       = 0x00180000,
0117         .offset     = MTDPART_OFS_APPEND,
0118     }, {
0119         .name       = "rootfs",
0120         .size       = 0x700000,
0121         .offset     = MTDPART_OFS_APPEND,
0122     }, {
0123         .name       = "data",
0124         .size       = MTDPART_SIZ_FULL,
0125         .offset     = MTDPART_OFS_APPEND,
0126     }
0127 };
0128 
0129 static struct flash_platform_data hackkit_flash_data = {
0130     .map_name   = "cfi_probe",
0131     .parts      = hackkit_partitions,
0132     .nr_parts   = ARRAY_SIZE(hackkit_partitions),
0133 };
0134 
0135 static struct resource hackkit_flash_resource =
0136     DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
0137 
0138 /* LEDs */
0139 struct gpio_led hackkit_gpio_leds[] = {
0140     {
0141         .name           = "hackkit:red",
0142         .default_trigger    = "cpu0",
0143         .gpio           = 22,
0144     },
0145     {
0146         .name           = "hackkit:green",
0147         .default_trigger    = "heartbeat",
0148         .gpio           = 23,
0149     },
0150 };
0151 
0152 static struct gpio_led_platform_data hackkit_gpio_led_info = {
0153     .leds       = hackkit_gpio_leds,
0154     .num_leds   = ARRAY_SIZE(hackkit_gpio_leds),
0155 };
0156 
0157 static struct platform_device hackkit_leds = {
0158     .name   = "leds-gpio",
0159     .id = -1,
0160     .dev    = {
0161         .platform_data  = &hackkit_gpio_led_info,
0162     }
0163 };
0164 
0165 static void __init hackkit_init(void)
0166 {
0167     sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1);
0168     platform_device_register(&hackkit_leds);
0169 }
0170 
0171 /**********************************************************************
0172  *  Exported Functions
0173  */
0174 
0175 MACHINE_START(HACKKIT, "HackKit Cpu Board")
0176     .atag_offset    = 0x100,
0177     .map_io     = hackkit_map_io,
0178     .nr_irqs    = SA1100_NR_IRQS,
0179     .init_irq   = sa1100_init_irq,
0180     .init_time  = sa1100_timer_init,
0181     .init_machine   = hackkit_init,
0182     .init_late  = sa11x0_init_late,
0183     .restart    = sa11x0_restart,
0184 MACHINE_END