~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/rb532/prom.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  *  RouterBoard 500 specific prom routines
  4  *
  5  *  Copyright (C) 2003, Peter Sadik <peter.sadik@idt.com>
  6  *  Copyright (C) 2005-2006, P.Christeas <p_christ@hol.gr>
  7  *  Copyright (C) 2007, Gabor Juhos <juhosg@openwrt.org>
  8  *                      Felix Fietkau <nbd@openwrt.org>
  9  *                      Florian Fainelli <florian@openwrt.org>
 10  */
 11 
 12 #include <linux/init.h>
 13 #include <linux/mm.h>
 14 #include <linux/export.h>
 15 #include <linux/string.h>
 16 #include <linux/console.h>
 17 #include <linux/memblock.h>
 18 #include <linux/ioport.h>
 19 
 20 #include <asm/bootinfo.h>
 21 #include <asm/mach-rc32434/ddr.h>
 22 #include <asm/mach-rc32434/prom.h>
 23 
 24 unsigned int idt_cpu_freq = 132000000;
 25 EXPORT_SYMBOL(idt_cpu_freq);
 26 
 27 static struct resource ddr_reg[] = {
 28         {
 29                 .name = "ddr-reg",
 30                 .start = DDR0_PHYS_ADDR,
 31                 .end = DDR0_PHYS_ADDR + sizeof(struct ddr_ram),
 32                 .flags = IORESOURCE_MEM,
 33         }
 34 };
 35 
 36 static inline int match_tag(char *arg, const char *tag)
 37 {
 38         return strncmp(arg, tag, strlen(tag)) == 0;
 39 }
 40 
 41 static inline unsigned long tag2ul(char *arg, const char *tag)
 42 {
 43         char *num;
 44 
 45         num = arg + strlen(tag);
 46         return simple_strtoul(num, 0, 10);
 47 }
 48 
 49 static void __init prom_setup_cmdline(void)
 50 {
 51         static char cmd_line[COMMAND_LINE_SIZE] __initdata;
 52         char *cp, *board;
 53         int prom_argc;
 54         char **prom_argv;
 55         int i;
 56 
 57         prom_argc = fw_arg0;
 58         prom_argv = (char **) fw_arg1;
 59 
 60         cp = cmd_line;
 61                 /* Note: it is common that parameters start
 62                  * at argv[1] and not argv[0],
 63                  * however, our elf loader starts at [0] */
 64         for (i = 0; i < prom_argc; i++) {
 65                 if (match_tag(prom_argv[i], FREQ_TAG)) {
 66                         idt_cpu_freq = tag2ul(prom_argv[i], FREQ_TAG);
 67                         continue;
 68                 }
 69 #ifdef IGNORE_CMDLINE_MEM
 70                 /* parses out the "mem=xx" arg */
 71                 if (match_tag(prom_argv[i], MEM_TAG))
 72                         continue;
 73 #endif
 74                 if (i > 0)
 75                         *(cp++) = ' ';
 76                 if (match_tag(prom_argv[i], BOARD_TAG)) {
 77                         board = prom_argv[i] + strlen(BOARD_TAG);
 78 
 79                         if (match_tag(board, BOARD_RB532A))
 80                                 mips_machtype = MACH_MIKROTIK_RB532A;
 81                         else
 82                                 mips_machtype = MACH_MIKROTIK_RB532;
 83                 }
 84 
 85                 strcpy(cp, prom_argv[i]);
 86                 cp += strlen(prom_argv[i]);
 87         }
 88         *(cp++) = ' ';
 89 
 90         i = strlen(arcs_cmdline);
 91         if (i > 0) {
 92                 *(cp++) = ' ';
 93                 strcpy(cp, arcs_cmdline);
 94                 cp += strlen(arcs_cmdline);
 95         }
 96         cmd_line[COMMAND_LINE_SIZE - 1] = '\0';
 97 
 98         strcpy(arcs_cmdline, cmd_line);
 99 }
100 
101 void __init prom_init(void)
102 {
103         struct ddr_ram __iomem *ddr;
104         phys_addr_t memsize;
105         phys_addr_t ddrbase;
106 
107         ddr = ioremap(ddr_reg[0].start,
108                         ddr_reg[0].end - ddr_reg[0].start);
109 
110         if (!ddr) {
111                 printk(KERN_ERR "Unable to remap DDR register\n");
112                 return;
113         }
114 
115         ddrbase = (phys_addr_t)&ddr->ddrbase;
116         memsize = (phys_addr_t)&ddr->ddrmask;
117         memsize = 0 - memsize;
118 
119         prom_setup_cmdline();
120 
121         /* give all RAM to boot allocator,
122          * except for the first 0x400 and the last 0x200 bytes */
123         memblock_add(ddrbase + 0x400, memsize - 0x600);
124 }
125 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php