Re: [PATCH 1/4] usb: dwc3: gadget: Fix TRB preparation during SG

2014-12-27 Thread Felipe Balbi
Hi,

On Sat, Dec 27, 2014 at 12:39:23PM +0530, Amit Virdi wrote:
 On Mon, Dec 22, 2014 at 9:34 PM, Felipe Balbi ba...@ti.com wrote:
  On Fri, Dec 19, 2014 at 12:40:15PM +0530, Amit Virdi wrote:
  When scatter gather is used, multiple TRBs are prepared from one DWC3 
  request.
  Hence, we must set the 'last' flag when the SG is last as well as the TRB 
  is
  last. The current implementation uses list_is_last to check if the 
  dwc3_request
  is the last request in the request_list.
 
  This doesn't work when SG is used. This is because, when it is the last 
  request,
  the first TRB preparation (in dwc3_prepare_one_trb) modifies the 
  dwc3_request
  list's next and prev pointers while moving the URB to req_queued.
 
  Hence, list_is_last always return false no matter what. The correct way is 
  not
  to access the modified pointers of dwc3_request but to use list_empty macro
  instead.
 
  Fixes: e5ba5ec833aa4a76980b512d6a6779643516b850 (usb: dwc3: gadget: fix 
  scatter
  gather implementation
 
  Signed-off-by: Amit Virdi amit.vi...@st.com
 
  you need to Cc stable here and make sure you point out which kernel
  versions this should be backported to. Looks like this sould be:
 
  Cc: sta...@vger.kernel.org # v3.9+
 
 Okay. I checked the git log. The commit (usb: dwc3: gadget: fix
 scatter gather implementation) was introduced in v3.8-rc5, hence
 v3.8, so I need to
 
 Cc: sta...@vger.kernel.org # v3.8+

hehe, many folks get confused by this. New features will never get
merged upstream during the -rc cycle. -rc5 is when I applied it to my
tree so it could be merged on the following merge window, which was
v3.9.

  Also, how have you tested this ? I need a test case to make sure it
  fails here and this patch really fixes the problem.
 
 
 This bug can be easily reproduced/tested if the gadget driver submits
 a urb having number of sg entries mapped to DMA more than 1 on bulk

which gadget driver does this ?

 endpoint. Following is the log snippet once this bug is reproduced:
 
 dwc3 dwc3.0: ep2in-bulk: Transfer Not Ready
 dwc3 dwc3.0: queing request 24cc5780 to ep2in-bulk length 960002
 dwc3 dwc3.0: ep2in-bulk: req 24cc5780 dma 24eb6400 length 2 chain
 dwc3 dwc3.0: ep2in-bulk: req 24cc5780 dma 25901800 length 96
 dwc3 dwc3.0: queing request 24cc5000 to ep2in-bulk length 960002
 dwc3 dwc3.0: ep2in-bulk: Transfer Not Ready
 dwc3 dwc3.0: queing request 24cc5900 to ep2in-bulk length 960002
 -
 
 Without this fix, the hardware never generates Transfer Complete
 event for the corresponding EP and goes into an unknown state.

whiuch kernel are you using to develop this ? Most of these messages
don't exist anymore with v3.19-rc because I have converted them into
tracepoints, considering you're showing me logs with these messages,
this tells me that you're sending me a patch developed/tested against a
kernel older than v3.18. I need to see full bootup logs, a register dump
(/sys/kernel/debug/*dwc3*/regdump) and a much larger debugging log from
dwc3 in order to accept patches from you. Sorry, but I cannot take
patches which were not tested against, at a minimum, the latest major
release.

It would be much better if you developed/tested against v3.19-rc1,
considering we have 40 different patches which were merged since v3.18
was tagged.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/4] usb: dwc3: gadget: Stop TRB preparation after limit is reached

2014-12-27 Thread Felipe Balbi
Hi,

On Sat, Dec 27, 2014 at 01:24:03PM +0530, Amit Virdi wrote:
 On Mon, Dec 22, 2014 at 9:36 PM, Felipe Balbi ba...@ti.com wrote:
  On Fri, Dec 19, 2014 at 12:40:16PM +0530, Amit Virdi wrote:
  When SG is used, there are two loops iterating to prepare TRBs:
   - Outer loop over the request_list
   - Inner loop over the SG list
 
  The driver must stop preparing TRBs when the max TRBs have been prepared. 
  The
  code was missing break to get out of the outer loop.
 
  Signed-off-by: Amit Virdi amit.vi...@st.com
 
  which bug is this fixing ? Which kernels are affected ? This need to be
  backported to which kernel ? Which commit introduced this bug ? How can
  I validate this to be a valid fix ?
 
 
 Problem description:
 DWC3 gadget sets up a pool of 32 TRBs for each EP during
 initialization. This means, the max TRBs that can be submitted for an
 EP is fixed to 32. Since the request queue for an EP is a linked list,
 any number of requests can be queued to it by the gadget layer.
 However, the dwc3 driver must not submit TRBs more than the pool it
 has created for. This limit wasn't respected when SG was used
 resulting in submitting more than the max TRBs, eventually leading to
 non-transfer of the TRBs submitted over the max limit.

