50414596d980e5cccc7adcd1430cb31e515db48c
[openwrt/staging/chunkeey.git] / target / linux / ipq806x / patches-4.19 / 850-soc-add-qualcomm-syscon.patch
1 From: Christian Lamparter <chunkeey@googlemail.com>
2 Subject: SoC: add qualcomm syscon
3 --- a/drivers/soc/qcom/Makefile
4 +++ b/drivers/soc/qcom/Makefile
5 @@ -18,6 +18,7 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_st
6 obj-$(CONFIG_QCOM_SMP2P) += smp2p.o
7 obj-$(CONFIG_QCOM_SMSM) += smsm.o
8 obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
9 +obj-$(CONFIG_QCOM_TCSR) += qcom_tcsr.o
10 obj-$(CONFIG_QCOM_APR) += apr.o
11 obj-$(CONFIG_QCOM_LLCC) += llcc-slice.o
12 obj-$(CONFIG_QCOM_SDM845_LLCC) += llcc-sdm845.o
13 --- a/drivers/soc/qcom/Kconfig
14 +++ b/drivers/soc/qcom/Kconfig
15 @@ -146,6 +146,13 @@ config QCOM_SMSM
16 Say yes here to support the Qualcomm Shared Memory State Machine.
17 The state machine is represented by bits in shared memory.
18
19 +config QCOM_TCSR
20 + tristate "QCOM Top Control and Status Registers"
21 + depends on ARCH_QCOM
22 + help
23 + Say y here to enable TCSR support. The TCSR provides control
24 + functions for various peripherals.
25 +
26 config QCOM_WCNSS_CTRL
27 tristate "Qualcomm WCNSS control driver"
28 depends on ARCH_QCOM
29 --- /dev/null
30 +++ b/drivers/soc/qcom/qcom_tcsr.c
31 @@ -0,0 +1,64 @@
32 +/*
33 + * Copyright (c) 2014, The Linux foundation. All rights reserved.
34 + *
35 + * This program is free software; you can redistribute it and/or modify
36 + * it under the terms of the GNU General Public License rev 2 and
37 + * only rev 2 as published by the free Software foundation.
38 + *
39 + * This program is distributed in the hope that it will be useful,
40 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 + * MERCHANTABILITY or fITNESS fOR A PARTICULAR PURPOSE. See the
42 + * GNU General Public License for more details.
43 + */
44 +
45 +#include <linux/clk.h>
46 +#include <linux/err.h>
47 +#include <linux/io.h>
48 +#include <linux/module.h>
49 +#include <linux/of.h>
50 +#include <linux/of_platform.h>
51 +#include <linux/platform_device.h>
52 +
53 +#define TCSR_USB_PORT_SEL 0xb0
54 +
55 +static int tcsr_probe(struct platform_device *pdev)
56 +{
57 + struct resource *res;
58 + const struct device_node *node = pdev->dev.of_node;
59 + void __iomem *base;
60 + u32 val;
61 +
62 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
63 + base = devm_ioremap_resource(&pdev->dev, res);
64 + if (IS_ERR(base))
65 + return PTR_ERR(base);
66 +
67 + if (!of_property_read_u32(node, "qcom,usb-ctrl-select", &val)) {
68 + dev_err(&pdev->dev, "setting usb port select = %d\n", val);
69 + writel(val, base + TCSR_USB_PORT_SEL);
70 + }
71 +
72 + return 0;
73 +}
74 +
75 +static const struct of_device_id tcsr_dt_match[] = {
76 + { .compatible = "qcom,tcsr", },
77 + { },
78 +};
79 +
80 +MODULE_DEVICE_TABLE(of, tcsr_dt_match);
81 +
82 +static struct platform_driver tcsr_driver = {
83 + .driver = {
84 + .name = "tcsr",
85 + .owner = THIS_MODULE,
86 + .of_match_table = tcsr_dt_match,
87 + },
88 + .probe = tcsr_probe,
89 +};
90 +
91 +module_platform_driver(tcsr_driver);
92 +
93 +MODULE_AUTHOR("Andy Gross <agross@codeaurora.org>");
94 +MODULE_DESCRIPTION("QCOM TCSR driver");
95 +MODULE_LICENSE("GPL v2");
96 --- /dev/null
97 +++ b/include/dt-bindings/soc/qcom,tcsr.h
98 @@ -0,0 +1,23 @@
99 +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
100 + *
101 + * This program is free software; you can redistribute it and/or modify
102 + * it under the terms of the GNU General Public License version 2 and
103 + * only version 2 as published by the Free Software Foundation.
104 + *
105 + * This program is distributed in the hope that it will be useful,
106 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
107 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108 + * GNU General Public License for more details.
109 + */
110 +#ifndef __DT_BINDINGS_QCOM_TCSR_H
111 +#define __DT_BINDINGS_QCOM_TCSR_H
112 +
113 +#define TCSR_USB_SELECT_USB3_P0 0x1
114 +#define TCSR_USB_SELECT_USB3_P1 0x2
115 +#define TCSR_USB_SELECT_USB3_DUAL 0x3
116 +
117 +/* TCSR A/B REG */
118 +#define IPQ806X_TCSR_REG_A_ADM_CRCI_MUX_SEL 0
119 +#define IPQ806X_TCSR_REG_B_ADM_CRCI_MUX_SEL 1
120 +
121 +#endif