Skip to contentSkip to conversation

Add Qualcomm TCSR driver

PATCH In review Andy Gross 4 participants 8 messages Jan 8, 2015 – Jan 9, 2015

Subsystems (3)
lore
Share & tools
lore

Andy Gross

author
#0 lore raw

cover Add Qualcomm TCSR driver

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
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
author
#1 lore raw

PATCH 1/2 soc: qcom: Add TCSR driver

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.

---
 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
drivers/soc/qcom/Kconfig +7 -0
index 7bd2c94..950c218 100644
@@ -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.
drivers/soc/qcom/Makefile +1 -0
index 4389012..f0c287c 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
+obj-$(CONFIG_QCOM_TCSR) +=	qcom_tcsr.o
drivers/soc/qcom/qcom_tcsr.c new file +83 -0

83 lines not on this page · raw message

include/soc/qcom/qcom_tcsr.h new file +21 -0
new file mode 100644
index 0000000..cbdd3c8
@@ -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
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw

Re: [PATCH 1/2] soc: qcom: Add TCSR driver

drivers/soc/qcom/qcom_tcsr.c line 73

Quoted 5 lines · Andy Gross
drivers/soc/qcom/qcom_tcsr.c new file +5 -0
+
+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!

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#3 lore raw

Re: [PATCH 1/2] soc: qcom: Add TCSR driver

Quoted 9 lines · Stephen Boyd

drivers/soc/qcom/qcom_tcsr.c line 73

Quoted 5 lines · Andy Gross
drivers/soc/qcom/qcom_tcsr.c new file +5 -0
+
+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......

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#4 lore raw

Re: [PATCH 1/2] soc: qcom: Add TCSR driver

In reply to Andy Gross
Quoted 7 lines · 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.

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

Arnd

author
#5 lore raw

Re: [PATCH 1/2] soc: qcom: Add TCSR driver

Quoted 11 lines · Arnd Bergmann
Quoted 7 lines · 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.

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.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#6 lore raw

Re: [PATCH 1/2] soc: qcom: Add TCSR driver

Quoted 7 lines · Andy Gross
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · 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.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

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

author
#7 lore raw

PATCH 2/2 soc: qcom: Add device tree binding for TCSR

In reply to Andy Gross

Add device tree binding support for the QCOM TCSR driver.

---
 .../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
Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt new file +33 -0
new file mode 100644
index 0000000..782a307
@@ -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 at 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)>;
+		};
+
+
include/dt-bindings/soc/qcom,tcsr.h new file +34 -0
new file mode 100644
index 0000000..8e18354
@@ -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
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation