Re: [PATCH v3] Input: pmic8xxx-pwrkey - Support shutdown

2015-07-17 Thread Dmitry Torokhov
On Tue, Jul 14, 2015 at 01:18:52PM -0700, Bjorn Andersson wrote:
> On Tue 14 Jul 12:05 PDT 2015, Stephen Boyd wrote:
> 
> > On pm8xxx PMICs, shutdown and restart are signaled to the PMIC
> > via a pin called PS_HOLD. When this pin goes low, the PMIC
> > performs a configurable power sequence. Add a .shutdown hook so
> > that we can properly configure this power sequence for shutdown
> > or restart depending on the system state.
> > 
> > Cc: Bjorn Andersson 
> > Signed-off-by: Stephen Boyd 
> > ---
> > 
> > Changes since v2:
> >  * s/ret/error/
> >  * Use of_device_get_match_data() and don't move match table
> >  * Fix whitespace errors
> > 
> 
> Reviewed-by: Bjorn Andersson 
> 
> And thanks for finding of_device_get_match_data()

Thanks, I'll apply when I sync with mainline and pull in
of_device_get_match_data(). Shout if you do not see it in next in a
week.

Thanks.

-- 
Dmitry
--
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


[PATCH v4 2/2] regulator: qcom-spmi: Add vendor specific configuration

2015-07-17 Thread Stephen Boyd
Add support for over current protection (OCP), pin control
selection, soft start strength, and auto-mode.

Cc: 
Signed-off-by: Stephen Boyd 
---

Notes:
Changes from v3:
* Split this patch out from rest of driver
* Moved auto mode into regulator-init-mode and made it equal to FAST mode
* Moved qcom,ocp-enable to regulator-over-current-protection property

Changes from v1:
* New patch split from orignal SPMI regulator driver

 .../bindings/regulator/qcom,spmi-regulator.txt |  60 ++-
 drivers/regulator/qcom_spmi-regulator.c| 200 -
 2 files changed, 251 insertions(+), 9 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt 
b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt
index 75b4604bad07..d00bfd8624a5 100644
--- a/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt
@@ -91,13 +91,65 @@ see regulator.txt - with additional custom properties 
described below:
 - regulator-initial-mode:
Usage: optional
Value type: 
-   Descrption: 1 = Set initial mode to high power mode (HPM), also referred
-   to as NPM.  HPM consumes more ground current than LPM, but
+   Description: 2 = Set initial mode to auto mode (automatically select
+   between HPM and LPM); not available on boost type
+   regulators.
+
+   1 = Set initial mode to high power mode (HPM), also referred
+   to as NPM. HPM consumes more ground current than LPM, but
it can source significantly higher load current. HPM is not
available on boost type regulators. For voltage switch type
regulators, HPM implies that over current protection and
-   soft start are active all the time. 0 = Set initial mode to
-   low power mode (LPM).
+   soft start are active all the time.
+
+   0 = Set initial mode to low power mode (LPM).
+
+- qcom,ocp-max-retries:
+   Usage: optional
+   Value type: 
+   Description: Maximum number of times to try toggling a voltage switch
+off and back on as a result of consecutive over current
+events.
+
+- qcom,ocp-retry-delay:
+   Usage: optional
+   Value type: 
+   Description: Time to delay in milliseconds between each voltage switch
+toggle after an over current event takes place.
+
+- qcom,pin-ctrl-enable:
+   Usage: optional
+   Value type: 
+   Description: Bit mask specifying which hardware pins should be used to
+enable the regulator, if any; supported bits are:
+   0 = ignore all hardware enable signals
+   BIT(0) = follow HW0_EN signal
+   BIT(1) = follow HW1_EN signal
+   BIT(2) = follow HW2_EN signal
+   BIT(3) = follow HW3_EN signal
+
+- qcom,pin-ctrl-hpm:
+   Usage: optional
+   Value type: 
+   Description: Bit mask specifying which hardware pins should be used to
+force the regulator into high power mode, if any;
+supported bits are:
+   0 = ignore all hardware enable signals
+   BIT(0) = follow HW0_EN signal
+   BIT(1) = follow HW1_EN signal
+   BIT(2) = follow HW2_EN signal
+   BIT(3) = follow HW3_EN signal
+   BIT(4) = follow PMIC awake state
+
+- qcom,vs-soft-start-strength:
+   Usage: optional
+   Value type: 
+   Description: This property sets the soft start strength for voltage
+switch type regulators; supported values are:
+   0 = 0.05 uA
+   1 = 0.25 uA
+   2 = 0.55 uA
+   3 = 0.75 uA
 
 Example:
 
diff --git a/drivers/regulator/qcom_spmi-regulator.c 
b/drivers/regulator/qcom_spmi-regulator.c
index 850a30a95b5b..638600696b4d 100644
--- a/drivers/regulator/qcom_spmi-regulator.c
+++ b/drivers/regulator/qcom_spmi-regulator.c
@@ -26,6 +26,70 @@
 #include 
 #include 
 
+/* Pin control enable input pins. */
+#define SPMI_REGULATOR_PIN_CTRL_ENABLE_NONE0x00
+#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN0 0x01
+#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN1 0x02
+#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN2 0x04
+#define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN3 0x08
+#define SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT  0x10
+
+/* Pin control high power mode input pins. */
+#define SPMI_REGULATOR_PIN_CTRL_HPM_NONE   0x00
+#define SPMI_REGULATOR_PIN_CTRL_HPM_EN00x01
+#define SPMI_REGULATOR_PIN_CTRL_HPM_EN1

[PATCH v4 1/2] regulator: Add over current protection (OCP) support

2015-07-17 Thread Stephen Boyd
Some regulators can automatically shut down when they detect an
over current event. Add an op (set_over_current_protection) and a
DT property + constraint to support this capability.

Cc: Rob Herring 
Signed-off-by: Stephen Boyd 
---

Changes since v3:
 * New patch

 Documentation/devicetree/bindings/regulator/regulator.txt | 1 +
 drivers/regulator/core.c  | 9 +
 drivers/regulator/of_regulator.c  | 3 +++
 include/linux/regulator/driver.h  | 1 +
 include/linux/regulator/machine.h | 1 +
 5 files changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt 
b/Documentation/devicetree/bindings/regulator/regulator.txt
index db88feb28c03..24bd422cecd5 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -42,6 +42,7 @@ Optional properties:
 - regulator-system-load: Load in uA present on regulator that is not captured 
by
   any consumer request.
 - regulator-pull-down: Enable pull down resistor when the regulator is 
disabled.
+- regulator-over-current-protection: Enable over current protection.
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c9f72019bd68..520413e2bca0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1081,6 +1081,15 @@ static int set_machine_constraints(struct regulator_dev 
*rdev,
}
}
 
