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>
27 #include <asm/mpc83xx.h>
29 #include <asm/ppc_sys.h>
31 #include <asm/delay.h>
33 #include <syslib/ppc83xx_setup.h>
37 /* Return the amount of memory */
39 mpc83xx_find_end_of_memory(void)
43 binfo = (bd_t *) __res;
45 return binfo->bi_memsize;
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);
64 /* The decrementer counts at the system (internal) clock freq divided by 4 */
66 mpc83xx_calibrate_decr(void)
68 bd_t *binfo = (bd_t *) __res;
69 unsigned int freq, divisor;
71 freq = binfo->bi_busfreq;
73 tb_ticks_per_jiffy = freq / HZ / divisor;
74 tb_to_us = mulhwu_scale_factor(freq / divisor, 1000000);
77 #ifdef CONFIG_SERIAL_8250
79 mpc83xx_early_serial_map(void)
81 #if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
82 struct uart_port serial_req;
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);
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);
118 mpc83xx_restart(char *cmd)
120 volatile unsigned char __iomem *reg;
123 reg = ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
128 * Unlock the BCSR bits so a PRST will update the contents.
129 * Otherwise the reset asserts but doesn't clear.
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);
136 * Trigger a reset via a low->high transition of the
139 tmp = in_8(reg + BCSR_MISC_REG2_OFF);
140 tmp &= ~BCSR_MISC_REG2_PORESET;
141 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
145 tmp |= BCSR_MISC_REG2_PORESET;
146 out_8(reg + BCSR_MISC_REG2_OFF, tmp);
152 mpc83xx_power_off(void)
165 /* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */