850-soc-add-qualcomm-syscon.patch 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. From: Christian Lamparter <[email protected]>
  2. Subject: SoC: add qualcomm syscon
  3. --- a/drivers/soc/qcom/Makefile
  4. +++ b/drivers/soc/qcom/Makefile
  5. @@ -21,6 +21,7 @@ obj-$(CONFIG_QCOM_SMP2P) += smp2p.o
  6. obj-$(CONFIG_QCOM_SMSM) += smsm.o
  7. obj-$(CONFIG_QCOM_SOCINFO) += socinfo.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-qcom.o
  12. obj-$(CONFIG_QCOM_RPMHPD) += rpmhpd.o
  13. --- a/drivers/soc/qcom/Kconfig
  14. +++ b/drivers/soc/qcom/Kconfig
  15. @@ -192,6 +192,13 @@ config QCOM_SOCINFO
  16. Say yes here to support the Qualcomm socinfo driver, providing
  17. information about the SoC to user space.
  18. +config QCOM_TCSR
  19. + tristate "QCOM Top Control and Status Registers"
  20. + depends on ARCH_QCOM
  21. + help
  22. + Say y here to enable TCSR support. The TCSR provides control
  23. + functions for various peripherals.
  24. +
  25. config QCOM_WCNSS_CTRL
  26. tristate "Qualcomm WCNSS control driver"
  27. depends on ARCH_QCOM || COMPILE_TEST
  28. --- /dev/null
  29. +++ b/drivers/soc/qcom/qcom_tcsr.c
  30. @@ -0,0 +1,98 @@
  31. +/*
  32. + * Copyright (c) 2014, The Linux foundation. All rights reserved.
  33. + *
  34. + * This program is free software; you can redistribute it and/or modify
  35. + * it under the terms of the GNU General Public License rev 2 and
  36. + * only rev 2 as published by the free Software foundation.
  37. + *
  38. + * This program is distributed in the hope that it will be useful,
  39. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. + * MERCHANTABILITY or fITNESS fOR A PARTICULAR PURPOSE. See the
  41. + * GNU General Public License for more details.
  42. + */
  43. +
  44. +#include <linux/clk.h>
  45. +#include <linux/err.h>
  46. +#include <linux/io.h>
  47. +#include <linux/module.h>
  48. +#include <linux/of.h>
  49. +#include <linux/of_platform.h>
  50. +#include <linux/platform_device.h>
  51. +
  52. +#define TCSR_USB_PORT_SEL 0xb0
  53. +#define TCSR_USB_HSPHY_CONFIG 0xC
  54. +
  55. +#define TCSR_ESS_INTERFACE_SEL_OFFSET 0x0
  56. +#define TCSR_ESS_INTERFACE_SEL_MASK 0xf
  57. +
  58. +#define TCSR_WIFI0_GLB_CFG_OFFSET 0x0
  59. +#define TCSR_WIFI1_GLB_CFG_OFFSET 0x4
  60. +#define TCSR_PNOC_SNOC_MEMTYPE_M0_M2 0x4
  61. +
  62. +static int tcsr_probe(struct platform_device *pdev)
  63. +{
  64. + struct resource *res;
  65. + const struct device_node *node = pdev->dev.of_node;
  66. + void __iomem *base;
  67. + u32 val;
  68. +
  69. + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  70. + base = devm_ioremap_resource(&pdev->dev, res);
  71. + if (IS_ERR(base))
  72. + return PTR_ERR(base);
  73. +
  74. + if (!of_property_read_u32(node, "qcom,usb-ctrl-select", &val)) {
  75. + dev_err(&pdev->dev, "setting usb port select = %d\n", val);
  76. + writel(val, base + TCSR_USB_PORT_SEL);
  77. + }
  78. +
  79. + if (!of_property_read_u32(node, "qcom,usb-hsphy-mode-select", &val)) {
  80. + dev_info(&pdev->dev, "setting usb hs phy mode select = %x\n", val);
  81. + writel(val, base + TCSR_USB_HSPHY_CONFIG);
  82. + }
  83. +
  84. + if (!of_property_read_u32(node, "qcom,ess-interface-select", &val)) {
  85. + u32 tmp = 0;
  86. + dev_info(&pdev->dev, "setting ess interface select = %x\n", val);
  87. + tmp = readl(base + TCSR_ESS_INTERFACE_SEL_OFFSET);
  88. + tmp = tmp & (~TCSR_ESS_INTERFACE_SEL_MASK);
  89. + tmp = tmp | (val&TCSR_ESS_INTERFACE_SEL_MASK);
  90. + writel(tmp, base + TCSR_ESS_INTERFACE_SEL_OFFSET);
  91. + }
  92. +
  93. + if (!of_property_read_u32(node, "qcom,wifi_glb_cfg", &val)) {
  94. + dev_info(&pdev->dev, "setting wifi_glb_cfg = %x\n", val);
  95. + writel(val, base + TCSR_WIFI0_GLB_CFG_OFFSET);
  96. + writel(val, base + TCSR_WIFI1_GLB_CFG_OFFSET);
  97. + }
  98. +
  99. + if (!of_property_read_u32(node, "qcom,wifi_noc_memtype_m0_m2", &val)) {
  100. + dev_info(&pdev->dev,
  101. + "setting wifi_noc_memtype_m0_m2 = %x\n", val);
  102. + writel(val, base + TCSR_PNOC_SNOC_MEMTYPE_M0_M2);
  103. + }
  104. +
  105. + return 0;
  106. +}
  107. +
  108. +static const struct of_device_id tcsr_dt_match[] = {
  109. + { .compatible = "qcom,tcsr", },
  110. + { },
  111. +};
  112. +
  113. +MODULE_DEVICE_TABLE(of, tcsr_dt_match);
  114. +
  115. +static struct platform_driver tcsr_driver = {
  116. + .driver = {
  117. + .name = "tcsr",
  118. + .owner = THIS_MODULE,
  119. + .of_match_table = tcsr_dt_match,
  120. + },
  121. + .probe = tcsr_probe,
  122. +};
  123. +
  124. +module_platform_driver(tcsr_driver);
  125. +
  126. +MODULE_AUTHOR("Andy Gross <[email protected]>");
  127. +MODULE_DESCRIPTION("QCOM TCSR driver");
  128. +MODULE_LICENSE("GPL v2");
  129. --- /dev/null
  130. +++ b/include/dt-bindings/soc/qcom,tcsr.h
  131. @@ -0,0 +1,48 @@
  132. +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
  133. + *
  134. + * This program is free software; you can redistribute it and/or modify
  135. + * it under the terms of the GNU General Public License version 2 and
  136. + * only version 2 as published by the Free Software Foundation.
  137. + *
  138. + * This program is distributed in the hope that it will be useful,
  139. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  140. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  141. + * GNU General Public License for more details.
  142. + */
  143. +#ifndef __DT_BINDINGS_QCOM_TCSR_H
  144. +#define __DT_BINDINGS_QCOM_TCSR_H
  145. +
  146. +#define TCSR_USB_SELECT_USB3_P0 0x1
  147. +#define TCSR_USB_SELECT_USB3_P1 0x2
  148. +#define TCSR_USB_SELECT_USB3_DUAL 0x3
  149. +
  150. +/* IPQ40xx HS PHY Mode Select */
  151. +#define TCSR_USB_HSPHY_HOST_MODE 0x00E700E7
  152. +#define TCSR_USB_HSPHY_DEVICE_MODE 0x00C700E7
  153. +
  154. +/* IPQ40xx ess interface mode select */
  155. +#define TCSR_ESS_PSGMII 0
  156. +#define TCSR_ESS_PSGMII_RGMII5 1
  157. +#define TCSR_ESS_PSGMII_RMII0 2
  158. +#define TCSR_ESS_PSGMII_RMII1 4
  159. +#define TCSR_ESS_PSGMII_RMII0_RMII1 6
  160. +#define TCSR_ESS_PSGMII_RGMII4 9
  161. +
  162. +/*
  163. + * IPQ40xx WiFi Global Config
  164. + * Bit 30:AXID_EN
  165. + * Enable AXI master bus Axid translating to confirm all txn submitted by order
  166. + * Bit 24: Use locally generated socslv_wxi_bvalid
  167. + * 1: use locally generate socslv_wxi_bvalid for performance.
  168. + * 0: use SNOC socslv_wxi_bvalid.
  169. + */
  170. +#define TCSR_WIFI_GLB_CFG 0x41000000
  171. +
  172. +/* IPQ40xx MEM_TYPE_SEL_M0_M2 Select Bit 26:24 - 2 NORMAL */
  173. +#define TCSR_WIFI_NOC_MEMTYPE_M0_M2 0x02222222
  174. +
  175. +/* TCSR A/B REG */
  176. +#define IPQ806X_TCSR_REG_A_ADM_CRCI_MUX_SEL 0
  177. +#define IPQ806X_TCSR_REG_B_ADM_CRCI_MUX_SEL 1
  178. +
  179. +#endif