devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add Qualcomm TCSR driver
@ 2015-01-08 22:52 Andy Gross
  2015-01-08 22:52 ` [PATCH 1/2] soc: qcom: Add " Andy Gross
  2015-01-08 22:52 ` [PATCH 2/2] soc: qcom: Add device tree binding for TCSR Andy Gross
  0 siblings, 2 replies; 8+ messages in thread
From: Andy Gross @ 2015-01-08 22:52 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: linux-arm-kernel, linux-kernel, Bjorn Andersson, Kumar Gala,
	devicetree, Andy Gross

This patch set adds a driver for the TCSR (Top Control and Status Register)
block that is present in the IPQ8064, APQ8064, and some later processors.  The
TCSR is responsible for accessing configuration and mux settings for a variety
of peripherals.

The initial version of this driver exposes configuration settings for the USB
PHY selection and ADM DMA CRCI muxing.

Andy Gross (2):
  soc: qcom: Add TCSR driver
  soc: qcom: Add device tree binding for TCSR

 .../devicetree/bindings/soc/qcom/qcom,tcsr.txt     |   33 ++++++++
 drivers/soc/qcom/Kconfig                           |    7 ++
 drivers/soc/qcom/Makefile                          |    1 +
 drivers/soc/qcom/qcom_tcsr.c                       |   83 ++++++++++++++++++++
 include/dt-bindings/soc/qcom,tcsr.h                |   34 ++++++++
 include/soc/qcom/qcom_tcsr.h                       |   21 +++++
 6 files changed, 179 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt
 create mode 100644 drivers/soc/qcom/qcom_tcsr.c
 create mode 100644 include/dt-bindings/soc/qcom,tcsr.h
 create mode 100644 include/soc/qcom/qcom_tcsr.h

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

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

* [PATCH 1/2] soc: qcom: Add TCSR driver
  2015-01-08 22:52 [PATCH 0/2] Add Qualcomm TCSR driver Andy Gross
@ 2015-01-08 22:52 ` Andy Gross
  2015-01-08 23:39   ` Stephen Boyd
       [not found]   ` <1420757577-20425-2-git-send-email-agross-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
  2015-01-08 22:52 ` [PATCH 2/2] soc: qcom: Add device tree binding for TCSR Andy Gross
  1 sibling, 2 replies; 8+ messages in thread
From: Andy Gross @ 2015-01-08 22:52 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: linux-arm-kernel, linux-kernel, Bjorn Andersson, Kumar Gala,
	devicetree, Andy Gross

This patch adds support for the TCSR (Top Control and Status Register) IP block
that is present in the Qualcomm IPQ8064, APQ8064, and some later processors.
This block contains additional configuration and mux settings for various
peripherals in the system, including the ADM DMA block and USB controller.

Signed-off-by: Andy Gross <agross@codeaurora.org>
---
 drivers/soc/qcom/Kconfig     |    7 ++++
 drivers/soc/qcom/Makefile    |    1 +
 drivers/soc/qcom/qcom_tcsr.c |   83 ++++++++++++++++++++++++++++++++++++++++++
 include/soc/qcom/qcom_tcsr.h |   21 +++++++++++
 4 files changed, 112 insertions(+)
 create mode 100644 drivers/soc/qcom/qcom_tcsr.c
 create mode 100644 include/soc/qcom/qcom_tcsr.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 7bd2c94..950c218 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -9,3 +9,10 @@ config QCOM_GSBI
           functions for connecting the underlying serial UART, SPI, and I2C
           devices to the output pins.
 
