linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework
@ 2012-09-02 10:40 Thierry Reding
  2012-09-02 10:40 ` [PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED() Thierry Reding
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Thierry Reding @ 2012-09-02 10:40 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: NeilBrown, Peter Ujfalusi, Benoit Cousson, Felipe Balbi, linux-kernel

Hi,

This mini series replaces the twl_has_*() macros by the equivalent
standard IS_ENABLED() macro and moves the PWM driver to the PWM
framework.

I'll take the second patch through the PWM tree but would like to have
some Acked-bys from people that know and have the hardware and can
verify that I haven't broken anything.

Thierry

Thierry Reding (2):
  mfd: twl: Replace twl_has_*() macros by IS_ENABLED()
  pwm: Move TWL6030 PWM driver to PWM framework

 drivers/mfd/Kconfig       |  10 ---
 drivers/mfd/Makefile      |   1 -
 drivers/mfd/twl-core.c    | 124 ++++++++-----------------------
 drivers/mfd/twl6030-pwm.c | 165 -----------------------------------------
 drivers/pwm/Kconfig       |   9 +++
 drivers/pwm/Makefile      |   1 +
 drivers/pwm/pwm-twl6030.c | 184 ++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 226 insertions(+), 268 deletions(-)
 delete mode 100644 drivers/mfd/twl6030-pwm.c
 create mode 100644 drivers/pwm/pwm-twl6030.c

-- 
1.7.12


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED()
  2012-09-02 10:40 [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework Thierry Reding
@ 2012-09-02 10:40 ` Thierry Reding
  2012-09-18  7:31   ` Peter Ujfalusi
  2012-09-02 10:40 ` [PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework Thierry Reding
  2012-09-03  8:11 ` [PATCH 0/2] mfd: twl: Move " Peter Ujfalusi
  2 siblings, 1 reply; 11+ messages in thread
From: Thierry Reding @ 2012-09-02 10:40 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: NeilBrown, Peter Ujfalusi, Benoit Cousson, Felipe Balbi, linux-kernel

Instead of reinventing macros for the same purpose, use the standard
macros.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
 drivers/mfd/twl-core.c | 117 +++++++++++--------------------------------------
 1 file changed, 25 insertions(+), 92 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 1c32afe..5fbb2a6 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -63,70 +63,6 @@
 
 #define DRIVER_NAME			"twl"
 
-#if defined(CONFIG_KEYBOARD_TWL4030) || defined(CONFIG_KEYBOARD_TWL4030_MODULE)
-#define twl_has_keypad()	true
-#else
-#define twl_has_keypad()	false
-#endif
-
-#if defined(CONFIG_GPIO_TWL4030) || defined(CONFIG_GPIO_TWL4030_MODULE)
-#define twl_has_gpio()	true
-#else
-#define twl_has_gpio()	false
-#endif
-
-#if defined(CONFIG_REGULATOR_TWL4030) \
-	|| defined(CONFIG_REGULATOR_TWL4030_MODULE)
-#define twl_has_regulator()	true
-#else
-#define twl_has_regulator()	false
-#endif
-
-#if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE)
-#define twl_has_madc()	true
-#else
-#define twl_has_madc()	false
-#endif
-
-#ifdef CONFIG_TWL4030_POWER
-#define twl_has_power()        true
-#else
-#define twl_has_power()        false
-#endif
-
-#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
-#define twl_has_rtc()	true
-#else
-#define twl_has_rtc()	false
-#endif
-
-#if defined(CONFIG_TWL4030_USB) || defined(CONFIG_TWL4030_USB_MODULE) ||\
-	defined(CONFIG_TWL6030_USB) || defined(CONFIG_TWL6030_USB_MODULE)
-#define twl_has_usb()	true
-#else
-#define twl_has_usb()	false
-#endif
-
-#if defined(CONFIG_TWL4030_WATCHDOG) || \
-	defined(CONFIG_TWL4030_WATCHDOG_MODULE)
-#define twl_has_watchdog()        true
-#else
-#define twl_has_watchdog()        false
-#endif
-
-#if defined(CONFIG_MFD_TWL4030_AUDIO) || \
-	defined(CONFIG_MFD_TWL4030_AUDIO_MODULE)
-#define twl_has_codec()	true
-#else
-#define twl_has_codec()	false
-#endif
-
-#if defined(CONFIG_CHARGER_TWL4030) || defined(CONFIG_CHARGER_TWL4030_MODULE)
-#define twl_has_bci()	true
-#else
-#define twl_has_bci()	false
-#endif
-
 /* Triton Core internal information (BEGIN) */
 
 /* Last - for index max*/
@@ -134,13 +70,6 @@
 
 #define TWL_NUM_SLAVES		4
 
-#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \
-	|| defined(CONFIG_INPUT_TWL4030_PWRBUTTON_MODULE)
-#define twl_has_pwrbutton()	true
-#else
-#define twl_has_pwrbutton()	false
-#endif
-
 #define SUB_CHIP_ID0 0
 #define SUB_CHIP_ID1 1
 #define SUB_CHIP_ID2 2
@@ -669,7 +598,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 	struct device	*child;
 	unsigned sub_chip_id;
 
-	if (twl_has_gpio() && pdata->gpio) {
+	if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) {
 		child = add_child(SUB_CHIP_ID1, "twl4030_gpio",
 				pdata->gpio, sizeof(*pdata->gpio),
 				false, irq_base + GPIO_INTR_OFFSET, 0);
@@ -677,7 +606,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 			return PTR_ERR(child);
 	}
 
-	if (twl_has_keypad() && pdata->keypad) {
+	if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) {
 		child = add_child(SUB_CHIP_ID2, "twl4030_keypad",
 				pdata->keypad, sizeof(*pdata->keypad),
 				true, irq_base + KEYPAD_INTR_OFFSET, 0);
@@ -685,7 +614,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 			return PTR_ERR(child);
 	}
 
-	if (twl_has_madc() && pdata->madc) {
+	if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc) {
 		child = add_child(2, "twl4030_madc",
 				pdata->madc, sizeof(*pdata->madc),
 				true, irq_base + MADC_INTR_OFFSET, 0);
@@ -693,7 +622,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 			return PTR_ERR(child);
 	}
 
-	if (twl_has_rtc()) {
+	if (IS_ENABLED(CONFIG_RTC_DRV_TWL4030)) {
 		/*
 		 * REVISIT platform_data here currently might expose the
 		 * "msecure" line ... but for now we just expect board
@@ -709,7 +638,8 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 			return PTR_ERR(child);
 	}
 
-	if (twl_has_usb() && pdata->usb && twl_class_is_4030()) {
+	if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb &&
+	    twl_class_is_4030()) {
 
 		static struct regulator_consumer_supply usb1v5 = {
 			.supply =	"usb1v5",
@@ -723,7 +653,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 		};
 
 	/* First add the regulators so that they can be used by transceiver */
-		if (twl_has_regulator()) {
+		if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) {
 			/* this is a template that gets copied */
 			struct regulator_init_data usb_fixed = {
 				.constraints.valid_modes_mask =
@@ -765,18 +695,19 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 			return PTR_ERR(child);
 
 		/* we need to connect regulators to this transceiver */
-		if (twl_has_regulator() && child) {
+		if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child) {
 			usb1v5.dev_name = dev_name(child);
 			usb1v8.dev_name = dev_name(child);
 			usb3v1[0].dev_name = dev_name(child);
 		}
 	}
-	if (twl_has_usb() && pdata->usb && twl_class_is_6030()) {
+	if (IS_ENABLED(CONFIG_TWL6030_USB) && pdata->usb &&
+	    twl_class_is_6030()) {
 
 		static struct regulator_consumer_supply usb3v3;
 		int regulator;
 
-		if (twl_has_regulator()) {
+		if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) {
 			/* this is a template that gets copied */
 			struct regulator_init_data usb_fixed = {
 				.constraints.valid_modes_mask =
@@ -813,9 +744,10 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 		if (IS_ERR(child))
 			return PTR_ERR(child);
 		/* we need to connect regulators to this transceiver */
-		if (twl_has_regulator() && child)
+		if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child)
 			usb3v3.dev_name = dev_name(child);
-	} else if (twl_has_regulator() && twl_class_is_6030()) {
+	} else if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) &&
+		   twl_class_is_6030()) {
 		if (features & TWL6025_SUBCLASS)
 			child = add_regulator(TWL6025_REG_LDOUSB,
 						pdata->ldousb, features);
@@ -827,20 +759,21 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 					return PTR_ERR(child);
 	}
 
-	if (twl_has_watchdog() && twl_class_is_4030()) {
+	if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) {
 		child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0);
 		if (IS_ERR(child))
 			return PTR_ERR(child);
 	}
 
-	if (twl_has_pwrbutton() && twl_class_is_4030()) {
+	if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) {
 		child = add_child(1, "twl4030_pwrbutton",
 				NULL, 0, true, irq_base + 8 + 0, 0);
 		if (IS_ERR(child))
 			return PTR_ERR(child);
 	}
 
-	if (twl_has_codec() && pdata->audio && twl_class_is_4030()) {
+	if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio &&
+	    twl_class_is_4030()) {
 		sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid;
 		child = add_child(sub_chip_id, "twl4030-audio",
 				pdata->audio, sizeof(*pdata->audio),
@@ -850,7 +783,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 	}
 
 	/* twl4030 regulators */
-	if (twl_has_regulator() && twl_class_is_4030()) {
+	if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_4030()) {
 		child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1,
 					features);
 		if (IS_ERR(child))
@@ -905,7 +838,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 	}
 
 	/* maybe add LDOs that are omitted on cost-reduced parts */
-	if (twl_has_regulator() && !(features & TPS_SUBSET)
+	if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && !(features & TPS_SUBSET)
 	  && twl_class_is_4030()) {
 		child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2,
 					features);
@@ -939,7 +872,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 	}
 
 	/* twl6030 regulators */
-	if (twl_has_regulator() && twl_class_is_6030() &&
+	if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() &&
 			!(features & TWL6025_SUBCLASS)) {
 		child = add_regulator(TWL6030_REG_VDD1, pdata->vdd1,
 					features);
@@ -1013,7 +946,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 	}
 
 	/* 6030 and 6025 share this regulator */
-	if (twl_has_regulator() && twl_class_is_6030()) {
+	if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030()) {
 		child = add_regulator(TWL6030_REG_VANA, pdata->vana,
 					features);
 		if (IS_ERR(child))
@@ -1021,7 +954,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 	}
 
 	/* twl6025 regulators */
-	if (twl_has_regulator() && twl_class_is_6030() &&
+	if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() &&
 			(features & TWL6025_SUBCLASS)) {
 		child = add_regulator(TWL6025_REG_LDO5, pdata->ldo5,
 					features);
@@ -1080,7 +1013,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 
 	}
 
-	if (twl_has_bci() && pdata->bci &&
+	if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci &&
 			!(features & (TPS_SUBSET | TWL5031))) {
 		child = add_child(3, "twl4030_bci",
 				pdata->bci, sizeof(*pdata->bci), false,
@@ -1292,7 +1225,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	}
 
 	/* load power event scripts */
-	if (twl_has_power() && pdata->power)
+	if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata->power)
 		twl4030_power_init(pdata->power);
 
 	/* Maybe init the T2 Interrupt subsystem */
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework
  2012-09-02 10:40 [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework Thierry Reding
  2012-09-02 10:40 ` [PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED() Thierry Reding
@ 2012-09-02 10:40 ` Thierry Reding
  2012-09-03  8:15   ` Peter Ujfalusi
  2012-09-03  8:11 ` [PATCH 0/2] mfd: twl: Move " Peter Ujfalusi
  2 siblings, 1 reply; 11+ messages in thread
From: Thierry Reding @ 2012-09-02 10:40 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: NeilBrown, Peter Ujfalusi, Benoit Cousson, Felipe Balbi, linux-kernel

This commit moves the driver to drivers/pwm and converts it to the new
PWM framework. In order for this to work properly, register the PWM as
child of the multi-function TWL6030 device.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
 drivers/mfd/Kconfig       |  10 ---
 drivers/mfd/Makefile      |   1 -
 drivers/mfd/twl-core.c    |   7 ++
 drivers/mfd/twl6030-pwm.c | 165 -----------------------------------------
 drivers/pwm/Kconfig       |   9 +++
 drivers/pwm/Makefile      |   1 +
 drivers/pwm/pwm-twl6030.c | 184 ++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 201 insertions(+), 176 deletions(-)
 delete mode 100644 drivers/mfd/twl6030-pwm.c
 create mode 100644 drivers/pwm/pwm-twl6030.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index d1facef..2f45891 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -298,16 +298,6 @@ config MFD_TWL4030_AUDIO
 	select MFD_CORE
 	default n
 
-config TWL6030_PWM
-	tristate "TWL6030 PWM (Pulse Width Modulator) Support"
-	depends on TWL4030_CORE
-	select HAVE_PWM
-	depends on !PWM
-	default n
-	help
-	  Say yes here if you want support for TWL6030 PWM.
-	  This is used to control charging LED brightness.
-
 config TWL6040_CORE
 	bool "Support for TWL6040 audio codec"
 	depends on I2C=y && GENERIC_HARDIRQS
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 79dd22d..53063a8 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -63,7 +63,6 @@ obj-$(CONFIG_TWL4030_CORE)	+= twl-core.o twl4030-irq.o twl6030-irq.o
 obj-$(CONFIG_TWL4030_MADC)      += twl4030-madc.o
 obj-$(CONFIG_TWL4030_POWER)    += twl4030-power.o
 obj-$(CONFIG_MFD_TWL4030_AUDIO)	+= twl4030-audio.o
-obj-$(CONFIG_TWL6030_PWM)	+= twl6030-pwm.o
 obj-$(CONFIG_TWL6040_CORE)	+= twl6040-core.o twl6040-irq.o
 
 obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 5fbb2a6..1b1a789 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -638,6 +638,13 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
 			return PTR_ERR(child);
 	}
 
+	if (IS_ENABLED(CONFIG_PWM_TWL6030)) {
+		child = add_child(TWL6030_MODULE_ID1, "twl6030-pwm", NULL, 0,
+				  false, 0, 0);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+	}
+
 	if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb &&
 	    twl_class_is_4030()) {
 
diff --git a/drivers/mfd/twl6030-pwm.c b/drivers/mfd/twl6030-pwm.c
deleted file mode 100644
index e8fee14..0000000
--- a/drivers/mfd/twl6030-pwm.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * twl6030_pwm.c
- * Driver for PHOENIX (TWL6030) Pulse Width Modulator
- *
- * Copyright (C) 2010 Texas Instruments
- * Author: Hemanth V <hemanthv@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed 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, see <http://www.gnu.org/licenses/>.
- */
-
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/i2c/twl.h>
-#include <linux/slab.h>
-
-#define LED_PWM_CTRL1	0xF4
-#define LED_PWM_CTRL2	0xF5
-
-/* Max value for CTRL1 register */
-#define PWM_CTRL1_MAX	255
-
-/* Pull down disable */
-#define PWM_CTRL2_DIS_PD	(1 << 6)
-
-/* Current control 2.5 milli Amps */
-#define PWM_CTRL2_CURR_02	(2 << 4)
-
-/* LED supply source */
-#define PWM_CTRL2_SRC_VAC	(1 << 2)
-
-/* LED modes */
-#define PWM_CTRL2_MODE_HW	(0 << 0)
-#define PWM_CTRL2_MODE_SW	(1 << 0)
-#define PWM_CTRL2_MODE_DIS	(2 << 0)
-
-#define PWM_CTRL2_MODE_MASK	0x3
-
-struct pwm_device {
-	const char *label;
-	unsigned int pwm_id;
-};
-
-int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
-{
-	u8 duty_cycle;
-	int ret;
-
-	if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
-		return -EINVAL;
-
-	duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns;
-
-	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1);
-
-	if (ret < 0) {
-		pr_err("%s: Failed to configure PWM, Error %d\n",
-			pwm->label, ret);
-		return ret;
-	}
-	return 0;
-}
-EXPORT_SYMBOL(pwm_config);
-
-int pwm_enable(struct pwm_device *pwm)
-{
-	u8 val;
-	int ret;
-
-	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
-	if (ret < 0) {
-		pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret);
-		return ret;
-	}
-
-	/* Change mode to software control */
-	val &= ~PWM_CTRL2_MODE_MASK;
-	val |= PWM_CTRL2_MODE_SW;
-
-	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-	if (ret < 0) {
-		pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret);
-		return ret;
-	}
-
-	twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
-	return 0;
-}
-EXPORT_SYMBOL(pwm_enable);
-
-void pwm_disable(struct pwm_device *pwm)
-{
-	u8 val;
-	int ret;
-
-	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
-	if (ret < 0) {
-		pr_err("%s: Failed to disable PWM, Error %d\n",
-			pwm->label, ret);
-		return;
-	}
-
-	val &= ~PWM_CTRL2_MODE_MASK;
-	val |= PWM_CTRL2_MODE_HW;
-
-	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-	if (ret < 0) {
-		pr_err("%s: Failed to disable PWM, Error %d\n",
-			pwm->label, ret);
-		return;
-	}
-	return;
-}
-EXPORT_SYMBOL(pwm_disable);
-
-struct pwm_device *pwm_request(int pwm_id, const char *label)
-{
-	u8 val;
-	int ret;
-	struct pwm_device *pwm;
-
-	pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
-	if (pwm == NULL) {
-		pr_err("%s: failed to allocate memory\n", label);
-		return NULL;
-	}
-
-	pwm->label = label;
-	pwm->pwm_id = pwm_id;
-
-	/* Configure PWM */
-	val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC |
-		PWM_CTRL2_MODE_HW;
-
-	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
-
-	if (ret < 0) {
-		pr_err("%s: Failed to configure PWM, Error %d\n",
-			 pwm->label, ret);
-
-		kfree(pwm);
-		return NULL;
-	}
-
-	return pwm;
-}
-EXPORT_SYMBOL(pwm_request);
-
-void pwm_free(struct pwm_device *pwm)
-{
-	pwm_disable(pwm);
-	kfree(pwm);
-}
-EXPORT_SYMBOL(pwm_free);
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index e678005..ed81720 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -142,6 +142,15 @@ config  PWM_TIEHRPWM
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-tiehrpwm.
 
+config PWM_TWL6030
+	tristate "TWL6030 PWM support"
+	depends on TWL4030_CORE
+	help
+	  Generic PWM framework driver for TWL6030.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called pwm-twl6030.
+
 config PWM_VT8500
 	tristate "vt8500 pwm support"
 	depends on ARCH_VT8500
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 29cf57e..acfe482 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -11,4 +11,5 @@ obj-$(CONFIG_PWM_SAMSUNG)	+= pwm-samsung.o
 obj-$(CONFIG_PWM_TEGRA)		+= pwm-tegra.o
 obj-$(CONFIG_PWM_TIECAP)	+= pwm-tiecap.o
 obj-$(CONFIG_PWM_TIEHRPWM)	+= pwm-tiehrpwm.o
+obj-$(CONFIG_PWM_TWL6030)	+= pwm-twl6030.o
 obj-$(CONFIG_PWM_VT8500)	+= pwm-vt8500.o
diff --git a/drivers/pwm/pwm-twl6030.c b/drivers/pwm/pwm-twl6030.c
new file mode 100644
index 0000000..8e63878
--- /dev/null
+++ b/drivers/pwm/pwm-twl6030.c
@@ -0,0 +1,184 @@
+/*
+ * twl6030_pwm.c
+ * Driver for PHOENIX (TWL6030) Pulse Width Modulator
+ *
+ * Copyright (C) 2010 Texas Instruments
+ * Author: Hemanth V <hemanthv@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/pwm.h>
+#include <linux/i2c/twl.h>
+#include <linux/slab.h>
+
+#define LED_PWM_CTRL1	0xF4
+#define LED_PWM_CTRL2	0xF5
+
+/* Max value for CTRL1 register */
+#define PWM_CTRL1_MAX	255
+
+/* Pull down disable */
+#define PWM_CTRL2_DIS_PD	(1 << 6)
+
+/* Current control 2.5 milli Amps */
+#define PWM_CTRL2_CURR_02	(2 << 4)
+
+/* LED supply source */
+#define PWM_CTRL2_SRC_VAC	(1 << 2)
+
+/* LED modes */
+#define PWM_CTRL2_MODE_HW	(0 << 0)
+#define PWM_CTRL2_MODE_SW	(1 << 0)
+#define PWM_CTRL2_MODE_DIS	(2 << 0)
+
+#define PWM_CTRL2_MODE_MASK	0x3
+
+struct twl6030_pwm_chip {
+	struct pwm_chip chip;
+};
+
+static int twl6030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+	int ret;
+	u8 val;
+
+	/* Configure PWM */
+	val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC |
+	      PWM_CTRL2_MODE_HW;
+
+	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
+	if (ret < 0) {
+		dev_err(chip->dev, "%s: Failed to configure PWM, Error %d\n",
+			pwm->label, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int twl6030_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
+			      int duty_ns, int period_ns)
+{
+	u8 duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns;
+	int ret;
+
+	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1);
+	if (ret < 0) {
+		pr_err("%s: Failed to configure PWM, Error %d\n",
+			pwm->label, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+	int ret;
+	u8 val;
+
+	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
+	if (ret < 0) {
+		dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n",
+			pwm->label, ret);
+		return ret;
+	}
+
+	/* Change mode to software control */
+	val &= ~PWM_CTRL2_MODE_MASK;
+	val |= PWM_CTRL2_MODE_SW;
+
+	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
+	if (ret < 0) {
+		dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n",
+			pwm->label, ret);
+		return ret;
+	}
+
+	twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
+	return 0;
+}
+
+static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+	int ret;
+	u8 val;
+
+	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
+	if (ret < 0) {
+		dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n",
+			pwm->label, ret);
+		return;
+	}
+
+	val &= ~PWM_CTRL2_MODE_MASK;
+	val |= PWM_CTRL2_MODE_HW;
+
+	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
+	if (ret < 0) {
+		dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n",
+			pwm->label, ret);
+	}
+}
+
+static const struct pwm_ops twl6030_pwm_ops = {
+	.request = twl6030_pwm_request,
+	.config = twl6030_pwm_config,
+	.enable = twl6030_pwm_enable,
+	.disable = twl6030_pwm_disable,
+};
+
+static int twl6030_pwm_probe(struct platform_device *pdev)
+{
+	struct twl6030_pwm_chip *twl6030;
+	int ret;
+
+	twl6030 = devm_kzalloc(&pdev->dev, sizeof(*twl6030), GFP_KERNEL);
+	if (!twl6030)
+		return -ENOMEM;
+
+	twl6030->chip.dev = &pdev->dev;
+	twl6030->chip.ops = &twl6030_pwm_ops;
+	twl6030->chip.base = -1;
+	twl6030->chip.npwm = 1;
+
+	ret = pwmchip_add(&twl6030->chip);
+	if (ret < 0)
+		return ret;
+
+	platform_set_drvdata(pdev, twl6030);
+
+	return 0;
+}
+
+static int twl6030_pwm_remove(struct platform_device *pdev)
+{
+	struct twl6030_pwm_chip *twl6030 = platform_get_drvdata(pdev);
+
+	return pwmchip_remove(&twl6030->chip);
+}
+
+static struct platform_driver twl6030_pwm_driver = {
+	.driver = {
+		.name = "twl6030-pwm",
+	},
+	.probe = twl6030_pwm_probe,
+	.remove = __devexit_p(twl6030_pwm_remove),
+};
+module_platform_driver(twl6030_pwm_driver);
+
+MODULE_ALIAS("platform:twl6030-pwm");
+MODULE_LICENSE("GPL");
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework
  2012-09-02 10:40 [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework Thierry Reding
  2012-09-02 10:40 ` [PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED() Thierry Reding
  2012-09-02 10:40 ` [PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework Thierry Reding
@ 2012-09-03  8:11 ` Peter Ujfalusi
  2012-09-07 13:19   ` Thierry Reding
  2 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-09-03  8:11 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

Hi,

On 09/02/2012 01:40 PM, Thierry Reding wrote:
> Hi,
> 
> This mini series replaces the twl_has_*() macros by the equivalent
> standard IS_ENABLED() macro and moves the PWM driver to the PWM
> framework.
> 
> I'll take the second patch through the PWM tree but would like to have
> some Acked-bys from people that know and have the hardware and can
> verify that I haven't broken anything.

All looks good for me but I have one comment for patch 2.

> 
> Thierry
> 
> Thierry Reding (2):
>   mfd: twl: Replace twl_has_*() macros by IS_ENABLED()
>   pwm: Move TWL6030 PWM driver to PWM framework
> 
>  drivers/mfd/Kconfig       |  10 ---
>  drivers/mfd/Makefile      |   1 -
>  drivers/mfd/twl-core.c    | 124 ++++++++-----------------------
>  drivers/mfd/twl6030-pwm.c | 165 -----------------------------------------
>  drivers/pwm/Kconfig       |   9 +++
>  drivers/pwm/Makefile      |   1 +
>  drivers/pwm/pwm-twl6030.c | 184 ++++++++++++++++++++++++++++++++++++++++++++++
>  7 files changed, 226 insertions(+), 268 deletions(-)
>  delete mode 100644 drivers/mfd/twl6030-pwm.c
>  create mode 100644 drivers/pwm/pwm-twl6030.c
> 


-- 
Péter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework
  2012-09-02 10:40 ` [PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework Thierry Reding
@ 2012-09-03  8:15   ` Peter Ujfalusi
  2012-09-07 13:17     ` Thierry Reding
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-09-03  8:15 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

On 09/02/2012 01:40 PM, Thierry Reding wrote:
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 5fbb2a6..1b1a789 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -638,6 +638,13 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
>  			return PTR_ERR(child);
>  	}
>  
> +	if (IS_ENABLED(CONFIG_PWM_TWL6030)) {

I think you should also check for the PMIC versions here before adding the child:
	if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) {

To avoid loading the twl6030-pwm driver for twl4030 class.

> +		child = add_child(TWL6030_MODULE_ID1, "twl6030-pwm", NULL, 0,
> +				  false, 0, 0);
> +		if (IS_ERR(child))
> +			return PTR_ERR(child);
> +	}
> +
>  	if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb &&
>  	    twl_class_is_4030()) {
>  
> diff --git a/drivers/mfd/twl6030-pwm.c b/drivers/mfd/twl6030-pwm.c
> deleted file mode 100644
> index e8fee14..0000000
> --- a/drivers/mfd/twl6030-pwm.c
> +++ /dev/null
> @@ -1,165 +0,0 @@
> -/*
> - * twl6030_pwm.c
> - * Driver for PHOENIX (TWL6030) Pulse Width Modulator
> - *
> - * Copyright (C) 2010 Texas Instruments
> - * Author: Hemanth V <hemanthv@ti.com>
> - *
> - * This program is free software; you can redistribute it and/or modify it
> - * under the terms of the GNU General Public License version 2 as published by
> - * the Free Software Foundation.
> - *
> - * This program is distributed 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, see <http://www.gnu.org/licenses/>.
> - */
> -
> -#include <linux/module.h>
> -#include <linux/platform_device.h>
> -#include <linux/i2c/twl.h>
> -#include <linux/slab.h>
> -
> -#define LED_PWM_CTRL1	0xF4
> -#define LED_PWM_CTRL2	0xF5
> -
> -/* Max value for CTRL1 register */
> -#define PWM_CTRL1_MAX	255
> -
> -/* Pull down disable */
> -#define PWM_CTRL2_DIS_PD	(1 << 6)
> -
> -/* Current control 2.5 milli Amps */
> -#define PWM_CTRL2_CURR_02	(2 << 4)
> -
> -/* LED supply source */
> -#define PWM_CTRL2_SRC_VAC	(1 << 2)
> -
> -/* LED modes */
> -#define PWM_CTRL2_MODE_HW	(0 << 0)
> -#define PWM_CTRL2_MODE_SW	(1 << 0)
> -#define PWM_CTRL2_MODE_DIS	(2 << 0)
> -
> -#define PWM_CTRL2_MODE_MASK	0x3
> -
> -struct pwm_device {
> -	const char *label;
> -	unsigned int pwm_id;
> -};
> -
> -int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
> -{
> -	u8 duty_cycle;
> -	int ret;
> -
> -	if (pwm == NULL || period_ns == 0 || duty_ns > period_ns)
> -		return -EINVAL;
> -
> -	duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns;
> -
> -	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1);
> -
> -	if (ret < 0) {
> -		pr_err("%s: Failed to configure PWM, Error %d\n",
> -			pwm->label, ret);
> -		return ret;
> -	}
> -	return 0;
> -}
> -EXPORT_SYMBOL(pwm_config);
> -
> -int pwm_enable(struct pwm_device *pwm)
> -{
> -	u8 val;
> -	int ret;
> -
> -	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
> -	if (ret < 0) {
> -		pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret);
> -		return ret;
> -	}
> -
> -	/* Change mode to software control */
> -	val &= ~PWM_CTRL2_MODE_MASK;
> -	val |= PWM_CTRL2_MODE_SW;
> -
> -	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
> -	if (ret < 0) {
> -		pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret);
> -		return ret;
> -	}
> -
> -	twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
> -	return 0;
> -}
> -EXPORT_SYMBOL(pwm_enable);
> -
> -void pwm_disable(struct pwm_device *pwm)
> -{
> -	u8 val;
> -	int ret;
> -
> -	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
> -	if (ret < 0) {
> -		pr_err("%s: Failed to disable PWM, Error %d\n",
> -			pwm->label, ret);
> -		return;
> -	}
> -
> -	val &= ~PWM_CTRL2_MODE_MASK;
> -	val |= PWM_CTRL2_MODE_HW;
> -
> -	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
> -	if (ret < 0) {
> -		pr_err("%s: Failed to disable PWM, Error %d\n",
> -			pwm->label, ret);
> -		return;
> -	}
> -	return;
> -}
> -EXPORT_SYMBOL(pwm_disable);
> -
> -struct pwm_device *pwm_request(int pwm_id, const char *label)
> -{
> -	u8 val;
> -	int ret;
> -	struct pwm_device *pwm;
> -
> -	pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
> -	if (pwm == NULL) {
> -		pr_err("%s: failed to allocate memory\n", label);
> -		return NULL;
> -	}
> -
> -	pwm->label = label;
> -	pwm->pwm_id = pwm_id;
> -
> -	/* Configure PWM */
> -	val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC |
> -		PWM_CTRL2_MODE_HW;
> -
> -	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
> -
> -	if (ret < 0) {
> -		pr_err("%s: Failed to configure PWM, Error %d\n",
> -			 pwm->label, ret);
> -
> -		kfree(pwm);
> -		return NULL;
> -	}
> -
> -	return pwm;
> -}
> -EXPORT_SYMBOL(pwm_request);
> -
> -void pwm_free(struct pwm_device *pwm)
> -{
> -	pwm_disable(pwm);
> -	kfree(pwm);
> -}
> -EXPORT_SYMBOL(pwm_free);
> -
> -MODULE_LICENSE("GPL");
> diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> index e678005..ed81720 100644
> --- a/drivers/pwm/Kconfig
> +++ b/drivers/pwm/Kconfig
> @@ -142,6 +142,15 @@ config  PWM_TIEHRPWM
>  	  To compile this driver as a module, choose M here: the module
>  	  will be called pwm-tiehrpwm.
>  
> +config PWM_TWL6030
> +	tristate "TWL6030 PWM support"
> +	depends on TWL4030_CORE
> +	help
> +	  Generic PWM framework driver for TWL6030.
> +
> +	  To compile this driver as a module, choose M here: the module
> +	  will be called pwm-twl6030.
> +
>  config PWM_VT8500
>  	tristate "vt8500 pwm support"
>  	depends on ARCH_VT8500
> diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
> index 29cf57e..acfe482 100644
> --- a/drivers/pwm/Makefile
> +++ b/drivers/pwm/Makefile
> @@ -11,4 +11,5 @@ obj-$(CONFIG_PWM_SAMSUNG)	+= pwm-samsung.o
>  obj-$(CONFIG_PWM_TEGRA)		+= pwm-tegra.o
>  obj-$(CONFIG_PWM_TIECAP)	+= pwm-tiecap.o
>  obj-$(CONFIG_PWM_TIEHRPWM)	+= pwm-tiehrpwm.o
> +obj-$(CONFIG_PWM_TWL6030)	+= pwm-twl6030.o
>  obj-$(CONFIG_PWM_VT8500)	+= pwm-vt8500.o
> diff --git a/drivers/pwm/pwm-twl6030.c b/drivers/pwm/pwm-twl6030.c
> new file mode 100644
> index 0000000..8e63878
> --- /dev/null
> +++ b/drivers/pwm/pwm-twl6030.c
> @@ -0,0 +1,184 @@
> +/*
> + * twl6030_pwm.c
> + * Driver for PHOENIX (TWL6030) Pulse Width Modulator
> + *
> + * Copyright (C) 2010 Texas Instruments
> + * Author: Hemanth V <hemanthv@ti.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published by
> + * the Free Software Foundation.
> + *
> + * This program is distributed 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, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/pwm.h>
> +#include <linux/i2c/twl.h>
> +#include <linux/slab.h>
> +
> +#define LED_PWM_CTRL1	0xF4
> +#define LED_PWM_CTRL2	0xF5
> +
> +/* Max value for CTRL1 register */
> +#define PWM_CTRL1_MAX	255
> +
> +/* Pull down disable */
> +#define PWM_CTRL2_DIS_PD	(1 << 6)
> +
> +/* Current control 2.5 milli Amps */
> +#define PWM_CTRL2_CURR_02	(2 << 4)
> +
> +/* LED supply source */
> +#define PWM_CTRL2_SRC_VAC	(1 << 2)
> +
> +/* LED modes */
> +#define PWM_CTRL2_MODE_HW	(0 << 0)
> +#define PWM_CTRL2_MODE_SW	(1 << 0)
> +#define PWM_CTRL2_MODE_DIS	(2 << 0)
> +
> +#define PWM_CTRL2_MODE_MASK	0x3
> +
> +struct twl6030_pwm_chip {
> +	struct pwm_chip chip;
> +};
> +
> +static int twl6030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> +	int ret;
> +	u8 val;
> +
> +	/* Configure PWM */
> +	val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC |
> +	      PWM_CTRL2_MODE_HW;
> +
> +	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
> +	if (ret < 0) {
> +		dev_err(chip->dev, "%s: Failed to configure PWM, Error %d\n",
> +			pwm->label, ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static int twl6030_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
> +			      int duty_ns, int period_ns)
> +{
> +	u8 duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns;
> +	int ret;
> +
> +	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1);
> +	if (ret < 0) {
> +		pr_err("%s: Failed to configure PWM, Error %d\n",
> +			pwm->label, ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> +	int ret;
> +	u8 val;
> +
> +	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
> +	if (ret < 0) {
> +		dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n",
> +			pwm->label, ret);
> +		return ret;
> +	}
> +
> +	/* Change mode to software control */
> +	val &= ~PWM_CTRL2_MODE_MASK;
> +	val |= PWM_CTRL2_MODE_SW;
> +
> +	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
> +	if (ret < 0) {
> +		dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n",
> +			pwm->label, ret);
> +		return ret;
> +	}
> +
> +	twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
> +	return 0;
> +}
> +
> +static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> +	int ret;
> +	u8 val;
> +
> +	ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2);
> +	if (ret < 0) {
> +		dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n",
> +			pwm->label, ret);
> +		return;
> +	}
> +
> +	val &= ~PWM_CTRL2_MODE_MASK;
> +	val |= PWM_CTRL2_MODE_HW;
> +
> +	ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2);
> +	if (ret < 0) {
> +		dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n",
> +			pwm->label, ret);
> +	}
> +}
> +
> +static const struct pwm_ops twl6030_pwm_ops = {
> +	.request = twl6030_pwm_request,
> +	.config = twl6030_pwm_config,
> +	.enable = twl6030_pwm_enable,
> +	.disable = twl6030_pwm_disable,
> +};
> +
> +static int twl6030_pwm_probe(struct platform_device *pdev)
> +{
> +	struct twl6030_pwm_chip *twl6030;
> +	int ret;
> +
> +	twl6030 = devm_kzalloc(&pdev->dev, sizeof(*twl6030), GFP_KERNEL);
> +	if (!twl6030)
> +		return -ENOMEM;
> +
> +	twl6030->chip.dev = &pdev->dev;
> +	twl6030->chip.ops = &twl6030_pwm_ops;
> +	twl6030->chip.base = -1;
> +	twl6030->chip.npwm = 1;
> +
> +	ret = pwmchip_add(&twl6030->chip);
> +	if (ret < 0)
> +		return ret;
> +
> +	platform_set_drvdata(pdev, twl6030);
> +
> +	return 0;
> +}
> +
> +static int twl6030_pwm_remove(struct platform_device *pdev)
> +{
> +	struct twl6030_pwm_chip *twl6030 = platform_get_drvdata(pdev);
> +
> +	return pwmchip_remove(&twl6030->chip);
> +}
> +
> +static struct platform_driver twl6030_pwm_driver = {
> +	.driver = {
> +		.name = "twl6030-pwm",
> +	},
> +	.probe = twl6030_pwm_probe,
> +	.remove = __devexit_p(twl6030_pwm_remove),
> +};
> +module_platform_driver(twl6030_pwm_driver);
> +
> +MODULE_ALIAS("platform:twl6030-pwm");
> +MODULE_LICENSE("GPL");
> 


