[PATCH v8 3/5] soc: qcom: pdr: extract PDR message marshalling data

2024-05-11 Thread Dmitry Baryshkov
The in-kernel PD mapper is going to use same message structures as the
QCOM_PDR_HELPERS module. Extract message marshalling data to separate
module that can be used by both PDR helpers and by PD mapper.

Reviewed-by: Bryan O'Donoghue 
Tested-by: Steev Klimaszewski 
Tested-by: Alexey Minnekhanov 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/Kconfig|   4 +
 drivers/soc/qcom/Makefile   |   1 +
 drivers/soc/qcom/pdr_internal.h | 306 ++
 drivers/soc/qcom/qcom_pdr_msg.c | 319 
 4 files changed, 334 insertions(+), 296 deletions(-)

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 5af33b0e3470..95973c6b828f 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -75,8 +75,12 @@ config QCOM_OCMEM
 config QCOM_PDR_HELPERS
tristate
select QCOM_QMI_HELPERS
+   select QCOM_PDR_MSG
depends on NET
 
+config QCOM_PDR_MSG
+   tristate
+
 config QCOM_PMIC_PDCHARGER_ULOG
tristate "Qualcomm PMIC PDCharger ULOG driver"
depends on RPMSG
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index ca0bece0dfff..3110ac3288bc 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_QCOM_GSBI) +=  qcom_gsbi.o
 obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
 obj-$(CONFIG_QCOM_OCMEM)   += ocmem.o
 obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o
+obj-$(CONFIG_QCOM_PDR_MSG) += qcom_pdr_msg.o
 obj-$(CONFIG_QCOM_PMIC_GLINK)  += pmic_glink.o
 obj-$(CONFIG_QCOM_PMIC_GLINK)  += pmic_glink_altmode.o
 obj-$(CONFIG_QCOM_PMIC_PDCHARGER_ULOG) += pmic_pdcharger_ulog.o
diff --git a/drivers/soc/qcom/pdr_internal.h b/drivers/soc/qcom/pdr_internal.h
index 03c282b7f17e..7e5bb5a95275 100644
--- a/drivers/soc/qcom/pdr_internal.h
+++ b/drivers/soc/qcom/pdr_internal.h
@@ -28,83 +28,12 @@ struct servreg_location_entry {
u32 instance;
 };
 
-static const struct qmi_elem_info servreg_location_entry_ei[] = {
-   {
-   .data_type  = QMI_STRING,
-   .elem_len   = SERVREG_NAME_LENGTH + 1,
-   .elem_size  = sizeof(char),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  name),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_4_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u32),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  instance),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_1_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u8),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  service_data_valid),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_4_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u32),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  service_data),
-   },
-   {}
-};
-
 struct servreg_get_domain_list_req {
char service_name[SERVREG_NAME_LENGTH + 1];
u8 domain_offset_valid;
u32 domain_offset;
 };
 
-static const struct qmi_elem_info servreg_get_domain_list_req_ei[] = {
-   {
-   .data_type  = QMI_STRING,
-   .elem_len   = SERVREG_NAME_LENGTH + 1,
-   .elem_size  = sizeof(char),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0x01,
-   .offset = offsetof(struct servreg_get_domain_list_req,
-  service_name),
-   },
-   {
-   .data_type  = QMI_OPT_FLAG,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u8),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0x10,
-   .offset = offsetof(struct servreg_get_domain_list_req,
-  domain_offset_valid),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_4_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u32),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0x10,
-   .offset = offsetof(struct servreg_get_domain_list_req,
-  domain_offset),
-   },
-   {}
-};

[PATCH v8 4/5] soc: qcom: add pd-mapper implementation

2024-05-11 Thread Dmitry Baryshkov
Existing userspace protection domain mapper implementation has several
issue. It doesn't play well with CONFIG_EXTRA_FIRMWARE, it doesn't
reread JSON files if firmware location is changed (or if firmware was
not available at the time pd-mapper was started but the corresponding
directory is mounted later), etc.

Provide in-kernel service implementing protection domain mapping
required to work with several services, which are provided by the DSP
firmware.

This module is loaded automatically by the remoteproc drivers when
necessary via the symbol dependency. It uses a root node to match a
protection domains map for a particular board. It is not possible to
implement it as a 'driver' as there is no corresponding device.

Tested-by: Steev Klimaszewski 
Tested-by: Alexey Minnekhanov 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/Kconfig  |  11 +
 drivers/soc/qcom/Makefile |   1 +
 drivers/soc/qcom/pdr_internal.h   |  14 +
 drivers/soc/qcom/qcom_pd_mapper.c | 676 ++
 drivers/soc/qcom/qcom_pdr_msg.c   |  34 ++
 5 files changed, 736 insertions(+)

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 95973c6b828f..0a2f2bfd7863 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -72,6 +72,17 @@ config QCOM_OCMEM
  requirements. This is typically used by the GPU, camera/video, and
  audio components on some Snapdragon SoCs.
 
+config QCOM_PD_MAPPER
+   tristate "Qualcomm Protection Domain Mapper"
+   select QCOM_QMI_HELPERS
+   depends on NET && QRTR
+   default QCOM_RPROC_COMMON
+   help
+ The Protection Domain Mapper maps registered services to the domains
+ and instances handled by the remote DSPs. This is a kernel-space
+ implementation of the service. It is a simpler alternative to the
+ userspace daemon.
+
 config QCOM_PDR_HELPERS
tristate
select QCOM_QMI_HELPERS
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 3110ac3288bc..d3560f861085 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o
 obj-$(CONFIG_QCOM_GSBI)+=  qcom_gsbi.o
 obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
 obj-$(CONFIG_QCOM_OCMEM)   += ocmem.o
+obj-$(CONFIG_QCOM_PD_MAPPER)   += qcom_pd_mapper.o
 obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o
 obj-$(CONFIG_QCOM_PDR_MSG) += qcom_pdr_msg.o
 obj-$(CONFIG_QCOM_PMIC_GLINK)  += pmic_glink.o
diff --git a/drivers/soc/qcom/pdr_internal.h b/drivers/soc/qcom/pdr_internal.h
index 7e5bb5a95275..8d17f7fb79e7 100644
--- a/drivers/soc/qcom/pdr_internal.h
+++ b/drivers/soc/qcom/pdr_internal.h
@@ -13,6 +13,8 @@
 #define SERVREG_SET_ACK_REQ0x23
 #define SERVREG_RESTART_PD_REQ 0x24
 
+#define SERVREG_LOC_PFR_REQ0x24
+
 #define SERVREG_DOMAIN_LIST_LENGTH 32
 #define SERVREG_RESTART_PD_REQ_MAX_LEN 67
 #define SERVREG_REGISTER_LISTENER_REQ_LEN  71
@@ -20,6 +22,7 @@
 #define SERVREG_GET_DOMAIN_LIST_REQ_MAX_LEN74
 #define SERVREG_STATE_UPDATED_IND_MAX_LEN  79
 #define SERVREG_GET_DOMAIN_LIST_RESP_MAX_LEN   2389
+#define SERVREG_LOC_PFR_RESP_MAX_LEN   10
 
 struct servreg_location_entry {
char name[SERVREG_NAME_LENGTH + 1];
@@ -79,6 +82,15 @@ struct servreg_set_ack_resp {
struct qmi_response_type_v01 resp;
 };
 
+struct servreg_loc_pfr_req {
+   char service[SERVREG_NAME_LENGTH + 1];
+   char reason[257];
+};
+
+struct servreg_loc_pfr_resp {
+   struct qmi_response_type_v01 rsp;
+};
+
 extern const struct qmi_elem_info servreg_location_entry_ei[];
 extern const struct qmi_elem_info servreg_get_domain_list_req_ei[];
 extern const struct qmi_elem_info servreg_get_domain_list_resp_ei[];
@@ -89,5 +101,7 @@ extern const struct qmi_elem_info 
servreg_restart_pd_resp_ei[];
 extern const struct qmi_elem_info servreg_state_updated_ind_ei[];
 extern const struct qmi_elem_info servreg_set_ack_req_ei[];
 extern const struct qmi_elem_info servreg_set_ack_resp_ei[];
+extern const struct qmi_elem_info servreg_loc_pfr_req_ei[];
+extern const struct qmi_elem_info servreg_loc_pfr_resp_ei[];
 
 #endif
diff --git a/drivers/soc/qcom/qcom_pd_mapper.c 
b/drivers/soc/qcom/qcom_pd_mapper.c
new file mode 100644
index ..ecb64f06527f
--- /dev/null
+++ b/drivers/soc/qcom/qcom_pd_mapper.c
@@ -0,0 +1,676 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Qualcomm Protection Domain mapper
+ *
+ * Copyright (c) 2023 Linaro Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pdr_internal.h"
+
+#define SERVREG_QMI_VERSION 0x101
+#define SERVREG_QMI_INSTANCE 0
+
+#define TMS_SERVREG_SERVICE "tms/servreg"
+
+struct qcom_pdm_domain_data {
+   const

[PATCH v8 5/5] remoteproc: qcom: enable in-kernel PD mapper

2024-05-11 Thread Dmitry Baryshkov
Request in-kernel protection domain mapper to be started before starting
Qualcomm DSP and release it once DSP is stopped. Once all DSPs are
stopped, the PD mapper will be stopped too.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/remoteproc/qcom_common.c| 87 +
 drivers/remoteproc/qcom_common.h| 10 +
 drivers/remoteproc/qcom_q6v5_adsp.c |  3 ++
 drivers/remoteproc/qcom_q6v5_mss.c  |  3 ++
 drivers/remoteproc/qcom_q6v5_pas.c  |  3 ++
 drivers/remoteproc/qcom_q6v5_wcss.c |  3 ++
 6 files changed, 109 insertions(+)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 03e5f5d533eb..8c8688f99f0a 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,6 +26,7 @@
 #define to_glink_subdev(d) container_of(d, struct qcom_rproc_glink, subdev)
 #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
 #define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev)
+#define to_pdm_subdev(d) container_of(d, struct qcom_rproc_pdm, subdev)
 
 #define MAX_NUM_OF_SS   10
 #define MAX_REGION_NAME_LENGTH  16
@@ -519,5 +521,90 @@ void qcom_remove_ssr_subdev(struct rproc *rproc, struct 
qcom_rproc_ssr *ssr)
 }
 EXPORT_SYMBOL_GPL(qcom_remove_ssr_subdev);
 
+static void pdm_dev_release(struct device *dev)
+{
+   struct auxiliary_device *adev = to_auxiliary_dev(dev);
+
+   kfree(adev);
+}
+
+static int pdm_notify_prepare(struct rproc_subdev *subdev)
+{
+   struct qcom_rproc_pdm *pdm = to_pdm_subdev(subdev);
+   struct auxiliary_device *adev;
+   int ret;
+
+   adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+   if (!adev)
+   return -ENOMEM;
+
+   adev->dev.parent = pdm->dev;
+   adev->dev.release = pdm_dev_release;
+   adev->name = "pd-mapper";
+   adev->id = pdm->index;
+
+   ret = auxiliary_device_init(adev);
+   if (ret) {
+   kfree(adev);
+   return ret;
+   }
+
+   ret = auxiliary_device_add(adev);
+   if (ret) {
+   auxiliary_device_uninit(adev);
+   return ret;
+   }
+
+   pdm->adev = adev;
+
+   return 0;
+}
+
+
+static void pdm_notify_unprepare(struct rproc_subdev *subdev)
+{
+   struct qcom_rproc_pdm *pdm = to_pdm_subdev(subdev);
+
+   if (!pdm->adev)
+   return;
+
+   auxiliary_device_delete(pdm->adev);
+   auxiliary_device_uninit(pdm->adev);
+   pdm->adev = NULL;
+}
+
+/**
+ * qcom_add_pdm_subdev() - register PD Mapper subdevice
+ * @rproc: rproc handle
+ * @pdm:   PDM subdevice handle
+ *
+ * Register @pdm so that Protection Device mapper service is started when the
+ * DSP is started too.
+ */
+void qcom_add_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm)
+{
+   pdm->dev = >dev;
+   pdm->index = rproc->index;
+
+   pdm->subdev.prepare = pdm_notify_prepare;
+   pdm->subdev.unprepare = pdm_notify_unprepare;
+
+   rproc_add_subdev(rproc, >subdev);
+}
+EXPORT_SYMBOL_GPL(qcom_add_pdm_subdev);
+
+/**
+ * qcom_remove_pdm_subdev() - remove PD Mapper subdevice
+ * @rproc: rproc handle
+ * @pdm:   PDM subdevice handle
+ *
+ * Remove the PD Mapper subdevice.
+ */
+void qcom_remove_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm)
+{
+   rproc_remove_subdev(rproc, >subdev);
+}
+EXPORT_SYMBOL_GPL(qcom_remove_pdm_subdev);
+
 MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h
index 9ef4449052a9..b07fbaa091a0 100644
--- a/drivers/remoteproc/qcom_common.h
+++ b/drivers/remoteproc/qcom_common.h
@@ -34,6 +34,13 @@ struct qcom_rproc_ssr {
struct qcom_ssr_subsystem *info;
 };
 
+struct qcom_rproc_pdm {
+   struct rproc_subdev subdev;
+   struct device *dev;
+   int index;
+   struct auxiliary_device *adev;
+};
+
 void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
void (*rproc_dumpfn_t)(struct rproc *rproc,
struct rproc_dump_segment *segment, void *dest, 
size_t offset,
@@ -52,6 +59,9 @@ void qcom_add_ssr_subdev(struct rproc *rproc, struct 
qcom_rproc_ssr *ssr,
 const char *ssr_name);
 void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr);
 
+void qcom_add_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm);
+void qcom_remove_pdm_subdev(struct rproc *rproc, struct qcom_rproc_pdm *pdm);
+
 #if IS_ENABLED(CONFIG_QCOM_SYSMON)
 struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc,
   const char *name,
diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c 
b/drivers/remoteproc/qcom_q6v5_a

[PATCH v8 2/5] soc: qcom: pdr: fix parsing of domains lists

2024-05-11 Thread Dmitry Baryshkov
While parsing the domains list, start offsets from 0 rather than from
domains_read. The domains_read is equal to the total count of the
domains we have seen, while the domains list in the message starts from
offset 0.

Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
Tested-by: Steev Klimaszewski 
Tested-by: Alexey Minnekhanov 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/pdr_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c
index e014dd2d8ab3..d495ee736519 100644
--- a/drivers/soc/qcom/pdr_interface.c
+++ b/drivers/soc/qcom/pdr_interface.c
@@ -422,7 +422,7 @@ static int pdr_locate_service(struct pdr_handle *pdr, 
struct pdr_service *pds)
if (ret < 0)
goto out;
 
