Re: [PATCH] soc: qcom: Introduce WCNSS_CTRL SMD client

2015-10-23 Thread Bjorn Andersson
On Fri, Oct 23, 2015 at 4:37 AM, yfw  wrote:
[..]
> Yes. I meant this remoteproc-wcnss driver. Will you try to upstream it?
>

https://lkml.org/lkml/2015/9/26/10

I thought I got you on the Cc on that series, sorry about that. I will
resend it once we have smsm/smp2p so that the kbuild robot doesn't
have a chance to shoot it down. (But no planned functional change so
far)

>>
>> Left is a mechanism to trigger the thing to boot and shutdown. One
>> potential solution would be to have the module_init/exit call
>> rproc_boot/shutdown from the WiFi & BT drivers. That way if one loads
>> the wcn36xx driver, the core is booted. This would also fit quite nicely
>> for other things - e.g. load the ALSA driver to trigger the ADSP
>> loading.
>>
>> The problem here is that we're then forced to either have a method of
>> deferring the rproc_boot() until the firmware is available or we always
>> must compile these drivers as kernel modules. This because the
>> file system isn't there during boot to provide the firmware.
>
> The firmware file could be put to initrd. That should allow wcn wifi driver
> builtin.
>

We have the same puzzle to solve for adsp, venus and the modem. And
the combined size of all these makes it practically infeasible to do
so.

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] soc: qcom: Introduce WCNSS_CTRL SMD client

2015-10-23 Thread yfw

Hi Bjorn,

On 2015/10/22 21:50, Bjorn Andersson wrote:

On Thu 22 Oct 03:25 PDT 2015, yfw wrote:


Hi Bjorn,

On 2015/9/22 1:52, Bjorn Andersson wrote:

[..]


I have a question: Do you have plan to add the nob to trigger wcnss firmware
downloading which is also common for wifi and BT?



In caf the wcnss driver is actually two drivers intermingled;
* a SMD client driver, responsible for pushing NV, something related to
   calibration, some power properties and so on

* a platform_driver implementing the wcnss specifics of the PIL through
   some hooks and providing the knob to trigger the PIL.

The first driver is related to the "OS" running on the wcnss, so that
should follow the life cycle of the SMD channel "WCNSS_CTRL". This is
what this patch provides - it loads the NV every time the wcnss core is
booted.


For the second part, I strongly believe that the PIL implementation
should deal with the specifics (e.g. regulator handling and
xo_calibration), rather than having a piece bolted on elsewhere - so
that's in the remoteproc-wcnss driver.


Yes. I meant this remoteproc-wcnss driver. Will you try to upstream it?



Left is a mechanism to trigger the thing to boot and shutdown. One
potential solution would be to have the module_init/exit call
rproc_boot/shutdown from the WiFi & BT drivers. That way if one loads
the wcn36xx driver, the core is booted. This would also fit quite nicely
for other things - e.g. load the ALSA driver to trigger the ADSP
loading.

The problem here is that we're then forced to either have a method of
deferring the rproc_boot() until the firmware is available or we always
must compile these drivers as kernel modules. This because the
file system isn't there during boot to provide the firmware.

The firmware file could be put to initrd. That should allow wcn wifi driver
builtin.



We do have the same thing in e.g. the Broadcom WiFi/BT solution and
there seems to be discussions related to this.


So for now, I punted and put a knob in the wcnss remoteproc driver.

Regards,
Bjorn



Regards
Yin, Fengwei

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] soc: qcom: Introduce WCNSS_CTRL SMD client

2015-10-22 Thread Bjorn Andersson
On Thu 22 Oct 03:25 PDT 2015, yfw wrote:

> Hi Bjorn,
> 
> On 2015/9/22 1:52, Bjorn Andersson wrote:
[..]
> 
> I have a question: Do you have plan to add the nob to trigger wcnss firmware
> downloading which is also common for wifi and BT?
> 

In caf the wcnss driver is actually two drivers intermingled;
* a SMD client driver, responsible for pushing NV, something related to
  calibration, some power properties and so on

* a platform_driver implementing the wcnss specifics of the PIL through
  some hooks and providing the knob to trigger the PIL.

The first driver is related to the "OS" running on the wcnss, so that
should follow the life cycle of the SMD channel "WCNSS_CTRL". This is
what this patch provides - it loads the NV every time the wcnss core is
booted.


For the second part, I strongly believe that the PIL implementation
should deal with the specifics (e.g. regulator handling and
xo_calibration), rather than having a piece bolted on elsewhere - so
that's in the remoteproc-wcnss driver.


Left is a mechanism to trigger the thing to boot and shutdown. One
potential solution would be to have the module_init/exit call
rproc_boot/shutdown from the WiFi & BT drivers. That way if one loads
the wcn36xx driver, the core is booted. This would also fit quite nicely
for other things - e.g. load the ALSA driver to trigger the ADSP
loading.

The problem here is that we're then forced to either have a method of
deferring the rproc_boot() until the firmware is available or we always
must compile these drivers as kernel modules. This because the
file system isn't there during boot to provide the firmware.

We do have the same thing in e.g. the Broadcom WiFi/BT solution and
there seems to be discussions related to this.


So for now, I punted and put a knob in the wcnss remoteproc driver.

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] soc: qcom: Introduce WCNSS_CTRL SMD client

2015-10-22 Thread yfw

Hi Bjorn,

On 2015/9/22 1:52, Bjorn Andersson wrote:

The WCNSS_CTRL SMD client is used for among other things upload nv
firmware to a newly booted WCNSS chip.

Signed-off-by: Bjorn Andersson 
---
This driver probes on the WCNSS_CTRL SMD channel as it comes up upon loading
the wcnss firmware, it currenly request version information from the wcnss and
downloads the nv binary.

This is needed for bringing up the individual functions of the wcnss chip.

  drivers/soc/qcom/Kconfig  |   7 ++
  drivers/soc/qcom/Makefile |   1 +
  drivers/soc/qcom/wcnss_ctrl.c | 272 ++
  3 files changed, 280 insertions(+)
  create mode 100644 drivers/soc/qcom/wcnss_ctrl.c

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index ba47b70f4d85..453ceb1af682 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -48,3 +48,10 @@ config QCOM_SMEM
  Say y here to enable support for the Qualcomm Shared Memory Manager.
  The driver provides an interface to items in a heap shared among all
  processors in a Qualcomm platform.
+
+config QCOM_WCNSS_CTRL
+   tristate "Qualcomm WCNSS control driver"
+   depends on QCOM_SMD
+   help
+ Client driver for the WCNSS_CTRL SMD channel, used to download nv
+ firmware to a newly booted WCNSS chip.
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 10a93d168e0e..9823103ea843 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_QCOM_PM)   +=  spm.o
  obj-$(CONFIG_QCOM_SMD) += smd.o
  obj-$(CONFIG_QCOM_SMD_RPM)+= smd-rpm.o
  obj-$(CONFIG_QCOM_SMEM) +=smem.o
+obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
diff --git a/drivers/soc/qcom/wcnss_ctrl.c b/drivers/soc/qcom/wcnss_ctrl.c
new file mode 100644
index ..7a986f881d5c
--- /dev/null
+++ b/drivers/soc/qcom/wcnss_ctrl.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2015, Sony Mobile Communications Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+
+#define WCNSS_REQUEST_TIMEOUT  (5 * HZ)
+
+#define NV_FRAGMENT_SIZE   3072
+#define NVBIN_FILE "wlan/prima/WCNSS_qcom_wlan_nv.bin"
+
+/**
+ * struct wcnss_ctrl - driver context
+ * @dev:   device handle
+ * @channel:   SMD channel handle
+ * @ack:   completion for outstanding requests
+ * @ack_status:status of the outstanding request
+ * @download_nv_work: worker for uploading nv binary
+ */
+struct wcnss_ctrl {
+   struct device *dev;
+   struct qcom_smd_channel *channel;
+
+   struct completion ack;
+   int ack_status;
+
+   struct work_struct download_nv_work;
+};
+
+/* message types */
+enum {
+   WCNSS_VERSION_REQ = 0x0100,
+   WCNSS_VERSION_RESP,
+   WCNSS_DOWNLOAD_NV_REQ,
+   WCNSS_DOWNLOAD_NV_RESP,
+   WCNSS_UPLOAD_CAL_REQ,
+   WCNSS_UPLOAD_CAL_RESP,
+   WCNSS_DOWNLOAD_CAL_REQ,
+   WCNSS_DOWNLOAD_CAL_RESP,
+};
+
+/**
+ * struct wcnss_msg_hdr - common packet header for requests and responses
+ * @type:  packet message type
+ * @len:   total length of the packet, including this header
+ */
+struct wcnss_msg_hdr {
+   u32 type;
+   u32 len;
+} __packed;
+
+/**
+ * struct wcnss_version_resp - version request response
+ * @hdr:   common packet wcnss_msg_hdr header
+ */
+struct wcnss_version_resp {
+   struct wcnss_msg_hdr hdr;
+   u8 major;
+   u8 minor;
+   u8 version;
+   u8 revision;
+} __packed;
+
+/**
+ * struct wcnss_download_nv_req - firmware fragment request
+ * @hdr:   common packet wcnss_msg_hdr header
+ * @seq:   sequence number of this fragment
+ * @last:  boolean indicator of this being the last fragment of the binary
+ * @frag_size: length of this fragment
+ * @fragment:  fragment data
+ */
+struct wcnss_download_nv_req {
+   struct wcnss_msg_hdr hdr;
+   u16 seq;
+   u16 last;
+   u32 frag_size;
+   u8 fragment[];
+} __packed;
+
+/**
+ * struct wcnss_download_nv_resp - firmware download response
+ * @hdr:   common packet wcnss_msg_hdr header
+ * @status:boolean to indicate success of the download
+ */
+struct wcnss_download_nv_resp {
+   struct wcnss_msg_hdr hdr;
+   u8 status;
+} __packed;
+
+/**
+ * wcnss_ctrl_smd_callback() - handler from SMD responses
+ * @qsdev: smd device handle
+ * @data:  pointer to the incoming data packet
+ * @count: size of the incoming data packet
+ *
+ * Handles any incoming packets from the remote W

Re: [PATCH] soc: qcom: Introduce WCNSS_CTRL SMD client

2015-09-22 Thread yfw
On Mon, Sep 21, 2015 at 10:52:55AM -0700, Bjorn Andersson wrote:
> The WCNSS_CTRL SMD client is used for among other things upload nv
> firmware to a newly booted WCNSS chip.
> 
> Signed-off-by: Bjorn Andersson 
> ---
> This driver probes on the WCNSS_CTRL SMD channel as it comes up upon loading
> the wcnss firmware, it currenly request version information from the wcnss and
> downloads the nv binary.
> 
> This is needed for bringing up the individual functions of the wcnss chip.
> 
>  drivers/soc/qcom/Kconfig  |   7 ++
>  drivers/soc/qcom/Makefile |   1 +
>  drivers/soc/qcom/wcnss_ctrl.c | 272 
> ++
>  3 files changed, 280 insertions(+)
>  create mode 100644 drivers/soc/qcom/wcnss_ctrl.c
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index ba47b70f4d85..453ceb1af682 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -48,3 +48,10 @@ config QCOM_SMEM
> Say y here to enable support for the Qualcomm Shared Memory Manager.
> The driver provides an interface to items in a heap shared among all
> processors in a Qualcomm platform.
> +
> +config QCOM_WCNSS_CTRL
> + tristate "Qualcomm WCNSS control driver"
> + depends on QCOM_SMD
> + help
> +   Client driver for the WCNSS_CTRL SMD channel, used to download nv
> +   firmware to a newly booted WCNSS chip.
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 10a93d168e0e..9823103ea843 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -3,3 +3,4 @@ obj-$(CONFIG_QCOM_PM) +=  spm.o
>  obj-$(CONFIG_QCOM_SMD) +=smd.o
>  obj-$(CONFIG_QCOM_SMD_RPM)   += smd-rpm.o
>  obj-$(CONFIG_QCOM_SMEM) +=   smem.o
> +obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
> diff --git a/drivers/soc/qcom/wcnss_ctrl.c b/drivers/soc/qcom/wcnss_ctrl.c
> new file mode 100644
> index ..7a986f881d5c
> --- /dev/null
> +++ b/drivers/soc/qcom/wcnss_ctrl.c
> @@ -0,0 +1,272 @@
> +/*
> + * Copyright (c) 2015, Sony Mobile Communications Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define WCNSS_REQUEST_TIMEOUT(5 * HZ)
> +
> +#define NV_FRAGMENT_SIZE 3072
> +#define NVBIN_FILE   "wlan/prima/WCNSS_qcom_wlan_nv.bin"
> +
> +/**
> + * struct wcnss_ctrl - driver context
> + * @dev: device handle
> + * @channel: SMD channel handle
> + * @ack: completion for outstanding requests
> + * @ack_status:  status of the outstanding request
> + * @download_nv_work: worker for uploading nv binary
> + */
> +struct wcnss_ctrl {
> + struct device *dev;
> + struct qcom_smd_channel *channel;
> +
> + struct completion ack;
> + int ack_status;
> +
> + struct work_struct download_nv_work;
> +};
> +
> +/* message types */
> +enum {
> + WCNSS_VERSION_REQ = 0x0100,
> + WCNSS_VERSION_RESP,
> + WCNSS_DOWNLOAD_NV_REQ,
> + WCNSS_DOWNLOAD_NV_RESP,
> + WCNSS_UPLOAD_CAL_REQ,
> + WCNSS_UPLOAD_CAL_RESP,
> + WCNSS_DOWNLOAD_CAL_REQ,
> + WCNSS_DOWNLOAD_CAL_RESP,
> +};
> +
> +/**
> + * struct wcnss_msg_hdr - common packet header for requests and responses
> + * @type:packet message type
> + * @len: total length of the packet, including this header
> + */
> +struct wcnss_msg_hdr {
> + u32 type;
> + u32 len;
> +} __packed;
> +
> +/**
> + * struct wcnss_version_resp - version request response
> + * @hdr: common packet wcnss_msg_hdr header
> + */
> +struct wcnss_version_resp {
> + struct wcnss_msg_hdr hdr;
> + u8 major;
> + u8 minor;
> + u8 version;
> + u8 revision;
> +} __packed;
> +
> +/**
> + * struct wcnss_download_nv_req - firmware fragment request
> + * @hdr: common packet wcnss_msg_hdr header
> + * @seq: sequence number of this fragment
> + * @last:boolean indicator of this being the last fragment of the binary
> + * @frag_size:   length of this fragment
> + * @fragment:fragment data
> + */
> +struct wcnss_download_nv_req {
> + struct wcnss_msg_hdr hdr;
> + u16 seq;
> + u16 last;
> + u32 frag_size;
> + u8 fragment[];
> +} __packed;
> +
> +/**
> + * struct wcnss_download_nv_resp - firmware download response
> + * @hdr: common packet wcnss_msg_hdr header
> + * @status:  boolean to indicate success of the download
> + */
> +struct wcnss_download_nv_resp {
> + struct wcnss_msg_hdr hdr;
> + u8 status;
> +} __packed;
> +
> +/**
> + * wcnss_ctrl_smd_callback() 

[PATCH] soc: qcom: Introduce WCNSS_CTRL SMD client

2015-09-21 Thread Bjorn Andersson
The WCNSS_CTRL SMD client is used for among other things upload nv
firmware to a newly booted WCNSS chip.

Signed-off-by: Bjorn Andersson 
---
This driver probes on the WCNSS_CTRL SMD channel as it comes up upon loading
the wcnss firmware, it currenly request version information from the wcnss and
downloads the nv binary.

This is needed for bringing up the individual functions of the wcnss chip.

 drivers/soc/qcom/Kconfig  |   7 ++
 drivers/soc/qcom/Makefile |   1 +
 drivers/soc/qcom/wcnss_ctrl.c | 272 ++
 3 files changed, 280 insertions(+)
 create mode 100644 drivers/soc/qcom/wcnss_ctrl.c

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index ba47b70f4d85..453ceb1af682 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -48,3 +48,10 @@ config QCOM_SMEM
  Say y here to enable support for the Qualcomm Shared Memory Manager.
  The driver provides an interface to items in a heap shared among all
  processors in a Qualcomm platform.
+
+config QCOM_WCNSS_CTRL
+   tristate "Qualcomm WCNSS control driver"
+   depends on QCOM_SMD
+   help
+ Client driver for the WCNSS_CTRL SMD channel, used to download nv
+ firmware to a newly booted WCNSS chip.
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 10a93d168e0e..9823103ea843 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_QCOM_PM)   +=  spm.o
 obj-$(CONFIG_QCOM_SMD) +=  smd.o
 obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) += smem.o
+obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
diff --git a/drivers/soc/qcom/wcnss_ctrl.c b/drivers/soc/qcom/wcnss_ctrl.c
new file mode 100644
index ..7a986f881d5c
--- /dev/null
+++ b/drivers/soc/qcom/wcnss_ctrl.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2015, Sony Mobile Communications Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include 
+#include 
+#include 
+#include 
+
+#define WCNSS_REQUEST_TIMEOUT  (5 * HZ)
+
+#define NV_FRAGMENT_SIZE   3072
+#define NVBIN_FILE "wlan/prima/WCNSS_qcom_wlan_nv.bin"
+
+/**
+ * struct wcnss_ctrl - driver context
+ * @dev:   device handle
+ * @channel:   SMD channel handle
+ * @ack:   completion for outstanding requests
+ * @ack_status:status of the outstanding request
+ * @download_nv_work: worker for uploading nv binary
+ */
+struct wcnss_ctrl {
+   struct device *dev;
+   struct qcom_smd_channel *channel;
+
+   struct completion ack;
+   int ack_status;
+
+   struct work_struct download_nv_work;
+};
+
+/* message types */
+enum {
+   WCNSS_VERSION_REQ = 0x0100,
+   WCNSS_VERSION_RESP,
+   WCNSS_DOWNLOAD_NV_REQ,
+   WCNSS_DOWNLOAD_NV_RESP,
+   WCNSS_UPLOAD_CAL_REQ,
+   WCNSS_UPLOAD_CAL_RESP,
+   WCNSS_DOWNLOAD_CAL_REQ,
+   WCNSS_DOWNLOAD_CAL_RESP,
+};
+
+/**
+ * struct wcnss_msg_hdr - common packet header for requests and responses
+ * @type:  packet message type
+ * @len:   total length of the packet, including this header
+ */
+struct wcnss_msg_hdr {
+   u32 type;
+   u32 len;
+} __packed;
+
+/**
+ * struct wcnss_version_resp - version request response
+ * @hdr:   common packet wcnss_msg_hdr header
+ */
+struct wcnss_version_resp {
+   struct wcnss_msg_hdr hdr;
+   u8 major;
+   u8 minor;
+   u8 version;
+   u8 revision;
+} __packed;
+
+/**
+ * struct wcnss_download_nv_req - firmware fragment request
+ * @hdr:   common packet wcnss_msg_hdr header
+ * @seq:   sequence number of this fragment
+ * @last:  boolean indicator of this being the last fragment of the binary
+ * @frag_size: length of this fragment
+ * @fragment:  fragment data
+ */
+struct wcnss_download_nv_req {
+   struct wcnss_msg_hdr hdr;
+   u16 seq;
+   u16 last;
+   u32 frag_size;
+   u8 fragment[];
+} __packed;
+
+/**
+ * struct wcnss_download_nv_resp - firmware download response
+ * @hdr:   common packet wcnss_msg_hdr header
+ * @status:boolean to indicate success of the download
+ */
+struct wcnss_download_nv_resp {
+   struct wcnss_msg_hdr hdr;
+   u8 status;
+} __packed;
+
+/**
+ * wcnss_ctrl_smd_callback() - handler from SMD responses
+ * @qsdev: smd device handle
+ * @data:  pointer to the incoming data packet
+ * @count: size of the incoming data packet
+ *
+ * Handles any incoming packets from the remote WCNSS_CTRL service.
+ */
+static int wcnss_ctrl_smd_callback(