+   if (rdev->constraints->over_current_protection
+   && ops->set_over_current_protection) {
+   ret = ops->set_over_current_protection(rdev);
+   if (ret < 0) {
+   rdev_err(rdev, "failed to set over current 
protection\n");
+   goto out;
+   }
+   }
+
print_constraints(rdev);
return 0;
 out:
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index b1c485b24ab2..250700c853bf 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -107,6 +107,9 @@ static void of_get_regulation_constraints(struct 
device_node *np,
if (!of_property_read_u32(np, "regulator-system-load", &pval))
constraints->system_load = pval;
 
+   constraints->over_current_protection = of_property_read_bool(np,
+   "regulator-over-current-protection");
+
for (i = 0; i < ARRAY_SIZE(regulator_states); i++) {
switch (i) {
case PM_SUSPEND_MEM:
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 4db9fbe4889d..45932228cbf5 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -148,6 +148,7 @@ struct regulator_ops {
int (*get_current_limit) (struct regulator_dev *);
 
int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
+   int (*set_over_current_protection) (struct regulator_dev *);
 
/* enable/disable regulator */
int (*enable) (struct regulator_dev *);
diff --git a/include/linux/regulator/machine.h 
b/include/linux/regulator/machine.h
index b11be1260129..a1067d0b3991 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -147,6 +147,7 @@ struct regulation_constraints {
unsigned ramp_disable:1; /* disable ramp delay */
unsigned soft_start:1;  /* ramp voltage slowly */
unsigned pull_down:1;   /* pull down resistor when regulator off */
+   unsigned over_current_protection:1; /* auto disable on over current */
 };
 
 /**
-- 
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-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/2] SPMI regulator driver updates

2015-07-17 Thread Stephen Boyd
This is the leftover parts of the SPMI regulator driver port. The
OCP feature and other vendor specific DT bindings that didn't make
v4.2. I've added a hook to configure OCP per 

Stephen Boyd (2):
  regulator: Add over current protection (OCP) support
  regulator: qcom-spmi: Add vendor specific configuration

 .../bindings/regulator/qcom,spmi-regulator.txt |  60 ++-
 .../devicetree/bindings/regulator/regulator.txt|   1 +
 drivers/regulator/core.c   |   9 +
 drivers/regulator/of_regulator.c   |   3 +
 drivers/regulator/qcom_spmi-regulator.c| 200 -
 include/linux/regulator/driver.h   |   1 +
 include/linux/regulator/machine.h  |   1 +
 7 files changed, 266 insertions(+), 9 deletions(-)

-- 
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-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 v2 02/11] soc: qcom: Add Shared Memory Manager driver

2015-07-17 Thread Andy Gross
On Fri, Jun 26, 2015 at 02:50:10PM -0700, bj...@kryo.se wrote:
> From: Bjorn Andersson 
> 
> The Shared Memory Manager driver implements an interface for allocating
> and accessing items in the memory area shared among all of the
> processors in a Qualcomm platform.
> 
> Signed-off-by: Bjorn Andersson 

Acked-by: Andy Gross 

-- 
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-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 v2 7/8] mfd: pm8921: Implement irq_get_irqchip_state

2015-07-17 Thread Linus Walleij
On Fri, Jul 17, 2015 at 2:33 PM, Linus Walleij  wrote:
> On Wed, Jul 15, 2015 at 8:40 AM, Bjorn Andersson
>  wrote:
>
>> Implement irq_chip->irq_get_irqchip_state to make it possible for PMIC
>> block drivers to access the IRQ real time status bits. The status bits
>> are used for various kinds of input signals, e.g. GPIO.
>>
>> Signed-off-by: Bjorn Andersson 
>> ---
>>
>> Changes since v1:
>> - Drop extra check for !chip
>> - Simplify return value
>
> This v2 version applied for v4.3.

Oh wait why did I do that, that's not my driver :)

Dropped it. Lee can take it in his MFD tree.

Acked-by: Linus Walleij 

Yours,
Linus Walleij
--
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


[RFC PATCH 4/4] iommu/arm-smmu: Add support for specifying regulators

2015-07-17 Thread Sricharan R
From: Mitchel Humpherys 

This adds the support to turn on the regulators required
for SMMUs. It is turned on during the SMMU probe and remains
'on' till the device exists.

Signed-off-by: Sricharan R 
---
 .../devicetree/bindings/iommu/arm,smmu.txt |  3 ++
 drivers/iommu/arm-smmu.c   | 48 +-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt 
b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index c2cf4fe..433d778 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -60,6 +60,9 @@ conditions.
  Documentation/devicetree/bindings/clock/clock-bindings.txt
  for more info.
 
+- vdd-supply: Phandle of the regulator that should be powered on during
+  SMMU register access.
+
 Example:
 
 smmu {
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 80d56f0a..c92de50 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -326,6 +326,8 @@ struct arm_smmu_device {
 
int num_clocks;
struct clk  **clocks;
+
+   struct regulator*regulator;
 };
 
 struct arm_smmu_cfg {
@@ -559,6 +561,22 @@ static void __arm_smmu_free_bitmap(unsigned long *map, int 
idx)
clear_bit(idx, map);
 }
 
+static int arm_smmu_enable_regulators(struct arm_smmu_device *smmu)
+{
+   if (!smmu->regulator)
+   return 0;
+
+   return regulator_enable(smmu->regulator);
+}
+
+static int arm_smmu_disable_regulators(struct arm_smmu_device *smmu)
+{
+   if (!smmu->regulator)
+   return 0;
+
+   return regulator_disable(smmu->regulator);
+}
+
 /* Wait for any pending TLB invalidations to complete */
 static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu)
 {
@@ -1583,6 +1601,20 @@ static int arm_smmu_id_size_to_bits(int size)
}
 }
 
+static int arm_smmu_init_regulators(struct arm_smmu_device *smmu)
+{
+   struct device *dev = smmu->dev;
+
+   if (!of_get_property(dev->of_node, "vdd-supply", NULL))
+   return 0;
+
+   smmu->regulator = devm_regulator_get(dev, "vdd");
+   if (IS_ERR(smmu->regulator))
+   return PTR_ERR(smmu->regulator);
+
+   return 0;
+}
+
 static int arm_smmu_init_clocks(struct arm_smmu_device *smmu)
 {
const char *cname;
@@ -1841,11 +1873,21 @@ static int arm_smmu_device_dt_probe(struct 
platform_device *pdev)
smmu->irqs[i] = irq;
}
 
+   err = arm_smmu_init_regulators(smmu);
+   if (err)
+   goto out_put_masters;
+
err = arm_smmu_init_clocks(smmu);
if (err)
goto out_put_masters;
 
-   arm_smmu_enable_clocks(smmu);
+   err = arm_smmu_enable_regulators(smmu);
+   if (err)
+   goto out_put_masters;
+
+   err = arm_smmu_enable_clocks(smmu);
+   if (err)
+   goto out_disable_regulators;
 
err = arm_smmu_device_cfg_probe(smmu);
if (err)
@@ -1908,6 +1950,9 @@ out_free_irqs:
 out_disable_clocks:
arm_smmu_disable_clocks(smmu);
 
+out_disable_regulators:
+   arm_smmu_disable_regulators(smmu);
+
 out_put_masters:
for (node = rb_first(&smmu->masters); node; node = rb_next(node)) {
struct arm_smmu_master *master
@@ -1953,6 +1998,7 @@ static int arm_smmu_device_remove(struct platform_device 
*pdev)
/* Turn the thing off */
writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0);
arm_smmu_disable_clocks(smmu);
+   arm_smmu_disable_regulators(smmu);
 
return 0;
 }
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation

--
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


[RFC PATCH 2/4] iommu/arm-smmu: Add xlate callback for initializing master devices from dt

2015-07-17 Thread Sricharan R
This adds of_xlate callback to arm-smmu driver. xlate callback
is called during device registration from DT for those master
devices attached to iommus using generic iommu bindings.

Signed-off-by: Sricharan R 
---
 drivers/iommu/arm-smmu.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 8c4eb43..2cf65ab 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -321,6 +321,7 @@ struct arm_smmu_device {
unsigned int*irqs;
 
struct list_headlist;
+   struct device_node  *node;
struct rb_root  masters;
 };
 
@@ -1434,6 +1435,38 @@ out_unlock:
return ret;
 }
 
+static int arm_smmu_of_xlate(struct device *dev,
+struct of_phandle_args *spec)
+{
+   struct arm_smmu_device *smmu;
+   struct arm_smmu_master *master;
+   int streamid;
+
+   spin_lock(&arm_smmu_devices_lock);
+   list_for_each_entry(smmu, &arm_smmu_devices, list) {
+   if (smmu->node == spec->np)
+   break;
+   }
+   spin_unlock(&arm_smmu_devices_lock);
+
+   if (!smmu || (smmu->node != spec->np))
+   return -ENODEV;
+
+   spec->np = dev->of_node;
+
+   master = find_smmu_master(smmu, spec->np);
+   if (!master) {
+   if (register_smmu_master(smmu, smmu->dev, spec))
+   return -ENODEV;
+   } else {
+   streamid = master->cfg.num_streamids;
+   master->cfg.streamids[streamid] = spec->args[0];
+   master->cfg.num_streamids++;
+   }
+
+   return 0;
+}
+
 static struct iommu_ops arm_smmu_ops = {
.capable= arm_smmu_capable,
.domain_init= arm_smmu_domain_init,
@@ -1449,6 +1482,7 @@ static struct iommu_ops arm_smmu_ops = {
.domain_get_attr= arm_smmu_domain_get_attr,
.domain_set_attr= arm_smmu_domain_set_attr,
.pgsize_bitmap  = -1UL, /* Restricted during device attach */
+   .of_xlate   = arm_smmu_of_xlate,
 };
 
 static void arm_smmu_device_reset(struct arm_smmu_device *smmu)
@@ -1782,6 +1816,8 @@ static int arm_smmu_device_dt_probe(struct 
platform_device *pdev)
}
}
 
+   smmu->node = dev->of_node;
+
INIT_LIST_HEAD(&smmu->list);
spin_lock(&arm_smmu_devices_lock);
list_add(&smmu->list, &arm_smmu_devices);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation

--
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


[RFC PATCH 1/4] iommu/arm-smmu: Init driver using IOMMU_OF_DECLARE

2015-07-17 Thread Sricharan R
This patch uses IOMMU_OF_DECLARE to register the driver
and the iommu_ops. So when master devices of the iommu are
registered, of_xlate callback can be used to add the master
configurations to the smmu driver.

Signed-off-by: Sricharan R 
---
 drivers/iommu/arm-smmu.c | 36 +++-
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index fc13dd5..8c4eb43 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -41,6 +41,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -254,6 +256,8 @@
 #define FSYNR0_WNR (1 << 4)
 
 static int force_stage;
+static bool init_done;
+
 module_param_named(force_stage, force_stage, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(force_stage,
"Force SMMU mappings to be installed at a particular stage of 
translation. A value of '1' or '2' forces the corresponding stage. All other 
values are ignored (i.e. no stage is forced). Note that selecting a specific 
stage will disable support for nested translation.");
@@ -1848,20 +1852,8 @@ static struct platform_driver arm_smmu_driver = {
 
 static int __init arm_smmu_init(void)
 {
-   struct device_node *np;
int ret;
 
-   /*
-* Play nice with systems that don't have an ARM SMMU by checking that
-* an ARM SMMU exists in the system before proceeding with the driver
-* and IOMMU bus operation registration.
-*/
-   np = of_find_matching_node(NULL, arm_smmu_of_match);
-   if (!np)
-   return 0;
-
-   of_node_put(np);
-
ret = platform_driver_register(&arm_smmu_driver);
if (ret)
return ret;
@@ -1880,15 +1872,33 @@ static int __init arm_smmu_init(void)
bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
 #endif
 
+   init_done = true;
+
return 0;
 }
 
+static int __init arm_smmu_of_setup(struct device_node *np)
+{
+
+   if (!init_done)
+   arm_smmu_init();
+
+   of_iommu_set_ops(np, &arm_smmu_ops);
+
+   return 0;
+}
+
+IOMMU_OF_DECLARE(arm_smmu_v1, "arm,smmu-v1", arm_smmu_of_setup);
+IOMMU_OF_DECLARE(arm_smmu_v2, "arm,smmu-v2", arm_smmu_of_setup);
+IOMMU_OF_DECLARE(arm_smmu_400, "arm,mmu-400", arm_smmu_of_setup);
+IOMMU_OF_DECLARE(arm_smmu_401, "arm,mmu-401", arm_smmu_of_setup);
+IOMMU_OF_DECLARE(arm_smmu_500, "arm,mmu-500", arm_smmu_of_setup);
+
 static void __exit arm_smmu_exit(void)
 {
return platform_driver_unregister(&arm_smmu_driver);
 }
 
-subsys_initcall(arm_smmu_init);
 module_exit(arm_smmu_exit);
 
 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations");
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation

--
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


[RFC PATCH 3/4] iommu/arm-smmu: Add support for specifying clocks

2015-07-17 Thread Sricharan R
From: Mitchel Humpherys 

On some platforms with tight power constraints it is polite to only
leave your clocks on for as long as you absolutely need them. Currently
we assume that all clocks necessary for SMMU register access are always
on.

Add some optional device tree properties to specify any clocks that are
necessary for SMMU register access and turn them on and off as needed.

If no clocks are specified in the device tree things continue to work
the way they always have: we assume all necessary clocks are always
turned on. The clocks are turned 'on' during the SMMU device probe
and remains 'on' till the device exists.

Signed-off-by: Mitchel Humpherys 
Signed-off-by: Sricharan R 
---
 .../devicetree/bindings/iommu/arm,smmu.txt | 11 +++
 drivers/iommu/arm-smmu.c   | 86 +-
 2 files changed, 94 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt 
b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
index 0676050..c2cf4fe 100644
--- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
+++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
@@ -49,6 +49,17 @@ conditions.
   aliases of secure registers have to be used during
   SMMU configuration.
 
+- clocks   : List of clocks to be used during SMMU register access. See
+ Documentation/devicetree/bindings/clock/clock-bindings.txt
+ for information about the format. For each clock specified
+ here, there must be a corresponding entery in clock-names
+ (see below).
+
+- clock-names  : List of clock names corresponding to the clocks specified in
+ the "clocks" property (above). See
+ Documentation/devicetree/bindings/clock/clock-bindings.txt
+ for more info.
+
 Example:
 
 smmu {
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 2cf65ab..80d56f0a 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -323,6 +323,9 @@ struct arm_smmu_device {
struct list_headlist;
struct device_node  *node;
struct rb_root  masters;
+
+   int num_clocks;
+   struct clk  **clocks;
 };
 
 struct arm_smmu_cfg {
@@ -365,6 +368,31 @@ static struct arm_smmu_option_prop arm_smmu_options[] = {
{ 0, NULL},
 };
 
+static int arm_smmu_enable_clocks(struct arm_smmu_device *smmu)
+{
+   int i, ret = 0;
+
+   for (i = 0; i < smmu->num_clocks; ++i) {
+   ret = clk_prepare_enable(smmu->clocks[i]);
+   if (ret) {
+   dev_err(smmu->dev, "Couldn't enable clock #%d\n", i);
+   while (i--)
+   clk_disable_unprepare(smmu->clocks[i]);
+   break;
+   }
+   }
+
+   return ret;
+}
+
+static void arm_smmu_disable_clocks(struct arm_smmu_device *smmu)
+{
+   int i;
+
+   for (i = 0; i < smmu->num_clocks; ++i)
+   clk_disable_unprepare(smmu->clocks[i]);
+}
+
 static void parse_driver_options(struct arm_smmu_device *smmu)
 {
int i = 0;
@@ -1555,6 +1583,47 @@ static int arm_smmu_id_size_to_bits(int size)
}
 }
 
+static int arm_smmu_init_clocks(struct arm_smmu_device *smmu)
+{
+   const char *cname;
+   struct property *prop;
+   int i;
+   struct device *dev = smmu->dev;
+
+   smmu->num_clocks =
+   of_property_count_strings(dev->of_node, "clock-names");
+
+   if (smmu->num_clocks < 1)
+   return 0;
+
+   smmu->clocks = devm_kzalloc(
+   dev, sizeof(*smmu->clocks) * smmu->num_clocks,
+   GFP_KERNEL);
+
+   if (!smmu->clocks) {
+   dev_err(dev,
+   "Failed to allocate memory for clocks\n");
+   return -ENODEV;
+   }
+
+   i = 0;
+   of_property_for_each_string(dev->of_node, "clock-names",
+   prop, cname) {
+   struct clk *c = devm_clk_get(dev, cname);
+
+   if (IS_ERR(c)) {
+   dev_err(dev, "Couldn't get clock: %s",
+   cname);
+   return -ENODEV;
+   }
+
+   smmu->clocks[i] = c;
+
+   ++i;
+   }
+   return 0;
+}
+
 static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
 {
unsigned long size;
@@ -1772,9 +1841,15 @@ static int arm_smmu_device_dt_probe(struct 
platform_device *pdev)
smmu->irqs[i] = irq;
}
 
+   err = arm_smmu_init_clocks(smmu);
+   if (err)
+   goto out_put_masters;
+
+   arm_smmu_enable_clocks(smmu);
+
err = arm_smmu_device_cfg_probe(smmu);
if (err)
-   return err;
+   goto out_disable_clocks;

[RFC PATCH 0/4] iommu/arm-smmu: Add support for adding masters/clocks using generic bindings

2015-07-17 Thread Sricharan R
This series adds support for xlate callback to add master
devices configs using generic bindings and clocks/regulators
required to access smmu.

OF_IOMMU_DECLARE is used to register and probe the smmu controller
devices before the masters are added in of_platform_populate.
Here, we are registering only the smmu driver and iommu_ops. The
smmu device registration is not done in OF_IOMMU_DECLARE to avoid
early smmu probe, because the clocks if any required for the controller
are not yet ready.

So the idea here is to get the right direction in adding this support.

Mitchel Humpherys (2):
  iommu/arm-smmu: add support for specifying clocks
  iommu/arm-smmu: Add support for specifying regulators

Sricharan R (2):
  iommu/arm-smmu: Init driver using IOMMU_OF_DECLARE
  iommu/arm-smmu: Add xlate callback for initializing master devices
from dt

 .../devicetree/bindings/iommu/arm,smmu.txt |  14 ++
 drivers/iommu/arm-smmu.c   | 210 +++--
 2 files changed, 208 insertions(+), 16 deletions(-)

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation

--
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 v3 1/3] ARM: dts: qcom: Add binding for the qcom coincell charger

2015-07-17 Thread Rob Herring
On Thu, Jul 16, 2015 at 6:55 PM, Tim Bird  wrote:
> This binding is used to configure the driver for the coincell charger
> found in Qualcomm PMICs.
>
> Signed-off-by: Tim Bird 

Reviewed-by: Rob Herring 

> ---
>
> Changes in v3:
>  - change charge-enable property to charger-disable
> Changes in v2:
>  - remove 'qcom,' from example node name
>  - Added reference to parent node pm8941@0 and binding doc for it
>
>  .../bindings/power/qcom,coincell-charger.txt   | 48 
> ++
>  1 file changed, 48 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/power/qcom,coincell-charger.txt
>
> diff --git 
> a/Documentation/devicetree/bindings/power/qcom,coincell-charger.txt 
> b/Documentation/devicetree/bindings/power/qcom,coincell-charger.txt
> new file mode 100644
> index 000..0e6d875
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/qcom,coincell-charger.txt
> @@ -0,0 +1,48 @@
> +Qualcomm Coincell Charger:
> +
> +The hardware block controls charging for a coincell or capacitor that is
> +used to provide power backup for certain features of the power management
> +IC (PMIC)
> +
> +- compatible:
> +   Usage: required
> +   Value type: 
> +   Definition: must be: "qcom,pm8941-coincell"
> +
> +- reg:
> +   Usage: required
> +   Value type: 
> +   Definition: base address of the coincell charger registers
> +
> +- qcom,rset-ohms:
> +   Usage: required
> +   Value type: 
> +   Definition: resistance (in ohms) for current-limiting resistor
> +   must be one of: 800, 1200, 1700, 2100
> +
> +- qcom,vset-millivolts:
> +   Usage: required
> +   Value type: 
> +   Definition: voltage (in millivolts) to apply for charging
> +   must be one of: 2500, 3000, 3100, 3200
> +
> +- qcom,charger-disable:
> +   Usage: optional
> +   Value type: 
> +   Definition: definining this property disables charging
> +
> +This charger is a sub-node of one of the 8941 PMIC blocks, and is specified
> +as a child node in DTS of that node.  See ../mfd/qcom,spmi-pmic.txt and
> +../mfd/qcom-pm8xxx.txt
> +
> +Example:
> +
> +   pm8941@0 {
> +   coincell@2800 {
> +   compatible = "qcom,pm8941-coincell";
> +   reg = <0x2800>;
> +
> +   qcom,rset-ohms = <2100>;
> +   qcom,vset-millivolts = <3000>;
> +   };
> +   };
> --
> 1.8.2.2
>
--
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 v2 7/8] mfd: pm8921: Implement irq_get_irqchip_state

2015-07-17 Thread Marc Zyngier
On 15/07/15 07:40, Bjorn Andersson wrote:
> Implement irq_chip->irq_get_irqchip_state to make it possible for PMIC
> block drivers to access the IRQ real time status bits. The status bits
> are used for various kinds of input signals, e.g. GPIO.
> 
> Signed-off-by: Bjorn Andersson 

Reviewed-by: Marc Zyngier 

M.
-- 
Jazz is not dead. It just smells funny...
--
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] [v2] pinctrl: add support for Qualcomm Technologies QDF2xxx ARM64 SoCs

2015-07-17 Thread Linus Walleij
On Wed, Jul 15, 2015 at 6:47 PM, Timur Tabi  wrote:

> Add the pinctrl driver for the Qualcomm Technologies QDF2xxx ARM64 SoCs,
> which uses the Qualcomm Technologies TLMM pinctrl/gpio device.  This
> driver is probed via ACPI and uses the pinctrl-msm.c backend driver.
>
> This driver is intended to be used only an ACPI-enabled system.  As such,
> UEFI will handle all pin control configuration, so this driver does not
> provide pin control functions.  It is effectively a GPIO-only driver.

In my experience, you will come back and add pin control to it if
it ever sees any practical power-aware use cases.

For the same reason that Intel is doing it to their pin controllers,
that also run on systems that are ACPI-enabled.

>
> Signed-off-by: Timur Tabi 

This version applied with Björn's review tag.


Yours,
Linus Walleij
--
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 v2 8/8] pinctrl: qcom: ssbi: Family A gpio & mpp drivers