this would become a much, much better commit log than the one you
provided. It's a much more verbose description of the issue.

 Commit that introduced this bug:
 This bug is present from the day support for sg list was added to dwc3
 gadget., i.e. since commit eeb720fb21d61dfc3aac780e721150998ef603af
 (usb: dwc3: gadget: add support for SG lists) - kernel version
 v3.2-rc7, hence v3.2
 
 Kernels affected:
 It is best to backport this fix to kernel v3.8+ as there were many
 enhancements/bug fixes from v3.2..v3.8
 
 Generic setup to reproduce/test this fix:
 This bug is reproduced whenever the number of TRBs that need to be
 submitted to the hardware from the software queue (request_list)
 becomes more than 32 on bulk endpoint. eg. if num_mapped_sgs is 2 and
 the request_list has 17 entries (hence, 34 potential TRBs), the
 scenario is reproduced.
 
 My setup details:
 For reproducing and testing the patches [1/4 and 2/4], I used an
 inhouse developed user space application that run on device side. This
 user space application interacts with the customized uvc webcam gadget
 to submit the video data to the DWC3 driver. The host side was running
 standard webcam application (cheese).

oh, so this is something I can't easily reproduce myself. Then I'll need
full boot logs, register dump and full trace output of dwc3 running and
exhibiting the problem. Also, make sure you use either v3.18 or v3.19rc1
to validate your changes.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 0/7] Menelaus cleanup for DT, phase 1

2014-12-27 Thread Aaro Koskinen
Hi,

These patches start removal of board-specific callbacks from Menelaus:
delete platform data and a callback from the driver to the board files.

Tested on top of 3.19-rc1 on N800/N810 which are the only in-tree users
for the driver.

Aaro Koskinen (7):
  mfd: menelaus: delete omap_has_menelaus
  mfd: menelaus: drop support for SW controller VCORE
  mfd: menelaus: add initial DT support
  ARM: OMAP: N8x0: configure menelaus using DT
  mfd: menelaus: delete platform data support
  mfd: menelaus: make vcore and regulator controls internal
  mfd: menelaus: use macro for magic number

 Documentation/devicetree/bindings/mfd/menelaus.txt | 30 
 arch/arm/boot/dts/omap2420-n8x0-common.dtsi|  3 +
 arch/arm/mach-omap2/board-n8x0.c   | 57 --
 arch/arm/mach-omap2/common-board-devices.h |  2 -
 arch/arm/mach-omap2/pdata-quirks.c |  1 -
 drivers/mfd/menelaus.c | 86 ++
 include/linux/mfd/menelaus.h   | 25 ---
 7 files changed, 87 insertions(+), 117 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/menelaus.txt

-- 
2.2.0

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


[PATCH 4/7] ARM: OMAP: N8x0: configure menelaus using DT

2014-12-27 Thread Aaro Koskinen
Configure Menelaus using DT.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/boot/dts/omap2420-n8x0-common.dtsi |  3 ++
 arch/arm/mach-omap2/board-n8x0.c| 57 -
 arch/arm/mach-omap2/pdata-quirks.c  |  1 -
 3 files changed, 3 insertions(+), 58 deletions(-)

diff --git a/arch/arm/boot/dts/omap2420-n8x0-common.dtsi 
b/arch/arm/boot/dts/omap2420-n8x0-common.dtsi
index c9f1e93..c19718c 100644
--- a/arch/arm/boot/dts/omap2420-n8x0-common.dtsi
+++ b/arch/arm/boot/dts/omap2420-n8x0-common.dtsi
@@ -32,6 +32,9 @@
compatible = menelaus;
reg = 0x72;
interrupts = 7 IRQ_TYPE_EDGE_RISING;
+   ti,autosleep;
+   ti,vcore-min-microvolt = 105;
+   ti,vcore-max-microvolt = 140;
};
 };
 
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index b6443a4..0b511c0 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -516,63 +516,6 @@ void __init n8x0_mmc_init(void)
 }
 #endif /* CONFIG_MMC_OMAP */
 
-#ifdef CONFIG_MENELAUS
-
-static int n8x0_auto_sleep_regulators(void)
-{
-   u32 val;
-   int ret;
-
-   val = EN_VPLL_SLEEP | EN_VMMC_SLEEP\
-   | EN_VAUX_SLEEP | EN_VIO_SLEEP \
-   | EN_VMEM_SLEEP | EN_DC3_SLEEP \
-   | EN_VC_SLEEP | EN_DC2_SLEEP;
-
-   ret = menelaus_set_regulator_sleep(1, val);
-   if (ret  0) {
-   pr_err(Could not set regulators to sleep on menelaus: %u\n,
-  ret);
-   return ret;
-   }
-   return 0;
-}
-
-static int n8x0_auto_voltage_scale(void)
-{
-   int ret;
-
-   ret = menelaus_set_vcore_hw(1400, 1050);
-   if (ret  0) {
-   pr_err(Could not set VCORE voltage on menelaus: %u\n, ret);
-   return ret;
-   }
-   return 0;
-}
-
-static int n8x0_menelaus_late_init(struct device *dev)
-{
-   int ret;
-
-   ret = n8x0_auto_voltage_scale();
-   if (ret  0)
-   return ret;
-   ret = n8x0_auto_sleep_regulators();
-   if (ret  0)
-   return ret;
-   return 0;
-}
-
-#else
-static int n8x0_menelaus_late_init(struct device *dev)
-{
-   return 0;
-}
-#endif
-
-struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
-   .late_init = n8x0_menelaus_late_init,
-};
-
 struct aic3x_pdata n810_aic33_data __initdata = {
.gpio_reset = 118,
 };
