blob: 602a86891f7fd826cf7b38ab92a899d23f21dc4d [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/time.h>
27#include <asm/mpc83xx.h>
28#include <asm/mmu.h>
29#include <asm/ppc_sys.h>
30#include <asm/kgdb.h>
Kumar Galaf9e4a002005-05-28 15:52:15 -070031#include <asm/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#include <syslib/ppc83xx_setup.h>
34
35phys_addr_t immrbar;
36
37/* Return the amount of memory */
38unsigned long __init
39mpc83xx_find_end_of_memory(void)
40{
41 bd_t *binfo;
42
43 binfo = (bd_t *) __res;
44
45 return binfo->bi_memsize;
46}
47
48long __init
49mpc83xx_time_init(void)
50{
51#define SPCR_OFFS 0x00000110
52#define SPCR_TBEN 0x00400000
53
54 bd_t *binfo = (bd_t *)__res;
55 u32 *spcr = ioremap(binfo->bi_immr_base + SPCR_OFFS, 4);
56
57 *spcr |= SPCR_TBEN;
58
59 iounmap(spcr);
60
61 return 0;
62}
63
64/* The decrementer counts at the system (internal) clock freq divided by 4 */
65void __init
66mpc83xx_calibrate_decr(void)
67{
68 bd_t *binfo = (bd_t *) __res;
69 unsigned int freq, divisor;
70
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);
75}
76
77#ifdef CONFIG_SERIAL_8250
78void __init
79mpc83xx_early_serial_map(void)
80{
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);
87
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);
92
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;
99
100 gen550_init(0, &serial_req);
101#endif
102
103 pdata[1].uartclk = binfo->bi_busfreq;
104 pdata[1].mapbase += binfo->bi_immr_base;
105 pdata[1].membase = ioremap(pdata[1].mapbase, 0x100);
106
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;
111
112 gen550_init(1, &serial_req);
113#endif
114}
115#endif
116
117void
118mpc83xx_restart(char *cmd)
119{
Kumar Galaf9e4a002005-05-28 15:52:15 -0700120 volatile unsigned char __iomem *reg;
121 unsigned char tmp;
122
123 reg = ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 local_irq_disable();
Kumar Galaf9e4a002005-05-28 15:52:15 -0700126
127 /*
128 * Unlock the BCSR bits so a PRST will update the contents.
129 * Otherwise the reset asserts but doesn't clear.
130 */
131 tmp = in_8(reg + BCSR_MISC_REG3_OFF);
132 tmp |= BCSR_MISC_REG3_CNFLOCK; /* low true, high false */
133 out_8(reg + BCSR_MISC_REG3_OFF, tmp);
134
135 /*
136 * Trigger a reset via a low->high transition of the
137 * PORESET bit.
138 */
139 tmp = in_8(reg + BCSR_MISC_REG2_OFF);
140 tmp &= ~BCSR_MISC_REG2_PORESET;
141 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
142
143 udelay(1);
144
145 tmp |= BCSR_MISC_REG2_PORESET;
146 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 for(;;);
149}
150
151void
152mpc83xx_power_off(void)
153{
154 local_irq_disable();
155 for(;;);
156}
157
158void
159mpc83xx_halt(void)
160{
161 local_irq_disable();
162 for(;;);
163}
164
165/* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */