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>
28 #include <asm/mpc83xx.h>
30 #include <asm/ppc_sys.h>
32 #include <asm/delay.h>
34 #include <syslib/ppc83xx_setup.h>
38 /* Return the amount of memory */
40 mpc83xx_find_end_of_memory(void)
44 binfo = (bd_t *) __res;
46 return binfo->bi_memsize;
50 mpc83xx_time_init(void)
52 #define SPCR_OFFS 0x00000110
53 #define SPCR_TBEN 0x00400000
55 bd_t *binfo = (bd_t *)__res;
56 u32 *spcr = ioremap(binfo->bi_immr_base + SPCR_OFFS, 4);
65 /* The decrementer counts at the system (internal) clock freq divided by 4 */
67 mpc83xx_calibrate_decr(void)
69 bd_t *binfo = (bd_t *) __res;
70 unsigned int freq, divisor;
72 freq = binfo->bi_busfreq;
74 tb_ticks_per_jiffy = freq / HZ / divisor;
75 tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
78 #ifdef CONFIG_SERIAL_8250
80 mpc83xx_early_serial_map(void)
82 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
83 struct uart_port serial_req;
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);
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);
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;
101 gen550_init(0, &serial_req);
104 pdata[1].uartclk = binfo->bi_busfreq;
105 pdata[1].mapbase += binfo->bi_immr_base;
106 pdata[1].membase = ioremap(pdata[1].mapbase, 0x100);
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;
113 gen550_init(1, &serial_req);
119 mpc83xx_restart(char *cmd)
121 volatile unsigned char __iomem *reg;
124 reg = ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
129 * Unlock the BCSR bits so a PRST will update the contents.
130 * Otherwise the reset asserts but doesn't clear.
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);
137 * Trigger a reset via a low->high transition of the
140 tmp = in_8(reg + BCSR_MISC_REG2_OFF);
141 tmp &= ~BCSR_MISC_REG2_PORESET;
142 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
146 tmp |= BCSR_MISC_REG2_PORESET;
147 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
153 mpc83xx_power_off(void)
166 /* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */