da38629a75d73dd258ac092a6f3ed6eaf0742371
[openwrt.git] / target / linux / ramips / patches-3.8 / 0004-MIPS-ralink-adds-prom-and-cmdline-code.patch
1 From 7e47cefa69c8ed2c889522ce29fcce73ce8cf08e Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 20 Jan 2013 22:01:05 +0100
4 Subject: [PATCH 04/14] MIPS: ralink: adds prom and cmdline code
5
6 Add minimal code to handle commandlines.
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
10 Patchwork: http://patchwork.linux-mips.org/patch/4892/
11 ---
12  arch/mips/ralink/prom.c |   69 +++++++++++++++++++++++++++++++++++++++++++++++
13  1 file changed, 69 insertions(+)
14  create mode 100644 arch/mips/ralink/prom.c
15
16 --- /dev/null
17 +++ b/arch/mips/ralink/prom.c
18 @@ -0,0 +1,69 @@
19 +/*
20 + *  This program is free software; you can redistribute it and/or modify it
21 + *  under the terms of the GNU General Public License version 2 as published
22 + *  by the Free Software Foundation.
23 + *
24 + *  Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
25 + *  Copyright (C) 2010 Joonas Lahtinen <joonas.lahtinen@gmail.com>
26 + *  Copyright (C) 2013 John Crispin <blogic@openwrt.org>
27 + */
28 +
29 +#include <linux/string.h>
30 +#include <linux/of_fdt.h>
31 +#include <linux/of_platform.h>
32 +
33 +#include <asm/bootinfo.h>
34 +#include <asm/addrspace.h>
35 +
36 +#include "common.h"
37 +
38 +struct ralink_soc_info soc_info;
39 +
40 +const char *get_system_type(void)
41 +{
42 +       return soc_info.sys_type;
43 +}
44 +
45 +static __init void prom_init_cmdline(int argc, char **argv)
46 +{
47 +       int i;
48 +
49 +       pr_debug("prom: fw_arg0=%08x fw_arg1=%08x fw_arg2=%08x fw_arg3=%08x\n",
50 +              (unsigned int)fw_arg0, (unsigned int)fw_arg1,
51 +              (unsigned int)fw_arg2, (unsigned int)fw_arg3);
52 +
53 +       argc = fw_arg0;
54 +       argv = (char **) KSEG1ADDR(fw_arg1);
55 +
56 +       if (!argv) {
57 +               pr_debug("argv=%p is invalid, skipping\n",
58 +                      argv);
59 +               return;
60 +       }
61 +
62 +       for (i = 0; i < argc; i++) {
63 +               char *p = (char *) KSEG1ADDR(argv[i]);
64 +
65 +               if (CPHYSADDR(p) && *p) {
66 +                       pr_debug("argv[%d]: %s\n", i, p);
67 +                       strlcat(arcs_cmdline, " ", sizeof(arcs_cmdline));
68 +                       strlcat(arcs_cmdline, p, sizeof(arcs_cmdline));
69 +               }
70 +       }
71 +}
72 +
73 +void __init prom_init(void)
74 +{
75 +       int argc;
76 +       char **argv;
77 +
78 +       prom_soc_init(&soc_info);
79 +
80 +       pr_info("SoC Type: %s\n", get_system_type());
81 +
82 +       prom_init_cmdline(argc, argv);
83 +}
84 +
85 +void __init prom_free_prom_memory(void)
86 +{
87 +}