linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: pinctrl-imx: add support for set bits for general purpose registers
@ 2012-07-06  9:09 Dong Aisheng
  2012-07-06  9:09 ` [PATCH 2/2] pinctrl: pinctrl-imx6q: add missed mux function for USBOTG_ID Dong Aisheng
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Dong Aisheng @ 2012-07-06  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

From: Dong Aisheng <dong.aisheng@linaro.org>

The General Purpose Registers (GPR) is used to select operating modes for
general features in the SoC, usually not related to the IOMUX itself,
but it does belong to IOMUX controller.
We simply provide an convient API for driver to call to set the general purpose
register bits if needed.

Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
---
 drivers/pinctrl/pinctrl-imx.c   |   19 +++++++++++++++++++
 include/linux/fsl/imx-pinctrl.h |   24 ++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/fsl/imx-pinctrl.h

diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
index 44e9726..b83b902 100644
--- a/drivers/pinctrl/pinctrl-imx.c
+++ b/drivers/pinctrl/pinctrl-imx.c
@@ -54,6 +54,24 @@ struct imx_pinctrl {
 	const struct imx_pinctrl_soc_info *info;
 };
 
+static struct imx_pinctrl *imx_pinctrl;
+/*
+ * Set bits for general purpose registers
+ */
+void imx_pinctrl_set_gpr_register(u8 gpr, u8 start_bit, u8 num_bits, u32 value)
+{
+	u32 reg;
+
+	/* general purpose register is 32 bits size */
+	WARN_ON(!imx_pinctrl || start_bit > 31 || num_bits > 32);
+
+	reg = readl(imx_pinctrl->base + gpr * 4);
+	reg &= ~(((1 << num_bits) - 1) << start_bit);
+	reg |= (value << start_bit);
+	writel(reg, imx_pinctrl->base + gpr * 4);
+}
+EXPORT_SYMBOL_GPL(imx_pinctrl_set_gpr_register);
+
 static const struct imx_pin_reg *imx_find_pin_reg(
 				const struct imx_pinctrl_soc_info *info,
 				unsigned pin, bool is_mux, unsigned mux)
@@ -587,6 +605,7 @@ int __devinit imx_pinctrl_probe(struct platform_device *pdev,
 	if (!ipctl->base)
 		return -EBUSY;
 
+	imx_pinctrl = ipctl;
 	imx_pinctrl_desc.name = dev_name(&pdev->dev);
 	imx_pinctrl_desc.pins = info->pins;
 	imx_pinctrl_desc.npins = info->npins;
diff --git a/include/linux/fsl/imx-pinctrl.h b/include/linux/fsl/imx-pinctrl.h
new file mode 100644
index 0000000..0212948
--- /dev/null
+++ b/include/linux/fsl/imx-pinctrl.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2012 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __FSL_IMX_PINCTRL_H__
+#define __FSL_IMX_PINCTRL_H__
+
+#ifdef CONFIG_PINCTRL_IMX
+extern void imx_pinctrl_set_gpr_register(u8 gpr, u8 start_bit,
+					u8 num_bits, u32 value);
+#else
+static inline void imx_pinctrl_set_gpr_register(u8 gpr, u8 start_bit,
+						u8 num_bits, u32 value)
+{
+	WARN(1, "CONFIG_PINCTRL_IMX is not selected, simply return\n");
+	return;
+}
+#endif
+
+#endif /* !__FSL_IMX_PINCTRL_H__ */
-- 
1.7.0.4

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

end of thread, other threads:[~2012-07-17  2:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-06  9:09 [PATCH 1/2] pinctrl: pinctrl-imx: add support for set bits for general purpose registers Dong Aisheng
2012-07-06  9:09 ` [PATCH 2/2] pinctrl: pinctrl-imx6q: add missed mux function for USBOTG_ID Dong Aisheng
2012-07-14 19:59   ` Linus Walleij
2012-07-06 15:52 ` [PATCH 1/2] pinctrl: pinctrl-imx: add support for set bits for general purpose registers Stephen Warren
2012-07-09  7:10   ` Dong Aisheng
2012-07-11  9:33     ` Richard Zhao
2012-07-11 11:35       ` Dong Aisheng
2012-07-14 20:24 ` Linus Walleij
2012-07-17  2:41   ` Dong Aisheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).