1 From e98005f02af333e0bf905a1e53caef009a37fc55 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sun, 14 Jul 2013 22:26:43 +0200
4 Subject: add basic tffs driver
7 Index: linux-3.10.13/arch/mips/lantiq/xway/Makefile
8 ===================================================================
9 --- linux-3.10.13.orig/arch/mips/lantiq/xway/Makefile 2013-09-29 00:18:30.164765435 +0200
10 +++ linux-3.10.13/arch/mips/lantiq/xway/Makefile 2013-09-29 00:18:30.216765439 +0200
12 obj-y := prom.o sysctrl.o clk.o reset.o dma.o timer.o dcdc.o
14 -obj-y += vmmc.o mtd_split.o
15 +obj-y += vmmc.o mtd_split.o tffs.o
17 obj-$(CONFIG_PCI) += ath_eep.o rt_eep.o pci-ath-fixup.o
19 Index: linux-3.10.13/arch/mips/lantiq/xway/tffs.c
20 ===================================================================
21 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
22 +++ linux-3.10.13/arch/mips/lantiq/xway/tffs.c 2013-09-29 00:37:17.712792305 +0200
24 +#include <linux/module.h>
25 +#include <linux/mtd/mtd.h>
26 +#include <linux/errno.h>
27 +#include <linux/slab.h>
34 +static struct tffs_id {
41 + { 0x01A9, "annex" },
44 + { 0x018a, "macwlan" },
45 + { 0x0195, "macwlan2" },
46 + { 0x018b, "macdsl" },
47 + { 0x01C2, "webgui_pass" },
48 + { 0x01AB, "wlan_key" },
51 +static struct mtd_info *tffs1, *tffs2;
53 +static struct tffs_id* tffs_find_id(int id)
57 + for (i = 0; i < ARRAY_SIZE(ids); i++)
58 + if (id == ids[i].id)
64 +static void tffs_index(void)
66 + struct tffs_entry *E = NULL;
67 + struct tffs_entry entry;
70 + while ((unsigned int) E + sizeof(struct tffs_entry) < tffs2->size) {
74 + ret = mtd_read(tffs2, (unsigned int) E, sizeof(struct tffs_entry), &retlen, (unsigned char *)&entry);
78 + if (entry.id == 0xffff)
81 + id = tffs_find_id(entry.id);
83 + id->offset = (uint32_t) E;
84 + id->len = entry.len;
85 + id->val = kzalloc(entry.len + 1, GFP_KERNEL);
86 + mtd_read(tffs2, ((unsigned int) E) + sizeof(struct tffs_entry), entry.len, &retlen, id->val);
89 + //printk(KERN_INFO "found entry at 0x%08X-> [<0x%x> %u bytes]\n", (uint32_t) E, entry.id, entry.len);
91 + printk(KERN_INFO "found entry name -> %s=%s\n", id->name, id->val);
93 + len = (entry.len + 3) & ~0x03;
94 + E = (struct tffs_entry *)(((unsigned int)E) + sizeof(struct tffs_entry) + len);
98 +static int __init tffs_init(void)
100 + tffs1 = get_mtd_device_nm("tffs (1)");
101 + tffs2 = get_mtd_device_nm("tffs (2)");
102 + if (IS_ERR(tffs1) || IS_ERR(tffs2))
109 +late_initcall(tffs_init);