ar71xx: Add eTactica EG-200 support
[openwrt/staging/wigyori.git] / package / boot / kobs-ng / patches / 003-raw-mode.patch
1 The downstream Freescale vendor kernel has a patch that allows determining
2 if raw NAND flash mode is provided via a debugfs file. This is not present
3 in upstream kernels, but the raw access support was added in the 3.19
4 kernel, so we will check the kernel version if we can't find the file.
5 --- a/src/mtd.c
6 +++ b/src/mtd.c
7 @@ -34,6 +34,7 @@
8 #include <errno.h>
9 #include <sys/types.h>
10 #include <sys/ioctl.h>
11 +#include <sys/utsname.h>
12
13 #include "mtd.h"
14 #include "rand.h"
15 @@ -808,15 +809,27 @@ struct mtd_data *mtd_open(const struct m
16 md->cfg = *cfg;
17
18 /* check if use new raw access mode */
19 + /* by looking for debugfs from fsl patch */
20 + md->raw_mode_flag = 0;
21 fp = fopen("/sys/kernel/debug/gpmi-nand/raw_mode", "r");
22 if (!fp) {
23 - md->raw_mode_flag = 0;
24 - vp(md, "mtd: use legacy raw access mode\n");
25 + /* fallback to kernel version: raw access added in 3.19 */
26 + struct utsname uts;
27 + if (!uname(&uts)) {
28 + int major = 0, minor = 0;
29 + sscanf(uts.release, "%d.%d", &major, &minor);
30 + vp(md, "mtd: Linux %d.%d\n", major, minor);
31 + if ((major << 8 | minor) > (3 << 8 | 18))
32 + md->raw_mode_flag = 1;
33 + }
34 } else {
35 fclose(fp);
36 md->raw_mode_flag = 1;
37 - vp(md, "mtd: use new bch layout raw access mode\n");
38 }
39 + if (md->raw_mode_flag)
40 + vp(md, "mtd: use new bch layout raw access mode\n");
41 + else
42 + vp(md, "mtd: use legacy raw access mode\n");
43
44 if (plat_config_data->m_u32UseMultiBootArea) {
45