diff --git a/arch/arm/mach-omap2/pdata-quirks.c 
b/arch/arm/mach-omap2/pdata-quirks.c
index 3d7eee1..fca4650 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -369,7 +369,6 @@ static struct pdata_init auxdata_quirks[] __initdata = {
 struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
 #ifdef CONFIG_MACH_NOKIA_N8X0
OF_DEV_AUXDATA(ti,omap2420-mmc, 0x4809c000, mmci-omap.0, NULL),
-   OF_DEV_AUXDATA(menelaus, 0x72, 1-0072, 
n8x0_menelaus_platform_data),
OF_DEV_AUXDATA(tlv320aic3x, 0x18, 2-0018, n810_aic33_data),
 #endif
 #ifdef CONFIG_ARCH_OMAP3
-- 
2.2.0

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


[PATCH 3/7] mfd: menelaus: add initial DT support

2014-12-27 Thread Aaro Koskinen
Add initial DT support.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 Documentation/devicetree/bindings/mfd/menelaus.txt | 30 +
 drivers/mfd/menelaus.c | 52 --
 2 files changed, 78 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/menelaus.txt

diff --git a/Documentation/devicetree/bindings/mfd/menelaus.txt 
b/Documentation/devicetree/bindings/mfd/menelaus.txt
new file mode 100644
index 000..5f69f23
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/menelaus.txt
@@ -0,0 +1,30 @@
+Menelaus (Texas Instruments TWL92330) Power Management chip
+
+Menelaus provides facilities to control the power resources.
+
+Required properties:
+- compatible: must be menelaus
+- reg: I2C address of the chip
+
+Optional properties:
+- interrupts: the interrupt
+- ti,autosleep: All regulators are put to sleep by default.
+- ti,vcore-min-microvolt: Range floor for the HW controlled VCORE
+- ti,vcore-max-microvolt: Range roof for the HW controlled VCORE
+
+The use of ti,autosleep is recommended at least on Nokia N800/N810.
+
+Example:
+
+i2c1 {
+   clock-frequency = 40;
+
+   pmic@72 {
+   compatible = menelaus;
+   reg = 0x72;
+   interrupts = 7 IRQ_TYPE_EDGE_RISING;
+   ti,autosleep;
+   ti,vcore-min-microvolt = 105;
+   ti,vcore-max-microvolt = 140;
+   };
+};
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 917fa86..3e04c64 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -16,6 +16,8 @@
  * Amit Kucheria amit.kuche...@nokia.com
  * Copyright (C) 2005, 2006 Nokia Corporation
  *
+ * Cleanups and DT modifications by Aaro Koskinen aaro.koski...@iki.fi.
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -767,6 +769,22 @@ out:
return ret;
 }
 
+static int menelaus_auto_sleep_regulators(void)
+{
+   u32 val;
+   int ret;
+
+   val = EN_VPLL_SLEEP | EN_VMMC_SLEEP | EN_VAUX_SLEEP | EN_VIO_SLEEP | \
+ EN_VMEM_SLEEP | EN_DC3_SLEEP  | EN_VC_SLEEP   | EN_DC2_SLEEP;
+   ret = menelaus_set_regulator_sleep(1, val);
+   if (ret  0) {
+   dev_err(the_menelaus-client-dev,
+   could not set regulators to sleep: %d\n, ret);
+   return ret;
+   }
+   return 0;
+}
+
 /*---*/
 
 /* Handles Menelaus interrupts. Does not run in interrupt context */
