All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i.MX6-SabreAuto: EIM: pull PAD_EIM_D18 low for NOR probe
@ 2015-01-14 23:36 alison
       [not found] ` <1421278609-8446-1-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 20+ messages in thread
From: alison @ 2015-01-14 23:36 UTC (permalink / raw)
  To: linux-mtd; +Cc: computersforpeace, shijie8, alison_chaiken

From: Alison Chaiken <alison_chaiken@mentor.com>

PAD_EIM_D18 must be pulled low at boot in order for the parallel NOR
connected to the EIM switch to probe properly.  Otherwise
cfi_qry_present() may return "U-V-]" rather than "Q-R-Y" if the
PAD_EIM_D18 is high.  Add a nor-gpios property to the nor node in the
SabreAuto device-tree and add a function to the imx-weim probe to set
GPIO5 to drive the pad.

Signed-off-by: Alison Chaiken <alison_chaiken@mentor.com>
---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi |  1 +
 drivers/bus/imx-weim.c                   | 43 ++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
index 009abd6..dd5e3bc 100644
--- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
@@ -454,5 +454,6 @@
 		bank-width = <2>;
 		fsl,weim-cs-timing = <0x00620081 0x00000001 0x1c022000
 				0x0000c000 0x1404a38e 0x00000000>;
+		nor-gpios = <&gpio5 4 GPIO_ACTIVE_LOW>;
 	};
 };
diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 0958b69..b3c2ca6 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -14,6 +14,8 @@
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
 #include <linux/regmap.h>
+#include <linux/of_gpio.h>
+#include <linux/gpio.h>
 
 struct imx_weim_devtype {
 	unsigned int	cs_count;
@@ -108,6 +110,40 @@ err:
 	return -EINVAL;
 }
 
+/* set the GPIO to control PAD_EIM_D18 so cfi_qry_present() works properly */
+static int __init nor_gpio_setup(struct device_node *np, struct device *parent)
+{
+	unsigned nor_gpio, level;
+	enum of_gpio_flags of_flags;
+	int ret;
+
+	nor_gpio = of_get_named_gpio_flags(np, "nor-gpios", 0, &of_flags);
+
+	/* this child is not a NOR chip */
+	if (!nor_gpio)
+		return 0;
+
+	if (gpio_is_valid(nor_gpio)) {
+		ret = devm_gpio_request_one(parent, nor_gpio,
+					GPIOF_DIR_OUT, "nor-gpio");
+	} else {
+		ret = -ENODEV;
+		goto out;
+	}
+
+	if (ret < 0)
+		goto out;
+
+	level = ((of_flags == OF_GPIO_ACTIVE_LOW) ? 0 : 1);
+
+	gpio_set_value(nor_gpio, level);
+
+	return 0;
+out:
+	dev_err(parent, "Unable to request EIM_D18 GPIO for NOR.\n");
+	return ret;
+}
+
 /* Parse and set the timing for this device. */
 static int __init weim_timing_setup(struct device_node *np, void __iomem *base,
 				    const struct imx_weim_devtype *devtype)
@@ -160,6 +196,13 @@ static int __init weim_parse_dt(struct platform_device *pdev,
 				child->full_name);
 			return ret;
 		}
+
+		ret = nor_gpio_setup(child, &pdev->dev);
+		if (ret) {
+			dev_err(&pdev->dev, "%s gpios setup failed.\n",
+				child->full_name);
+			return ret;
+		}
 	}
 
 	ret = of_platform_populate(pdev->dev.of_node,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-04-27  7:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14 23:36 [PATCH] i.MX6-SabreAuto: EIM: pull PAD_EIM_D18 low for NOR probe alison
     [not found] ` <1421278609-8446-1-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-01-15  0:03   ` Brian Norris
2015-01-15  0:03     ` Brian Norris
2015-01-15  0:03     ` Brian Norris
2015-01-15  7:56     ` Sascha Hauer
2015-01-15  7:56       ` Sascha Hauer
2015-01-15  7:56       ` Sascha Hauer
     [not found]       ` <20150115075646.GM23940-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-01-15 18:46         ` [PATCHv2] i.MX6-SabreAuto: WEIM: add steering-gpios to set WEIM for NOR alison-hh6fLRYtCEIS+FvcfC7Uqw
2015-01-15 18:46           ` alison at she-devel.com
     [not found]           ` <1421347571-9239-1-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-01-15 18:46             ` [PATCH] " alison-hh6fLRYtCEIS+FvcfC7Uqw
2015-01-15 18:46               ` alison at she-devel.com
     [not found]               ` <1421347571-9239-2-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-01-16  7:27                 ` Sascha Hauer
2015-01-16  7:27                   ` Sascha Hauer
     [not found]                   ` <20150116072716.GD18220-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-04-19 21:02                     ` [PATCH 0/2] i.MX6-SabreAuto: DTS: use gpio-hog to enable WEIM-NOR at boot alison-hh6fLRYtCEIS+FvcfC7Uqw
     [not found]                       ` <1429477343-11076-1-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-04-19 21:02                         ` [PATCH 1/2] " alison-hh6fLRYtCEIS+FvcfC7Uqw
     [not found]                           ` <1429477343-11076-2-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-04-23  6:31                             ` Sascha Hauer
     [not found]                               ` <20150423063127.GJ6325-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-04-24  8:00                                 ` [PATCHv2 0/2] i.MX6-SabreAuto: DTS: use gpio-hog to enable WEIM-NOR at boo alison-hh6fLRYtCEIS+FvcfC7Uqw
     [not found]                                   ` <1429862420-15434-1-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-04-24  8:00                                     ` [PATCHv2 1/2] i.MX6-SabreAuto: DTS: use gpio-hog to enable WEIM-NOR at boot alison-hh6fLRYtCEIS+FvcfC7Uqw
     [not found]                                       ` <1429862420-15434-2-git-send-email-alison_chaiken-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-04-27  7:49                                         ` Shawn Guo
2015-04-27  5:53                                 ` [PATCH " Sascha Hauer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.