-   for (i = domains_read; i < resp->domain_list_len; i++) {
+   for (i = 0; i < resp->domain_list_len; i++) {
entry = >domain_list[i];
 
if (strnlen(entry->name, sizeof(entry->name)) == 
sizeof(entry->name))

-- 
2.39.2




[PATCH v8 0/5] soc: qcom: add in-kernel pd-mapper implementation

2024-05-11 Thread Dmitry Baryshkov
Protection domain mapper is a QMI service providing mapping between
'protection domains' and services supported / allowed in these domains.
For example such mapping is required for loading of the WiFi firmware or
for properly starting up the UCSI / altmode / battery manager support.

The existing userspace implementation has several issue. It doesn't play
well with CONFIG_EXTRA_FIRMWARE, it doesn't reread the JSON files if the
firmware location is changed (or if the firmware was not available at
the time pd-mapper was started but the corresponding directory is
mounted later), etc.

However this configuration is largely static and common between
different platforms. Provide in-kernel service implementing static
per-platform data.

To: Bjorn Andersson 
To: Konrad Dybcio 
To: Sibi Sankar 
To: Mathieu Poirier 
Cc: linux-arm-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-remotep...@vger.kernel.org
Cc: Johan Hovold 
Cc: Xilin Wu 
Cc: "Bryan O'Donoghue" 
Cc: Steev Klimaszewski 
Cc: Alexey Minnekhanov 

--

Changes in v8:
- Reworked pd-mapper to register as an rproc_subdev / auxdev
- Dropped Tested-by from Steev and Alexey from the last patch since the
  implementation was changed significantly.
- Add sensors, cdsp and mpss_root domains to 660 config (Alexey
  Minnekhanov)
- Added platform entry for sm4250 (used for qrb4210 / RB2)
- Added locking to the pdr_get_domain_list() (Chris Lew)
- Remove the call to qmi_del_server() and corresponding API (Chris Lew)
- In qmi_handle_init() changed 1024 to a defined constant (Chris Lew)
- Link to v7: 
https://lore.kernel.org/r/20240424-qcom-pd-mapper-v7-0-05f7fc646...@linaro.org

Changes in v7:
- Fixed modular build (Steev)
- Link to v6: 
https://lore.kernel.org/r/20240422-qcom-pd-mapper-v6-0-f96957d01...@linaro.org

Changes in v6:
- Reworked mutex to fix lockdep issue on deregistration
- Fixed dependencies between PD-mapper and remoteproc to fix modular
  builds (Krzysztof)
- Added EXPORT_SYMBOL_GPL to fix modular builds (Krzysztof)
- Fixed kerneldocs (Krzysztof)
- Removed extra pr_debug messages (Krzysztof)
- Fixed wcss build (Krzysztof)
- Added platforms which do not require protection domain mapping to
  silence the notice on those platforms
- Link to v5: 
https://lore.kernel.org/r/20240419-qcom-pd-mapper-v5-0-e35b6f847...@linaro.org

Changes in v5:
- pdr: drop lock in pdr_register_listener, list_lock is already held (Chris Lew)
- pd_mapper: reworked to provide static configuration per platform
  (Bjorn)
- Link to v4: 
https://lore.kernel.org/r/20240311-qcom-pd-mapper-v4-0-24679cca5...@linaro.org

Changes in v4:
- Fixed missing chunk, reenabled kfree in qmi_del_server (Konrad)
- Added configuration for sm6350 (Thanks to Luca)
- Removed RFC tag (Konrad)
- Link to v3: 
https://lore.kernel.org/r/20240304-qcom-pd-mapper-v3-0-6858fa1ac...@linaro.org

Changes in RFC v3:
- Send start / stop notifications when PD-mapper domain list is changed
- Reworked the way PD-mapper treats protection domains, register all of
  them in a single batch
- Added SC7180 domains configuration based on TCL Book 14 GO
- Link to v2: 
https://lore.kernel.org/r/20240301-qcom-pd-mapper-v2-0-5d12a081d...@linaro.org

Changes in RFC v2:
- Swapped num_domains / domains (Konrad)
- Fixed an issue with battery not working on sc8280xp
- Added missing configuration for QCS404

---
Dmitry Baryshkov (5):
  soc: qcom: pdr: protect locator_addr with the main mutex
  soc: qcom: pdr: fix parsing of domains lists
  soc: qcom: pdr: extract PDR message marshalling data
  soc: qcom: add pd-mapper implementation
  remoteproc: qcom: enable in-kernel PD mapper

 drivers/remoteproc/qcom_common.c|  87 +
 drivers/remoteproc/qcom_common.h|  10 +
 drivers/remoteproc/qcom_q6v5_adsp.c |   3 +
 drivers/remoteproc/qcom_q6v5_mss.c  |   3 +
 drivers/remoteproc/qcom_q6v5_pas.c  |   3 +
 drivers/remoteproc/qcom_q6v5_wcss.c |   3 +
 drivers/soc/qcom/Kconfig|  15 +
 drivers/soc/qcom/Makefile   |   2 +
 drivers/soc/qcom/pdr_interface.c|  17 +-
 drivers/soc/qcom/pdr_internal.h | 318 ++---
 drivers/soc/qcom/qcom_pd_mapper.c   | 676 
 drivers/soc/qcom/qcom_pdr_msg.c | 353 +++
 12 files changed, 1190 insertions(+), 300 deletions(-)
---
base-commit: e5119bbdaca76cd3c15c3c975d51d840bbfb2488
change-id: 20240301-qcom-pd-mapper-e12d622d4ad0

Best regards,
-- 
Dmitry Baryshkov 




[PATCH v8 1/5] soc: qcom: pdr: protect locator_addr with the main mutex

2024-05-11 Thread Dmitry Baryshkov
If the service locator server is restarted fast enough, the PDR can
rewrite locator_addr fields concurrently. Protect them by placing
modification of those fields under the main pdr->lock.

Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
Tested-by: Neil Armstrong  # on SM8550-QRD
Tested-by: Steev Klimaszewski 
Tested-by: Alexey Minnekhanov 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/pdr_interface.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c
index a1b6a4081dea..e014dd2d8ab3 100644
--- a/drivers/soc/qcom/pdr_interface.c
+++ b/drivers/soc/qcom/pdr_interface.c
@@ -76,12 +76,12 @@ static int pdr_locator_new_server(struct qmi_handle *qmi,
  locator_hdl);
struct pdr_service *pds;
 
+   mutex_lock(>lock);
/* Create a local client port for QMI communication */
pdr->locator_addr.sq_family = AF_QIPCRTR;
pdr->locator_addr.sq_node = svc->node;
pdr->locator_addr.sq_port = svc->port;
 
-   mutex_lock(>lock);
pdr->locator_init_complete = true;
mutex_unlock(>lock);
 
@@ -104,10 +104,10 @@ static void pdr_locator_del_server(struct qmi_handle *qmi,
 
mutex_lock(>lock);
pdr->locator_init_complete = false;
-   mutex_unlock(>lock);
 
pdr->locator_addr.sq_node = 0;
pdr->locator_addr.sq_port = 0;
+   mutex_unlock(>lock);
 }
 
 static const struct qmi_ops pdr_locator_ops = {
@@ -365,6 +365,7 @@ static int pdr_get_domain_list(struct 
servreg_get_domain_list_req *req,
if (ret < 0)
return ret;
 
+   mutex_lock(>lock);
ret = qmi_send_request(>locator_hdl,
   >locator_addr,
   , SERVREG_GET_DOMAIN_LIST_REQ,
@@ -373,15 +374,16 @@ static int pdr_get_domain_list(struct 
servreg_get_domain_list_req *req,
   req);
if (ret < 0) {
qmi_txn_cancel();
-   return ret;
+   goto err_unlock;
}
 
ret = qmi_txn_wait(, 5 * HZ);
if (ret < 0) {
pr_err("PDR: %s get domain list txn wait failed: %d\n",
   req->service_name, ret);
-   return ret;
+   goto err_unlock;
}
+   mutex_unlock(>lock);
 
if (resp->resp.result != QMI_RESULT_SUCCESS_V01) {
pr_err("PDR: %s get domain list failed: 0x%x\n",
@@ -390,6 +392,11 @@ static int pdr_get_domain_list(struct 
servreg_get_domain_list_req *req,
}
 
return 0;
+
+err_unlock:
+   mutex_unlock(>lock);
+
+   return ret;
 }
 
 static int pdr_locate_service(struct pdr_handle *pdr, struct pdr_service *pds)

-- 
2.39.2




Re: [PATCH v7 1/6] soc: qcom: pdr: protect locator_addr with the main mutex

2024-05-11 Thread Dmitry Baryshkov
On Thu, 25 Apr 2024 at 22:30, Chris Lew  wrote:
>
>
> On 4/24/2024 2:27 AM, Dmitry Baryshkov wrote:
> > If the service locator server is restarted fast enough, the PDR can
> > rewrite locator_addr fields concurrently. Protect them by placing
> > modification of those fields under the main pdr->lock.
> >
> > Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart 
> > helpers")
> > Tested-by: Neil Armstrong  # on SM8550-QRD
> > Signed-off-by: Dmitry Baryshkov 
> > ---
> >   drivers/soc/qcom/pdr_interface.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/soc/qcom/pdr_interface.c 
> > b/drivers/soc/qcom/pdr_interface.c
> > index a1b6a4081dea..19cfe4b41235 100644
> > --- a/drivers/soc/qcom/pdr_interface.c
> > +++ b/drivers/soc/qcom/pdr_interface.c
> > @@ -76,12 +76,12 @@ static int pdr_locator_new_server(struct qmi_handle 
> > *qmi,
> > locator_hdl);
> >   struct pdr_service *pds;
> >
> > + mutex_lock(>lock);
> >   /* Create a local client port for QMI communication */
> >   pdr->locator_addr.sq_family = AF_QIPCRTR;
> >   pdr->locator_addr.sq_node = svc->node;
> >   pdr->locator_addr.sq_port = svc->port;
> >
> > - mutex_lock(>lock);
> >   pdr->locator_init_complete = true;
> >   mutex_unlock(>lock);
> >
> > @@ -104,10 +104,10 @@ static void pdr_locator_del_server(struct qmi_handle 
> > *qmi,
> >
> >   mutex_lock(>lock);
> >   pdr->locator_init_complete = false;
> > - mutex_unlock(>lock);
> >
> >   pdr->locator_addr.sq_node = 0;
> >   pdr->locator_addr.sq_port = 0;
> > + mutex_unlock(>lock);
> >   }
> >
> >   static const struct qmi_ops pdr_locator_ops = {
> >
>
> These two functions are provided as qmi_ops handlers in pdr_locator_ops.
> Aren't they serialized in the qmi handle's workqueue since it as an
> ordered_workqueue? Even in a fast pdr scenario I don't think we would
> see a race condition between these two functions.
>
> The other access these two functions do race against is in the
> pdr_notifier_work. I think you would need to protect locator_addr in
> pdr_get_domain_list since the qmi_send_request there uses
> 'pdr->locator_addr'.

Thanks, I missed it initially. I think I'd keep the rest of the
changes and expand the lock to cover pdr_get_domain_list().

>
> Thanks!
> Chris



-- 
With best wishes
Dmitry



Re: [PATCH v7 6/6] remoteproc: qcom: enable in-kernel PD mapper

2024-04-26 Thread Dmitry Baryshkov
On Sat, 27 Apr 2024 at 04:03, Chris Lew  wrote:
>
>
>
> On 4/24/2024 2:28 AM, Dmitry Baryshkov wrote:
> > diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c 
> > b/drivers/remoteproc/qcom_q6v5_adsp.c
> > index 1d24c9b656a8..02d0c626b03b 100644
> > --- a/drivers/remoteproc/qcom_q6v5_adsp.c
> > +++ b/drivers/remoteproc/qcom_q6v5_adsp.c
> > @@ -23,6 +23,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >
> > @@ -375,10 +376,14 @@ static int adsp_start(struct rproc *rproc)
> >   int ret;
> >   unsigned int val;
> >
> > - ret = qcom_q6v5_prepare(>q6v5);
> > + ret = qcom_pdm_get();
> >   if (ret)
> >   return ret;
>
> Would it make sense to try and model this as a rproc subdev? This
> section of the remoteproc code seems to be focused on making specific
> calls to setup and enable hardware resources, where as pd mapper is
> software.
>
> sysmon and ssr are also purely software and they are modeled as subdevs
> in qcom_common. I'm not an expert on remoteproc organization but this
> was just a thought.

Well, the issue is that the pd-mapper is a global, not a per-remoteproc instance

>
> Thanks!
> Chris
>
> >
> > + ret = qcom_q6v5_prepare(>q6v5);
> > + if (ret)
> > + goto put_pdm;
> > +
> >   ret = adsp_map_carveout(rproc);
> >   if (ret) {
> >   dev_err(adsp->dev, "ADSP smmu mapping failed\n");
> > @@ -446,6 +451,8 @@ static int adsp_start(struct rproc *rproc)
> >   adsp_unmap_carveout(rproc);
> >   disable_irqs:
> >   qcom_q6v5_unprepare(>q6v5);
> > +put_pdm:
> > + qcom_pdm_release();
> >
> >   return ret;
> >   }
>


-- 
With best wishes
Dmitry



Re: [PATCH v7 0/6] soc: qcom: add in-kernel pd-mapper implementation

2024-04-25 Thread Dmitry Baryshkov
On Thu, 25 Apr 2024 at 10:08, Steev Klimaszewski  wrote:
>
> Hi Dmitry,
>
> On Wed, Apr 24, 2024 at 4:28 AM Dmitry Baryshkov
>  wrote:
> >
> > Protection domain mapper is a QMI service providing mapping between
> > 'protection domains' and services supported / allowed in these domains.
> > For example such mapping is required for loading of the WiFi firmware or
> > for properly starting up the UCSI / altmode / battery manager support.
> >
> > The existing userspace implementation has several issue. It doesn't play
> > well with CONFIG_EXTRA_FIRMWARE, it doesn't reread the JSON files if the
> > firmware location is changed (or if the firmware was not available at
> > the time pd-mapper was started but the corresponding directory is
> > mounted later), etc.
> >
> > However this configuration is largely static and common between
> > different platforms. Provide in-kernel service implementing static
> > per-platform data.
> >
> > Unlike previous revisions of the patchset, this iteration uses static
> > configuration per platform, rather than building it dynamically from the
> > list of DSPs being started.
> >
> > To: Bjorn Andersson 
> > To: Konrad Dybcio 
> > To: Sibi Sankar 
> > To: Mathieu Poirier 
> > Cc: linux-arm-...@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-remotep...@vger.kernel.org
> > Cc: Johan Hovold 
> > Cc: Xilin Wu 
> > Cc: "Bryan O'Donoghue" 
> > --
> >
> > Changes in v7:
> > - Fixed modular build (Steev)
> > - Link to v6: 
> > https://lore.kernel.org/r/20240422-qcom-pd-mapper-v6-0-f96957d01...@linaro.org
> >
> > Changes in v6:
> > - Reworked mutex to fix lockdep issue on deregistration
> > - Fixed dependencies between PD-mapper and remoteproc to fix modular
> >   builds (Krzysztof)
> > - Added EXPORT_SYMBOL_GPL to fix modular builds (Krzysztof)
> > - Fixed kerneldocs (Krzysztof)
> > - Removed extra pr_debug messages (Krzysztof)
> > - Fixed wcss build (Krzysztof)
> > - Added platforms which do not require protection domain mapping to
> >   silence the notice on those platforms
> > - Link to v5: 
> > https://lore.kernel.org/r/20240419-qcom-pd-mapper-v5-0-e35b6f847...@linaro.org
> >
> > Changes in v5:
> > - pdr: drop lock in pdr_register_listener, list_lock is already held (Chris 
> > Lew)
> > - pd_mapper: reworked to provide static configuration per platform
> >   (Bjorn)
> > - Link to v4: 
> > https://lore.kernel.org/r/20240311-qcom-pd-mapper-v4-0-24679cca5...@linaro.org
> >
> > Changes in v4:
> > - Fixed missing chunk, reenabled kfree in qmi_del_server (Konrad)
> > - Added configuration for sm6350 (Thanks to Luca)
> > - Removed RFC tag (Konrad)
> > - Link to v3: 
> > https://lore.kernel.org/r/20240304-qcom-pd-mapper-v3-0-6858fa1ac...@linaro.org
> >
> > Changes in RFC v3:
> > - Send start / stop notifications when PD-mapper domain list is changed
> > - Reworked the way PD-mapper treats protection domains, register all of
> >   them in a single batch
> > - Added SC7180 domains configuration based on TCL Book 14 GO
> > - Link to v2: 
> > https://lore.kernel.org/r/20240301-qcom-pd-mapper-v2-0-5d12a081d...@linaro.org
> >
> > Changes in RFC v2:
> > - Swapped num_domains / domains (Konrad)
> > - Fixed an issue with battery not working on sc8280xp
> > - Added missing configuration for QCS404
> >
> > ---
> > Dmitry Baryshkov (6):
> >   soc: qcom: pdr: protect locator_addr with the main mutex
> >   soc: qcom: pdr: fix parsing of domains lists
> >   soc: qcom: pdr: extract PDR message marshalling data
> >   soc: qcom: qmi: add a way to remove running service
> >   soc: qcom: add pd-mapper implementation
> >   remoteproc: qcom: enable in-kernel PD mapper
> >
> >  drivers/remoteproc/Kconfig  |   4 +
> >  drivers/remoteproc/qcom_q6v5_adsp.c |  11 +-
> >  drivers/remoteproc/qcom_q6v5_mss.c  |  10 +-
> >  drivers/remoteproc/qcom_q6v5_pas.c  |  12 +-
> >  drivers/remoteproc/qcom_q6v5_wcss.c |  12 +-
> >  drivers/soc/qcom/Kconfig|  14 +
> >  drivers/soc/qcom/Makefile   |   2 +
> >  drivers/soc/qcom/pdr_interface.c    |   6 +-
> >  drivers/soc/qcom/pdr_internal.h | 318 ++---
> >  drivers/soc/qcom/qcom_pd_mapper.c   | 656 
> > 
> >  drivers/soc/qcom/qcom_pdr_msg.c | 353 +++
> >  drivers/soc/qcom/qmi_interface.c|  67 
> >  include/linux/soc/qcom/pd_mapper.h  |  28 ++
> >  include/linux/soc/qcom/qmi.h|   2 +
> >  14 files changed, 1193 insertions(+), 302 deletions(-)
> > ---
> > base-commit: a59668a9397e7245b26e9be85d23f242ff757ae8
> > change-id: 20240301-qcom-pd-mapper-e12d622d4ad0
> >
> > Best regards,
> > --
> > Dmitry Baryshkov 
> >
> >
> I've tested this series over a large number of reboots, and the p-d
> devices(?) do always seem to come up (with the pd-mapper service
> disabled) on my Thinkpad X13s.  One less service to run in userland!
> Tested-by: Steev Klimaszewski 

Thank you!

-- 
With best wishes
Dmitry



[PATCH v7 5/6] soc: qcom: add pd-mapper implementation

2024-04-24 Thread Dmitry Baryshkov
Existing userspace protection domain mapper implementation has several
issue. It doesn't play well with CONFIG_EXTRA_FIRMWARE, it doesn't
reread JSON files if firmware location is changed (or if firmware was
not available at the time pd-mapper was started but the corresponding
directory is mounted later), etc.

Provide in-kernel service implementing protection domain mapping
required to work with several services, which are provided by the DSP
firmware.

This module is loaded automatically by the remoteproc drivers when
necessary via the symbol dependency. It uses a root node to match a
protection domains map for a particular board. It is not possible to
implement it as a 'driver' as there is no corresponding device.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/Kconfig   |  10 +
 drivers/soc/qcom/Makefile  |   1 +
 drivers/soc/qcom/pdr_internal.h|  14 +
 drivers/soc/qcom/qcom_pd_mapper.c  | 656 +
 drivers/soc/qcom/qcom_pdr_msg.c|  34 ++
 include/linux/soc/qcom/pd_mapper.h |  28 ++
 6 files changed, 743 insertions(+)

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 95973c6b828f..f666366841b8 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -72,6 +72,16 @@ config QCOM_OCMEM
  requirements. This is typically used by the GPU, camera/video, and
  audio components on some Snapdragon SoCs.
 
+config QCOM_PD_MAPPER
+   tristate "Qualcomm Protection Domain Mapper"
+   select QCOM_QMI_HELPERS
+   depends on NET && QRTR
+   help
+ The Protection Domain Mapper maps registered services to the domains
+ and instances handled by the remote DSPs. This is a kernel-space
+ implementation of the service. It is a simpler alternative to the
+ userspace daemon.
+
 config QCOM_PDR_HELPERS
tristate
select QCOM_QMI_HELPERS
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 3110ac3288bc..d3560f861085 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o
 obj-$(CONFIG_QCOM_GSBI)+=  qcom_gsbi.o
 obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
 obj-$(CONFIG_QCOM_OCMEM)   += ocmem.o
+obj-$(CONFIG_QCOM_PD_MAPPER)   += qcom_pd_mapper.o
 obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o
 obj-$(CONFIG_QCOM_PDR_MSG) += qcom_pdr_msg.o
 obj-$(CONFIG_QCOM_PMIC_GLINK)  += pmic_glink.o
diff --git a/drivers/soc/qcom/pdr_internal.h b/drivers/soc/qcom/pdr_internal.h
index 7e5bb5a95275..8d17f7fb79e7 100644
--- a/drivers/soc/qcom/pdr_internal.h
+++ b/drivers/soc/qcom/pdr_internal.h
@@ -13,6 +13,8 @@
 #define SERVREG_SET_ACK_REQ0x23
 #define SERVREG_RESTART_PD_REQ 0x24
 
+#define SERVREG_LOC_PFR_REQ0x24
+
 #define SERVREG_DOMAIN_LIST_LENGTH 32
 #define SERVREG_RESTART_PD_REQ_MAX_LEN 67
 #define SERVREG_REGISTER_LISTENER_REQ_LEN  71
@@ -20,6 +22,7 @@
 #define SERVREG_GET_DOMAIN_LIST_REQ_MAX_LEN74
 #define SERVREG_STATE_UPDATED_IND_MAX_LEN  79
 #define SERVREG_GET_DOMAIN_LIST_RESP_MAX_LEN   2389
+#define SERVREG_LOC_PFR_RESP_MAX_LEN   10
 
 struct servreg_location_entry {
char name[SERVREG_NAME_LENGTH + 1];
@@ -79,6 +82,15 @@ struct servreg_set_ack_resp {
struct qmi_response_type_v01 resp;
 };
 
+struct servreg_loc_pfr_req {
+   char service[SERVREG_NAME_LENGTH + 1];
+   char reason[257];
+};
+
+struct servreg_loc_pfr_resp {
+   struct qmi_response_type_v01 rsp;
+};
+
 extern const struct qmi_elem_info servreg_location_entry_ei[];
 extern const struct qmi_elem_info servreg_get_domain_list_req_ei[];
 extern const struct qmi_elem_info servreg_get_domain_list_resp_ei[];
@@ -89,5 +101,7 @@ extern const struct qmi_elem_info 
servreg_restart_pd_resp_ei[];
 extern const struct qmi_elem_info servreg_state_updated_ind_ei[];
 extern const struct qmi_elem_info servreg_set_ack_req_ei[];
 extern const struct qmi_elem_info servreg_set_ack_resp_ei[];
+extern const struct qmi_elem_info servreg_loc_pfr_req_ei[];
+extern const struct qmi_elem_info servreg_loc_pfr_resp_ei[];
 
 #endif
diff --git a/drivers/soc/qcom/qcom_pd_mapper.c 
b/drivers/soc/qcom/qcom_pd_mapper.c
new file mode 100644
index ..ba5440506c95
--- /dev/null
+++ b/drivers/soc/qcom/qcom_pd_mapper.c
@@ -0,0 +1,656 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Qualcomm Protection Domain mapper
+ *
+ * Copyright (c) 2023 Linaro Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "pdr_internal.h"
+
+#define SERVREG_QMI_VERSION 0x101
+#define SERVREG_QMI_INSTANCE 0
+
+#define TMS_SERVREG_SERVICE "tms/servreg"
+
+struct qcom_pdm_domain_data {
+   const char *domain;
+   u32 instance_id;
+   /* NULL-

[PATCH v7 6/6] remoteproc: qcom: enable in-kernel PD mapper

2024-04-24 Thread Dmitry Baryshkov
Request in-kernel protection domain mapper to be started before starting
Qualcomm DSP and release it once DSP is stopped. Once all DSPs are
stopped, the PD mapper will be stopped too.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/remoteproc/Kconfig  |  4 
 drivers/remoteproc/qcom_q6v5_adsp.c | 11 ++-
 drivers/remoteproc/qcom_q6v5_mss.c  | 10 +-
 drivers/remoteproc/qcom_q6v5_pas.c  | 12 +++-
 drivers/remoteproc/qcom_q6v5_wcss.c | 12 +++-
 5 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 48845dc8fa85..a0ce552f89a1 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -181,6 +181,7 @@ config QCOM_Q6V5_ADSP
depends on QCOM_SYSMON || QCOM_SYSMON=n
depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n
depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n
+   depends on QCOM_PD_MAPPER || QCOM_PD_MAPPER=n
select MFD_SYSCON
select QCOM_PIL_INFO
select QCOM_MDT_LOADER
@@ -201,6 +202,7 @@ config QCOM_Q6V5_MSS
depends on QCOM_SYSMON || QCOM_SYSMON=n
depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n
depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n
+   depends on QCOM_PD_MAPPER || QCOM_PD_MAPPER=n
select MFD_SYSCON
select QCOM_MDT_LOADER
select QCOM_PIL_INFO
@@ -221,6 +223,7 @@ config QCOM_Q6V5_PAS
depends on QCOM_SYSMON || QCOM_SYSMON=n
depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n
depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n
+   depends on QCOM_PD_MAPPER || QCOM_PD_MAPPER=n
select MFD_SYSCON
select QCOM_PIL_INFO
select QCOM_MDT_LOADER
@@ -243,6 +246,7 @@ config QCOM_Q6V5_WCSS
depends on QCOM_SYSMON || QCOM_SYSMON=n
depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n
depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n
+   depends on QCOM_PD_MAPPER || QCOM_PD_MAPPER=n
select MFD_SYSCON
select QCOM_MDT_LOADER
select QCOM_PIL_INFO
diff --git a/drivers/remoteproc/qcom_q6v5_adsp.c 
b/drivers/remoteproc/qcom_q6v5_adsp.c
index 1d24c9b656a8..02d0c626b03b 100644
--- a/drivers/remoteproc/qcom_q6v5_adsp.c
+++ b/drivers/remoteproc/qcom_q6v5_adsp.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -375,10 +376,14 @@ static int adsp_start(struct rproc *rproc)
int ret;
unsigned int val;
 
-   ret = qcom_q6v5_prepare(>q6v5);
+   ret = qcom_pdm_get();
if (ret)
return ret;
 
+   ret = qcom_q6v5_prepare(>q6v5);
+   if (ret)
+   goto put_pdm;
+
ret = adsp_map_carveout(rproc);
if (ret) {
dev_err(adsp->dev, "ADSP smmu mapping failed\n");
@@ -446,6 +451,8 @@ static int adsp_start(struct rproc *rproc)
adsp_unmap_carveout(rproc);
 disable_irqs:
qcom_q6v5_unprepare(>q6v5);
+put_pdm:
+   qcom_pdm_release();
 
return ret;
 }
@@ -478,6 +485,8 @@ static int adsp_stop(struct rproc *rproc)
if (handover)
qcom_adsp_pil_handover(>q6v5);
 
+   qcom_pdm_release();
+
return ret;
 }
 
diff --git a/drivers/remoteproc/qcom_q6v5_mss.c 
b/drivers/remoteproc/qcom_q6v5_mss.c
index 1779fc890e10..791f11e7adbf 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1581,10 +1582,14 @@ static int q6v5_start(struct rproc *rproc)
int xfermemop_ret;
int ret;
 
-   ret = q6v5_mba_load(qproc);
+   ret = qcom_pdm_get();
if (ret)
return ret;
 
+   ret = q6v5_mba_load(qproc);
+   if (ret)
+   goto put_pdm;
+
dev_info(qproc->dev, "MBA booted with%s debug policy, loading mpss\n",
 qproc->dp_size ? "" : "out");
 
@@ -1613,6 +1618,8 @@ static int q6v5_start(struct rproc *rproc)
 reclaim_mpss:
q6v5_mba_reclaim(qproc);
q6v5_dump_mba_logs(qproc);
+put_pdm:
+   qcom_pdm_release();
 
return ret;
 }
@@ -1627,6 +1634,7 @@ static int q6v5_stop(struct rproc *rproc)
dev_err(qproc->dev, "timed out on wait\n");
 
q6v5_mba_reclaim(qproc);
+   qcom_pdm_release();
 
return 0;
 }
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c 
b/drivers/remoteproc/qcom_q6v5_pas.c
index 54d8005d40a3..653e54f975fc 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -261,10 +262,14 @@ static int adsp_start(struct rproc *rproc)
struct qcom_adsp *adsp = rproc->priv;
int ret;
 
-   ret = qcom_q6v5_prepare(>q6v5);
+   ret = qcom_pdm_get();
if (ret)
return ret;
 
+

[PATCH v7 4/6] soc: qcom: qmi: add a way to remove running service

2024-04-24 Thread Dmitry Baryshkov
Add qmi_del_server(), a pair to qmi_add_server(), a way to remove
running server from the QMI socket. This is e.g. necessary for
pd-mapper, which needs to readd a server each time the DSP is started or
stopped.

Tested-by: Neil Armstrong  # on SM8550-QRD
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/qmi_interface.c | 67 
 include/linux/soc/qcom/qmi.h |  2 ++
 2 files changed, 69 insertions(+)

diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c
index bb98b06e87f8..18ff2015c682 100644
--- a/drivers/soc/qcom/qmi_interface.c
+++ b/drivers/soc/qcom/qmi_interface.c
@@ -289,6 +289,73 @@ int qmi_add_server(struct qmi_handle *qmi, unsigned int 
service,
 }
 EXPORT_SYMBOL_GPL(qmi_add_server);
 
+static void qmi_send_del_server(struct qmi_handle *qmi, struct qmi_service 
*svc)
+{
+   struct qrtr_ctrl_pkt pkt;
+   struct sockaddr_qrtr sq;
+   struct msghdr msg = { };
+   struct kvec iv = { , sizeof(pkt) };
+   int ret;
+
+   memset(, 0, sizeof(pkt));
+   pkt.cmd = cpu_to_le32(QRTR_TYPE_DEL_SERVER);
+   pkt.server.service = cpu_to_le32(svc->service);
+   pkt.server.instance = cpu_to_le32(svc->version | svc->instance << 8);
+   pkt.server.node = cpu_to_le32(qmi->sq.sq_node);
+   pkt.server.port = cpu_to_le32(qmi->sq.sq_port);
+
+   sq.sq_family = qmi->sq.sq_family;
+   sq.sq_node = qmi->sq.sq_node;
+   sq.sq_port = QRTR_PORT_CTRL;
+
+   msg.msg_name = 
+   msg.msg_namelen = sizeof(sq);
+
+   mutex_lock(>sock_lock);
+   if (qmi->sock) {
+   ret = kernel_sendmsg(qmi->sock, , , 1, sizeof(pkt));
+   if (ret < 0)
+   pr_err("send service deregistration failed: %d\n", ret);
+   }
+   mutex_unlock(>sock_lock);
+}
+
+/**
+ * qmi_del_server() - register a service with the name service
+ * @qmi:   qmi handle
+ * @service:   type of the service
+ * @instance:  instance of the service
+ * @version:   version of the service
+ *
+ * Remove registration of the service with the name service. This notifies
+ * clients that they should no longer send messages to the client associated
+ * with @qmi.
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int qmi_del_server(struct qmi_handle *qmi, unsigned int service,
+  unsigned int version, unsigned int instance)
+{
+   struct qmi_service *svc;
+   struct qmi_service *tmp;
+
+   list_for_each_entry_safe(svc, tmp, >services, list_node) {
+   if (svc->service != service ||
+   svc->version != version ||
+   svc->instance != instance)
+   continue;
+
+   qmi_send_del_server(qmi, svc);
+   list_del(>list_node);
+   kfree(svc);
+
+   return 0;
+   }
+
+   return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(qmi_del_server);
+
 /**
  * qmi_txn_init() - allocate transaction id within the given QMI handle
  * @qmi:   QMI handle
diff --git a/include/linux/soc/qcom/qmi.h b/include/linux/soc/qcom/qmi.h
index 469e02d2aa0d..5039c30e4bdc 100644
--- a/include/linux/soc/qcom/qmi.h
+++ b/include/linux/soc/qcom/qmi.h
@@ -241,6 +241,8 @@ int qmi_add_lookup(struct qmi_handle *qmi, unsigned int 
service,
   unsigned int version, unsigned int instance);
 int qmi_add_server(struct qmi_handle *qmi, unsigned int service,
   unsigned int version, unsigned int instance);
+int qmi_del_server(struct qmi_handle *qmi, unsigned int service,
+  unsigned int version, unsigned int instance);
 
 int qmi_handle_init(struct qmi_handle *qmi, size_t max_msg_len,
const struct qmi_ops *ops,

-- 
2.39.2




[PATCH v7 3/6] soc: qcom: pdr: extract PDR message marshalling data

2024-04-24 Thread Dmitry Baryshkov
The in-kernel PD mapper is going to use same message structures as the
QCOM_PDR_HELPERS module. Extract message marshalling data to separate
module that can be used by both PDR helpers and by PD mapper.

Reviewed-by: Bryan O'Donoghue 
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/Kconfig|   4 +
 drivers/soc/qcom/Makefile   |   1 +
 drivers/soc/qcom/pdr_internal.h | 306 ++
 drivers/soc/qcom/qcom_pdr_msg.c | 319 
 4 files changed, 334 insertions(+), 296 deletions(-)

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 5af33b0e3470..95973c6b828f 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -75,8 +75,12 @@ config QCOM_OCMEM
 config QCOM_PDR_HELPERS
tristate
select QCOM_QMI_HELPERS
+   select QCOM_PDR_MSG
depends on NET
 
+config QCOM_PDR_MSG
+   tristate
+
 config QCOM_PMIC_PDCHARGER_ULOG
tristate "Qualcomm PMIC PDCharger ULOG driver"
depends on RPMSG
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index ca0bece0dfff..3110ac3288bc 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_QCOM_GSBI) +=  qcom_gsbi.o
 obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
 obj-$(CONFIG_QCOM_OCMEM)   += ocmem.o
 obj-$(CONFIG_QCOM_PDR_HELPERS) += pdr_interface.o
+obj-$(CONFIG_QCOM_PDR_MSG) += qcom_pdr_msg.o
 obj-$(CONFIG_QCOM_PMIC_GLINK)  += pmic_glink.o
 obj-$(CONFIG_QCOM_PMIC_GLINK)  += pmic_glink_altmode.o
 obj-$(CONFIG_QCOM_PMIC_PDCHARGER_ULOG) += pmic_pdcharger_ulog.o
diff --git a/drivers/soc/qcom/pdr_internal.h b/drivers/soc/qcom/pdr_internal.h
index 03c282b7f17e..7e5bb5a95275 100644
--- a/drivers/soc/qcom/pdr_internal.h
+++ b/drivers/soc/qcom/pdr_internal.h
@@ -28,83 +28,12 @@ struct servreg_location_entry {
u32 instance;
 };
 
-static const struct qmi_elem_info servreg_location_entry_ei[] = {
-   {
-   .data_type  = QMI_STRING,
-   .elem_len   = SERVREG_NAME_LENGTH + 1,
-   .elem_size  = sizeof(char),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  name),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_4_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u32),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  instance),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_1_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u8),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  service_data_valid),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_4_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u32),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0,
-   .offset = offsetof(struct servreg_location_entry,
-  service_data),
-   },
-   {}
-};
-
 struct servreg_get_domain_list_req {
char service_name[SERVREG_NAME_LENGTH + 1];
u8 domain_offset_valid;
u32 domain_offset;
 };
 
-static const struct qmi_elem_info servreg_get_domain_list_req_ei[] = {
-   {
-   .data_type  = QMI_STRING,
-   .elem_len   = SERVREG_NAME_LENGTH + 1,
-   .elem_size  = sizeof(char),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0x01,
-   .offset = offsetof(struct servreg_get_domain_list_req,
-  service_name),
-   },
-   {
-   .data_type  = QMI_OPT_FLAG,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u8),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0x10,
-   .offset = offsetof(struct servreg_get_domain_list_req,
-  domain_offset_valid),
-   },
-   {
-   .data_type  = QMI_UNSIGNED_4_BYTE,
-   .elem_len   = 1,
-   .elem_size  = sizeof(u32),
-   .array_type = NO_ARRAY,
-   .tlv_type   = 0x10,
-   .offset = offsetof(struct servreg_get_domain_list_req,
-  domain_offset),
-   },
-   {}
-};
-
 struct servreg_get_domain_list_resp {
struct qmi_response_type_v01 resp;

[PATCH v7 2/6] soc: qcom: pdr: fix parsing of domains lists

2024-04-24 Thread Dmitry Baryshkov
While parsing the domains list, start offsets from 0 rather than from
domains_read. The domains_read is equal to the total count of the
domains we have seen, while the domains list in the message starts from
offset 0.

Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/pdr_interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c
index 19cfe4b41235..3c6f2d21e5e4 100644
--- a/drivers/soc/qcom/pdr_interface.c
+++ b/drivers/soc/qcom/pdr_interface.c
@@ -415,7 +415,7 @@ static int pdr_locate_service(struct pdr_handle *pdr, 
struct pdr_service *pds)
if (ret < 0)
goto out;
 
-   for (i = domains_read; i < resp->domain_list_len; i++) {
+   for (i = 0; i < resp->domain_list_len; i++) {
entry = >domain_list[i];
 
if (strnlen(entry->name, sizeof(entry->name)) == 
sizeof(entry->name))

-- 
2.39.2




[PATCH v7 0/6] soc: qcom: add in-kernel pd-mapper implementation

2024-04-24 Thread Dmitry Baryshkov
Protection domain mapper is a QMI service providing mapping between
'protection domains' and services supported / allowed in these domains.
For example such mapping is required for loading of the WiFi firmware or
for properly starting up the UCSI / altmode / battery manager support.

The existing userspace implementation has several issue. It doesn't play
well with CONFIG_EXTRA_FIRMWARE, it doesn't reread the JSON files if the
firmware location is changed (or if the firmware was not available at
the time pd-mapper was started but the corresponding directory is
mounted later), etc.

However this configuration is largely static and common between
different platforms. Provide in-kernel service implementing static
per-platform data.

Unlike previous revisions of the patchset, this iteration uses static
configuration per platform, rather than building it dynamically from the
list of DSPs being started.

To: Bjorn Andersson 
To: Konrad Dybcio 
To: Sibi Sankar 
To: Mathieu Poirier 
Cc: linux-arm-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-remotep...@vger.kernel.org
Cc: Johan Hovold 
Cc: Xilin Wu 
Cc: "Bryan O'Donoghue" 
--

Changes in v7:
- Fixed modular build (Steev)
- Link to v6: 
https://lore.kernel.org/r/20240422-qcom-pd-mapper-v6-0-f96957d01...@linaro.org

Changes in v6:
- Reworked mutex to fix lockdep issue on deregistration
- Fixed dependencies between PD-mapper and remoteproc to fix modular
  builds (Krzysztof)
- Added EXPORT_SYMBOL_GPL to fix modular builds (Krzysztof)
- Fixed kerneldocs (Krzysztof)
- Removed extra pr_debug messages (Krzysztof)
- Fixed wcss build (Krzysztof)
- Added platforms which do not require protection domain mapping to
  silence the notice on those platforms
- Link to v5: 
https://lore.kernel.org/r/20240419-qcom-pd-mapper-v5-0-e35b6f847...@linaro.org

Changes in v5:
- pdr: drop lock in pdr_register_listener, list_lock is already held (Chris Lew)
- pd_mapper: reworked to provide static configuration per platform
  (Bjorn)
- Link to v4: 
https://lore.kernel.org/r/20240311-qcom-pd-mapper-v4-0-24679cca5...@linaro.org

Changes in v4:
- Fixed missing chunk, reenabled kfree in qmi_del_server (Konrad)
- Added configuration for sm6350 (Thanks to Luca)
- Removed RFC tag (Konrad)
- Link to v3: 
https://lore.kernel.org/r/20240304-qcom-pd-mapper-v3-0-6858fa1ac...@linaro.org

Changes in RFC v3:
- Send start / stop notifications when PD-mapper domain list is changed
- Reworked the way PD-mapper treats protection domains, register all of
  them in a single batch
- Added SC7180 domains configuration based on TCL Book 14 GO
- Link to v2: 
https://lore.kernel.org/r/20240301-qcom-pd-mapper-v2-0-5d12a081d...@linaro.org

Changes in RFC v2:
- Swapped num_domains / domains (Konrad)
- Fixed an issue with battery not working on sc8280xp
- Added missing configuration for QCS404

---
Dmitry Baryshkov (6):
  soc: qcom: pdr: protect locator_addr with the main mutex
  soc: qcom: pdr: fix parsing of domains lists
  soc: qcom: pdr: extract PDR message marshalling data
  soc: qcom: qmi: add a way to remove running service
  soc: qcom: add pd-mapper implementation
  remoteproc: qcom: enable in-kernel PD mapper

 drivers/remoteproc/Kconfig  |   4 +
 drivers/remoteproc/qcom_q6v5_adsp.c |  11 +-
 drivers/remoteproc/qcom_q6v5_mss.c  |  10 +-
 drivers/remoteproc/qcom_q6v5_pas.c  |  12 +-
 drivers/remoteproc/qcom_q6v5_wcss.c |  12 +-
 drivers/soc/qcom/Kconfig|  14 +
 drivers/soc/qcom/Makefile   |   2 +
 drivers/soc/qcom/pdr_interface.c|   6 +-
 drivers/soc/qcom/pdr_internal.h | 318 ++---
 drivers/soc/qcom/qcom_pd_mapper.c   | 656 
 drivers/soc/qcom/qcom_pdr_msg.c | 353 +++
 drivers/soc/qcom/qmi_interface.c|  67 
 include/linux/soc/qcom/pd_mapper.h  |  28 ++
 include/linux/soc/qcom/qmi.h|   2 +
 14 files changed, 1193 insertions(+), 302 deletions(-)
---
base-commit: a59668a9397e7245b26e9be85d23f242ff757ae8
change-id: 20240301-qcom-pd-mapper-e12d622d4ad0

Best regards,
-- 
Dmitry Baryshkov 




[PATCH v7 1/6] soc: qcom: pdr: protect locator_addr with the main mutex

2024-04-24 Thread Dmitry Baryshkov
If the service locator server is restarted fast enough, the PDR can
rewrite locator_addr fields concurrently. Protect them by placing
modification of those fields under the main pdr->lock.

Fixes: fbe639b44a82 ("soc: qcom: Introduce Protection Domain Restart helpers")
Tested-by: Neil Armstrong  # on SM8550-QRD
Signed-off-by: Dmitry Baryshkov 
---
 drivers/soc/qcom/pdr_interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/pdr_interface.c b/drivers/soc/qcom/pdr_interface.c
index a1b6a4081dea..19cfe4b41235 100644
--- a/drivers/soc/qcom/pdr_interface.c
+++ b/drivers/soc/qcom/pdr_interface.c
@@ -76,12 +76,12 @@ static int pdr_locator_new_server(struct qmi_handle *qmi,
  locator_hdl);
struct pdr_service *pds;
 
+   mutex_lock(>lock);
/* Create a local client port for QMI communication */
pdr->locator_addr.sq_family = AF_QIPCRTR;
pdr->locator_addr.sq_node = svc->node;
pdr->locator_addr.sq_port = svc->port;
 
-   mutex_lock(>lock);
pdr->locator_init_complete = true;
mutex_unlock(>lock);
 
@@ -104,10 +104,10 @@ static void pdr_locator_del_server(struct qmi_handle *qmi,
 
mutex_lock(>lock);
pdr->locator_init_complete = false;
-   mutex_unlock(>lock);
 
pdr->locator_addr.sq_node = 0;
pdr->locator_addr.sq_port = 0;
+   mutex_unlock(>lock);
 }
 
 static const struct qmi_ops pdr_locator_ops = {

-- 
2.39.2




[PATCH v2 2/3] arm64: dts: qcom: msm8996: add glink-edge nodes

2024-04-18 Thread Dmitry Baryshkov
MSM8996 provides limited glink support, so add corresponding device tree
nodes. For example the following interfaces are provided on db820c:

modem:
208.remoteproc:glink-edge.LOOPBACK_CTL_MPSS.-1.-1
208.remoteproc:glink-edge.glink_ssr.-1.-1
208.remoteproc:glink-edge.rpmsg_chrdev.0.0

adsp:
930.remoteproc:glink-edge.LOOPBACK_CTL_LPASS.-1.-1
930.remoteproc:glink-edge.glink_ssr.-1.-1
930.remoteproc:glink-edge.rpmsg_chrdev.0.0

Reviewed-by: Konrad Dybcio 
Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/msm8996.dtsi | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi 
b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 1601e46549e7..7ae499fa7d91 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -2453,6 +2453,13 @@ slpi_pil: remoteproc@1c0 {
 
status = "disabled";
 
+   glink-edge {
+   interrupts = ;
+   label = "dsps";
+   qcom,remote-pid = <3>;
+   mboxes = <_glb 27>;
+   };
+
smd-edge {
interrupts = ;
 
@@ -2522,6 +2529,13 @@ metadata {
memory-region = <_mem>;
};
 
+   glink-edge {
+   interrupts = ;
+   label = "modem";
+   qcom,remote-pid = <1>;
+   mboxes = <_glb 15>;
+   };
+
smd-edge {
interrupts = ;
 
@@ -3467,6 +3481,14 @@ adsp_pil: remoteproc@930 {
 
status = "disabled";
 
+   glink-edge {
+   interrupts = ;
+   label = "lpass";
+   qcom,remote-pid = <2>;
+   mboxes = <_glb 9>;
+   };
+
+
smd-edge {
interrupts = ;
 

-- 
2.39.2




[PATCH v2 3/3] arm64: dts: msm8996: add fastrpc nodes

2024-04-18 Thread Dmitry Baryshkov
From: Srinivas Kandagatla 

The ADSP provides fastrpc/compute capabilities. Enable support for the
fastrpc on this DSP.

Signed-off-by: Srinivas Kandagatla 
Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/msm8996.dtsi | 57 +++
 1 file changed, 57 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi 
b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 7ae499fa7d91..f9bbb191661b 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -3545,6 +3545,63 @@ q6routing: routing {
};
};
};
+
+   fastrpc {
+   compatible = "qcom,fastrpc";
+   qcom,smd-channels = 
"fastrpcsmd-apps-dsp";
+   label = "adsp";
+   qcom,non-secure-domain;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cb@5 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <5>;
+   iommus = <_q6_smmu 5>;
+   };
+
+   cb@6 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <6>;
+   iommus = <_q6_smmu 6>;
+   };
+
+   cb@7 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <7>;
+   iommus = <_q6_smmu 7>;
+   };
+
+   cb@8 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <8>;
+   iommus = <_q6_smmu 8>;
+   };
+
+   cb@9 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <9>;
+   iommus = <_q6_smmu 9>;
+   };
+
+   cb@10 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <10>;
+   iommus = <_q6_smmu 10>;
+   };
+
+   cb@11 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <11>;
+   iommus = <_q6_smmu 11>;
+   };
+
+   cb@12 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <12>;
+   iommus = <_q6_smmu 12>;
+   };
+   };
};
};
 

-- 
2.39.2




[PATCH v2 0/3] arm64: dts: qcom: msm8996: enable fastrpc and glink-edge

2024-04-18 Thread Dmitry Baryshkov
Enable the FastRPC and glink-edge nodes on MSM8996 platform. Tested on
APQ8096 Dragonboard820c.

Signed-off-by: Dmitry Baryshkov 
---
Changes in v2:
- Fixed order of compute nodes (Konrad)
- Link to v1: 
https://lore.kernel.org/r/20240401-msm8996-remoteproc-v1-0-f02ab47fc...@linaro.org

---
Dmitry Baryshkov (2):
  dt-bindings: remoteproc: qcom,msm8996-mss-pil: allow glink-edge on msm8996
  arm64: dts: qcom: msm8996: add glink-edge nodes

Srinivas Kandagatla (1):
  arm64: dts: msm8996: add fastrpc nodes

 .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  1 -
 arch/arm64/boot/dts/qcom/msm8996.dtsi  | 79 ++
 2 files changed, 79 insertions(+), 1 deletion(-)
---
base-commit: 4eab358930711bbeb85bf5ee267d0d42d3394c2c
change-id: 20240320-msm8996-remoteproc-fccbc2b54ea1

Best regards,
-- 
Dmitry Baryshkov 




[PATCH v2 1/3] dt-bindings: remoteproc: qcom,msm8996-mss-pil: allow glink-edge on msm8996

2024-04-18 Thread Dmitry Baryshkov
MSM8996 has limited glink support, allow glink-edge node on MSM8996
platform.

Acked-by: Rob Herring 
Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml 
b/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml
index 971734085d51..4d2055f283ac 100644
--- a/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml
@@ -231,7 +231,6 @@ allOf:
 - const: snoc_axi
 - const: mnoc_axi
 - const: qdss
-glink-edge: false
   required:
 - pll-supply
 - smd-edge

-- 
2.39.2




Re: [PATCHv3 1/2] dt-bindings: usb: typec: anx7688: start a binding document

2024-04-11 Thread Dmitry Baryshkov
On Thu, Apr 11, 2024 at 09:59:35PM +0200, Krzysztof Kozlowski wrote:
> On 10/04/2024 04:20, Ondřej Jirman wrote:
> > On Mon, Apr 08, 2024 at 10:12:30PM GMT, Krzysztof Kozlowski wrote:
> >> On 08/04/2024 17:17, Ondřej Jirman wrote:
> >>>
> >>> Now for things to not fail during suspend/resume based on PM callbacks
> >>> invocation order, anx7688 driver needs to enable this regulator too, as 
> >>> long
> >>> as it needs it.
> >>
> >> No, the I2C bus driver needs to manage it. Not one individual I2C
> >> device. Again, why anx7688 is specific? If you next phone has anx8867,
> >> using different driver, you also add there i2c-supply? And if it is
> >> nxp,ptn5100 as well?
> > 
> > Yes, that could work, if I2C core would manage this.
> 
> Either I don't understand about which I2C regulator you speak or this is
> not I2C core regulator. This is a regulator to be managed by the I2C
> controller, not by I2C core.

If it is a supply that pulls up the SDA/SCL lines, then it is generic
enough to be handled by the core. For example, on Qualcomm platforms CCI
lines also usually have external supply as a pull-up.


-- 
With best wishes
Dmitry



Re: [PATCH v2 2/2] ARM: dts: qcom: msm8974-hammerhead: Update gpio hog node name

2024-04-09 Thread Dmitry Baryshkov
On Tue, 9 Apr 2024 at 21:37, Luca Weiss  wrote:
>
> Follow the gpio-hog bindings and use otg-hog as node name.
>
> Signed-off-by: Luca Weiss 
> ---
>  arch/arm/boot/dts/qcom/qcom-msm8974-lge-nexus5-hammerhead.dts | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry



Re: [PATCHv3 2/2] usb: typec: anx7688: Add driver for ANX7688 USB-C HDMI bridge

2024-04-09 Thread Dmitry Baryshkov
On Tue, Apr 09, 2024 at 01:04:12PM +0200, Pavel Machek wrote:
> Hi!
> 
> > > This is driver for ANX7688 USB-C HDMI, with flashing and debugging
> > > features removed. ANX7688 is rather criticial piece on PinePhone,
> > > there's no display and no battery charging without it.
> > > 
> > > There's likely more work to be done here, but having basic support
> > > in mainline is needed to be able to work on the other stuff
> > > (networking, cameras, power management).
> > > 
> > > Signed-off-by: Ondrej Jirman 
> > > Co-developed-by: Martijn Braam 
> > > Co-developed-by: Samuel Holland 
> > > Signed-off-by: Pavel Machek 
> > 
> > Just couple of quick comments below - I did not have time to go over
> > this very thoroughly, but I think you need to make a new version in
> > any case because of comments in 1/2.
> 

[skipped]

> 
> > > +static int anx7688_connect(struct anx7688 *anx7688)
> > > +{
> > > + struct typec_partner_desc desc = {};
> > > + int ret, i;
> > > + u8 fw[2];
> > > + const u8 dp_snk_identity[16] = {
> > > + 0x00, 0x00, 0x00, 0xec, /* id header */
> > > + 0x00, 0x00, 0x00, 0x00, /* cert stat */
> > > + 0x00, 0x00, 0x00, 0x00, /* product type */
> > > + 0x39, 0x00, 0x00, 0x51  /* alt mode adapter */
> > > + };
> > > + const u8 svid[4] = {
> > > + 0x00, 0x00, 0x01, 0xff,
> > > + };
> > 
> > Why not get those from DT?
> 
> Are you sure it belongs to the DT (and that DT people will agree)?

>From Documentation/devicetree/bindings/connector/usb-connector.yaml:

altmodes {
displayport {
svid = /bits/ 16 <0xff01>;
vdo = <0x1c46>;
};
};

BTW, I don't see the VDO for the DP altmode in your code. Maybe I missed
it at a quick glance.

> 
> > > + u32 caps[8];
> > > +


-- 
With best wishes
Dmitry



Re: [PATCH] ARM: dts: qcom: msm8974-sony-shinano: Enable vibrator

2024-04-06 Thread Dmitry Baryshkov
On Sat, 6 Apr 2024 at 18:36, Luca Weiss  wrote:
>
> Enable the vibrator connected to PM8941 found on the Sony shinano
> platform.
>
> Signed-off-by: Luca Weiss 
> ---
>  .../arm/boot/dts/qcom/qcom-msm8974pro-sony-xperia-shinano-common.dtsi | 4 
> 
>  1 file changed, 4 insertions(+)


Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry



Re: [PATCH 3/3] arm64: dts: msm8996: add fastrpc nodes

2024-04-02 Thread Dmitry Baryshkov
On Tue, 2 Apr 2024 at 17:47, Konrad Dybcio  wrote:
>
> On 31.03.2024 11:10 PM, Dmitry Baryshkov wrote:
> > From: Srinivas Kandagatla 
> >
> > The ADSP provides fastrpc/compute capabilities. Enable support for the
> > fastrpc on this DSP.
> >
> > Signed-off-by: Srinivas Kandagatla 
> > Signed-off-by: Dmitry Baryshkov 
> > ---
> >  arch/arm64/boot/dts/qcom/msm8996.dtsi | 57 
> > +++
> >  1 file changed, 57 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi 
> > b/arch/arm64/boot/dts/qcom/msm8996.dtsi
> > index 7ae499fa7d91..cf7ab01f3af6 100644
> > --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
> > @@ -3545,6 +3545,63 @@ q6routing: routing {
> >   };
> >   };
> >   };
> > +
> > + fastrpc {
> > + compatible = "qcom,fastrpc";
> > + qcom,smd-channels = 
> > "fastrpcsmd-apps-dsp";
> > + label = "adsp";
> > + qcom,non-secure-domain;
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + cb@8 {
> > + compatible = 
> > "qcom,fastrpc-compute-cb";
> > + reg = <8>;
> > + iommus = <_q6_smmu 8>;
> > + };
> > +
> > + cb@9 {
> > + compatible = 
> > "qcom,fastrpc-compute-cb";
> > + reg = <9>;
> > + iommus = <_q6_smmu 9>;
> > + };
> > +
> > + cb@10 {
> > + compatible = 
> > "qcom,fastrpc-compute-cb";
> > + reg = <10>;
> > + iommus = <_q6_smmu 10>;
> > + };
> > +
> > + cb@11 {
> > + compatible = 
> > "qcom,fastrpc-compute-cb";
> > + reg = <11>;
> > + iommus = <_q6_smmu 11>;
> > + };
> > +
> > + cb@12 {
> > + compatible = 
> > "qcom,fastrpc-compute-cb";
> > + reg = <12>;
> > + iommus = <_q6_smmu 12>;
> > + };
> > +
> > + cb@5 {
> > + compatible = 
> > "qcom,fastrpc-compute-cb";
> > + reg = <5>;
>
> No need to copy downstream's creative alphabetical-but-not-numerical
> sorting..

Ack, I'll fix the order.

> The entries look OK though.. although, any reason we have
> such a weird binding including faux child nodes and not just an array
> of iommus? Is the only way to discover the fastrpc nodes' properties
> such as qcom,non-secure-domain or vmid belonging through hardcoding?

No idea here. This is how fastrpc nodes are defined on all existing
platforms. Maybe Srini knows the story and the reason behind the
bindings??



-- 
With best wishes
Dmitry



[PATCH 3/3] arm64: dts: msm8996: add fastrpc nodes

2024-03-31 Thread Dmitry Baryshkov
From: Srinivas Kandagatla 

The ADSP provides fastrpc/compute capabilities. Enable support for the
fastrpc on this DSP.

Signed-off-by: Srinivas Kandagatla 
Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/msm8996.dtsi | 57 +++
 1 file changed, 57 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi 
b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 7ae499fa7d91..cf7ab01f3af6 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -3545,6 +3545,63 @@ q6routing: routing {
};
};
};
+
+   fastrpc {
+   compatible = "qcom,fastrpc";
+   qcom,smd-channels = 
"fastrpcsmd-apps-dsp";
+   label = "adsp";
+   qcom,non-secure-domain;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cb@8 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <8>;
+   iommus = <_q6_smmu 8>;
+   };
+
+   cb@9 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <9>;
+   iommus = <_q6_smmu 9>;
+   };
+
+   cb@10 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <10>;
+   iommus = <_q6_smmu 10>;
+   };
+
+   cb@11 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <11>;
+   iommus = <_q6_smmu 11>;
+   };
+
+   cb@12 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <12>;
+   iommus = <_q6_smmu 12>;
+   };
+
+   cb@5 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <5>;
+   iommus = <_q6_smmu 5>;
+   };
+
+   cb@6 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <6>;
+   iommus = <_q6_smmu 6>;
+   };
+
+   cb@7 {
+   compatible = 
"qcom,fastrpc-compute-cb";
+   reg = <7>;
+   iommus = <_q6_smmu 7>;
+   };
+   };
};
};
 

-- 
2.39.2




[PATCH 2/3] arm64: dts: qcom: msm8996: add glink-edge nodes

2024-03-31 Thread Dmitry Baryshkov
MSM8996 provides limited glink support, so add corresponding device tree
nodes. For example the following interfaces are provided on db820c:

modem:
208.remoteproc:glink-edge.LOOPBACK_CTL_MPSS.-1.-1
208.remoteproc:glink-edge.glink_ssr.-1.-1
208.remoteproc:glink-edge.rpmsg_chrdev.0.0

adsp:
930.remoteproc:glink-edge.LOOPBACK_CTL_LPASS.-1.-1
930.remoteproc:glink-edge.glink_ssr.-1.-1
930.remoteproc:glink-edge.rpmsg_chrdev.0.0

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/msm8996.dtsi | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi 
b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 1601e46549e7..7ae499fa7d91 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -2453,6 +2453,13 @@ slpi_pil: remoteproc@1c0 {
 
status = "disabled";
 
+   glink-edge {
+   interrupts = ;
+   label = "dsps";
+   qcom,remote-pid = <3>;
+   mboxes = <_glb 27>;
+   };
+
smd-edge {
interrupts = ;
 
@@ -2522,6 +2529,13 @@ metadata {
memory-region = <_mem>;
};
 
+   glink-edge {
+   interrupts = ;
+   label = "modem";
+   qcom,remote-pid = <1>;
+   mboxes = <_glb 15>;
+   };
+
smd-edge {
interrupts = ;
 
@@ -3467,6 +3481,14 @@ adsp_pil: remoteproc@930 {
 
status = "disabled";
 
+   glink-edge {
+   interrupts = ;
+   label = "lpass";
+   qcom,remote-pid = <2>;
+   mboxes = <_glb 9>;
+   };
+
+
smd-edge {
interrupts = ;
 

-- 
2.39.2




[PATCH 1/3] dt-bindings: remoteproc: qcom,msm8996-mss-pil: allow glink-edge on msm8996

2024-03-31 Thread Dmitry Baryshkov
MSM8996 has limited glink support, allow glink-edge node on MSM8996
platform.

Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml 
b/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml
index 971734085d51..4d2055f283ac 100644
--- a/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,msm8996-mss-pil.yaml
@@ -231,7 +231,6 @@ allOf:
 - const: snoc_axi
 - const: mnoc_axi
 - const: qdss
-glink-edge: false
   required:
 - pll-supply
 - smd-edge

-- 
2.39.2




[PATCH 0/3] arm64: dts: qcom: msm8996: enable fastrpc and glink-edge

2024-03-31 Thread Dmitry Baryshkov
Enable the FastRPC and glink-edge nodes on MSM8996 platform. Tested on
APQ8096 Dragonboard820c.

Signed-off-by: Dmitry Baryshkov 
---
Dmitry Baryshkov (2):
  dt-bindings: remoteproc: qcom,msm8996-mss-pil: allow glink-edge on msm8996
  arm64: dts: qcom: msm8996: add glink-edge nodes

Srinivas Kandagatla (1):
  arm64: dts: msm8996: add fastrpc nodes

 .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  1 -
 arch/arm64/boot/dts/qcom/msm8996.dtsi  | 79 ++
 2 files changed, 79 insertions(+), 1 deletion(-)
---
base-commit: 13ee4a7161b6fd938aef6688ff43b163f6d83e37
change-id: 20240320-msm8996-remoteproc-fccbc2b54ea1

Best regards,
-- 
Dmitry Baryshkov 




Re: [PATCH 5/5] arm64: dts: qcom: sm7225-fairphone-fp4: Enable USB role switching

2024-03-22 Thread Dmitry Baryshkov
On Fri, 22 Mar 2024 at 10:03, Luca Weiss  wrote:
>
> Configure the Type-C and VBUS regulator on PM7250B and wire it up to the
> USB PHY, so that USB role and orientation switching works.
>
> Signed-off-by: Luca Weiss 
> ---
> With this patch I'm not quite sure if the 'ports' are connected
> correctly, though functionally everything appears to work fine.
>
> On some other SoCs port@1 in qmpphy and a second port in dwc3 are
> connected together also - one port of USB 2.0 HS, one for USB 3.0 SS.
>
> Here I'm following sm8250's solution. Also checking the binding doc
> doesn't reveal anything useful.

Thanks for pointing it out. The SM8250 / RB5 predated final DP
bindings / graphs. As such it didn't fully describe the signal chain
(the signals go from DWC3 and from DP controllers to the QMP PHY,
where they are muxed to the 4 output lanes).
I'll post an update for sm8250 / bindings doc.

I'd kindly ask to connect qmp / port@1 and dwc / port@1

> ---
>  arch/arm64/boot/dts/qcom/sm6350.dtsi  | 25 ++
>  arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts | 57 
> ++-
>  2 files changed, 81 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/boot/dts/qcom/sm6350.dtsi 
> b/arch/arm64/boot/dts/qcom/sm6350.dtsi
> index 24bcec3366ef..b267500467f0 100644
> --- a/arch/arm64/boot/dts/qcom/sm6350.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm6350.dtsi
> @@ -1686,6 +1686,27 @@ usb_1_qmpphy: phy@88e8000 {
> #phy-cells = <1>;
>
> status = "disabled";
> +
> +   ports {
> +   #address-cells = <1>;
> +   #size-cells = <0>;
> +
> +   port@0 {
> +   reg = <0>;
> +
> +   usb_1_qmpphy_out: endpoint {};
> +   };
> +
> +   port@1 {
> +   reg = <1>;
> +   };
> +
> +   port@2 {
> +   reg = <2>;
> +
> +   usb_1_qmpphy_dp_in: endpoint {};
> +   };
> +   };
> };
>
> dc_noc: interconnect@916 {
> @@ -1861,6 +1882,10 @@ usb_1_dwc3: usb@a60 {
> snps,hird-threshold = /bits/ 8 <0x10>;
> phys = <_1_hsphy>, <_1_qmpphy 
> QMP_USB43DP_USB3_PHY>;
> phy-names = "usb2-phy", "usb3-phy";
> +
> +   port {
> +   usb_1_role_switch_out: endpoint {};
> +   };
> };
> };
>
> diff --git a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts 
> b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> index bc67e8c1fe4d..104f23ec322d 100644
> --- a/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> +++ b/arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts
> @@ -19,6 +19,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include "sm7225.dtsi"
>  #include "pm6150l.dtsi"
>  #include "pm6350.dtsi"
> @@ -543,6 +544,50 @@ conn-therm@1 {
> };
>  };
>
> +_typec {
> +   vdd-pdphy-supply = <_l3a>;
> +
> +   status = "okay";
> +
> +   connector {
> +   compatible = "usb-c-connector";
> +
> +   power-role = "source";
> +   data-role = "dual";
> +   self-powered;
> +
> +   source-pdos =  +PDO_FIXED_DUAL_ROLE |
> +PDO_FIXED_USB_COMM |
> +PDO_FIXED_DATA_SWAP)>;
> +
> +   ports {
> +   #address-cells = <1>;
> +   #size-cells = <0>;
> +
> +   port@0 {
> +   reg = <0>;
> +   pm7250b_role_switch_in: endpoint {
> +   remote-endpoint = 
> <_1_role_switch_out>;
> +   };
> +   };
> +
> +   port@1 {
> +   reg = <1>;
> +   pm7250b_typec_mux_in: endpoint {
> +   remote-endpoint = <_1_qmpphy_out>;
> +   };
> +   };
> +   };
> +   };
> +};
> +
> +_vbus {
> +   regulator-min-microamp = <50>;
> +   regulator-max-microamp = <150>;
> +   status = "okay";
> +};
> +
>  _rtc {
> status = "okay";
>  };
> @@ -726,7 +771,12 @@ _1 {
>
>  _1_dwc3 {
> maximum-speed = "super-speed";
> -   dr_mode = "peripheral";
> +   dr_mode = "otg";
> +   usb-role-switch;
> +};
> +
> +_1_role_switch_out {
> +

Re: [PATCH] usb: typec: ptn36502: switch to DRM_AUX_BRIDGE

2024-03-15 Thread Dmitry Baryshkov
On Fri, 15 Mar 2024 at 18:04, Luca Weiss  wrote:
>
> Switch to using the new DRM_AUX_BRIDGE helper to create the transparent
> DRM bridge device instead of handcoding corresponding functionality.
>
> Signed-off-by: Luca Weiss 
> ---
> Very similar to this patch:
> c5d296bad640 ("usb: typec: nb7vpq904m: switch to DRM_AUX_BRIDGE")

Thanks! LGTM

> ---
>  drivers/usb/typec/mux/Kconfig|  2 +-
>  drivers/usb/typec/mux/ptn36502.c | 44 
> ++--
>  2 files changed, 3 insertions(+), 43 deletions(-)

Reviewed-by: Dmitry Baryshkov 


-- 
With best wishes
Dmitry



Re: [PATCH 2/5] ARM: dts: qcom: msm8974pro-castor: Add mmc aliases

2024-03-06 Thread Dmitry Baryshkov
On Wed, 6 Mar 2024 at 01:26, Luca Weiss  wrote:
>
> Add the mmc0 & mmc1 aliases to make sure internal storage always becomes
> /dev/mmcblk0 and SD card becomes /dev/mmcblk1
>
> Signed-off-by: Luca Weiss 
> ---
>  arch/arm/boot/dts/qcom/qcom-msm8974pro-sony-xperia-shinano-castor.dts | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry



Re: [PATCH 4/5] ARM: dts: qcom: msm8974pro-castor: Add debounce-interval for keys

2024-03-06 Thread Dmitry Baryshkov
On Wed, 6 Mar 2024 at 01:26, Luca Weiss  wrote:
>
> Set the debounce-interval for the GPIO keys.
>
> Signed-off-by: Luca Weiss 
> ---
>  arch/arm/boot/dts/qcom/qcom-msm8974pro-sony-xperia-shinano-castor.dts | 2 ++
>  1 file changed, 2 insertions(+)


Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry



Re: [PATCH 5/5] ARM: dts: qcom: msm8974pro-castor: Rename wifi node name

2024-03-06 Thread Dmitry Baryshkov
On Wed, 6 Mar 2024 at 01:18, Luca Weiss  wrote:
>
> Give the wifi node a generic node name 'wifi'.
>
> Signed-off-by: Luca Weiss 
> ---
>  arch/arm/boot/dts/qcom/qcom-msm8974pro-sony-xperia-shinano-castor.dts | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Dmitry Baryshkov 




-- 
With best wishes
Dmitry



Re: [PATCH v2 3/3] arm64: dts: qcom: qcs404: Use qcs404-hfpll compatible for hfpll

2024-02-18 Thread Dmitry Baryshkov
On Sun, 18 Feb 2024 at 22:58, Luca Weiss  wrote:
>
> Follow the updated bindings and use a QCS404-specific compatible for the
> HFPLL on this SoC.
>
> Signed-off-by: Luca Weiss 
> ---
> Please note that this patch should only land after the patch for the
> clock driver.
> ---
>  arch/arm64/boot/dts/qcom/qcs404.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Dmitry Baryshkov 


-- 
With best wishes
Dmitry



Re: [PATCH 2/3] remoteproc: qcom_q6v5_pas: Add support for X1E80100 ADSP/CDSP

2024-01-29 Thread Dmitry Baryshkov
On Mon, 29 Jan 2024 at 15:35, Abel Vesa  wrote:
>
> From: Sibi Sankar 
>
> Add support for PIL loading on ADSP and CDSP on X1E80100 SoCs.
>
> Signed-off-by: Sibi Sankar 
> Signed-off-by: Abel Vesa 
> ---
>  drivers/remoteproc/qcom_q6v5_pas.c | 41 
> ++
>  1 file changed, 41 insertions(+)
>

Reviewed-by: Dmitry Baryshkov 


-- 
With best wishes
Dmitry



Re: [PATCH 3/3] remoteproc: qcom_q6v5_pas: Unload lite firmware on ADSP

2024-01-29 Thread Dmitry Baryshkov
On Mon, 29 Jan 2024 at 15:35, Abel Vesa  wrote:
>
> From: Sibi Sankar 
>
> The UEFI loads a lite variant of the ADSP firmware to support charging
> use cases. The kernel needs to unload and reload it with the firmware
> that has full feature support for audio. This patch arbitarily shutsdown
> the lite firmware before loading the full firmware.
>
> Signed-off-by: Sibi Sankar 
> Signed-off-by: Abel Vesa 
> ---
>  drivers/remoteproc/qcom_q6v5_pas.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c 
> b/drivers/remoteproc/qcom_q6v5_pas.c
> index 083d71f80e5c..4f6940368eb4 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
> @@ -39,6 +39,7 @@ struct adsp_data {
> const char *dtb_firmware_name;
> int pas_id;
> int dtb_pas_id;
> +   int lite_pas_id;
> unsigned int minidump_id;
> bool auto_boot;
> bool decrypt_shutdown;
> @@ -72,6 +73,7 @@ struct qcom_adsp {
> const char *dtb_firmware_name;
> int pas_id;
> int dtb_pas_id;
> +   int lite_pas_id;
> unsigned int minidump_id;
> int crash_reason_smem;
> bool decrypt_shutdown;
> @@ -210,6 +212,10 @@ static int adsp_load(struct rproc *rproc, const struct 
> firmware *fw)
> /* Store firmware handle to be used in adsp_start() */
> adsp->firmware = fw;
>
> +   /* WIP: Shutdown the ADSP if it's running a lite version of the 
> firmware*/

Why is it still marked as WIP?

> +   if (adsp->lite_pas_id)
> +   ret = qcom_scm_pas_shutdown(adsp->lite_pas_id);
> +
> if (adsp->dtb_pas_id) {
> ret = request_firmware(>dtb_firmware, 
> adsp->dtb_firmware_name, adsp->dev);
> if (ret) {
> @@ -693,6 +699,7 @@ static int adsp_probe(struct platform_device *pdev)
> adsp->rproc = rproc;
> adsp->minidump_id = desc->minidump_id;
> adsp->pas_id = desc->pas_id;
> +   adsp->lite_pas_id = desc->lite_pas_id;
> adsp->info_name = desc->sysmon_name;
> adsp->decrypt_shutdown = desc->decrypt_shutdown;
> adsp->region_assign_idx = desc->region_assign_idx;
> @@ -990,6 +997,7 @@ static const struct adsp_data x1e80100_adsp_resource = {
> .dtb_firmware_name = "adsp_dtb.mdt",
> .pas_id = 1,
> .dtb_pas_id = 0x24,
> +   .lite_pas_id = 0x1f,
> .minidump_id = 5,
> .auto_boot = true,
> .proxy_pd_names = (char*[]){
>
> --
> 2.34.1
>
>


-- 
With best wishes
Dmitry



Re: [PATCH RFC 2/2] arm64: dts: qcom: msm8953: Add GPU

2024-01-25 Thread Dmitry Baryshkov

On 25/01/2024 23:56, Luca Weiss wrote:

From: Vladimir Lypak 

Add the GPU node for the Adreno 506 found on this family of SoCs. The
clock speeds are a bit different per SoC variant, SDM450 maxes out at
600MHz while MSM8953 (= SDM625) goes up to 650MHz and SDM632 goes up to
725MHz.

To achieve this, create a new sdm450.dtsi to hold the 600MHz OPP and
use the new dtsi for sdm450-motorola-ali.

Signed-off-by: Vladimir Lypak 
Co-developed-by: Luca Weiss 
Signed-off-by: Luca Weiss 
---
  arch/arm64/boot/dts/qcom/msm8953.dtsi| 115 +++
  arch/arm64/boot/dts/qcom/sdm450-motorola-ali.dts |   2 +-
  arch/arm64/boot/dts/qcom/sdm450.dtsi |  14 +++
  arch/arm64/boot/dts/qcom/sdm632.dtsi |   8 ++
  4 files changed, 138 insertions(+), 1 deletion(-)


Reviewed-by: Dmitry Baryshkov 


--
With best wishes
Dmitry




Re: [PATCH RFC 1/2] arm64: dts: qcom: msm8953: Add GPU IOMMU

2024-01-25 Thread Dmitry Baryshkov

On 25/01/2024 23:56, Luca Weiss wrote:

From: Vladimir Lypak 

Add the IOMMU used for the GPU on MSM8953.

Signed-off-by: Vladimir Lypak 
---
  arch/arm64/boot/dts/qcom/msm8953.dtsi | 31 +++
  1 file changed, 31 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8953.dtsi 
b/arch/arm64/boot/dts/qcom/msm8953.dtsi
index dcb5c98b793c..91d083871ab0 100644
--- a/arch/arm64/boot/dts/qcom/msm8953.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8953.dtsi
@@ -1046,6 +1046,37 @@ mdss_dsi1_phy: phy@1a96400 {
};
};
  
+		gpu_iommu: iommu@1c48000 {


Nit: most of the platforms use the adreno_smmu label. But maybe the 
msm-iommu vs arm-smmu makes difference here.


Nevertheless:

Reviewed-by: Dmitry Baryshkov 


+   compatible = "qcom,msm8953-iommu", "qcom,msm-iommu-v2";
+   ranges = <0 0x01c48000 0x8000>;
+
+   clocks = < GCC_OXILI_AHB_CLK>,
+< GCC_BIMC_GFX_CLK>;
+   clock-names = "iface", "bus";
+
+   power-domains = < OXILI_CX_GDSC>;
+
+   qcom,iommu-secure-id = <18>;
+
+   #address-cells = <1>;
+   #iommu-cells = <1>;
+   #size-cells = <1>;
+
+   /* gfx3d_user */
+   iommu-ctx@0 {
+   compatible = "qcom,msm-iommu-v2-ns";
+   reg = <0x 0x1000>;
+   interrupts = ;
+   };
+
+   /* gfx3d_secure */
+   iommu-ctx@2000 {
+   compatible = "qcom,msm-iommu-v2-sec";
+   reg = <0x2000 0x1000>;
+   interrupts = ;
+   };
+   };
+
apps_iommu: iommu@1e2 {
compatible = "qcom,msm8953-iommu", "qcom,msm-iommu-v1";
ranges = <0 0x01e2 0x2>;



--
With best wishes
Dmitry




Re: [PATCH v2 2/3] clk: qcom: gcc-msm8953: add more resets

2024-01-25 Thread Dmitry Baryshkov
On Thu, 25 Jan 2024 at 23:36, Luca Weiss  wrote:
>
> From: Vladimir Lypak 
>
> Add new entries in the gcc driver for some more resets found on MSM8953.
>
> Signed-off-by: Vladimir Lypak 
> [luca: expand commit message, move entry, add more entries]
> Signed-off-by: Luca Weiss 
> ---
>  drivers/clk/qcom/gcc-msm8953.c | 4 
>  1 file changed, 4 insertions(+)

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry



Re: [PATCH v2 3/3] arm64: dts: qcom: msm8953: add reset for display subsystem

2024-01-25 Thread Dmitry Baryshkov
On Thu, 25 Jan 2024 at 23:36, Luca Weiss  wrote:
>
> From: Vladimir Lypak 
>
> With this reset we can avoid situations like IRQ storms from DSI host
> before it even started probing (because boot-loader left DSI IRQs on).
>
> Signed-off-by: Vladimir Lypak 
> Reviewed-by: Konrad Dybcio 
> Signed-off-by: Luca Weiss 
> ---
>  arch/arm64/boot/dts/qcom/msm8953.dtsi | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry



Re: [PATCH 2/2] arm64: dts: qcom: sm7225-fairphone-fp4: Add PM6150L thermals

2024-01-09 Thread Dmitry Baryshkov
On Tue, 9 Jan 2024 at 12:10, Konrad Dybcio  wrote:
>
>
>
> On 1/5/24 15:54, Luca Weiss wrote:
> > Configure the thermals for the PA_THERM1, MSM_THERM, PA_THERM0,
> > RFC_CAM_THERM, CAM_FLASH_THERM and QUIET_THERM thermistors connected to
> > PM6150L.
> >
> > Due to hardware constraints we can only register 4 zones with
> > pm6150l_adc_tm, the other 2 we can register via generic-adc-thermal.
>
> Ugh.. so the ADC can support more inputs than the ADC_TM that was
> designed to ship alongside it can?

Yes. ADC_TM can support monitoring of 8 channels in total.

>
> And that's why the "generic-adc-thermal"-provided zones need to
> be polled?
>
> >
> > The trip points can really only be considered as placeholders, more
> > configuration with cooling etc. can be added later.
> >
> > Signed-off-by: Luca Weiss 
> > ---
> [...]
>
> I've read the sentence above, but..
> > + sdm-skin-thermal {
> > + polling-delay-passive = <1000>;
> > + polling-delay = <5000>;
> > + thermal-sensors = <_therm_sensor>;
> > +
> > + trips {
> > + active-config0 {
> > + temperature = <125000>;
> > + hysteresis = <1000>;
> > + type = "passive";
>
> I don't fancy burnt fingers for dinner!
>
> Konrad
>


-- 
With best wishes
Dmitry



Re: [PATCH RFT] arm64: dts: qcom: sm8350: Reenable crypto & cryptobam

2024-01-08 Thread Dmitry Baryshkov
On Mon, 8 Jan 2024 at 16:23, Luca Weiss  wrote:
>
> On Mon Jan 8, 2024 at 3:18 PM CET, Konrad Dybcio wrote:
> > On 8.01.2024 14:49, Luca Weiss wrote:
> > > When num-channels and qcom,num-ees is not provided in devicetree, the
> > > driver will try to read these values from the registers during probe but
> > > this fails if the interconnect is not on and then crashes the system.
> > >
> > > So we can provide these properties in devicetree (queried after patching
> > > BAM driver to enable the necessary interconnect) so we can probe
> > > cryptobam without reading registers and then also use the QCE as
> > > expected.
> >
> > This really feels a bit backwards.. Enable the resource to query the
> > hardware for numbers, so that said resource can be enabled, but
> > slightly later :/
>
> If you think adding interconnect support to driver and dtsi is better,
> let me know.

I'd say, adding the proper interconnect is a better option. Otherwise
we just depend on the QCE itself to set up the vote for us.

>
> Stephan (+CC) mentioned it should be okay like this *shrug*
>
> For the record, this is the same way I got the values for sc7280[0] and
> sm6350[1].
>
> [0] 
> https://lore.kernel.org/linux-arm-msm/20231229-sc7280-cryptobam-fixup-v1-1-bd8f68589...@fairphone.com/
> [1] 
> https://lore.kernel.org/linux-arm-msm/20240105-sm6350-qce-v1-0-416e5c731...@fairphone.com/
>
> diff --git a/arch/arm64/boot/dts/qcom/sm8350.dtsi 
> b/arch/arm64/boot/dts/qcom/sm8350.dtsi
> index b46236235b7f..cd4dd9852d9e 100644
> --- a/arch/arm64/boot/dts/qcom/sm8350.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm8350.dtsi
> @@ -1756,8 +1756,8 @@ cryptobam: dma-controller@1dc4000 {
> qcom,controlled-remotely;
> iommus = <_smmu 0x594 0x0011>,
>  <_smmu 0x596 0x0011>;
> -   /* FIXME: Probing BAM DMA causes some abort and 
> system hang */
> -   status = "fail";
> +   interconnects = <_noc MASTER_CRYPTO 0 _virt 
> SLAVE_EBI1 0>;
> +   interconnect-names = "memory";
> };
>
> crypto: crypto@1dfa000 {
> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
> index 5e7d332731e0..9de28f615639 100644
> --- a/drivers/dma/qcom/bam_dma.c
> +++ b/drivers/dma/qcom/bam_dma.c
> @@ -40,6 +40,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  #include "../dmaengine.h"
> @@ -394,6 +395,7 @@ struct bam_device {
> const struct reg_offset_data *layout;
>
> struct clk *bamclk;
> +   struct icc_path *mem_path;
> int irq;
>
> /* dma start transaction tasklet */
> @@ -1206,6 +1208,7 @@ static int bam_init(struct bam_device *bdev)
> bdev->num_channels = val & BAM_NUM_PIPES_MASK;
> }
>
> +   printk(KERN_ERR "%s:%d DBG num_ees=%u num_channels=%u\n", __func__, 
> __LINE__, bdev->num_ees, bdev->num_channels);
> /* Reset BAM now if fully controlled locally */
> if (!bdev->controlled_remotely && !bdev->powered_remotely)
> bam_reset(bdev);
> @@ -1298,6 +1301,14 @@ static int bam_dma_probe(struct platform_device *pdev)
> return ret;
> }
>
> +   bdev->mem_path = devm_of_icc_get(bdev->dev, "memory");
> +   if (IS_ERR(bdev->mem_path))
> +   return PTR_ERR(bdev->mem_path);
> +
> +   ret = icc_set_bw(bdev->mem_path, 1, 1);

Probably this needs some more sensible value.

> +   if (ret)
> +   return ret;
> +
> ret = bam_init(bdev);
> if (ret)
> goto err_disable_clk;
>


-- 
With best wishes
Dmitry



Re: [PATCH 1/3] dt-bindings: clock: qcom,hfpll: Convert to YAML

2024-01-02 Thread Dmitry Baryshkov
On Sun, 31 Dec 2023 at 16:49, Luca Weiss  wrote:
>
> Convert the .txt documentation to .yaml.
>
> Take the liberty to change the compatibles for ipq8064, apq8064, msm8974
> and msm8960 to follow the updated naming schema. These compatibles are
> not used upstream yet.
>
> Also add a compatible for QCS404 since that SoC upstream already uses
> qcom,hfpll compatible but without an SoC-specific string.
>
> Signed-off-by: Luca Weiss 
> ---
>  .../devicetree/bindings/clock/qcom,hfpll.txt   | 63 -
>  .../devicetree/bindings/clock/qcom,hfpll.yaml  | 82 
> ++
>  2 files changed, 82 insertions(+), 63 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/clock/qcom,hfpll.txt 
> b/Documentation/devicetree/bindings/clock/qcom,hfpll.txt
> deleted file mode 100644
> index 5769cbbe76be..
> --- a/Documentation/devicetree/bindings/clock/qcom,hfpll.txt
> +++ /dev/null
> @@ -1,63 +0,0 @@
> -High-Frequency PLL (HFPLL)
> -
> -PROPERTIES
> -
> -- compatible:
> -   Usage: required
> -   Value type: :
> -   shall contain only one of the following. The generic
> -   compatible "qcom,hfpll" should be also included.
> -
> -"qcom,hfpll-ipq8064", "qcom,hfpll"
> -"qcom,hfpll-apq8064", "qcom,hfpll"
> -"qcom,hfpll-msm8974", "qcom,hfpll"
> -"qcom,hfpll-msm8960", "qcom,hfpll"
> -"qcom,msm8976-hfpll-a53", "qcom,hfpll"
> -"qcom,msm8976-hfpll-a72", "qcom,hfpll"
> -"qcom,msm8976-hfpll-cci", "qcom,hfpll"
> -
> -- reg:
> -   Usage: required
> -   Value type: 
> -   Definition: address and size of HPLL registers. An optional second
> -   element specifies the address and size of the alias
> -   register region.
> -
> -- clocks:
> -   Usage: required
> -   Value type: 
> -   Definition: reference to the xo clock.
> -
> -- clock-names:
> -   Usage: required
> -   Value type: 
> -   Definition: must be "xo".
> -
> -- clock-output-names:
> -   Usage: required
> -   Value type: 
> -   Definition: Name of the PLL. Typically hfpllX where X is a CPU number
> -   starting at 0. Otherwise hfpll_Y where Y is more specific
> -   such as "l2".
> -
> -Example:
> -
> -1) An HFPLL for the L2 cache.
> -
> -   clock-controller@f9016000 {
> -   compatible = "qcom,hfpll-ipq8064", "qcom,hfpll";
> -   reg = <0xf9016000 0x30>;
> -   clocks = <_board>;
> -   clock-names = "xo";
> -   clock-output-names = "hfpll_l2";
> -   };
> -
> -2) An HFPLL for CPU0. This HFPLL has the alias register region.
> -
> -   clock-controller@f908a000 {
> -   compatible = "qcom,hfpll-ipq8064", "qcom,hfpll";
> -   reg = <0xf908a000 0x30>, <0xf900a000 0x30>;
> -   clocks = <_board>;
> -   clock-names = "xo";
> -   clock-output-names = "hfpll0";
> -   };
> diff --git a/Documentation/devicetree/bindings/clock/qcom,hfpll.yaml 
> b/Documentation/devicetree/bindings/clock/qcom,hfpll.yaml
> new file mode 100644
> index ..2cb4098012bc
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/qcom,hfpll.yaml
> @@ -0,0 +1,82 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/clock/qcom,hfpll.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Qualcomm High-Frequency PLL
> +
> +maintainers:
> +  - Bjorn Andersson 
> +
> +description:
> +  The HFPLL is used as CPU PLL on various Qualcomm SoCs.
> +
> +properties:
> +  compatible:
> +items:
> +  - enum:
> +  - qcom,apq8064-hfpll
> +  - qcom,ipq8064-hfpll
> +  - qcom,msm8960-hfpll

I think we should drop these entries. On msm8960 / apq8064 / ipq8064
the HFPLLs are a part of GCC, so there is no need for a separate
compat entry.

> +  - qcom,msm8974-hfpll

This one is good, the HFPLL is separate, next to the acc / saw

> +  - qcom,msm8976-hfpll-a53
> +  - qcom,msm8976-hfpll-a72
> +  - qcom,msm8976-hfpll-cci

Ok.

> +  - qcom,qcs404-hfpll
> +  - const: qcom,hfpll
> +
> +  reg:
> +items:
> +  - description: Base address and size of the register region
> +  - description: Optional base address and size of the alias register 
> region
> +minItems: 1
> +
> +  '#clock-cells':
> +const: 0
> +
> +  clocks:
> +items:
> +  - description: board XO clock
> +
> +  clock-names:
> +items:
> +  - const: xo
> +
> +  clock-output-names:
> +description:
> +  Name of the PLL. Typically hfpllX where X is a CPU number starting at 
> 0.
> +  Otherwise hfpll_Y where Y is more specific such as "l2".
> +maxItems: 1
> +
> +required:
> +  - 

Re: [PATCH 0/3] Fairphone 5 PMIC-GLINK support (USB-C, charger, fuel gauge)

2023-12-21 Thread Dmitry Baryshkov
On Thu, 21 Dec 2023 at 09:33, Luca Weiss  wrote:
>
> On Wed Dec 20, 2023 at 1:32 PM CET, Konrad Dybcio wrote:
> > On 20.12.2023 11:02, Luca Weiss wrote:
> > > This series adds all the necessary bits to enable USB-C role switching,
> > > charger and fuel gauge (all via pmic-glink) on Fairphone 5.
> > >
> > > One thing that could be made different is the pmic-glink compatible.
> > > I've chosen to use qcm6490 compatible for it and not sc7280 since
> > > there's plenty of firmware variety on sc7280-based platforms and they
> > > might require different quirks in the future, so limit this PDOS quirk
> > > to just qcm6490 for now.
> > >
> > > If someone thinks it should be qcom,sc7280-pmic-glink, please let me
> > > know :)
> > IMO it's best to continue using the "base soc" (which just so happened
> > to fall onto sc7280 this time around) for all compatibles, unless the
> > derivatives actually had changes
>
> Hi Konrad,
>
> I think at some point I asked Dmitry what he thought and he mentioned
> qcm6490. Even found the message again:
>
> > well, since it is a firmware thing, you might want to emphasise that.
> > So from my POV qcm6490 makes more sense
>
> But yeah since it's likely that sc7280 firmware behaves the same as
> qcm6490 firmware it's probably okay to use sc7280 compatible, worst case
> we change it later :) I'll send a v2 with those changes.

Worst case we end up with sc7280 which has yet another slightly
different UCSI / PMIC GLINK implementation, but the compatible string
is already taken.
I still suppose that this should be a qcm6490-related string.

>
> Regards
> Luca
>
> >
> > as far as firmware goes, I *think* CrOS doesn't even have PMIC_GLINK?
> > There are however WoA 7280 laptops which totally should have it.. Would
> > be nice to hunt some down and see if they report different stuff to
> > what's there on android firmware
> >
> > Konrad
>


-- 
With best wishes
Dmitry



Re: [PATCH 2/3] usb: typec: ucsi: Add qcm6490-pmic-glink as needing PDOS quirk

2023-12-20 Thread Dmitry Baryshkov
On Wed, 20 Dec 2023 at 12:04, Luca Weiss  wrote:
>
> The QCM6490 Linux Android firmware needs this workaround as well. Add it
> to the list.
>
> Signed-off-by: Luca Weiss 
> ---
>  drivers/usb/typec/ucsi/ucsi_glink.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry



Re: [PATCH v5 2/3] arm64: dts: qcom: sc7280: Add UFS nodes for sc7280 soc

2023-12-05 Thread Dmitry Baryshkov

On 05/12/2023 10:45, Nitin Rawat wrote:



On 12/4/2023 10:58 PM, Manivannan Sadhasivam wrote:

On Mon, Dec 04, 2023 at 01:21:42PM +0100, Luca Weiss wrote:

On Mon Dec 4, 2023 at 1:15 PM CET, Nitin Rawat wrote:



On 12/4/2023 3:54 PM, Luca Weiss wrote:

From: Nitin Rawat 

Add UFS host controller and PHY nodes for sc7280 soc.

Signed-off-by: Nitin Rawat 
Reviewed-by: Konrad Dybcio 
Tested-by: Konrad Dybcio  # QCM6490 FP5
[luca: various cleanups and additions as written in the cover letter]
Signed-off-by: Luca Weiss 
---
   arch/arm64/boot/dts/qcom/sc7280.dtsi | 74 
+++-

   1 file changed, 73 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi 
b/arch/arm64/boot/dts/qcom/sc7280.dtsi

index 04bf85b0399a..8b08569f2191 100644
--- a/arch/arm64/boot/dts/qcom/sc7280.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi
@@ -15,6 +15,7 @@
   #include 
   #include 
   #include 
+#include 
   #include 
   #include 
   #include 
@@ -906,7 +907,7 @@ gcc: clock-controller@10 {
   clocks = < RPMH_CXO_CLK>,
    < RPMH_CXO_CLK_A>, <_clk>,
    <0>, <_phy>,
- <0>, <0>, <0>,
+ <_mem_phy 0>, <_mem_phy 1>, <_mem_phy 
2>,

    <_1_qmpphy QMP_USB43DP_USB3_PIPE_CLK>;
   clock-names = "bi_tcxo", "bi_tcxo_ao", "sleep_clk",
 "pcie_0_pipe_clk", "pcie_1_pipe_clk",
@@ -2238,6 +2239,77 @@ pcie1_phy: phy@1c0e000 {
   status = "disabled";
   };
+    ufs_mem_hc: ufs@1d84000 {
+    compatible = "qcom,sc7280-ufshc", "qcom,ufshc",
+ "jedec,ufs-2.0";
+    reg = <0x0 0x01d84000 0x0 0x3000>;
+    interrupts = ;
+    phys = <_mem_phy>;
+    phy-names = "ufsphy";
+    lanes-per-direction = <2>;
+    #reset-cells = <1>;
+    resets = < GCC_UFS_PHY_BCR>;
+    reset-names = "rst";
+
+    power-domains = < GCC_UFS_PHY_GDSC>;
+    required-opps = <_opp_nom>;
+
+    iommus = <_smmu 0x80 0x0>;
+    dma-coherent;
+
+    interconnects = <_noc MASTER_UFS_MEM 
QCOM_ICC_TAG_ALWAYS

+ _virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>,
+    <_noc MASTER_APPSS_PROC QCOM_ICC_TAG_ALWAYS
+  SLAVE_UFS_MEM_CFG QCOM_ICC_TAG_ALWAYS>;
+    interconnect-names = "ufs-ddr", "cpu-ufs";
+
+    clocks = < GCC_UFS_PHY_AXI_CLK>,
+ < GCC_AGGRE_UFS_PHY_AXI_CLK>,
+ < GCC_UFS_PHY_AHB_CLK>,
+ < GCC_UFS_PHY_UNIPRO_CORE_CLK>,
+ < RPMH_CXO_CLK>,
+ < GCC_UFS_PHY_TX_SYMBOL_0_CLK>,
+ < GCC_UFS_PHY_RX_SYMBOL_0_CLK>,
+ < GCC_UFS_PHY_RX_SYMBOL_1_CLK>;
+    clock-names = "core_clk",
+  "bus_aggr_clk",
+  "iface_clk",
+  "core_clk_unipro",
+  "ref_clk",
+  "tx_lane0_sync_clk",
+  "rx_lane0_sync_clk",
+  "rx_lane1_sync_clk";
+    freq-table-hz =
+    <7500 3>,
+    <0 0>,
+    <0 0>,
+    <7500 3>,
+    <0 0>,
+    <0 0>,
+    <0 0>,
+    <0 0>;
+    status = "disabled";
+    };
+
+    ufs_mem_phy: phy@1d87000 {
+    compatible = "qcom,sc7280-qmp-ufs-phy";
+    reg = <0x0 0x01d87000 0x0 0xe00>;
+    clocks = < RPMH_CXO_CLK>,
+ < GCC_UFS_PHY_PHY_AUX_CLK>,
+ < GCC_UFS_1_CLKREF_EN>;
+    clock-names = "ref", "ref_aux", "qref";
+
+    power-domains = < GCC_UFS_PHY_GDSC>;


Hi Nitin,



GCC_UFS_PHY_GDSC is UFS controller GDSC. For sc7280 Phy we don't 
need this.


In the current dt-bindings the power-domains property is required.

Is there another power-domain for the PHY to use, or do we need to
adjust the bindings to not require power-domains property for ufs phy on
sc7280?



PHYs are backed by MX power domain. So you should use that.


Also, with "PHY" in the name, it's interesting that this is not for the
phy ;)



Yes, confusing indeed. But the controllers (PCIe, UFS, USB etc...) are 
backed by
GDSCs and all the analog components (PHYs) belong to MX domain since 
it is kind

of always ON.

I'll submit a series to fix this for the rest of the SoCs.

- Mani



Hi Mani,

UFS Phy is a passive driver and its resource enable/disable is 
controlled by UFS controller driver.


Since PHY belongs to MX domain which is always on. IMO, there is no need 
for explicitly voting for MX domain for sc7280 and older targets.


Only starting SM8550, we have a separate UFS PHY GDSC which needs to be 
voted for enabling or disabling and hence we need to have power-domain 
property for SM8550.


Hence, I feel updating the binding to reflect that 

Re: [PATCH v2 2/3] arm64: dts: qcom: sc7280: Move video-firmware to chrome-common

2023-11-24 Thread Dmitry Baryshkov
On Fri, 24 Nov 2023 at 14:30, Vikash Garodia  wrote:
>
> On 11/24/2023 5:05 PM, Luca Weiss wrote:
> > On Fri Nov 24, 2023 at 7:38 AM CET, Vikash Garodia wrote:
> >>
> >> On 11/22/2023 7:50 PM, Luca Weiss wrote:
> >>> On Wed Nov 22, 2023 at 2:17 PM CET, Vikash Garodia wrote:
> 
>  On 10/2/2023 7:50 PM, Luca Weiss wrote:
> > If the video-firmware node is present, the venus driver assumes we're on
> > a system that doesn't use TZ for starting venus, like on ChromeOS
> > devices.
> >
> > Move the video-firmware node to chrome-common.dtsi so we can use venus
> > on a non-ChromeOS devices.
> >
> > At the same time also disable the venus node by default in the dtsi,
> > like it's done on other SoCs.
> >
> > Reviewed-by: Bryan O'Donoghue 
> > Signed-off-by: Luca Weiss 
> > ---
> >  arch/arm64/boot/dts/qcom/sc7280-chrome-common.dtsi | 8 
> >  arch/arm64/boot/dts/qcom/sc7280.dtsi   | 6 ++
> >  2 files changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/arm64/boot/dts/qcom/sc7280-chrome-common.dtsi 
> > b/arch/arm64/boot/dts/qcom/sc7280-chrome-common.dtsi
> > index 5d462ae14ba1..cd491e4d 100644
> > --- a/arch/arm64/boot/dts/qcom/sc7280-chrome-common.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/sc7280-chrome-common.dtsi
> > @@ -104,6 +104,14 @@  {
> >   dma-coherent;
> >  };
> >
> > + {
> > + status = "okay";
> > +
> > + video-firmware {
> > + iommus = <_smmu 0x21a2 0x0>;
> > + };
> > +};
> > +
> >   {
> >   status = "okay";
> >  };
> > diff --git a/arch/arm64/boot/dts/qcom/sc7280.dtsi 
> > b/arch/arm64/boot/dts/qcom/sc7280.dtsi
> > index 66f1eb83cca7..fa53f54d4675 100644
> > --- a/arch/arm64/boot/dts/qcom/sc7280.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/sc7280.dtsi
> > @@ -3740,6 +3740,8 @@ venus: video-codec@aa0 {
> ><_smmu 0x2184 0x20>;
> >> 0x2184 is a secure SID. I think qcm6490-fairphone-fp5.dts needs to 
> >> override the
> >> iommus property as well to retain only the non secure SID i.e 0x2180 ? I am
> >> seeing below crash
> >>
> >> Call trace:
> >> [   47.663593]  qcom_smmu_write_s2cr+0x64/0xa4
> >> [   47.663616]  arm_smmu_attach_dev+0x120/0x284
> >> [   47.663647]  __iommu_attach_device+0x24/0xf8
> >> [   47.676845]  __iommu_device_set_domain+0x70/0xd0
> >> [   47.681632]  __iommu_group_set_domain_internal+0x60/0x1b4
> >> [   47.687218]  iommu_setup_default_domain+0x358/0x418
> >> [   47.692258]  __iommu_probe_device+0x3e4/0x404
> >>
> >> Could you please reconfirm if Video SID 0x2184 (and mask) is allowed by the
> >> qcm6490-fairphone-fp5 hardware having TZ ?
> >
> > Hi,
> >
> > On FP5 it seems it's no problem to have both SIDs in there, probe and
> > using venus appears to work fine.
> >
> > Are you using different firmware than QCM6490.LA.3.0 on the device where
> > you tested this?
> I was testing this on RB3 board which uses firmware [1].

There is something wrong here.

RB3 board uses venus-5.2
RB5 board uses vpu-1.0
Only sc7280 uses vpu-2.0

>
> Regards,
> Vikash
>
> [1]
> https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/qcom/vpu-2.0
>
> >>
> >   memory-region = <_mem>;
> >
> > + status = "disabled";
> > +
> >   video-decoder {
> >   compatible = "venus-decoder";
> >   };
> > @@ -3748,10 +3750,6 @@ video-encoder {
> >   compatible = "venus-encoder";
> >   };
> >
> > - video-firmware {
> > - iommus = <_smmu 0x21a2 0x0>;
> > - };
> > -
> >   venus_opp_table: opp-table {
> >   compatible = "operating-points-v2";
> >
> >
>  Changes look good. Is this tested on SC7280 ?
> >>>
> >>> Hi Vikash,
> >>>
> >>> I didn't test it myself on sc7280 (just qcm6490-fp5) but dtx_diff
> >>> reports no differences except for status = okay property being added, so
> >>> there should be no change on those boards. See below.
> >>>
> >>> Regards
> >>> Luca
> >>
> >> I tested on SC7280 (herobrine) and all good.
> >
> > Great, thanks!
> >
> > Regards
> > Luca
> >
> >>
> >> Regards,
> >> Vikash
> >
>


-- 
With best wishes
Dmitry



Re: [PATCH 9/9] arm64: dts: qcom: qcm6490-fairphone-fp5: Enable WiFi

2023-11-04 Thread Dmitry Baryshkov
[Added Kalle to the CC list]

On Tue, 31 Oct 2023 at 12:31, Luca Weiss  wrote:
>
> On Mon Oct 30, 2023 at 8:26 PM CET, Konrad Dybcio wrote:
> > On 27.10.2023 16:20, Luca Weiss wrote:
> > > Now that the WPSS remoteproc is enabled, enable wifi so we can use it.
> > >
> > > Signed-off-by: Luca Weiss 
> > > ---
> > >  arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 4 
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts 
> > > b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> > > index d65eef30091b..e7e20f73cbe6 100644
> > > --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> > > +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> > > @@ -713,3 +713,7 @@  {
> > > firmware-name = "qcom/qcm6490/fairphone5/venus.mbn";
> > > status = "okay";
> > >  };
> > > +
> > > + {
> > > +   status = "okay";
> > qcom,ath11k-calibration-variant?
>
> What value would I put there for my device? Based on existing usages
> (mostly for ath10k) I'd say "Fairphone_5"?

I think this is fine.

> And you mean I should add this property in dts before even looking into
> the firmware/calibration side of it?

>From my experience some (most?) of the device manufacturers do the
wrong thing here. They do not program a sensible board_id, leaving it
as 0xff or some other semi-random value. The calibration variant is
the only way for the kernel to distinguish between such poor devices.

The kernel will do a smart thing though. If the device-specific
calibration data is not present, it will try to fall back to the
generic data.

-- 
With best wishes
Dmitry


Re: [PATCH 3/3] remoteproc: qcom: pas: Add SM8650 remoteproc support

2023-10-25 Thread Dmitry Baryshkov
On Wed, 25 Oct 2023 at 10:43, Neil Armstrong  wrote:
>
> Add DSP Peripheral Authentication Service support for the SM8650 platform.
>
> Signed-off-by: Neil Armstrong 
> ---
>  drivers/remoteproc/qcom_q6v5_pas.c | 50 
> ++
>  1 file changed, 50 insertions(+)

Reviewed-by: Dmitry Baryshkov 


-- 
With best wishes
Dmitry


Re: [PATCH] ARM: dts: qcom: msm8226: provide dsi phy clocks to mmcc

2023-09-23 Thread Dmitry Baryshkov
On Wed, 12 Jul 2023 at 10:53, Luca Weiss  wrote:
>
> Some mmcc clocks have dsi0pll & dsi0pllbyte as clock parents so we
> should provide them in the dt, which I missed in the commit adding the
> mdss nodes.
>
> Fixes: d5fb01ad5eb4 ("ARM: dts: qcom: msm8226: Add mdss nodes")
> Signed-off-by: Luca Weiss 
> ---
>  arch/arm/boot/dts/qcom/qcom-msm8226.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry


Re: [PATCH v2] ARM: dts: qcom: msm8974: correct qfprom node size

2023-09-23 Thread Dmitry Baryshkov
On Fri, 22 Sept 2023 at 19:57, Luca Weiss  wrote:
>
> On Sonntag, 6. August 2023 12:47:51 CEST Luca Weiss wrote:
> > Hi Bjorn,
> >
> > On Montag, 31. Juli 2023 23:45:21 CEST Bjorn Andersson wrote:
> > > On Thu, Jun 15, 2023 at 08:20:41PM +0200, Konrad Dybcio wrote:
> > > > On 15.06.2023 20:17, Luca Weiss wrote:
> > > > > From: Craig Tatlor 
> > > > >
> > > > > The qfprom actually has size 0x3000, so adjust the reg.
> > > > >
> > > > > Note that the non-ECC-corrected qfprom can be found at 0xfc4b8000
> > > > > (-0x4000). The current reg points to the ECC-corrected qfprom block
> > > > > which should have equivalent values at all offsets compared to the
> > > > > non-corrected version.
> > > > >
> > > > > [l...@z3ntu.xyz: extract to standalone patch and adjust for review
> > > > > comments]
> > > > >
> > > > > Fixes: c59ffb519357 ("arm: dts: msm8974: Add thermal zones, tsens and
> > > > > qfprom nodes") Signed-off-by: Craig Tatlor 
> > > > > Signed-off-by: Luca Weiss 
> > > > > ---
> > > >
> > > > Not sure of the actual size of the region, maybe Bjorn can help..
> > > >
> > > > Downstream 3.10 suggests 0x60F0, 0x20F0 after adjusting for the ECC
> > > > offset
> > >
> > > There is indeed 0x3000 bytes until the next region, but afaict the
> > > corrected ECC values only cover the first 0x800 bytes thereof.
> > >
> > > Can you please let me know if this patch fixes a problem, or just
> > > makes the numbers look better?
> >
> > Initially this patch came from a different direction, to make space to use
> > the PVS bits for cpufreq. Since Konrad said in earlier revisions that I
> > should always use the +0x4000 space for the ECC-corrected variant I've
> > switched to that.
> >
> > If you think it's not useful to have the qfprom size reflect the actual
> > size, we can also drop this patch since I don't think it's actually
> > necessary for anything that I have lying around in some branches.
> >
> > I think I've just sent the current patch to make sure the hardware
> > description (dts) is as accurate as possible, but of course since any info
> > on Qualcomm is very restricted it could also be a bit wrong.
>
> Hi Bjorn,
>
> this patch is still lying in my inbox. Do you think it's correct or incorrect
> - so should we drop it?

There are JTAG and coresight fuses at 0xfc4be024. So, I think, the
regions should be extended to 0x20f0 or 0x2100. BTW: could you please
also fix msm8974 and apq8084 in a similar way?

>
> Regards
> Luca
>
> >
> > Regards
> > Luca
> >
> > > Regards,
> > > Bjorn
> > >
> > > > Konrad
> > > >
> > > > > Changes in v2:
> > > > > - Keep base offset but expand reg from 0x1000 to 0x3000 (Konrad)
> > > > > - Link to v1:
> > > > > https://lore.kernel.org/r/20230130-msm8974-qfprom-v1-1-975aa0e5e083@z3
> > > > > n
> > > > > tu.xyz ---
> > > > >
> > > > >  arch/arm/boot/dts/qcom-msm8974.dtsi | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi
> > > > > b/arch/arm/boot/dts/qcom-msm8974.dtsi index 7ed0d925a4e9..3156fe25967f
> > > > > 100644
> > > > > --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
> > > > > +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
> > > > > @@ -1194,7 +1194,7 @@ restart@fc4ab000 {
> > > > >
> > > > > qfprom: qfprom@fc4bc000 {
> > > > >
> > > > > compatible = "qcom,msm8974-qfprom",
> >
> > "qcom,qfprom";
> >
> > > > > -   reg = <0xfc4bc000 0x1000>;
> > > > > +   reg = <0xfc4bc000 0x3000>;
> > > > >
> > > > > #address-cells = <1>;
> > > > > #size-cells = <1>;
> > > > >
> > > > > ---
> > > > > base-commit: 858fd168a95c5b9669aac8db6c14a9aeab446375
> > > > > change-id: 20230130-msm8974-qfprom-619c0e8f26eb
> > > > >
> > > > > Best regards,
>
>
>
>


-- 
With best wishes
Dmitry


Re: [PATCH v2 3/3] ARM: dts: qcom: msm8226: Add blsp1_i2c6 and blsp1_uart2

2023-09-23 Thread Dmitry Baryshkov
On Fri, 22 Sept 2023 at 19:56, Luca Weiss  wrote:
>
> Add more busses found on msm8226 SoC.
>
> Signed-off-by: Luca Weiss 
> ---
>  arch/arm/boot/dts/qcom/qcom-msm8226.dtsi | 33 
> 
>  1 file changed, 33 insertions(+)
>

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry


Re: [PATCH v2 2/3] pinctrl: qcom: msm8226: Add blsp_i2c6 function

2023-09-23 Thread Dmitry Baryshkov
On Fri, 22 Sept 2023 at 19:56, Luca Weiss  wrote:
>
> On GPIO22 and GPIO23 there is another I2C bus. Add the function for it.
>
> Signed-off-by: Luca Weiss 
> ---
>  drivers/pinctrl/qcom/pinctrl-msm8226.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>

Reviewed-by: Dmitry Baryshkov 

-- 
With best wishes
Dmitry


Re: [PATCH] drm/msm/a6xx: fix for kernels without CONFIG_NVMEM

2021-04-01 Thread Dmitry Baryshkov
On Thu, 1 Apr 2021 at 23:09, Rob Clark  wrote:
>
> On Mon, Feb 22, 2021 at 8:06 AM Rob Clark  wrote:
> >
> > On Mon, Feb 22, 2021 at 7:45 AM Akhil P Oommen  
> > wrote:
> > >
> > > On 2/19/2021 9:30 PM, Rob Clark wrote:
> > > > On Fri, Feb 19, 2021 at 2:44 AM Akhil P Oommen  
> > > > wrote:
> > > >>
> > > >> On 2/18/2021 9:41 PM, Rob Clark wrote:
> > > >>> On Thu, Feb 18, 2021 at 4:28 AM Akhil P Oommen 
> > > >>>  wrote:
> > > 
> > >  On 2/18/2021 2:05 AM, Jonathan Marek wrote:
> > > > On 2/17/21 3:18 PM, Rob Clark wrote:
> > > >> On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse
> > > >>  wrote:
> > > >>>
> > > >>> On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:
> > >  On 2/17/2021 8:36 AM, Rob Clark wrote:
> > > > On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek 
> > > > 
> > > > wrote:
> > > >>
> > > >> Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a
> > > >> ENOENT error,
> > > >> to fix the case where the kernel was compiled without 
> > > >> CONFIG_NVMEM.
> > > >>
> > > >> Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 
> > > >> gpu")
> > > >> Signed-off-by: Jonathan Marek 
> > > >> ---
> > > >> drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
> > > >> 1 file changed, 3 insertions(+), 3 deletions(-)
> > > >>
> > > >> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >> index ba8e9d3cf0fe..7fe5d97606aa 100644
> > > >> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> > > >> @@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct
> > > >> device *dev, struct a6xx_gpu *a6xx_gpu,
> > > >>
> > > >>cell = nvmem_cell_get(dev, "speed_bin");
> > > >>/*
> > > >> -* -ENOENT means that the platform doesn't support
> > > >> speedbin which is
> > > >> -* fine
> > > >> +* -ENOENT means no speed bin in device tree,
> > > >> +* -EOPNOTSUPP means kernel was built without 
> > > >> CONFIG_NVMEM
> > > >
> > > > very minor nit, it would be nice to at least preserve the gist 
> > > > of the
> > > > "which is fine" (ie. some variation of "this is an optional 
> > > > thing and
> > > > things won't catch fire without it" ;-))
> > > >
> > > > (which is, I believe, is true, hopefully Akhil could confirm.. 
> > > > if not
> > > > we should have a harder dependency on CONFIG_NVMEM..)
> > >  IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw'
> > >  property,
> > >  we will see some error during boot up if we don't call
> > >  dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev,
> > >  "speed_bin")"
> > >  is a way to test this.
> > > 
> > >  If there is no other harm, we can put a hard dependency on
> > >  CONFIG_NVMEM.
> > > >>>
> > > >>> I'm not sure if we want to go this far given the squishiness about
> > > >>> module
> > > >>> dependencies. As far as I know we are the only driver that uses 
> > > >>> this
> > > >>> seriously
> > > >>> on QCOM SoCs and this is only needed for certain targets. I don't
> > > >>> know if we
> > > >>> want to force every target to build NVMEM and QFPROM on our 
> > > >>> behalf.
> > > >>> But maybe
> > > >>> I'm just saying that because Kconfig dependencies tend to break my
> > > >>> brain (and
> > > >>> then Arnd has to send a patch to fix it).
> > > >>>
> > > >>
> > > >> Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
> > > >> other dependencies, so I suppose it wouldn't be the end of the 
> > > >> world
> > > >> to select that.. but I guess we don't want to require QFPROM
> > > >>
> > > >> I guess at the end of the day, what is the failure mode if you 
> > > >> have a
> > > >> speed-bin device, but your kernel config misses QFPROM (and 
> > > >> possibly
> > > >> NVMEM)?  If the result is just not having the highest clk rate(s)
> > > 
> > >  Atleast on sc7180's gpu, using an unsupported FMAX breaks gmu. It 
> > >  won't
> > >  be very obvious what went wrong when this happens!
> > > >>>
> > > >>> Ugg, ok..
> > > >>>
> > > >>> I suppose we could select NVMEM, but not QFPROM, and then the case
> > > >>> where QFPROM is not enabled on platforms that have the speed-bin field
> > > >>> in DT will fail gracefully and all other platforms would continue on
> > > >>> happily?
> > > >>>
> > > >>> BR,
> > > >>> -R
> > > >>
> > > >> Sounds good to me.
> > > >>
> > > >
> > > > You probably should 

Re: [Freedreno] [v1] drm/msm/disp/dpu1: fix warn stack reported during dpu resume

2021-04-01 Thread Dmitry Baryshkov
On Thu, 1 Apr 2021 at 16:19,  wrote:
>
> On 2021-04-01 07:37, Dmitry Baryshkov wrote:
> > On 01/04/2021 01:47, Rob Clark wrote:
> >> On Wed, Mar 31, 2021 at 9:03 AM Dmitry Baryshkov
> >>  wrote:
> >>>
> >>> On 31/03/2021 14:27, Kalyan Thota wrote:
> >>>> WARN_ON was introduced by the below commit to catch runtime resumes
> >>>> that are getting triggered before icc path was set.
> >>>>
> >>>> "drm/msm/disp/dpu1: icc path needs to be set before dpu runtime
> >>>> resume"
> >>>>
> >>>> For the targets where the bw scaling is not enabled, this WARN_ON is
> >>>> a false alarm. Fix the WARN condition appropriately.
> >>>
> >>> Should we change all DPU targets to use bw scaling to the mdp from
> >>> the
> >>> mdss nodes? The limitation to sc7180 looks artificial.
> >>
> >> yes, we should, this keeps biting us on 845
> >
> > Done,
> > https://lore.kernel.org/linux-arm-msm/20210401020533.3956787-2-dmitry.barysh...@linaro.org/
>
> Hi Dmitry,
>
> https://lore.kernel.org/linux-arm-msm/20210401020533.3956787-2-dmitry.barysh...@linaro.org/
>
> you need to add clk_inefficiency_factor, bw_inefficiency_factor in the
> catalogue for the new
> targets where bw scaling is being enabled. please reuse sc7180 values.

Done in patch 1 in that series.

>
> secondly, the AXI clock needs to be moved from mdss to mdp device like
> as in sc7180 dt if its not done already.

Is this enough:
sm8250 has < GCC_DISP_HF_AXI_CLK> both in mdss and mdp nodes
sdm845 has < GCC_DISP_AXI_CLK> in mdss node and <
DISP_CC_MDSS_AXI_CLK> in the mdp node.


>
> lastly, if you are planning to remove the static votes from dpu_mdss, do
> you also want to move the
> interconnect paths from mdss device to mdp device in the dt ?

I have no strong opinion on this. So far I did not change dt to be
compatible with the current device trees.

>
>
> Thanks,
> Kalyan
>
> >
> >>
> >>>>
> >>>> Reported-by: Steev Klimaszewski 
> >>
> >> Please add Fixes: tag as well
> Adding Fixes tag above my sign-off, should i push another version or can
> it be picked from here ?
>
> Fixes: Id252b9c2887 ("drm/msm/disp/dpu1: icc path needs to be set before
> dpu runtime resume")
> >>
> >>>> Signed-off-by: Kalyan Thota 
> >>>> ---
> >>>>drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  |  8 +---
> >>>>drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h  |  9 +
> >>>>drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c | 11 ++-
> >>>>3 files changed, 20 insertions(+), 8 deletions(-)
> >>>>
> >>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> >>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> >>>> index cab387f..0071a4d 100644
> >>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> >>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> >>>> @@ -294,6 +294,9 @@ static int
> >>>> dpu_kms_parse_data_bus_icc_path(struct dpu_kms *dpu_kms)
> >>>>struct icc_path *path1;
> >>>>struct drm_device *dev = dpu_kms->dev;
> >>>>
> >>>> + if (!dpu_supports_bw_scaling(dev))
> >>>> + return 0;
> >>>> +
> >>>>path0 = of_icc_get(dev->dev, "mdp0-mem");
> >>>>path1 = of_icc_get(dev->dev, "mdp1-mem");
> >>>>
> >>>> @@ -934,8 +937,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
> >>>>DPU_DEBUG("REG_DMA is not defined");
> >>>>}
> >>>>
> >>>> - if (of_device_is_compatible(dev->dev->of_node,
> >>>> "qcom,sc7180-mdss"))
> >>>> - dpu_kms_parse_data_bus_icc_path(dpu_kms);
> >>>> + dpu_kms_parse_data_bus_icc_path(dpu_kms);
> >>>>
> >>>>pm_runtime_get_sync(_kms->pdev->dev);
> >>>>
> >>>> @@ -1198,7 +1200,7 @@ static int __maybe_unused
> >>>> dpu_runtime_resume(struct device *dev)
> >>>>
> >>>>ddev = dpu_kms->dev;
> >>>>
> >>>> - WARN_ON(!(dpu_kms->num_paths));
> >>>> + WARN_ON((dpu_supports_bw_scaling(ddev) &&
> >>>> !dpu_kms->num_paths));
> >>>>

Re: [v1] drm/msm/disp/dpu1: fix warn stack reported during dpu resume

2021-03-31 Thread Dmitry Baryshkov

On 01/04/2021 01:47, Rob Clark wrote:

On Wed, Mar 31, 2021 at 9:03 AM Dmitry Baryshkov
 wrote:


On 31/03/2021 14:27, Kalyan Thota wrote:

WARN_ON was introduced by the below commit to catch runtime resumes
that are getting triggered before icc path was set.

"drm/msm/disp/dpu1: icc path needs to be set before dpu runtime resume"

For the targets where the bw scaling is not enabled, this WARN_ON is
a false alarm. Fix the WARN condition appropriately.


Should we change all DPU targets to use bw scaling to the mdp from the
mdss nodes? The limitation to sc7180 looks artificial.


yes, we should, this keeps biting us on 845


Done, 
https://lore.kernel.org/linux-arm-msm/20210401020533.3956787-2-dmitry.barysh...@linaro.org/






Reported-by: Steev Klimaszewski 


Please add Fixes: tag as well


Signed-off-by: Kalyan Thota 
---
   drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  |  8 +---
   drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h  |  9 +
   drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c | 11 ++-
   3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index cab387f..0071a4d 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -294,6 +294,9 @@ static int dpu_kms_parse_data_bus_icc_path(struct dpu_kms 
*dpu_kms)
   struct icc_path *path1;
   struct drm_device *dev = dpu_kms->dev;

+ if (!dpu_supports_bw_scaling(dev))
+ return 0;
+
   path0 = of_icc_get(dev->dev, "mdp0-mem");
   path1 = of_icc_get(dev->dev, "mdp1-mem");

@@ -934,8 +937,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
   DPU_DEBUG("REG_DMA is not defined");
   }

- if (of_device_is_compatible(dev->dev->of_node, "qcom,sc7180-mdss"))
- dpu_kms_parse_data_bus_icc_path(dpu_kms);
+ dpu_kms_parse_data_bus_icc_path(dpu_kms);

   pm_runtime_get_sync(_kms->pdev->dev);

@@ -1198,7 +1200,7 @@ static int __maybe_unused dpu_runtime_resume(struct 
device *dev)

   ddev = dpu_kms->dev;

- WARN_ON(!(dpu_kms->num_paths));
+ WARN_ON((dpu_supports_bw_scaling(ddev) && !dpu_kms->num_paths));
   /* Min vote of BW is required before turning on AXI clk */
   for (i = 0; i < dpu_kms->num_paths; i++)
   icc_set_bw(dpu_kms->path[i], 0, Bps_to_icc(MIN_IB_BW));
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
index d6717d6..f7bcc0a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
@@ -154,6 +154,15 @@ struct vsync_info {

   #define to_dpu_global_state(x) container_of(x, struct dpu_global_state, base)

+/**
+ * dpu_supports_bw_scaling: returns true for drivers that support bw scaling.
+ * @dev: Pointer to drm_device structure
+ */
+static inline int dpu_supports_bw_scaling(struct drm_device *dev)
+{
+ return of_device_is_compatible(dev->dev->of_node, "qcom,sc7180-mdss");
+}
+
   /* Global private object state for tracking resources that are shared across
* multiple kms objects (planes/crtcs/etc).
*/
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
index cd40788..8cd712c 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
@@ -41,6 +41,9 @@ static int dpu_mdss_parse_data_bus_icc_path(struct drm_device 
*dev,
   struct icc_path *path0 = of_icc_get(dev->dev, "mdp0-mem");
   struct icc_path *path1 = of_icc_get(dev->dev, "mdp1-mem");

+ if (dpu_supports_bw_scaling(dev))
+ return 0;
+
   if (IS_ERR_OR_NULL(path0))
   return PTR_ERR_OR_ZERO(path0);

@@ -276,11 +279,9 @@ int dpu_mdss_init(struct drm_device *dev)

   DRM_DEBUG("mapped mdss address space @%pK\n", dpu_mdss->mmio);

- if (!of_device_is_compatible(dev->dev->of_node, "qcom,sc7180-mdss")) {
- ret = dpu_mdss_parse_data_bus_icc_path(dev, dpu_mdss);
- if (ret)
- return ret;
- }
+ ret = dpu_mdss_parse_data_bus_icc_path(dev, dpu_mdss);
+ if (ret)
+ return ret;

   mp = _mdss->mp;
   ret = msm_dss_parse_clock(pdev, mp);




--
With best wishes
Dmitry



--
With best wishes
Dmitry


Re: [v1] drm/msm/disp/dpu1: fix warn stack reported during dpu resume

2021-03-31 Thread Dmitry Baryshkov

On 31/03/2021 14:27, Kalyan Thota wrote:

WARN_ON was introduced by the below commit to catch runtime resumes
that are getting triggered before icc path was set.

"drm/msm/disp/dpu1: icc path needs to be set before dpu runtime resume"

For the targets where the bw scaling is not enabled, this WARN_ON is
a false alarm. Fix the WARN condition appropriately.


Should we change all DPU targets to use bw scaling to the mdp from the 
mdss nodes? The limitation to sc7180 looks artificial.




Reported-by: Steev Klimaszewski 
Signed-off-by: Kalyan Thota 
---
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  |  8 +---
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h  |  9 +
  drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c | 11 ++-
  3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index cab387f..0071a4d 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -294,6 +294,9 @@ static int dpu_kms_parse_data_bus_icc_path(struct dpu_kms 
*dpu_kms)
struct icc_path *path1;
struct drm_device *dev = dpu_kms->dev;
  
+	if (!dpu_supports_bw_scaling(dev))

+   return 0;
+
path0 = of_icc_get(dev->dev, "mdp0-mem");
path1 = of_icc_get(dev->dev, "mdp1-mem");
  
@@ -934,8 +937,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)

DPU_DEBUG("REG_DMA is not defined");
}
  
-	if (of_device_is_compatible(dev->dev->of_node, "qcom,sc7180-mdss"))

-   dpu_kms_parse_data_bus_icc_path(dpu_kms);
+   dpu_kms_parse_data_bus_icc_path(dpu_kms);
  
  	pm_runtime_get_sync(_kms->pdev->dev);
  
@@ -1198,7 +1200,7 @@ static int __maybe_unused dpu_runtime_resume(struct device *dev)
  
  	ddev = dpu_kms->dev;
  
-	WARN_ON(!(dpu_kms->num_paths));

+   WARN_ON((dpu_supports_bw_scaling(ddev) && !dpu_kms->num_paths));
/* Min vote of BW is required before turning on AXI clk */
for (i = 0; i < dpu_kms->num_paths; i++)
icc_set_bw(dpu_kms->path[i], 0, Bps_to_icc(MIN_IB_BW));
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
index d6717d6..f7bcc0a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
@@ -154,6 +154,15 @@ struct vsync_info {
  
  #define to_dpu_global_state(x) container_of(x, struct dpu_global_state, base)
  
+/**

+ * dpu_supports_bw_scaling: returns true for drivers that support bw scaling.
+ * @dev: Pointer to drm_device structure
+ */
+static inline int dpu_supports_bw_scaling(struct drm_device *dev)
+{
+   return of_device_is_compatible(dev->dev->of_node, "qcom,sc7180-mdss");
+}
+
  /* Global private object state for tracking resources that are shared across
   * multiple kms objects (planes/crtcs/etc).
   */
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
index cd40788..8cd712c 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_mdss.c
@@ -41,6 +41,9 @@ static int dpu_mdss_parse_data_bus_icc_path(struct drm_device 
*dev,
struct icc_path *path0 = of_icc_get(dev->dev, "mdp0-mem");
struct icc_path *path1 = of_icc_get(dev->dev, "mdp1-mem");
  
+	if (dpu_supports_bw_scaling(dev))

+   return 0;
+
if (IS_ERR_OR_NULL(path0))
return PTR_ERR_OR_ZERO(path0);
  
@@ -276,11 +279,9 @@ int dpu_mdss_init(struct drm_device *dev)
  
  	DRM_DEBUG("mapped mdss address space @%pK\n", dpu_mdss->mmio);
  
-	if (!of_device_is_compatible(dev->dev->of_node, "qcom,sc7180-mdss")) {

-   ret = dpu_mdss_parse_data_bus_icc_path(dev, dpu_mdss);
-   if (ret)
-   return ret;
-   }
+   ret = dpu_mdss_parse_data_bus_icc_path(dev, dpu_mdss);
+   if (ret)
+   return ret;
  
  	mp = _mdss->mp;

ret = msm_dss_parse_clock(pdev, mp);




--
With best wishes
Dmitry


[PATCH v6 5/7] phy: qcom-qmp: add support for sm8250-usb3-dp phy

2021-03-31 Thread Dmitry Baryshkov
Add support for QMP V4 Combo USB3+DP PHY (for SM8250 platform).

Signed-off-by: Dmitry Baryshkov 
Acked-by: Bjorn Andersson 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 394 ++--
 drivers/phy/qualcomm/phy-qcom-qmp.h |  40 ++-
 2 files changed, 412 insertions(+), 22 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index e1dbc9d936e7..7877f70cf86f 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -1840,6 +1840,86 @@ static const struct qmp_phy_init_tbl 
sm8250_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_rbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x6f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x08),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0e),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr2[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x8c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x1f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr3[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x2f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x2a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_tx_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_VMODE_CTRL1, 0x40),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_INTERFACE_SELECT, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_CLKBUF_ENABLE, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RESET_TSYNC_EN, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_INTERFACE_MODE, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_BAND, 0x4),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_POL_INV, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_DRV_LVL

[PATCH v6 6/7] arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode

2021-03-31 Thread Dmitry Baryshkov
USB1 QMP PHY is not just a USB3 PHY, but USB3+DP PHY. Change device tree
nodes accordingly.

Signed-off-by: Dmitry Baryshkov 
Reviewed-by: Bjorn Andersson 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 947e1accae3a..0f79e6885004 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2097,12 +2097,11 @@ usb_2_hsphy: phy@88e4000 {
};
 
usb_1_qmpphy: phy@88e9000 {
-   compatible = "qcom,sm8250-qmp-usb3-phy";
+   compatible = "qcom,sm8250-qmp-usb3-dp-phy";
reg = <0 0x088e9000 0 0x200>,
- <0 0x088e8000 0 0x20>;
-   reg-names = "reg-base", "dp_com";
+ <0 0x088e8000 0 0x40>,
+ <0 0x088ea000 0 0x200>;
status = "disabled";
-   #clock-cells = <1>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
@@ -2116,7 +2115,7 @@ usb_1_qmpphy: phy@88e9000 {
 < GCC_USB3_PHY_PRIM_BCR>;
reset-names = "phy", "common";
 
-   usb_1_ssphy: lanes@88e9200 {
+   usb_1_ssphy: usb3-phy@88e9200 {
reg = <0 0x088e9200 0 0x200>,
  <0 0x088e9400 0 0x200>,
  <0 0x088e9c00 0 0x400>,
@@ -2128,6 +2127,20 @@ usb_1_ssphy: lanes@88e9200 {
clock-names = "pipe0";
clock-output-names = "usb3_phy_pipe_clk_src";
};
+
+   dp_phy: dp-phy@88ea200 {
+   reg = <0 0x088ea200 0 0x200>,
+ <0 0x088ea400 0 0x200>,
+ <0 0x088eac00 0 0x400>,
+ <0 0x088ea600 0 0x200>,
+ <0 0x088ea800 0 0x200>,
+ <0 0x088eaa00 0 0x100>;
+   #phy-cells = <0>;
+   #clock-cells = <1>;
+   clocks = < GCC_USB3_PRIM_PHY_PIPE_CLK>;
+   clock-names = "pipe0";
+   clock-output-names = "usb3_phy_pipe_clk_src";
+   };
};
 
usb_2_qmpphy: phy@88eb000 {
-- 
2.30.2



[PATCH v6 4/7] phy: qcom-qmp: rename common registers

2021-03-31 Thread Dmitry Baryshkov
A plenty of DP PHY registers are common between V3 and V4. To simplify
V4 code, rename all common registers.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 50 ++---
 drivers/phy/qualcomm/phy-qcom-qmp.h | 37 ++---
 2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 854f6ff7faef..e1dbc9d936e7 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -3354,20 +3354,20 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
 {
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
/* Turn on BIAS current for PHY/PLL */
writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
   QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_LANE_0_1_PWRDN |
   DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
   DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(QSERDES_V3_COM_BIAS_EN |
   QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
@@ -3375,16 +3375,16 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
   QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
-   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
-   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
-   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
-   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG9);
qphy->dp_aux_cfg = 0;
 
writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
@@ -3494,9 +3494,9 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
 *  writel(0x4c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
 */
val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
-   writel(val, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(val, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
-   writel(0x5c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
+   writel(0x5c, qphy->pcs + QSERDES_DP_PHY_MODE);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL);
 
@@ -3526,11 +3526,11 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
clk_set_rate(dp_clks->dp_link_hw.clk, dp_opts->link_rate * 10);
clk_set_rate(dp_clks->dp_pixel_hw.clk, pixel_freq);
 
-   writel(0x04, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x09, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
+   writel(0x04, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x05, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x09, qphy->pcs + QSERDES_DP_PHY_CFG);
 
writel(0x20, qphy->serdes + QSERDES_V3_COM_RESETSM_CNTRL);
 
@@ -3541,7 +3541,7 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
1))
return -ETIMED

[PATCH v6 2/7] dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250

2021-03-31 Thread Dmitry Baryshkov
Add compatible for SM8250 in QMP USB3 DP PHY bindings.

Signed-off-by: Dmitry Baryshkov 
Acked-by: Rob Herring 
Reviewed-by: Bjorn Andersson 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 62c0179d1765..217aa6c91893 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -15,6 +15,7 @@ properties:
 enum:
   - qcom,sc7180-qmp-usb3-dp-phy
   - qcom,sdm845-qmp-usb3-dp-phy
+  - qcom,sm8250-qmp-usb3-dp-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



[PATCH v6 7/7] arm64: dts: qcom: use dp_phy to provide clocks to dispcc

2021-03-31 Thread Dmitry Baryshkov
Plug dp_phy-provided clocks to display clock controller.

Signed-off-by: Dmitry Baryshkov 
Reviewed-by: Bjorn Andersson 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 0f79e6885004..a2478bd3590a 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2600,8 +2600,8 @@ dispcc: clock-controller@af0 {
 <_phy 1>,
 <_phy 0>,
 <_phy 1>,
-<0>,
-<0>,
+<_phy 0>,
+<_phy 1>,
 <0>,
 <0>,
 <0>,
@@ -2614,8 +2614,8 @@ dispcc: clock-controller@af0 {
  "dsi0_phy_pll_out_dsiclk",
  "dsi1_phy_pll_out_byteclk",
  "dsi1_phy_pll_out_dsiclk",
- "dp_link_clk_divsel_ten",
- "dp_vco_divided_clk_src_mux",
+ "dp_phy_pll_link_clk",
+ "dp_phy_pll_vco_div_clk",
  "dptx1_phy_pll_link_clk",
  "dptx1_phy_pll_vco_div_clk",
  "dptx2_phy_pll_link_clk",
-- 
2.30.2



[PATCH v6 1/7] dt-bindings: phy: qcom,qmp-usb3-dp-phy: move usb3 compatibles back to qcom,qmp-phy.yaml

2021-03-31 Thread Dmitry Baryshkov
The commit 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy
information") has support for DP part of USB3+DP combo PHYs. However
this change is not backwards compatible, placing additional requirements
onto qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy device nodes
(to include separate DP part, etc). However the aforementioned nodes do
not inclue DP part, they strictly follow the schema defined in the
qcom,qmp-phy.yaml file. Move those compatibles, leaving
qcom,qmp-usb3-dp-phy.yaml to describe only real "combo" USB3+DP device nodes.

Fixes: 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy 
information")
Cc: Stephen Boyd 
Cc: Sandeep Maheswaram 
Signed-off-by: Dmitry Baryshkov 
Acked-by: Rob Herring 
Reviewed-by: Stephen Boyd 
Reviewed-by: Bjorn Andersson 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 2 ++
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
index 626447fee092..7808ec8bc712 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
@@ -25,11 +25,13 @@ properties:
   - qcom,msm8998-qmp-pcie-phy
   - qcom,msm8998-qmp-ufs-phy
   - qcom,msm8998-qmp-usb3-phy
+  - qcom,sc7180-qmp-usb3-phy
   - qcom,sc8180x-qmp-ufs-phy
   - qcom,sc8180x-qmp-usb3-phy
   - qcom,sdm845-qhp-pcie-phy
   - qcom,sdm845-qmp-pcie-phy
   - qcom,sdm845-qmp-ufs-phy
+  - qcom,sdm845-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-uni-phy
   - qcom,sm8150-qmp-ufs-phy
   - qcom,sm8150-qmp-usb3-phy
diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 33974ad10afe..62c0179d1765 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -14,9 +14,7 @@ properties:
   compatible:
 enum:
   - qcom,sc7180-qmp-usb3-dp-phy
-  - qcom,sc7180-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-dp-phy
-  - qcom,sdm845-qmp-usb3-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



[PATCH v6 0/7] phy: qcom-qmp: provide DP phy support for sm8250

2021-03-31 Thread Dmitry Baryshkov
Changes since v5:
 - Rebase on top of phy-next
 - Rework 'move DP functions to callbacks' patch to leave most of the
   code in place, using function prototypes.

Changes since v4:
 - Fix typo in the qcom,sc7180-qmp-usb3-phy name in the first patch

Changes since v3:
 - Move qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy from
   qcom,qmp-usb3-dp.yaml to qcom,qmp-phy.yaml
 - Do not touch qcom,sm8250-qmp-usb3-phy compatible

Changes since v2:
 - Drop unused qmp_v4_usb3_rx_tbl

Changes since v1:
 - Provide dt bindings
 - Split register renaming from sm8250-dp-phy patch
 - Add respective changes to sm8250 device tree





[PATCH v6 3/7] phy: qcom-qmp: move DP functions to callbacks

2021-03-31 Thread Dmitry Baryshkov
In preparation to adding support for V4 DP PHY move DP functions to
callbacks at struct qmp_phy_cfg.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 73 -
 1 file changed, 51 insertions(+), 22 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 1c79a713780d..854f6ff7faef 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2268,6 +2268,8 @@ static const struct qmp_phy_init_tbl 
sm8350_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+struct qmp_phy;
+
 /* struct qmp_phy_cfg - per-PHY initialization config */
 struct qmp_phy_cfg {
/* phy-type - PCIE/UFS/USB */
@@ -2307,6 +2309,12 @@ struct qmp_phy_cfg {
const struct qmp_phy_init_tbl *serdes_tbl_hbr3;
int serdes_tbl_hbr3_num;
 
+   /* DP PHY callbacks */
+   int (*configure_dp_phy)(struct qmp_phy *qphy);
+   void (*configure_dp_tx)(struct qmp_phy *qphy);
+   int (*calibrate_dp_phy)(struct qmp_phy *qphy);
+   void (*dp_aux_init)(struct qmp_phy *qphy);
+
/* clock ids to be requested */
const char * const *clk_list;
int num_clks;
@@ -2423,6 +2431,11 @@ struct qcom_qmp {
struct reset_control *ufs_reset;
 };
 
+static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy *qphy);
+static void qcom_qmp_v3_phy_configure_dp_tx(struct qmp_phy *qphy);
+static int qcom_qmp_v3_phy_configure_dp_phy(struct qmp_phy *qphy);
+static int qcom_qmp_v3_dp_phy_calibrate(struct qmp_phy *qphy);
+
 static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
 {
u32 reg;
@@ -2871,6 +2884,11 @@ static const struct qmp_phy_cfg sc7180_dpphy_cfg = {
 
.has_phy_dp_com_ctrl= true,
.is_dual_lane_phy   = true,
+
+   .dp_aux_init = qcom_qmp_v3_phy_dp_aux_init,
+   .configure_dp_tx = qcom_qmp_v3_phy_configure_dp_tx,
+   .configure_dp_phy = qcom_qmp_v3_phy_configure_dp_phy,
+   .calibrate_dp_phy = qcom_qmp_v3_dp_phy_calibrate,
 };
 
 static const struct qmp_phy_combo_cfg sc7180_usb3dpphy_cfg = {
@@ -3332,7 +3350,7 @@ static int qcom_qmp_phy_serdes_init(struct qmp_phy *qphy)
return 0;
 }
 
-static void qcom_qmp_phy_dp_aux_init(struct qmp_phy *qphy)
+static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy *qphy)
 {
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
@@ -3403,7 +3421,7 @@ static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = {
{ 0x1f, 0xff, 0xff, 0xff }
 };
 
-static void qcom_qmp_phy_configure_dp_tx(struct qmp_phy *qphy)
+static void qcom_qmp_v3_phy_configure_dp_tx(struct qmp_phy *qphy)
 {
const struct phy_configure_opts_dp *dp_opts = >dp_opts;
unsigned int v_level = 0, p_level = 0;
@@ -3451,21 +3469,7 @@ static void qcom_qmp_phy_configure_dp_tx(struct qmp_phy 
*qphy)
writel(bias_en, qphy->tx2 + QSERDES_V3_TX_TRANSCEIVER_BIAS_EN);
 }
 
-static int qcom_qmp_dp_phy_configure(struct phy *phy, union phy_configure_opts 
*opts)
-{
-   const struct phy_configure_opts_dp *dp_opts = >dp;
-   struct qmp_phy *qphy = phy_get_drvdata(phy);
-
-   memcpy(>dp_opts, dp_opts, sizeof(*dp_opts));
-   if (qphy->dp_opts.set_voltages) {
-   qcom_qmp_phy_configure_dp_tx(qphy);
-   qphy->dp_opts.set_voltages = 0;
-   }
-
-   return 0;
-}
-
-static int qcom_qmp_phy_configure_dp_phy(struct qmp_phy *qphy)
+static int qcom_qmp_v3_phy_configure_dp_phy(struct qmp_phy *qphy)
 {
const struct qmp_phy_dp_clks *dp_clks = qphy->dp_clks;
const struct phy_configure_opts_dp *dp_opts = >dp_opts;
@@ -3561,9 +3565,8 @@ static int qcom_qmp_phy_configure_dp_phy(struct qmp_phy 
*qphy)
  * We need to calibrate the aux setting here as many times
  * as the caller tries
  */
-static int qcom_qmp_dp_phy_calibrate(struct phy *phy)
+static int qcom_qmp_v3_dp_phy_calibrate(struct qmp_phy *qphy)
 {
-   struct qmp_phy *qphy = phy_get_drvdata(phy);
static const u8 cfg1_settings[] = { 0x13, 0x23, 0x1d };
u8 val;
 
@@ -3576,6 +3579,32 @@ static int qcom_qmp_dp_phy_calibrate(struct phy *phy)
return 0;
 }
 
+static int qcom_qmp_dp_phy_configure(struct phy *phy, union phy_configure_opts 
*opts)
+{
+   const struct phy_configure_opts_dp *dp_opts = >dp;
+   struct qmp_phy *qphy = phy_get_drvdata(phy);
+   const struct qmp_phy_cfg *cfg = qphy->cfg;
+
+   memcpy(>dp_opts, dp_opts, sizeof(*dp_opts));
+   if (qphy->dp_opts.set_voltages) {
+   cfg->configure_dp_tx(qphy);
+   qphy->dp_opts.set_voltages = 0;
+   }
+
+   return 0;
+}
+
+static int qcom_qmp_dp_phy_calibrate(struct phy *phy)
+{
+   struct qmp_phy *qphy = phy_get_drvdata(phy);
+   const struct qmp_phy_cfg *cfg = qphy->cfg;
+
+   if (cfg-

[PATCH v6 1/7] dt-bindings: phy: qcom,qmp-usb3-dp-phy: move usb3 compatibles back to qcom,qmp-phy.yaml

2021-03-31 Thread Dmitry Baryshkov
The commit 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy
information") has support for DP part of USB3+DP combo PHYs. However
this change is not backwards compatible, placing additional requirements
onto qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy device nodes
(to include separate DP part, etc). However the aforementioned nodes do
not inclue DP part, they strictly follow the schema defined in the
qcom,qmp-phy.yaml file. Move those compatibles, leaving
qcom,qmp-usb3-dp-phy.yaml to describe only real "combo" USB3+DP device nodes.

Fixes: 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy 
information")
Cc: Stephen Boyd 
Cc: Sandeep Maheswaram 
Signed-off-by: Dmitry Baryshkov 
Acked-by: Rob Herring 
Reviewed-by: Stephen Boyd 
Reviewed-by: Bjorn Andersson 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 2 ++
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
index 626447fee092..7808ec8bc712 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
@@ -25,11 +25,13 @@ properties:
   - qcom,msm8998-qmp-pcie-phy
   - qcom,msm8998-qmp-ufs-phy
   - qcom,msm8998-qmp-usb3-phy
+  - qcom,sc7180-qmp-usb3-phy
   - qcom,sc8180x-qmp-ufs-phy
   - qcom,sc8180x-qmp-usb3-phy
   - qcom,sdm845-qhp-pcie-phy
   - qcom,sdm845-qmp-pcie-phy
   - qcom,sdm845-qmp-ufs-phy
+  - qcom,sdm845-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-uni-phy
   - qcom,sm8150-qmp-ufs-phy
   - qcom,sm8150-qmp-usb3-phy
diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 33974ad10afe..62c0179d1765 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -14,9 +14,7 @@ properties:
   compatible:
 enum:
   - qcom,sc7180-qmp-usb3-dp-phy
-  - qcom,sc7180-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-dp-phy
-  - qcom,sdm845-qmp-usb3-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



Re: [PATCH v2] drm/msm: a6xx: Make sure the SQE microcode is safe

2021-03-31 Thread Dmitry Baryshkov

Hello,

On 10/02/2021 03:52, Jordan Crouse wrote:

Most a6xx targets have security issues that were fixed with new versions
of the microcode(s). Make sure that we are booting with a safe version of
the microcode for the target and print a message and error if not.

v2: Add more informative error messages and fix typos

Signed-off-by: Jordan Crouse 


[skipped]


+   }  else {
+   /*
+* a650 tier targets don't need whereami but still need to be
+* equal to or newer than 1.95 for other security fixes
+*/
+   if (adreno_is_a650(adreno_gpu)) {
+   if ((buf[0] & 0xfff) >= 0x195) {
+   ret = true;
+   goto out;
+   }


I think this is incorrect. The latest firmware i have here also fails 
this check, with the buf[0] = 0x016dd099, so buf[0] & 0xfff = 0x099.


Could you please confirm the versioning?


+
+   DRM_DEV_ERROR(>pdev->dev,
+   "a650 SQE ucode is too old. Have version %x need at 
least %x\n",
+   buf[0] & 0xfff, 0x195);
+   }
+
+   /*
+* When a660 is added those targets should return true here
+* since those have all the critical security fixes built in
+* from the start
+*/
+   }
+out:
msm_gem_put_vaddr(obj);
+   return ret;
  }
  
  static int a6xx_ucode_init(struct msm_gpu *gpu)

@@ -566,7 +611,13 @@ static int a6xx_ucode_init(struct msm_gpu *gpu)
}
  
  		msm_gem_object_set_name(a6xx_gpu->sqe_bo, "sqefw");

-   a6xx_ucode_check_version(a6xx_gpu, a6xx_gpu->sqe_bo);
+   if (!a6xx_ucode_check_version(a6xx_gpu, a6xx_gpu->sqe_bo)) {
+   msm_gem_unpin_iova(a6xx_gpu->sqe_bo, gpu->aspace);
+   drm_gem_object_put(a6xx_gpu->sqe_bo);
+
+   a6xx_gpu->sqe_bo = NULL;
+   return -EPERM;
+   }
}
  
  	gpu_write64(gpu, REG_A6XX_CP_SQE_INSTR_BASE_LO,



--
With best wishes
Dmitry


[PATCH v5 6/7] arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode

2021-03-28 Thread Dmitry Baryshkov
USB1 QMP PHY is not just a USB3 PHY, but USB3+DP PHY. Change device tree
nodes accordingly.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 947e1accae3a..0f79e6885004 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2097,12 +2097,11 @@ usb_2_hsphy: phy@88e4000 {
};
 
usb_1_qmpphy: phy@88e9000 {
-   compatible = "qcom,sm8250-qmp-usb3-phy";
+   compatible = "qcom,sm8250-qmp-usb3-dp-phy";
reg = <0 0x088e9000 0 0x200>,
- <0 0x088e8000 0 0x20>;
-   reg-names = "reg-base", "dp_com";
+ <0 0x088e8000 0 0x40>,
+ <0 0x088ea000 0 0x200>;
status = "disabled";
-   #clock-cells = <1>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
@@ -2116,7 +2115,7 @@ usb_1_qmpphy: phy@88e9000 {
 < GCC_USB3_PHY_PRIM_BCR>;
reset-names = "phy", "common";
 
-   usb_1_ssphy: lanes@88e9200 {
+   usb_1_ssphy: usb3-phy@88e9200 {
reg = <0 0x088e9200 0 0x200>,
  <0 0x088e9400 0 0x200>,
  <0 0x088e9c00 0 0x400>,
@@ -2128,6 +2127,20 @@ usb_1_ssphy: lanes@88e9200 {
clock-names = "pipe0";
clock-output-names = "usb3_phy_pipe_clk_src";
};
+
+   dp_phy: dp-phy@88ea200 {
+   reg = <0 0x088ea200 0 0x200>,
+ <0 0x088ea400 0 0x200>,
+ <0 0x088eac00 0 0x400>,
+ <0 0x088ea600 0 0x200>,
+ <0 0x088ea800 0 0x200>,
+ <0 0x088eaa00 0 0x100>;
+   #phy-cells = <0>;
+   #clock-cells = <1>;
+   clocks = < GCC_USB3_PRIM_PHY_PIPE_CLK>;
+   clock-names = "pipe0";
+   clock-output-names = "usb3_phy_pipe_clk_src";
+   };
};
 
usb_2_qmpphy: phy@88eb000 {
-- 
2.30.2



[PATCH v5 5/7] phy: qcom-qmp: add support for sm8250-usb3-dp phy

2021-03-28 Thread Dmitry Baryshkov
Add support for QMP V4 Combo USB3+DP PHY (for SM8250 platform).

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 388 ++--
 drivers/phy/qualcomm/phy-qcom-qmp.h |  40 ++-
 2 files changed, 406 insertions(+), 22 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 097bc005ba43..a47da2fff7a1 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -1840,6 +1840,86 @@ static const struct qmp_phy_init_tbl 
sm8250_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_rbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x6f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x08),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0e),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr2[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x8c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x1f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr3[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x2f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x2a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_tx_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_VMODE_CTRL1, 0x40),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_INTERFACE_SELECT, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_CLKBUF_ENABLE, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RESET_TSYNC_EN, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_INTERFACE_MODE, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_BAND, 0x4),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_POL_INV, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_DRV_LVL, 0x2a

[PATCH v5 7/7] arm64: dts: qcom: use dp_phy to provide clocks to dispcc

2021-03-28 Thread Dmitry Baryshkov
Plug dp_phy-provided clocks to display clock controller.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 0f79e6885004..a2478bd3590a 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2600,8 +2600,8 @@ dispcc: clock-controller@af0 {
 <_phy 1>,
 <_phy 0>,
 <_phy 1>,
-<0>,
-<0>,
+<_phy 0>,
+<_phy 1>,
 <0>,
 <0>,
 <0>,
@@ -2614,8 +2614,8 @@ dispcc: clock-controller@af0 {
  "dsi0_phy_pll_out_dsiclk",
  "dsi1_phy_pll_out_byteclk",
  "dsi1_phy_pll_out_dsiclk",
- "dp_link_clk_divsel_ten",
- "dp_vco_divided_clk_src_mux",
+ "dp_phy_pll_link_clk",
+ "dp_phy_pll_vco_div_clk",
  "dptx1_phy_pll_link_clk",
  "dptx1_phy_pll_vco_div_clk",
  "dptx2_phy_pll_link_clk",
-- 
2.30.2



[PATCH v5 3/7] phy: qcom-qmp: move DP functions to callbacks

2021-03-28 Thread Dmitry Baryshkov
In preparation to adding support for V4 DP PHY move DP functions to
callbacks at struct qmp_phy_cfg.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 438 +++-
 1 file changed, 231 insertions(+), 207 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 9cdebe7f26cb..4150096fd350 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2268,6 +2268,8 @@ static const struct qmp_phy_init_tbl 
sm8350_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+struct qmp_phy;
+
 /* struct qmp_phy_cfg - per-PHY initialization config */
 struct qmp_phy_cfg {
/* phy-type - PCIE/UFS/USB */
@@ -2307,6 +2309,12 @@ struct qmp_phy_cfg {
const struct qmp_phy_init_tbl *serdes_tbl_hbr3;
int serdes_tbl_hbr3_num;
 
+   /* DP PHY callbacks */
+   int (*configure_dp_phy)(struct qmp_phy *qphy);
+   void (*configure_dp_tx)(struct qmp_phy *qphy);
+   int (*calibrate_dp_phy)(struct qmp_phy *qphy);
+   void (*dp_aux_init)(struct qmp_phy *qphy);
+
/* clock ids to be requested */
const char * const *clk_list;
int num_clks;
@@ -2423,6 +2431,216 @@ struct qcom_qmp {
struct reset_control *ufs_reset;
 };
 
+static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy *qphy)
+{
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   /* Turn on BIAS current for PHY/PLL */
+   writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_LANE_0_1_PWRDN |
+  DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
+  DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(QSERDES_V3_COM_BIAS_EN |
+  QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL |
+  QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   qphy->dp_aux_cfg = 0;
+
+   writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
+  PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
+  PHY_AUX_REQ_ERR_MASK,
+  qphy->pcs + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK);
+}
+
+static const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = {
+   { 0x00, 0x0c, 0x14, 0x19 },
+   { 0x00, 0x0b, 0x12, 0xff },
+   { 0x00, 0x0b, 0xff, 0xff },
+   { 0x04, 0xff, 0xff, 0xff }
+};
+
+static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = {
+   { 0x08, 0x0f, 0x16, 0x1f },
+   { 0x11, 0x1e, 0x1f, 0xff },
+   { 0x19, 0x1f, 0xff, 0xff },
+   { 0x1f, 0xff, 0xff, 0xff }
+};
+
+static void qcom_qmp_v3_phy_configure_dp_tx(struct qmp_phy *qphy)
+{
+   const struct phy_configure_opts_dp *dp_opts = >dp_opts;
+   unsigned int v_level = 0, p_level = 0;
+   u32 bias_en, drvr_en;
+   u8 voltage_swing_cfg, pre_emphasis_cfg;
+   int i;
+
+   for (i = 0; i < dp_opts->lanes; i++) {
+   v_level = max(v_level, dp_opts->voltage[i]);
+   p_level = max(p_level, dp_opts->pre[i]);
+   }
+
+   if (dp_opts->lanes == 1) {
+   bias_en = 0x3e;
+   drvr_en = 0x13;
+   } else {
+   bias_en = 0x3f;
+   drvr_en = 0x10;
+   }
+
+   voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level];
+   pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level];
+
+   /* TODO: Move check to config check */
+   if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF)
+   return;
+
+   /* Enable MUX to use Cursor values from these registers */
+   voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN;
+  

[PATCH v5 4/7] phy: qcom-qmp: rename common registers

2021-03-28 Thread Dmitry Baryshkov
A plenty of DP PHY registers are common between V3 and V4. To simplify
V4 code, rename all common registers.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 50 ++---
 drivers/phy/qualcomm/phy-qcom-qmp.h | 37 ++---
 2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 4150096fd350..097bc005ba43 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2435,20 +2435,20 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
 {
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
/* Turn on BIAS current for PHY/PLL */
writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
   QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_LANE_0_1_PWRDN |
   DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
   DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(QSERDES_V3_COM_BIAS_EN |
   QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
@@ -2456,16 +2456,16 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
   QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
-   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
-   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
-   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
-   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG9);
qphy->dp_aux_cfg = 0;
 
writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
@@ -2556,9 +2556,9 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
 *  writel(0x4c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
 */
val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
-   writel(val, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(val, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
-   writel(0x5c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
+   writel(0x5c, qphy->pcs + QSERDES_DP_PHY_MODE);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL);
 
@@ -2588,11 +2588,11 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
clk_set_rate(dp_clks->dp_link_hw.clk, dp_opts->link_rate * 10);
clk_set_rate(dp_clks->dp_pixel_hw.clk, pixel_freq);
 
-   writel(0x04, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x09, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
+   writel(0x04, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x05, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x09, qphy->pcs + QSERDES_DP_PHY_CFG);
 
writel(0x20, qphy->serdes + QSERDES_V3_COM_RESETSM_CNTRL);
 
@@ -2603,7 +2603,7 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
1))
return -ETIMED

[PATCH v5 1/7] dt-bindings: phy: qcom,qmp-usb3-dp-phy: move usb3 compatibles back to qcom,qmp-phy.yaml

2021-03-28 Thread Dmitry Baryshkov
The commit 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy
information") has support for DP part of USB3+DP combo PHYs. However
this change is not backwards compatible, placing additional requirements
onto qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy device nodes
(to include separate DP part, etc). However the aforementioned nodes do
not inclue DP part, they strictly follow the schema defined in the
qcom,qmp-phy.yaml file. Move those compatibles, leaving
qcom,qmp-usb3-dp-phy.yaml to describe only real "combo" USB3+DP device nodes.

Fixes: 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy 
information")
Cc: Stephen Boyd 
Cc: Sandeep Maheswaram 
Signed-off-by: Dmitry Baryshkov 
Acked-by: Rob Herring 
Reviewed-by: Stephen Boyd 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 2 ++
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
index 626447fee092..7808ec8bc712 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
@@ -25,11 +25,13 @@ properties:
   - qcom,msm8998-qmp-pcie-phy
   - qcom,msm8998-qmp-ufs-phy
   - qcom,msm8998-qmp-usb3-phy
+  - qcom,sc7180-qmp-usb3-phy
   - qcom,sc8180x-qmp-ufs-phy
   - qcom,sc8180x-qmp-usb3-phy
   - qcom,sdm845-qhp-pcie-phy
   - qcom,sdm845-qmp-pcie-phy
   - qcom,sdm845-qmp-ufs-phy
+  - qcom,sdm845-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-uni-phy
   - qcom,sm8150-qmp-ufs-phy
   - qcom,sm8150-qmp-usb3-phy
diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 33974ad10afe..62c0179d1765 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -14,9 +14,7 @@ properties:
   compatible:
 enum:
   - qcom,sc7180-qmp-usb3-dp-phy
-  - qcom,sc7180-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-dp-phy
-  - qcom,sdm845-qmp-usb3-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



[PATCH v5 2/7] dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250

2021-03-28 Thread Dmitry Baryshkov
Add compatible for SM8250 in QMP USB3 DP PHY bindings.

Signed-off-by: Dmitry Baryshkov 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 62c0179d1765..217aa6c91893 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -15,6 +15,7 @@ properties:
 enum:
   - qcom,sc7180-qmp-usb3-dp-phy
   - qcom,sdm845-qmp-usb3-dp-phy
+  - qcom,sm8250-qmp-usb3-dp-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



[PATCH v5 0/7] phy: qcom-qmp: provide DP phy support for sm8250

2021-03-28 Thread Dmitry Baryshkov
Changes since v4:
 - Fix typo in the qcom,sc7180-qmp-usb3-phy name in the first patch

Changes since v3:
 - Move qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy from
   qcom,qmp-usb3-dp.yaml to qcom,qmp-phy.yaml
 - Do not touch qcom,sm8250-qmp-usb3-phy compatible

Changes since v2:
 - Drop unused qmp_v4_usb3_rx_tbl

Changes since v1:
 - Provide dt bindings
 - Split register renaming from sm8250-dp-phy patch
 - Add respective changes to sm8250 device tree

The following changes since commit a38fd8748464831584a19438cbb3082b5a2dab15:

  Linux 5.12-rc2 (2021-03-05 17:33:41 -0800)

are available in the Git repository at:

  https://git.linaro.org/people/dmitry.baryshkov/kernel.git sm8250-dp-phy

for you to fetch changes up to aef044832f8f34495c35f8324ee55e2500dc3db5:

  arm64: dts: qcom: use dp_phy to provide clocks to dispcc (2021-03-28 23:43:31 
+0300)


Dmitry Baryshkov (7):
  dt-bindings: phy: qcom,qmp-usb3-dp-phy: move usb3 compatibles back to 
qcom,qmp-phy.yaml
  dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250
  phy: qcom-qmp: move DP functions to callbacks
  phy: qcom-qmp: rename common registers
  phy: qcom-qmp: add support for sm8250-usb3-dp phy
  arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode
  arm64: dts: qcom: use dp_phy to provide clocks to dispcc

 .../devicetree/bindings/phy/qcom,qmp-phy.yaml  |   2 +
 .../bindings/phy/qcom,qmp-usb3-dp-phy.yaml |   3 +-
 arch/arm64/boot/dts/qcom/sm8250.dtsi   |  31 +-
 drivers/phy/qualcomm/phy-qcom-qmp.c| 850 +++--
 drivers/phy/qualcomm/phy-qcom-qmp.h|  77 +-
 5 files changed, 693 insertions(+), 270 deletions(-)




[PATCH v4 5/7] phy: qcom-qmp: add support for sm8250-usb3-dp phy

2021-03-26 Thread Dmitry Baryshkov
Add support for QMP V4 Combo USB3+DP PHY (for SM8250 platform).

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 388 ++--
 drivers/phy/qualcomm/phy-qcom-qmp.h |  40 ++-
 2 files changed, 406 insertions(+), 22 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 097bc005ba43..a47da2fff7a1 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -1840,6 +1840,86 @@ static const struct qmp_phy_init_tbl 
sm8250_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_rbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x6f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x08),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0e),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr2[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x8c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x1f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr3[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x2f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x2a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_tx_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_VMODE_CTRL1, 0x40),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_INTERFACE_SELECT, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_CLKBUF_ENABLE, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RESET_TSYNC_EN, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_INTERFACE_MODE, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_BAND, 0x4),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_POL_INV, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_DRV_LVL, 0x2a

[PATCH v4 3/7] phy: qcom-qmp: move DP functions to callbacks

2021-03-26 Thread Dmitry Baryshkov
In preparation to adding support for V4 DP PHY move DP functions to
callbacks at struct qmp_phy_cfg.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 438 +++-
 1 file changed, 231 insertions(+), 207 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 9cdebe7f26cb..4150096fd350 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2268,6 +2268,8 @@ static const struct qmp_phy_init_tbl 
sm8350_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+struct qmp_phy;
+
 /* struct qmp_phy_cfg - per-PHY initialization config */
 struct qmp_phy_cfg {
/* phy-type - PCIE/UFS/USB */
@@ -2307,6 +2309,12 @@ struct qmp_phy_cfg {
const struct qmp_phy_init_tbl *serdes_tbl_hbr3;
int serdes_tbl_hbr3_num;
 
+   /* DP PHY callbacks */
+   int (*configure_dp_phy)(struct qmp_phy *qphy);
+   void (*configure_dp_tx)(struct qmp_phy *qphy);
+   int (*calibrate_dp_phy)(struct qmp_phy *qphy);
+   void (*dp_aux_init)(struct qmp_phy *qphy);
+
/* clock ids to be requested */
const char * const *clk_list;
int num_clks;
@@ -2423,6 +2431,216 @@ struct qcom_qmp {
struct reset_control *ufs_reset;
 };
 
+static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy *qphy)
+{
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   /* Turn on BIAS current for PHY/PLL */
+   writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_LANE_0_1_PWRDN |
+  DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
+  DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(QSERDES_V3_COM_BIAS_EN |
+  QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL |
+  QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   qphy->dp_aux_cfg = 0;
+
+   writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
+  PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
+  PHY_AUX_REQ_ERR_MASK,
+  qphy->pcs + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK);
+}
+
+static const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = {
+   { 0x00, 0x0c, 0x14, 0x19 },
+   { 0x00, 0x0b, 0x12, 0xff },
+   { 0x00, 0x0b, 0xff, 0xff },
+   { 0x04, 0xff, 0xff, 0xff }
+};
+
+static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = {
+   { 0x08, 0x0f, 0x16, 0x1f },
+   { 0x11, 0x1e, 0x1f, 0xff },
+   { 0x19, 0x1f, 0xff, 0xff },
+   { 0x1f, 0xff, 0xff, 0xff }
+};
+
+static void qcom_qmp_v3_phy_configure_dp_tx(struct qmp_phy *qphy)
+{
+   const struct phy_configure_opts_dp *dp_opts = >dp_opts;
+   unsigned int v_level = 0, p_level = 0;
+   u32 bias_en, drvr_en;
+   u8 voltage_swing_cfg, pre_emphasis_cfg;
+   int i;
+
+   for (i = 0; i < dp_opts->lanes; i++) {
+   v_level = max(v_level, dp_opts->voltage[i]);
+   p_level = max(p_level, dp_opts->pre[i]);
+   }
+
+   if (dp_opts->lanes == 1) {
+   bias_en = 0x3e;
+   drvr_en = 0x13;
+   } else {
+   bias_en = 0x3f;
+   drvr_en = 0x10;
+   }
+
+   voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level];
+   pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level];
+
+   /* TODO: Move check to config check */
+   if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF)
+   return;
+
+   /* Enable MUX to use Cursor values from these registers */
+   voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN;
+  

[PATCH v4 7/7] arm64: dts: qcom: use dp_phy to provide clocks to dispcc

2021-03-26 Thread Dmitry Baryshkov
Plug dp_phy-provided clocks to display clock controller.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 0f79e6885004..a2478bd3590a 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2600,8 +2600,8 @@ dispcc: clock-controller@af0 {
 <_phy 1>,
 <_phy 0>,
 <_phy 1>,
-<0>,
-<0>,
+<_phy 0>,
+<_phy 1>,
 <0>,
 <0>,
 <0>,
@@ -2614,8 +2614,8 @@ dispcc: clock-controller@af0 {
  "dsi0_phy_pll_out_dsiclk",
  "dsi1_phy_pll_out_byteclk",
  "dsi1_phy_pll_out_dsiclk",
- "dp_link_clk_divsel_ten",
- "dp_vco_divided_clk_src_mux",
+ "dp_phy_pll_link_clk",
+ "dp_phy_pll_vco_div_clk",
  "dptx1_phy_pll_link_clk",
  "dptx1_phy_pll_vco_div_clk",
  "dptx2_phy_pll_link_clk",
-- 
2.30.2



[PATCH v4 6/7] arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode

2021-03-26 Thread Dmitry Baryshkov
USB1 QMP PHY is not just a USB3 PHY, but USB3+DP PHY. Change device tree
nodes accordingly.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 947e1accae3a..0f79e6885004 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2097,12 +2097,11 @@ usb_2_hsphy: phy@88e4000 {
};
 
usb_1_qmpphy: phy@88e9000 {
-   compatible = "qcom,sm8250-qmp-usb3-phy";
+   compatible = "qcom,sm8250-qmp-usb3-dp-phy";
reg = <0 0x088e9000 0 0x200>,
- <0 0x088e8000 0 0x20>;
-   reg-names = "reg-base", "dp_com";
+ <0 0x088e8000 0 0x40>,
+ <0 0x088ea000 0 0x200>;
status = "disabled";
-   #clock-cells = <1>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
@@ -2116,7 +2115,7 @@ usb_1_qmpphy: phy@88e9000 {
 < GCC_USB3_PHY_PRIM_BCR>;
reset-names = "phy", "common";
 
-   usb_1_ssphy: lanes@88e9200 {
+   usb_1_ssphy: usb3-phy@88e9200 {
reg = <0 0x088e9200 0 0x200>,
  <0 0x088e9400 0 0x200>,
  <0 0x088e9c00 0 0x400>,
@@ -2128,6 +2127,20 @@ usb_1_ssphy: lanes@88e9200 {
clock-names = "pipe0";
clock-output-names = "usb3_phy_pipe_clk_src";
};
+
+   dp_phy: dp-phy@88ea200 {
+   reg = <0 0x088ea200 0 0x200>,
+ <0 0x088ea400 0 0x200>,
+ <0 0x088eac00 0 0x400>,
+ <0 0x088ea600 0 0x200>,
+ <0 0x088ea800 0 0x200>,
+ <0 0x088eaa00 0 0x100>;
+   #phy-cells = <0>;
+   #clock-cells = <1>;
+   clocks = < GCC_USB3_PRIM_PHY_PIPE_CLK>;
+   clock-names = "pipe0";
+   clock-output-names = "usb3_phy_pipe_clk_src";
+   };
};
 
usb_2_qmpphy: phy@88eb000 {
-- 
2.30.2



[PATCH v4 2/7] dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250

2021-03-26 Thread Dmitry Baryshkov
Add compatible for SM8250 in QMP USB3 DP PHY bindings.

Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 62c0179d1765..217aa6c91893 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -15,6 +15,7 @@ properties:
 enum:
   - qcom,sc7180-qmp-usb3-dp-phy
   - qcom,sdm845-qmp-usb3-dp-phy
+  - qcom,sm8250-qmp-usb3-dp-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



[PATCH v4 4/7] phy: qcom-qmp: rename common registers

2021-03-26 Thread Dmitry Baryshkov
A plenty of DP PHY registers are common between V3 and V4. To simplify
V4 code, rename all common registers.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 50 ++---
 drivers/phy/qualcomm/phy-qcom-qmp.h | 37 ++---
 2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 4150096fd350..097bc005ba43 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2435,20 +2435,20 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
 {
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
/* Turn on BIAS current for PHY/PLL */
writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
   QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_LANE_0_1_PWRDN |
   DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
   DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(QSERDES_V3_COM_BIAS_EN |
   QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
@@ -2456,16 +2456,16 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
   QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
-   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
-   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
-   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
-   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG9);
qphy->dp_aux_cfg = 0;
 
writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
@@ -2556,9 +2556,9 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
 *  writel(0x4c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
 */
val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
-   writel(val, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(val, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
-   writel(0x5c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
+   writel(0x5c, qphy->pcs + QSERDES_DP_PHY_MODE);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL);
 
@@ -2588,11 +2588,11 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
clk_set_rate(dp_clks->dp_link_hw.clk, dp_opts->link_rate * 10);
clk_set_rate(dp_clks->dp_pixel_hw.clk, pixel_freq);
 
-   writel(0x04, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x09, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
+   writel(0x04, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x05, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x09, qphy->pcs + QSERDES_DP_PHY_CFG);
 
writel(0x20, qphy->serdes + QSERDES_V3_COM_RESETSM_CNTRL);
 
@@ -2603,7 +2603,7 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
1))
return -ETIMED

[PATCH v4 1/7] dt-bindings: phy: qcom,qmp-usb3-dp-phy: move usb3 compatibles back to qcom,qmp-phy.yaml

2021-03-26 Thread Dmitry Baryshkov
The commit 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy
information") has support for DP part of USB3+DP combo PHYs. However
this change is not backwards compatible, placing additional requirements
onto qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy device nodes
(to include separate DP part, etc). However the aforementioned nodes do
not inclue DP part, they strictly follow the schema defined in the
qcom,qmp-phy.yaml file. Move those compatibles, leaving
qcom,qmp-usb3-dp-phy.yaml to describe only real "combo" USB3+DP device nodes.

Fixes: 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add DP phy 
information")
Cc: Stephen Boyd 
Cc: Sandeep Maheswaram 
Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 2 ++
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
index 626447fee092..0f42b36b0ac5 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
@@ -25,11 +25,13 @@ properties:
   - qcom,msm8998-qmp-pcie-phy
   - qcom,msm8998-qmp-ufs-phy
   - qcom,msm8998-qmp-usb3-phy
+  - qcom,sc7180x-qmp-usb3-phy
   - qcom,sc8180x-qmp-ufs-phy
   - qcom,sc8180x-qmp-usb3-phy
   - qcom,sdm845-qhp-pcie-phy
   - qcom,sdm845-qmp-pcie-phy
   - qcom,sdm845-qmp-ufs-phy
+  - qcom,sdm845-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-uni-phy
   - qcom,sm8150-qmp-ufs-phy
   - qcom,sm8150-qmp-usb3-phy
diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 33974ad10afe..62c0179d1765 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -14,9 +14,7 @@ properties:
   compatible:
 enum:
   - qcom,sc7180-qmp-usb3-dp-phy
-  - qcom,sc7180-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-dp-phy
-  - qcom,sdm845-qmp-usb3-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



[PATCH v4 0/7] phy: qcom-qmp: provide DP phy support for sm8250

2021-03-26 Thread Dmitry Baryshkov
Changes since v3:
 - Move qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy from
   qcom,qmp-usb3-dp.yaml to qcom,qmp-phy.yaml
 - Do not touch qcom,sm8250-qmp-usb3-phy compatible

Changes since v2:
 - Drop unused qmp_v4_usb3_rx_tbl

Changes since v1:
 - Provide dt bindings
 - Split register renaming from sm8250-dp-phy patch
 - Add respective changes to sm8250 device tree





Re: [PATCH v3 1/6] dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250

2021-03-26 Thread Dmitry Baryshkov
On Fri, 26 Mar 2021 at 04:20, Rob Herring  wrote:
>
> On Thu, Mar 18, 2021 at 10:59:25PM +0300, Dmitry Baryshkov wrote:
> > Add compatible for SM8250 in QMP USB3 DP PHY bindings.
> >
> > Signed-off-by: Dmitry Baryshkov 
> > ---
> >  Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 1 -
> >  Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 2 ++
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
> > b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
> > index 626447fee092..c558aa605b9d 100644
> > --- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
> > +++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
> > @@ -38,7 +38,6 @@ properties:
> >- qcom,sm8250-qmp-gen3x1-pcie-phy
> >- qcom,sm8250-qmp-gen3x2-pcie-phy
> >- qcom,sm8250-qmp-modem-pcie-phy
> > -  - qcom,sm8250-qmp-usb3-phy
>
> Why is this being moved? Not sure what the differences between the 2
> bindings, but doesn't seem like a backwards compatible change.

Hmm. I followed the existing schemas, but they are incorrect. It looks
like the commit 724fabf5df13 ("dt-bindings: phy: qcom,qmp-usb3-dp: Add
DP phy information") has introduced backwards-incompatible change,
which is not followed by the current kernel device trees. I'd proposed
to move qcom,sc7180-qmp-usb3-phy and qcom,sdm845-qmp-usb3-phy back to
bindings/phy/qcom,qmp-phy.yaml (as those device nodes do not use DP
serdes block, etc).

I'll include the fix into v4 of this series.

>
> >- qcom,sm8250-qmp-usb3-uni-phy
> >- qcom,sm8350-qmp-ufs-phy
> >- qcom,sm8350-qmp-usb3-phy
> > diff --git 
> > a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
> > b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
> > index 33974ad10afe..9792cc567cb5 100644
> > --- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
> > +++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
> > @@ -17,6 +17,8 @@ properties:
> >- qcom,sc7180-qmp-usb3-phy
> >- qcom,sdm845-qmp-usb3-dp-phy
> >- qcom,sdm845-qmp-usb3-phy
> > +  - qcom,sm8250-qmp-usb3-dp-phy
> > +  - qcom,sm8250-qmp-usb3-phy
> >reg:
> >  items:
> >- description: Address and length of PHY's USB serdes block.
> > --
> > 2.30.2
> >



-- 
With best wishes
Dmitry


[PATCH v3 5/6] arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode

2021-03-18 Thread Dmitry Baryshkov
USB1 QMP PHY is not just a USB3 PHY, but USB3+DP PHY. Change device tree
nodes accordingly.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 947e1accae3a..0f79e6885004 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2097,12 +2097,11 @@ usb_2_hsphy: phy@88e4000 {
};
 
usb_1_qmpphy: phy@88e9000 {
-   compatible = "qcom,sm8250-qmp-usb3-phy";
+   compatible = "qcom,sm8250-qmp-usb3-dp-phy";
reg = <0 0x088e9000 0 0x200>,
- <0 0x088e8000 0 0x20>;
-   reg-names = "reg-base", "dp_com";
+ <0 0x088e8000 0 0x40>,
+ <0 0x088ea000 0 0x200>;
status = "disabled";
-   #clock-cells = <1>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
@@ -2116,7 +2115,7 @@ usb_1_qmpphy: phy@88e9000 {
 < GCC_USB3_PHY_PRIM_BCR>;
reset-names = "phy", "common";
 
-   usb_1_ssphy: lanes@88e9200 {
+   usb_1_ssphy: usb3-phy@88e9200 {
reg = <0 0x088e9200 0 0x200>,
  <0 0x088e9400 0 0x200>,
  <0 0x088e9c00 0 0x400>,
@@ -2128,6 +2127,20 @@ usb_1_ssphy: lanes@88e9200 {
clock-names = "pipe0";
clock-output-names = "usb3_phy_pipe_clk_src";
};
+
+   dp_phy: dp-phy@88ea200 {
+   reg = <0 0x088ea200 0 0x200>,
+ <0 0x088ea400 0 0x200>,
+ <0 0x088eac00 0 0x400>,
+ <0 0x088ea600 0 0x200>,
+ <0 0x088ea800 0 0x200>,
+ <0 0x088eaa00 0 0x100>;
+   #phy-cells = <0>;
+   #clock-cells = <1>;
+   clocks = < GCC_USB3_PRIM_PHY_PIPE_CLK>;
+   clock-names = "pipe0";
+   clock-output-names = "usb3_phy_pipe_clk_src";
+   };
};
 
usb_2_qmpphy: phy@88eb000 {
-- 
2.30.2



[PATCH v3 6/6] arm64: dts: qcom: use dp_phy to provide clocks to dispcc

2021-03-18 Thread Dmitry Baryshkov
Plug dp_phy-provided clocks to display clock controller.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 0f79e6885004..a2478bd3590a 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2600,8 +2600,8 @@ dispcc: clock-controller@af0 {
 <_phy 1>,
 <_phy 0>,
 <_phy 1>,
-<0>,
-<0>,
+<_phy 0>,
+<_phy 1>,
 <0>,
 <0>,
 <0>,
@@ -2614,8 +2614,8 @@ dispcc: clock-controller@af0 {
  "dsi0_phy_pll_out_dsiclk",
  "dsi1_phy_pll_out_byteclk",
  "dsi1_phy_pll_out_dsiclk",
- "dp_link_clk_divsel_ten",
- "dp_vco_divided_clk_src_mux",
+ "dp_phy_pll_link_clk",
+ "dp_phy_pll_vco_div_clk",
  "dptx1_phy_pll_link_clk",
  "dptx1_phy_pll_vco_div_clk",
  "dptx2_phy_pll_link_clk",
-- 
2.30.2



[PATCH v3 2/6] phy: qcom-qmp: move DP functions to callbacks

2021-03-18 Thread Dmitry Baryshkov
In preparation to adding support for V4 DP PHY move DP functions to
callbacks at struct qmp_phy_cfg.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 438 +++-
 1 file changed, 231 insertions(+), 207 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 9cdebe7f26cb..4150096fd350 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2268,6 +2268,8 @@ static const struct qmp_phy_init_tbl 
sm8350_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+struct qmp_phy;
+
 /* struct qmp_phy_cfg - per-PHY initialization config */
 struct qmp_phy_cfg {
/* phy-type - PCIE/UFS/USB */
@@ -2307,6 +2309,12 @@ struct qmp_phy_cfg {
const struct qmp_phy_init_tbl *serdes_tbl_hbr3;
int serdes_tbl_hbr3_num;
 
+   /* DP PHY callbacks */
+   int (*configure_dp_phy)(struct qmp_phy *qphy);
+   void (*configure_dp_tx)(struct qmp_phy *qphy);
+   int (*calibrate_dp_phy)(struct qmp_phy *qphy);
+   void (*dp_aux_init)(struct qmp_phy *qphy);
+
/* clock ids to be requested */
const char * const *clk_list;
int num_clks;
@@ -2423,6 +2431,216 @@ struct qcom_qmp {
struct reset_control *ufs_reset;
 };
 
+static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy *qphy)
+{
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   /* Turn on BIAS current for PHY/PLL */
+   writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_LANE_0_1_PWRDN |
+  DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
+  DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(QSERDES_V3_COM_BIAS_EN |
+  QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL |
+  QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   qphy->dp_aux_cfg = 0;
+
+   writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
+  PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
+  PHY_AUX_REQ_ERR_MASK,
+  qphy->pcs + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK);
+}
+
+static const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = {
+   { 0x00, 0x0c, 0x14, 0x19 },
+   { 0x00, 0x0b, 0x12, 0xff },
+   { 0x00, 0x0b, 0xff, 0xff },
+   { 0x04, 0xff, 0xff, 0xff }
+};
+
+static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = {
+   { 0x08, 0x0f, 0x16, 0x1f },
+   { 0x11, 0x1e, 0x1f, 0xff },
+   { 0x19, 0x1f, 0xff, 0xff },
+   { 0x1f, 0xff, 0xff, 0xff }
+};
+
+static void qcom_qmp_v3_phy_configure_dp_tx(struct qmp_phy *qphy)
+{
+   const struct phy_configure_opts_dp *dp_opts = >dp_opts;
+   unsigned int v_level = 0, p_level = 0;
+   u32 bias_en, drvr_en;
+   u8 voltage_swing_cfg, pre_emphasis_cfg;
+   int i;
+
+   for (i = 0; i < dp_opts->lanes; i++) {
+   v_level = max(v_level, dp_opts->voltage[i]);
+   p_level = max(p_level, dp_opts->pre[i]);
+   }
+
+   if (dp_opts->lanes == 1) {
+   bias_en = 0x3e;
+   drvr_en = 0x13;
+   } else {
+   bias_en = 0x3f;
+   drvr_en = 0x10;
+   }
+
+   voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level];
+   pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level];
+
+   /* TODO: Move check to config check */
+   if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF)
+   return;
+
+   /* Enable MUX to use Cursor values from these registers */
+   voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN;
+  

[PATCH v3 4/6] phy: qcom-qmp: add support for sm8250-usb3-dp phy

2021-03-18 Thread Dmitry Baryshkov
Add support for QMP V4 Combo USB3+DP PHY (for SM8250 platform).

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 388 ++--
 drivers/phy/qualcomm/phy-qcom-qmp.h |  40 ++-
 2 files changed, 406 insertions(+), 22 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 097bc005ba43..a47da2fff7a1 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -1840,6 +1840,86 @@ static const struct qmp_phy_init_tbl 
sm8250_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_rbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x6f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x08),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0e),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr2[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x8c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x1f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr3[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x2f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x2a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_tx_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_VMODE_CTRL1, 0x40),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_INTERFACE_SELECT, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_CLKBUF_ENABLE, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RESET_TSYNC_EN, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_INTERFACE_MODE, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_BAND, 0x4),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_POL_INV, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_DRV_LVL, 0x2a

[PATCH v3 1/6] dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250

2021-03-18 Thread Dmitry Baryshkov
Add compatible for SM8250 in QMP USB3 DP PHY bindings.

Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 1 -
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
index 626447fee092..c558aa605b9d 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
@@ -38,7 +38,6 @@ properties:
   - qcom,sm8250-qmp-gen3x1-pcie-phy
   - qcom,sm8250-qmp-gen3x2-pcie-phy
   - qcom,sm8250-qmp-modem-pcie-phy
-  - qcom,sm8250-qmp-usb3-phy
   - qcom,sm8250-qmp-usb3-uni-phy
   - qcom,sm8350-qmp-ufs-phy
   - qcom,sm8350-qmp-usb3-phy
diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 33974ad10afe..9792cc567cb5 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -17,6 +17,8 @@ properties:
   - qcom,sc7180-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-dp-phy
   - qcom,sdm845-qmp-usb3-phy
+  - qcom,sm8250-qmp-usb3-dp-phy
+  - qcom,sm8250-qmp-usb3-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



[PATCH v3 3/6] phy: qcom-qmp: rename common registers

2021-03-18 Thread Dmitry Baryshkov
A plenty of DP PHY registers are common between V3 and V4. To simplify
V4 code, rename all common registers.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 50 ++---
 drivers/phy/qualcomm/phy-qcom-qmp.h | 37 ++---
 2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 4150096fd350..097bc005ba43 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2435,20 +2435,20 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
 {
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
/* Turn on BIAS current for PHY/PLL */
writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
   QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_LANE_0_1_PWRDN |
   DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
   DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(QSERDES_V3_COM_BIAS_EN |
   QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
@@ -2456,16 +2456,16 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
   QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
-   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
-   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
-   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
-   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG9);
qphy->dp_aux_cfg = 0;
 
writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
@@ -2556,9 +2556,9 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
 *  writel(0x4c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
 */
val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
-   writel(val, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(val, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
-   writel(0x5c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
+   writel(0x5c, qphy->pcs + QSERDES_DP_PHY_MODE);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL);
 
@@ -2588,11 +2588,11 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
clk_set_rate(dp_clks->dp_link_hw.clk, dp_opts->link_rate * 10);
clk_set_rate(dp_clks->dp_pixel_hw.clk, pixel_freq);
 
-   writel(0x04, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x09, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
+   writel(0x04, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x05, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x09, qphy->pcs + QSERDES_DP_PHY_CFG);
 
writel(0x20, qphy->serdes + QSERDES_V3_COM_RESETSM_CNTRL);
 
@@ -2603,7 +2603,7 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
1))
return -ETIMED

[PATCH v3 0/6] phy: qcom-qmp: provide DP phy support for sm8250

2021-03-18 Thread Dmitry Baryshkov
Changes since v2:
 - Drop unused qmp_v4_usb3_rx_tbl

Changes since v1:
 - Provide dt bindings
 - Split register renaming from sm8250-dp-phy patch
 - Add respective changes to sm8250 device tree

The following changes since commit a38fd8748464831584a19438cbb3082b5a2dab15:

  Linux 5.12-rc2 (2021-03-05 17:33:41 -0800)

are available in the Git repository at:

  https://git.linaro.org/people/dmitry.baryshkov/kernel.git sm8250-dp-phy

for you to fetch changes up to 31f660041a72c2321ebc5328a9cfdaa6e0c63ff1:

  arm64: dts: qcom: use dp_phy to provide clocks to dispcc (2021-03-18 22:57:57 
+0300)


Dmitry Baryshkov (6):
  dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250
  phy: qcom-qmp: move DP functions to callbacks
  phy: qcom-qmp: rename common registers
  phy: qcom-qmp: add support for sm8250-usb3-dp phy
  arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode
  arm64: dts: qcom: use dp_phy to provide clocks to dispcc

 .../devicetree/bindings/phy/qcom,qmp-phy.yaml  |   1 -
 .../bindings/phy/qcom,qmp-usb3-dp-phy.yaml |   2 +
 arch/arm64/boot/dts/qcom/sm8250.dtsi   |  31 +-
 drivers/phy/qualcomm/phy-qcom-qmp.c| 850 +++--
 drivers/phy/qualcomm/phy-qcom-qmp.h|  77 +-
 5 files changed, 692 insertions(+), 269 deletions(-)




[PATCH v2 6/6] arm64: dts: qcom: use dp_phy to provide clocks to dispcc

2021-03-18 Thread Dmitry Baryshkov
Plug dp_phy-provided clocks to display clock controller.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 0f79e6885004..a2478bd3590a 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2600,8 +2600,8 @@ dispcc: clock-controller@af0 {
 <_phy 1>,
 <_phy 0>,
 <_phy 1>,
-<0>,
-<0>,
+<_phy 0>,
+<_phy 1>,
 <0>,
 <0>,
 <0>,
@@ -2614,8 +2614,8 @@ dispcc: clock-controller@af0 {
  "dsi0_phy_pll_out_dsiclk",
  "dsi1_phy_pll_out_byteclk",
  "dsi1_phy_pll_out_dsiclk",
- "dp_link_clk_divsel_ten",
- "dp_vco_divided_clk_src_mux",
+ "dp_phy_pll_link_clk",
+ "dp_phy_pll_vco_div_clk",
  "dptx1_phy_pll_link_clk",
  "dptx1_phy_pll_vco_div_clk",
  "dptx2_phy_pll_link_clk",
-- 
2.30.2



[PATCH v2 4/6] phy: qcom-qmp: add support for sm8250-usb3-dp phy

2021-03-18 Thread Dmitry Baryshkov
Add support for QMP V4 Combo USB3+DP PHY (for SM8250 platform).

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 400 ++--
 drivers/phy/qualcomm/phy-qcom-qmp.h |  40 ++-
 2 files changed, 418 insertions(+), 22 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 097bc005ba43..b7168a0ed29b 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -1840,6 +1840,98 @@ static const struct qmp_phy_init_tbl 
sm8250_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_rbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x05),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x6f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x08),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x04),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x0e),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr2[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x01),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x8c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x1f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x1c),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_serdes_tbl_hbr3[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_HSCLK_SEL, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DEC_START_MODE0, 0x69),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START2_MODE0, 0x80),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START3_MODE0, 0x07),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP1_MODE0, 0x2f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP2_MODE0, 0x2a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_COM_LOCK_CMP_EN, 0x08),
+};
+
+static const struct qmp_phy_init_tbl qmp_v4_dp_tx_tbl[] = {
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_VMODE_CTRL1, 0x40),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PRE_STALL_LDO_BOOST_EN, 0x30),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_INTERFACE_SELECT, 0x3b),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_CLKBUF_ENABLE, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RESET_TSYNC_EN, 0x03),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TRAN_DRVR_EMP_EN, 0x0f),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_INTERFACE_MODE, 0x00),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_TX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_RES_CODE_LANE_OFFSET_RX, 0x11),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_BAND, 0x4),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_POL_INV, 0x0a),
+   QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_DRV_LVL, 0x2a

[PATCH v2 2/6] phy: qcom-qmp: move DP functions to callbacks

2021-03-18 Thread Dmitry Baryshkov
In preparation to adding support for V4 DP PHY move DP functions to
callbacks at struct qmp_phy_cfg.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 438 +++-
 1 file changed, 231 insertions(+), 207 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 9cdebe7f26cb..4150096fd350 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2268,6 +2268,8 @@ static const struct qmp_phy_init_tbl 
sm8350_usb3_uniphy_pcs_tbl[] = {
QMP_PHY_INIT_CFG(QPHY_V4_PCS_REFGEN_REQ_CONFIG1, 0x21),
 };
 
+struct qmp_phy;
+
 /* struct qmp_phy_cfg - per-PHY initialization config */
 struct qmp_phy_cfg {
/* phy-type - PCIE/UFS/USB */
@@ -2307,6 +2309,12 @@ struct qmp_phy_cfg {
const struct qmp_phy_init_tbl *serdes_tbl_hbr3;
int serdes_tbl_hbr3_num;
 
+   /* DP PHY callbacks */
+   int (*configure_dp_phy)(struct qmp_phy *qphy);
+   void (*configure_dp_tx)(struct qmp_phy *qphy);
+   int (*calibrate_dp_phy)(struct qmp_phy *qphy);
+   void (*dp_aux_init)(struct qmp_phy *qphy);
+
/* clock ids to be requested */
const char * const *clk_list;
int num_clks;
@@ -2423,6 +2431,216 @@ struct qcom_qmp {
struct reset_control *ufs_reset;
 };
 
+static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy *qphy)
+{
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   /* Turn on BIAS current for PHY/PLL */
+   writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
+  DP_PHY_PD_CTL_LANE_0_1_PWRDN |
+  DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
+  DP_PHY_PD_CTL_DP_CLAMP_EN,
+  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+
+   writel(QSERDES_V3_COM_BIAS_EN |
+  QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
+  QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL |
+  QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
+  qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
+
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   qphy->dp_aux_cfg = 0;
+
+   writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
+  PHY_AUX_SYNC_ERR_MASK | PHY_AUX_ALIGN_ERR_MASK |
+  PHY_AUX_REQ_ERR_MASK,
+  qphy->pcs + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK);
+}
+
+static const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = {
+   { 0x00, 0x0c, 0x14, 0x19 },
+   { 0x00, 0x0b, 0x12, 0xff },
+   { 0x00, 0x0b, 0xff, 0xff },
+   { 0x04, 0xff, 0xff, 0xff }
+};
+
+static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = {
+   { 0x08, 0x0f, 0x16, 0x1f },
+   { 0x11, 0x1e, 0x1f, 0xff },
+   { 0x19, 0x1f, 0xff, 0xff },
+   { 0x1f, 0xff, 0xff, 0xff }
+};
+
+static void qcom_qmp_v3_phy_configure_dp_tx(struct qmp_phy *qphy)
+{
+   const struct phy_configure_opts_dp *dp_opts = >dp_opts;
+   unsigned int v_level = 0, p_level = 0;
+   u32 bias_en, drvr_en;
+   u8 voltage_swing_cfg, pre_emphasis_cfg;
+   int i;
+
+   for (i = 0; i < dp_opts->lanes; i++) {
+   v_level = max(v_level, dp_opts->voltage[i]);
+   p_level = max(p_level, dp_opts->pre[i]);
+   }
+
+   if (dp_opts->lanes == 1) {
+   bias_en = 0x3e;
+   drvr_en = 0x13;
+   } else {
+   bias_en = 0x3f;
+   drvr_en = 0x10;
+   }
+
+   voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level];
+   pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level];
+
+   /* TODO: Move check to config check */
+   if (voltage_swing_cfg == 0xFF && pre_emphasis_cfg == 0xFF)
+   return;
+
+   /* Enable MUX to use Cursor values from these registers */
+   voltage_swing_cfg |= DP_PHY_TXn_TX_DRV_LVL_MUX_EN;
+  

[PATCH v2 3/6] phy: qcom-qmp: rename common registers

2021-03-18 Thread Dmitry Baryshkov
A plenty of DP PHY registers are common between V3 and V4. To simplify
V4 code, rename all common registers.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/phy/qualcomm/phy-qcom-qmp.c | 50 ++---
 drivers/phy/qualcomm/phy-qcom-qmp.h | 37 ++---
 2 files changed, 44 insertions(+), 43 deletions(-)

diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c 
b/drivers/phy/qualcomm/phy-qcom-qmp.c
index 4150096fd350..097bc005ba43 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp.c
@@ -2435,20 +2435,20 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
 {
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
/* Turn on BIAS current for PHY/PLL */
writel(QSERDES_V3_COM_BIAS_EN | QSERDES_V3_COM_BIAS_EN_MUX |
   QSERDES_V3_COM_CLKBUF_L_EN | QSERDES_V3_COM_EN_SYSCLK_TX_SEL,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(DP_PHY_PD_CTL_PSR_PWRDN, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN |
   DP_PHY_PD_CTL_LANE_0_1_PWRDN |
   DP_PHY_PD_CTL_LANE_2_3_PWRDN | DP_PHY_PD_CTL_PLL_PWRDN |
   DP_PHY_PD_CTL_DP_CLAMP_EN,
-  qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+  qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
writel(QSERDES_V3_COM_BIAS_EN |
   QSERDES_V3_COM_BIAS_EN_MUX | QSERDES_V3_COM_CLKBUF_R_EN |
@@ -2456,16 +2456,16 @@ static void qcom_qmp_v3_phy_dp_aux_init(struct qmp_phy 
*qphy)
   QSERDES_V3_COM_CLKBUF_RX_DRIVE_L,
   qphy->serdes + QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN);
 
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG0);
-   writel(0x13, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG1);
-   writel(0x24, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x00, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG3);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG4);
-   writel(0x26, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG5);
-   writel(0x0a, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG6);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG7);
-   writel(0xbb, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG8);
-   writel(0x03, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG9);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG0);
+   writel(0x13, qphy->pcs + QSERDES_DP_PHY_AUX_CFG1);
+   writel(0x24, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x00, qphy->pcs + QSERDES_DP_PHY_AUX_CFG3);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG4);
+   writel(0x26, qphy->pcs + QSERDES_DP_PHY_AUX_CFG5);
+   writel(0x0a, qphy->pcs + QSERDES_DP_PHY_AUX_CFG6);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG7);
+   writel(0xbb, qphy->pcs + QSERDES_DP_PHY_AUX_CFG8);
+   writel(0x03, qphy->pcs + QSERDES_DP_PHY_AUX_CFG9);
qphy->dp_aux_cfg = 0;
 
writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK |
@@ -2556,9 +2556,9 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
 *  writel(0x4c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
 */
val |= DP_PHY_PD_CTL_LANE_2_3_PWRDN;
-   writel(val, qphy->pcs + QSERDES_V3_DP_PHY_PD_CTL);
+   writel(val, qphy->pcs + QSERDES_DP_PHY_PD_CTL);
 
-   writel(0x5c, qphy->pcs + QSERDES_V3_DP_PHY_MODE);
+   writel(0x5c, qphy->pcs + QSERDES_DP_PHY_MODE);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL);
writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL);
 
@@ -2588,11 +2588,11 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
clk_set_rate(dp_clks->dp_link_hw.clk, dp_opts->link_rate * 10);
clk_set_rate(dp_clks->dp_pixel_hw.clk, pixel_freq);
 
-   writel(0x04, qphy->pcs + QSERDES_V3_DP_PHY_AUX_CFG2);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x01, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
-   writel(0x09, qphy->pcs + QSERDES_V3_DP_PHY_CFG);
+   writel(0x04, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x05, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x01, qphy->pcs + QSERDES_DP_PHY_CFG);
+   writel(0x09, qphy->pcs + QSERDES_DP_PHY_CFG);
 
writel(0x20, qphy->serdes + QSERDES_V3_COM_RESETSM_CNTRL);
 
@@ -2603,7 +2603,7 @@ static int qcom_qmp_v3_phy_configure_dp_phy(struct 
qmp_phy *qphy)
1))
return -ETIMED

[PATCH v2 0/6] phy: qcom-qmp: provide DP phy support for sm8250

2021-03-18 Thread Dmitry Baryshkov
Changes since v1:
 - Provide dt bindings
 - Split register renaming from sm8250-dp-phy patch
 - Add respective changes to sm8250 device tree

The following changes since commit a38fd8748464831584a19438cbb3082b5a2dab15:

  Linux 5.12-rc2 (2021-03-05 17:33:41 -0800)

are available in the Git repository at:

  https://git.linaro.org/people/dmitry.baryshkov/kernel.git sm8250-dp-phy

for you to fetch changes up to 112496035090508ff6e901d6b373bb6ab1ccc9ad:

  arm64: dts: qcom: use dp_phy to provide clocks to dispcc (2021-03-18 17:01:53 
+0300)


Dmitry Baryshkov (6):
  dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250
  phy: qcom-qmp: move DP functions to callbacks
  phy: qcom-qmp: rename common registers
  phy: qcom-qmp: add support for sm8250-usb3-dp phy
  arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode
  arm64: dts: qcom: use dp_phy to provide clocks to dispcc

 .../devicetree/bindings/phy/qcom,qmp-phy.yaml  |   1 -
 .../bindings/phy/qcom,qmp-usb3-dp-phy.yaml |   2 +
 arch/arm64/boot/dts/qcom/sm8250.dtsi   |  31 +-
 drivers/phy/qualcomm/phy-qcom-qmp.c| 862 +++--
 drivers/phy/qualcomm/phy-qcom-qmp.h|  77 +-
 5 files changed, 704 insertions(+), 269 deletions(-)




[PATCH v2 5/6] arm64: dts: qcom: sm8250: switch usb1 qmp phy to USB3+DP mode

2021-03-18 Thread Dmitry Baryshkov
USB1 QMP PHY is not just a USB3 PHY, but USB3+DP PHY. Change device tree
nodes accordingly.

Signed-off-by: Dmitry Baryshkov 
---
 arch/arm64/boot/dts/qcom/sm8250.dtsi | 23 ++-
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi 
b/arch/arm64/boot/dts/qcom/sm8250.dtsi
index 947e1accae3a..0f79e6885004 100644
--- a/arch/arm64/boot/dts/qcom/sm8250.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi
@@ -2097,12 +2097,11 @@ usb_2_hsphy: phy@88e4000 {
};
 
usb_1_qmpphy: phy@88e9000 {
-   compatible = "qcom,sm8250-qmp-usb3-phy";
+   compatible = "qcom,sm8250-qmp-usb3-dp-phy";
reg = <0 0x088e9000 0 0x200>,
- <0 0x088e8000 0 0x20>;
-   reg-names = "reg-base", "dp_com";
+ <0 0x088e8000 0 0x40>,
+ <0 0x088ea000 0 0x200>;
status = "disabled";
-   #clock-cells = <1>;
#address-cells = <2>;
#size-cells = <2>;
ranges;
@@ -2116,7 +2115,7 @@ usb_1_qmpphy: phy@88e9000 {
 < GCC_USB3_PHY_PRIM_BCR>;
reset-names = "phy", "common";
 
-   usb_1_ssphy: lanes@88e9200 {
+   usb_1_ssphy: usb3-phy@88e9200 {
reg = <0 0x088e9200 0 0x200>,
  <0 0x088e9400 0 0x200>,
  <0 0x088e9c00 0 0x400>,
@@ -2128,6 +2127,20 @@ usb_1_ssphy: lanes@88e9200 {
clock-names = "pipe0";
clock-output-names = "usb3_phy_pipe_clk_src";
};
+
+   dp_phy: dp-phy@88ea200 {
+   reg = <0 0x088ea200 0 0x200>,
+ <0 0x088ea400 0 0x200>,
+ <0 0x088eac00 0 0x400>,
+ <0 0x088ea600 0 0x200>,
+ <0 0x088ea800 0 0x200>,
+ <0 0x088eaa00 0 0x100>;
+   #phy-cells = <0>;
+   #clock-cells = <1>;
+   clocks = < GCC_USB3_PRIM_PHY_PIPE_CLK>;
+   clock-names = "pipe0";
+   clock-output-names = "usb3_phy_pipe_clk_src";
+   };
};
 
usb_2_qmpphy: phy@88eb000 {
-- 
2.30.2



[PATCH v2 1/6] dt-bindings: phy: qcom,qmp-usb3-dp: Add support for SM8250

2021-03-18 Thread Dmitry Baryshkov
Add compatible for SM8250 in QMP USB3 DP PHY bindings.

Signed-off-by: Dmitry Baryshkov 
---
 Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml | 1 -
 Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
index 626447fee092..c558aa605b9d 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
@@ -38,7 +38,6 @@ properties:
   - qcom,sm8250-qmp-gen3x1-pcie-phy
   - qcom,sm8250-qmp-gen3x2-pcie-phy
   - qcom,sm8250-qmp-modem-pcie-phy
-  - qcom,sm8250-qmp-usb3-phy
   - qcom,sm8250-qmp-usb3-uni-phy
   - qcom,sm8350-qmp-ufs-phy
   - qcom,sm8350-qmp-usb3-phy
diff --git a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml 
b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
index 33974ad10afe..9792cc567cb5 100644
--- a/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
+++ b/Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
@@ -17,6 +17,8 @@ properties:
   - qcom,sc7180-qmp-usb3-phy
   - qcom,sdm845-qmp-usb3-dp-phy
   - qcom,sdm845-qmp-usb3-phy
+  - qcom,sm8250-qmp-usb3-dp-phy
+  - qcom,sm8250-qmp-usb3-phy
   reg:
 items:
   - description: Address and length of PHY's USB serdes block.
-- 
2.30.2



Re: [PATCH] dt-bindings: More cleanup of standard unit properties

2021-03-16 Thread Dmitry Baryshkov
On Tue, 16 Mar 2021 at 22:48, Rob Herring  wrote:
>
> Properties with standard unit suffixes already have a type and don't need
> type references. Fix a few more cases which have gotten added.
>
> Cc: Luca Ceresoli 
> Cc: Jonathan Cameron 
> Cc: Dmitry Torokhov 
> Cc: Bjorn Andersson 
> Cc: Zhang Rui 
> Cc: Daniel Lezcano 
> Cc: Linus Walleij 
> Cc: Kevin Tsai 
> Cc: Dmitry Baryshkov 
> Cc: Sebastian Reichel 
> Cc: Mark Brown 
> Cc: linux-...@vger.kernel.org
> Cc: linux-in...@vger.kernel.org
> Cc: linux...@vger.kernel.org
> Signed-off-by: Rob Herring 
> ---

For the qcom-spmi-adc-tm5.yaml:
Acked-by: Dmity Baryshkov 

>  Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml | 1 -
>  Documentation/devicetree/bindings/input/input.yaml  | 1 -
>  Documentation/devicetree/bindings/power/supply/bq256xx.yaml | 1 -
>  Documentation/devicetree/bindings/power/supply/ltc4162-l.yaml   | 2 --
>  .../devicetree/bindings/regulator/qcom-labibb-regulator.yaml| 1 -
>  .../devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml  | 1 -
>  6 files changed, 7 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml 
> b/Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml
> index 27972938b60d..c63b79c3351b 100644
> --- a/Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml
> +++ b/Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml
> @@ -48,7 +48,6 @@ properties:
>vdd-supply: true
>
>capella,aset-resistance-ohms:
> -$ref: /schemas/types.yaml#/definitions/uint32
>  enum: [5, 10, 30, 60]
>  description: >
>Sensitivity calibration resistance. Note that calibration curves
> diff --git a/Documentation/devicetree/bindings/input/input.yaml 
> b/Documentation/devicetree/bindings/input/input.yaml
> index ab407f266bef..3fc37478c0c0 100644
> --- a/Documentation/devicetree/bindings/input/input.yaml
> +++ b/Documentation/devicetree/bindings/input/input.yaml
> @@ -32,6 +32,5 @@ properties:
>Duration in seconds which the key should be kept pressed for device to
>power off automatically. Device with key pressed shutdown feature can
>specify this property.
> -$ref: /schemas/types.yaml#/definitions/uint32
>
>  additionalProperties: true
> diff --git a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml 
> b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml
> index 18b54783e11a..92ec7ed25668 100644
> --- a/Documentation/devicetree/bindings/power/supply/bq256xx.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/bq256xx.yaml
> @@ -39,7 +39,6 @@ properties:
>  maxItems: 1
>
>ti,watchdog-timeout-ms:
> -$ref: /schemas/types.yaml#/definitions/uint32
>  default: 0
>  description: |
>Watchdog timer in ms. 0 (default) disables the watchdog
> diff --git a/Documentation/devicetree/bindings/power/supply/ltc4162-l.yaml 
> b/Documentation/devicetree/bindings/power/supply/ltc4162-l.yaml
> index 1f88c9e013f4..6d7aa97a6475 100644
> --- a/Documentation/devicetree/bindings/power/supply/ltc4162-l.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/ltc4162-l.yaml
> @@ -29,12 +29,10 @@ properties:
>  description: I2C address of the charger.
>
>lltc,rsnsb-micro-ohms:
> -$ref: /schemas/types.yaml#/definitions/uint32
>  description: Battery sense resistor in microohm.
>  minimum: 1000
>
>lltc,rsnsi-micro-ohms:
> -$ref: /schemas/types.yaml#/definitions/uint32
>  description: Input current sense resistor in microohm.
>  minimum: 1000
>
> diff --git 
> a/Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml 
> b/Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml
> index cf784bd1f5e5..1ddc1efd19e2 100644
> --- a/Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml
> +++ b/Documentation/devicetree/bindings/regulator/qcom-labibb-regulator.yaml
> @@ -23,7 +23,6 @@ properties:
>
>  properties:
>qcom,soft-start-us:
> -$ref: /schemas/types.yaml#/definitions/uint32
>  description: Regulator soft start time in microseconds.
>  enum: [200, 400, 600, 800]
>  default: 200
> diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml 
> b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> index 7cd364430573..95a728f4d333 100644
> --- a/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-adc-tm5.yaml
> @@ -78,7 +78,6 @@ patternProperties:
>also known as absolute calibration.
>
>

  1   2   3   >