@@ -1162,6 +1180,7 @@ static int menelaus_probe(struct i2c_client *client,
struct menelaus_chip*menelaus;
int rev = 0;
int err = 0;
+   struct device_node  *np = client-dev.of_node;
struct menelaus_platform_data *menelaus_pdata =
dev_get_platdata(client-dev);
 
@@ -1221,10 +1240,35 @@ static int menelaus_probe(struct i2c_client *client,
else
menelaus-vcore_hw_mode = 0;
 
-   if (menelaus_pdata != NULL  menelaus_pdata-late_init != NULL) {
-   err = menelaus_pdata-late_init(client-dev);
-   if (err  0)
-   goto fail;
+   if (menelaus_pdata != NULL) {
+   if (menelaus_pdata-late_init != NULL) {
+   err = menelaus_pdata-late_init(client-dev);
+   if (err  0)
+   goto fail;
+   }
+   } else if (np) {
+   u32 vcore_min;
+   u32 vcore_max;
+
+   if (!of_property_read_u32(np, ti,vcore-min-microvolt,
+ vcore_min) 
+   !of_property_read_u32(np, ti,vcore-max-microvolt,
+ vcore_max)) {
+   err = menelaus_set_vcore_hw(vcore_max / 1000,
+   vcore_min / 1000);
+   if (err  0) {
+   dev_err(client-dev,
+   could not set VCORE voltage: %d\n,
+   err);
+   goto fail;
+   }
+   }
+
+   if (of_property_read_bool(np, ti,autosleep)) {
+   err = menelaus_auto_sleep_regulators();
+   if (err  0)
+   goto fail;
+   }
}
 
menelaus_rtc_init(menelaus);
-- 
2.2.0

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


[PATCH 2/7] mfd: menelaus: drop support for SW controller VCORE

2014-12-27 Thread Aaro Koskinen
Drop support for SW controlled VCORE, nobody uses it.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/menelaus.c   | 23 ---
 include/linux/mfd/menelaus.h |  1 -
 2 files changed, 24 deletions(-)

diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 9f01aef..917fa86 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -532,29 +532,6 @@ static const struct menelaus_vtg_value vcore_values[] = {
{ 1450, 18 },
 };
 
-int menelaus_set_vcore_sw(unsigned int mV)
-{
-   int val, ret;
-   struct i2c_client *c = the_menelaus-client;
-
-   val = menelaus_get_vtg_value(mV, vcore_values,
-ARRAY_SIZE(vcore_values));
-   if (val  0)
-   return -EINVAL;
-
-   dev_dbg(c-dev, Setting VCORE to %d mV (val 0x%02x)\n, mV, val);
-
-   /* Set SW mode and the voltage in one go. */
-   mutex_lock(the_menelaus-lock);
-   ret = menelaus_write_reg(MENELAUS_VCORE_CTRL1, val);
-   if (ret == 0)
-   the_menelaus-vcore_hw_mode = 0;
-   mutex_unlock(the_menelaus-lock);
-   msleep(1);
-
-   return ret;
-}
-
 int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV)
 {
int fval, rval, val, ret;
diff --git a/include/linux/mfd/menelaus.h b/include/linux/mfd/menelaus.h
index a1e12bf3..9e85ac0 100644
--- a/include/linux/mfd/menelaus.h
+++ b/include/linux/mfd/menelaus.h
@@ -24,7 +24,6 @@ extern int menelaus_set_vaux(unsigned int mV);
 extern int menelaus_set_vdcdc(int dcdc, unsigned int mV);
 extern int menelaus_set_slot_sel(int enable);
 extern int menelaus_get_slot_pin_states(void);
-extern int menelaus_set_vcore_sw(unsigned int mV);
 extern int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV);
 
 #define EN_VPLL_SLEEP  (1  7)
-- 
2.2.0

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


[PATCH 5/7] mfd: menelaus: delete platform data support

2014-12-27 Thread Aaro Koskinen
Delete platform data support.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 arch/arm/mach-omap2/common-board-devices.h |  2 --
 drivers/mfd/menelaus.c | 10 +-
 include/linux/mfd/menelaus.h   |  6 --
 3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/arch/arm/mach-omap2/common-board-devices.h 
b/arch/arm/mach-omap2/common-board-devices.h
index 07c88ae..7a30228 100644
--- a/arch/arm/mach-omap2/common-board-devices.h
+++ b/arch/arm/mach-omap2/common-board-devices.h
@@ -2,7 +2,6 @@
 #define __OMAP_COMMON_BOARD_DEVICES__
 
 #include sound/tlv320aic3x.h
-#include linux/mfd/menelaus.h
 #include twl-common.h
 
 #define NAND_BLOCK_SIZESZ_128K
@@ -14,7 +13,6 @@ void omap_ads7846_init(int bus_num, int gpio_pendown, int 
gpio_debounce,
   struct ads7846_platform_data *board_pdata);
 void *n8x0_legacy_init(void);
 
-extern struct menelaus_platform_data n8x0_menelaus_platform_data;
 extern struct aic3x_pdata n810_aic33_data;
 
 #endif /* __OMAP_COMMON_BOARD_DEVICES__ */
diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 3e04c64..4a900cc 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -1181,8 +1181,6 @@ static int menelaus_probe(struct i2c_client *client,
int rev = 0;
int err = 0;
struct device_node  *np = client-dev.of_node;
-   struct menelaus_platform_data *menelaus_pdata =
-   dev_get_platdata(client-dev);
 
if (the_menelaus) {
dev_dbg(client-dev, only one %s for now\n,
@@ -1240,13 +1238,7 @@ static int menelaus_probe(struct i2c_client *client,
else
menelaus-vcore_hw_mode = 0;
 
-   if (menelaus_pdata != NULL) {
-   if (menelaus_pdata-late_init != NULL) {
-   err = menelaus_pdata-late_init(client-dev);
-   if (err  0)
-   goto fail;
-   }
-   } else if (np) {
+   if (np) {
u32 vcore_min;
u32 vcore_max;
 
diff --git a/include/linux/mfd/menelaus.h b/include/linux/mfd/menelaus.h
index 9e85ac0..21eeff5 100644
--- a/include/linux/mfd/menelaus.h
+++ b/include/linux/mfd/menelaus.h
@@ -5,12 +5,6 @@
 #ifndef __ASM_ARCH_MENELAUS_H
 #define __ASM_ARCH_MENELAUS_H
 
-struct device;
-
-struct menelaus_platform_data {
-   int (* late_init)(struct device *dev);
-};
-
 extern int menelaus_register_mmc_callback(void (*callback)(void *data, u8 
card_mask),
  void *data);
 extern void menelaus_unregister_mmc_callback(void);
-- 
2.2.0

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


[PATCH 1/7] mfd: menelaus: delete omap_has_menelaus

2014-12-27 Thread Aaro Koskinen
Delete unused macro.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 include/linux/mfd/menelaus.h | 6 --
 1 file changed, 6 deletions(-)

diff --git a/include/linux/mfd/menelaus.h b/include/linux/mfd/menelaus.h
index f097e89..a1e12bf3 100644
--- a/include/linux/mfd/menelaus.h
+++ b/include/linux/mfd/menelaus.h
@@ -38,10 +38,4 @@ extern int menelaus_set_vcore_hw(unsigned int roof_mV, 
unsigned int floor_mV);
 
 extern int menelaus_set_regulator_sleep(int enable, u32 val);
 
-#if defined(CONFIG_ARCH_OMAP2)  defined(CONFIG_MENELAUS)
-#define omap_has_menelaus()1
-#else
-#define omap_has_menelaus()0
-#endif
-
 #endif
-- 
2.2.0

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


[PATCH 7/7] mfd: menelaus: use macro for magic number

2014-12-27 Thread Aaro Koskinen
Use macro to check a register bit.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/menelaus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 8660adf..05bae40 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -1242,7 +1242,7 @@ static int menelaus_probe(struct i2c_client *client,
err = menelaus_read_reg(MENELAUS_VCORE_CTRL1);
if (err  0)
goto fail;
-   if (err  BIT(7))
+   if (err  VCORE_CTRL1_HW_NSW)
menelaus-vcore_hw_mode = 1;
else
menelaus-vcore_hw_mode = 0;
-- 
2.2.0

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


[PATCH 6/7] mfd: menelaus: make vcore and regulator controls internal

2014-12-27 Thread Aaro Koskinen
Make vcore and regulator control functions internal to the driver.

Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
---
 drivers/mfd/menelaus.c   | 13 +++--
 include/linux/mfd/menelaus.h | 12 
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
index 4a900cc..8660adf 100644
--- a/drivers/mfd/menelaus.c
+++ b/drivers/mfd/menelaus.c
@@ -163,6 +163,15 @@
 #define MCT_PIN_ST_S1_CD_ST(1  0)
 #define MCT_PIN_ST_S2_CD_ST(1  1)
 
+#define EN_VPLL_SLEEP  (1  7)
+#define EN_VMMC_SLEEP  (1  6)
+#define EN_VAUX_SLEEP  (1  5)
+#define EN_VIO_SLEEP   (1  4)
+#define EN_VMEM_SLEEP  (1  3)
+#define EN_DC3_SLEEP   (1  2)
+#define EN_DC2_SLEEP   (1  1)
+#define EN_VC_SLEEP(1  0)
+
 static void menelaus_work(struct work_struct *_menelaus);
 
 struct menelaus_chip {
@@ -534,7 +543,7 @@ static const struct menelaus_vtg_value vcore_values[] = {
{ 1450, 18 },
 };
 
-int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV)
+static int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV)
 {
int fval, rval, val, ret;
struct i2c_client *c = the_menelaus-client;
@@ -743,7 +752,7 @@ int menelaus_get_slot_pin_states(void)
 }
 EXPORT_SYMBOL(menelaus_get_slot_pin_states);
 
-int menelaus_set_regulator_sleep(int enable, u32 val)
+static int menelaus_set_regulator_sleep(int enable, u32 val)
 {
int t, ret;
struct i2c_client *c = the_menelaus-client;
diff --git a/include/linux/mfd/menelaus.h b/include/linux/mfd/menelaus.h
index 21eeff5..bcabc03 100644
--- a/include/linux/mfd/menelaus.h
+++ b/include/linux/mfd/menelaus.h
@@ -18,17 +18,5 @@ extern int menelaus_set_vaux(unsigned int mV);
 extern int menelaus_set_vdcdc(int dcdc, unsigned int mV);
 extern int menelaus_set_slot_sel(int enable);
 extern int menelaus_get_slot_pin_states(void);
-extern int menelaus_set_vcore_hw(unsigned int roof_mV, unsigned int floor_mV);
-
-#define EN_VPLL_SLEEP  (1  7)
-#define EN_VMMC_SLEEP  (1  6)
-#define EN_VAUX_SLEEP  (1  5)
-#define EN_VIO_SLEEP   (1  4)
-#define EN_VMEM_SLEEP  (1  3)
-#define EN_DC3_SLEEP   (1  2)
-#define EN_DC2_SLEEP   (1  1)
-#define EN_VC_SLEEP(1  0)
-
-extern int menelaus_set_regulator_sleep(int enable, u32 val);
 
 #endif
-- 
2.2.0

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


Re: [PATCH 3/3] ARM: dts: OMAP34xx/36xx: Add temperature sensor

2014-12-27 Thread Pavel Machek
On Fri 2014-12-26 13:34:54, Sebastian Reichel wrote:
 OMAP34xx and OMAP36xx processors contain a register in the
 syscon area, which can be used to determine the SoCs temperature.
 
 Signed-off-by: Sebastian Reichel s...@kernel.org

Acked-by: Pavel Machek pa...@ucw.cz
Tested-by: Pavel Machek pa...@ucw.cz

Driver binds and does something, so binding works ok.
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] DT Binding for omap3 temperature sensor

2014-12-27 Thread Pavel Machek
On Fri 2014-12-26 13:34:52, Sebastian Reichel wrote:
 OMAP34xx and OMAP36xx processors contain a register in the syscon area,
 which can be used to determine the SoCs temperature. This provides a
 DT binding specification for the temperature monitor.
 
 Signed-off-by: Sebastian Reichel s...@kernel.org

Acked-by: Pavel Machek pa...@ucw.cz
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] hwmon: Driver for OMAP3 temperature sensor

2014-12-27 Thread Pavel Machek
Hi!


 OMAP34xx and OMAP36xx processors contain a register in the syscon area,
 which can be used to determine the SoCs temperature. This patch provides
 a DT based driver for the temperature sensor based on an older driver
 written by Peter De Schrijver for the Nokia N900 and N9.
 
 Signed-off-by: Sebastian Reichel s...@kernel.org

I did clk_enable - clk_prepare_enable conversion, as described in
another email.

I got occasional error reading:

root@n900:~# cat /sys/class/hwmon/hwmon0/device/temp_input
20.0
root@n900:~# cat /sys/class/hwmon/hwmon0/device/temp_input
cat: /sys/class/hwmon/hwmon0/device/temp_input: Input/output error
root@n900:~# cat /sys/class/hwmon/hwmon0/device/temp_input
20.0

Nothing in dmesg. It takes few tries to reproduce..

On other attempt, it hung hard:

root@n900:~# cat /sys/class/hwmon/hwmon0/device/temp_input ; cat
/sys/class/hwmon/hwmon0/device/temp_input  ;cat
/sys/class/hwmon/hwmon0/device/temp_input ; cat
/sys/class/hwmon/hwmon0/device/temp_input
17.0
17.0
^[[A



^Z


^C^C^C

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] hwmon: Driver for OMAP3 temperature sensor

2014-12-27 Thread Pavel Machek
On Fri 2014-12-26 13:34:53, Sebastian Reichel wrote:
 OMAP34xx and OMAP36xx processors contain a register in the syscon area,
 which can be used to determine the SoCs temperature. This patch provides
 a DT based driver for the temperature sensor based on an older driver
 written by Peter De Schrijver for the Nokia N900 and N9.
 
 Signed-off-by: Sebastian Reichel s...@kernel.org

I'd suggest these cleanups... But I don't see why it would fail. (Aha,
and sorry for trailing whitespace, you'll probably need to delete it.)

Signed-off-by: Pavel Machek pa...@ucw.cz

diff --git a/drivers/hwmon/omap3-temp.c b/drivers/hwmon/omap3-temp.c
index afe1b5a..8a69604 100644
--- a/drivers/hwmon/omap3-temp.c
+++ b/drivers/hwmon/omap3-temp.c
@@ -35,21 +35,29 @@
 /* 32.768Khz clock speed in nano seconds */
 #define CLOCK_32K_SPEED_NS 30518
 
-/* minimum delay for EOCZ rise after SOC rise is
- * 11 cycles of the 32.768Khz clock */
+/*
+ * minimum delay for EOCZ rise after SOC rise is
+ * 11 cycles of the 32.768Khz clock
+ */
 #define EOCZ_MIN_RISING_DELAY (11 * CLOCK_32K_SPEED_NS)
 
-/* From docs, maximum delay for EOCZ rise after SOC rise is
+/*
+ * From docs, maximum delay for EOCZ rise after SOC rise is
  * 14 cycles of the 32.768Khz clock. But after some experiments,
- * 24 cycles as maximum is safer. */
+ * 24 cycles as maximum is safer.
+ */
 #define EOCZ_MAX_RISING_DELAY (24 * CLOCK_32K_SPEED_NS)
 
-/* minimum delay for EOCZ falling is
- * 36 cycles of the 32.768Khz clock */
+/*
+ * minimum delay for EOCZ falling is
+ * 36 cycles of the 32.768Khz clock 
+ */
 #define EOCZ_MIN_FALLING_DELAY (36 * CLOCK_32K_SPEED_NS)
 
-/* maximum delay for EOCZ falling is
- * 40 cycles of the 32.768Khz clock */
+/*
+ * maximum delay for EOCZ falling is
+ * 40 cycles of the 32.768Khz clock 
+ */
 #define EOCZ_MAX_FALLING_DELAY (40 * CLOCK_32K_SPEED_NS)
 
 /* temperature register offset in the syscon register area */
@@ -116,8 +124,8 @@ struct omap3_temp_data {
bool valid;
 };
 
-static inline u32 wait_for_eocz(int min_delay, int max_delay, u32 level,
-   struct omap3_temp_data *data)
+static inline bool wait_for_eocz(struct omap3_temp_data *data,
+int min_delay, int max_delay, u32 level)
 {
ktime_t timeout, expire;
u32 temp_sensor_reg, eocz_mask;
@@ -133,10 +141,10 @@ static inline u32 wait_for_eocz(int min_delay, int 
max_delay, u32 level,
do {
regmap_read(data-syscon, SYSCON_TEMP_REG, temp_sensor_reg);
if ((temp_sensor_reg  eocz_mask) == level)
-   break;
+   return true;
} while (ktime_us_delta(expire, ktime_get())  0);
 
-   return (temp_sensor_reg  eocz_mask) == level;
+   return false;
 }
 
 static int omap3_temp_update(struct omap3_temp_data *data)
@@ -153,16 +161,16 @@ static int omap3_temp_update(struct omap3_temp_data *data)
regmap_update_bits(data-syscon, SYSCON_TEMP_REG,
   soc_mask, soc_mask);
 
-   if (!wait_for_eocz(EOCZ_MIN_RISING_DELAY,
-   EOCZ_MAX_RISING_DELAY, 1, data)) {
+   if (!wait_for_eocz(data, EOCZ_MIN_RISING_DELAY,
+   EOCZ_MAX_RISING_DELAY, 1)) {
e = -EIO;
goto err;
}
 
regmap_update_bits(data-syscon, SYSCON_TEMP_REG, soc_mask, 0);
 
-   if (!wait_for_eocz(EOCZ_MIN_FALLING_DELAY,
-   EOCZ_MAX_FALLING_DELAY, 0, data)) {
+   if (!wait_for_eocz(data, EOCZ_MIN_FALLING_DELAY,
+   EOCZ_MAX_FALLING_DELAY, 0)) {
e = -EIO;
goto err;
}


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] hwmon: Driver for OMAP3 temperature sensor

2014-12-27 Thread Pavel Machek
On Fri 2014-12-26 13:34:53, Sebastian Reichel wrote:
 OMAP34xx and OMAP36xx processors contain a register in the syscon area,
 which can be used to determine the SoCs temperature. This patch provides
 a DT based driver for the temperature sensor based on an older driver
 written by Peter De Schrijver for the Nokia N900 and N9.
 
 Signed-off-by: Sebastian Reichel s...@kernel.org

When it hangs, it seems to hang here:

if (!wait_for_eocz(data, EOCZ_MIN_RISING_DELAY,
EOCZ_MAX_RISING_DELAY, 1)) {
e = -EIO;
goto
err;
}

...so wait does not seem to reliably wait.
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] hwmon: Driver for OMAP3 temperature sensor

2014-12-27 Thread Pavel Machek
On Fri 2014-12-26 13:34:53, Sebastian Reichel wrote:
 OMAP34xx and OMAP36xx processors contain a register in the syscon area,
 which can be used to determine the SoCs temperature. This patch provides
 a DT based driver for the temperature sensor based on an older driver
 written by Peter De Schrijver for the Nokia N900 and N9.
 
 Signed-off-by: Sebastian Reichel s...@kernel.org
 ---
  drivers/hwmon/Kconfig  |   8 ++
  drivers/hwmon/Makefile |   1 +
  drivers/hwmon/omap3-temp.c | 307 
 +
  3 files changed, 316 insertions(+)
  create mode 100644 drivers/hwmon/omap3-temp.c

When it hangs, it loops here:

do {
regmap_read(data-syscon, SYSCON_TEMP_REG,temp_sensor_reg);
if ((temp_sensor_reg  eocz_mask) == level)
   return true;
printk(=);
}
while (ktime_us_delta(expire, ktime_get())  0);

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/7] mfd: menelaus: add initial DT support

2014-12-27 Thread Felipe Balbi
On Sat, Dec 27, 2014 at 07:52:55PM +0200, Aaro Koskinen wrote:
 Add initial DT support.
 
 Signed-off-by: Aaro Koskinen aaro.koski...@iki.fi
 ---
  Documentation/devicetree/bindings/mfd/menelaus.txt | 30 +
  drivers/mfd/menelaus.c | 52 
 --
  2 files changed, 78 insertions(+), 4 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/mfd/menelaus.txt
 
 diff --git a/Documentation/devicetree/bindings/mfd/menelaus.txt 
 b/Documentation/devicetree/bindings/mfd/menelaus.txt
 new file mode 100644
 index 000..5f69f23
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/menelaus.txt
 @@ -0,0 +1,30 @@
 +Menelaus (Texas Instruments TWL92330) Power Management chip
 +
 +Menelaus provides facilities to control the power resources.
 +
 +Required properties:
 +- compatible: must be menelaus
 +- reg: I2C address of the chip
 +
 +Optional properties:
 +- interrupts: the interrupt
 +- ti,autosleep: All regulators are put to sleep by default.
 +- ti,vcore-min-microvolt: Range floor for the HW controlled VCORE
 +- ti,vcore-max-microvolt: Range roof for the HW controlled VCORE
 +
 +The use of ti,autosleep is recommended at least on Nokia N800/N810.
 +
 +Example:
 +
 +i2c1 {
 + clock-frequency = 40;
 +
 + pmic@72 {
 + compatible = menelaus;
 + reg = 0x72;
 + interrupts = 7 IRQ_TYPE_EDGE_RISING;
 + ti,autosleep;
 + ti,vcore-min-microvolt = 105;
 + ti,vcore-max-microvolt = 140;

looks like these should be first converted to actual regulators
otherwise we will have to maintain this binding forever which means that
any effort of adding regulator fwk support for menelaus will become a
lot more difficult because it'll have to cope with the legacy/bogus
binding.

I started doing irqchip/irqdomain conversion but I don't have where to
test and got side-tracked by other stuff. I'll see if I can restart that
work early next year.

Then, if you change your series so that first you add proper regulator
fwk support, we should be pretty good with menelaus.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 2/3] hwmon: Driver for OMAP3 temperature sensor

2014-12-27 Thread Pavel Machek
On Sat 2014-12-27 20:58:25, Pavel Machek wrote:
 On Fri 2014-12-26 13:34:53, Sebastian Reichel wrote:
  OMAP34xx and OMAP36xx processors contain a register in the syscon area,
  which can be used to determine the SoCs temperature. This patch provides
  a DT based driver for the temperature sensor based on an older driver
  written by Peter De Schrijver for the Nokia N900 and N9.
  
  Signed-off-by: Sebastian Reichel s...@kernel.org
  ---
   drivers/hwmon/Kconfig  |   8 ++
   drivers/hwmon/Makefile |   1 +
   drivers/hwmon/omap3-temp.c | 307 
  +
   3 files changed, 316 insertions(+)
   create mode 100644 drivers/hwmon/omap3-temp.c
 
 When it hangs, it loops here:
 
 do {
 regmap_read(data-syscon, SYSCON_TEMP_REG,temp_sensor_reg);
 if ((temp_sensor_reg  eocz_mask) == level)
return true;
 printk(=);
 }
 while (ktime_us_delta(expire, ktime_get())  0);

And this fixes the hang, and makes level handling more readable.

Fix the timeout code, now it actually works. Driver still fails after
a while.

Signed-off-by: Pavel Machek pa...@ucw.cz

diff --git a/drivers/hwmon/omap3-temp.c b/drivers/hwmon/omap3-temp.c
index 8a69604..1b8c768 100644
--- a/drivers/hwmon/omap3-temp.c
+++ b/drivers/hwmon/omap3-temp.c
@@ -130,9 +130,7 @@ static inline bool wait_for_eocz(struct omap3_temp_data 
*data,
ktime_t timeout, expire;
u32 temp_sensor_reg, eocz_mask;
 
eocz_mask = BIT(data-hwdata-eocz_bit);
-   level = 1;
-   level *= eocz_mask;
 
expire = ktime_add_ns(ktime_get(), max_delay);
timeout = ktime_set(0, min_delay);
@@ -140,9 +141,9 @@ static inline bool wait_for_eocz(struct omap3_temp_data 
*data,
schedule_hrtimeout(timeout, HRTIMER_MODE_REL);
do {
regmap_read(data-syscon, SYSCON_TEMP_REG, temp_sensor_reg);
-   if ((temp_sensor_reg  eocz_mask) == level)
+   if (!!(temp_sensor_reg  eocz_mask) == level)
return true;
-   } while (ktime_us_delta(expire, ktime_get())  0);
+   } while (ktime_after(expire, ktime_get()));
 
return false;
 }

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] hwmon: Driver for OMAP3 temperature sensor

2014-12-27 Thread Pavel Machek
On Fri 2014-12-26 13:34:53, Sebastian Reichel wrote:
 OMAP34xx and OMAP36xx processors contain a register in the syscon area,
 which can be used to determine the SoCs temperature. This patch provides
 a DT based driver for the temperature sensor based on an older driver
 written by Peter De Schrijver for the Nokia N900 and N9.
 
 Signed-off-by: Sebastian Reichel s...@kernel.org

As I mentioned before, this version stops working after a
while. Version I originally posted seems to work ok under same load.

Best regards,
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line unsubscribe linux-omap 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 3/5] input: misc: add tps65218 power button driver

2014-12-27 Thread Dmitry Torokhov
On Fri, Dec 26, 2014 at 09:36:48PM -0600, Felipe Balbi wrote:
 With this driver, we can report KEY_POWER on
 AM437x SK. This patch has been tested with said
 board.
 
 Signed-off-by: Felipe Balbi ba...@ti.com

Applied, thank you.

 ---
 
 Changes since v1:
   - Add device tree documentation
   - s/ret/error
   - removed 'pressed' as input core will filter events
   - use a saner name when requesting IRQ. dev_name(dev) will return
   $i2c_bus_address.i2c-omap:0-0024:tps65218-pwrbutton
   - remove blank line before MODULE_DEVICE_TABLE()
 
  .../bindings/input/tps65218-pwrbutton.txt  |  17 +++
  drivers/input/misc/Kconfig |  10 ++
  drivers/input/misc/Makefile|   1 +
  drivers/input/misc/tps65218-pwrbutton.c| 124 
 +
  4 files changed, 152 insertions(+)
  create mode 100644 
 Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
  create mode 100644 drivers/input/misc/tps65218-pwrbutton.c
 
 diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt 
 b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
 new file mode 100644
 index 000..e30e0b9
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt
 @@ -0,0 +1,17 @@
 +Texas Instruments TPS65218 power button
 +
 +This driver provides a simple power button event via an Interrupt.
 +
 +Required properties:
 +- compatible: should be ti,tps65218-pwrbutton
 +- interrupts: should be one of the following
 +   - 3 IRQ_TYPE_EDGE_BOTH: For controllers compatible with tps65218
 +
 +Example:
 +
 +tps {
 + power-button {
 + compatible = ti,tps65218-pwrbutton;
 + interrupts = 3 IRQ_TYPE_EDGE_BOTH;
 + };
 +};
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index 23297ab..364cfb8 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -404,6 +404,16 @@ config INPUT_RETU_PWRBUTTON
 To compile this driver as a module, choose M here. The module will
 be called retu-pwrbutton.
  
 +config INPUT_TPS65218_PWRBUTTON
 + tristate TPS65218 Power button driver
 + depends on MFD_TPS65218
 + help
 +   Say Y here if you want to enable power buttong reporting for
 +   the TPS65218 Power Management IC device.
 +
 +   To compile this driver as a module, choose M here. The module will
 +   be called tps65218-pwrbutton.
 +
  config INPUT_TWL4030_PWRBUTTON
   tristate TWL4030 Power button Driver
   depends on TWL4030_CORE
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
 index 19c7603..a923753 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
 @@ -59,6 +59,7 @@ obj-$(CONFIG_INPUT_SGI_BTNS)+= sgi_btns.o
  obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)+= sirfsoc-onkey.o
  obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o
  obj-$(CONFIG_INPUT_SPARCSPKR)+= sparcspkr.o
 +obj-$(CONFIG_INPUT_TPS65218_PWRBUTTON)   += tps65218-pwrbutton.o
  obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON)+= twl4030-pwrbutton.o
  obj-$(CONFIG_INPUT_TWL4030_VIBRA)+= twl4030-vibra.o
  obj-$(CONFIG_INPUT_TWL6040_VIBRA)+= twl6040-vibra.o
 diff --git a/drivers/input/misc/tps65218-pwrbutton.c 
 b/drivers/input/misc/tps65218-pwrbutton.c
 new file mode 100644
 index 000..2f85e2e
 --- /dev/null
 +++ b/drivers/input/misc/tps65218-pwrbutton.c
 @@ -0,0 +1,124 @@
 +/*
 + * Texas Instruments' TPS65218 Power Button Input Driver
 + *
 + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
 + * Author: Felipe Balbi ba...@ti.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + *
 + * This program is distributed as is WITHOUT ANY WARRANTY of any
 + * kind, whether express or implied; without even the implied warranty
 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/init.h
 +#include linux/input.h
 +#include linux/interrupt.h
 +#include linux/kernel.h
 +#include linux/mfd/tps65218.h
 +#include linux/module.h
 +#include linux/of.h
 +#include linux/platform_device.h
 +#include linux/slab.h
 +
 +struct tps65218_pwrbutton {
 + struct device *dev;
 + struct tps65218 *tps;
 + struct input_dev *idev;
 +};
 +
 +static irqreturn_t tps65218_pwr_irq(int irq, void *_pwr)
 +{
 + struct tps65218_pwrbutton *pwr = _pwr;
 + unsigned int reg;
 + int error;
 +
 + error = tps65218_reg_read(pwr-tps, TPS65218_REG_STATUS, reg);
 + if (error) {
 + dev_err(pwr-dev, can't read register -- %d\n, error);
 + goto out;
 + }
 +
 + if (reg  TPS65218_STATUS_PB_STATE) {
 + input_report_key(pwr-idev, KEY_POWER, 1);
 +