ipq806x: Add support for IPQ806x chip family
[openwrt/openwrt.git] / target / linux / ipq806x / patches / 0153-soc-qcom-tcsr-Add-TCSR-driver.patch
1 From 0b469f3f4c0e6a0e0b1b60a059600e325a03b6f5 Mon Sep 17 00:00:00 2001
2 From: Andy Gross <agross@codeaurora.org>
3 Date: Thu, 12 Jun 2014 00:52:06 -0500
4 Subject: [PATCH 153/182] soc: qcom: tcsr: Add TCSR driver
5
6 This patch adds support for the TCSR IP block present in Qualcomm processors.
7
8 Signed-off-by: Andy Gross <agross@codeaurora.org>
9 ---
10 .../devicetree/bindings/soc/qcom/qcom,tcsr.txt | 25 ++++++++
11 drivers/soc/qcom/Kconfig | 6 ++
12 drivers/soc/qcom/Makefile | 1 +
13 drivers/soc/qcom/qcom_tcsr.c | 64 ++++++++++++++++++++
14 include/dt-bindings/soc/qcom,tcsr.h | 19 ++++++
15 5 files changed, 115 insertions(+)
16 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt
17 create mode 100644 drivers/soc/qcom/qcom_tcsr.c
18 create mode 100644 include/dt-bindings/soc/qcom,tcsr.h
19
20 diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt
21 new file mode 100644
22 index 0000000..6ea74c1
23 --- /dev/null
24 +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,tcsr.txt
25 @@ -0,0 +1,25 @@
26 +QCOM TCSR (Top Control and Status Register) Driver
27 +
28 +The TCSR provides miscellaneous control functions and status registers for
29 +Qualcomm processors.
30 +
31 +Required properties:
32 +- compatible: must contain "qcom,tcsr" for IPQ806x
33 +- reg: Address range for TCSR registers
34 +
35 +Optional properties:
36 +- qcom,usb-ctrl-select : indicates USB port type selection. Please reference
37 + dt-bindings/soc/qcom,tcsr.h for valid USB port selection values.
38 +
39 +Example for IPQ8064:
40 +
41 +#include <dt-bindings/soc/qcom,tcsr.h>
42 +
43 + tcsr: tcsr@1a400000 {
44 + compatible = "qcom,tcsr";
45 + reg = <0x1a400000 0x100>;
46 +
47 + qcom,usb-ctrl-select = <TCSR_USB_SELECT_USB3_DUAL>;
48 + };
49 +
50 +
51 diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
52 index 7bd2c94..3e4486a 100644
53 --- a/drivers/soc/qcom/Kconfig
54 +++ b/drivers/soc/qcom/Kconfig
55 @@ -9,3 +9,9 @@ config QCOM_GSBI
56 functions for connecting the underlying serial UART, SPI, and I2C
57 devices to the output pins.
58
59 +config QCOM_TCSR
60 + tristate "QCOM Top Control and Status Registers"
61 + depends on ARCH_QCOM
62 + help
63 + Say y here to enable TCSR support. The TCSR provides control
64 + functions for various peripherals.
65 diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
66 index 4389012..d299492 100644
67 --- a/drivers/soc/qcom/Makefile
68 +++ b/drivers/soc/qcom/Makefile
69 @@ -1 +1,2 @@
70 obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o
71 +obj-$(CONFIG_QCOM_TCSR) += qcom_tcsr.o
72 diff --git a/drivers/soc/qcom/qcom_tcsr.c b/drivers/soc/qcom/qcom_tcsr.c
73 new file mode 100644
74 index 0000000..dd33153
75 --- /dev/null
76 +++ b/drivers/soc/qcom/qcom_tcsr.c
77 @@ -0,0 +1,64 @@
78 +/*
79 + * Copyright (c) 2014, The Linux foundation. All rights reserved.
80 + *
81 + * This program is free software; you can redistribute it and/or modify
82 + * it under the terms of the GNU General Public License rev 2 and
83 + * only rev 2 as published by the free Software foundation.
84 + *
85 + * This program is distributed in the hope that it will be useful,
86 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
87 + * MERCHANTABILITY or fITNESS fOR A PARTICULAR PURPOSE. See the
88 + * GNU General Public License for more details.
89 + */
90 +
91 +#include <linux/clk.h>
92 +#include <linux/err.h>
93 +#include <linux/io.h>
94 +#include <linux/module.h>
95 +#include <linux/of.h>
96 +#include <linux/of_platform.h>
97 +#include <linux/platform_device.h>
98 +
99 +#define TCSR_USB_PORT_SEL 0xb0
100 +
101 +static int tcsr_probe(struct platform_device *pdev)
102 +{
103 + struct resource *res;
104 + const struct device_node *node = pdev->dev.of_node;
105 + void __iomem *base;
106 + u32 val;
107 +
108 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
109 + base = devm_ioremap_resource(&pdev->dev, res);
110 + if (IS_ERR(base))
111 + return PTR_ERR(base);
112 +
113 + if (!of_property_read_u32(node, "qcom,usb-ctrl-select", &val)) {
114 + dev_err(&pdev->dev, "setting usb port select = %d\n", val);
115 + writel(val, base + TCSR_USB_PORT_SEL);
116 + }
117 +
118 + return 0;
119 +}
120 +
121 +static const struct of_device_id tcsr_dt_match[] = {
122 + { .compatible = "qcom,tcsr", },
123 + { },
124 +};
125 +
126 +MODULE_DEVICE_TABLE(of, tcsr_dt_match);
127 +
128 +static struct platform_driver tcsr_driver = {
129 + .driver = {
130 + .name = "tcsr",
131 + .owner = THIS_MODULE,
132 + .of_match_table = tcsr_dt_match,
133 + },
134 + .probe = tcsr_probe,
135 +};
136 +
137 +module_platform_driver(tcsr_driver);
138 +
139 +MODULE_AUTHOR("Andy Gross <agross@codeaurora.org>");
140 +MODULE_DESCRIPTION("QCOM TCSR driver");
141 +MODULE_LICENSE("GPL v2");
142 diff --git a/include/dt-bindings/soc/qcom,tcsr.h b/include/dt-bindings/soc/qcom,tcsr.h
143 new file mode 100644
144 index 0000000..c9d497a
145 --- /dev/null
146 +++ b/include/dt-bindings/soc/qcom,tcsr.h
147 @@ -0,0 +1,19 @@
148 +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
149 + *
150 + * This program is free software; you can redistribute it and/or modify
151 + * it under the terms of the GNU General Public License version 2 and
152 + * only version 2 as published by the Free Software Foundation.
153 + *
154 + * This program is distributed in the hope that it will be useful,
155 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
156 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
157 + * GNU General Public License for more details.
158 + */
159 +#ifndef __DT_BINDINGS_QCOM_TCSR_H
160 +#define __DT_BINDINGS_QCOM_TCSR_H
161 +
162 +#define TCSR_USB_SELECT_USB3_P0 0x1
163 +#define TCSR_USB_SELECT_USB3_P1 0x2
164 +#define TCSR_USB_SELECT_USB3_DUAL 0x3
165 +
166 +#endif
167 --
168 1.7.10.4
169