blob: 843cf8873e60f35376b80e2cda72839ee99fb35a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/ppc/syslib/ppc83xx_setup.c
3 *
4 * MPC83XX common board code
5 *
6 * Maintainer: Kumar Gala <kumar.gala@freescale.com>
7 *
8 * Copyright 2005 Freescale Semiconductor Inc.
9 *
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.
14 */
15
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>
25
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>
Kumar Galaf9e4a002005-05-28 15:52:15 -070032#include <asm/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34#include <syslib/ppc83xx_setup.h>
35
36phys_addr_t immrbar;
37
38/* Return the amount of memory */
39unsigned long __init
40mpc83xx_find_end_of_memory(void)
41{
42 bd_t *binfo;
43
44 binfo = (bd_t *) __res;
45
46 return binfo->bi_memsize;
47}
48
49long __init
50mpc83xx_time_init(void)
51{
52#define SPCR_OFFS 0x00000110
53#define SPCR_TBEN 0x00400000
54
55 bd_t *binfo = (bd_t *)__res;
56 u32 *spcr = ioremap(binfo->bi_immr_base + SPCR_OFFS, 4);
57
58 *spcr |= SPCR_TBEN;
59
60 iounmap(spcr);
61
62 return 0;
63}
64
65/* The decrementer counts at the system (internal) clock freq divided by 4 */
66void __init
67mpc83xx_calibrate_decr(void)
68{
69 bd_t *binfo = (bd_t *) __res;
70 unsigned int freq, divisor;
71
72 freq = binfo->bi_busfreq;
73 divisor = 4;
74 tb_ticks_per_jiffy = freq / HZ / divisor;
75 tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
76}
77
78#ifdef CONFIG_SERIAL_8250
79void __init
80mpc83xx_early_serial_map(void)
81{
82#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
83 struct uart_port serial_req;
84#endif
85 struct plat_serial8250_port *pdata;
86 bd_t *binfo = (bd_t *) __res;
87 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(MPC83xx_DUART);
88
89 /* Setup serial port access */
90 pdata[0].uartclk = binfo->bi_busfreq;
91 pdata[0].mapbase += binfo->bi_immr_base;
92 pdata[0].membase = ioremap(pdata[0].mapbase, 0x100);
93
94#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
95 memset(&serial_req, 0, sizeof (serial_req));
96 serial_req.iotype = SERIAL_IO_MEM;
97 serial_req.mapbase = pdata[0].mapbase;
98 serial_req.membase = pdata[0].membase;
99 serial_req.regshift = 0;
100
101 gen550_init(0, &serial_req);
102#endif
103
104 pdata[1].uartclk = binfo->bi_busfreq;
105 pdata[1].mapbase += binfo->bi_immr_base;
106 pdata[1].membase = ioremap(pdata[1].mapbase, 0x100);
107
108#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
109 /* Assume gen550_init() doesn't modify serial_req */
110 serial_req.mapbase = pdata[1].mapbase;
111 serial_req.membase = pdata[1].membase;
112
113 gen550_init(1, &serial_req);
114#endif
115}
116#endif
117
118void
119mpc83xx_restart(char *cmd)
120{
Kumar Galaf9e4a002005-05-28 15:52:15 -0700121 volatile unsigned char __iomem *reg;
122 unsigned char tmp;
123
124 reg = ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 local_irq_disable();
Kumar Galaf9e4a002005-05-28 15:52:15 -0700127
128 /*
129 * Unlock the BCSR bits so a PRST will update the contents.
130 * Otherwise the reset asserts but doesn't clear.
131 */
132 tmp = in_8(reg + BCSR_MISC_REG3_OFF);
133 tmp |= BCSR_MISC_REG3_CNFLOCK; /* low true, high false */
134 out_8(reg + BCSR_MISC_REG3_OFF, tmp);
135
136 /*
137 * Trigger a reset via a low->high transition of the
138 * PORESET bit.
139 */
140 tmp = in_8(reg + BCSR_MISC_REG2_OFF);
141 tmp &= ~BCSR_MISC_REG2_PORESET;
142 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
143
144 udelay(1);
145
146 tmp |= BCSR_MISC_REG2_PORESET;
147 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 for(;;);
150}
151
152void
153mpc83xx_power_off(void)
154{
155 local_irq_disable();
156 for(;;);
157}
158
159void
160mpc83xx_halt(void)
161{
162 local_irq_disable();
163 for(;;);
164}
165
166/* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */