Re: [PATCH v4] remoteproc: qcom: Introduce Non-PAS ADSP PIL driver

2018-10-06 Thread Bjorn Andersson
On Mon 24 Sep 04:07 PDT 2018, Rohit kumar wrote:

> This adds Non PAS ADSP PIL driver for Qualcomm
> Technologies Inc SoCs.
> Added initial support for SDM845 with ADSP bootup and
> shutdown operation handled from Application Processor
> SubSystem(APSS).
> 
> Signed-off-by: Rohit kumar 

Sorry for missing this on the last few patches, I thought we said we
where going to name the driver qcom_q6v5_adsp. Rather than spending more
time on this I applied the patch with this change, as it does look good.

Please let me know if you have any concerns with this.

Regards,
Bjorn

> ---
> Changes since v3:
>   Addressed comments posted by Sibi
> 
> This patch is dependent on the rpmh powerdomain driver 
> https://lkml.org/lkml/2018/6/27/7
> and renaming of Hexagon v5 PAS driver 
> https://patchwork.kernel.org/patch/10601119/ .
> 
>  drivers/remoteproc/Kconfig |  14 ++
>  drivers/remoteproc/Makefile|   1 +
>  drivers/remoteproc/qcom_adsp_pil.c | 502 
> +
>  3 files changed, 517 insertions(+)
>  create mode 100644 drivers/remoteproc/qcom_adsp_pil.c
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index 8894935..f554669 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -140,6 +140,20 @@ config QCOM_Q6V5_WCSS
> Say y here to support the Qualcomm Peripheral Image Loader for the
> Hexagon V5 based WCSS remote processors.
>  
> +config QCOM_ADSP_PIL
> + tristate "Qualcomm Technology Inc ADSP Peripheral Image Loader"
> + depends on OF && ARCH_QCOM
> + depends on QCOM_SMEM
> + depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
> + depends on QCOM_SYSMON || QCOM_SYSMON=n
> + select MFD_SYSCON
> + select QCOM_MDT_LOADER
> + select QCOM_Q6V5_COMMON
> + select QCOM_RPROC_COMMON
> + help
> +   Say y here to support the Peripheral Image Loader
> +   for the Qualcomm Technology Inc. ADSP remote processors.
> +
>  config QCOM_SYSMON
>   tristate "Qualcomm sysmon driver"
>   depends on RPMSG
> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> index 050f41a..0e1b89c 100644
> --- a/drivers/remoteproc/Makefile
> +++ b/drivers/remoteproc/Makefile
> @@ -19,6 +19,7 @@ obj-$(CONFIG_QCOM_Q6V5_COMMON)  += qcom_q6v5.o
>  obj-$(CONFIG_QCOM_Q6V5_MSS)  += qcom_q6v5_mss.o
>  obj-$(CONFIG_QCOM_Q6V5_PAS)  += qcom_q6v5_pas.o
>  obj-$(CONFIG_QCOM_Q6V5_WCSS) += qcom_q6v5_wcss.o
> +obj-$(CONFIG_QCOM_ADSP_PIL)  += qcom_adsp_pil.o
>  obj-$(CONFIG_QCOM_SYSMON)+= qcom_sysmon.o
>  obj-$(CONFIG_QCOM_WCNSS_PIL) += qcom_wcnss_pil.o
>  qcom_wcnss_pil-y += qcom_wcnss.o
> diff --git a/drivers/remoteproc/qcom_adsp_pil.c 
> b/drivers/remoteproc/qcom_adsp_pil.c
> new file mode 100644
> index 000..f2f5e56
> --- /dev/null
> +++ b/drivers/remoteproc/qcom_adsp_pil.c
> @@ -0,0 +1,502 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
> + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "qcom_common.h"
> +#include "qcom_q6v5.h"
> +#include "remoteproc_internal.h"
> +
> +/* time out value */
> +#define ACK_TIMEOUT  1000
> +#define BOOT_FSM_TIMEOUT 1
> +/* mask values */
> +#define EVB_MASK GENMASK(27, 4)
> +/*QDSP6SS register offsets*/
> +#define RST_EVB_REG  0x10
> +#define CORE_START_REG   0x400
> +#define BOOT_CMD_REG 0x404
> +#define BOOT_STATUS_REG  0x408
> +#define RET_CFG_REG  0x1C
> +/*TCSR register offsets*/
> +#define LPASS_MASTER_IDLE_REG0x8
> +#define LPASS_HALTACK_REG0x4
> +#define LPASS_PWR_ON_REG 0x10
> +#define LPASS_HALTREQ_REG0x0
> +
> +/* list of clocks required by ADSP PIL */
> +static const char * const adsp_clk_id[] = {
> + "sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
> + "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
> +};
> +
> +struct adsp_pil_data {
> + int crash_reason_smem;
> + const char *firmware_name;
> +
> + const char *ssr_name;
> + const char *sysmon_name;
> + int ssctl_id;
> +};
> +
> +struct qcom_adsp {
> + struct device *dev;
> + struct rproc *rproc;
> +
> + struct qcom_q6v5 q6v5;
> +
> + struct clk *xo;
> +
> + int num_clks;
> + struct clk_bulk_data *clks;
> +
> + void __iomem *qdsp6ss_base;
> +
> + struct reset_control *pdc_sync_reset;
> + struct reset_control *cc_lpass_restart;
> +
> + 

Re: [PATCH v4] remoteproc: qcom: Introduce Non-PAS ADSP PIL driver

2018-10-06 Thread Bjorn Andersson
On Mon 24 Sep 04:07 PDT 2018, Rohit kumar wrote:

> This adds Non PAS ADSP PIL driver for Qualcomm
> Technologies Inc SoCs.
> Added initial support for SDM845 with ADSP bootup and
> shutdown operation handled from Application Processor
> SubSystem(APSS).
> 
> Signed-off-by: Rohit kumar 

Sorry for missing this on the last few patches, I thought we said we
where going to name the driver qcom_q6v5_adsp. Rather than spending more
time on this I applied the patch with this change, as it does look good.

Please let me know if you have any concerns with this.

Regards,
Bjorn

> ---
> Changes since v3:
>   Addressed comments posted by Sibi
> 
> This patch is dependent on the rpmh powerdomain driver 
> https://lkml.org/lkml/2018/6/27/7
> and renaming of Hexagon v5 PAS driver 
> https://patchwork.kernel.org/patch/10601119/ .
> 
>  drivers/remoteproc/Kconfig |  14 ++
>  drivers/remoteproc/Makefile|   1 +
>  drivers/remoteproc/qcom_adsp_pil.c | 502 
> +
>  3 files changed, 517 insertions(+)
>  create mode 100644 drivers/remoteproc/qcom_adsp_pil.c
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index 8894935..f554669 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -140,6 +140,20 @@ config QCOM_Q6V5_WCSS
> Say y here to support the Qualcomm Peripheral Image Loader for the
> Hexagon V5 based WCSS remote processors.
>  
> +config QCOM_ADSP_PIL
> + tristate "Qualcomm Technology Inc ADSP Peripheral Image Loader"
> + depends on OF && ARCH_QCOM
> + depends on QCOM_SMEM
> + depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
> + depends on QCOM_SYSMON || QCOM_SYSMON=n
> + select MFD_SYSCON
> + select QCOM_MDT_LOADER
> + select QCOM_Q6V5_COMMON
> + select QCOM_RPROC_COMMON
> + help
> +   Say y here to support the Peripheral Image Loader
> +   for the Qualcomm Technology Inc. ADSP remote processors.
> +
>  config QCOM_SYSMON
>   tristate "Qualcomm sysmon driver"
>   depends on RPMSG
> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> index 050f41a..0e1b89c 100644
> --- a/drivers/remoteproc/Makefile
> +++ b/drivers/remoteproc/Makefile
> @@ -19,6 +19,7 @@ obj-$(CONFIG_QCOM_Q6V5_COMMON)  += qcom_q6v5.o
>  obj-$(CONFIG_QCOM_Q6V5_MSS)  += qcom_q6v5_mss.o
>  obj-$(CONFIG_QCOM_Q6V5_PAS)  += qcom_q6v5_pas.o
>  obj-$(CONFIG_QCOM_Q6V5_WCSS) += qcom_q6v5_wcss.o
> +obj-$(CONFIG_QCOM_ADSP_PIL)  += qcom_adsp_pil.o
>  obj-$(CONFIG_QCOM_SYSMON)+= qcom_sysmon.o
>  obj-$(CONFIG_QCOM_WCNSS_PIL) += qcom_wcnss_pil.o
>  qcom_wcnss_pil-y += qcom_wcnss.o
> diff --git a/drivers/remoteproc/qcom_adsp_pil.c 
> b/drivers/remoteproc/qcom_adsp_pil.c
> new file mode 100644
> index 000..f2f5e56
> --- /dev/null
> +++ b/drivers/remoteproc/qcom_adsp_pil.c
> @@ -0,0 +1,502 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
> + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "qcom_common.h"
> +#include "qcom_q6v5.h"
> +#include "remoteproc_internal.h"
> +
> +/* time out value */
> +#define ACK_TIMEOUT  1000
> +#define BOOT_FSM_TIMEOUT 1
> +/* mask values */
> +#define EVB_MASK GENMASK(27, 4)
> +/*QDSP6SS register offsets*/
> +#define RST_EVB_REG  0x10
> +#define CORE_START_REG   0x400
> +#define BOOT_CMD_REG 0x404
> +#define BOOT_STATUS_REG  0x408
> +#define RET_CFG_REG  0x1C
> +/*TCSR register offsets*/
> +#define LPASS_MASTER_IDLE_REG0x8
> +#define LPASS_HALTACK_REG0x4
> +#define LPASS_PWR_ON_REG 0x10
> +#define LPASS_HALTREQ_REG0x0
> +
> +/* list of clocks required by ADSP PIL */
> +static const char * const adsp_clk_id[] = {
> + "sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
> + "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
> +};
> +
> +struct adsp_pil_data {
> + int crash_reason_smem;
> + const char *firmware_name;
> +
> + const char *ssr_name;
> + const char *sysmon_name;
> + int ssctl_id;
> +};
> +
> +struct qcom_adsp {
> + struct device *dev;
> + struct rproc *rproc;
> +
> + struct qcom_q6v5 q6v5;
> +
> + struct clk *xo;
> +
> + int num_clks;
> + struct clk_bulk_data *clks;
> +
> + void __iomem *qdsp6ss_base;
> +
> + struct reset_control *pdc_sync_reset;
> + struct reset_control *cc_lpass_restart;
> +
> + 

Re: [PATCH v4] remoteproc: qcom: Introduce Non-PAS ADSP PIL driver

2018-09-24 Thread Sibi Sankar

Hi Rohit,

Thanks for the quick turnaround, the patches look fine.

Reviewed-by: Sibi Sankar 
Tested-by: Sibi Sankar 

On 2018-09-24 16:37, Rohit kumar wrote:

This adds Non PAS ADSP PIL driver for Qualcomm
Technologies Inc SoCs.
Added initial support for SDM845 with ADSP bootup and
shutdown operation handled from Application Processor
SubSystem(APSS).

Signed-off-by: Rohit kumar 
---
Changes since v3:
Addressed comments posted by Sibi

This patch is dependent on the rpmh powerdomain driver
https://lkml.org/lkml/2018/6/27/7
and renaming of Hexagon v5 PAS driver
https://patchwork.kernel.org/patch/10601119/ .

 drivers/remoteproc/Kconfig |  14 ++
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/qcom_adsp_pil.c | 502 
+

 3 files changed, 517 insertions(+)
 create mode 100644 drivers/remoteproc/qcom_adsp_pil.c

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 8894935..f554669 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -140,6 +140,20 @@ config QCOM_Q6V5_WCSS
  Say y here to support the Qualcomm Peripheral Image Loader for the
  Hexagon V5 based WCSS remote processors.

+config QCOM_ADSP_PIL
+   tristate "Qualcomm Technology Inc ADSP Peripheral Image Loader"
+   depends on OF && ARCH_QCOM
+   depends on QCOM_SMEM
+   depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
+   depends on QCOM_SYSMON || QCOM_SYSMON=n
+   select MFD_SYSCON
+   select QCOM_MDT_LOADER
+   select QCOM_Q6V5_COMMON
+   select QCOM_RPROC_COMMON
+   help
+ Say y here to support the Peripheral Image Loader
+ for the Qualcomm Technology Inc. ADSP remote processors.
+
 config QCOM_SYSMON
tristate "Qualcomm sysmon driver"
depends on RPMSG
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 050f41a..0e1b89c 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_QCOM_Q6V5_COMMON)+= qcom_q6v5.o
 obj-$(CONFIG_QCOM_Q6V5_MSS)+= qcom_q6v5_mss.o
 obj-$(CONFIG_QCOM_Q6V5_PAS)+= qcom_q6v5_pas.o
 obj-$(CONFIG_QCOM_Q6V5_WCSS)   += qcom_q6v5_wcss.o
+obj-$(CONFIG_QCOM_ADSP_PIL)+= qcom_adsp_pil.o
 obj-$(CONFIG_QCOM_SYSMON)  += qcom_sysmon.o
 obj-$(CONFIG_QCOM_WCNSS_PIL)   += qcom_wcnss_pil.o
 qcom_wcnss_pil-y   += qcom_wcnss.o
diff --git a/drivers/remoteproc/qcom_adsp_pil.c
b/drivers/remoteproc/qcom_adsp_pil.c
new file mode 100644
index 000..f2f5e56
--- /dev/null
+++ b/drivers/remoteproc/qcom_adsp_pil.c
@@ -0,0 +1,502 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qcom_common.h"
+#include "qcom_q6v5.h"
+#include "remoteproc_internal.h"
+
+/* time out value */
+#define ACK_TIMEOUT1000
+#define BOOT_FSM_TIMEOUT   1
+/* mask values */
+#define EVB_MASK   GENMASK(27, 4)
+/*QDSP6SS register offsets*/
+#define RST_EVB_REG0x10
+#define CORE_START_REG 0x400
+#define BOOT_CMD_REG   0x404
+#define BOOT_STATUS_REG0x408
+#define RET_CFG_REG0x1C
+/*TCSR register offsets*/
+#define LPASS_MASTER_IDLE_REG  0x8
+#define LPASS_HALTACK_REG  0x4
+#define LPASS_PWR_ON_REG   0x10
+#define LPASS_HALTREQ_REG  0x0
+
+/* list of clocks required by ADSP PIL */
+static const char * const adsp_clk_id[] = {
+	"sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr", 
"lpass_ahbm_aon_cbcr",

+   "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
+};
+
+struct adsp_pil_data {
+   int crash_reason_smem;
+   const char *firmware_name;
+
+   const char *ssr_name;
+   const char *sysmon_name;
+   int ssctl_id;
+};
+
+struct qcom_adsp {
+   struct device *dev;
+   struct rproc *rproc;
+
+   struct qcom_q6v5 q6v5;
+
+   struct clk *xo;
+
+   int num_clks;
+   struct clk_bulk_data *clks;
+
+   void __iomem *qdsp6ss_base;
+
+   struct reset_control *pdc_sync_reset;
+   struct reset_control *cc_lpass_restart;
+
+   struct regmap *halt_map;
+   unsigned int halt_lpass;
+
+   int crash_reason_smem;
+
+   struct completion start_done;
+   struct completion stop_done;
+
+   phys_addr_t mem_phys;
+   phys_addr_t mem_reloc;
+   void *mem_region;
+   size_t mem_size;
+
+   struct qcom_rproc_glink glink_subdev;
+   struct qcom_rproc_ssr ssr_subdev;
+   struct 

Re: [PATCH v4] remoteproc: qcom: Introduce Non-PAS ADSP PIL driver

2018-09-24 Thread Sibi Sankar

Hi Rohit,

Thanks for the quick turnaround, the patches look fine.

Reviewed-by: Sibi Sankar 
Tested-by: Sibi Sankar 

On 2018-09-24 16:37, Rohit kumar wrote:

This adds Non PAS ADSP PIL driver for Qualcomm
Technologies Inc SoCs.
Added initial support for SDM845 with ADSP bootup and
shutdown operation handled from Application Processor
SubSystem(APSS).

Signed-off-by: Rohit kumar 
---
Changes since v3:
Addressed comments posted by Sibi

This patch is dependent on the rpmh powerdomain driver
https://lkml.org/lkml/2018/6/27/7
and renaming of Hexagon v5 PAS driver
https://patchwork.kernel.org/patch/10601119/ .

 drivers/remoteproc/Kconfig |  14 ++
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/qcom_adsp_pil.c | 502 
+

 3 files changed, 517 insertions(+)
 create mode 100644 drivers/remoteproc/qcom_adsp_pil.c

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 8894935..f554669 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -140,6 +140,20 @@ config QCOM_Q6V5_WCSS
  Say y here to support the Qualcomm Peripheral Image Loader for the
  Hexagon V5 based WCSS remote processors.

+config QCOM_ADSP_PIL
+   tristate "Qualcomm Technology Inc ADSP Peripheral Image Loader"
+   depends on OF && ARCH_QCOM
+   depends on QCOM_SMEM
+   depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
+   depends on QCOM_SYSMON || QCOM_SYSMON=n
+   select MFD_SYSCON
+   select QCOM_MDT_LOADER
+   select QCOM_Q6V5_COMMON
+   select QCOM_RPROC_COMMON
+   help
+ Say y here to support the Peripheral Image Loader
+ for the Qualcomm Technology Inc. ADSP remote processors.
+
 config QCOM_SYSMON
tristate "Qualcomm sysmon driver"
depends on RPMSG
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 050f41a..0e1b89c 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_QCOM_Q6V5_COMMON)+= qcom_q6v5.o
 obj-$(CONFIG_QCOM_Q6V5_MSS)+= qcom_q6v5_mss.o
 obj-$(CONFIG_QCOM_Q6V5_PAS)+= qcom_q6v5_pas.o
 obj-$(CONFIG_QCOM_Q6V5_WCSS)   += qcom_q6v5_wcss.o
+obj-$(CONFIG_QCOM_ADSP_PIL)+= qcom_adsp_pil.o
 obj-$(CONFIG_QCOM_SYSMON)  += qcom_sysmon.o
 obj-$(CONFIG_QCOM_WCNSS_PIL)   += qcom_wcnss_pil.o
 qcom_wcnss_pil-y   += qcom_wcnss.o
diff --git a/drivers/remoteproc/qcom_adsp_pil.c
b/drivers/remoteproc/qcom_adsp_pil.c
new file mode 100644
index 000..f2f5e56
--- /dev/null
+++ b/drivers/remoteproc/qcom_adsp_pil.c
@@ -0,0 +1,502 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qcom_common.h"
+#include "qcom_q6v5.h"
+#include "remoteproc_internal.h"
+
+/* time out value */
+#define ACK_TIMEOUT1000
+#define BOOT_FSM_TIMEOUT   1
+/* mask values */
+#define EVB_MASK   GENMASK(27, 4)
+/*QDSP6SS register offsets*/
+#define RST_EVB_REG0x10
+#define CORE_START_REG 0x400
+#define BOOT_CMD_REG   0x404
+#define BOOT_STATUS_REG0x408
+#define RET_CFG_REG0x1C
+/*TCSR register offsets*/
+#define LPASS_MASTER_IDLE_REG  0x8
+#define LPASS_HALTACK_REG  0x4
+#define LPASS_PWR_ON_REG   0x10
+#define LPASS_HALTREQ_REG  0x0
+
+/* list of clocks required by ADSP PIL */
+static const char * const adsp_clk_id[] = {
+	"sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr", 
"lpass_ahbm_aon_cbcr",

+   "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
+};
+
+struct adsp_pil_data {
+   int crash_reason_smem;
+   const char *firmware_name;
+
+   const char *ssr_name;
+   const char *sysmon_name;
+   int ssctl_id;
+};
+
+struct qcom_adsp {
+   struct device *dev;
+   struct rproc *rproc;
+
+   struct qcom_q6v5 q6v5;
+
+   struct clk *xo;
+
+   int num_clks;
+   struct clk_bulk_data *clks;
+
+   void __iomem *qdsp6ss_base;
+
+   struct reset_control *pdc_sync_reset;
+   struct reset_control *cc_lpass_restart;
+
+   struct regmap *halt_map;
+   unsigned int halt_lpass;
+
+   int crash_reason_smem;
+
+   struct completion start_done;
+   struct completion stop_done;
+
+   phys_addr_t mem_phys;
+   phys_addr_t mem_reloc;
+   void *mem_region;
+   size_t mem_size;
+
+   struct qcom_rproc_glink glink_subdev;
+   struct qcom_rproc_ssr ssr_subdev;
+   struct 

[PATCH v4] remoteproc: qcom: Introduce Non-PAS ADSP PIL driver

2018-09-24 Thread Rohit kumar
This adds Non PAS ADSP PIL driver for Qualcomm
Technologies Inc SoCs.
Added initial support for SDM845 with ADSP bootup and
shutdown operation handled from Application Processor
SubSystem(APSS).

Signed-off-by: Rohit kumar 
---
Changes since v3:
Addressed comments posted by Sibi

This patch is dependent on the rpmh powerdomain driver 
https://lkml.org/lkml/2018/6/27/7
and renaming of Hexagon v5 PAS driver 
https://patchwork.kernel.org/patch/10601119/ .

 drivers/remoteproc/Kconfig |  14 ++
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/qcom_adsp_pil.c | 502 +
 3 files changed, 517 insertions(+)
 create mode 100644 drivers/remoteproc/qcom_adsp_pil.c

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 8894935..f554669 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -140,6 +140,20 @@ config QCOM_Q6V5_WCSS
  Say y here to support the Qualcomm Peripheral Image Loader for the
  Hexagon V5 based WCSS remote processors.
 
+config QCOM_ADSP_PIL
+   tristate "Qualcomm Technology Inc ADSP Peripheral Image Loader"
+   depends on OF && ARCH_QCOM
+   depends on QCOM_SMEM
+   depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
+   depends on QCOM_SYSMON || QCOM_SYSMON=n
+   select MFD_SYSCON
+   select QCOM_MDT_LOADER
+   select QCOM_Q6V5_COMMON
+   select QCOM_RPROC_COMMON
+   help
+ Say y here to support the Peripheral Image Loader
+ for the Qualcomm Technology Inc. ADSP remote processors.
+
 config QCOM_SYSMON
tristate "Qualcomm sysmon driver"
depends on RPMSG
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 050f41a..0e1b89c 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_QCOM_Q6V5_COMMON)+= qcom_q6v5.o
 obj-$(CONFIG_QCOM_Q6V5_MSS)+= qcom_q6v5_mss.o
 obj-$(CONFIG_QCOM_Q6V5_PAS)+= qcom_q6v5_pas.o
 obj-$(CONFIG_QCOM_Q6V5_WCSS)   += qcom_q6v5_wcss.o
+obj-$(CONFIG_QCOM_ADSP_PIL)+= qcom_adsp_pil.o
 obj-$(CONFIG_QCOM_SYSMON)  += qcom_sysmon.o
 obj-$(CONFIG_QCOM_WCNSS_PIL)   += qcom_wcnss_pil.o
 qcom_wcnss_pil-y   += qcom_wcnss.o
diff --git a/drivers/remoteproc/qcom_adsp_pil.c 
b/drivers/remoteproc/qcom_adsp_pil.c
new file mode 100644
index 000..f2f5e56
--- /dev/null
+++ b/drivers/remoteproc/qcom_adsp_pil.c
@@ -0,0 +1,502 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qcom_common.h"
+#include "qcom_q6v5.h"
+#include "remoteproc_internal.h"
+
+/* time out value */
+#define ACK_TIMEOUT1000
+#define BOOT_FSM_TIMEOUT   1
+/* mask values */
+#define EVB_MASK   GENMASK(27, 4)
+/*QDSP6SS register offsets*/
+#define RST_EVB_REG0x10
+#define CORE_START_REG 0x400
+#define BOOT_CMD_REG   0x404
+#define BOOT_STATUS_REG0x408
+#define RET_CFG_REG0x1C
+/*TCSR register offsets*/
+#define LPASS_MASTER_IDLE_REG  0x8
+#define LPASS_HALTACK_REG  0x4
+#define LPASS_PWR_ON_REG   0x10
+#define LPASS_HALTREQ_REG  0x0
+
+/* list of clocks required by ADSP PIL */
+static const char * const adsp_clk_id[] = {
+   "sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
+   "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
+};
+
+struct adsp_pil_data {
+   int crash_reason_smem;
+   const char *firmware_name;
+
+   const char *ssr_name;
+   const char *sysmon_name;
+   int ssctl_id;
+};
+
+struct qcom_adsp {
+   struct device *dev;
+   struct rproc *rproc;
+
+   struct qcom_q6v5 q6v5;
+
+   struct clk *xo;
+
+   int num_clks;
+   struct clk_bulk_data *clks;
+
+   void __iomem *qdsp6ss_base;
+
+   struct reset_control *pdc_sync_reset;
+   struct reset_control *cc_lpass_restart;
+
+   struct regmap *halt_map;
+   unsigned int halt_lpass;
+
+   int crash_reason_smem;
+
+   struct completion start_done;
+   struct completion stop_done;
+
+   phys_addr_t mem_phys;
+   phys_addr_t mem_reloc;
+   void *mem_region;
+   size_t mem_size;
+
+   struct qcom_rproc_glink glink_subdev;
+   struct qcom_rproc_ssr ssr_subdev;
+   struct qcom_sysmon *sysmon;
+};
+
+static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
+{
+   unsigned long timeout;
+   unsigned int val;
+   int 

[PATCH v4] remoteproc: qcom: Introduce Non-PAS ADSP PIL driver

2018-09-24 Thread Rohit kumar
This adds Non PAS ADSP PIL driver for Qualcomm
Technologies Inc SoCs.
Added initial support for SDM845 with ADSP bootup and
shutdown operation handled from Application Processor
SubSystem(APSS).

Signed-off-by: Rohit kumar 
---
Changes since v3:
Addressed comments posted by Sibi

This patch is dependent on the rpmh powerdomain driver 
https://lkml.org/lkml/2018/6/27/7
and renaming of Hexagon v5 PAS driver 
https://patchwork.kernel.org/patch/10601119/ .

 drivers/remoteproc/Kconfig |  14 ++
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/qcom_adsp_pil.c | 502 +
 3 files changed, 517 insertions(+)
 create mode 100644 drivers/remoteproc/qcom_adsp_pil.c

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 8894935..f554669 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -140,6 +140,20 @@ config QCOM_Q6V5_WCSS
  Say y here to support the Qualcomm Peripheral Image Loader for the
  Hexagon V5 based WCSS remote processors.
 
+config QCOM_ADSP_PIL
+   tristate "Qualcomm Technology Inc ADSP Peripheral Image Loader"
+   depends on OF && ARCH_QCOM
+   depends on QCOM_SMEM
+   depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
+   depends on QCOM_SYSMON || QCOM_SYSMON=n
+   select MFD_SYSCON
+   select QCOM_MDT_LOADER
+   select QCOM_Q6V5_COMMON
+   select QCOM_RPROC_COMMON
+   help
+ Say y here to support the Peripheral Image Loader
+ for the Qualcomm Technology Inc. ADSP remote processors.
+
 config QCOM_SYSMON
tristate "Qualcomm sysmon driver"
depends on RPMSG
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 050f41a..0e1b89c 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_QCOM_Q6V5_COMMON)+= qcom_q6v5.o
 obj-$(CONFIG_QCOM_Q6V5_MSS)+= qcom_q6v5_mss.o
 obj-$(CONFIG_QCOM_Q6V5_PAS)+= qcom_q6v5_pas.o
 obj-$(CONFIG_QCOM_Q6V5_WCSS)   += qcom_q6v5_wcss.o
+obj-$(CONFIG_QCOM_ADSP_PIL)+= qcom_adsp_pil.o
 obj-$(CONFIG_QCOM_SYSMON)  += qcom_sysmon.o
 obj-$(CONFIG_QCOM_WCNSS_PIL)   += qcom_wcnss_pil.o
 qcom_wcnss_pil-y   += qcom_wcnss.o
diff --git a/drivers/remoteproc/qcom_adsp_pil.c 
b/drivers/remoteproc/qcom_adsp_pil.c
new file mode 100644
index 000..f2f5e56
--- /dev/null
+++ b/drivers/remoteproc/qcom_adsp_pil.c
@@ -0,0 +1,502 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Qualcomm Technology Inc. ADSP Peripheral Image Loader for SDM845.
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "qcom_common.h"
+#include "qcom_q6v5.h"
+#include "remoteproc_internal.h"
+
+/* time out value */
+#define ACK_TIMEOUT1000
+#define BOOT_FSM_TIMEOUT   1
+/* mask values */
+#define EVB_MASK   GENMASK(27, 4)
+/*QDSP6SS register offsets*/
+#define RST_EVB_REG0x10
+#define CORE_START_REG 0x400
+#define BOOT_CMD_REG   0x404
+#define BOOT_STATUS_REG0x408
+#define RET_CFG_REG0x1C
+/*TCSR register offsets*/
+#define LPASS_MASTER_IDLE_REG  0x8
+#define LPASS_HALTACK_REG  0x4
+#define LPASS_PWR_ON_REG   0x10
+#define LPASS_HALTREQ_REG  0x0
+
+/* list of clocks required by ADSP PIL */
+static const char * const adsp_clk_id[] = {
+   "sway_cbcr", "lpass_aon", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
+   "qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
+};
+
+struct adsp_pil_data {
+   int crash_reason_smem;
+   const char *firmware_name;
+
+   const char *ssr_name;
+   const char *sysmon_name;
+   int ssctl_id;
+};
+
+struct qcom_adsp {
+   struct device *dev;
+   struct rproc *rproc;
+
+   struct qcom_q6v5 q6v5;
+
+   struct clk *xo;
+
+   int num_clks;
+   struct clk_bulk_data *clks;
+
+   void __iomem *qdsp6ss_base;
+
+   struct reset_control *pdc_sync_reset;
+   struct reset_control *cc_lpass_restart;
+
+   struct regmap *halt_map;
+   unsigned int halt_lpass;
+
+   int crash_reason_smem;
+
+   struct completion start_done;
+   struct completion stop_done;
+
+   phys_addr_t mem_phys;
+   phys_addr_t mem_reloc;
+   void *mem_region;
+   size_t mem_size;
+
+   struct qcom_rproc_glink glink_subdev;
+   struct qcom_rproc_ssr ssr_subdev;
+   struct qcom_sysmon *sysmon;
+};
+
+static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
+{
+   unsigned long timeout;
+   unsigned int val;
+   int