Merge changes I09ff589a,Iabdc863b,Ib53510db into msm-3.0

* changes:
  defconfig: msm7627a: Enable PMIC LEDs driver
  board-msm7627a-io: Add platform device for touch backlight
  leds: leds-pmic-mpp: Add support for MPP connected LED
This commit is contained in:
Linux Build Service Account
2012-05-03 04:55:22 -07:00
committed by QuIC Gerrit Code Review
6 changed files with 175 additions and 0 deletions

View File

@@ -309,6 +309,7 @@ CONFIG_MMC_MSM_SDC3_SUPPORT=y
CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_MSM_PDM=y
CONFIG_LEDS_PMIC_MPP=y
CONFIG_SWITCH=y
CONFIG_SWITCH_GPIO=y
CONFIG_RTC_CLASS=y

View File

@@ -309,6 +309,7 @@ CONFIG_MMC_MSM_CARD_HW_DETECTION=y
CONFIG_MMC_MSM_SDC3_SUPPORT=y
CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT=y
CONFIG_LEDS_MSM_PDM=y
CONFIG_LEDS_PMIC_MPP=y
CONFIG_SWITCH=y
CONFIG_SWITCH_GPIO=y
CONFIG_RTC_CLASS=y

View File

@@ -25,6 +25,7 @@
#include <asm/gpio.h>
#include <asm/mach-types.h>
#include <mach/rpc_server_handset.h>
#include <mach/pmic.h>
#include "devices.h"
#include "board-msm7627a.h"
@@ -653,6 +654,24 @@ static struct platform_device kp_pdev_sku3 = {
},
};
static struct led_info ctp_backlight_info = {
.name = "button-backlight",
.flags = PM_MPP__I_SINK__LEVEL_40mA << 16 | PM_MPP_7,
};
static struct led_platform_data ctp_backlight_pdata = {
.leds = &ctp_backlight_info,
.num_leds = 1,
};
static struct platform_device pmic_mpp_leds_pdev = {
.name = "pmic-mpp-leds",
.id = -1,
.dev = {
.platform_data = &ctp_backlight_pdata,
},
};
void __init msm7627a_add_io_devices(void)
{
/* touchscreen */
@@ -752,5 +771,6 @@ void __init qrd7627a_add_io_devices(void)
}
platform_device_register(&gpio_leds_8625);
platform_device_register(&pmic_mpp_leds_pdev);
}
}

View File

@@ -194,6 +194,18 @@ config LEDS_MSM_PDM
To compile this driver as a module, choose M here: the
module will be called leds-msm-pdm.
config LEDS_PMIC_MPP
tristate "LED Support for Qualcomm PMIC MPP connected LEDs"
depends on LEDS_CLASS && MSM_SMD
help
This option enables support for LEDs connected to PMIC MPPs
on Qualcomm reference boards.
If unsure, say N.
To compile this driver as a module, choose M here: the
module will be called leds-pmic-mpp.
config LEDS_GPIO_PLATFORM
bool "Platform device bindings for GPIO LEDs"
depends on LEDS_GPIO

View File

@@ -47,6 +47,7 @@ obj-$(CONFIG_LEDS_NS2) += leds-ns2.o
obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o
obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
obj-$(CONFIG_LEDS_PMIC8058) += leds-pmic8058.o
obj-$(CONFIG_LEDS_PMIC_MPP) += leds-pmic-mpp.o
obj-$(CONFIG_LEDS_QCIBL) += leds-qci-backlight.o
obj-$(CONFIG_LEDS_MSM_PDM) += leds-msm-pdm.o

View File

@@ -0,0 +1,140 @@
/* Copyright (c) 2012, 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/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
#include <linux/slab.h>
#include <mach/pmic.h>
#define LED_MPP(x) ((x) & 0xFF)
#define LED_CURR(x) ((x) >> 16)
struct pmic_mpp_led_data {
struct led_classdev cdev;
int curr;
int mpp;
};
static void pm_mpp_led_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
struct pmic_mpp_led_data *led;
int ret;
led = container_of(led_cdev, struct pmic_mpp_led_data, cdev);
if (value < LED_OFF || value > led->cdev.max_brightness) {
dev_err(led->cdev.dev, "Invalid brightness value");
return;
}
ret = pmic_secure_mpp_config_i_sink(led->mpp, led->curr,
value ? PM_MPP__I_SINK__SWITCH_ENA :
PM_MPP__I_SINK__SWITCH_DIS);
if (ret)
dev_err(led_cdev->dev, "can't set mpp led\n");
}
static int pmic_mpp_led_probe(struct platform_device *pdev)
{
const struct led_platform_data *pdata = pdev->dev.platform_data;
struct pmic_mpp_led_data *led, *tmp_led;
int i, rc;
if (!pdata) {
dev_err(&pdev->dev, "platform data not supplied\n");
return -EINVAL;
}
led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL);
if (!led) {
dev_err(&pdev->dev, "failed to alloc memory\n");
return -ENOMEM;
}
platform_set_drvdata(pdev, led);
for (i = 0; i < pdata->num_leds; i++) {
tmp_led = &led[i];
tmp_led->cdev.name = pdata->leds[i].name;
tmp_led->cdev.brightness_set = pm_mpp_led_set;
tmp_led->cdev.brightness = LED_OFF;
tmp_led->cdev.max_brightness = LED_FULL;
tmp_led->mpp = LED_MPP(pdata->leds[i].flags);
tmp_led->curr = LED_CURR(pdata->leds[i].flags);
if (tmp_led->curr < PM_MPP__I_SINK__LEVEL_5mA ||
tmp_led->curr > PM_MPP__I_SINK__LEVEL_40mA) {
dev_err(&pdev->dev, "invalid current\n");
goto unreg_led_cdev;
}
rc = led_classdev_register(&pdev->dev, &tmp_led->cdev);
if (rc) {
dev_err(&pdev->dev, "failed to register led\n");
goto unreg_led_cdev;
}
}
return 0;
unreg_led_cdev:
while (i)
led_classdev_unregister(&led[--i].cdev);
kfree(led);
return rc;
}
static int __devexit pmic_mpp_led_remove(struct platform_device *pdev)
{
const struct led_platform_data *pdata = pdev->dev.platform_data;
struct pmic_mpp_led_data *led = platform_get_drvdata(pdev);
int i;
for (i = 0; i < pdata->num_leds; i++)
led_classdev_unregister(&led[i].cdev);
kfree(led);
return 0;
}
static struct platform_driver pmic_mpp_led_driver = {
.probe = pmic_mpp_led_probe,
.remove = __devexit_p(pmic_mpp_led_remove),
.driver = {
.name = "pmic-mpp-leds",
.owner = THIS_MODULE,
},
};
static int __init pmic_mpp_led_init(void)
{
return platform_driver_register(&pmic_mpp_led_driver);
}
module_init(pmic_mpp_led_init);
static void __exit pmic_mpp_led_exit(void)
{
platform_driver_unregister(&pmic_mpp_led_driver);
}
module_exit(pmic_mpp_led_exit);
MODULE_DESCRIPTION("PMIC MPP LEDs driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:pmic-mpp-leds");