Re: [PATCH v3 4/5] soc: qcom: Driver for the Qualcomm RPM over SMD

2015-07-29 Thread Andy Gross
On Mon, Jul 27, 2015 at 08:20:32PM -0700, Bjorn Andersson wrote:
> Driver for the Resource Power Manager (RPM) found in Qualcomm 8974 based
> devices.
> The driver exposes resources that child drivers can operate on; to
> implementing regulator, clock and bus frequency drivers.
> 
> Signed-off-by: Bjorn Andersson 
> ---

Applied, thanks!

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 4/5] soc: qcom: Driver for the Qualcomm RPM over SMD

2015-07-29 Thread Andy Gross
On Mon, Jul 27, 2015 at 08:20:32PM -0700, Bjorn Andersson wrote:
 Driver for the Resource Power Manager (RPM) found in Qualcomm 8974 based
 devices.
 The driver exposes resources that child drivers can operate on; to
 implementing regulator, clock and bus frequency drivers.
 
 Signed-off-by: Bjorn Andersson bjorn.anders...@sonymobile.com
 ---

Applied, thanks!

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 4/5] soc: qcom: Driver for the Qualcomm RPM over SMD

2015-07-27 Thread Bjorn Andersson
Driver for the Resource Power Manager (RPM) found in Qualcomm 8974 based
devices.
The driver exposes resources that child drivers can operate on; to
implementing regulator, clock and bus frequency drivers.

Signed-off-by: Bjorn Andersson 
---

Changes since v2:
- Updated error handling path in RPM driver
- Moved to arch_initcall
- Moved from mfd

 drivers/soc/qcom/Kconfig |  14 +++
 drivers/soc/qcom/Makefile|   1 +
 drivers/soc/qcom/smd-rpm.c   | 244 +++
 include/linux/soc/qcom/smd-rpm.h |  35 ++
 4 files changed, 294 insertions(+)
 create mode 100644 drivers/soc/qcom/smd-rpm.c
 create mode 100644 include/linux/soc/qcom/smd-rpm.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 5c1a067b6677..65181d5d7574 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -26,6 +26,20 @@ config QCOM_SMD
  providing communication channels to remote processors in Qualcomm
  platforms.
 
+config QCOM_SMD_RPM
+   tristate "Qualcomm Resource Power Manager (RPM) over SMD"
+   depends on QCOM_SMD && OF
+   help
+ If you say yes to this option, support will be included for the
+ Resource Power Manager system found in the Qualcomm 8974 based
+ devices.
+
+ This is required to access many regulators, clocks and bus
+ frequencies controlled by the RPM on these devices.
+
+ Say M here if you want to include support for the Qualcomm RPM as a
+ module. This will build a module called "qcom-smd-rpm".
+
 config QCOM_SMEM
tristate "Qualcomm Shared Memory Manager (SMEM)"
depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index f961a8796ed2..10a93d168e0e 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_QCOM_GSBI)+=  qcom_gsbi.o
 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
