Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | /*
* linux/arch/arm/mach-sa1100/system3.c
*
* Copyright (C) 2001 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
*
* $Id: system3.c,v 1.1.6.1 2001/12/04 17:28:06 seletz Exp $
*
* This file contains all PT Sytsem 3 tweaks. Based on original work from
* Nicolas Pitre's assabet fixes
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* $Log: system3.c,v $
* Revision 1.1.6.1 2001/12/04 17:28:06 seletz
* - merged from previous branch
*
* Revision 1.1.4.3 2001/12/04 15:16:31 seletz
* - merged from linux_2_4_13_ac5_rmk2
*
* Revision 1.1.4.2 2001/11/19 17:18:57 seletz
* - more code cleanups
*
* Revision 1.1.4.1 2001/11/16 13:52:05 seletz
* - PT Digital Board Support Code
*
* Revision 1.1.2.2 2001/11/05 16:46:18 seletz
* - cleanups
*
* Revision 1.1.2.1 2001/10/15 16:00:43 seletz
* - first revision working with new board
*
*
*/
#include <linux/config.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/cpufreq.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <asm/hardware.h>
#include <asm/setup.h>
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/irq.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
#include <asm/mach/serial_sa1100.h>
#include <asm/arch/irq.h>
#include <linux/serial_core.h>
#include "generic.h"
#include "sa1111.h"
#define DEBUG 1
#ifdef DEBUG
# define DPRINTK( x, args... ) printk( "%s: line %d: "x, __FUNCTION__, __LINE__, ## args );
#else
# define DPRINTK( x, args... ) /* nix */
#endif
/**********************************************************************
* prototypes
*/
/* init funcs */
static void __init fixup_system3(struct machine_desc *desc,
struct param_struct *params, char **cmdline, struct meminfo *mi);
static void __init get_system3_scr(void);
static int __init system3_init(void);
static void __init system3_init_irq(void);
static void __init system3_map_io(void);
static void system3_IRQ_demux( int irq, void *dev_id, struct pt_regs *regs );
static int system3_get_mctrl(struct uart_port *port);
static void system3_set_mctrl(struct uart_port *port, u_int mctrl);
static void system3_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
static int sdram_notifier(struct notifier_block *nb, unsigned long event, void *data);
extern void convert_to_tag_list(struct param_struct *params, int mem_init);
/**********************************************************************
* global data
*/
/**********************************************************************
* static data
*/
static struct map_desc system3_io_desc[] __initdata = {
/* virtual physical length domain r w c b */
{ 0xe8000000, 0x00000000, 0x01000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash bank 0 */
{ 0xf3000000, 0x10000000, 0x00100000, DOMAIN_IO, 0, 1, 0, 0 }, /* System Registers */
{ 0xf4000000, 0x40000000, 0x00100000, DOMAIN_IO, 0, 1, 0, 0 }, /* SA-1111 */
LAST_DESC
};
static struct sa1100_port_fns system3_port_fns __initdata = {
.set_mctrl = system3_set_mctrl,
.get_mctrl = system3_get_mctrl,
.pm = system3_uart_pm,
};
static struct irqaction system3_irq = {
.name = "PT Digital Board SA1111 IRQ",
.handler = system3_IRQ_demux,
.flags = SA_INTERRUPT
};
static struct notifier_block system3_clkchg_block = {
.notifier_call = sdram_notifier,
};
/**********************************************************************
* Static functions
*/
static void __init system3_map_io(void)
{
DPRINTK( "%s\n", "START" );
sa1100_map_io();
iotable_init(system3_io_desc);
sa1100_register_uart_fns(&system3_port_fns);
sa1100_register_uart(0, 1); /* com port */
sa1100_register_uart(1, 2);
sa1100_register_uart(2, 3); /* radio module */
Ser1SDCR0 |= SDCR0_SUS;
}
/*********************************************************************
* Install IRQ handler
*/
static void system3_IRQ_demux( int irq, void *dev_id, struct pt_regs *regs )
{
u_char irr;
for(;;){
//irr = PTCPLD_REG_IRQSR & (PT_IRQ_LAN | PT_IRQ_USAR | PT_IRQ_SA1111);
irr = PT_IRQSR & (PT_IRQ_LAN | PT_IRQ_SA1111);
irr ^= (PT_IRQ_LAN);
if (!irr) break;
if( irr & PT_IRQ_LAN )
do_IRQ(IRQ_SYSTEM3_SMC9196, regs);
#if 0
/* Highspeed Serial Bus not yet used */
if( irr & PT_IRQ_USAR )
do_IRQ(PT_USAR_IRQ, regs);
#endif
if( irr & PT_IRQ_SA1111 )
sa1111_IRQ_demux(irq, dev_id, regs);
}
}
static void __init system3_init_irq(void)
{
int irq;
DPRINTK( "%s\n", "START" );
/* SA1111 IRQ not routed to a GPIO. */
sa1111_init_irq(-1);
/* setup extra IRQs */
irq = IRQ_SYSTEM3_SMC9196;
irq_desc[irq].valid = 1;
irq_desc[irq].probe_ok = 1;
#if 0
/* Highspeed Serial Bus not yet used */
irq = PT_USAR_IRQ;
irq_desc[irq].valid = 1;
irq_desc[irq].probe_ok = 1;
#endif
/* IRQ by CPLD */
set_GPIO_IRQ_edge( GPIO_GPIO(25), GPIO_RISING_EDGE );
setup_arm_irq( IRQ_GPIO25, &system3_irq );
}
/**********************************************************************
* On system 3 limit cpu frequency to 206 Mhz
*/
static int sdram_notifier(struct notifier_block *nb, unsigned long event,
void *data)
{
switch (event) {
case CPUFREQ_MINMAX:
cpufreq_updateminmax(data, 147500, 206000);
break;
}
return 0;
}
/**
* fixup_system3 - fixup function for system 3 board
* @desc: machine description
* @param: kernel params
* @cmdline: kernel cmdline
* @mi: memory info struct
*
*/
static void __init fixup_system3(struct machine_desc *desc,
struct param_struct *params, char **cmdline, struct meminfo *mi)
{
DPRINTK( "%s\n", "START" );
ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);
setup_ramdisk( 1, 0, 0, 8192 );
setup_initrd( 0xc0800000, 8*1024*1024 );
}
/**
* system3_uart_pm - powermgmt callback function for system 3 UART
* @port: uart port structure
* @state: pm state
* @oldstate: old pm state
*
*/
static void system3_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
{
/* TODO: switch on/off uart in powersave mode */
}
/*
* Note! this can be called from IRQ context.
* FIXME: Handle PT Digital Board CTRL regs irq-safe.
*
* NB: system3 uses COM_RTS and COM_DTR for both UART1 (com port)
* and UART3 (radio module). We only handle them for UART1 here.
*/
static void system3_set_mctrl(struct uart_port *port, u_int mctrl)
{
if (port->mapbase == _Ser1UTCR0) {
u_int set = 0, clear = 0;
if (mctrl & TIOCM_RTS)
set |= PT_CTRL2_RS1_RTS;
else
clear |= PT_CTRL2_RS1_RTS;
if (mctrl & TIOCM_DTR)
set |= PT_CTRL2_RS1_DTR;
else
clear |= PT_CTRL2_RS1_DTR;
PTCTRL2_clear(clear);
PTCTRL2_set(set);
}
}
static int system3_get_mctrl(struct uart_port *port)
{
u_int ret = 0;
u_int irqsr = PT_IRQSR;
/* need 2 reads to read current value */
irqsr = PT_IRQSR;
/* TODO: check IRQ source register for modem/com
status lines and set them correctly. */
ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
return ret;
}
static int __init system3_init(void)
{
int ret = 0;
DPRINTK( "%s\n", "START" );
if ( !machine_is_pt_system3() ) {
ret = -EINVAL;
goto DONE;
}
/* init control register */
PT_CTRL0 = PT_CTRL0_INIT;
PT_CTRL1 = 0x02;
PT_CTRL2 = 0x00;
DPRINTK( "CTRL[0]=0x%02x\n", PT_CTRL0 );
DPRINTK( "CTRL[1]=0x%02x\n", PT_CTRL1 );
DPRINTK( "CTRL[2]=0x%02x\n", PT_CTRL2 );
/*
* Ensure that the memory bus request/grant signals are setup,
* and the grant is held in its inactive state.
*/
sa1110_mb_disable();
/*
* Probe for a SA1111.
*/
ret = sa1111_probe(PT_SA1111_BASE);
if (ret < 0) {
printk( KERN_WARNING"PT Digital Board: no SA1111 found!\n" );
goto DONE;
}
/*
* We found it. Wake the chip up.
*/
sa1111_wake();
/*
* The SDRAM configuration of the SA1110 and the SA1111 must
* match. This is very important to ensure that SA1111 accesses
* don't corrupt the SDRAM. Note that this ungates the SA1111's
* MBGNT signal, so we must have called sa1110_mb_disable()
* beforehand.
*/
sa1111_configure_smc(1,
FExtr(MDCNFG, MDCNFG_SA1110_DRAC0),
FExtr(MDCNFG, MDCNFG_SA1110_TDL0));
/*
* We only need to turn on DCLK whenever we want to use the
* DMA. It can otherwise be held firmly in the off position.
*/
SKPCR |= SKPCR_DCLKEN;
/*
* Enable the SA1110 memory bus request and grant signals.
*/
sa1110_mb_enable();
system3_init_irq();
#if defined( CONFIG_CPU_FREQ )
ret = cpufreq_register_notifier(&system3_clkchg_block);
if ( ret != 0 ) {
printk( KERN_WARNING"PT Digital Board: could not register clock scale callback\n" );
goto DONE;
}
#endif
ret = 0;
DONE:
DPRINTK( "ret=%d\n", ret );
return ret;
}
/**********************************************************************
* Exported Functions
*/
/**********************************************************************
* kernel magic macros
*/
__initcall(system3_init);
MACHINE_START(PT_SYSTEM3, "PT System 3")
BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
BOOT_PARAMS(0xc0000100)
FIXUP(fixup_system3)
MAPIO(system3_map_io)
INITIRQ(sa1100_init_irq)
MACHINE_END
|