1f2ffa5abSDezhong Diao /* 2f2ffa5abSDezhong Diao * MIPS support for CONFIG_OF device tree support 3f2ffa5abSDezhong Diao * 4f2ffa5abSDezhong Diao * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com> 5f2ffa5abSDezhong Diao * 6f2ffa5abSDezhong Diao * This program is free software; you can redistribute it and/or modify 7f2ffa5abSDezhong Diao * it under the terms of the GNU General Public License version 2 as 8f2ffa5abSDezhong Diao * published by the Free Software Foundation. 9f2ffa5abSDezhong Diao */ 10f2ffa5abSDezhong Diao 11f2ffa5abSDezhong Diao #include <linux/init.h> 1273bc256dSPaul Gortmaker #include <linux/export.h> 13f2ffa5abSDezhong Diao #include <linux/errno.h> 14f2ffa5abSDezhong Diao #include <linux/types.h> 15f2ffa5abSDezhong Diao #include <linux/bootmem.h> 16f2ffa5abSDezhong Diao #include <linux/initrd.h> 17f2ffa5abSDezhong Diao #include <linux/debugfs.h> 18f2ffa5abSDezhong Diao #include <linux/of.h> 19f2ffa5abSDezhong Diao #include <linux/of_fdt.h> 20f2ffa5abSDezhong Diao 21f2ffa5abSDezhong Diao #include <asm/page.h> 22f2ffa5abSDezhong Diao #include <asm/prom.h> 23f2ffa5abSDezhong Diao 249169a5d0SJohn Crispin static char mips_machine_name[64] = "Unknown"; 259169a5d0SJohn Crispin 269169a5d0SJohn Crispin __init void mips_set_machine_name(const char *name) 279169a5d0SJohn Crispin { 289169a5d0SJohn Crispin if (name == NULL) 299169a5d0SJohn Crispin return; 309169a5d0SJohn Crispin 3141c8366bSChen Gang strlcpy(mips_machine_name, name, sizeof(mips_machine_name)); 329169a5d0SJohn Crispin pr_info("MIPS: machine is %s\n", mips_get_machine_name()); 339169a5d0SJohn Crispin } 349169a5d0SJohn Crispin 359169a5d0SJohn Crispin char *mips_get_machine_name(void) 369169a5d0SJohn Crispin { 379169a5d0SJohn Crispin return mips_machine_name; 389169a5d0SJohn Crispin } 399169a5d0SJohn Crispin 409169a5d0SJohn Crispin #ifdef CONFIG_OF 41f2ffa5abSDezhong Diao void __init early_init_dt_add_memory_arch(u64 base, u64 size) 42f2ffa5abSDezhong Diao { 43f2ffa5abSDezhong Diao return add_memory_region(base, size, BOOT_MEM_RAM); 44f2ffa5abSDezhong Diao } 45f2ffa5abSDezhong Diao 46672c5446SGrant Likely void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 47f2ffa5abSDezhong Diao { 48672c5446SGrant Likely return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); 49f2ffa5abSDezhong Diao } 50f2ffa5abSDezhong Diao 51f2ffa5abSDezhong Diao #ifdef CONFIG_BLK_DEV_INITRD 52374d5c99SSantosh Shilimkar void __init early_init_dt_setup_initrd_arch(u64 start, u64 end) 53f2ffa5abSDezhong Diao { 54f2ffa5abSDezhong Diao initrd_start = (unsigned long)__va(start); 55f2ffa5abSDezhong Diao initrd_end = (unsigned long)__va(end); 56f2ffa5abSDezhong Diao initrd_below_start_ok = 1; 57f2ffa5abSDezhong Diao } 58f2ffa5abSDezhong Diao #endif 59f2ffa5abSDezhong Diao 609169a5d0SJohn Crispin int __init early_init_dt_scan_model(unsigned long node, const char *uname, 619169a5d0SJohn Crispin int depth, void *data) 629169a5d0SJohn Crispin { 639169a5d0SJohn Crispin if (!depth) { 649169a5d0SJohn Crispin char *model = of_get_flat_dt_prop(node, "model", NULL); 659169a5d0SJohn Crispin 669169a5d0SJohn Crispin if (model) 679169a5d0SJohn Crispin mips_set_machine_name(model); 689169a5d0SJohn Crispin } 699169a5d0SJohn Crispin return 0; 709169a5d0SJohn Crispin } 719169a5d0SJohn Crispin 72f75813c0SRob Herring void __init __dt_setup_arch(struct boot_param_header *bph) 73f2ffa5abSDezhong Diao { 74f75813c0SRob Herring if (!early_init_dt_scan(bph)) 75f75813c0SRob Herring return; 769169a5d0SJohn Crispin 779169a5d0SJohn Crispin /* try to load the mips machine name */ 789169a5d0SJohn Crispin of_scan_flat_dt(early_init_dt_scan_model, NULL); 79f2ffa5abSDezhong Diao } 809169a5d0SJohn Crispin #endif 81