2015-07-17 Thread Linus Walleij
On Wed, Jul 15, 2015 at 8:40 AM, Bjorn Andersson
 wrote:

> This introduces pinctrl drivers for gpio and mpp blocks found in family A
> PMICs.
>
> Tested-by: Srinivas Kandagatla 
> Signed-off-by: Bjorn Andersson 
> ---
>
> Changes since v1:
> - Update platform_driver name
> - Use of_device_get_match_data()

This v2 version applied for v4.3.

Yours,
Linus Walleij
--
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 v2 7/8] mfd: pm8921: Implement irq_get_irqchip_state

2015-07-17 Thread Linus Walleij
On Wed, Jul 15, 2015 at 8:40 AM, Bjorn Andersson
 wrote:

> Implement irq_chip->irq_get_irqchip_state to make it possible for PMIC
> block drivers to access the IRQ real time status bits. The status bits
> are used for various kinds of input signals, e.g. GPIO.
>
> Signed-off-by: Bjorn Andersson 
> ---
>
> Changes since v1:
> - Drop extra check for !chip
> - Simplify return value

This v2 version applied for v4.3.

Yours,
Linus Walleij
--
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 6/8] pinctrl: qcom: spmi-mpp: Transpose pinmux function

2015-07-17 Thread Linus Walleij
On Thu, Jun 18, 2015 at 8:47 AM, Bjorn Andersson
 wrote:

