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