+config QCOM_TCSR
+	tristate "QCOM Top Control and Status Registers"
+	depends on ARCH_QCOM
+	help
+	  Say y here to enable TCSR support.  The TCSR provides control
+	  functions for various peripherals, like selection of USB port type and
+	  GSBI CRCI muxing.
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 4389012..f0c287c 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
+obj-$(CONFIG_QCOM_TCSR) +=	qcom_tcsr.o
diff --git a/drivers/soc/qcom/qcom_tcsr.c b/drivers/soc/qcom/qcom_tcsr.c
new file mode 100644
index 0000000..f8d5ef8
--- /dev/null
+++ b/drivers/soc/qcom/qcom_tcsr.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2014-2015, The Linux foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License rev 2 and
+ * only rev 2 as published by the free Software foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or fITNESS fOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <soc/qcom/qcom_tcsr.h>
+
+#define TCSR_ADM_A_CRCI_MUX_SEL	0x70
+#define TCSR_ADM_B_CRCI_MUX_SEL	0x74
+#define TCSR_USB_PORT_SEL	0xb0
+
+static int initialized;
+
+int qcom_tcsr_is_initialized(void)
+{
+	return !initialized;
+}
+EXPORT_SYMBOL(qcom_tcsr_is_initialized);
+
+static int qcom_tcsr_probe(struct platform_device *pdev)
+{
+	struct resource *res;
+	const struct device_node *node = pdev->dev.of_node;
+	void __iomem *base;
+	u32 val;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	if (!of_property_read_u32(node, "qcom,usb-ctrl-select", &val)) {
+		dev_info(&pdev->dev, "setting usb port select = %d\n", val);
+		writel(val, base + TCSR_USB_PORT_SEL);
+	}
+
+	if (!of_property_read_u32(node, "qcom,adm-a-crci-mux-sel", &val))
+		writel(val, base + TCSR_ADM_A_CRCI_MUX_SEL);
+
+	if (!of_property_read_u32(node, "qcom,adm-b-crci-mux-sel", &val))
+		writel(val, base + TCSR_ADM_B_CRCI_MUX_SEL);
+
+	initialized = 1;
+
+	return 0;
+}
+
+static const struct of_device_id qcom_tcsr_dt_match[] = {
+	{ .compatible = "qcom,tcsr", },
+	{ },
+};
+
+MODULE_DEVICE_TABLE(of, qcom_tcsr_dt_match);
+
+static struct platform_driver qcom_tcsr_driver = {
+	.driver = {
+		.name		= "tcsr",
+		.owner		= THIS_MODULE,
+		.of_match_table	= qcom_tcsr_dt_match,
+	},
+	.probe = qcom_tcsr_probe,
+};
+
+module_platform_driver(qcom_tcsr_driver);
+
+MODULE_AUTHOR("Andy Gross <agross@codeaurora.org>");
+MODULE_DESCRIPTION("QCOM TCSR driver");
+MODULE_LICENSE("GPL v2");
diff --git a/include/soc/qcom/qcom_tcsr.h b/include/soc/qcom/qcom_tcsr.h
new file mode 100644
index 0000000..cbdd3c8
--- /dev/null
+++ b/include/soc/qcom/qcom_tcsr.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2015, The Linux foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License rev 2 and
+ * only rev 2 as published by the free Software foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or fITNESS fOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef _QCOM_TCSR_H
+
+#ifdef CONFIG_QCOM_TCSR
+int qcom_tcsr_is_initialized(void);
+#else
+static inline int qcom_tcsr_is_initialized(void) {return -ENODEV; }
+#endif
+
+#endif
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

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

* [PATCH 2/2] soc: qcom: Add device tree binding for TCSR
  2015-01-08 22:52 [PATCH 0/2] Add Qualcomm TCSR driver Andy Gross
  2015-01-08 22:52 ` [PATCH 1/2] soc: qcom: Add " Andy Gross
@ 2015-01-08 22:52 ` Andy Gross
  1 sibling, 0 replies; 8+ messages in thread
From: Andy Gross @ 2015-01-08 22:52 UTC (permalink / raw)
  To: linux-arm-msm
  Cc: linux-arm-kernel, linux-kernel, Bjorn Andersson, Kumar Gala,
	devicetree, Andy Gross

Add device tree binding support for the QCOM TCSR driver.

