Re: [PATCH v6 2/3] mfd: qcom-rpm: Driver for the Qualcomm RPM

2014-09-04 Thread Lee Jones
On Mon, 25 Aug 2014, Bjorn Andersson wrote:

> Driver for the Resource Power Manager (RPM) found in Qualcomm 8660, 8960
> and 8064 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 
> ---
>  drivers/mfd/Kconfig  |   14 +
>  drivers/mfd/Makefile |1 +
>  drivers/mfd/qcom_rpm.c   |  580 
> ++
>  include/linux/mfd/qcom_rpm.h |   10 +
>  4 files changed, 605 insertions(+)
>  create mode 100644 drivers/mfd/qcom_rpm.c
>  create mode 100644 include/linux/mfd/qcom_rpm.h

I'd like to take this in with the other MFD patch.

Is the regulator one okay to go in on it's own?

Acked-by: Lee Jones 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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 v6 2/3] mfd: qcom-rpm: Driver for the Qualcomm RPM

2014-08-25 Thread Bjorn Andersson
Driver for the Resource Power Manager (RPM) found in Qualcomm 8660, 8960
and 8064 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 
---
 drivers/mfd/Kconfig  |   14 +
 drivers/mfd/Makefile |1 +
 drivers/mfd/qcom_rpm.c   |  580 ++
 include/linux/mfd/qcom_rpm.h |   10 +
 4 files changed, 605 insertions(+)
 create mode 100644 drivers/mfd/qcom_rpm.c
 create mode 100644 include/linux/mfd/qcom_rpm.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index de5abf2..6743e88 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -539,6 +539,20 @@ config MFD_PM8921_CORE
  Say M here if you want to include support for PM8921 chip as a module.
  This will build a module called "pm8921-core".
 
+config MFD_QCOM_RPM
+   tristate "Qualcomm Resource Power Manager (RPM)"
+   depends on ARCH_QCOM && OF
+   help
+ If you say yes to this option, support will be included for the
+ Resource Power Manager system found in the Qualcomm 8660, 8960 and
+ 8064 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_rpm".
+
 config MFD_RDC321X
tristate "RDC R-321x southbridge"
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index f001487..3f2fc89 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -153,6 +153,7 @@ obj-$(CONFIG_MFD_SI476X_CORE)   += si476x-core.o
 obj-$(CONFIG_MFD_CS5535)   += cs5535-mfd.o
 obj-$(CONFIG_MFD_OMAP_USB_HOST)+= omap-usb-host.o omap-usb-tll.o
 obj-$(CONFIG_MFD_PM8921_CORE)  += pm8921-core.o ssbi.o
+obj-$(CONFIG_MFD_QCOM_RPM) += qcom_rpm.o
 obj-$(CONFIG_TPS65911_COMPARATOR)  += tps65911-comparator.o
 obj-$(CONFIG_MFD_TPS65090) += tps65090.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
diff --git a/drivers/mfd/qcom_rpm.c b/drivers/mfd/qcom_rpm.c
new file mode 100644
index 000..f006433
--- /dev/null
+++ b/drivers/mfd/qcom_rpm.c
@@ -0,0 +1,580 @@
+/*
+ * Copyright (c) 2014, Sony Mobile Communications AB.
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Author: Bjorn Andersson 
+ *
+ * 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 
+#include 
+
+#include 
+
+struct qcom_rpm_resource {
+   unsigned target_id;
+   unsigned status_id;
+   unsigned select_id;
+   unsigned size;
+};
+
+struct qcom_rpm_data {
+   u32 version;
+   const struct qcom_rpm_resource *resource_table;
+   unsigned n_resources;
+};
+
+struct qcom_rpm {
+   struct device *dev;
+   struct regmap *ipc_regmap;
+   unsigned ipc_offset;
+   unsigned ipc_bit;
+
+   struct completion ack;
+   struct mutex lock;
+
+   void __iomem *status_regs;
+   void __iomem *ctrl_regs;
+   void __iomem *req_regs;
+
+   u32 ack_status;
+
+   const struct qcom_rpm_data *data;
+};
+
+#define RPM_STATUS_REG(rpm, i) ((rpm)->status_regs + (i) * 4)
+#define RPM_CTRL_REG(rpm, i)   ((rpm)->ctrl_regs + (i) * 4)
+#define RPM_REQ_REG(rpm, i)((rpm)->req_regs + (i) * 4)
+
+#define RPM_REQUEST_TIMEOUT(5 * HZ)
+
+#define RPM_REQUEST_CONTEXT3
+#define RPM_REQ_SELECT 11
+#define RPM_ACK_CONTEXT15
+#define RPM_ACK_SELECTOR   23
+#define RPM_SELECT_SIZE7
+
+#define RPM_ACTIVE_STATE   BIT(0)
+#define RPM_NOTIFICATION   BIT(30)
+#define RPM_REJECTED   BIT(31)
+
+#define RPM_SIGNAL BIT(2)
+
+static const struct qcom_rpm_resource apq8064_rpm_resource_table[] = {
+   [QCOM_RPM_CXO_CLK] ={ 25, 9, 5, 1 },
+   [QCOM_RPM_PXO_CLK] ={ 26, 10, 6, 1 },
+   [QCOM_RPM_APPS_FABRIC_CLK] ={ 27, 11, 8, 1 },
+   [QCOM_RPM_SYS_FABRIC_CLK] = { 28, 12, 9, 1 },
+   [QCOM_RPM_MM_FABRIC_CLK] =  { 29, 13, 10, 1 },
+   [QCOM_RPM_DAYTONA_FABRIC_CLK] = { 30, 14, 11, 1 },
+   [QCOM_RPM_SFPB_CLK] =   { 31, 15, 12, 1 },
+   [QCOM_RPM_CFPB_CLK] =   { 32, 16, 13, 1 },
+   [QCOM_RPM_MMFPB_CLK] =  { 33, 17, 14, 1 },
+   [QCOM_RPM_EBI1