| 1 | /* |
| 2 | * Ralink SoC common setup |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org> |
| 5 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published |
| 9 | * by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/io.h> |
| 15 | #include <linux/serial_8250.h> |
| 16 | |
| 17 | #include <asm/bootinfo.h> |
| 18 | #include <asm/addrspace.h> |
| 19 | |
| 20 | #include <asm/mach-ralink/common.h> |
| 21 | #include <asm/mach-ralink/machine.h> |
| 22 | #include <ralink_soc.h> |
| 23 | |
| 24 | unsigned char ramips_sys_type[RAMIPS_SYS_TYPE_LEN]; |
| 25 | |
| 26 | const char *get_system_type(void) |
| 27 | { |
| 28 | return ramips_sys_type; |
| 29 | } |
| 30 | |
| 31 | static void __init detect_mem_size(void) |
| 32 | { |
| 33 | unsigned long size; |
| 34 | |
| 35 | for (size = RALINK_SOC_MEM_SIZE_MIN; size < RALINK_SOC_MEM_SIZE_MAX; |
| 36 | size <<= 1 ) { |
| 37 | if (!memcmp(detect_mem_size, |
| 38 | detect_mem_size + size, 1024)) |
| 39 | break; |
| 40 | } |
| 41 | |
| 42 | add_memory_region(RALINK_SOC_SDRAM_BASE, size, BOOT_MEM_RAM); |
| 43 | } |
| 44 | |
| 45 | void __init ramips_early_serial_setup(int line, unsigned base, unsigned freq, |
| 46 | unsigned irq) |
| 47 | { |
| 48 | struct uart_port p; |
| 49 | int err; |
| 50 | |
| 51 | memset(&p, 0, sizeof(p)); |
| 52 | p.flags = UPF_SKIP_TEST | UPF_FIXED_TYPE; |
| 53 | p.iotype = UPIO_AU; |
| 54 | p.uartclk = freq; |
| 55 | p.regshift = 2; |
| 56 | p.type = PORT_16550A; |
| 57 | |
| 58 | p.mapbase = base; |
| 59 | p.membase = ioremap_nocache(p.mapbase, PAGE_SIZE); |
| 60 | p.line = line; |
| 61 | p.irq = irq; |
| 62 | |
| 63 | err = early_serial_setup(&p); |
| 64 | if (err) |
| 65 | printk(KERN_ERR "early serial%d registration failed %d\n", |
| 66 | line, err); |
| 67 | } |
| 68 | |
| 69 | void __init plat_mem_setup(void) |
| 70 | { |
| 71 | set_io_port_base(KSEG1); |
| 72 | |
| 73 | detect_mem_size(); |
| 74 | ramips_soc_setup(); |
| 75 | } |
| 76 | |
| 77 | __setup("board=", mips_machtype_setup); |
| 78 | |
| 79 | static int __init ramips_machine_setup(void) |
| 80 | { |
| 81 | mips_machine_setup(); |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | arch_initcall(ramips_machine_setup); |
| 86 | |
| 87 | static void __init ramips_generic_init(void) |
| 88 | { |
| 89 | } |
| 90 | |
| 91 | MIPS_MACHINE(RAMIPS_MACH_GENERIC, "Generic", "Generic Ralink board", |
| 92 | ramips_generic_init); |
| 93 | |