ipq40xx: Add patches for 4.19
[oweals/openwrt.git] / target / linux / ipq40xx / 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,98 @@
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 +#define TCSR_USB_HSPHY_CONFIG  0xC
55 +
56 +#define TCSR_ESS_INTERFACE_SEL_OFFSET   0x0
57 +#define TCSR_ESS_INTERFACE_SEL_MASK     0xf
58 +
59 +#define TCSR_WIFI0_GLB_CFG_OFFSET      0x0
60 +#define TCSR_WIFI1_GLB_CFG_OFFSET      0x4
61 +#define TCSR_PNOC_SNOC_MEMTYPE_M0_M2   0x4
62 +
63 +static int tcsr_probe(struct platform_device *pdev)
64 +{
65 +       struct resource *res;
66 +       const struct device_node *node = pdev->dev.of_node;
67 +       void __iomem *base;
68 +       u32 val;
69 +
70 +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
71 +       base = devm_ioremap_resource(&pdev->dev, res);
72 +       if (IS_ERR(base))
73 +               return PTR_ERR(base);
74 +
75 +       if (!of_property_read_u32(node, "qcom,usb-ctrl-select", &val)) {
76 +               dev_err(&pdev->dev, "setting usb port select = %d\n", val);
77 +               writel(val, base + TCSR_USB_PORT_SEL);
78 +       }
79 +
80 +       if (!of_property_read_u32(node, "qcom,usb-hsphy-mode-select", &val)) {
81 +               dev_info(&pdev->dev, "setting usb hs phy mode select = %x\n", val);
82 +               writel(val, base + TCSR_USB_HSPHY_CONFIG);
83 +       }
84 +
85 +       if (!of_property_read_u32(node, "qcom,ess-interface-select", &val)) {
86 +               u32 tmp = 0;
87 +               dev_info(&pdev->dev, "setting ess interface select = %x\n", val);
88 +               tmp = readl(base + TCSR_ESS_INTERFACE_SEL_OFFSET);
89 +               tmp = tmp & (~TCSR_ESS_INTERFACE_SEL_MASK);
90 +               tmp = tmp | (val&TCSR_ESS_INTERFACE_SEL_MASK);
91 +               writel(tmp, base + TCSR_ESS_INTERFACE_SEL_OFFSET);
92 +        }
93 +
94 +       if (!of_property_read_u32(node, "qcom,wifi_glb_cfg", &val)) {
95 +               dev_info(&pdev->dev, "setting wifi_glb_cfg = %x\n", val);
96 +               writel(val, base + TCSR_WIFI0_GLB_CFG_OFFSET);
97 +               writel(val, base + TCSR_WIFI1_GLB_CFG_OFFSET);
98 +       }
99 +
100 +       if (!of_property_read_u32(node, "qcom,wifi_noc_memtype_m0_m2", &val)) {
101 +               dev_info(&pdev->dev,
102 +                       "setting wifi_noc_memtype_m0_m2 = %x\n", val);
103 +               writel(val, base + TCSR_PNOC_SNOC_MEMTYPE_M0_M2);
104 +       }
105 +
106 +       return 0;
107 +}
108 +
109 +static const struct of_device_id tcsr_dt_match[] = {
110 +       { .compatible = "qcom,tcsr", },
111 +       { },
112 +};
113 +
114 +MODULE_DEVICE_TABLE(of, tcsr_dt_match);
115 +
116 +static struct platform_driver tcsr_driver = {
117 +       .driver = {
118 +               .name           = "tcsr",
119 +               .owner          = THIS_MODULE,
120 +               .of_match_table = tcsr_dt_match,
121 +       },
122 +       .probe = tcsr_probe,
123 +};
124 +
125 +module_platform_driver(tcsr_driver);
126 +
127 +MODULE_AUTHOR("Andy Gross <agross@codeaurora.org>");
128 +MODULE_DESCRIPTION("QCOM TCSR driver");
129 +MODULE_LICENSE("GPL v2");
130 --- /dev/null
131 +++ b/include/dt-bindings/soc/qcom,tcsr.h
132 @@ -0,0 +1,48 @@
133 +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
134 + *
135 + * This program is free software; you can redistribute it and/or modify
136 + * it under the terms of the GNU General Public License version 2 and
137 + * only version 2 as published by the Free Software Foundation.
138 + *
139 + * This program is distributed in the hope that it will be useful,
140 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
141 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
142 + * GNU General Public License for more details.
143 + */
144 +#ifndef __DT_BINDINGS_QCOM_TCSR_H
145 +#define __DT_BINDINGS_QCOM_TCSR_H
146 +
147 +#define TCSR_USB_SELECT_USB3_P0                0x1
148 +#define TCSR_USB_SELECT_USB3_P1                0x2
149 +#define TCSR_USB_SELECT_USB3_DUAL      0x3
150 +
151 +/* IPQ40xx HS PHY Mode Select */
152 +#define TCSR_USB_HSPHY_HOST_MODE       0x00E700E7
153 +#define TCSR_USB_HSPHY_DEVICE_MODE     0x00C700E7
154 +
155 +/* IPQ40xx ess interface mode select */
156 +#define TCSR_ESS_PSGMII              0
157 +#define TCSR_ESS_PSGMII_RGMII5       1
158 +#define TCSR_ESS_PSGMII_RMII0        2
159 +#define TCSR_ESS_PSGMII_RMII1        4
160 +#define TCSR_ESS_PSGMII_RMII0_RMII1  6
161 +#define TCSR_ESS_PSGMII_RGMII4       9
162 +
163 +/*
164 + * IPQ40xx WiFi Global Config
165 + * Bit 30:AXID_EN
166 + * Enable AXI master bus Axid translating to confirm all txn submitted by order
167 + * Bit 24: Use locally generated socslv_wxi_bvalid
168 + * 1:  use locally generate socslv_wxi_bvalid for performance.
169 + * 0:  use SNOC socslv_wxi_bvalid.
170 + */
171 +#define TCSR_WIFI_GLB_CFG              0x41000000
172 +
173 +/* IPQ40xx MEM_TYPE_SEL_M0_M2 Select Bit 26:24 - 2 NORMAL */
174 +#define TCSR_WIFI_NOC_MEMTYPE_M0_M2    0x02222222
175 +
176 +/* TCSR A/B REG */
177 +#define IPQ806X_TCSR_REG_A_ADM_CRCI_MUX_SEL     0
178 +#define IPQ806X_TCSR_REG_B_ADM_CRCI_MUX_SEL     1
179 +
180 +#endif