1 From d27ec8bb97db0f60d81ab255d51ac4e967362067 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Thu, 7 Aug 2014 18:34:19 +0200
4 Subject: [PATCH 07/31] MIPS: lantiq: add basic tffs driver
6 Signed-off-by: John Crispin <blogic@openwrt.org>
8 arch/mips/lantiq/xway/Makefile | 2 +-
9 arch/mips/lantiq/xway/tffs.c | 87 ++++++++++++++++++++++++++++++++++++++++
10 2 files changed, 88 insertions(+), 1 deletion(-)
11 create mode 100644 arch/mips/lantiq/xway/tffs.c
13 diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile
14 index a2edc53..c73d3f2 100644
15 --- a/arch/mips/lantiq/xway/Makefile
16 +++ b/arch/mips/lantiq/xway/Makefile
18 obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o dcdc.o
21 +obj-y += vmmc.o tffs.o
23 obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o
24 diff --git a/arch/mips/lantiq/xway/tffs.c b/arch/mips/lantiq/xway/tffs.c
26 index 0000000..c9c6e19
28 +++ b/arch/mips/lantiq/xway/tffs.c
30 +#include <linux/module.h>
31 +#include <linux/mtd/mtd.h>
32 +#include <linux/errno.h>
33 +#include <linux/slab.h>
40 +static struct tffs_id {
47 + { 0x01A9, "annex" },
50 + { 0x018a, "macwlan" },
51 + { 0x0195, "macwlan2" },
52 + { 0x018b, "macdsl" },
53 + { 0x01C2, "webgui_pass" },
54 + { 0x01AB, "wlan_key" },
57 +static struct mtd_info *tffs1, *tffs2;
59 +static struct tffs_id* tffs_find_id(int id)
63 + for (i = 0; i < ARRAY_SIZE(ids); i++)
64 + if (id == ids[i].id)
70 +static void tffs_index(void)
72 + struct tffs_entry *E = NULL;
73 + struct tffs_entry entry;
76 + while ((unsigned int) E + sizeof(struct tffs_entry) < tffs2->size) {
80 + ret = mtd_read(tffs2, (unsigned int) E, sizeof(struct tffs_entry), &retlen, (unsigned char *)&entry);
84 + if (entry.id == 0xffff)
87 + id = tffs_find_id(entry.id);
89 + id->offset = (uint32_t) E;
90 + id->len = entry.len;
91 + id->val = kzalloc(entry.len + 1, GFP_KERNEL);
92 + mtd_read(tffs2, ((unsigned int) E) + sizeof(struct tffs_entry), entry.len, &retlen, id->val);
95 + //printk(KERN_INFO "found entry at 0x%08X-> [<0x%x> %u bytes]\n", (uint32_t) E, entry.id, entry.len);
97 + printk(KERN_INFO "found entry name -> %s=%s\n", id->name, id->val);
99 + len = (entry.len + 3) & ~0x03;
100 + E = (struct tffs_entry *)(((unsigned int)E) + sizeof(struct tffs_entry) + len);
104 +static int __init tffs_init(void)
106 + tffs1 = get_mtd_device_nm("tffs (1)");
107 + tffs2 = get_mtd_device_nm("tffs (2)");
108 + if (IS_ERR(tffs1) || IS_ERR(tffs2))
115 +late_initcall(tffs_init);