> The "function" of the MPP driver was inherited from the GPIO driver, but the
> differences between the two hardware blocks makes both the driver and the
> device tree binding to be awkward.
>
> Instead of overloading the "normal" function with various modes this patch
> transposes the pinmux function to represent the three operating modes of the
> MPP (digital, analog and current sink). The properties of pin pairing and 
> DTEST
> routing is moved to separate properties.
>
> Signed-off-by: Bjorn Andersson 

Patch applied.

Yours,
Linus Walleij
--
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 v2 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level

2015-07-17 Thread Linus Walleij
On Wed, Jul 15, 2015 at 8:40 AM, Bjorn Andersson
 wrote:

> When the MPP is configured for analog output the output level is selected by
> the AOUT_CTL register, this patch makes it possible to control this.
>
> Signed-off-by: Bjorn Andersson 
> ---
>
> Changes since v1:
> - Assign aout_level in pmic_mpp_populate()

Applied this v2 version for v4.3 unless someone protests.

Yours,
Linus Walleij
--
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] pinctrl: qcom: Hook pm_power_down for shutdown support

2015-07-17 Thread Linus Walleij
On Tue, Jul 7, 2015 at 3:09 AM, Stephen Boyd  wrote:

> Assign pm_power_off() if we have the PS_HOLD functionality so
> that we can properly shutdown the SoC. Otherwise, shutdown won't
> do anything besides put the CPU into a tight loop. Unfortunately,
> we have to use a singleton here because pm_power_off() doesn't
> take any arguments. Fortunately there's only one instance of the
> pinctrl device on a running system so this isn't a problem.
>
> Cc: Bjorn Andersson 
> Cc: Pramod Gurav 
> Signed-off-by: Stephen Boyd 

Patch applied with Björn's ACK.

Yours,
Linus Walleij
--
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