summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2013-06-20 04:11:29 +0400
committerArnd Bergmann <arnd@arndb.de>2013-06-20 04:11:29 +0400
commited2ca6ee4bfd060c079fd05d0eb8862da02dd248 (patch)
treef395e9fd07353c4070f18a0b1d1d29c220ee8114 /drivers
parentf25a4d68f8ca83132dcfb8607d55fc71b12956c0 (diff)
parent93b331cec9e15210af1da9782bf699e5d3a61f0f (diff)
downloadlinux-ed2ca6ee4bfd060c079fd05d0eb8862da02dd248.tar.xz
Merge tag 'imx-dt-3.11' of git://git.linaro.org/people/shawnguo/linux-2.6 into next/dt
From Shawn Guo: imx device tree changes for 3.11: * A bunch of new board additions, imx6sl-evk, vf610-twr, imx53-tx53, imx53-m53evk and imx27-phytec-phycore * Various pinctrl setting updates and additions * Enable various on board peripherals, usb, audio, nor, display etc. * Configure L2 cache data and tag latency from device tree * Add imx-weim bus driver * tag 'imx-dt-3.11' of git://git.linaro.org/people/shawnguo/linux-2.6: (82 commits) ARM: dts: imx27: Add VPU devicetree node ARM: mxc: fix gpio-ranges for VF610 ARM: dtsi: imx6qdl-sabresd: Enable WM8962 audio support ARM: dtsi: imx6qdl-sabresd: Enable SSI2 and AUDMUX ARM: dtsi: imx6qdl-sabresd: Add WM8962 CODEC support ARM: dtsi: imx6qdl-sabresd: add a fixed regulator for WM8962 ARM: dtsi: imx6dl: Add a pinctrl for AUDMUX ARM: dtsi: imx6q/imx6dl: Add a pinctrl for I2C1 ARM: dts: imx6qdl-sabresd: add clko1 iomux configuration ARM: dts: Phytec imx6q pfla02 and pbab01 support ARM: dts: imx6q: Add pinctrl for usdhc2 and enet ARM: dts: imx27-phytec-phycore-rdk: Add MTD name for NOR flash ARM: dts: imx27-phytec-phycore-rdk: Add SDHC support ARM: dts: i.MX27: Add SDHC devicetree nodes ARM: dts: i.MX27: Add DMA devicetree node ARM: dts: imx6qdl-sabreauto: enable the WEIM NOR ARM: dts: imx6dl: add pinctrls for WEIM NOR ARM: dts: imx6q: add pinctrls for WEIM NOR ARM: dts: imx6qdl: add more information for WEIM ARM: dts: imx6q{dl}: fix the pin conflict between SPI and WEIM ... Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bus/Kconfig9
-rw-r--r--drivers/bus/Makefile1
-rw-r--r--drivers/bus/imx-weim.c138
3 files changed, 148 insertions, 0 deletions
diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index b05ecab915c4..46cd5bb098a9 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -4,6 +4,15 @@
menu "Bus devices"
+config IMX_WEIM
+ bool "Freescale EIM DRIVER"
+ depends on ARCH_MXC
+ help
+ Driver for i.MX6 WEIM controller.
+ The WEIM(Wireless External Interface Module) works like a bus.
+ You can attach many different devices on it, such as NOR, onenand.
+ But now, we only support the Parallel NOR.
+
config MVEBU_MBUS
bool
depends on PLAT_ORION
diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile
index 3c7b53c12091..436bbccf4894 100644
--- a/drivers/bus/Makefile
+++ b/drivers/bus/Makefile
@@ -2,6 +2,7 @@
# Makefile for the bus drivers.
#
+obj-$(CONFIG_IMX_WEIM) += imx-weim.o
obj-$(CONFIG_MVEBU_MBUS) += mvebu-mbus.o
obj-$(CONFIG_OMAP_OCP2SCP) += omap-ocp2scp.o
diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
new file mode 100644
index 000000000000..349f14e886b7
--- /dev/null
+++ b/drivers/bus/imx-weim.c
@@ -0,0 +1,138 @@
+/*
+ * EIM driver for Freescale's i.MX chips
+ *
+ * Copyright (C) 2013 Freescale Semiconductor, Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/of_device.h>
+
+struct imx_weim {
+ void __iomem *base;
+ struct clk *clk;
+};
+
+static const struct of_device_id weim_id_table[] = {
+ { .compatible = "fsl,imx6q-weim", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, weim_id_table);
+
+#define CS_TIMING_LEN 6
+#define CS_REG_RANGE 0x18
+
+/* Parse and set the timing for this device. */
+static int
+weim_timing_setup(struct platform_device *pdev, struct device_node *np)
+{
+ struct imx_weim *weim = platform_get_drvdata(pdev);
+ u32 value[CS_TIMING_LEN];
+ u32 cs_idx;
+ int ret;
+ int i;
+
+ /* get the CS index from this child node's "reg" property. */
+ ret = of_property_read_u32(np, "reg", &cs_idx);
+ if (ret)
+ return ret;
+
+ /* The weim has four chip selects. */
+ if (cs_idx > 3)
+ return -EINVAL;
+
+ ret = of_property_read_u32_array(np, "fsl,weim-cs-timing",
+ value, CS_TIMING_LEN);
+ if (ret)
+ return ret;
+
+ /* set the timing for WEIM */
+ for (i = 0; i < CS_TIMING_LEN; i++)
+ writel(value[i], weim->base + cs_idx * CS_REG_RANGE + i * 4);
+ return 0;
+}
+
+static int weim_parse_dt(struct platform_device *pdev)
+{
+ struct device_node *child;
+ int ret;
+
+ for_each_child_of_node(pdev->dev.of_node, child) {
+ if (!child->name)
+ continue;
+
+ ret = weim_timing_setup(pdev, child);
+ if (ret) {
+ dev_err(&pdev->dev, "%s set timing failed.\n",
+ child->full_name);
+ return ret;
+ }
+ }
+
+ ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+ if (ret)
+ dev_err(&pdev->dev, "%s fail to create devices.\n",
+ pdev->dev.of_node->full_name);
+ return ret;
+}
+
+static int weim_probe(struct platform_device *pdev)
+{
+ struct imx_weim *weim;
+ struct resource *res;
+ int ret = -EINVAL;
+
+ weim = devm_kzalloc(&pdev->dev, sizeof(*weim), GFP_KERNEL);
+ if (!weim) {
+ ret = -ENOMEM;
+ goto weim_err;
+ }
+ platform_set_drvdata(pdev, weim);
+
+ /* get the resource */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ weim->base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(weim->base)) {
+ ret = PTR_ERR(weim->base);
+ goto weim_err;
+ }
+
+ /* get the clock */
+ weim->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(weim->clk))
+ goto weim_err;
+
+ ret = clk_prepare_enable(weim->clk);
+ if (ret)
+ goto weim_err;
+
+ /* parse the device node */
+ ret = weim_parse_dt(pdev);
+ if (ret) {
+ clk_disable_unprepare(weim->clk);
+ goto weim_err;
+ }
+
+ dev_info(&pdev->dev, "WEIM driver registered.\n");
+ return 0;
+
+weim_err:
+ return ret;
+}
+
+static struct platform_driver weim_driver = {
+ .driver = {
+ .name = "imx-weim",
+ .of_match_table = weim_id_table,
+ },
+ .probe = weim_probe,
+};
+
+module_platform_driver(weim_driver);
+MODULE_AUTHOR("Freescale Semiconductor Inc.");
+MODULE_DESCRIPTION("i.MX EIM Controller Driver");
+MODULE_LICENSE("GPL");