| 1 | #include <linux/init.h> |
| 2 | #include <linux/module.h> |
| 3 | #include <linux/bootmem.h> |
| 4 | #include <linux/etherdevice.h> |
| 5 | |
| 6 | #include <asm/bootinfo.h> |
| 7 | |
| 8 | #include <ifxmips.h> |
| 9 | #include <ifxmips_prom.h> |
| 10 | |
| 11 | /* for voice cpu (MIPS24K) */ |
| 12 | unsigned int *prom_cp1_base; |
| 13 | unsigned int prom_cp1_size; |
| 14 | |
| 15 | /* for Multithreading (APRP) on MIPS34K */ |
| 16 | unsigned long physical_memsize; |
| 17 | |
| 18 | void |
| 19 | prom_free_prom_memory(void) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | unsigned int* |
| 24 | prom_get_cp1_base(void) |
| 25 | { |
| 26 | return prom_cp1_base; |
| 27 | } |
| 28 | EXPORT_SYMBOL(prom_get_cp1_base); |
| 29 | |
| 30 | unsigned int |
| 31 | prom_get_cp1_size(void) |
| 32 | { |
| 33 | /* return size im MB */ |
| 34 | return prom_cp1_size>>20; |
| 35 | } |
| 36 | EXPORT_SYMBOL(prom_get_cp1_size); |
| 37 | |
| 38 | extern unsigned char ifxmips_ethaddr[6]; |
| 39 | int cmdline_mac = 0; |
| 40 | |
| 41 | static int __init |
| 42 | ifxmips_set_ethaddr(char *str) |
| 43 | { |
| 44 | #define IS_HEX(x) \ |
| 45 | (((x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') \ |
| 46 | || (x >= 'A' && x <= 'F')) ? (1) : (0)) |
| 47 | int i; |
| 48 | str = strchr(str, '='); |
| 49 | if (!str) |
| 50 | goto out; |
| 51 | str++; |
| 52 | if (strlen(str) != 17) |
| 53 | goto out; |
| 54 | for (i = 0; i < 6; i++) { |
| 55 | if (!IS_HEX(str[3 * i]) || !IS_HEX(str[(3 * i) + 1])) |
| 56 | goto out; |
| 57 | if ((i != 5) && (str[(3 * i) + 2] != ':')) |
| 58 | goto out; |
| 59 | ifxmips_ethaddr[i] = simple_strtoul(&str[3 * i], NULL, 16); |
| 60 | } |
| 61 | if (is_valid_ether_addr(ifxmips_ethaddr)) |
| 62 | cmdline_mac = 1; |
| 63 | out: |
| 64 | return 1; |
| 65 | } |
| 66 | __setup("ethaddr", ifxmips_set_ethaddr); |
| 67 | |
| 68 | void __init |
| 69 | prom_init(void) |
| 70 | { |
| 71 | int argc = fw_arg0; |
| 72 | char **argv = (char **) fw_arg1; |
| 73 | char **envp = (char **) fw_arg2; |
| 74 | |
| 75 | int memsize = 16; /* assume 16M as default */ |
| 76 | int i; |
| 77 | |
| 78 | if (argc) |
| 79 | { |
| 80 | argv = (char **)KSEG1ADDR((unsigned long)argv); |
| 81 | arcs_cmdline[0] = '\0'; |
| 82 | for (i = 1; i < argc; i++) |
| 83 | { |
| 84 | char *a = (char *)KSEG1ADDR(argv[i]); |
| 85 | if (!argv[i]) |
| 86 | continue; |
| 87 | /* for voice cpu on Twinpass/Danube */ |
| 88 | if (cpu_data[0].cputype == CPU_24K) |
| 89 | if (!strncmp(a, "cp1_size=", 9)) |
| 90 | { |
| 91 | prom_cp1_size = memparse(a + 9, &a); |
| 92 | continue; |
| 93 | } |
| 94 | if (strlen(arcs_cmdline) + strlen(a + 1) >= sizeof(arcs_cmdline)) |
| 95 | { |
| 96 | early_printf("cmdline overflow, skipping: %s\n", a); |
| 97 | break; |
| 98 | } |
| 99 | strcat(arcs_cmdline, a); |
| 100 | strcat(arcs_cmdline, " "); |
| 101 | } |
| 102 | if (!*arcs_cmdline) |
| 103 | strcpy(&(arcs_cmdline[0]), |
| 104 | "console=ttyS0,115200 rootfstype=squashfs,jffs2"); |
| 105 | } |
| 106 | envp = (char **)KSEG1ADDR((unsigned long)envp); |
| 107 | while (*envp) |
| 108 | { |
| 109 | char *e = (char *)KSEG1ADDR(*envp); |
| 110 | |
| 111 | if (!strncmp(e, "memsize=", 8)) |
| 112 | { |
| 113 | e += 8; |
| 114 | memsize = simple_strtoul(e, NULL, 10); |
| 115 | } |
| 116 | envp++; |
| 117 | } |
| 118 | memsize *= 1024 * 1024; |
| 119 | |
| 120 | /* only on Twinpass/Danube a second CPU is used for Voice */ |
| 121 | if ((cpu_data[0].cputype == CPU_24K) && (prom_cp1_size)) |
| 122 | { |
| 123 | memsize -= prom_cp1_size; |
| 124 | prom_cp1_base = (unsigned int *)KSEG1ADDR(memsize); |
| 125 | |
| 126 | early_printf("Using %dMB Ram and reserving %dMB for cp1\n", |
| 127 | memsize>>20, prom_cp1_size>>20); |
| 128 | } |
| 129 | |
| 130 | add_memory_region(0x00000000, memsize, BOOT_MEM_RAM); |
| 131 | } |
| 132 | |