aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bus
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 17:23:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 17:23:01 -0400
commitee1a8d402e7e204d57fb108aa40003b6d1633036 (patch)
tree3abf4be63d11bbbd04c89bd668a17533f942b911 /drivers/bus
parent40e71e7015ab85c8606f50736525220948a3b24b (diff)
parent9686bb66a4c50e43ffee903a9fc62237ee2de1e6 (diff)
Merge tag 'dt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC device tree changes from Arnd Bergmann: "These changes from 30 individual branches for the most part update device tree files, but there are also a few source code changes that have crept in this time, usually in order to atomically move over a driver from using hardcoded data to DT probing. A number of platforms change their DT files to use the C preprocessor, which is causing a bit of churn, but that is hopefully only this once" * tag 'dt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (372 commits) ARM: at91: dt: rm9200ek: add spi support ARM: at91: dt: rm9200: add spi support ARM: at91/DT: at91sam9n12: add SPI DMA client infos ARM: at91/DT: sama5d3: add SPI DMA client infos ARM: at91/DT: fix SPI compatibility string ARM: Kirkwood: Fix the internal register ranges translation ARM: dts: bcm281xx: change comment to C89 style ARM: mmc: bcm281xx SDHCI driver (dt mods) ARM: nomadik: add the new clocks to the device tree clk: nomadik: implement the Nomadik clocks properly ARM: dts: omap5-uevm: Provide USB Host PHY clock frequency ARM: dts: omap4-panda: Fix DVI EDID reads ARM: dts: omap4-panda: Add USB Host support arm: mvebu: enable mini-PCIe connectors on Armada 370 RD ARM: shmobile: irqpin: add a DT property to enable masking on parent ARM: dts: AM43x EPOS EVM support ARM: dts: OMAP5: Add bandgap DT entry ARM: dts: AM33XX: Add pinmux configuration for CPSW to am335x EVM ARM: dts: AM33XX: Add pinmux configuration for CPSW to EVMsk ARM: dts: AM33XX: Add pinmux configuration for CPSW to beaglebone ...
Diffstat (limited to 'drivers/bus')
-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 5286e2d333b0..1f70e84b442c 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -4,6 +4,15 @@
4 4
5menu "Bus devices" 5menu "Bus devices"
6 6
7config IMX_WEIM
8 bool "Freescale EIM DRIVER"
9 depends on ARCH_MXC
10 help
11 Driver for i.MX6 WEIM controller.
12 The WEIM(Wireless External Interface Module) works like a bus.
13 You can attach many different devices on it, such as NOR, onenand.
14 But now, we only support the Parallel NOR.
15
7config MVEBU_MBUS 16config MVEBU_MBUS
8 bool 17 bool
9 depends on PLAT_ORION 18 depends on PLAT_ORION
diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile
index 670cea443802..8947bdd0de8b 100644
--- a/drivers/bus/Makefile
+++ b/drivers/bus/Makefile
@@ -2,6 +2,7 @@
2# Makefile for the bus drivers. 2# Makefile for the bus drivers.
3# 3#
4 4
5obj-$(CONFIG_IMX_WEIM) += imx-weim.o
5obj-$(CONFIG_MVEBU_MBUS) += mvebu-mbus.o 6obj-$(CONFIG_MVEBU_MBUS) += mvebu-mbus.o
6obj-$(CONFIG_OMAP_OCP2SCP) += omap-ocp2scp.o 7obj-$(CONFIG_OMAP_OCP2SCP) += omap-ocp2scp.o
7 8
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 @@
1/*
2 * EIM driver for Freescale's i.MX chips
3 *
4 * Copyright (C) 2013 Freescale Semiconductor, Inc.
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10#include <linux/module.h>
11#include <linux/clk.h>
12#include <linux/io.h>
13#include <linux/of_device.h>
14
15struct imx_weim {
16 void __iomem *base;
17 struct clk *clk;
18};
19
20static const struct of_device_id weim_id_table[] = {
21 { .compatible = "fsl,imx6q-weim", },
22 {}
23};
24MODULE_DEVICE_TABLE(of, weim_id_table);
25
26#define CS_TIMING_LEN 6
27#define CS_REG_RANGE 0x18
28
29/* Parse and set the timing for this device. */
30static int
31weim_timing_setup(struct platform_device *pdev, struct device_node *np)
32{
33 struct imx_weim *weim = platform_get_drvdata(pdev);
34 u32 value[CS_TIMING_LEN];
35 u32 cs_idx;
36 int ret;
37 int i;
38
39 /* get the CS index from this child node's "reg" property. */
40 ret = of_property_read_u32(np, "reg", &cs_idx);
41 if (ret)
42 return ret;
43
44 /* The weim has four chip selects. */
45 if (cs_idx > 3)
46 return -EINVAL;
47
48 ret = of_property_read_u32_array(np, "fsl,weim-cs-timing",
49 value, CS_TIMING_LEN);
50 if (ret)
51 return ret;
52
53 /* set the timing for WEIM */
54 for (i = 0; i < CS_TIMING_LEN; i++)
55 writel(value[i], weim->base + cs_idx * CS_REG_RANGE + i * 4);
56 return 0;
57}
58
59static int weim_parse_dt(struct platform_device *pdev)
60{
61 struct device_node *child;
62 int ret;
63
64 for_each_child_of_node(pdev->dev.of_node, child) {
65 if (!child->name)
66 continue;
67
68 ret = weim_timing_setup(pdev, child);
69 if (ret) {
70 dev_err(&pdev->dev, "%s set timing failed.\n",
71 child->full_name);
72 return ret;
73 }
74 }
75
76 ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
77 if (ret)
78 dev_err(&pdev->dev, "%s fail to create devices.\n",
79 pdev->dev.of_node->full_name);
80 return ret;
81}
82
83static int weim_probe(struct platform_device *pdev)
84{
85 struct imx_weim *weim;
86 struct resource *res;
87 int ret = -EINVAL;
88
89 weim = devm_kzalloc(&pdev->dev, sizeof(*weim), GFP_KERNEL);
90 if (!weim) {
91 ret = -ENOMEM;
92 goto weim_err;
93 }
94 platform_set_drvdata(pdev, weim);
95
96 /* get the resource */
97 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
98 weim->base = devm_ioremap_resource(&pdev->dev, res);
99 if (IS_ERR(weim->base)) {
100 ret = PTR_ERR(weim->base);
101 goto weim_err;
102 }
103
104 /* get the clock */
105 weim->clk = devm_clk_get(&pdev->dev, NULL);
106 if (IS_ERR(weim->clk))
107 goto weim_err;
108
109 ret = clk_prepare_enable(weim->clk);
110 if (ret)
111 goto weim_err;
112
113 /* parse the device node */
114 ret = weim_parse_dt(pdev);
115 if (ret) {
116 clk_disable_unprepare(weim->clk);
117 goto weim_err;
118 }
119
120 dev_info(&pdev->dev, "WEIM driver registered.\n");
121 return 0;
122
123weim_err:
124 return ret;
125}
126
127static struct platform_driver weim_driver = {
128 .driver = {
129 .name = "imx-weim",
130 .of_match_table = weim_id_table,
131 },
132 .probe = weim_probe,
133};
134
135module_platform_driver(weim_driver);
136MODULE_AUTHOR("Freescale Semiconductor Inc.");
137MODULE_DESCRIPTION("i.MX EIM Controller Driver");
138MODULE_LICENSE("GPL");