blob: 7f86bd911826a4327462d577d43c53031c2fe185 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-sa1100/hackkit.c
3 *
4 * Copyright (C) 2002 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
5 *
6 * This file contains all HackKit tweaks. Based on original work from
7 * Nicolas Pitre's assabet fixes
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/sched.h>
17#include <linux/tty.h>
18#include <linux/module.h>
19#include <linux/errno.h>
20#include <linux/cpufreq.h>
21#include <linux/serial_core.h>
22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h>
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <asm/mach-types.h>
26#include <asm/setup.h>
27#include <asm/page.h>
28#include <asm/pgtable.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30#include <asm/mach/arch.h>
31#include <asm/mach/flash.h>
32#include <asm/mach/map.h>
33#include <asm/mach/irq.h>
34#include <asm/mach/serial_sa1100.h>
35
Rob Herringf314f332012-02-24 00:06:51 +010036#include <mach/hardware.h>
37#include <mach/irqs.h>
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include "generic.h"
40
41/**********************************************************************
42 * prototypes
43 */
44
45/* init funcs */
46static void __init hackkit_map_io(void);
47
48static u_int hackkit_get_mctrl(struct uart_port *port);
49static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl);
50static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
51
52/**********************************************************************
53 * global data
54 */
55
56/**********************************************************************
57 * static data
58 */
59
60static struct map_desc hackkit_io_desc[] __initdata = {
Deepak Saxena92519d82005-10-28 15:19:04 +010061 { /* Flash bank 0 */
62 .virtual = 0xe8000000,
63 .pfn = __phys_to_pfn(0x00000000),
64 .length = 0x01000000,
65 .type = MT_DEVICE
66 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070067};
68
69static struct sa1100_port_fns hackkit_port_fns __initdata = {
70 .set_mctrl = hackkit_set_mctrl,
71 .get_mctrl = hackkit_get_mctrl,
72 .pm = hackkit_uart_pm,
73};
74
75/**********************************************************************
76 * Static functions
77 */
78
79static void __init hackkit_map_io(void)
80{
81 sa1100_map_io();
82 iotable_init(hackkit_io_desc, ARRAY_SIZE(hackkit_io_desc));
83
84 sa1100_register_uart_fns(&hackkit_port_fns);
85 sa1100_register_uart(0, 1); /* com port */
86 sa1100_register_uart(1, 2);
87 sa1100_register_uart(2, 3); /* radio module */
88
89 Ser1SDCR0 |= SDCR0_SUS;
90}
91
92/**
93 * hackkit_uart_pm - powermgmt callback function for system 3 UART
94 * @port: uart port structure
95 * @state: pm state
96 * @oldstate: old pm state
97 *
98 */
99static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
100{
101 /* TODO: switch on/off uart in powersave mode */
102}
103
104/*
105 * Note! this can be called from IRQ context.
106 * FIXME: No modem ctrl lines yet.
107 */
108static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl)
109{
110#if 0
111 if (port->mapbase == _Ser1UTCR0) {
112 u_int set = 0, clear = 0;
113
114 if (mctrl & TIOCM_RTS)
115 set |= PT_CTRL2_RS1_RTS;
116 else
117 clear |= PT_CTRL2_RS1_RTS;
118
119 if (mctrl & TIOCM_DTR)
120 set |= PT_CTRL2_RS1_DTR;
121 else
122 clear |= PT_CTRL2_RS1_DTR;
123
124 PTCTRL2_clear(clear);
125 PTCTRL2_set(set);
126 }
127#endif
128}
129
130static u_int hackkit_get_mctrl(struct uart_port *port)
131{
132 u_int ret = 0;
133#if 0
134 u_int irqsr = PT_IRQSR;
135
136 /* need 2 reads to read current value */
137 irqsr = PT_IRQSR;
138
139 /* TODO: check IRQ source register for modem/com
140 status lines and set them correctly. */
141#endif
142
143 ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
144
145 return ret;
146}
147
148static struct mtd_partition hackkit_partitions[] = {
149 {
150 .name = "BLOB",
151 .size = 0x00040000,
152 .offset = 0x00000000,
153 .mask_flags = MTD_WRITEABLE, /* force read-only */
154 }, {
155 .name = "config",
156 .size = 0x00040000,
157 .offset = MTDPART_OFS_APPEND,
158 }, {
159 .name = "kernel",
160 .size = 0x00100000,
161 .offset = MTDPART_OFS_APPEND,
162 }, {
163 .name = "initrd",
164 .size = 0x00180000,
165 .offset = MTDPART_OFS_APPEND,
166 }, {
167 .name = "rootfs",
168 .size = 0x700000,
169 .offset = MTDPART_OFS_APPEND,
170 }, {
171 .name = "data",
172 .size = MTDPART_SIZ_FULL,
173 .offset = MTDPART_OFS_APPEND,
174 }
175};
176
177static struct flash_platform_data hackkit_flash_data = {
178 .map_name = "cfi_probe",
179 .parts = hackkit_partitions,
180 .nr_parts = ARRAY_SIZE(hackkit_partitions),
181};
182
Russell Kinga1810992012-01-12 10:25:29 +0000183static struct resource hackkit_flash_resource =
184 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186static void __init hackkit_init(void)
187{
Russell King7a5b4e12009-10-06 14:55:53 +0100188 sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189}
190
191/**********************************************************************
192 * Exported Functions
193 */
194
195MACHINE_START(HACKKIT, "HackKit Cpu Board")
Nicolas Pitre17f44252011-07-05 22:38:17 -0400196 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100197 .map_io = hackkit_map_io,
Rob Herringf314f332012-02-24 00:06:51 +0100198 .nr_irqs = SA1100_NR_IRQS,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100199 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 .timer = &sa1100_timer,
201 .init_machine = hackkit_init,
Shawn Guo7fea1ba2012-04-26 21:22:45 +0800202 .init_late = sa11x0_init_late,
Russell Kingd9ca5832011-11-05 10:28:50 +0000203 .restart = sa11x0_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204MACHINE_END