Linux-2.6.12-rc2
[linux-2.6/kvm.git] / arch / ppc / syslib / ppc83xx_setup.c
blobc28f9d679484f348e18c5409141983be5a7fcfe6
1 /*
2 * arch/ppc/syslib/ppc83xx_setup.c
4 * MPC83XX common board code
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com>
8 * Copyright 2005 Freescale Semiconductor Inc.
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
16 #include <linux/config.h>
17 #include <linux/types.h>
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/pci.h>
21 #include <linux/serial.h>
22 #include <linux/tty.h> /* for linux/serial_core.h */
23 #include <linux/serial_core.h>
24 #include <linux/serial_8250.h>
26 #include <asm/prom.h>
27 #include <asm/time.h>
28 #include <asm/mpc83xx.h>
29 #include <asm/mmu.h>
30 #include <asm/ppc_sys.h>
31 #include <asm/kgdb.h>
33 #include <syslib/ppc83xx_setup.h>
35 phys_addr_t immrbar;
37 /* Return the amount of memory */
38 unsigned long __init
39 mpc83xx_find_end_of_memory(void)
41 bd_t *binfo;
43 binfo = (bd_t *) __res;
45 return binfo->bi_memsize;
48 long __init
49 mpc83xx_time_init(void)
51 #define SPCR_OFFS 0x00000110
52 #define SPCR_TBEN 0x00400000
54 bd_t *binfo = (bd_t *)__res;
55 u32 *spcr = ioremap(binfo->bi_immr_base + SPCR_OFFS, 4);
57 *spcr |= SPCR_TBEN;
59 iounmap(spcr);
61 return 0;
64 /* The decrementer counts at the system (internal) clock freq divided by 4 */
65 void __init
66 mpc83xx_calibrate_decr(void)
68 bd_t *binfo = (bd_t *) __res;
69 unsigned int freq, divisor;
71 freq = binfo->bi_busfreq;
72 divisor = 4;
73 tb_ticks_per_jiffy = freq / HZ / divisor;
74 tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
77 #ifdef CONFIG_SERIAL_8250
78 void __init
79 mpc83xx_early_serial_map(void)
81 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
82 struct uart_port serial_req;
83 #endif
84 struct plat_serial8250_port *pdata;
85 bd_t *binfo = (bd_t *) __res;
86 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC83xx_DUART);
88 /* Setup serial port access */
89 pdata[0].uartclk = binfo->bi_busfreq;
90 pdata[0].mapbase += binfo->bi_immr_base;
91 pdata[0].membase = ioremap(pdata[0].mapbase, 0x100);
93 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
94 memset(&serial_req, 0, sizeof (serial_req));
95 serial_req.iotype = SERIAL_IO_MEM;
96 serial_req.mapbase = pdata[0].mapbase;
97 serial_req.membase = pdata[0].membase;
98 serial_req.regshift = 0;
100 gen550_init(0, &serial_req);
101 #endif
103 pdata[1].uartclk = binfo->bi_busfreq;
104 pdata[1].mapbase += binfo->bi_immr_base;
105 pdata[1].membase = ioremap(pdata[1].mapbase, 0x100);
107 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
108 /* Assume gen550_init() doesn't modify serial_req */
109 serial_req.mapbase = pdata[1].mapbase;
110 serial_req.membase = pdata[1].membase;
112 gen550_init(1, &serial_req);
113 #endif
115 #endif
117 void
118 mpc83xx_restart(char *cmd)
120 local_irq_disable();
121 for(;;);
124 void
125 mpc83xx_power_off(void)
127 local_irq_disable();
128 for(;;);
131 void
132 mpc83xx_halt(void)
134 local_irq_disable();
135 for(;;);
138 /* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */