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 bjorn.anders...@sonymobile.com
  Signed-off-by: Stephen Boyd sb...@codeaurora.org
  ---
  
  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 bjorn.anders...@sonymobile.com
 
 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


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

2015-07-13 Thread Dmitry Torokhov
Hi Stephen,

On Mon, Jul 13, 2015 at 04:30:34PM -0700, 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.

Just a bit of bikeshedding on my part...

 
 Cc: Bjorn Andersson bjorn.anders...@sonymobile.com
 Signed-off-by: Stephen Boyd sb...@codeaurora.org
 ---
  drivers/input/misc/pmic8xxx-pwrkey.c | 284 
 ++-
  1 file changed, 277 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c 
 b/drivers/input/misc/pmic8xxx-pwrkey.c
 index c4ca20e63221..1d1ee5951b3a 100644
 --- a/drivers/input/misc/pmic8xxx-pwrkey.c
 +++ b/drivers/input/misc/pmic8xxx-pwrkey.c
 @@ -20,17 +20,72 @@
  #include linux/regmap.h
  #include linux/log2.h
  #include linux/of.h
 +#include linux/of_device.h
  
  #define PON_CNTL_1 0x1C
  #define PON_CNTL_PULL_UP BIT(7)
  #define PON_CNTL_TRIG_DELAY_MASK (0x7)
 +#define PON_CNTL_1_PULL_UP_EN0xe0
 +#define PON_CNTL_1_USB_PWR_EN0x10
 +#define PON_CNTL_1_WD_EN_RESET   0x08
 +
 +#define PM8058_SLEEP_CTRL0x02b
 +#define PM8921_SLEEP_CTRL0x10a
 +
 +#define SLEEP_CTRL_SMPL_EN_RESET 0x04
 +
 +/* Regulator master enable addresses */
 +#define REG_PM8058_VREG_EN_MSM   0x018
 +#define REG_PM8058_VREG_EN_GRP_5_4   0x1C8
 +
 +/* Regulator control registers for shutdown/reset */
 +#define PM8058_S0_CTRL   0x004
 +#define PM8058_S1_CTRL   0x005
 +#define PM8058_S3_CTRL   0x111
 +#define PM8058_L21_CTRL  0x120
 +#define PM8058_L22_CTRL  0x121
 +
 +#define PM8058_REGULATOR_ENABLE_MASK 0x80
 +#define PM8058_REGULATOR_ENABLE  0x80
 +#define PM8058_REGULATOR_DISABLE 0x00
 +#define PM8058_REGULATOR_PULL_DOWN_MASK  0x40
 +#define PM8058_REGULATOR_PULL_DOWN_EN0x40
 +
 +/* Buck CTRL register */
 +#define PM8058_SMPS_LEGACY_VREF_SEL  0x20
 +#define PM8058_SMPS_LEGACY_VPROG_MASK0x1F
 +#define PM8058_SMPS_ADVANCED_BAND_MASK   0xC0
 +#define PM8058_SMPS_ADVANCED_BAND_SHIFT  6
 +#define PM8058_SMPS_ADVANCED_VPROG_MASK  0x3F
 +
 +/* Buck TEST2 registers for shutdown/reset */
 +#define PM8058_S0_TEST2  0x084
 +#define PM8058_S1_TEST2  0x085
 +#define PM8058_S3_TEST2  0x11A
 +
 +#define PM8058_REGULATOR_BANK_WRITE  0x80
 +#define PM8058_REGULATOR_BANK_MASK   0x70
 +#define PM8058_REGULATOR_BANK_SHIFT  4
 +#define PM8058_REGULATOR_BANK_SEL(n) ((n)  PM8058_REGULATOR_BANK_SHIFT)
 +
 +/* Buck TEST2 register bank 1 */
 +#define PM8058_SMPS_LEGACY_VLOW_SEL  0x01
 +
 +/* Buck TEST2 register bank 7 */
 +#define PM8058_SMPS_ADVANCED_MODE_MASK   0x02
 +#define PM8058_SMPS_ADVANCED_MODE0x02
 +#define PM8058_SMPS_LEGACY_MODE  0x00
  
  /**
   * struct pmic8xxx_pwrkey - pmic8xxx pwrkey information
   * @key_press_irq: key press irq number
 + * @regmap: device regmap
 + * @shutdown_fn: shutdown configuration function
   */
  struct pmic8xxx_pwrkey {
   int key_press_irq;
 + struct regmap *regmap;
 + int (*shutdown_fn)(struct pmic8xxx_pwrkey *, bool);
  };
  
  static irqreturn_t pwrkey_press_irq(int irq, void *_pwr)
 @@ -76,6 +131,220 @@ static int __maybe_unused pmic8xxx_pwrkey_resume(struct 
 device *dev)
  static SIMPLE_DEV_PM_OPS(pm8xxx_pwr_key_pm_ops,
   pmic8xxx_pwrkey_suspend, pmic8xxx_pwrkey_resume);
  
 +static void pmic8xxx_pwrkey_shutdown(struct platform_device *pdev)
 +{
 + struct pmic8xxx_pwrkey *pwrkey = platform_get_drvdata(pdev);
 + int ret;
 + u8 mask, val;
 + bool reset = system_state == SYSTEM_RESTART;
 +
 + if (pwrkey-shutdown_fn) {
 + ret = pwrkey-shutdown_fn(pwrkey, reset);
 + if (ret)
 + return;

Can we call this variable error please?

 + }
 +
 + /*
 +  * Select action to perform (reset or shutdown) when PS_HOLD goes low.
 +  * Also ensure that KPD, CBL0, and CBL1 pull ups are enabled and that
 +  * USB charging is enabled.
 +  */
 + mask = PON_CNTL_1_PULL_UP_EN | PON_CNTL_1_USB_PWR_EN;
 + mask |= PON_CNTL_1_WD_EN_RESET;
 + val = mask;
 + if (!reset)
 + val = ~PON_CNTL_1_WD_EN_RESET;
 +
 + regmap_update_bits(pwrkey-regmap, PON_CNTL_1, mask, val);
 +}
 +
 +/*
 + * Set an SMPS regulator to be disabled in its CTRL register, but enabled
 + * in the master enable register.  Also set it's pull 

Re: [PATCH v2 0/2] Qualcomm PM8941 power key driver

2015-03-24 Thread Dmitry Torokhov
On Fri, Mar 20, 2015 at 02:54:33AM +0100, Bjorn Andersson wrote:
 On Mon, Feb 16, 2015 at 10:55 AM, Ivan T. Ivanov iiva...@mm-sol.com wrote:
 
  On Fri, 2015-01-23 at 16:19 -0800, Bjorn Andersson wrote:
  These patches add dt bindings and a device driver for the power key block 
  in
  the Qualcomm PM8941 pmic.
 
  Changes since v1:
   * Use a reboot_notifier to set power off/reboot mode
   * Use irq flags from devicetree
   * Some style fixes
 
  Courtney Cavin (2):
input: Add Qualcomm PM8941 power key driver
input: pm8941-pwrkey: Add DT binding documentation
 
  Tested-by: Ivan T. Ivanov iiva...@mm-sol.com
 
 
 Thanks for your testing Ivan.
 
 Dmitry, can you apply this? (It still applies cleanly to linux-next)
 

Queued for 4.1, thank you.

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


Re: [PATCH 2/4] Input: pmic8xxx-keypad - use regmap_field for register access

2014-10-27 Thread Dmitry Torokhov
On Mon, Oct 27, 2014 at 05:30:41PM +0200, Ivan T. Ivanov wrote:
 
 Hi Dmitry, 
 
 On Mon, 2014-10-13 at 16:02 +0200, Mark Brown wrote:
  On Wed, Oct 08, 2014 at 01:32:33PM -0700, Dmitry Torokhov wrote:
   On Wed, Oct 08, 2014 at 09:04:26PM +0100, Mark Brown wrote:
On Wed, Oct 08, 2014 at 11:20:58AM -0700, Stephen Boyd wrote:
  
 Srini/Mark, any reason why the regmap_field structure is opaque?
  
So you can't peer into it and rely on the contents.  I can see it being
useful to add a bulk allocator.
  
   And then one have to define offsets in an array and use awkward syntax
   to access individual fields. Can we just reply on reviews/documentation
   for users to not do wrong thing?
  
  I have very little confidence in users not doing awful things to be
  honest, this is the sort of API where the users are just random things
  all over the kernel so this sort of thing tends to be found after the
  fact.  I get a lot of these in drivers that just got thrown over the
  wall so nobody really knows what things are doing when you do find them.
  
  If the standard allocators aren't doing a good job (I've not checked)
  I'd much rather handle this inside the API if we can.
  
 
 Is there something that I can help here or patches are good as they are? :-)

Well, as far as I can see Bjorn (in the other thread) has some
objections on merging these devices together, so I ma just waiting for
you settle this issue.

I see he's not on this therad so let's CC him.

For the record I ma still not happy that we need to dynamically allocate
all these regmap fields.

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


Re: [PATCH 2/4] Input: pmic8xxx-keypad - use regmap_field for register access

2014-10-08 Thread Dmitry Torokhov
On Wed, Oct 08, 2014 at 09:04:26PM +0100, Mark Brown wrote:
 On Wed, Oct 08, 2014 at 11:20:58AM -0700, Stephen Boyd wrote:
  On 10/08/2014 11:13 AM, Dmitry Torokhov wrote:
 
  Oops. struct regmap_field is opaque. It seems that the allocation
  is the only way that I could have instance of it.
 
  Maybe we can add an API to allocate an array of fields?
 
  Maybe we could make the structure public instead? I do not see any
  reason for allocating something separately that has exactly the same
  lifetime as owning structure.
 
 The lifetime may be different to that of the register map it references,
 consider MFD function devices for example.  

Exactly, it is different than lifetime of the register map, but the same
as device structure of the driver instantiating it. And so instead of
doing 10+ separate allocations one could do just one.

 
  Srini/Mark, any reason why the regmap_field structure is opaque?
 
 So you can't peer into it and rely on the contents.  I can see it being
 useful to add a bulk allocator.

And then one have to define offsets in an array and use awkward syntax
to access individual fields. Can we just reply on reviews/documentation
for users to not do wrong thing?

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


Re: [PATCH 2/4] Input: pmic8xxx-keypad - use regmap_field for register access

2014-10-07 Thread Dmitry Torokhov
Hi Ivan,

On Tue, Oct 07, 2014 at 12:50:46PM +0300, Ivan T. Ivanov wrote:
 @@ -527,10 +538,55 @@ static int pmic8xxx_kp_probe(struct platform_device 
 *pdev)
  
   platform_set_drvdata(pdev, kp);
  
 + if (rows  info-min_rows)
 + rows = info-min_rows;
 +
 + if (cols  info-min_cols)
 + cols = info-min_cols;
 +
   kp-num_rows= rows;
   kp-num_cols= cols;
   kp-dev = pdev-dev;
  
 + kp-events = devm_regmap_field_alloc(kp-dev, kp-regmap,
 +  info-events);
 + if (IS_ERR(kp-events))
 + return PTR_ERR(kp-events);
 +
 + kp-scan_rows = devm_regmap_field_alloc(kp-dev, kp-regmap,
 + info-scan_rows);
 + if (IS_ERR(kp-scan_rows))
 + return PTR_ERR(kp-scan_rows);
 +
 + kp-scan_cols = devm_regmap_field_alloc(kp-dev, kp-regmap,
 + info-scan_cols);
 + if (IS_ERR(kp-scan_cols))
 + return PTR_ERR(kp-scan_cols);
 +
 + kp-enable = devm_regmap_field_alloc(kp-dev, kp-regmap,
 +  info-enable);
 + if (IS_ERR(kp-enable))
 + return PTR_ERR(kp-enable);
 +
 + kp-read_state = devm_regmap_field_alloc(kp-dev, kp-regmap,
 +  info-read_state);
 + if (IS_ERR(kp-read_state))
 + return PTR_ERR(kp-read_state);
 +
 + kp-dbonce = devm_regmap_field_alloc(kp-dev, kp-regmap,
 +  info-dbonce);
 + if (IS_ERR(kp-dbonce))
 + return PTR_ERR(kp-dbonce);
 +
 + kp-pause = devm_regmap_field_alloc(kp-dev, kp-regmap, info-pause);
 + if (IS_ERR(kp-pause))
 + return PTR_ERR(kp-pause);
 +
 + kp-row_hold = devm_regmap_field_alloc(kp-dev, kp-regmap,
 +info-row_hold);
 + if (IS_ERR(kp-row_hold))
 + return PTR_ERR(kp-row_hold);

Why do we have to allocate all regmap fields separately instead of
embedding them into keypad structure?

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


Re: [PATCH 1/2] input: Add Qualcomm PM8941 power key driver

2014-10-06 Thread Dmitry Torokhov
Hi Bjorn,

On Mon, Oct 06, 2014 at 06:12:00PM -0700, Bjorn Andersson wrote:
 +
 + rc = devm_request_threaded_irq(pdev-dev, pwrkey-irq,
 + NULL, pm8941_pwrkey_irq,
 + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |

Do we need to hard-code IRQ flags like this? I'd rather we respect DT
data.

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


Re: [PATCH 1/2] input: Add Qualcomm PM8941 power key driver

2014-10-06 Thread Dmitry Torokhov
On Mon, Oct 06, 2014 at 06:52:51PM -0700, Bjorn Andersson wrote:
 On Mon 06 Oct 18:30 PDT 2014, Dmitry Torokhov wrote:
 
  Hi Bjorn,
  
 
 Hi,
 
  On Mon, Oct 06, 2014 at 06:12:00PM -0700, Bjorn Andersson wrote:
   +
   + rc = devm_request_threaded_irq(pdev-dev, pwrkey-irq,
   + NULL, pm8941_pwrkey_irq,
   + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
  
  Do we need to hard-code IRQ flags like this? I'd rather we respect DT
  data.
  
 
 We could move it to DT but I don't think there's any other combination of
 these flags would make sense. If you insist I can remove it though.

No, that's fine if you are certain we want to react on both edges always.

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


Re: [PATCH] Input: pmic8xxx-pwrkey - Set sane default for debounce time

2014-05-14 Thread Dmitry Torokhov
On Mon, Mar 31, 2014 at 11:29:27AM -0700, Stephen Boyd wrote:
 On 03/31/14 11:23, Dmitry Torokhov wrote:
  On Mon, Mar 31, 2014 at 11:14:24AM -0700, Stephen Boyd wrote:
  If the debounce time is 0 our usage of ilog2() later on in this
  driver will cause undefined behavior. If CONFIG_OF=n this fact is
  evident to the compiler, and it emits a call to ilog2_NaN()
  which doesn't exist. Fix this by setting a sane default for
  debounce.
 
  Reported-by: Arnd Bergmann a...@arndb.de
  Signed-off-by: Stephen Boyd sb...@codeaurora.org
  ---
   drivers/input/misc/pmic8xxx-pwrkey.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
  diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c 
  b/drivers/input/misc/pmic8xxx-pwrkey.c
  index 1cb8fda7a166..27add04676e1 100644
  --- a/drivers/input/misc/pmic8xxx-pwrkey.c
  +++ b/drivers/input/misc/pmic8xxx-pwrkey.c
  @@ -92,7 +92,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device 
  *pdev)
 bool pull_up;
   
 if (of_property_read_u32(pdev-dev.of_node, debounce, kpd_delay))
  -  kpd_delay = 0;
  +  kpd_delay = 15625;
  What if somebody supplied 0 via DT? Can we check and return -EINVAL?
 
 Sure. Here's a v2.
 
 -8--
 From: Stephen Boyd sb...@codeaurora.org
 Subject: [PATCH v2] Input: pmic8xxx-pwrkey - Set sane default for debounce
  time
 
 If the debounce time is 0 our usage of ilog2() later on in this
 driver will cause undefined behavior. If CONFIG_OF=n this fact is
 evident to the compiler, and it emits a call to ilog2_NaN()
 which doesn't exist. Fix this by setting a sane default for
 debounce and failing to probe if debounce is 0 in the DT.
 
 Reported-by: Arnd Bergmann a...@arndb.de
 Signed-off-by: Stephen Boyd sb...@codeaurora.org

Applied, thank you. Sorry for the delay.

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


Re: [PATCH] Input: pmic8xxx-pwrkey - Set sane default for debounce time

2014-03-31 Thread Dmitry Torokhov
On Mon, Mar 31, 2014 at 11:14:24AM -0700, Stephen Boyd wrote:
 If the debounce time is 0 our usage of ilog2() later on in this
 driver will cause undefined behavior. If CONFIG_OF=n this fact is
 evident to the compiler, and it emits a call to ilog2_NaN()
 which doesn't exist. Fix this by setting a sane default for
 debounce.
 
 Reported-by: Arnd Bergmann a...@arndb.de
 Signed-off-by: Stephen Boyd sb...@codeaurora.org
 ---
  drivers/input/misc/pmic8xxx-pwrkey.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c 
 b/drivers/input/misc/pmic8xxx-pwrkey.c
 index 1cb8fda7a166..27add04676e1 100644
 --- a/drivers/input/misc/pmic8xxx-pwrkey.c
 +++ b/drivers/input/misc/pmic8xxx-pwrkey.c
 @@ -92,7 +92,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device 
 *pdev)
   bool pull_up;
  
   if (of_property_read_u32(pdev-dev.of_node, debounce, kpd_delay))
 - kpd_delay = 0;
 + kpd_delay = 15625;

What if somebody supplied 0 via DT? Can we check and return -EINVAL?

  
   pull_up = of_property_read_bool(pdev-dev.of_node, pull-up);
  
 -- 
 The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
 hosted by The Linux Foundation
 

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


Re: [PATCH v5 0/9] Use regmap+devm+DT in pm8xxx input drivers

2014-03-29 Thread Dmitry Torokhov
On Tue, Mar 04, 2014 at 10:34:39AM -0800, Stephen Boyd wrote:
 These patches move the pm8xxx input drivers over to use devm_* APIs
 and regmap. This breaks the dependency of these drivers on the pm8xxx
 specific read/write calls and also simplifies the probe code a bit.
 Finally we add devicetree support to these drivers so they can be probed
 on the platforms that are supported upstream.

Applied all (and folded DT binding patches into respective driver
changes).

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


Re: [PATCH 2/7] Input: pmic8xxx-pwrkey - Migrate to regmap APIs

2014-01-02 Thread Dmitry Torokhov
On Thu, Jan 02, 2014 at 06:49:59PM +, Mark Brown wrote:
 On Sun, Dec 15, 2013 at 03:33:37AM -0800, Dmitry Torokhov wrote:
  On Tue, Dec 10, 2013 at 03:43:11PM -0800, Stephen Boyd wrote:
 
   + regmap = dev_get_regmap(pdev-dev.parent, NULL);
   + if (!regmap)
   + return -ENODEV;
 
  And you are leaking memory here...
 
 He's not, dev_get_regmap() just gets a pointer to an existing regmap -
 no reference is taken and nothing is allocated.  It's a helper that's
 mainly there so that generic code can be written without needing the
 regmap to be passed around.  The caller is responsible for ensuring that
 it will stick around for as long as it's used (generally by having it
 lifetime managed with the device).

I was not talking about data returned by dev_get_regmap() but all other
memory that was allocated before as this was pre devm conversion of the
driver.

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


Re: [PATCH 6/7] Input: pmic8xxx-keypad - Migrate to devm_* APIs

2013-12-16 Thread Dmitry Torokhov
On Tue, Dec 10, 2013 at 03:43:15PM -0800, Stephen Boyd wrote:
 Simplify the error paths and reduce the lines of code in this
 driver by using the devm_* APIs.
 
 Signed-off-by: Stephen Boyd sb...@codeaurora.org
 ---
  drivers/input/keyboard/pmic8xxx-keypad.c | 62 
 +---
  1 file changed, 17 insertions(+), 45 deletions(-)
 
 diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c 
 b/drivers/input/keyboard/pmic8xxx-keypad.c
 index 2c9f19a..4e6bfbf 100644
 --- a/drivers/input/keyboard/pmic8xxx-keypad.c
 +++ b/drivers/input/keyboard/pmic8xxx-keypad.c
 @@ -586,7 +586,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
   return -EINVAL;
   }
  
 - kp = kzalloc(sizeof(*kp), GFP_KERNEL);
 + kp = devm_kzalloc(pdev-dev, sizeof(*kp), GFP_KERNEL);
   if (!kp)
   return -ENOMEM;
  
 @@ -595,32 +595,27 @@ static int pmic8xxx_kp_probe(struct platform_device 
 *pdev)
   kp-pdata   = pdata;
   kp-dev = pdev-dev;
  
 - kp-input = input_allocate_device();
 + kp-input = devm_input_allocate_device(pdev-dev);
   if (!kp-input) {
   dev_err(pdev-dev, unable to allocate input device\n);
 - rc = -ENOMEM;
 - goto err_alloc_device;
 + return -ENOMEM;
   }
  
   kp-key_sense_irq = platform_get_irq(pdev, 0);
   if (kp-key_sense_irq  0) {
   dev_err(pdev-dev, unable to get keypad sense irq\n);
 - rc = -ENXIO;
 - goto err_get_irq;
 + return kp-key_sense_irq;
   }
  
   kp-key_stuck_irq = platform_get_irq(pdev, 1);
   if (kp-key_stuck_irq  0) {
   dev_err(pdev-dev, unable to get keypad stuck irq\n);
 - rc = -ENXIO;
 - goto err_get_irq;
 + return kp-key_stuck_irq;
   }
  
   kp-input-name = pdata-input_name ? : PMIC8XXX keypad;
   kp-input-phys = pdata-input_phys_device ? : pmic8xxx_keypad/input0;
  
 - kp-input-dev.parent   = pdev-dev;
 -
   kp-input-id.bustype   = BUS_I2C;
   kp-input-id.version   = 0x0001;
   kp-input-id.product   = 0x0001;
 @@ -634,7 +629,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
   kp-keycodes, kp-input);
   if (rc) {
   dev_err(pdev-dev, failed to build keymap\n);
 - goto err_get_irq;
 + return rc;
   }
  
   if (pdata-rep)
 @@ -650,7 +645,7 @@ static int pmic8xxx_kp_probe(struct platform_device *pdev)
   rc = pmic8xxx_kpd_init(kp);
   if (rc  0) {
   dev_err(pdev-dev, unable to initialize keypad controller\n);
 - goto err_get_irq;
 + return rc;
   }
  
   rc = pmic8xxx_kp_config_gpio(pdata-cols_gpio_start,
 @@ -667,24 +662,26 @@ static int pmic8xxx_kp_probe(struct platform_device 
 *pdev)
   goto err_gpio_config;
   }
  
 - rc = request_any_context_irq(kp-key_sense_irq, pmic8xxx_kp_irq,
 -  IRQF_TRIGGER_RISING, pmic-keypad, kp);
 + rc = devm_request_any_context_irq(pdev-dev, kp-key_sense_irq,
 + pmic8xxx_kp_irq, IRQF_TRIGGER_RISING, pmic-keypad,
 + kp);
   if (rc  0) {
   dev_err(pdev-dev, failed to request keypad sense irq\n);
 - goto err_get_irq;
 + return rc;
   }
  
 - rc = request_any_context_irq(kp-key_stuck_irq, pmic8xxx_kp_stuck_irq,
 -  IRQF_TRIGGER_RISING, pmic-keypad-stuck, kp);
 + rc = devm_request_any_context_irq(pdev-dev, kp-key_stuck_irq,
 + pmic8xxx_kp_stuck_irq, IRQF_TRIGGER_RISING,
 + pmic-keypad-stuck, kp);
   if (rc  0) {
   dev_err(pdev-dev, failed to request keypad stuck irq\n);
 - goto err_req_stuck_irq;
 + return rc;
   }
  
   rc = pmic8xxx_kp_read_u8(kp, ctrl_val, KEYP_CTRL);
   if (rc  0) {
   dev_err(pdev-dev, failed to read KEYP_CTRL register\n);
 - goto err_pmic_reg_read;
 + return rc;
   }
  
   kp-ctrl_reg = ctrl_val;
 @@ -692,36 +689,12 @@ static int pmic8xxx_kp_probe(struct platform_device 
 *pdev)
   rc = input_register_device(kp-input);
   if (rc  0) {
   dev_err(pdev-dev, unable to register keypad input device\n);
 - goto err_pmic_reg_read;
 + return rc;
   }
  
   device_init_wakeup(pdev-dev, pdata-wakeup);
  
   return 0;
 -
 -err_pmic_reg_read:
 - free_irq(kp-key_stuck_irq, kp);
 -err_req_stuck_irq:
 - free_irq(kp-key_sense_irq, kp);
 -err_gpio_config:
 -err_get_irq:
 - input_free_device(kp-input);
 -err_alloc_device:
 - kfree(kp);
 - return rc;
 -}
 -
 -static int pmic8xxx_kp_remove(struct platform_device *pdev)
 -{
 - struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
 -
 - device_init_wakeup(pdev-dev, 0);

Why are we removing 

Re: [PATCH 5/7] genirq: Add devm_request_any_context_irq()

2013-12-15 Thread Dmitry Torokhov
On Tue, Dec 10, 2013 at 03:43:14PM -0800, Stephen Boyd wrote:
 Some drivers use request_any_context_irq() but there isn't a
 devm_* function for it. Add one so that these drivers don't need
 to explicitly free the irq on driver detach.
 
 Cc: Thomas Gleixner t...@linutronix.de

Thomas, would it be OK with me picking this patch through my tree if you
do not have issues with it?

Thanks.

 Signed-off-by: Stephen Boyd sb...@codeaurora.org
 ---
  include/linux/interrupt.h |  5 +
  kernel/irq/devres.c   | 45 +
  2 files changed, 50 insertions(+)
 
 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
 index c9e831d..8334f9b 100644
 --- a/include/linux/interrupt.h
 +++ b/include/linux/interrupt.h
 @@ -160,6 +160,11 @@ devm_request_irq(struct device *dev, unsigned int irq, 
 irq_handler_t handler,
devname, dev_id);
  }
  
 +extern int __must_check
 +devm_request_any_context_irq(struct device *dev, unsigned int irq,
 +  irq_handler_t handler, unsigned long irqflags,
 +  const char *devname, void *dev_id);
 +
  extern void devm_free_irq(struct device *dev, unsigned int irq, void 
 *dev_id);
  
  /*
 diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
 index bd8e788..f71e9ff 100644
 --- a/kernel/irq/devres.c
 +++ b/kernel/irq/devres.c
 @@ -73,6 +73,51 @@ int devm_request_threaded_irq(struct device *dev, unsigned 
 int irq,
  EXPORT_SYMBOL(devm_request_threaded_irq);
  
  /**
 + *   devm_request_any_context_irq - allocate an interrupt line for a managed 
 device
 + *   @dev: device to request interrupt for
 + *   @irq: Interrupt line to allocate
 + *   @handler: Function to be called when the IRQ occurs
 + *   @thread_fn: function to be called in a threaded interrupt context. NULL
 + *   for devices which handle everything in @handler
 + *   @irqflags: Interrupt type flags
 + *   @devname: An ascii name for the claiming device
 + *   @dev_id: A cookie passed back to the handler function
 + *
 + *   Except for the extra @dev argument, this function takes the
 + *   same arguments and performs the same function as
 + *   request_any_context_irq().  IRQs requested with this function will be
 + *   automatically freed on driver detach.
 + *
 + *   If an IRQ allocated with this function needs to be freed
 + *   separately, devm_free_irq() must be used.
 + */
 +int devm_request_any_context_irq(struct device *dev, unsigned int irq,
 +   irq_handler_t handler, unsigned long irqflags,
 +   const char *devname, void *dev_id)
 +{
 + struct irq_devres *dr;
 + int rc;
 +
 + dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres),
 +   GFP_KERNEL);
 + if (!dr)
 + return -ENOMEM;
 +
 + rc = request_any_context_irq(irq, handler, irqflags, devname, dev_id);
 + if (rc) {
 + devres_free(dr);
 + return rc;
 + }
 +
 + dr-irq = irq;
 + dr-dev_id = dev_id;
 + devres_add(dev, dr);
 +
 + return 0;
 +}
 +EXPORT_SYMBOL(devm_request_any_context_irq);
 +
 +/**
   *   devm_free_irq - free an interrupt
   *   @dev: device to free interrupt for
   *   @irq: Interrupt line to free
 -- 
 The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
 hosted by The Linux Foundation
 

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


Re: [PATCH 2/7] Input: pmic8xxx-pwrkey - Migrate to regmap APIs

2013-12-15 Thread Dmitry Torokhov
On Tue, Dec 10, 2013 at 03:43:11PM -0800, Stephen Boyd wrote:
 Use the regmap APIs for this driver instead of custom pm8xxx
 APIs. This breaks this driver's dependency on the pm8xxx APIs and
 allows us to easily port it to other bus protocols in the future.
 
 Signed-off-by: Stephen Boyd sb...@codeaurora.org
 ---
  drivers/input/misc/pmic8xxx-pwrkey.c | 13 +
  1 file changed, 9 insertions(+), 4 deletions(-)
 
 diff --git a/drivers/input/misc/pmic8xxx-pwrkey.c 
 b/drivers/input/misc/pmic8xxx-pwrkey.c
 index 233b216..a4de105 100644
 --- a/drivers/input/misc/pmic8xxx-pwrkey.c
 +++ b/drivers/input/misc/pmic8xxx-pwrkey.c
 @@ -18,9 +18,9 @@
  #include linux/input.h
  #include linux/interrupt.h
  #include linux/platform_device.h
 +#include linux/regmap.h
  #include linux/log2.h
  
 -#include linux/mfd/pm8xxx/core.h
  #include linux/input/pmic8xxx-pwrkey.h
  
  #define PON_CNTL_1 0x1C
 @@ -83,7 +83,8 @@ static int pmic8xxx_pwrkey_probe(struct platform_device 
 *pdev)
   int key_press_irq = platform_get_irq(pdev, 1);
   int err;
   unsigned int delay;
 - u8 pon_cntl;
 + unsigned int pon_cntl;
 + struct regmap *regmap;
   struct pmic8xxx_pwrkey *pwrkey;
   const struct pm8xxx_pwrkey_platform_data *pdata =
   dev_get_platdata(pdev-dev);
 @@ -108,6 +109,10 @@ static int pmic8xxx_pwrkey_probe(struct platform_device 
 *pdev)
   err = -ENOMEM;
   }
  
 + regmap = dev_get_regmap(pdev-dev.parent, NULL);
 + if (!regmap)
 + return -ENODEV;

And you are leaking memory here...

 +
   input_set_capability(pwr, EV_KEY, KEY_POWER);
  
   pwr-name = pmic8xxx_pwrkey;
 @@ -116,7 +121,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device 
 *pdev)
   delay = (pdata-kpd_trigger_delay_us  10) / USEC_PER_SEC;
   delay = 1 + ilog2(delay);
  
 - err = pm8xxx_readb(pdev-dev.parent, PON_CNTL_1, pon_cntl);
 + err = regmap_read(regmap, PON_CNTL_1, pon_cntl);
   if (err  0) {
   dev_err(pdev-dev, failed reading PON_CNTL_1 err=%d\n, err);
   return err;
 @@ -129,7 +134,7 @@ static int pmic8xxx_pwrkey_probe(struct platform_device 
 *pdev)
   else
   pon_cntl = ~PON_CNTL_PULL_UP;
  
 - err = pm8xxx_writeb(pdev-dev.parent, PON_CNTL_1, pon_cntl);
 + err = regmap_write(regmap, PON_CNTL_1, pon_cntl);
   if (err  0) {
   dev_err(pdev-dev, failed writing PON_CNTL_1 err=%d\n, err);
   return err;
 -- 
 The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
 hosted by The Linux Foundation
 

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


Re: [PATCH] input: misc: Add support for pm8xxx based vibrator driver

2011-08-03 Thread Dmitry Torokhov
On Tue, Aug 02, 2011 at 02:30:18PM +0530, Anirudh Ghayal wrote:
 Hi Dmitry,
 
 On 8/2/2011 12:11 PM, Dmitry Torokhov wrote:
 On Tue, Aug 02, 2011 at 11:57:13AM +0530, Anirudh Ghayal wrote:
 
 Yes should have been dev_err.
 
 Dmitry, would you like me to submit another patch for this? I can
 make the @work change as well. Or would you make this minor change
 as well. Thank you.
 
 
 Anirudh, I made this plus a few more cosmetic changes, if you could try
 the patch below and let me know if it still works I will commit it for
 the next merge window.
 
 
 Thank you for making changes. I have tested the patch and it works fine.
 

Thank you, I queued it for 3.2.

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


Re: [PATCH] input: misc: Add support for pm8xxx based vibrator driver

2011-08-02 Thread Dmitry Torokhov
On Tue, Aug 02, 2011 at 11:57:13AM +0530, Anirudh Ghayal wrote:
 
 Yes should have been dev_err.
 
 Dmitry, would you like me to submit another patch for this? I can
 make the @work change as well. Or would you make this minor change
 as well. Thank you.
 

Anirudh, I made this plus a few more cosmetic changes, if you could try
the patch below and let me know if it still works I will commit it for
the next merge window.

Thanks.

-- 
Dmitry


Input: misc - Add support for pm8xxx based vibrator driver

From: Amy Maloche amalo...@codeaurora.org

Add support for pm8xx based vibrator to facilitate haptics.
This module uses the ff-memless framework.

Signed-off-by: Amy Maloche amalo...@codeaurora.org
Signed-off-by: Anirudh Ghayal agha...@codeaurora.org
Reviewed-by: Wanlong Gao gaowanl...@cn.fujitsu.com
Signed-off-by: Dmitry Torokhov d...@mail.ru
---

 drivers/input/misc/Kconfig   |   34 +++-
 drivers/input/misc/Makefile  |3 
 drivers/input/misc/pm8xxx-vibrator.c |  296 ++
 3 files changed, 321 insertions(+), 12 deletions(-)
 create mode 100644 drivers/input/misc/pm8xxx-vibrator.c


diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7ec4a20..bc53df5 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -74,6 +74,29 @@ config INPUT_PCSPKR
  To compile this driver as a module, choose M here: the
  module will be called pcspkr.
 
+config INPUT_PM8XXX_VIBRATOR
+   tristate Qualcomm PM8XXX vibrator support
+   depends on MFD_PM8XXX
+   select INPUT_FF_MEMLESS
+   help
+ This option enables device driver support for the vibrator
+ on Qualcomm PM8xxx chip. This driver supports ff-memless interface
+ from input framework.
+
+ To compile this driver as module, choose M here: the
+ module will be called pm8xxx-vibrator.
+
+config INPUT_PMIC8XXX_PWRKEY
+   tristate PMIC8XXX power key support
+   depends on MFD_PM8XXX
+   help
+ Say Y here if you want support for the PMIC8XXX power key.
+
+ If unsure, say N.
+
+ To compile this driver as a module, choose M here: the
+ module will be called pmic8xxx-pwrkey.
+
 config INPUT_SPARCSPKR
tristate SPARC Speaker support
depends on PCI  SPARC64
@@ -368,17 +391,6 @@ config INPUT_PWM_BEEPER
  To compile this driver as a module, choose M here: the module will be
  called pwm-beeper.
 
-config INPUT_PMIC8XXX_PWRKEY
-   tristate PMIC8XXX power key support
-   depends on MFD_PM8XXX
-   help
- Say Y here if you want support for the PMIC8XXX power key.
-
- If unsure, say N.
-
- To compile this driver as a module, choose M here: the
- module will be called pmic8xxx-pwrkey.
-
 config INPUT_GPIO_ROTARY_ENCODER
tristate Rotary encoders connected to GPIO pins
depends on GPIOLIB  GENERIC_GPIO
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b56b9bf..3dc2a5f 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -34,9 +34,10 @@ obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o
 obj-$(CONFIG_INPUT_PCF50633_PMU)   += pcf50633-input.o
 obj-$(CONFIG_INPUT_PCF8574)+= pcf8574_keypad.o
 obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
+obj-$(CONFIG_INPUT_PM8XXX_VIBRATOR)+= pm8xxx-vibrator.o
+obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)+= pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_POWERMATE)  += powermate.o
 obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o
-obj-$(CONFIG_INPUT_PMIC8XXX_PWRKEY)+= pmic8xxx-pwrkey.o
 obj-$(CONFIG_INPUT_RB532_BUTTON)   += rb532_button.o
 obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)+= rotary_encoder.o
 obj-$(CONFIG_INPUT_SGI_BTNS)   += sgi_btns.o
diff --git a/drivers/input/misc/pm8xxx-vibrator.c 
b/drivers/input/misc/pm8xxx-vibrator.c
new file mode 100644
index 000..58c72c5
--- /dev/null
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -0,0 +1,296 @@
+/* Copyright (c) 2010-2011, Code Aurora Forum. 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/init.h
+#include linux/kernel.h
+#include linux/errno.h
+#include linux/platform_device.h
+#include linux/input.h
+#include linux/slab.h
+#include linux/mfd/pm8xxx/core.h
+
+#define VIB_DRV0x4A
+
+#define VIB_DRV_SEL_MASK   0xf8
+#define VIB_DRV_SEL_SHIFT  0x03
+#define VIB_DRV_EN_MANUAL_MASK 0xfc
+
+#define VIB_MAX_LEVEL_mV

Re: [PATCH] input: misc: Add support for pm8xxx based vibrator driver

2011-08-01 Thread Dmitry Torokhov
On Tue, Aug 02, 2011 at 12:42:43PM +0800, Wanlong Gao wrote:
 On 08/02/2011 12:13 PM, Anirudh Ghayal wrote:
 +/*
 + * struct pm8xxx_vib - structure to hold vibrator data
 + * @vib_input_dev: input device supporting force feedback
 + * @vwork: work structure to set the vibration parameters
 Anirudh,  It's should be @work?

Looks like it, I can fix it up locally, no need to resubmit.

BTW, please do not hesitate to add your Reviewed-by or Acked-by if you
are mostly satisfied with the patch (sans a few minor issues that you
should point out). I can't guarantee that I will always add your tags
(depends on when I commit the patch to my one of my public branches) but
I will try to do so.

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


Re: [PATCH] input: misc: Add support for pm8xxx based vibrator driver

2011-08-01 Thread Dmitry Torokhov
On Tue, Aug 02, 2011 at 01:18:46PM +0800, Wanlong Gao wrote:
 On 08/02/2011 01:11 PM, Dmitry Torokhov wrote:
 On Tue, Aug 02, 2011 at 12:42:43PM +0800, Wanlong Gao wrote:
 On 08/02/2011 12:13 PM, Anirudh Ghayal wrote:
 +/*
 + * struct pm8xxx_vib - structure to hold vibrator data
 + * @vib_input_dev: input device supporting force feedback
 + * @vwork: work structure to set the vibration parameters
 Anirudh,  It's should be @work?
 
 Looks like it, I can fix it up locally, no need to resubmit.
 
 BTW, please do not hesitate to add your Reviewed-by or Acked-by if you
 are mostly satisfied with the patch (sans a few minor issues that you
 should point out). I can't guarantee that I will always add your tags
 (depends on when I commit the patch to my one of my public branches) but
 I will try to do so.
 
 Thanks.
 
 Sure, I see, thanks Dmitry.
 

So was this reviewed-by? ;)

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


Re: [PATCH V4] input: pm8xxx_keypad: Qualcomm pm8xxx keypad controller driver

2011-05-19 Thread Dmitry Torokhov
On Thu, May 19, 2011 at 10:54:04AM +0530, Anirudh Ghayal wrote:
 From: Trilok Soni ts...@codeaurora.org
 
 Add Qualcomm PMIC8XXX based keypad controller driver
 supporting upto 18x8 matrix configuration.
 
 Signed-off-by: Trilok Soni ts...@codeaurora.org
 Signed-off-by: Anirudh Ghayal agha...@codeaurora.org

Acked-by: Dmitry Torokhov d...@mail.ru

Thanks Anirudh, please feel free to merge through Samuel's tree.

 ---
  drivers/input/keyboard/Kconfig   |   11 +
  drivers/input/keyboard/Makefile  |1 +
  drivers/input/keyboard/pmic8xxx-keypad.c |  799 
 ++
  include/linux/input/pmic8xxx-keypad.h|   52 ++
  4 files changed, 863 insertions(+), 0 deletions(-)
  create mode 100644 drivers/input/keyboard/pmic8xxx-keypad.c
  create mode 100644 include/linux/input/pmic8xxx-keypad.h
 
 diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
 index b16bed0..42fe6f1 100644
 --- a/drivers/input/keyboard/Kconfig
 +++ b/drivers/input/keyboard/Kconfig
 @@ -390,6 +390,17 @@ config KEYBOARD_PXA930_ROTARY
 To compile this driver as a module, choose M here: the
 module will be called pxa930_rotary.
  
 +config KEYBOARD_PMIC8XXX
 + tristate Qualcomm PMIC8XXX keypad support
 + depends on MFD_PM8XXX
 + help
 +   Say Y here if you want to enable the driver for the PMIC8XXX
 +   keypad provided as a reference design from Qualcomm. This is intended
 +   to support upto 18x8 matrix based keypad design.
 +
 +   To compile this driver as a module, choose M here: the module will
 +   be called pmic8xxx-keypad.
 +
  config KEYBOARD_SAMSUNG
   tristate Samsung keypad support
   depends on SAMSUNG_DEV_KEYPAD
 diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
 index 878e6c2..ff996c8 100644
 --- a/drivers/input/keyboard/Makefile
 +++ b/drivers/input/keyboard/Makefile
 @@ -32,6 +32,7 @@ obj-$(CONFIG_KEYBOARD_NOMADIK)  += 
 nomadik-ske-keypad.o
  obj-$(CONFIG_KEYBOARD_OMAP)  += omap-keypad.o
  obj-$(CONFIG_KEYBOARD_OMAP4) += omap4-keypad.o
  obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o
 +obj-$(CONFIG_KEYBOARD_PMIC8XXX)  += pmic8xxx-keypad.o
  obj-$(CONFIG_KEYBOARD_PXA27x)+= pxa27x_keypad.o
  obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o
  obj-$(CONFIG_KEYBOARD_QT1070)   += qt1070.o
 diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c 
 b/drivers/input/keyboard/pmic8xxx-keypad.c
 new file mode 100644
 index 000..40b02ae
 --- /dev/null
 +++ b/drivers/input/keyboard/pmic8xxx-keypad.c
 @@ -0,0 +1,799 @@
 +/* Copyright (c) 2009-2011, Code Aurora Forum. 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/kernel.h
 +#include linux/interrupt.h
 +#include linux/slab.h
 +#include linux/input.h
 +#include linux/bitops.h
 +#include linux/delay.h
 +#include linux/mutex.h
 +
 +#include linux/mfd/pm8xxx/core.h
 +#include linux/mfd/pm8xxx/gpio.h
 +#include linux/input/pmic8xxx-keypad.h
 +
 +#define PM8XXX_MAX_ROWS  18
 +#define PM8XXX_MAX_COLS  8
 +#define PM8XXX_ROW_SHIFT 3
 +#define PM8XXX_MATRIX_MAX_SIZE   (PM8XXX_MAX_ROWS * PM8XXX_MAX_COLS)
 +
 +#define PM8XXX_MIN_ROWS  5
 +#define PM8XXX_MIN_COLS  5
 +
 +#define MAX_SCAN_DELAY   128
 +#define MIN_SCAN_DELAY   1
 +
 +/* in nanoseconds */
 +#define MAX_ROW_HOLD_DELAY   122000
 +#define MIN_ROW_HOLD_DELAY   30500
 +
 +#define MAX_DEBOUNCE_TIME20
 +#define MIN_DEBOUNCE_TIME5
 +
 +#define KEYP_CTRL0x148
 +
 +#define KEYP_CTRL_EVNTS  BIT(0)
 +#define KEYP_CTRL_EVNTS_MASK 0x3
 +
 +#define KEYP_CTRL_SCAN_COLS_SHIFT5
 +#define KEYP_CTRL_SCAN_COLS_MIN  5
 +#define KEYP_CTRL_SCAN_COLS_BITS 0x3
 +
 +#define KEYP_CTRL_SCAN_ROWS_SHIFT2
 +#define KEYP_CTRL_SCAN_ROWS_MIN  5
 +#define KEYP_CTRL_SCAN_ROWS_BITS 0x7
 +
 +#define KEYP_CTRL_KEYP_ENBIT(7)
 +
 +#define KEYP_SCAN0x149
 +
 +#define KEYP_SCAN_READ_STATE BIT(0)
 +#define KEYP_SCAN_DBOUNCE_SHIFT  1
 +#define KEYP_SCAN_PAUSE_SHIFT3
 +#define KEYP_SCAN_ROW_HOLD_SHIFT 6
 +
 +#define KEYP_TEST0x14A
 +
 +#define KEYP_TEST_CLEAR_RECENT_SCAN  BIT(6)
 +#define KEYP_TEST_CLEAR_OLD_SCAN BIT(5)
 +#define KEYP_TEST_READ_RESET BIT(4

Re: [PATCH 1/2] pwm: Add stubs for pwm operations

2011-05-18 Thread Dmitry Torokhov
On Wed, May 18, 2011 at 10:48:45AM +0530, Mohan Pallaka wrote:
 Chip drivers that support both pwm and non-pwm modes
 would encounter compilation errors if the platform doesn't
 have support for pwm, even though the chip is programmed
 to work in non-pwm mode. Add stubs for pwm functions to
 avoid compilation errors in these scenarios.
 
 Signed-off-by: Mohan Pallaka mpall...@codeaurora.org
 ---
  include/linux/pwm.h |   24 
  1 files changed, 24 insertions(+), 0 deletions(-)
 
 diff --git a/include/linux/pwm.h b/include/linux/pwm.h
 index 7c77575..f0bc51f 100644
 --- a/include/linux/pwm.h
 +++ b/include/linux/pwm.h
 @@ -3,6 +3,7 @@
  
  struct pwm_device;
  
 +#if defined(CONFIG_PWM)

Shouldn't it be CONFIG_HAVE_PWM?

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


Re: [PATCH V3 2/2] input: pmic8xxx_pwrkey: Add support for power key

2011-05-17 Thread Dmitry Torokhov
On Fri, May 13, 2011 at 03:17:51PM +0530, Anirudh Ghayal wrote:
 From: Trilok Soni ts...@codeaurora.org
 
 Add support for PMIC8XXX power key driven over dedicated
 KYPD_PWR_N pin.
 
 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Signed-off-by: Trilok Soni ts...@codeaurora.org
 Signed-off-by: Anirudh Ghayal agha...@codeaurora.org

