| 1 | /* |
| 2 | * linux/arch/mips/jz4740/common/setup.c |
| 3 | * |
| 4 | * JZ4740 common setup routines. |
| 5 | * |
| 6 | * Copyright (C) 2006 Ingenic Semiconductor Inc. |
| 7 | * |
| 8 | * This program is free software; you can distribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License (Version 2) as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 | * for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. |
| 20 | * |
| 21 | */ |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/io.h> |
| 26 | #include <linux/ioport.h> |
| 27 | #include <linux/tty.h> |
| 28 | #include <linux/serial.h> |
| 29 | #include <linux/serial_core.h> |
| 30 | #include <linux/serial_8250.h> |
| 31 | |
| 32 | #include <asm/cpu.h> |
| 33 | #include <asm/bootinfo.h> |
| 34 | #include <asm/irq.h> |
| 35 | #include <asm/mipsregs.h> |
| 36 | #include <asm/reboot.h> |
| 37 | #include <asm/pgtable.h> |
| 38 | #include <asm/time.h> |
| 39 | #include <asm/mach-jz4740/jz4740.h> |
| 40 | #include <asm/mach-jz4740/regs.h> |
| 41 | #include <asm/mach-jz4740/clock.h> |
| 42 | |
| 43 | #include "clock.h" |
| 44 | |
| 45 | extern char *__init prom_getcmdline(void); |
| 46 | extern void jz_restart(char *); |
| 47 | extern void jz_halt(void); |
| 48 | extern void jz_power_off(void); |
| 49 | |
| 50 | static void __init jz_serial_setup(void) |
| 51 | { |
| 52 | #ifdef CONFIG_SERIAL_8250 |
| 53 | struct uart_port s; |
| 54 | REG8(UART0_FCR) |= UARTFCR_UUE; /* enable UART module */ |
| 55 | memset(&s, 0, sizeof(s)); |
| 56 | s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST; |
| 57 | s.iotype = SERIAL_IO_MEM; |
| 58 | s.regshift = 2; |
| 59 | s.uartclk = jz4740_clock_bdata.ext_rate; |
| 60 | |
| 61 | s.line = 0; |
| 62 | s.membase = (u8 *)UART0_BASE; |
| 63 | s.irq = JZ_IRQ_UART0; |
| 64 | if (early_serial_setup(&s) != 0) { |
| 65 | printk(KERN_ERR "Serial ttyS0 setup failed!\n"); |
| 66 | } |
| 67 | |
| 68 | s.line = 1; |
| 69 | s.membase = (u8 *)UART1_BASE; |
| 70 | s.irq = JZ_IRQ_UART1; |
| 71 | if (early_serial_setup(&s) != 0) { |
| 72 | printk(KERN_ERR "Serial ttyS1 setup failed!\n"); |
| 73 | } |
| 74 | #endif |
| 75 | } |
| 76 | |
| 77 | void __init plat_mem_setup(void) |
| 78 | { |
| 79 | char *argptr; |
| 80 | |
| 81 | argptr = prom_getcmdline(); |
| 82 | |
| 83 | /* IO/MEM resources. Which will be the addtion value in `inX' and |
| 84 | * `outX' macros defined in asm/io.h */ |
| 85 | set_io_port_base(0); |
| 86 | ioport_resource.start = 0x00000000; |
| 87 | ioport_resource.end = 0xffffffff; |
| 88 | iomem_resource.start = 0x00000000; |
| 89 | iomem_resource.end = 0xffffffff; |
| 90 | |
| 91 | _machine_restart = jz_restart; |
| 92 | _machine_halt = jz_halt; |
| 93 | pm_power_off = jz_power_off; |
| 94 | jz_serial_setup(); |
| 95 | } |
| 96 | |
| 97 | |