From patchwork Fri Oct 8 13:17:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sugumar Natarajan X-Patchwork-Id: 241301 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o98E0ST8001397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Oct 2010 14:00:50 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o98Dwvcl007761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 8 Oct 2010 08:58:57 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id o98Dwvma009476; Fri, 8 Oct 2010 08:58:57 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id D61348071B; Fri, 8 Oct 2010 08:58:20 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 9BEB08062C for ; Fri, 8 Oct 2010 08:57:26 -0500 (CDT) Received: from tidmzi-ftp.india.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with SMTP id o98DvOCf015609; Fri, 8 Oct 2010 08:57:25 -0500 (CDT) Received: from symphonyindia.ti.com (symphony-ftp [192.168.247.11]) by tidmzi-ftp.india.ext.ti.com (Postfix) with SMTP id 8D4CA3887C; Fri, 8 Oct 2010 19:27:18 +0530 (IST) Received: from localhost.localdomain ([192.168.247.76]) by symphonyindia.ti.com (8.13.1/8.12.10) with ESMTP id o98DoTOP031878; Fri, 8 Oct 2010 19:20:29 +0530 From: sugumar To: linux-embedded@vger.kernel.org Subject: [PATCH 3/4] Modify the back light driver to support the new PWM framework Date: Fri, 8 Oct 2010 18:47:43 +0530 Message-Id: <1286543863-32115-1-git-send-email-sugumar@ti.com> X-Mailer: git-send-email 1.5.6 Cc: davinci-linux-open-source@linux.davincidsp.com X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Oct 2010 14:00:51 +0000 (UTC) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 6f32dd6..0c90d98 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -5,6 +5,7 @@ menuconfig GENERIC_PWM tristate "PWM Support" depends on SYSFS + select HAVE_PWM help This enables PWM support through the generic PWM API. If unsure, say N. diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 5504435..591a2fd 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -17,12 +17,12 @@ #include #include #include -#include +#include #include #include struct pwm_bl_data { - struct pwm_device *pwm; + struct pwm_channel *pwm; struct device *dev; unsigned int period; int (*notify)(struct device *, @@ -45,11 +45,13 @@ static int pwm_backlight_update_status(struct backlight_device *bl) brightness = pb->notify(pb->dev, brightness); if (brightness == 0) { - pwm_config(pb->pwm, 0, pb->period); - pwm_disable(pb->pwm); + pwm_set_period_ns(pb->pwm, pb->period); + pwm_set_duty_ns(pb->pwm, 0); + pwm_stop(pb->pwm); } else { - pwm_config(pb->pwm, brightness * pb->period / max, pb->period); - pwm_enable(pb->pwm); + pwm_set_period_ns(pb->pwm, pb->period); + pwm_set_duty_ns(pb->pwm, brightness * pb->period / max); + pwm_start(pb->pwm); } return 0; } @@ -94,7 +96,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->notify = data->notify; pb->dev = &pdev->dev; - pb->pwm = pwm_request(data->pwm_id, "backlight"); + pb->pwm = pwm_request(data->pwm_id, data->ch, "backlight"); if (IS_ERR(pb->pwm)) { dev_err(&pdev->dev, "unable to request PWM for backlight\n"); ret = PTR_ERR(pb->pwm); @@ -119,7 +121,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) return 0; err_bl: - pwm_free(pb->pwm); + pwm_release(pb->pwm); err_pwm: kfree(pb); err_alloc: @@ -135,9 +137,9 @@ static int pwm_backlight_remove(struct platform_device *pdev) struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev); backlight_device_unregister(bl); - pwm_config(pb->pwm, 0, pb->period); - pwm_disable(pb->pwm); - pwm_free(pb->pwm); + pwm_set_duty_ns(pb->pwm, 0); + pwm_stop(pb->pwm); + pwm_release(pb->pwm); kfree(pb); if (data->exit) data->exit(&pdev->dev); @@ -153,8 +155,8 @@ static int pwm_backlight_suspend(struct platform_device *pdev, if (pb->notify) pb->notify(pb->dev, 0); - pwm_config(pb->pwm, 0, pb->period); - pwm_disable(pb->pwm); + pwm_set_duty_ns(pb->pwm, 0); + pwm_stop(pb->pwm); return 0; } diff --git a/include/linux/pwm_backlight.h b/include/linux/pwm_backlight.h index 01b3d75..eb325bb 100644 --- a/include/linux/pwm_backlight.h +++ b/include/linux/pwm_backlight.h @@ -5,7 +5,8 @@ #define __LINUX_PWM_BACKLIGHT_H struct platform_pwm_backlight_data { - int pwm_id; + const char *pwm_id; + int ch; unsigned int max_brightness; unsigned int dft_brightness; unsigned int pwm_period_ns;