Signed-off-by: Andy Gross <agross@codeaurora.org>
---
 .../devicetree/bindings/soc/qcom/qcom,tcsr.txt     |   33 +++++++++++++++++++
 include/dt-bindings/soc/qcom,tcsr.h                |   34 ++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt
 create mode 100644 include/dt-bindings/soc/qcom,tcsr.h

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt
new file mode 100644
index 0000000..782a307
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt
@@ -0,0 +1,33 @@
+QCOM TCSR (Top Control and Status Register) Driver
+
+The TCSR provides miscellaneous control functions and status registers for
+Qualcomm processors.
+
+Required properties:
+- compatible: must contain "qcom,tcsr" for IPQ806x and APQ8064
+- reg: Address range for TCSR registers
+
+Optional properties:
+- qcom,usb-ctrl-select : indicates USB port type selection.  Please reference
+  dt-bindings/soc/qcom,tcsr.h for valid USB port selection values.
+- qcom,adm-a-crci-mux-sel : indicates the CRCI mux settings for peripherals.
+  Please reference dt-bindings/soc/qcom,tcsr.h for valid selection values.
+- qcom,adm-b-crci-mux-sel : indicates the CRCI mux settings for peripherals.
+  Please reference dt-bindings/soc/qcom,tcsr.h for valid selection values.
+
+Example for IPQ8064:
+
+#include <dt-bindings/soc/qcom,tcsr.h>
+
+		tcsr: tcsr@1a400000 {
+			compatible = "qcom,tcsr";
+			reg = <0x1a400000 0x100>;
+
+			qcom,usb-ctrl-select = <TCSR_USB_SELECT_USB3_DUAL>;
+			qcom,adm-a-crci-mux-sel =
+				< TCSR_ADM_CRCI_SEL(GSBI1, ADM_CRCI_QUP)>;
+			qcom,adm-b-crci-mux-sel =
+				< TCSR_ADM_CRCI_SEL(GSBI1, ADM_CRCI_QUP)>;
+		};
+
+
diff --git a/include/dt-bindings/soc/qcom,tcsr.h b/include/dt-bindings/soc/qcom,tcsr.h
new file mode 100644
index 0000000..8e18354
--- /dev/null
+++ b/include/dt-bindings/soc/qcom,tcsr.h
@@ -0,0 +1,34 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef __DT_BINDINGS_QCOM_TCSR_H
+#define __DT_BINDINGS_QCOM_TCSR_H
+
+#define TCSR_USB_SELECT_USB3_P0		0x1
+#define TCSR_USB_SELECT_USB3_P1		0x2
+#define TCSR_USB_SELECT_USB3_DUAL	0x3
+
+#define GSBI1				1
+#define GSBI2				2
+#define GSBI3				3
+#define GSBI4				4
+#define GSBI5				5
+#define GSBI6				6
+#define GSBI7				7
+
+/* values are in pairs - RX/TX.  So both are 0 or both are 1 */
+#define ADM_CRCI_QUP			0
+#define ADM_CRCI_UART			3
+
+/* calculate CRCI value by shifting the value by correct shift */
+#define TCSR_ADM_CRCI_SEL(gsbi, val)	(val << (gsbi-1)*2)
+
+#endif
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

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

* Re: [PATCH 1/2] soc: qcom: Add TCSR driver
  2015-01-08 22:52 ` [PATCH 1/2] soc: qcom: Add " Andy Gross
@ 2015-01-08 23:39   ` Stephen Boyd
       [not found]     ` <54AF1540.6090800-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
       [not found]   ` <1420757577-20425-2-git-send-email-agross-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Stephen Boyd @ 2015-01-08 23:39 UTC (permalink / raw)
  To: Andy Gross, linux-arm-msm
  Cc: devicetree, Kumar Gala, linux-kernel, Bjorn Andersson,
	linux-arm-kernel