Acked-by: Dmitry Torokhov d...@mail.ru

Anirudh,

Looks great, thank you for making changes. Please feel free to merge
with the rest of the pmic8xxx MFD patches. I assume they will go through
MFD tree, right?

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


Re: [PATCH V3 1/2] input: pmic8xxx-keypad: Add row and column gpio configuration

2011-05-17 Thread Dmitry Torokhov
On Fri, May 13, 2011 at 03:17:50PM +0530, Anirudh Ghayal wrote:
 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Signed-off-by: Anirudh Ghayal agha...@codeaurora.org

Acked-by: Dmitry Torokhov d...@mail.ru

 ---
  drivers/input/keyboard/pmic8xxx-keypad.c |   58 
 ++
  include/linux/input/pmic8xxx-keypad.h|2 +
  2 files changed, 60 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/input/keyboard/pmic8xxx-keypad.c 
 b/drivers/input/keyboard/pmic8xxx-keypad.c
 index 0229325..40b02ae 100644
 --- a/drivers/input/keyboard/pmic8xxx-keypad.c
 +++ b/drivers/input/keyboard/pmic8xxx-keypad.c
 @@ -21,6 +21,7 @@
  #include linux/mutex.h
  
  #include linux/mfd/pm8xxx/core.h
 +#include linux/mfd/pm8xxx/gpio.h
  #include linux/input/pmic8xxx-keypad.h
  
  #define PM8XXX_MAX_ROWS  18
 @@ -446,6 +447,27 @@ static int __devinit pmic8xxx_kpd_init(struct 
 pmic8xxx_kp *kp)
  
  }
  
 +static int  __devinit pmic8xxx_kp_config_gpio(int gpio_start, int num_gpios,
 + struct pmic8xxx_kp *kp, struct pm_gpio *gpio_config)
 +{
 + int rc, i;
 +
 + if (gpio_start  0 || num_gpios  0)
 + return -EINVAL;
 +
 + for (i = 0; i  num_gpios; i++) {
 + rc = pm8xxx_gpio_config(gpio_start + i, gpio_config);
 + if (rc) {
 + dev_err(kp-dev, %s: FAIL pm8xxx_gpio_config():
 + for PM GPIO [%d] rc=%d.\n,
 + __func__, gpio_start + i, rc);
 + return rc;
 + }
 +  }
 +
 + return 0;
 +}
 +
  static int pmic8xxx_kp_enable(struct pmic8xxx_kp *kp)
  {
   int rc;
 @@ -504,6 +526,27 @@ static int __devinit pmic8xxx_kp_probe(struct 
 platform_device *pdev)
   int rc;
   u8 ctrl_val;
  
 + struct pm_gpio kypd_drv = {
 + .direction  = PM_GPIO_DIR_OUT,
 + .output_buffer  = PM_GPIO_OUT_BUF_OPEN_DRAIN,
 + .output_value   = 0,
 + .pull   = PM_GPIO_PULL_NO,
 + .vin_sel= PM_GPIO_VIN_S3,
 + .out_strength   = PM_GPIO_STRENGTH_LOW,
 + .function   = PM_GPIO_FUNC_1,
 + .inv_int_pol= 1,
 + };
 +
 + struct pm_gpio kypd_sns = {
 + .direction  = PM_GPIO_DIR_IN,
 + .pull   = PM_GPIO_PULL_UP_31P5,
 + .vin_sel= PM_GPIO_VIN_S3,
 + .out_strength   = PM_GPIO_STRENGTH_NO,
 + .function   = PM_GPIO_FUNC_NORMAL,
 + .inv_int_pol= 1,
 + };
 +
 +
   if (!pdata || !pdata-num_cols || !pdata-num_rows ||
   pdata-num_cols  PM8XXX_MAX_COLS ||
   pdata-num_rows  PM8XXX_MAX_ROWS ||
 @@ -609,6 +652,20 @@ static int __devinit pmic8xxx_kp_probe(struct 
 platform_device *pdev)
   goto err_get_irq;
   }
  
 + rc = pmic8xxx_kp_config_gpio(pdata-cols_gpio_start,
 + pdata-num_cols, kp, kypd_sns);
 + if (rc  0) {
 + dev_err(pdev-dev, unable to configure keypad sense lines\n);
 + goto err_gpio_config;
 + }
 +
 + rc = pmic8xxx_kp_config_gpio(pdata-rows_gpio_start,
 + pdata-num_rows, kp, kypd_drv);
 + if (rc  0) {
 + dev_err(pdev-dev, unable to configure keypad drive lines\n);
 + goto err_gpio_config;
 + }
 +
   rc = request_any_context_irq(kp-key_sense_irq, pmic8xxx_kp_irq,
IRQF_TRIGGER_RISING, pmic-keypad, kp);
   if (rc  0) {
 @@ -645,6 +702,7 @@ err_pmic_reg_read:
   free_irq(kp-key_stuck_irq, NULL);
  err_req_stuck_irq:
   free_irq(kp-key_sense_irq, NULL);
 +err_gpio_config:
  err_get_irq:
   input_free_device(kp-input);
  err_alloc_device:
 diff --git a/include/linux/input/pmic8xxx-keypad.h 
 b/include/linux/input/pmic8xxx-keypad.h
 index fc2ac4c..5f1e2f9 100644
 --- a/include/linux/input/pmic8xxx-keypad.h
 +++ b/include/linux/input/pmic8xxx-keypad.h
 @@ -38,6 +38,8 @@ struct pm8xxx_keypad_platform_data {
  
   unsigned int num_cols;
   unsigned int num_rows;
 + unsigned int rows_gpio_start;
 + unsigned int cols_gpio_start;
  
   unsigned int debounce_ms;
   unsigned int scan_delay_ms;
 -- 
 Sent by a consultant of the Qualcomm Innovation Center, Inc.\nThe Qualcomm 
 Innovation Center, Inc. is a member of the Code Aurora Forum.
 

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


Re: [PATCH 1/2] pwm: Add __weak attributed functions for pwm operations

2011-05-15 Thread Dmitry Torokhov
On Fri, May 13, 2011 at 06:13:21PM +0530, Mohan Pallaka wrote:
 For chip drivers that support both pwm and non-pwm modes
 would encounter compilation errors if the platform doesn't
 have support for pwm though the chip is programmed to work
 in non-pwm mode. Add __weak attributed pwm functions to avoid
 compilation issues in these scenarios.
 

Russell,

You seem to have authored pwm.h, do you have any objections to this
change?

Thanks!

 Change-Id: Ia507bf659d4d67d71f135012e7d919aca6c45c6c
 Signed-off-by: Mohan Pallaka mpall...@codeaurora.org
 ---
  include/linux/pwm.h |   12 +++-
  1 files changed, 7 insertions(+), 5 deletions(-)
 
 diff --git a/include/linux/pwm.h b/include/linux/pwm.h
 index 7c77575..e0c8c3f 100644
 --- a/include/linux/pwm.h
 +++ b/include/linux/pwm.h
 @@ -3,29 +3,31 @@
  
  struct pwm_device;
  
 +/* Add __weak functions to support PWM */
 +
  /*
   * pwm_request - request a PWM device
   */
 -struct pwm_device *pwm_request(int pwm_id, const char *label);
 +struct pwm_device __weak *pwm_request(int pwm_id, const char *label);
  
  /*
   * pwm_free - free a PWM device
   */
 -void pwm_free(struct pwm_device *pwm);
 +void __weak pwm_free(struct pwm_device *pwm);
  
  /*
   * pwm_config - change a PWM device configuration
   */
 -int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
 +int __weak pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
  
  /*
   * pwm_enable - start a PWM output toggling
   */
 -int pwm_enable(struct pwm_device *pwm);
 +int __weak pwm_enable(struct pwm_device *pwm);
  
  /*
   * pwm_disable - stop a PWM output toggling
   */
 -void pwm_disable(struct pwm_device *pwm);
 +void __weak pwm_disable(struct pwm_device *pwm);
  
  #endif /* __LINUX_PWM_H */
 
 -- 
 Sent by a consultant of the Qualcomm Innovation Center, Inc.
 The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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


Re: [PATCH 1/2] pwm: Add __weak attributed functions for pwm operations

2011-05-15 Thread Dmitry Torokhov
On Fri, May 13, 2011 at 06:13:21PM +0530, Mohan Pallaka wrote:
 For chip drivers that support both pwm and non-pwm modes
 would encounter compilation errors if the platform doesn't
 have support for pwm though the chip is programmed to work
 in non-pwm mode. Add __weak attributed pwm functions to avoid
 compilation issues in these scenarios.
 

Russell,

You seem to have authored pwm.h, do you have any objections to this
change?

Thanks!

 Change-Id: Ia507bf659d4d67d71f135012e7d919aca6c45c6c
 Signed-off-by: Mohan Pallaka mpall...@codeaurora.org
 ---
  include/linux/pwm.h |   12 +++-
  1 files changed, 7 insertions(+), 5 deletions(-)
 
 diff --git a/include/linux/pwm.h b/include/linux/pwm.h
 index 7c77575..e0c8c3f 100644
 --- a/include/linux/pwm.h
 +++ b/include/linux/pwm.h
 @@ -3,29 +3,31 @@
  
  struct pwm_device;
  
 +/* Add __weak functions to support PWM */
 +
  /*
   * pwm_request - request a PWM device
   */
 -struct pwm_device *pwm_request(int pwm_id, const char *label);
 +struct pwm_device __weak *pwm_request(int pwm_id, const char *label);
  
  /*
   * pwm_free - free a PWM device
   */
 -void pwm_free(struct pwm_device *pwm);
 +void __weak pwm_free(struct pwm_device *pwm);
  
  /*
   * pwm_config - change a PWM device configuration
   */
 -int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
 +int __weak pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns);
  
  /*
   * pwm_enable - start a PWM output toggling
   */
 -int pwm_enable(struct pwm_device *pwm);
 +int __weak pwm_enable(struct pwm_device *pwm);
  
  /*
   * pwm_disable - stop a PWM output toggling
   */
 -void pwm_disable(struct pwm_device *pwm);
 +void __weak pwm_disable(struct pwm_device *pwm);
  
  #endif /* __LINUX_PWM_H */
 
 -- 
 Sent by a consultant of the Qualcomm Innovation Center, Inc.
 The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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


Re: [RFC v2 PATCH 7/7] input: misc: Add support for PM8058 based vibrator driver

2011-02-02 Thread Dmitry Torokhov
Hi Anirudh,

On Tue, Feb 01, 2011 at 07:17:43PM +0530, Anirudh Ghayal wrote:
 +
 +#include linux/mfd/pmic8058.h
 +#include linux/input/pmic8058-vibrator.h

Where is this header file? Shouldn't it be part of this patch?

 +
 +#define VIB_DRV  0x4A
 +
 +#define VIB_DRV_SEL_MASK 0xf8
 +#define VIB_DRV_SEL_SHIFT0x03
 +#define VIB_DRV_EN_MANUAL_MASK   0xfc
 +
 +#define VIB_MAX_LEVEL_mV (3100)
 +#define VIB_MIN_LEVEL_mV (1200)
 +#define VIB_MAX_LEVELS   (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV)
 +
 +#define MAX_FF_SPEED 0xff
 +
 +/*
 + * struct pmic8058_vib - structure to hold vibrator data
 + * vib_input_dev: input device supporting force feedback
 + * work: work structure to set the vibration parameters
 + * dev: device supporting force feedback
 + * pdata: platform data
 + * pm_chip: reference to pmic chip to carry out read/write operations
 + * speed: speed of vibration set from userland
 + * state: state of vibrator
 + * level: level of vibration to set in the chip
 + * reg_vib_drv: VIB_DRV register value

Hmm, this is kind of kerneldoc but not quite (kerneldoc's arguments
start with '@').

 + *
 + */
 +struct pmic8058_vib {
 + struct input_dev *vib_input_dev;
 + struct work_struct work;
 + struct device *dev;
 + const struct pmic8058_vibrator_pdata *pdata;
 + struct pm8058_chip  *pm_chip;
 + int speed;
 + int state;
 + int level;
 + u8  reg_vib_drv;
 +};
 +
 +/*
 + * pmic8058_vib_read_u8 - helper to read a byte from pmic chip
 + * vib: pointer to vibrator structure
 + * data: placeholder for data to be read
 + * reg: register address
 + *
 + */
 +static int pmic8058_vib_read_u8(struct pmic8058_vib *vib,
 +  u8 *data, u16 reg)
 +{
 + int rc;
 +
 + rc = pm8058_read(vib-pm_chip, reg, data, 1);
 + if (rc  0)
 + dev_warn(vib-dev, Error reading pmic8058 reg 0x%x(0x%x)\n,
 + reg, rc);
 + return rc;
 +}
 +
 +/*
 + * pmic8058_vib_write_u8 - helper to write a byte to pmic chip
 + * vib: pointer to vibrator structure
 + * data: data to write
 + * reg: register address
 + *
 + */
 +static int pmic8058_vib_write_u8(struct pmic8058_vib *vib,
 +  u8 data, u16 reg)
 +{
 + int rc;
 +
 + rc = pm8058_write(vib-pm_chip, reg, data, 1);
 + if (rc  0)
 + dev_warn(vib-dev, Error writing pmic8058 reg 0x%x(0x%x)\n,
 + reg, rc);
 + return rc;
 +}
 +
 +/*
 + * pmic8058_vib_set - handler to start/stop vibration
 + * vib: pointer to vibrator structure
 + * on: state to set
 + *
 + */
 +static int pmic8058_vib_set(struct pmic8058_vib *vib, int on)
 +{
 + int rc;
 + u8 val;
 +
 + val = vib-reg_vib_drv;
 +
 + if (on)
 + val |= ((vib-level  VIB_DRV_SEL_SHIFT)  VIB_DRV_SEL_MASK);
 + else
 + val = ~VIB_DRV_SEL_MASK;
 +
 + rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
 + if (rc  0)
 + return rc;
 +
 + vib-reg_vib_drv = val;
 + return rc;
 +}
 +
 +/*
 + * pmic8058_work_handler - worker to set vibration level
 + * work: pointer to work_struct
 + *
 + */
 +static void pmic8058_work_handler(struct work_struct *work)
 +{
 + struct pmic8058_vib *vib;
 + int rc;
 + u8 val;
 +
 + vib  = container_of(work, struct pmic8058_vib, work);
 +
 + rc = pmic8058_vib_read_u8(vib, val, VIB_DRV);
 + if (rc  0)
 + return;
 +
 + /*
 +  * pmic vibrator supports voltage ranges from 1.2 to 3.1V, so
 +  * scale the level to fit into these ranges.
 +  */
 + if (vib-speed) {
 + vib-state = 1;
 + vib-level = ((VIB_MAX_LEVELS * vib-speed) / MAX_FF_SPEED) +
 + VIB_MIN_LEVEL_mV;
 + vib-level /= 100;
 + } else {
 + vib-state = 0;
 + vib-level = VIB_MIN_LEVEL_mV / 100;
 + }
 + pmic8058_vib_set(vib, vib-state);
 +}
 +
 +/*
 + * pmic8058_vib_play_effect - function to handle vib effects.
 + * dev: input device pointer
 + * data: data of effect
 + * effect: effect to play
 + *
 + * Currently this driver supports only rumble effects.
 + *
 + */
 +static int pmic8058_vib_play_effect(struct input_dev *dev, void *data,
 +   struct ff_effect *effect)
 +{
 + struct pmic8058_vib *vib = input_get_drvdata(dev);
 +
 + vib-speed = effect-u.rumble.strong_magnitude  8;
 + if (!vib-speed)
 + vib-speed = effect-u.rumble.weak_magnitude  9;
 + schedule_work(vib-work);
 + return 0;
 +}
 +
 +static int __devinit pmic8058_vib_probe(struct platform_device *pdev)
 +
 +{
 + struct pm8058_chip *pm_chip;
 + struct pmic8058_vib *vib;
 + const struct pmic8058_vibrator_pdata *pdata = pdev-dev.platform_data;
 + int rc;
 + u8 val;
 +
 + pm_chip = platform_get_drvdata(pdev);

The parent should not abuse platform data of _this_ device, it 

Re: [RFC v2 PATCH 4/7] input: pmic8058_pwrkey: Add support for power key

2011-02-01 Thread Dmitry Torokhov
On Tue, Feb 01, 2011 at 07:17:40PM +0530, Anirudh Ghayal wrote:
 From: Trilok Soni ts...@codeaurora.org
 
 Add support for PMIC8058 power key driven over dedicated
 KYPD_PWR_N pin. It allows the user to specify the amount
 of time by which the power key reporting can be delayed.
 
 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Signed-off-by: Trilok Soni ts...@codeaurora.org
 ---
 Changes from v1:
 Addressed review comments from Dmitry.
 Added KEY_SCREENLOCK instead of KEY_END.

...
 + input_report_key(pwrkey-pwr, KEY_SCROLLLOCK, 1);
...
 + input_report_key(pwrkey-pwr, KEY_SCREENLOCK, 0);
...
 + input_set_capability(pwr, EV_KEY, KEY_SCROLLLOCK);


You are confused about the event you are sending.

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


Re: [RFC v1 PATCH 2/6] input: pm8058_keypad: Qualcomm PMIC8058 keypad controller driver

2010-12-07 Thread Dmitry Torokhov
On Tue, Dec 07, 2010 at 02:52:11PM +0530, Trilok Soni wrote:
 Hi Dmitry
 
 On 12/6/2010 11:44 PM, Dmitry Torokhov wrote:
  Hi Trilok,
  
  On Wed, Nov 10, 2010 at 06:17:57PM +0530, Trilok Soni wrote:
  Add Qualcomm PMIC8058 based keypad controller driver
  supporting upto 18x8 matrix configuration.
 
  
  Looks very good, just a couple of small things:
 
 Thanks for reviewing same revision of the patch again :)
 

Oops ;) Did I need to review something else from you then? I have a
nagging feeling that I have a patch outstanding...

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


Re: [RFC v1 PATCH 5/6] input: pmic8058-othc: Add support for PM8058 based OTHC

2010-12-07 Thread Dmitry Torokhov
Hi Trilok,

On Wed, Nov 10, 2010 at 06:18:00PM +0530, Trilok Soni wrote:
 From: Anirudh Ghayal agha...@codeaurora.org
 
 One-touch headset controller is a hardware module in Qualcomm's PMIC8058.
 It supports headset insert/remove and switch press/release detection events
 over 3 MIC BIAS lines. The MIC BIAS lines can be configured to support
 headset detection or act as regular BIAS lines.
 
 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Signed-off-by: Anirudh Ghayal agha...@codeaurora.org
 ---
  drivers/input/misc/Kconfig  |   10 +
  drivers/input/misc/Makefile |1 +
  drivers/input/misc/pmic8058-othc.c  |  544 
 +++
  include/linux/input/pmic8058-othc.h |  117 
  4 files changed, 672 insertions(+), 0 deletions(-)
  create mode 100644 drivers/input/misc/pmic8058-othc.c
  create mode 100644 include/linux/input/pmic8058-othc.h
 
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index aeb9165..df6097c 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -359,6 +359,16 @@ config INPUT_PMIC8058_PWRKEY
 To compile this driver as a module, choose M here: the
 module will be called pmic8058-pwrkey.
  
 +config INPUT_PMIC8058_OTHC
 + tristate Qualcomm PMIC8058 OTHC support
 + depends on PMIC8058
 + help
 +   Say Y here if you want support PMIC8058 One-touch Headset Controller
 +   (OTHC)
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called pmic8058-othc.
 +
  config INPUT_GPIO_ROTARY_ENCODER
   tristate Rotary encoders connected to GPIO pins
   depends on GPIOLIB  GENERIC_GPIO
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
 index c4357a0..a713370 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
 @@ -29,6 +29,7 @@ obj-$(CONFIG_INPUT_PCAP)+= pcap_keys.o
  obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
  obj-$(CONFIG_INPUT_PCF8574)  += pcf8574_keypad.o
  obj-$(CONFIG_INPUT_PCSPKR)   += pcspkr.o
 +obj-$(CONFIG_INPUT_PMIC8058_OTHC)+= pmic8058-othc.o
  obj-$(CONFIG_INPUT_POWERMATE)+= powermate.o
  obj-$(CONFIG_INPUT_PWM_BEEPER)   += pwm-beeper.o
  obj-$(CONFIG_INPUT_PMIC8058_PWRKEY)  += pmic8058-pwrkey.o
 diff --git a/drivers/input/misc/pmic8058-othc.c 
 b/drivers/input/misc/pmic8058-othc.c
 new file mode 100644
 index 000..78f157a
 --- /dev/null
 +++ b/drivers/input/misc/pmic8058-othc.c
 @@ -0,0 +1,544 @@
 +/* Copyright (c) 2010, Code Aurora Forum. 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.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 + * 02110-1301, USA.
 + */
 +
 +#define pr_fmt(fmt) %s: fmt, __func__
 +
 +#include linux/module.h
 +#include linux/init.h
 +#include linux/kernel.h
 +#include linux/slab.h
 +#include linux/interrupt.h
 +#include linux/input.h
 +#include linux/platform_device.h
 +#include linux/pm.h
 +
 +#include linux/mfd/pmic8058.h
 +#include linux/input/pmic8058-othc.h
 +
 +#define PM8058_OTHC_LOW_CURR_MASK0xF0
 +#define PM8058_OTHC_HIGH_CURR_MASK   0x0F
 +#define PM8058_OTHC_EN_SIG_MASK  0x3F
 +#define PM8058_OTHC_HYST_PREDIV_MASK 0xC7
 +#define PM8058_OTHC_CLK_PREDIV_MASK  0xF8
 +#define PM8058_OTHC_HYST_CLK_MASK0x0F
 +#define PM8058_OTHC_PERIOD_CLK_MASK  0xF0
 +
 +#define PM8058_OTHC_LOW_CURR_SHIFT   0x4
 +#define PM8058_OTHC_EN_SIG_SHIFT 0x6
 +#define PM8058_OTHC_HYST_PREDIV_SHIFT0x3
 +#define PM8058_OTHC_HYST_CLK_SHIFT   0x4
 +
 +#define PM8058_OTHC_LOW_CURR_MIRROR  10
 +#define PM8058_OTHC_HIGH_CURR_MIRROR 100
 +#define PM8058_OTHC_CLK_SRC_SHIFT10
 +
 +/**
 + * struct pm8058_othc - othc driver data structure
 + * @othc_ipd: input device for othc
 + * @othc_pdata:  a pointer to the platform data
 + * @othc_base: base address of the OTHC controller
 + * @othc_irq_sw: switch detect irq number
 + * @othc_irq_ir: headset jack detect irq number
 + * @othc_sw_state: current state of the switch
 + * @othc_ir_state: current state of the headset
 + * @switch_reject: indicates if valid switch press
 + * @switch_debounce_ms: the debounce time for the switch
 + * @lock: spin lock variable
 + * @timer: timer for switch debounce time
 + * @pm_chip: pointer to the pm8058 parent chip
 + */
 +struct pm8058_othc {
 + struct input_dev *othc_ipd

Re: [RFC v1 PATCH 2/6] input: pm8058_keypad: Qualcomm PMIC8058 keypad controller driver

2010-12-06 Thread Dmitry Torokhov
Hi Trilok,

On Wed, Nov 10, 2010 at 06:17:57PM +0530, Trilok Soni wrote:
 Add Qualcomm PMIC8058 based keypad controller driver
 supporting upto 18x8 matrix configuration.
 

Looks very good, just a couple of small things:

 +
 +#include linux/input/pmic8058-keypad.h

Move to MFD directory with the rest of pmic8058 definitions?

 + */
 +struct pmic8058_kp {
 + const struct pmic8058_keypad_data *pdata;
 + struct input_dev *input;
 + int key_sense_irq;
 + int key_stuck_irq;
 +
 + unsigned short *keycodes;

I'd pull the keycodes into this structure (at the end) so it can be
allocated in one shot. Hmm it even appears to be constant-sized. So just
declare it right here and be done with it.

 +
 +static int pmic8058_detect_ghost_keys(struct pmic8058_kp *kp, u16 *new_state)

bool

 +{
 + int row, found_first = -1;
 + u16 check, row_state;
 +
 + check = 0;
 + for (row = 0; row  kp-pdata-num_rows; row++) {
 + row_state = (~new_state[row]) 
 +  ((1  kp-pdata-num_cols) - 1);
 +
 + if (hweight16(row_state)  1) {
 + if (found_first == -1)
 + found_first = row;
 + if (check  row_state) {
 + dev_dbg(kp-dev, detected ghost key on row[%d]
 +   and row[%d]\n, found_first, row);
 + return 1;

true

 + }
 + }
 + check |= row_state;
 + }
 + return 0;

false

 +
 +static int pmic8058_kpd_init(struct pmic8058_kp *kp)
 +{
 + int bits, rc, cycles;
 + u8 scan_val = 0, ctrl_val = 0;
 + static u8 row_bits[] = {

const?

 + 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7,
 + };
 +
 +}
 +
 +static int pmic8058_kp_enable(struct pmic8058_kp *kp)
 +{
 + int rc;
 +
 + kp-ctrl_reg |= KEYP_CTRL_KEYP_EN;
 +
 + rc = pmic8058_kp_write_u8(kp, kp-ctrl_reg, KEYP_CTRL);
 + if (rc  0)
 + return rc;
 +
 + enable_irq(kp-key_sense_irq);
 + enable_irq(kp-key_stuck_irq);
 +
 + return rc;
 +}
 +
 +static int pmic8058_kp_disable(struct pmic8058_kp *kp)
 +{
 + int rc;
 +
 + kp-ctrl_reg = ~KEYP_CTRL_KEYP_EN;
 +
 + rc = pmic8058_kp_write_u8(kp, kp-ctrl_reg, KEYP_CTRL);
 + if (rc  0)
 + return rc;
 +
 + disable_irq(kp-key_sense_irq);
 + disable_irq(kp-key_stuck_irq);
 +
 + return rc;
 +}
 +
 +static int pmic8058_kp_open(struct input_dev *dev)
 +{
 + struct pmic8058_kp *kp = input_get_drvdata(dev);
 +
 + return pmic8058_kp_enable(kp);
 +}
 +
 +static void pmic8058_kp_close(struct input_dev *dev)
 +{
 + struct pmic8058_kp *kp = input_get_drvdata(dev);
 +
 + pmic8058_kp_disable(kp);
 +}
 +

You need to protect suspend/resume from racing with open_close. Take
dev-mutex and act depending on whether there are users of the device.

 + if (pdata-rows_gpio_start  0 || pdata-cols_gpio_start  0) {
 + dev_err(pdev-dev, invalid gpio_start platform data\n);
 + return -EINVAL;

These are declared as unsigned. Hmm, doesn't sparse catch it?

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


Re: [RFC v1 PATCH 4/6] input: pmic8058_pwrkey: Add support for power key

2010-11-12 Thread Dmitry Torokhov
On Fri, Nov 12, 2010 at 02:26:28PM +0530, Trilok Soni wrote:
 Hi Dmitry,
 
 On 11/12/2010 6:27 AM, Dmitry Torokhov wrote:
  On Thu, Nov 11, 2010 at 05:30:21PM +0530, Trilok Soni wrote:
  Hi Dmitry,
 
  On 11/11/2010 12:51 PM, Dmitry Torokhov wrote:
  Hi Trilkok,
 
  On Wed, Nov 10, 2010 at 06:17:59PM +0530, Trilok Soni wrote:
  Add support for PMIC8058 power key driven over dedicated KYPD_PWR_N
  pin. It allows the user to specify the amount of time by which the
  power key reporting can be delayed.
 
 
  Why do we need to delay KEY_POWER reporting? Do we need to use high
  resolution timers or regular timers would do as well? KEY_END
  appears to be abused (you don't want to move your cursor to the end
  of line, do you?). Also I wonder if header file should reside in
  linux/mfd with the rest of pmic8058 components.
 
  Most of the time Mobile devices come with single physical key for
  POWER, which if pressed for less than 500ms (configurable) then it
  will only report KEY_END (which say locks the screen on mobile) and if
  it pressed more than 500ms then it will also report KEY_POWER event
  too, which will say display menu on your mobile for asking you to
  suspend/switch off/etc, operations.
 
  
  I see,. If you would have used KEY_SCREENLOCK iinstead of KEY_END I
  would likely not ask this question ;)
  
 
 KEY_SCRENNLOCK looks good, let me analyze the impact on userspace framework
 which I have. I will come back on this in a day.
 
  For the timers I can move from hrtimers to regular timers.
 
  For the header file, I can move them to include/linux/mfd too. No
  problem on that.
 
  
  I am not even sure we need to keep them in separate header files, but it
  is up to you.
 
 Do you suggest that all the MFD sub-devices's platform data structures should 
 come from single
 header file?
 

It is an option, depends on how many external headers are needed, etc.

When I looked at this particular file I got the feeling that it could be
folded together with the rest. I expect that the board code that will
specify platform resources will include every one of this sub-files
anyway. But maybe if I was presented with the combined header I'd say
wow, thats too big...

Like I said, it is up to you.

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


Re: [RFC v1 PATCH 4/6] input: pmic8058_pwrkey: Add support for power key

2010-11-11 Thread Dmitry Torokhov
On Thu, Nov 11, 2010 at 05:30:21PM +0530, Trilok Soni wrote:
 Hi Dmitry,
 
 On 11/11/2010 12:51 PM, Dmitry Torokhov wrote:
  Hi Trilkok,
  
  On Wed, Nov 10, 2010 at 06:17:59PM +0530, Trilok Soni wrote:
  Add support for PMIC8058 power key driven over dedicated KYPD_PWR_N
  pin. It allows the user to specify the amount of time by which the
  power key reporting can be delayed.
 
  
  Why do we need to delay KEY_POWER reporting? Do we need to use high
  resolution timers or regular timers would do as well? KEY_END
  appears to be abused (you don't want to move your cursor to the end
  of line, do you?). Also I wonder if header file should reside in
  linux/mfd with the rest of pmic8058 components.
 
 Most of the time Mobile devices come with single physical key for
 POWER, which if pressed for less than 500ms (configurable) then it
 will only report KEY_END (which say locks the screen on mobile) and if
 it pressed more than 500ms then it will also report KEY_POWER event
 too, which will say display menu on your mobile for asking you to
 suspend/switch off/etc, operations.
 

I see,. If you would have used KEY_SCREENLOCK iinstead of KEY_END I
would likely not ask this question ;)

 For the timers I can move from hrtimers to regular timers.
 
 For the header file, I can move them to include/linux/mfd too. No
 problem on that.
 

I am not even sure we need to keep them in separate header files, but it
is up to you.

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


Re: [RFC v1 PATCH 1/6] matrix_keypad: Increase the max limit of rows and columns

2010-11-10 Thread Dmitry Torokhov
On Thu, Nov 11, 2010 at 02:33:45AM +0800, Eric Miao wrote:
 On Wed, Nov 10, 2010 at 8:47 PM, Trilok Soni ts...@codeaurora.org wrote:
  Some keyboard controller have support for more than
  16 columns and rows.
 
  Cc: Dmitry Torokhov dmitry.torok...@gmail.com
  Cc: Eric Miao eric.y.m...@gmail.com
  Signed-off-by: Trilok Soni ts...@codeaurora.org
  ---
   include/linux/input/matrix_keypad.h |    8 
   1 files changed, 4 insertions(+), 4 deletions(-)
 
  diff --git a/include/linux/input/matrix_keypad.h 
  b/include/linux/input/matrix_keypad.h
  index 80352ad..d80845e 100644
  --- a/include/linux/input/matrix_keypad.h
  +++ b/include/linux/input/matrix_keypad.h
  @@ -4,11 +4,11 @@
   #include linux/types.h
   #include linux/input.h
 
  -#define MATRIX_MAX_ROWS                16
  -#define MATRIX_MAX_COLS                16
  +#define MATRIX_MAX_ROWS                18
  +#define MATRIX_MAX_COLS                18
 
  -#define KEY(row, col, val)     row)  (MATRIX_MAX_ROWS - 1))  24) |\
  -                                (((col)  (MATRIX_MAX_COLS - 1))  16) |\
  +#define KEY(row, col, val)     row) % (MATRIX_MAX_ROWS))  24) |\
  +                                (((col) % (MATRIX_MAX_COLS))  16) |\
                                  (val  0x))
 
 
 Or maybe we can solve this completely by introducing something like:
 
 struct matrix_keycode {
 int row;
 int col;
 int value;

Though that triples the space needed to store initial keymaps.

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


Re: [RFC v1 PATCH 4/6] input: pmic8058_pwrkey: Add support for power key

2010-11-10 Thread Dmitry Torokhov
Hi Trilkok,

On Wed, Nov 10, 2010 at 06:17:59PM +0530, Trilok Soni wrote:
 Add support for PMIC8058 power key driven over dedicated
 KYPD_PWR_N pin. It allows the user to specify the amount
 of time by which the power key reporting can be delayed.
 

Why do we need to delay KEY_POWER reporting? Do we need to use high
resolution timers or regular timers would do as well? KEY_END appears to
be abused (you don't want to move your cursor to the end of line, do
you?). Also I wonder if header file should reside in linux/mfd with the
rest of pmic8058 components.

Thanks. 

 Cc: Dmitry Torokhov dmitry.torok...@gmail.com
 Signed-off-by: Trilok Soni ts...@codeaurora.org
 ---
  drivers/input/misc/Kconfig|   11 +
  drivers/input/misc/Makefile   |1 +
  drivers/input/misc/pmic8058-pwrkey.c  |  322 
 +
  include/linux/input/pmic8058-pwrkey.h |   37 
  4 files changed, 371 insertions(+), 0 deletions(-)
  create mode 100644 drivers/input/misc/pmic8058-pwrkey.c
  create mode 100644 include/linux/input/pmic8058-pwrkey.h
 
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index b99b8cb..aeb9165 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -348,6 +348,17 @@ config INPUT_PWM_BEEPER
 To compile this driver as a module, choose M here: the module will be
 called pwm-beeper.
  
 +config INPUT_PMIC8058_PWRKEY
 + tristate PMIC8058 power key support
 + depends on PMIC8058
 + help
 +   Say Y here if you want support for the PMIC8058 power key.
 +
 +   If unsure, say N.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called pmic8058-pwrkey.
 +
  config INPUT_GPIO_ROTARY_ENCODER
   tristate Rotary encoders connected to GPIO pins
   depends on GPIOLIB  GENERIC_GPIO
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
 index 1fe1f6c..c4357a0 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
 @@ -31,6 +31,7 @@ obj-$(CONFIG_INPUT_PCF8574) += pcf8574_keypad.o
  obj-$(CONFIG_INPUT_PCSPKR)   += pcspkr.o
  obj-$(CONFIG_INPUT_POWERMATE)+= powermate.o
  obj-$(CONFIG_INPUT_PWM_BEEPER)   += pwm-beeper.o
 +obj-$(CONFIG_INPUT_PMIC8058_PWRKEY)  += pmic8058-pwrkey.o
  obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
  obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)  += rotary_encoder.o
  obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
 diff --git a/drivers/input/misc/pmic8058-pwrkey.c 
 b/drivers/input/misc/pmic8058-pwrkey.c
 new file mode 100644
 index 000..3714b24
 --- /dev/null
 +++ b/drivers/input/misc/pmic8058-pwrkey.c
 @@ -0,0 +1,322 @@
 +/* Copyright (c) 2010, Code Aurora Forum. 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.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 + * 02110-1301, USA.
 + */
 +
 +#include linux/module.h
 +#include linux/init.h
 +#include linux/kernel.h
 +#include linux/errno.h
 +#include linux/slab.h
 +#include linux/input.h
 +#include linux/interrupt.h
 +#include linux/platform_device.h
 +#include linux/mfd/pmic8058.h
 +#include linux/log2.h
 +#include linux/spinlock.h
 +#include linux/hrtimer.h
 +
 +#include linux/input/pmic8058-pwrkey.h
 +
 +#define PON_CNTL_1   0x1C
 +#define PON_CNTL_PULL_UP BIT(7)
 +#define PON_CNTL_TRIG_DELAY_MASK (0x7)
 +
 +/**
 + * struct pmic8058_pwrkey - pmic8058 pwrkey information
 + * @key_press_irq: key press irq number
 + * @pm_chip: pmic8058 parent
 + * @timer: timer for end key simulation
 + * @key_pressed: flag to keep track for power key reporting
 + * @pdata: platform data
 + * @lock:  protect key press update and end key simulation
 + */
 +struct pmic8058_pwrkey {
 + struct input_dev *pwr;
 + int key_press_irq;
 + struct pm8058_chip  *pm_chip;
 + struct hrtimer timer;
 + bool key_pressed;
 + struct pmic8058_pwrkey_pdata *pdata;
 + spinlock_t lock;
 +};
 +
 +static enum hrtimer_restart pmic8058_pwrkey_timer(struct hrtimer *timer)
 +{
 + unsigned long flags;
 + struct pmic8058_pwrkey *pwrkey = container_of(timer,
 + struct pmic8058_pwrkey, timer);
 +
 + spin_lock_irqsave(pwrkey-lock, flags);
 + pwrkey-key_pressed = true;
 +
 + input_report_key(pwrkey-pwr, KEY_POWER, 1);
 + input_sync(pwrkey-pwr

Re: [PATCH 0/1] input: keyboard: add qci keyboard driver

2010-09-01 Thread Dmitry Torokhov
On Tue, Aug 31, 2010 at 04:54:47PM -0400, Neil Leeder wrote:
 On 8/30/2010 5:55 PM, Dmitry Torokhov wrote:
 And still you are using only one GPIO in your driver? While WPCE775x
 does seem to have matrix keypad support I think that you are using one
 of the 3 PS/2 ports, like your touchpad does.
 
 Hi Dmitry,
 
 I can assure you that the keyboard is on the 8*18 GPIO matrix on the
 Nuvoton EC (only 8*16 being used in the current design). There
 certainly are 3 PS/2 ports on the EC, but in the board designs I
 have only one of those is used as a PS/2 port, and that is for the
 touchpad. The other two ports are muxed with GPIOs and the pins are
 being used as GPIOs for other functions, not PS/2 ports.
 
 The firmware on the EC converts keypresses on the GPIO matrix to
 scancodes and sends them over I2C. The single GPIO used by the
 keyboard driver is an interrupt.
 
 The device is initialized with 0xf4; the device is supposed to respond
 with 0xfa; I wonder what scancodes the device reports... It smells
 strongly of PS/2.
 
 Also, it is not controller that supports PS/2 commands but rather the
 device itself so I am still hopeful that we could make use of the
 standard drivers.
 
 We can speculate on the reasons that the firmware on the EC uses
 0xF4  0xFA for init and ack - my guess would be for a minimal
 amount of commonality with the PS/2 protocol - but it doesn't
 emulate the rest of the PS/2 protocol for the GPIO matrix device. I
 tried with atkbd. It issues reset, getid, setleds - all of which
 fail with no response from the EC. It only responds to F4.

OK, I give up on pursuit of serio solution. Again ;)

 
 The scancodes reported are whatever the firmware provides. A
 previous version of firmware had some non-standard values and the
 driver had to use a look-up table to convert them to something
 useful. With the change to the current keyboard layout Quanta
 changed the scancodes reported to match the KEY_* values in input.h,
 which is why there is no table in the current driver.

I believe we still should support changing keymap via EVIOCSKEYCODE so
we need to have the keymap even though the initial seed is 1:1 with
scancodes.

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


Re: [PATCH 0/1] input: keyboard: add qci keyboard driver

2010-08-30 Thread Dmitry Torokhov
On Mon, Aug 30, 2010 at 02:22:10PM -0400, Neil Leeder wrote:
 On 8/27/2010 6:33 PM, Dmitry Torokhov wrote:
 No, this is crazy... This is a twin-brother of the touchpad driver and
 I really do not understand why chip claiming to have PS/2 interface
 (3 ports if I were to believe the diagram) would not allow us talk to
 the devices...
 
 I didn't provide a key bit of information, sorry. The keyboard is
 not attached to the EC's PS/2 port. It is on a matrix of GPIOs.

And still you are using only one GPIO in your driver? While WPCE775x
does seem to have matrix keypad support I think that you are using one
of the 3 PS/2 ports, like your touchpad does.

 
 I was trying to explain that even though the firmware on the EC uses
 0xF4 written over i2c to initialize it, it doesn't appear to support
 other PS/2 commands directed to the keyboard on the GPIO matrix.
 

The device is initialized with 0xf4; the device is supposed to respond
with 0xfa; I wonder what scancodes the device reports... It smells
strongly of PS/2.

Also, it is not controller that supports PS/2 commands but rather the
device itself so I am still hopeful that we could make use of the
standard drivers.

Wan, you worked at Nuvoton, do you know if wpce775 fully supports PS/2
interface? 

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


Re: [PATCH v2] input: mouse: add qci touchpad driver

2010-08-19 Thread Dmitry Torokhov
On Wed, Aug 18, 2010 at 05:38:38PM -0400, Neil Leeder wrote:
 Hi Dmitry,
 
 On 8/17/2010 2:05 PM, Dmitry Torokhov wrote:
 That suggests that the device responds to at least basic PS/2 queries.
 
 I can see data being passed through the serio driver but the logitech
 driver can't process it.
 
 
 What about loading psmouse module with proto=bare?
 
 Could you also dump the data received from touchpad during probing?
 
 
 It appears the controller does somewhat respond as a PS/2 device.
 The first problem is it only responds to CMD_GETID correctly about
 50% of the time. Sometimes it responds well with a 0x00, other times
 with 0xfa, which causes psmouse_probe to not recognize it as a
 pointing device.
 
 [1.037223] wpce775x_send len=1 data=f2
 [1.054412] wpce775x_recv ... data_in=fa fa 64 0 0 0 0 0 fa 0 0 0
 0 0 0 0
 
 It also doesn't respond well to CMD_GETINFO, which is why it gets
 mis-detected as the wrong device type. As an aside, I'm not sure if
 combining separate commands into one i2c packet is correct, but
 separating them didn't seem to produce better results either.
 
 [1.723943] wpce775x_send len=3 data=e8 3 e6
 [1.735666] wpce775x_recv ... data_in=fa fa 64 0 0 0 0 0 fa 0 0 0
 0 0 0 0
 [1.735892] wpce775x_send len=3 data=e6 e6 e9
 [1.748281] wpce775x_recv ... data_in=fe fa 64 0 0 0 0 0 fa 0 0 0
 0 0 0 0
 [1.748500] wpce775x_send len=3 data=e8 0 e6
 [1.760233] wpce775x_recv ... data_in=fa fa 64 0 0 0 0 0 fa 0 0 0
 0 0 0 0
 [1.760457] wpce775x_send len=3 data=e6 e6 e9
 [1.772876] wpce775x_recv ... data_in=fe fa 64 0 0 0 0 0 fa 0 0 0
 0 0 0 0
 
 Using proto=bare gets around the GETINFO failure, but doesn't help
 with the more important GETID failure.

Does it help if you change write() to transmit (and read) 1 byte at a time?

 
 The other issue is that when the serio driver requests up to 16
 bytes over i2c, the controller responds with 16 bytes of data, which
 appear to be the 3 flags/X/Y regs plus 13 bytes of irrelevant data.
 This all gets passed to psmouse which interprets it 3 bytes at a
 time as movement data. Not only does the extra data get interpreted
 as movement info, but it causes subsequent real data to be
 mis-aligned and wrongly interpreted.
 
 [  115.915558] wpce775x_recv ... data_in=28 1 ff 0 0 0 0 0 9c 0 0 0 0 0 0 0
 [  115.915649] psmouse_process_byte data=28 01 ff rel_x=1 rel_y=1
 --- OK
 [  115.915688] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 [  115.915714] psmouse_process_byte data=00 00 9c rel_x=0 rel_y=-156
 --- bad
 [  115.915745] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 [  115.915771] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 [  115.928269] wpce775x_recv ... data_in=28 1 fe 0 0 0 0 0 9c 0 0 0 0 0 0 0
 [  115.928357] psmouse_process_byte data=00 28 01 rel_x=40 rel_y=-1
 --- wrong
 [  115.928396] psmouse_process_byte data=fe 00 00 rel_x=0 rel_y=0
 --- wrong
 [  115.928426] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 [  115.928457] psmouse_process_byte data=9c 00 00 rel_x=0 rel_y=0
 [  115.928484] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 [  115.939728] wpce775x_recv ... data_in=28 1 ff 0 0 0 0 0 9c 0 0 0 0 0 0 0
 [  115.939818] psmouse_process_byte data=00 00 28 rel_x=0 rel_y=-40
 --- wrong
 [  115.939857] psmouse_process_byte data=01 ff 00 rel_x=255 rel_y=0
 --- wrong
 [  115.939889] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 [  115.939916] psmouse_process_byte data=00 9c 00 rel_x=156 rel_y=0
 --- bad
 [  115.939947] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 [  115.939972] psmouse_process_byte data=00 00 00 rel_x=0 rel_y=0
 
 Is there a way to get the serio driver to only read 3 bytes of data
 per interrupt?
 

One way would be to look for PSMOUSE_CMD_ENABLE/PSMOUSE_CMD_DISABLE
(0xf4/0xf5) in -write() method to switch between 1 and 3-byte transfers.

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


Re: [PATCH v2] input: mouse: add qci touchpad driver

2010-08-17 Thread Dmitry Torokhov

Hi Neil,

On Aug 17, 2010, at 10:14 AM, Neil Leeder nlee...@codeaurora.org  
wrote:



On 8/13/2010 8:54 PM, Dmitry Torokhov wrote:
Also it is not a simple coincidence that to enable device you send  
0xf4
to it (which is PSMOUSE_CMD_ENABLE - standard PS/2 command). This  
tends

to suggest that interface is not actually hidden and that the device
(touchpad) could be replaced with other kinds of devices.

Anyway, please try the driver (you  may need to hardcode the IRQ  
trigger
type for now) and see if psmouse is able to talk to the touchpad.  
If it

is then serio is the proper solution.


Dmitri,
I fixed one line in the wpce775x_serio driver which looked like a  
typo - hope I got that right:


   for (i = 0; i  count; i++)
-serio_interrupt(ps2if-serio, ps2if-data_in[1], 0);
+serio_interrupt(ps2if-serio, ps2if-data_in[i], 0);
   }



Yep, that was a typo.

I tried running with psmouse but it didn't work. The touchpad was  
never detected as a synaptics touchpad. I looked at the dataflow  
from the device and it wasn't responding to the commands that  
synaptics_detect() was sending it. It eventually showed up as an  
unknown logitech mouse.



That suggests that the device responds to at least basic PS/2 queries.

I can see data being passed through the serio driver but the  
logitech driver can't process it.




What about loading psmouse module with proto=bare?

Could you also dump the data received from touchpad during probing?


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


Re: [PATCH 0/1] mouse: add qci touchpad driver

2010-08-06 Thread Dmitry Torokhov
On Friday, August 06, 2010 01:31:57 pm Neil Leeder wrote:
 This is an update of the driver that Quanta posted here a few days ago.
 Quanta wrote the original version of the driver and I am picking up
 maintenance for code aurora forum.
 
 I've addressed the review comments. The only one that's outstanding is
 the use of the sensitivity value. I don't see an easy way that userspace
 would be able to apply the sensitivity scaling between the driver and
 say xorg, so for now I've left it in the driver, but I'd welcome any
 suggestions for improvement.
 

Doesn't xset mouse do what you want?

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