Qualcomm PMIC8058 sub-device drivers
Subsystems (5)
v2 cover Qualcomm PMIC8058 sub-device drivers
This patch series contains the V2 RFC version of sub-device drivers for Qualcomm PMIC8058. It is submitted here as RFC, due the dependent drivers like PMIC8058 core driver and SSBI bus driver are not yet merged into the mainline. We are sending these patches early to get the feedback from the community.
In this V2 version we have added one new driver- PM8058 based vibrator.
If you want to refer the PMIC8058 core and SSBI driver they are available here:
PMIC8058 core driver:
https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm.git;a=blob;f=drivers/mfd/pmic8058.c;h=dc561988c474721d76178ab1a2f82a3a4d1b03a1;hb=refs/heads/msm-2.6.35
Amy Maloche (1):
input: misc: Add support for PM8058 based vibrator driver
Anirudh Ghayal (2):
input: pmic8058-othc: Add support for PM8058 based OTHC
drivers: rtc: Add support for Qualcomm PMIC8058 RTC
Trilok Soni (4):
matrix_keypad: Increase the max limit of rows and columns
input: pm8058_keypad: Qualcomm PMIC8058 keypad controller driver
led: pmic8058: Add PMIC8058 leds driver
input: pmic8058_pwrkey: Add support for power key
drivers/input/keyboard/Kconfig | 11 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/pmic8058-keypad.c | 754 ++++++++++++++++++++++++++++++ drivers/input/misc/Kconfig | 32 ++ drivers/input/misc/Makefile | 3 + drivers/input/misc/pmic8058-othc.c | 535 +++++++++++++++++++++ drivers/input/misc/pmic8058-pwrkey.c | 318 +++++++++++++ drivers/input/misc/pmic8058-vibrator.c | 306 ++++++++++++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-pmic8058.c | 360 ++++++++++++++ drivers/rtc/Kconfig | 9 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-pm8058.c | 488 +++++++++++++++++++ include/linux/input/matrix_keypad.h | 4 +- include/linux/input/pmic8058-keypad.h | 53 +++ include/linux/input/pmic8058-othc.h | 117 +++++ include/linux/input/pmic8058-pwrkey.h | 37 ++ include/linux/leds-pmic8058.h | 61 +++ include/linux/rtc/rtc-pm8058.h | 29 ++ 20 files changed, 3129 insertions(+), 2 deletions(-) create mode 100644 drivers/input/keyboard/pmic8058-keypad.c create mode 100644 drivers/input/misc/pmic8058-othc.c create mode 100644 drivers/input/misc/pmic8058-pwrkey.c create mode 100644 drivers/input/misc/pmic8058-vibrator.c create mode 100644 drivers/leds/leds-pmic8058.c create mode 100644 drivers/rtc/rtc-pm8058.c create mode 100644 include/linux/input/pmic8058-keypad.h create mode 100644 include/linux/input/pmic8058-othc.h create mode 100644 include/linux/input/pmic8058-pwrkey.h create mode 100644 include/linux/leds-pmic8058.h create mode 100644 include/linux/rtc/rtc-pm8058.h
Signature · 1 line
1.7.3.5
RFC PATCH v2 1/7 matrix_keypad: Increase the max limit of rows and columns
From: Trilok Soni <[email protected]>
Some keyboard controller have support for more than 16 columns and rows. Moving this value to 32.
---
Changes from v1:
Moved the max columns and rows to 32
include/linux/input/matrix_keypad.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/input/matrix_keypad.h +2 -2
@@ -4,8 +4,8 @@#include <linux/types.h> #include <linux/input.h> -#define MATRIX_MAX_ROWS 16 -#define MATRIX_MAX_COLS 16 +#define MATRIX_MAX_ROWS 32 +#define MATRIX_MAX_COLS 32#define KEY (row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\ (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
Signature · 1 line
1.7.3.5
Re: [RFC v2 PATCH 1/7] matrix_keypad: Increase the max limit of rows and columns
Quoted 8 lines · Anirudh Ghayal
From: Trilok Soni <[email protected]>
Some keyboard controller have support for more than 16 columns and rows. Moving this value to 32.
Cc Eric Miao <[email protected]>Cc Dmitry Torokhov <[email protected]>Signed-off-by Trilok Soni <[email protected]>
This looks good to me, as long as the bits don't exceed 256, which is used in the #KEY() macro. So far, 32 looks to be a sane number to me, unless we have further requirement to get this larger.
Quoted 23 lines
---
Changes from v1:
Moved the max columns and rows to 32include/linux/input/matrix_keypad.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)include/linux/input/matrix_keypad.h +2
-3@@ -4,8 +4,8 @@ #include <linux/types.h> #include <linux/input.h> -#define MATRIX_MAX_ROWS 16 -#define MATRIX_MAX_COLS 16 +#define MATRIX_MAX_ROWS 32 +#define MATRIX_MAX_COLS 32 #define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\ (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\ --
Quoted 3 lines
1.7.3.5
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC v2 PATCH 1/7] matrix_keypad: Increase the max limit of rows and columns
Hi Dmitry,
Quoted 10 lines · Eric Miao
Quoted 8 lines · Anirudh Ghayal
From: Trilok Soni <[email protected]>
Some keyboard controller have support for more than 16 columns and rows. Moving this value to 32.
Cc Eric Miao <[email protected]>Cc Dmitry Torokhov <[email protected]>Signed-off-by Trilok Soni <[email protected]>
Quoted 6 lines
This looks good to me, as long as the bits don't exceed 256, which is used in the #KEY() macro. So far, 32 looks to be a sane number to me, unless we have further requirement to get this larger.
Acked-by Eric Miao <[email protected]>
Are you going to pick up this patch only from the series you want us to get it submitted it separately?
---Trilok Soni
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [RFC v2 PATCH 1/7] matrix_keypad: Increase the max limit of rows and columns
Quoted 17 lines · Trilok Soni
Hi Dmitry,
Quoted 14 lines · Eric Miao
Quoted 8 lines · Anirudh Ghayal
From: Trilok Soni <[email protected]>
Some keyboard controller have support for more than 16 columns and rows. Moving this value to 32.
Cc Eric Miao <[email protected]>Cc Dmitry Torokhov <[email protected]>Signed-off-by Trilok Soni <[email protected]>This looks good to me, as long as the bits don't exceed 256, which is used in the #KEY() macro. So far, 32 looks to be a sane number to me, unless we have further requirement to get this larger.
Quoted 5 lines
Quoted 2 lines
Acked-by Eric Miao <[email protected]>Are you going to pick up this patch only from the series you want us to get it submitted it separately?
I believe Dmitry will pick this series once all the patches are reviewed?
RFC PATCH v2 2/7 input: pm8058_keypad: Qualcomm PMIC8058 keypad controller driver
In reply to Anirudh GhayalFrom: Trilok Soni <[email protected]>
Add Qualcomm PMIC8058 based keypad controller driver supporting upto 18x8 matrix configuration.
---
Changes from v1:
Addressed review comments from Dmitry.
Race condition handling in suspend/resume
Statically allocate keycode array.
drivers/input/keyboard/Kconfig | 11 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/pmic8058-keypad.c | 754 ++++++++++++++++++++++++++++++ include/linux/input/pmic8058-keypad.h | 53 +++ 4 files changed, 819 insertions(+), 0 deletions(-) create mode 100644 drivers/input/keyboard/pmic8058-keypad.c create mode 100644 include/linux/input/pmic8058-keypad.h
drivers/input/keyboard/Kconfig +11 -0
@@ -370,6 +370,17 @@ config KEYBOARD_PXA930_ROTARY To compile this driver as a module, choose M here: the module will be called pxa930_rotary. +config KEYBOARD_PMIC8058 + tristate "Qualcomm PMIC8058 keypad support" + depends on PMIC8058 + help + Say Y here if you want to enable the driver for the PMIC8058 + 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 pmic8058-keypad. + config KEYBOARD_SAMSUNG tristate "Samsung keypad support" depends on SAMSUNG_DEV_KEYPAD
drivers/input/keyboard/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_KEYBOARD_OMAP4) += omap4-keypad.o obj-$(CONFIG_KEYBOARD_OPENCORES) += opencores-kbd.o obj-$(CONFIG_KEYBOARD_PXA27x) += pxa27x_keypad.o obj-$(CONFIG_KEYBOARD_PXA930_ROTARY) += pxa930_rotary.o +obj-$(CONFIG_KEYBOARD_PMIC8058) += pmic8058-keypad.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o
drivers/input/keyboard/pmic8058-keypad.c new file +754 -0
754 lines not on this page · raw message
include/linux/input/pmic8058-keypad.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
1.7.3.5
RFC PATCH v2 3/7 led: pmic8058: Add PMIC8058 leds driver
In reply to Anirudh GhayalFrom: Trilok Soni <[email protected]>
Add support for Qualcomm PMIC8058 keyboard
backlight, flash and low current leds.
---
Changes from v1:
Addressed review comments from Peter and Dmitry.
drivers/leds/Kconfig | 11 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-pmic8058.c | 360 +++++++++++++++++++++++++++++++++++++++++ include/linux/leds-pmic8058.h | 61 +++++++ 4 files changed, 433 insertions(+), 0 deletions(-) create mode 100644 drivers/leds/leds-pmic8058.c create mode 100644 include/linux/leds-pmic8058.h
drivers/leds/Kconfig +11 -0
@@ -250,6 +250,17 @@ config LEDS_PCA955X LED driver chips accessed via the I2C bus. Supported devices include PCA9550, PCA9551, PCA9552, and PCA9553. +config LEDS_PMIC8058 + tristate "LED Support for Qualcomm PMIC8058" + depends on PMIC8058 + help + This option enables support for LEDs connected over PMIC8058 + (Power Management IC) chip on Qualcomm reference boards, + for example SURF and FFAs. + + To compile this driver as a module, choose M here: the module will + be called leds-pmic8058. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_PMIC8058) += leds-pmic8058.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o
drivers/leds/leds-pmic8058.c new file +360 -0
360 lines not on this page · raw message
include/linux/leds-pmic8058.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
1.7.3.5
Re: [RFC v2 PATCH 3/7] led: pmic8058: Add PMIC8058 leds driver
Quoted 127 lines · Anirudh Ghayal
From: Trilok Soni <[email protected]>
Add support for Qualcomm PMIC8058 keyboard
backlight, flash and low current leds.Cc Dmitry Torokhov <[email protected]>Cc Lars-Peter Clausen <[email protected]>Signed-off-by Trilok Soni <[email protected]>---
Changes from v1:
Addressed review comments from Peter and Dmitry.drivers/leds/Kconfig | 11 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-pmic8058.c | 360 +++++++++++++++++++++++++++++++++++++++++ include/linux/leds-pmic8058.h | 61 +++++++ 4 files changed, 433 insertions(+), 0 deletions(-) create mode 100644 drivers/leds/leds-pmic8058.c create mode 100644 include/linux/leds-pmic8058.hdrivers/leds/Kconfig +11
-0@@ -250,6 +250,17 @@ config LEDS_PCA955X LED driver chips accessed via the I2C bus. Supported devices include PCA9550, PCA9551, PCA9552, and PCA9553. +config LEDS_PMIC8058 + tristate "LED Support for Qualcomm PMIC8058" + depends on PMIC8058 + help + This option enables support for LEDs connected over PMIC8058 + (Power Management IC) chip on Qualcomm reference boards, + for example SURF and FFAs. + + To compile this driver as a module, choose M here: the module will + be called leds-pmic8058. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASSdrivers/leds/Makefile +1
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_PMIC8058) += leds-pmic8058.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.odrivers/leds/leds-pmic8058.c new file +67
-0@@ -0,0 +1,360 @@ +/* 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. +* +* 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/kernel.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/platform_device.h> +#include <linux/leds.h> +#include <linux/workqueue.h> +#include <linux/spinlock.h> +#include <linux/mfd/pmic8058.h> +#include <linux/leds-pmic8058.h> + +#define SSBI_REG_ADDR_DRV_KEYPAD 0x48 +#define PM8058_DRV_KEYPAD_BL_MASK 0xf0 +#define PM8058_DRV_KEYPAD_BL_SHIFT 0x04 + +#define SSBI_REG_ADDR_FLASH_DRV0 0x49 +#define PM8058_DRV_FLASH_MASK 0xf0 +#define PM8058_DRV_FLASH_SHIFT 0x04 + +#define SSBI_REG_ADDR_FLASH_DRV1 0xFB + +#define SSBI_REG_ADDR_LED_CTRL_BASE 0x131 +#define SSBI_REG_ADDR_LED_CTRL (n) (SSBI_REG_ADDR_LED_CTRL_BASE + (n)) +#define PM8058_DRV_LED_CTRL_MASK 0xf8 +#define PM8058_DRV_LED_CTRL_SHIFT 0x03 + +#define MAX_FLASH_LED_CURRENT 300 +#define MAX_LC_LED_CURRENT 40 +#define MAX_KP_BL_LED_CURRENT 300 + +#define MAX_KEYPAD_BL_LEVEL (1 << 4) +#define MAX_LED_DRV_LEVEL 20/* 2 * 20 mA */ + +#define PMIC8058_LED_OFFSET (id) ((id) - PMIC8058_ID_LED_0) + +#define MAX_KB_LED_BRIGHTNESS 15 +#define MAX_LC_LED_BRIGHTNESS 20 +#define MAX_FLASH_LED_BRIGHTNESS 15 + +#define PMIC8058_MAX_LEDS 7 + +/** +* struct pmic8058_led_data - internal led data structure +* @led_classdev - led class device +* @id - led index +* @led_brightness - led brightness levels +* @pm_chip - parent MFD core device +* @work - workqueue for led +* @lock - to protect the transactions +* @reg - cached value of led register +*/ +struct pmic8058_led_data {
drivers/leds/leds-pmic8058.c line 77
Quoted 10 lines
drivers/leds/leds-pmic8058.c new file +10
-0+struct led_classdev cdev; +int id; +u8 reg; +enum led_brightness brightness; +struct pm8058_chip *pm_chip; +struct work_struct work; +struct mutex lock; +}; + +#define PM8058_MAX_LEDS 7
This is unused
Quoted 86 lines
drivers/leds/leds-pmic8058.c new file +86
-0+ +static void led_kp_set (struct pmic8058_led_data *led,enum led_brightness value) +{ +int rc; +u8 level; + + level = (value <<PM8058_DRV_KEYPAD_BL_SHIFT ) & +PM8058_DRV_KEYPAD_BL_MASK ; + + led->reg &= ~PM8058_DRV_KEYPAD_BL_MASK ; + led->reg |= level; + + rc =pm8058_write (led->pm_chip,SSBI_REG_ADDR_DRV_KEYPAD , + &led->reg,1 ); +if (rc <0 ) +dev_err (led->cdev.dev,"can't set keypad backlight level\n" ); +} + +static void led_lc_set (struct pmic8058_led_data *led,enum led_brightness value) +{ +int rc, offset; +u8 level; + + level = (value <<PM8058_DRV_LED_CTRL_SHIFT ) & +PM8058_DRV_LED_CTRL_MASK ; + + offset =PMIC8058_LED_OFFSET (led->id); + + led->reg &= ~PM8058_DRV_LED_CTRL_MASK ; + led->reg |= level; + + rc =pm8058_write (led->pm_chip,SSBI_REG_ADDR_LED_CTRL (offset), + &led->reg,1 ); +if (rc) +dev_err (led->cdev.dev,"can't set (%d) led value\n" , + led->id); +} + +static void +led_flash_set (struct pmic8058_led_data *led,enum led_brightness value) +{ +int rc; +u8 level; +u16 reg_addr; + + level = (value <<PM8058_DRV_FLASH_SHIFT ) & +PM8058_DRV_FLASH_MASK ; + + led->reg &= ~PM8058_DRV_FLASH_MASK ; + led->reg |= level; + +if (led->id ==PMIC8058_ID_FLASH_LED_0 ) + reg_addr =SSBI_REG_ADDR_FLASH_DRV0 ; +else + reg_addr =SSBI_REG_ADDR_FLASH_DRV1 ; + + rc =pm8058_write (led->pm_chip, reg_addr, &led->reg,1 ); +if (rc <0 ) +dev_err (led->cdev.dev,"can't set flash led%d level\n" , + led->id); +} + +static void pmic8058_led_work (struct work_struct *work) +{ +struct pmic8058_led_data *led =container_of (work, + struct pmic8058_led_data, work); + +mutex_lock (&led->lock); + +switch (led->id) { +case PMIC8058_ID_LED_KB_LIGHT : +led_kp_set (led, led->brightness); +break ; +case PMIC8058_ID_LED_0 : +case PMIC8058_ID_LED_1 : +case PMIC8058_ID_LED_2 : +led_lc_set (led, led->brightness); +break ; +case PMIC8058_ID_FLASH_LED_0 : +case PMIC8058_ID_FLASH_LED_1 : +led_flash_set (led, led->brightness); +break ; + } + +mutex_unlock (&led->lock); +}
drivers/leds/leds-pmic8058.c line 173
Quoted 10 lines
drivers/leds/leds-pmic8058.c new file +10
-0+ +static void pmic8058_led_set (struct led_classdev *led_cdev, +enum led_brightness value) +{ +struct pmic8058_led_data *led; + + led = container_of(led_cdev, struct pmic8058_led_data, cdev); + + led->brightness = value; +schedule_work (&led->work);
As discussed last time it might be a good idea to schedule the work on the system_nrt_wq work queue and remove the mutex in the work function.
Quoted 142 lines
drivers/leds/leds-pmic8058.c new file +142
-0+} + +static enum led_brightness pmic8058_led_get (struct led_classdev *led_cdev) +{ +struct pmic8058_led_data *led; + + led = container_of(led_cdev, struct pmic8058_led_data, cdev); + +return led->brightness; +} + +static int get_max_brightness (enum pmic8058_leds id) +{ +switch (id) { +case PMIC8058_ID_LED_KB_LIGHT : +return MAX_KB_LED_BRIGHTNESS ; +case PMIC8058_ID_LED_0 : +case PMIC8058_ID_LED_1 : +case PMIC8058_ID_LED_2 : +return MAX_LC_LED_BRIGHTNESS ; +case PMIC8058_ID_FLASH_LED_0 : +case PMIC8058_ID_FLASH_LED_1 : +return MAX_FLASH_LED_CURRENT ; +default : +return 0 ; + } +} + +static int get_init_value (struct pmic8058_led_data *led,u8 *val) +{ +int rc, offset; +u16 addr; + +switch (led->id) { +case PMIC8058_ID_LED_KB_LIGHT : + addr =SSBI_REG_ADDR_DRV_KEYPAD ; +break ; +case PMIC8058_ID_LED_0 : +case PMIC8058_ID_LED_1 : +case PMIC8058_ID_LED_2 : + offset =PMIC8058_LED_OFFSET (led->id); + addr =SSBI_REG_ADDR_LED_CTRL (offset); +break ; +case PMIC8058_ID_FLASH_LED_0 : + addr =SSBI_REG_ADDR_FLASH_DRV0 ; +break ; +case PMIC8058_ID_FLASH_LED_1 : + addr =SSBI_REG_ADDR_FLASH_DRV1 ; +break ; + } + + rc =pm8058_read (led->pm_chip, addr, val,1 ); +if (rc) +dev_err (led->cdev.dev,"can't get led(%d) level\n" , led->id); + +return rc; +} + +static int __devinit pmic8058_led_probe (struct platform_device *pdev) +{ +const struct pmic8058_leds_platform_data *pdata = + pdev->dev.platform_data; +struct pmic8058_led_data *led_dat; +struct pmic8058_led *curr_led; +int rc, i; +struct pm8058_chip *pm_chip; +struct pmic8058_led_data *led; + + pm_chip =platform_get_drvdata (pdev); +if (pm_chip ==NULL ) { +dev_err (&pdev->dev,"no parent data passed in\n" ); +return -EINVAL ; + } + +if (pdata ==NULL ) { +dev_err (&pdev->dev,"platform data not supplied\n" ); +return -EINVAL ; + } + +if (pdata->num_leds >PMIC8058_MAX_LEDS ) { +dev_err (&pdev->dev,"can't handle more than %d LEDs\n" , +PMIC8058_MAX_LEDS ); +return -EFAULT ; + } + + led =kcalloc (pdata->num_leds,sizeof (*led),GFP_KERNEL ); +if (led ==NULL ) { +dev_err (&pdev->dev,"failed to alloc memory\n" ); +return -ENOMEM ; + } + +for (i =0 ; i < pdata->num_leds; i++) { + curr_led = &pdata->leds[i]; + led_dat = &led[curr_led->id]; + + led_dat->id = curr_led->id; + +if (!((led_dat->id >=PMIC8058_ID_LED_KB_LIGHT ) && + (led_dat->id <=PMIC8058_ID_FLASH_LED_1 ))) { +dev_err (&pdev->dev,"invalid LED ID (%d) specified\n" , + led_dat->id); + rc = -EINVAL ; + goto fail_id_check; + } + + led_dat->cdev.name = curr_led->name; + led_dat->cdev.default_trigger = curr_led->default_trigger; + led_dat->cdev.brightness_set = pmic8058_led_set; + led_dat->cdev.brightness_get = pmic8058_led_get; + led_dat->cdev.brightness =LED_OFF ; + led_dat->cdev.flags =LED_CORE_SUSPENDRESUME ; + + led_dat->cdev.max_brightness =get_max_brightness (led_dat->id); + led_dat->pm_chip = pm_chip; + + rc =get_init_value (led_dat, &led_dat->reg); +if (rc <0 ) + goto fail_id_check; + +mutex_init (&led_dat->lock); +INIT_WORK (&led_dat->work, pmic8058_led_work); + + rc =led_classdev_register (&pdev->dev, &led_dat->cdev); +if (rc) { +dev_err (&pdev->dev,"unable to register led %d\n" , + led_dat->id); + goto fail_id_check; + } + } + +platform_set_drvdata (pdev, led); + +return 0 ; + +fail_id_check: +if (i >0 ) { +for (i = i -1 ; i >=0 ; i--) +led_classdev_unregister (&led[i].cdev); + } +kfree (led); +return rc; +}
drivers/leds/leds-pmic8058.c line 325
Quoted 10 lines
drivers/leds/leds-pmic8058.c new file +10
-0+ +static int __devexit pmic8058_led_remove(struct platform_device *pdev) +{ +int i; +const struct pmic8058_leds_platform_data *pdata = + pdev->dev.platform_data; +struct pmic8058_led_data *led =platform_get_drvdata (pdev); + +for (i =0 ; i < pdata->num_leds; i++) { +mutex_destroy (&led[led->id].lock);
Since the mutex is used in the work function it should be destroyed after canceling the work.
drivers/leds/leds-pmic8058.c line 327
Quoted 2 lines
drivers/leds/leds-pmic8058.c new file +2
-0+led_classdev_unregister (&led[led->id].cdev); +cancel_work_sync (&led[led->id].work);
This looks wrong. I guess it should be "&led[i]..."
Quoted 89 lines
drivers/leds/leds-pmic8058.c new file +33
-0+ } + +kfree (led); + +return 0 ; +} + +static struct platform_driver pmic8058_led_driver = { + .probe = pmic8058_led_probe, + .remove =__devexit_p (pmic8058_led_remove), + .driver = { + .name ="pm8058-led" , + .owner =THIS_MODULE , + }, +}; + +static int __init pmic8058_led_init (void ) +{ +return platform_driver_register (&pmic8058_led_driver); +} +module_init (pmic8058_led_init); + +static void __exit pmic8058_led_exit(void) +{ +platform_driver_unregister (&pmic8058_led_driver); +} +module_exit (pmic8058_led_exit); + +MODULE_DESCRIPTION ("PMIC8058 LEDs driver" ); +MODULE_LICENSE ("GPL v2" ); +MODULE_VERSION ("1.0" ); +MODULE_ALIAS ("platform:pmic8058-led" ); +MODULE_AUTHOR ("Trilok Soni <[email protected]>" );include/linux/leds-pmic8058.h new file +50
-0@@ -0,0 +1,61 @@ +/* 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. +* +* 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. +*/ + +#ifndef __LEDS_PMIC8058_H__ +#define __LEDS_PMIC8058_H__ + +/** +* enum pmic8058_leds - PMIC8058 supported led ids +* @PMIC8058_ID_LED_KB_LIGHT - keyboard backlight led +* @PMIC8058_ID_LED_0 - First low current led +* @PMIC8058_ID_LED_1 - Second low current led +* @PMIC8058_ID_LED_2 - Third low current led +* @PMIC8058_ID_FLASH_LED_0 - First flash led +* @PMIC8058_ID_FLASH_LED_0 - Second flash led +*/ +enum pmic8058_leds { +PMIC8058_ID_LED_KB_LIGHT =1 , +PMIC8058_ID_LED_0 , +PMIC8058_ID_LED_1 , +PMIC8058_ID_LED_2 , +PMIC8058_ID_FLASH_LED_0 , +PMIC8058_ID_FLASH_LED_1 , +}; + +/** +* struct pmic8058_led - per led data +* @name - name of the led +* @default_trigger - default trigger which needs to e attached +* @id - supported led id +*/ +struct pmic8058_led { +const char *name; +const char *default_trigger; +enum pmic8058_leds id; +}; +
include/linux/leds-pmic8058.h line 60
Quoted 10 lines
include/linux/leds-pmic8058.h new file +10
-0+/** +* struct pmic8058_leds_platform_data - platform data for leds +* @num_leds - number of leds +* @leds - array of struct pmic8058_led +*/ +struct pmic8058_leds_platform_data { +int num_leds; +struct pmic8058_led *leds; +}; +
Wasn't it the idea to reuse led_info and led_platform_data?
include/linux/leds-pmic8058.h line 61
Quoted 1 line
include/linux/leds-pmic8058.h new file +1
-0+#endif /* __LEDS_PMIC8058_H__ */
Otherwise it looks good to me.
- Lars
RFC PATCH v2 4/7 input: pmic8058_pwrkey: Add support for power key
In reply to Anirudh GhayalFrom: Trilok Soni <[email protected]>
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.
---
Changes from v1:
Addressed review comments from Dmitry.
Added KEY_SCREENLOCK instead of KEY_END.
Moved to timer list instead of hires timers.
drivers/input/misc/Kconfig | 11 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/pmic8058-pwrkey.c | 318 +++++++++++++++++++++++++++++++++ include/linux/input/pmic8058-pwrkey.h | 37 ++++ 4 files changed, 367 insertions(+), 0 deletions(-) create mode 100644 drivers/input/misc/pmic8058-pwrkey.c create mode 100644 include/linux/input/pmic8058-pwrkey.h
drivers/input/misc/Kconfig +11 -0
@@ -330,6 +330,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
drivers/input/misc/Makefile +1 -0
@@ -33,6 +33,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
drivers/input/misc/pmic8058-pwrkey.c new file +318 -0
318 lines not on this page · raw message
include/linux/input/pmic8058-pwrkey.h new file +37 -0
@@ -0,0 +1,37 @@ +/* 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. +* +* 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. +*/ + +#ifndef __PMIC8058_PWRKEY_H__ +#define __PMIC8058_PWRKEY_H__ +/** +* struct pmic8058_pwrkey_pdata - platform data for pwrkey driver +* @pull up: power on register control for pull up/down configuration +* @pwrkey_time_ms: time after which power key event should be generated, if +* key is released before then end key is reported. +* Supply zero for only power key reporting. +* @kpd_trigger_delay_us: time delay for power key state change interrupt +* trigger. +* @wakeup: configure power key as wakeup source +*/ +struct pmic8058_pwrkey_pdata { +bool pull_up; +u16 pwrkey_time_ms; +u32 kpd_trigger_delay_us; +u32 wakeup; +}; + +#endif /* __PMIC8058_PWRKEY_H__ */
Signature · 1 line
1.7.3.5
Dmitry Torokhov
maintainerRe: [RFC v2 PATCH 4/7] input: pmic8058_pwrkey: Add support for power key
Quoted 12 lines · Anirudh Ghayal
From: Trilok Soni <[email protected]>
Add support for PMIC8058 power key driven over dedicated
KYPD_PWR_Npin. It allows the user to specify the amount of time by which the power key reporting can be delayed.Cc Dmitry Torokhov <[email protected]>Signed-off-by Trilok Soni <[email protected]>---
Changes from v1:
Addressed review comments from Dmitry.
AddedKEY_SCREENLOCKinstead ofKEY_END.
...
Quoted 1 line
drivers/input/misc/pmic8058-pwrkey.c new file +1
-0+input_report_key (pwrkey->pwr,KEY_SCROLLLOCK ,1 );
...
Quoted 1 line
drivers/input/misc/pmic8058-pwrkey.c new file +1
-0+input_report_key (pwrkey->pwr,KEY_SCREENLOCK ,0 );
...
drivers/input/misc/pmic8058-pwrkey.c line 199
Quoted 1 line
drivers/input/misc/pmic8058-pwrkey.c new file +1
-0+input_set_capability (pwr,EV_KEY ,KEY_SCROLLLOCK );
You are confused about the event you are sending.
Thanks.
Signature · 1 line
Dmitry
Re: [RFC v2 PATCH 4/7] input: pmic8058_pwrkey: Add support for power key
Hi Dmitry,
Quoted 15 lines · Dmitry Torokhov
Quoted 12 lines · Anirudh Ghayal
From: Trilok Soni <[email protected]>
Add support for PMIC8058 power key driven over dedicated
KYPD_PWR_Npin. It allows the user to specify the amount of time by which the power key reporting can be delayed.Cc Dmitry Torokhov <[email protected]>Signed-off-by Trilok Soni <[email protected]>---
Changes from v1:
Addressed review comments from Dmitry.
AddedKEY_SCREENLOCKinstead ofKEY_END....
Quoted 8 lines
Quoted 1 line
drivers/input/misc/pmic8058-pwrkey.c new file +1
-0+input_report_key (pwrkey->pwr,KEY_SCROLLLOCK ,1 );...
Quoted 1 line
drivers/input/misc/pmic8058-pwrkey.c new file +1
-0+input_report_key (pwrkey->pwr,KEY_SCREENLOCK ,0 );...
drivers/input/misc/pmic8058-pwrkey.c line 199
Quoted 1 line
drivers/input/misc/pmic8058-pwrkey.c new file +1
-0+input_set_capability (pwr,EV_KEY ,KEY_SCROLLLOCK );You are confused about the event you are sending.
My mistake. I will fix this to KEY_SCREENLOCK in v3.
---Trilok Soni
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
RFC PATCH v2 5/7 input: pmic8058-othc: Add support for PM8058 based OTHC
In reply to Anirudh GhayalOne-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.
---
Addressed review comments from Dimitry.
removed IRQF_ONESHOT, const pdata.
drivers/input/misc/Kconfig | 9 + drivers/input/misc/Makefile | 1 + drivers/input/misc/pmic8058-othc.c | 535 +++++++++++++++++++++++++++++++++++ include/linux/input/pmic8058-othc.h | 117 ++++++++ 4 files changed, 662 insertions(+), 0 deletions(-) create mode 100644 drivers/input/misc/pmic8058-othc.c create mode 100644 include/linux/input/pmic8058-othc.h
drivers/input/misc/Kconfig +9 -0
@@ -465,4 +465,13 @@ config INPUT_CMA3000_I2C To compile this driver as a module, choose M here: the module will be called cma3000_d0x_i2c. +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. endif
drivers/input/misc/Makefile +1 -0
@@ -31,6 +31,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
drivers/input/misc/pmic8058-othc.c new file +535 -0
535 lines not on this page · raw message
include/linux/input/pmic8058-othc.h new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
1.7.3.5
Re: [rtc-linux] [RFC v2 PATCH 5/7] input: pmic8058-othc: Add support for PM8058 based OTHC
Quoted 4 lines · Anirudh Ghayal
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.
This should probably be integrated with ASoC for management of the biases if nothing else, though it'd also allow other stuff. ALSA has support for creating input devices from jacks already.
drivers/input/misc/pmic8058-othc.c line 373
Quoted 2 lines
drivers/input/misc/pmic8058-othc.c new file +2
-0+input_set_capability (ipd,EV_SW ,SW_HEADPHONE_INSERT ); +input_set_capability (ipd,EV_KEY ,KEY_MEDIA );
The ALSA (well, ASoC) stuff would also allow the input device to be merged with that for other detection methods so if you've got a headset jack capable of detecting other things (eg, mechanical insertion or separate mic and headphone detection).
Re: [rtc-linux] [RFC v2 PATCH 5/7] input: pmic8058-othc: Add support for PM8058 based OTHC
Hi Mark,
Quoted 10 lines · Mark Brown
Quoted 4 lines · Anirudh Ghayal
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.
This should probably be integrated with ASoC for management of the biases if nothing else, though it'd also allow other stuff. ALSA has support for creating input devices from jacks already.
Quoted 7 lines
drivers/input/misc/pmic8058-othc.c line 373
Quoted 2 lines
drivers/input/misc/pmic8058-othc.c new file +2
-0+input_set_capability (ipd,EV_SW ,SW_HEADPHONE_INSERT ); +input_set_capability (ipd,EV_KEY ,KEY_MEDIA );The ALSA (well, ASoC) stuff would also allow the input device to be merged with that for other detection methods so if you've got a headset jack capable of detecting other things (eg, mechanical insertion or separate mic and headphone detection).
Thanks for the review. We will analyze on how much we should be able to move from this OTHC driver to ALSA jack detection.
---Trilok Soni
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
RFC PATCH v2 6/7 drivers: rtc: Add support for Qualcomm PMIC8058 RTC
In reply to Anirudh GhayalPMIC8058 is Qualcomm's power management IC. A 32-bit RTC is housed inside this PMIC. The RTC driver uses SSBI to communicate with the RTC module.
---
Changes from v1:
Addressed review comments from Peter.
removed rtc"0", local variable to store ctrl register state, removed rtc_irq, added alarm_irq_enable
drivers/rtc/Kconfig | 9 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-pm8058.c | 488 ++++++++++++++++++++++++++++++++++++++++ include/linux/rtc/rtc-pm8058.h | 29 +++ 4 files changed, 527 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-pm8058.c create mode 100644 include/linux/rtc/rtc-pm8058.h
drivers/rtc/Kconfig +9 -0
@@ -985,4 +985,13 @@ config RTC_DRV_LPC32XX This driver can also be buillt as a module. If so, the module will be called rtc-lpc32xx. +config RTC_DRV_PM8058 + tristate "Qualcomm PMIC8058 RTC" + depends on PMIC8058 + help + Say Y here if you want to support the Qualcomm PMIC8058 RTC. + + To compile this driver as a module, choose M here: the + module will be called pmic8058-rtc. + endif # RTC_CLASS
drivers/rtc/Makefile +1 -0
@@ -74,6 +74,7 @@ obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o obj-$(CONFIG_RTC_DRV_PCF2123) += rtc-pcf2123.o obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o +obj-$(CONFIG_RTC_DRV_PM8058) += rtc-pm8058.o obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o obj-$(CONFIG_RTC_DRV_PS3) += rtc-ps3.o
drivers/rtc/rtc-pm8058.c new file +488 -0
488 lines not on this page · raw message
include/linux/rtc/rtc-pm8058.h new file +29 -0
@@ -0,0 +1,29 @@ +/* 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. +* +* 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. +*/ + +#ifndef __RTC_PM8058_H__ +#define __RTC_PM8058_H__ + +/** +* struct pm8058_rtc_pdata - RTC driver platform data +* @rtc_write_enable: variable stating RTC write capability +*/ +struct pm8058_rtc_pdata { +bool rtc_write_enable; +}; + +#endif /* __RTC_PM8058_H__ */
Signature · 1 line
1.7.3.5
RFC PATCH v2 7/7 input: misc: Add support for PM8058 based vibrator driver
In reply to Anirudh GhayalFrom: Amy Maloche <[email protected]>
Add support for pmic8058 based vibrator to facilitate haptics.
--- drivers/input/misc/Kconfig | 12 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/pmic8058-vibrator.c | 306 ++++++++++++++++++++++++++++++++ 3 files changed, 319 insertions(+), 0 deletions(-) create mode 100644 drivers/input/misc/pmic8058-vibrator.c
drivers/input/misc/Kconfig +12 -0
@@ -74,6 +74,18 @@ config INPUT_PCSPKR To compile this driver as a module, choose M here: the module will be called pcspkr. +config INPUT_PMIC8058_VIBRATOR + tristate "Qualcomm PM8058 vibrator support" + depends on PMIC8058 + select INPUT_FF_MEMLESS + help + This option enables device driver support for the vibrator + on Qualcomm PM8058 chip. This driver supports ff-memless interface + from input framework. + + To compile this driver as module, choose M here: the + module will be called pmic8058-vibrator. + config INPUT_SPARCSPKR tristate "SPARC Speaker support" depends on PCI && SPARC64
drivers/input/misc/Makefile +1 -0
@@ -32,6 +32,7 @@ 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_PMIC8058_VIBRATOR) += pmic8058-vibrator.o obj-$(CONFIG_INPUT_POWERMATE) += powermate.o obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o obj-$(CONFIG_INPUT_PMIC8058_PWRKEY) += pmic8058-pwrkey.o
drivers/input/misc/pmic8058-vibrator.c new file +306 -0
306 lines not on this page · raw message
Signature · 1 line
1.7.3.5
Dmitry Torokhov
maintainerRe: [RFC v2 PATCH 7/7] input: misc: Add support for PM8058 based vibrator driver
Hi Anirudh,
drivers/input/misc/pmic8058-vibrator.c line 27
Quoted 3 lines · Anirudh Ghayal
drivers/input/misc/pmic8058-vibrator.c new file +3
-0+ +#include <linux/mfd/pmic8058.h> +#include <linux/input/pmic8058-vibrator.h>
Where is this header file? Shouldn't it be part of this patch?
Quoted 14 lines
drivers/input/misc/pmic8058-vibrator.c new file +14
-0+ +#define VIB_DRV 0x4A + +#define VIB_DRV_SEL_MASK 0xf8 +#define VIB_DRV_SEL_SHIFT 0x03 +#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 + +/*
drivers/input/misc/pmic8058-vibrator.c line 51
Quoted 10 lines
drivers/input/misc/pmic8058-vibrator.c new file +10
-0+* 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 '@').
Quoted 132 lines
+ *
+ */drivers/input/misc/pmic8058-vibrator.c new file +130
-0+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 ; +} +
drivers/input/misc/pmic8058-vibrator.c line 193
Quoted 10 lines
drivers/input/misc/pmic8058-vibrator.c new file +10
-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 belongs to this driver. In fact you overwrite it with pmic8058_vib below, which means that you can't unbind the driver and bind it again.
Please find other way to pass pm_chip.
Quoted 53 lines
drivers/input/misc/pmic8058-vibrator.c new file +53
-0+if (pm_chip ==NULL ) { +dev_err (&pdev->dev,"no parent data passed in\n" ); +return -EINVAL ; + } + +if (!pdata) +return -EINVAL ; + +if (pdata->level_mV < VIB_MIN_LEVEL_mV || + pdata->level_mV > VIB_MAX_LEVEL_mV) +return -EINVAL ; + + vib =kzalloc (sizeof (*vib),GFP_KERNEL ); +if (!vib) +return -ENOMEM ; + + vib->pm_chip = pm_chip; + vib->pdata = pdata; + vib->dev = &pdev->dev; + +INIT_WORK (&vib->work, pmic8058_work_handler); + + vib->vib_input_dev =input_allocate_device (); + +if (vib->vib_input_dev ==NULL ) { +dev_err (&pdev->dev,"couldn't allocate input device\n" ); + rc = -ENOMEM ; + goto err_alloc_dev; + } + +input_set_drvdata (vib->vib_input_dev, vib); + + vib->vib_input_dev->name ="pmic8058_vibrator" ; + vib->vib_input_dev->id.version =1 ; + vib->vib_input_dev->dev.parent = &pdev->dev; + +/* operate in manual mode */ + rc =pmic8058_vib_read_u8 (vib, &val,VIB_DRV ); +if (rc <0 ) + goto err_read_vib; + val &= ~VIB_DRV_EN_MANUAL_MASK ; + rc =pmic8058_vib_write_u8 (vib, val,VIB_DRV ); +if (rc <0 ) + goto err_read_vib; + + vib->reg_vib_drv = val; + +input_set_capability (vib->vib_input_dev,EV_FF ,FF_RUMBLE ); + + rc =input_ff_create_memless (vib->vib_input_dev,NULL , + pmic8058_vib_play_effect); +if (rc <0 ) { +dev_dbg (&pdev->dev,"couldn't register vibrator to FF\n" );
drivers/input/misc/pmic8058-vibrator.c line 256
Quoted 10 lines
drivers/input/misc/pmic8058-vibrator.c new file +10
-0+ goto err_create_memless; + } + +platform_set_drvdata (pdev, vib); + + rc =input_register_device (vib->vib_input_dev); +if (rc <0 ) { +dev_dbg (&pdev->dev,"couldn't register input device\n" ); + goto err_reg_input_dev; + }
platform_set_drvdata(pdev, vib) should go here so you do not need to clean it if input_register_device() fails.
Quoted 9 lines
drivers/input/misc/pmic8058-vibrator.c new file +9
-0+return 0 ; + +err_reg_input_dev: +input_ff_destroy (vib->vib_input_dev); +err_create_memless: +err_read_vib: +input_free_device (vib->vib_input_dev); +err_alloc_dev: +kfree (vib);
drivers/input/misc/pmic8058-vibrator.c line 275
Quoted 10 lines
drivers/input/misc/pmic8058-vibrator.c new file +10
-0+return rc; +} + +static int __devexit pmic8058_vib_remove(struct platform_device *pdev) +{ +struct pmic8058_vib *vib =platform_get_drvdata (pdev); + +cancel_work_sync (&vib->work); +if (vib->state) +pmic8058_vib_set (vib,0 );
This should probably be part of pmic8058_vib_close() method.
drivers/input/misc/pmic8058-vibrator.c line 278
Quoted 3 lines
drivers/input/misc/pmic8058-vibrator.c new file +3
-0+ +input_unregister_device (vib->vib_input_dev); +kfree (vib);
Need to call platform_set_drvdata(pdev, NULL);
drivers/input/misc/pmic8058-vibrator.c line 289
Quoted 11 lines
drivers/input/misc/pmic8058-vibrator.c new file +11
-0+return 0 ; +} + +static struct platform_driver pmic8058_vib_driver = { + .probe = pmic8058_vib_probe, + .remove =__devexit_p (pmic8058_vib_remove), + .driver = { + .name ="pm8058-vib" , + .owner =THIS_MODULE , + }, +};
What about PM? Do you need to shut off vibration if device goes to sleep?
Thanks.
Signature · 1 line
Dmitry
Re: [RFC v2 PATCH 7/7] input: misc: Add support for PM8058 based vibrator driver
Hi Dmitry,
Quoted 8 lines · Dmitry Torokhov
Hi Anirudh,
drivers/input/misc/pmic8058-vibrator.c line 27
Quoted 3 lines · Anirudh Ghayal
drivers/input/misc/pmic8058-vibrator.c new file +3
-0+ +#include <linux/mfd/pmic8058.h> +#include <linux/input/pmic8058-vibrator.h> Where is this header file? Shouldn't it be part of this patch?
Looks like someone forgot "git add" on it. We will fix this in v3.
Quoted 20 lines
Quoted 20 lines
drivers/input/misc/pmic8058-vibrator.c new file +19
-0+ +#define VIB_DRV 0x4A + +#define VIB_DRV_SEL_MASK 0xf8 +#define VIB_DRV_SEL_SHIFT 0x03 +#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
Quoted 8 lines
Quoted 5 lines
+ *
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_DRVregister valueHmm, this is kind of kerneldoc but not quite (kerneldoc's arguments start with '@').
Ack. It will be fixed.
Quoted 16 lines
drivers/input/misc/pmic8058-vibrator.c line 193
Quoted 11 lines
drivers/input/misc/pmic8058-vibrator.c new file +11
-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 belongs to this driver. In fact you overwrite it with
pmic8058_vibbelow, which means that you can't unbind the driver and bind it again.
Quoted 1 line
Please find other way to pass
pm_chip.
This will be fixed through pmic8058 core driver, when we submit. We are aware of it, and the all the sub-device driver will be changed to do it properly once we release them again with pmic core driver submission.
Quoted 11 lines
drivers/input/misc/pmic8058-vibrator.c line 256
Quoted 8 lines
drivers/input/misc/pmic8058-vibrator.c new file +8
-0+ +platform_set_drvdata (pdev, vib); + + rc =input_register_device (vib->vib_input_dev); +if (rc <0 ) { +dev_dbg (&pdev->dev,"couldn't register input device\n" ); + goto err_reg_input_dev; + }
platform_set_drvdata(pdev, vib)should go here so you do not need to clean it ifinput_register_device()fails.
Ack
Quoted 11 lines
drivers/input/misc/pmic8058-vibrator.c line 275
Quoted 8 lines
drivers/input/misc/pmic8058-vibrator.c new file +8
-0+ +static int __devexit pmic8058_vib_remove(struct platform_device *pdev) +{ +struct pmic8058_vib *vib =platform_get_drvdata (pdev); + +cancel_work_sync (&vib->work); +if (vib->state) +pmic8058_vib_set (vib,0 );This should probably be part of
pmic8058_vib_close()method.
Ok. We will check and fix.
Quoted 5 lines
drivers/input/misc/pmic8058-vibrator.c line 278
Quoted 3 lines
drivers/input/misc/pmic8058-vibrator.c new file +3
-0+ +input_unregister_device (vib->vib_input_dev); +kfree (vib);Need to call
platform_set_drvdata(pdev, NULL);
Ack.
Quoted 2 lines
What about PM? Do you need to shut off vibration if device goes to sleep?
Yes. Let me check and add it to v3 patch series.
I will drop the PMIC8058 OTHC from v3 series, as Mark suggested to explore ASoC way of doing it.
---Trilok Soni
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.