aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 15:34:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-28 15:34:33 -0400
commit09893ee84591b0417a9186a7e7cf1503ccf99ac2 (patch)
treeda8b044ad157b82203df04ae48cb60f4737cc390 /drivers/of
parent4bb2d1009f671815870e8f78e826e4f9071392a7 (diff)
parent7d1206bc2859c6e9f46e35ae697c138e7d7858a7 (diff)
Merge tag 'dt2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull "ARM: More device tree support updates" from Olof Johansson: "This branch contains a number of updates for device tree support on several ARM platforms, in particular: * AT91 continues the device tree conversion adding support for a number of on-chip drivers and other functionality * ux500 adds probing of some of the core SoC blocks through device tree * Initial device tree support for ST SPEAr600 platforms * kirkwood continues the conversion to device-tree probing" Manually merge arch/arm/mach-ux500/Kconfig due to MACH_U8500 rename, and drivers/usb/gadget/at91_udc.c due to header file include cleanups. Also do an "evil merge" for the MACH_U8500 config option rename that the affected RMI4 touchscreen driver in staging. It's called MACH_MOP500 now, and it was missed during previous merges. * tag 'dt2' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (48 commits) ARM: SPEAr600: Add device-tree support to SPEAr600 boards ARM: ux500: Provide local timer support for Device Tree ARM: ux500: Enable PL022 SSP Controller in Device Tree ARM: ux500: Enable PL310 Level 2 Cache Controller in Device Tree ARM: ux500: Enable PL011 AMBA UART Controller for Device Tree ARM: ux500: Enable Cortex-A9 GIC (Generic Interrupt Controller) in Device Tree ARM: ux500: db8500: list most devices in the snowball device tree ARM: ux500: split dts file for snowball into generic part ARM: ux500: combine the board init functions for DT boot ARM: ux500: Initial Device Tree support for Snowball ARM: ux500: CONFIG: Enable Device Tree support for future endeavours ARM: kirkwood: use devicetree for rtc-mv ARM: kirkwood: rtc-mv devicetree bindings ARM: kirkwood: fdt: define uart[01] as disabled, enable uart0 ARM: kirkwood: fdt: facilitate new boards during fdt migration ARM: kirkwood: fdt: absorb kirkwood_init() ARM: kirkwood: fdt: use mrvl ticker symbol ARM: orion: wdt: use resource vice direct access ARM: Kirkwood: Remove tclk from kirkwood_asoc_platform_data. ARM: orion: spi: remove enable_clock_fix which is not used ...
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/Kconfig4
-rw-r--r--drivers/of/Makefile1
-rw-r--r--drivers/of/of_mtd.c85
3 files changed, 90 insertions, 0 deletions
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 6ea51dcbc728..8e84ce9765a9 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -91,4 +91,8 @@ config OF_PCI_IRQ
91 help 91 help
92 OpenFirmware PCI IRQ routing helpers 92 OpenFirmware PCI IRQ routing helpers
93 93
94config OF_MTD
95 depends on MTD
96 def_bool y
97
94endmenu # OF 98endmenu # OF
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index a73f5a51ff4c..aa90e602c8a7 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_OF_SELFTEST) += selftest.o
12obj-$(CONFIG_OF_MDIO) += of_mdio.o 12obj-$(CONFIG_OF_MDIO) += of_mdio.o
13obj-$(CONFIG_OF_PCI) += of_pci.o 13obj-$(CONFIG_OF_PCI) += of_pci.o
14obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o 14obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o
15obj-$(CONFIG_OF_MTD) += of_mtd.o
diff --git a/drivers/of/of_mtd.c b/drivers/of/of_mtd.c
new file mode 100644
index 000000000000..e7cad627a5d1
--- /dev/null
+++ b/drivers/of/of_mtd.c
@@ -0,0 +1,85 @@
1/*
2 * Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
3 *
4 * OF helpers for mtd.
5 *
6 * This file is released under the GPLv2
7 *
8 */
9#include <linux/kernel.h>
10#include <linux/of_mtd.h>
11#include <linux/mtd/nand.h>
12#include <linux/export.h>
13
14/**
15 * It maps 'enum nand_ecc_modes_t' found in include/linux/mtd/nand.h
16 * into the device tree binding of 'nand-ecc', so that MTD
17 * device driver can get nand ecc from device tree.
18 */
19static const char *nand_ecc_modes[] = {
20 [NAND_ECC_NONE] = "none",
21 [NAND_ECC_SOFT] = "soft",
22 [NAND_ECC_HW] = "hw",
23 [NAND_ECC_HW_SYNDROME] = "hw_syndrome",
24 [NAND_ECC_HW_OOB_FIRST] = "hw_oob_first",
25 [NAND_ECC_SOFT_BCH] = "soft_bch",
26};
27
28/**
29 * of_get_nand_ecc_mode - Get nand ecc mode for given device_node
30 * @np: Pointer to the given device_node
31 *
32 * The function gets ecc mode string from property 'nand-ecc-mode',
33 * and return its index in nand_ecc_modes table, or errno in error case.
34 */
35const int of_get_nand_ecc_mode(struct device_node *np)
36{
37 const char *pm;
38 int err, i;
39
40 err = of_property_read_string(np, "nand-ecc-mode", &pm);
41 if (err < 0)
42 return err;
43
44 for (i = 0; i < ARRAY_SIZE(nand_ecc_modes); i++)
45 if (!strcasecmp(pm, nand_ecc_modes[i]))
46 return i;
47
48 return -ENODEV;
49}
50EXPORT_SYMBOL_GPL(of_get_nand_ecc_mode);
51
52/**
53 * of_get_nand_bus_width - Get nand bus witdh for given device_node
54 * @np: Pointer to the given device_node
55 *
56 * return bus width option, or errno in error case.
57 */
58int of_get_nand_bus_width(struct device_node *np)
59{
60 u32 val;
61
62 if (of_property_read_u32(np, "nand-bus-width", &val))
63 return 8;
64
65 switch(val) {
66 case 8:
67 case 16:
68 return val;
69 default:
70 return -EIO;
71 }
72}
73EXPORT_SYMBOL_GPL(of_get_nand_bus_width);
74
75/**
76 * of_get_nand_on_flash_bbt - Get nand on flash bbt for given device_node
77 * @np: Pointer to the given device_node
78 *
79 * return true if present false other wise
80 */
81bool of_get_nand_on_flash_bbt(struct device_node *np)
82{
83 return of_property_read_bool(np, "nand-on-flash-bbt");
84}
85EXPORT_SYMBOL_GPL(of_get_nand_on_flash_bbt);