2
0

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

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