ralink: add 3.14 support
[openwrt/svn-archive/archive.git] / target / linux / ramips / patches-3.14 / 0004-MIPS-ralink-adds-a-bootrom-dumper-module.patch
1 From af03898c74172ab16d610f3eeaa65f66401eb7db Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Tue, 21 May 2013 15:50:31 +0200
4 Subject: [PATCH 04/57] MIPS: ralink: adds a bootrom dumper module
5
6 This patch adds a trivial driver that allows userland to extract the bootrom of
7 a SoC via debugfs.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 ---
11 arch/mips/ralink/Makefile | 2 ++
12 arch/mips/ralink/bootrom.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
13 2 files changed, 50 insertions(+)
14 create mode 100644 arch/mips/ralink/bootrom.c
15
16 diff --git a/arch/mips/ralink/Makefile b/arch/mips/ralink/Makefile
17 index 98ae349..584a8d9 100644
18 --- a/arch/mips/ralink/Makefile
19 +++ b/arch/mips/ralink/Makefile
20 @@ -17,4 +17,6 @@ obj-$(CONFIG_SOC_MT7620) += mt7620.o
21
22 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
23
24 +obj-$(CONFIG_DEBUG_FS) += bootrom.o
25 +
26 obj-y += dts/
27 diff --git a/arch/mips/ralink/bootrom.c b/arch/mips/ralink/bootrom.c
28 new file mode 100644
29 index 0000000..f926f6f
30 --- /dev/null
31 +++ b/arch/mips/ralink/bootrom.c
32 @@ -0,0 +1,48 @@
33 +/*
34 + * This program is free software; you can redistribute it and/or modify it
35 + * under the terms of the GNU General Public License version 2 as published
36 + * by the Free Software Foundation.
37 + *
38 + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
39 + */
40 +
41 +#include <linux/debugfs.h>
42 +#include <linux/seq_file.h>
43 +
44 +#define BOOTROM_OFFSET 0x10118000
45 +#define BOOTROM_SIZE 0x8000
46 +
47 +static void __iomem *membase = (void __iomem*) KSEG1ADDR(BOOTROM_OFFSET);
48 +
49 +static int bootrom_show(struct seq_file *s, void *unused)
50 +{
51 + seq_write(s, membase, BOOTROM_SIZE);
52 +
53 + return 0;
54 +}
55 +
56 +static int bootrom_open(struct inode *inode, struct file *file)
57 +{
58 + return single_open(file, bootrom_show, NULL);
59 +}
60 +
61 +static const struct file_operations bootrom_file_ops = {
62 + .open = bootrom_open,
63 + .read = seq_read,
64 + .llseek = seq_lseek,
65 + .release = single_release,
66 +};
67 +
68 +static int bootrom_setup(void)
69 +{
70 + if (!debugfs_create_file("bootrom", 0444,
71 + NULL, NULL, &bootrom_file_ops)) {
72 + pr_err("Failed to create bootrom debugfs file\n");
73 +
74 + return -EINVAL;
75 + }
76 +
77 + return 0;
78 +}
79 +
80 +postcore_initcall(bootrom_setup);
81 --
82 1.7.10.4
83