Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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> |
| 32 | |
| 33 | #include <syslib/ppc83xx_setup.h> |
| 34 | |
| 35 | phys_addr_t immrbar; |
| 36 | |
| 37 | /* Return the amount of memory */ |
| 38 | unsigned long __init |
| 39 | mpc83xx_find_end_of_memory(void) |
| 40 | { |
| 41 | bd_t *binfo; |
| 42 | |
| 43 | binfo = (bd_t *) __res; |
| 44 | |
| 45 | return binfo->bi_memsize; |
| 46 | } |
| 47 | |
| 48 | long __init |
| 49 | mpc83xx_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 */ |
| 65 | void __init |
| 66 | mpc83xx_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 |
| 78 | void __init |
| 79 | mpc83xx_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 | |
| 117 | void |
| 118 | mpc83xx_restart(char *cmd) |
| 119 | { |
| 120 | local_irq_disable(); |
| 121 | for(;;); |
| 122 | } |
| 123 | |
| 124 | void |
| 125 | mpc83xx_power_off(void) |
| 126 | { |
| 127 | local_irq_disable(); |
| 128 | for(;;); |
| 129 | } |
| 130 | |
| 131 | void |
| 132 | mpc83xx_halt(void) |
| 133 | { |
| 134 | local_irq_disable(); |
| 135 | for(;;); |
| 136 | } |
| 137 | |
| 138 | /* PCI SUPPORT DOES NOT EXIT, MODEL after ppc85xx_setup.c */ |