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

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