diff --git a/drivers/soc/qcom/smd-rpm.c b/drivers/soc/qcom/smd-rpm.c
new file mode 100644
index ..1392ccf14a20
--- /dev/null
+++ b/drivers/soc/qcom/smd-rpm.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2015, Sony Mobile Communications AB.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * 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 
+#include 
+
+#include 
+#include 
+
+#define RPM_REQUEST_TIMEOUT (5 * HZ)
+
+/**
+ * struct qcom_smd_rpm - state of the rpm device driver
+ * @rpm_channel:   reference to the smd channel
+ * @ack:   completion for acks
+ * @lock:  mutual exclusion around the send/complete pair
+ * @ack_status:result of the rpm request
+ */
+struct qcom_smd_rpm {
+   struct qcom_smd_channel *rpm_channel;
+
+   struct completion ack;
+   struct mutex lock;
+   int ack_status;
+};
+
+/**
+ * struct qcom_rpm_header - header for all rpm requests and responses
+ * @service_type:  identifier of the service
+ * @length:length of the payload
+ */
+struct qcom_rpm_header {
+   u32 service_type;
+   u32 length;
+};
+
+/**
+ * struct qcom_rpm_request - request message to the rpm
+ * @msg_id:identifier of the outgoing message
+ * @flags: active/sleep state flags
+ * @type:  resource type
+ * @id:resource id
+ * @data_len:  length of the payload following this header
+ */
+struct qcom_rpm_request {
+   u32 msg_id;
+   u32 flags;
+   u32 type;
+   u32 id;
+   u32 data_len;
+};
+
+/**
+ * struct qcom_rpm_message - response message from the rpm
+ * @msg_type:  indicator of the type of message
+ * @length:the size of this message, including the message header
+ * @msg_id:message id
+ * @message:   textual message from the rpm
+ *
+ * Multiple of these messages can be stacked in an rpm message.
+ */
+struct qcom_rpm_message {
+   u32 msg_type;
+   u32 length;
+   union {
+   u32 msg_id;
+   u8 message[0];
+   };
+};
+
+#define RPM_SERVICE_TYPE_REQUEST   0x00716572 /* "req\0" */
+
+#define RPM_MSG_TYPE_ERR   0x00727265 /* "err\0" */
+#define RPM_MSG_TYPE_MSG_ID0x2367736d /* "msg#" */
+
+/**
+ * qcom_rpm_smd_write - write @buf to @type:@id
+ * @rpm:   rpm handle
+ * @type:  resource type
+ * @id:resource identifier
+ * @buf:   the data to be 

[PATCH v3 4/5] soc: qcom: Driver for the Qualcomm RPM over SMD

2015-07-27 Thread Bjorn Andersson
Driver for the Resource Power Manager (RPM) found in Qualcomm 8974 based
devices.
The driver exposes resources that child drivers can operate on; to
implementing regulator, clock and bus frequency drivers.

Signed-off-by: Bjorn Andersson bjorn.anders...@sonymobile.com
---

Changes since v2:
- Updated error handling path in RPM driver
- Moved to arch_initcall
- Moved from mfd

 drivers/soc/qcom/Kconfig |  14 +++
 drivers/soc/qcom/Makefile|   1 +
 drivers/soc/qcom/smd-rpm.c   | 244 +++
 include/linux/soc/qcom/smd-rpm.h |  35 ++
 4 files changed, 294 insertions(+)
 create mode 100644 drivers/soc/qcom/smd-rpm.c
 create mode 100644 include/linux/soc/qcom/smd-rpm.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 5c1a067b6677..65181d5d7574 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -26,6 +26,20 @@ config QCOM_SMD
  providing communication channels to remote processors in Qualcomm
  platforms.
 
+config QCOM_SMD_RPM
+   tristate Qualcomm Resource Power Manager (RPM) over SMD
+   depends on QCOM_SMD  OF
+   help
+ If you say yes to this option, support will be included for the
+ Resource Power Manager system found in the Qualcomm 8974 based
+ devices.
+
+ This is required to access many regulators, clocks and bus
+ frequencies controlled by the RPM on these devices.
+
+ Say M here if you want to include support for the Qualcomm RPM as a
+ module. This will build a module called qcom-smd-rpm.
+
 config QCOM_SMEM
tristate Qualcomm Shared Memory Manager (SMEM)
depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index f961a8796ed2..10a93d168e0e 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_QCOM_GSBI)+=  qcom_gsbi.o
 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
diff --git a/drivers/soc/qcom/smd-rpm.c b/drivers/soc/qcom/smd-rpm.c
new file mode 100644
index ..1392ccf14a20
--- /dev/null
+++ b/drivers/soc/qcom/smd-rpm.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2015, Sony Mobile Communications AB.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * 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 linux/module.h
+#include linux/platform_device.h
+#include linux/of_platform.h
+#include linux/io.h
+#include linux/interrupt.h
+
+#include linux/soc/qcom/smd.h
+#include linux/soc/qcom/smd-rpm.h
+
+#define RPM_REQUEST_TIMEOUT (5 * HZ)
+
+/**
+ * struct qcom_smd_rpm - state of the rpm device driver
+ * @rpm_channel:   reference to the smd channel
+ * @ack:   completion for acks
+ * @lock:  mutual exclusion around the send/complete pair
+ * @ack_status:result of the rpm request
+ */
+struct qcom_smd_rpm {
+   struct qcom_smd_channel *rpm_channel;
+
+   struct completion ack;
+   struct mutex lock;
+   int ack_status;
+};
+
+/**
+ * struct qcom_rpm_header - header for all rpm requests and responses
+ * @service_type:  identifier of the service
+ * @length:length of the payload
+ */
+struct qcom_rpm_header {
+   u32 service_type;
+   u32 length;
+};
+
+/**
+ * struct qcom_rpm_request - request message to the rpm
+ * @msg_id:identifier of the outgoing message
+ * @flags: active/sleep state flags
+ * @type:  resource type
+ * @id:resource id
+ * @data_len:  length of the payload following this header
+ */
+struct qcom_rpm_request {
+   u32 msg_id;
+   u32 flags;
+   u32 type;
+   u32 id;
+   u32 data_len;
+};
+
+/**
+ * struct qcom_rpm_message - response message from the rpm
+ * @msg_type:  indicator of the type of message
+ * @length:the size of this message, including the message header
+ * @msg_id:message id
+ * @message:   textual message from the rpm
+ *
+ * Multiple of these messages can be stacked in an rpm message.
+ */
+struct qcom_rpm_message {
+   u32 msg_type;
+   u32 length;
+   union {
+   u32 msg_id;
+   u8 message[0];
+   };
+};
+
+#define RPM_SERVICE_TYPE_REQUEST   0x00716572 /* req\0 */
+
+#define RPM_MSG_TYPE_ERR   0x00727265 /* err\0 */
+#define RPM_MSG_TYPE_MSG_ID0x2367736d /* msg# */
+
+/**
+ * qcom_rpm_smd_write - write @buf to