On 01/08/2015 02:52 PM, Andy Gross wrote:
> +
> +static struct platform_driver qcom_tcsr_driver = {
> +	.driver = {
> +		.name		= "tcsr",
> +		.owner		= THIS_MODULE,

This is done by the module_platform_driver() macro now so it's largely
unnecessary. Best to remove it so that the janitors don't find you!

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 1/2] soc: qcom: Add TCSR driver
       [not found]   ` <1420757577-20425-2-git-send-email-agross-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
@ 2015-01-09  0:06     ` Arnd Bergmann
  2015-01-09 17:13       ` Andy Gross
  0 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2015-01-09  0:06 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Andy Gross, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Kumar Gala,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Bjorn Andersson

On Thursday 08 January 2015 16:52:56 Andy Gross wrote:
> This patch adds support for the TCSR (Top Control and Status Register) IP block
> that is present in the Qualcomm IPQ8064, APQ8064, and some later processors.
> This block contains additional configuration and mux settings for various
> peripherals in the system, including the ADM DMA block and USB controller.
> 
> Signed-off-by: Andy Gross <agross-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
> 

It sounds like this is a collection of random registers. Have you considered
making it a syscon node instead?

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] soc: qcom: Add TCSR driver
       [not found]     ` <54AF1540.6090800-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
@ 2015-01-09 17:10       ` Andy Gross
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Gross @ 2015-01-09 17:10 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Kumar Gala,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Bjorn Andersson,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Thu, Jan 08, 2015 at 03:39:44PM -0800, Stephen Boyd wrote:
> On 01/08/2015 02:52 PM, Andy Gross wrote:
> > +
> > +static struct platform_driver qcom_tcsr_driver = {
> > +	.driver = {
> > +		.name		= "tcsr",
> > +		.owner		= THIS_MODULE,
> 
> This is done by the module_platform_driver() macro now so it's largely
> unnecessary. Best to remove it so that the janitors don't find you!

Old habits die hard......

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] soc: qcom: Add TCSR driver
  2015-01-09  0:06     ` Arnd Bergmann
@ 2015-01-09 17:13       ` Andy Gross
  2015-01-09 18:31         ` Bjorn Andersson
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Gross @ 2015-01-09 17:13 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Kumar Gala,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Bjorn Andersson

On Fri, Jan 09, 2015 at 01:06:56AM +0100, Arnd Bergmann wrote:
> On Thursday 08 January 2015 16:52:56 Andy Gross wrote:
> > This patch adds support for the TCSR (Top Control and Status Register) IP block
> > that is present in the Qualcomm IPQ8064, APQ8064, and some later processors.
> > This block contains additional configuration and mux settings for various
> > peripherals in the system, including the ADM DMA block and USB controller.
> > 
> > Signed-off-by: Andy Gross <agross-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
> > 
> 
> It sounds like this is a collection of random registers. Have you considered
> making it a syscon node instead?

That's a capital idea and solves my probe_defer issue more cleanly.  I'll rework
and resend.

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] soc: qcom: Add TCSR driver
  2015-01-09 17:13       ` Andy Gross
@ 2015-01-09 18:31         ` Bjorn Andersson
  0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Andersson @ 2015-01-09 18:31 UTC (permalink / raw)
  To: Andy Gross
  Cc: Arnd Bergmann, linux-arm-kernel@lists.infradead.org,
	linux-arm-msm, devicetree@vger.kernel.org, Kumar Gala,
	linux-kernel@vger.kernel.org, Bjorn Andersson

On Fri, Jan 9, 2015 at 9:13 AM, Andy Gross <agross@codeaurora.org> wrote:
> On Fri, Jan 09, 2015 at 01:06:56AM +0100, Arnd Bergmann wrote:
>> On Thursday 08 January 2015 16:52:56 Andy Gross wrote:
>> > This patch adds support for the TCSR (Top Control and Status Register) IP block
>> > that is present in the Qualcomm IPQ8064, APQ8064, and some later processors.
>> > This block contains additional configuration and mux settings for various
>> > peripherals in the system, including the ADM DMA block and USB controller.
>> >
>> > Signed-off-by: Andy Gross <agross@codeaurora.org>
>> >
>>
>> It sounds like this is a collection of random registers. Have you considered
>> making it a syscon node instead?
>
> That's a capital idea and solves my probe_defer issue more cleanly.  I'll rework
> and resend.
>

Then I guess I need to rework the tcsr-mutex driver to operate on top
a syson instead.

Do we want the same for the sfpb mutex or should I continue to ioremap for that?

Regards,
Bjorn

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

end of thread, other threads:[~2015-01-09 18:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-08 22:52 [PATCH 0/2] Add Qualcomm TCSR driver Andy Gross
2015-01-08 22:52 ` [PATCH 1/2] soc: qcom: Add " Andy Gross
2015-01-08 23:39   ` Stephen Boyd
     [not found]     ` <54AF1540.6090800-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-01-09 17:10       ` Andy Gross
     [not found]   ` <1420757577-20425-2-git-send-email-agross-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2015-01-09  0:06     ` Arnd Bergmann
2015-01-09 17:13       ` Andy Gross
2015-01-09 18:31         ` Bjorn Andersson
2015-01-08 22:52 ` [PATCH 2/2] soc: qcom: Add device tree binding for TCSR Andy Gross

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).