-- 
Péter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework
  2012-09-03  8:15   ` Peter Ujfalusi
@ 2012-09-07 13:17     ` Thierry Reding
  0 siblings, 0 replies; 11+ messages in thread
From: Thierry Reding @ 2012-09-07 13:17 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 745 bytes --]

On Mon, Sep 03, 2012 at 11:15:27AM +0300, Peter Ujfalusi wrote:
> On 09/02/2012 01:40 PM, Thierry Reding wrote:
> > diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> > index 5fbb2a6..1b1a789 100644
> > --- a/drivers/mfd/twl-core.c
> > +++ b/drivers/mfd/twl-core.c
> > @@ -638,6 +638,13 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base,
> >  			return PTR_ERR(child);
> >  	}
> >  
> > +	if (IS_ENABLED(CONFIG_PWM_TWL6030)) {
> 
> I think you should also check for the PMIC versions here before adding the child:
> 	if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) {
> 
> To avoid loading the twl6030-pwm driver for twl4030 class.

Yes, that does make sense. I'll add it.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework
  2012-09-03  8:11 ` [PATCH 0/2] mfd: twl: Move " Peter Ujfalusi
@ 2012-09-07 13:19   ` Thierry Reding
  2012-09-07 13:52     ` Peter Ujfalusi
  0 siblings, 1 reply; 11+ messages in thread
From: Thierry Reding @ 2012-09-07 13:19 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 634 bytes --]

On Mon, Sep 03, 2012 at 11:11:56AM +0300, Peter Ujfalusi wrote:
> Hi,
> 
> On 09/02/2012 01:40 PM, Thierry Reding wrote:
> > Hi,
> > 
> > This mini series replaces the twl_has_*() macros by the equivalent
> > standard IS_ENABLED() macro and moves the PWM driver to the PWM
> > framework.
> > 
> > I'll take the second patch through the PWM tree but would like to have
> > some Acked-bys from people that know and have the hardware and can
> > verify that I haven't broken anything.
> 
> All looks good for me but I have one comment for patch 2.

Okay. With that change to patch 2, can I add your Acked-by?

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework
  2012-09-07 13:19   ` Thierry Reding
@ 2012-09-07 13:52     ` Peter Ujfalusi
  2012-09-18  7:07       ` Thierry Reding
  0 siblings, 1 reply; 11+ messages in thread
From: Peter Ujfalusi @ 2012-09-07 13:52 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

On 09/07/2012 04:19 PM, Thierry Reding wrote:
>> All looks good for me but I have one comment for patch 2.
> 
> Okay. With that change to patch 2, can I add your Acked-by?

Yes, with that change added:

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework
  2012-09-07 13:52     ` Peter Ujfalusi
@ 2012-09-18  7:07       ` Thierry Reding
  2012-09-18  7:32         ` Peter Ujfalusi
  0 siblings, 1 reply; 11+ messages in thread
From: Thierry Reding @ 2012-09-18  7:07 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

On Fri, Sep 07, 2012 at 04:52:05PM +0300, Peter Ujfalusi wrote:
> On 09/07/2012 04:19 PM, Thierry Reding wrote:
> >> All looks good for me but I have one comment for patch 2.
> > 
> > Okay. With that change to patch 2, can I add your Acked-by?
> 
> Yes, with that change added:
> 
> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Peter: does this Acked-by also apply to patch 1?

Do I need Acked-by's from anybody else? I was hoping Samuel would give
his, but there has been no response for over a week. Does anybody know
if he's on vacation or so? I thought I had seen other mails from him,
so maybe he just overlooked this. Before I queue this up for Linus I
wanted to take it through linux-next for a few weeks, but time is
already running short.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED()
  2012-09-02 10:40 ` [PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED() Thierry Reding
@ 2012-09-18  7:31   ` Peter Ujfalusi
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Ujfalusi @ 2012-09-18  7:31 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

On 09/02/2012 01:40 PM, Thierry Reding wrote:
> Instead of reinventing macros for the same purpose, use the standard
> macros.
> 
> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>

Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework
  2012-09-18  7:07       ` Thierry Reding
@ 2012-09-18  7:32         ` Peter Ujfalusi
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Ujfalusi @ 2012-09-18  7:32 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Samuel Ortiz, NeilBrown, Benoit Cousson, Felipe Balbi, linux-kernel

On 09/18/2012 10:07 AM, Thierry Reding wrote:
> Peter: does this Acked-by also apply to patch 1?

Just sent my ack to the first patch.

> Do I need Acked-by's from anybody else? I was hoping Samuel would give
> his, but there has been no response for over a week. Does anybody know
> if he's on vacation or so? I thought I had seen other mails from him,
> so maybe he just overlooked this. Before I queue this up for Linus I
> wanted to take it through linux-next for a few weeks, but time is
> already running short.

Yeah, this reminds me that I also need to ping Samuel for several series
waiting for his ack or to pick them up.

-- 
Péter

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-09-18  7:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-02 10:40 [PATCH 0/2] mfd: twl: Move PWM driver to PWM framework Thierry Reding
2012-09-02 10:40 ` [PATCH 1/2] mfd: twl: Replace twl_has_*() macros by IS_ENABLED() Thierry Reding
2012-09-18  7:31   ` Peter Ujfalusi
2012-09-02 10:40 ` [PATCH 2/2] pwm: Move TWL6030 PWM driver to PWM framework Thierry Reding
2012-09-03  8:15   ` Peter Ujfalusi
2012-09-07 13:17     ` Thierry Reding
2012-09-03  8:11 ` [PATCH 0/2] mfd: twl: Move " Peter Ujfalusi
2012-09-07 13:19   ` Thierry Reding
2012-09-07 13:52     ` Peter Ujfalusi
2012-09-18  7:07       ` Thierry Reding
2012-09-18  7:32         ` Peter Ujfalusi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).