Skip to contentSkip to conversation

pcf50633: Replace custom gpio api with gpiolib

PATCH New Lars-Peter Clausen 1 participant 4 messages May 12, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover pcf50633: Replace custom gpio api with gpiolib

Hi

This patch series replaces the custom api in the pcf50633 gpio driver with gpiolib. There is only one user of the custom api which can be safely removed.

Lars-Peter Clausen (3):
gta02: Remove usage of pcf50633 gpio api
MFD: pcf50633-gpio: Add gpiolib support
MFD: pcf50633: Move pcf50633-gpio driver to the gpio drivers folder

 arch/arm/mach-s3c2440/Kconfig      |    1 -
 arch/arm/mach-s3c2440/mach-gta02.c |   12 +--
 drivers/gpio/Kconfig               |    7 +
 drivers/gpio/Makefile              |    1 +
 drivers/gpio/pcf50633-gpio.c       |  228 ++++++++++++++++++++++++++++++++++++
 drivers/mfd/Kconfig                |    7 -
 drivers/mfd/Makefile               |    1 -
 drivers/mfd/pcf50633-core.c        |    4 +-
 drivers/mfd/pcf50633-gpio.c        |  121 -------------------
 include/linux/mfd/pcf50633/core.h  |    4 +
 include/linux/mfd/pcf50633/gpio.h  |   61 +++++-----
 11 files changed, 277 insertions(+), 170 deletions(-)
 create mode 100644 drivers/gpio/pcf50633-gpio.c
 delete mode 100644 drivers/mfd/pcf50633-gpio.c
#1 lore raw

PATCH 1/3 gta02: Remove usage of pcf50633 gpio api

This is the only user of the pcf50633 gpio api. Since the custom interface is going to be replaced with gpiolib all users need to be removed or replaced. It is safe to remove it in this case since it is used to turn a gpio off for which there is no matching enable function call.

---
 arch/arm/mach-s3c2440/Kconfig      |    1 -
 arch/arm/mach-s3c2440/mach-gta02.c |   12 ++----------
 2 files changed, 2 insertions(+), 11 deletions(-)
arch/arm/mach-s3c2440/Kconfig +0 -1
index 9d102b9..16e7066 100644
@@ -95,7 +95,6 @@ config MACH_NEO1973_GTA02
 	bool "Openmoko GTA02 / Freerunner phone"
 	select CPU_S3C2442
 	select MFD_PCF50633
-	select PCF50633_GPIO
 	select I2C
 	select POWER_SUPPLY
 	select MACH_NEO1973
arch/arm/mach-s3c2440/mach-gta02.c +2 -10
index 120a26f..1c7d36d 100644
@@ -54,7 +54,6 @@
 #include <linux/mfd/pcf50633/core.h>
 #include <linux/mfd/pcf50633/mbc.h>
 #include <linux/mfd/pcf50633/adc.h>
-#include <linux/mfd/pcf50633/gpio.h>
 #include <linux/mfd/pcf50633/pmic.h>
 #include <linux/mfd/pcf50633/backlight.h>
 
@@ -167,16 +166,9 @@ gta02_configure_pmu_for_charger(struct pcf50633 *pcf, void *unused, int res)
 	int  ma;
 
 	/* Interpret charger type */
-	if (res < ((ADC_NOM_CHG_DETECT_USB + ADC_NOM_CHG_DETECT_1A) / 2)) {
-
-		/*
-		 * Sanity - stop GPO driving out now that we have a 1A charger
-		 * GPO controls USB Host power generation on GTA02
-		 */
-		pcf50633_gpio_set(pcf, PCF50633_GPO, 0);
-
+	if (res < ((ADC_NOM_CHG_DETECT_USB + ADC_NOM_CHG_DETECT_1A) / 2))
 		ma = 1000;
-	} else
+	else
 		ma = 100;
 
 	pcf50633_mbc_usb_curlim_set(pcf, ma);
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/3 MFD: pcf50633-gpio: Add gpiolib support

In reply to Lars-Peter Clausen

This patch replaces the custom gpio interface of the pcf50633 gpio driver with gpiolib. Although the pcf50633 offers more functionality then what can be exposed through the gpiolib api this functionality is seldomly used. Furthermore functions providing the additional functionality can be modeld on top of gpiolib.
By using gpiolib it is possible to use generic drivers for devices connected to one of the pcf50633 gpios.

---
 drivers/mfd/pcf50633-core.c       |    4 +-
 drivers/mfd/pcf50633-gpio.c       |  159 +++++++++++++++++++++++++++++++------
 include/linux/mfd/pcf50633/core.h |    4 +
 include/linux/mfd/pcf50633/gpio.h |   61 ++++++++-------
 4 files changed, 172 insertions(+), 56 deletions(-)
drivers/mfd/pcf50633-core.c +3 -1
index 704736e..87682c8 100644
@@ -307,7 +307,8 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
 						&pcf->adc_pdev);
 	pcf50633_client_dev_register(pcf, "pcf50633-backlight",
 						&pcf->bl_pdev);
-
+	pcf50633_client_dev_register(pcf, "pcf50633-gpio",
+						&pcf->gpio_pdev);
 
 	for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
 		struct platform_device *pdev;
@@ -349,6 +350,7 @@ static int __devexit pcf50633_remove(struct i2c_client *client)
 
 	pcf50633_irq_free(pcf);
 
+	platform_device_unregister(pcf->gpio_pdev);
 	platform_device_unregister(pcf->input_pdev);
 	platform_device_unregister(pcf->rtc_pdev);
 	platform_device_unregister(pcf->mbc_pdev);
drivers/mfd/pcf50633-gpio.c +133 -26

210 lines not on this page · raw message

include/linux/mfd/pcf50633/core.h +4 -0
index ad411a7..9953fa1 100644
@@ -19,6 +19,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/power_supply.h>
 #include <linux/mfd/pcf50633/backlight.h>
+#include <linux/gpio.h>
 
 struct pcf50633;
 
@@ -46,6 +47,8 @@ struct pcf50633_platform_data {
 	u8 resumers[5];
 
 	struct pcf50633_bl_platform_data *backlight_data;
+
+	int gpio_base;
 };
 
 struct pcf50633_irq {
@@ -151,6 +154,7 @@ struct pcf50633 {
 
 	int onkey1s_held;
 
+	struct platform_device *gpio_pdev;
 	struct platform_device *rtc_pdev;
 	struct platform_device *mbc_pdev;
 	struct platform_device *adc_pdev;
include/linux/mfd/pcf50633/gpio.h +32 -29

70 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 3/3 MFD: pcf50633: Move pcf50633-gpio driver to the gpio drivers folder

In reply to Lars-Peter Clausen

Now that the driver is implemented using gpiolib it should be moved to the gpio drivers folder.

---
 drivers/gpio/Kconfig         |    7 ++
 drivers/gpio/Makefile        |    1 +
 drivers/gpio/pcf50633-gpio.c |  228 ++++++++++++++++++++++++++++++++++++++++++
 drivers/mfd/Kconfig          |    7 --
 drivers/mfd/Makefile         |    1 -
 drivers/mfd/pcf50633-gpio.c  |  228 ------------------------------------------
 6 files changed, 236 insertions(+), 236 deletions(-)
 create mode 100644 drivers/gpio/pcf50633-gpio.c
 delete mode 100644 drivers/mfd/pcf50633-gpio.c
drivers/gpio/Kconfig +7 -0
index bde1bad..905fea4 100644
@@ -242,6 +242,13 @@ config GPIO_ADP5588
 	  To compile this driver as a module, choose M here: the module will be
 	  called adp5588-gpio.
 
+config GPIO_PCF50633
+	tristate "GPIO support for NXP PCF50633"
+	depends on MFD_PCF50633
+	help
+	 Say yes here if you want to include support GPIO for pins on
+	 the PCF50633 chip.
+
 comment "PCI GPIO expanders:"
 
 config GPIO_CS5535
drivers/gpio/Makefile +1 -0
index 51c3cdd..928aede 100644
@@ -31,3 +31,4 @@ obj-$(CONFIG_GPIO_WM8994)	+= wm8994-gpio.o
 obj-$(CONFIG_GPIO_SCH)		+= sch_gpio.o
 obj-$(CONFIG_GPIO_RDC321X)	+= rdc321x-gpio.o
 obj-$(CONFIG_GPIO_JANZ_TTL)	+= janz-ttl.o
+obj-$(CONFIG_GPIO_PCF50633)	+= pcf50633-gpio.o
drivers/gpio/pcf50633-gpio.c new file +228 -0

228 lines not on this page · raw message

drivers/mfd/Kconfig +0 -7
index fea62a9..440118e 100644
@@ -367,13 +367,6 @@ config PCF50633_ADC
 	 Say yes here if you want to include support for ADC in the
 	 NXP PCF50633 chip.
 
-config PCF50633_GPIO
-	tristate "Support for NXP PCF50633 GPIO"
-	depends on MFD_PCF50633
-	help
-	 Say yes here if you want to include support GPIO for pins on
-	 the PCF50633 chip.
-
 config ABX500_CORE
 	bool "ST-Ericsson ABX500 Mixed Signal Circuit register functions"
 	default y if ARCH_U300
drivers/mfd/Makefile +0 -1
index ca1517e..10fed9d 100644
@@ -60,7 +60,6 @@ obj-$(CONFIG_MFD_MAX8925)	+= max8925.o
 pcf50633-objs			:= pcf50633-core.o pcf50633-irq.o
 obj-$(CONFIG_MFD_PCF50633)	+= pcf50633.o
 obj-$(CONFIG_PCF50633_ADC)	+= pcf50633-adc.o
-obj-$(CONFIG_PCF50633_GPIO)	+= pcf50633-gpio.o
 obj-$(CONFIG_ABX500_CORE)	+= abx500-core.o
 obj-$(CONFIG_AB3100_CORE)	+= ab3100-core.o
 obj-$(CONFIG_AB3100_OTP)	+= ab3100-otp.o
drivers/mfd/pcf50633-gpio.c deleted +0 -228

228 lines not on this page · raw message

Signature · 1 line
1.5.6.5