diff options
author | lars <lars@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-07-30 15:40:36 +0000 |
---|---|---|
committer | lars <lars@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2009-07-30 15:40:36 +0000 |
commit | fe8a4ad530831ef7b897a9617b30a6d280fd2814 (patch) | |
tree | cd5842b6ead6386c81db676073eeeca1998f2414 | |
parent | d6694fb05efb76fcc931bd1588facd28073fcaf0 (diff) |
[s3c24xx] Replace gta02 led driver with generic gpio led driver.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@17053 3c298f89-4303-0410-b956-a3cf2f4a3e73
3 files changed, 32 insertions, 205 deletions
diff --git a/target/linux/s3c24xx/config-2.6.30 b/target/linux/s3c24xx/config-2.6.30 index 3324e5bfa3..f5933c4675 100644 --- a/target/linux/s3c24xx/config-2.6.30 +++ b/target/linux/s3c24xx/config-2.6.30 @@ -219,8 +219,7 @@ CONFIG_LCD_CLASS_DEVICE=y # CONFIG_LCD_PLATFORM is not set # CONFIG_LCD_TDO24M is not set # CONFIG_LCD_VGG2432A4 is not set -# CONFIG_LEDS_GPIO is not set -CONFIG_LEDS_GTA02=y +CONFIG_LEDS_GPIO=y CONFIG_LEDS_GTA02_VIBRATOR=y # CONFIG_LEDS_PWM is not set # CONFIG_LEDS_S3C24XX is not set @@ -254,9 +253,8 @@ CONFIG_MACH_NEO1973_GTA02=y CONFIG_MFD_CORE=y CONFIG_MFD_GLAMO=y CONFIG_MFD_GLAMO_FB=y -# CONFIG_MFD_GLAMO_FB_XGLAMO_WORKAROUND is not set +CONFIG_MFD_GLAMO_GPIO=y CONFIG_MFD_GLAMO_MCI=y -CONFIG_MFD_GLAMO_SPI_GPIO=y CONFIG_MFD_PCF50633=y # CONFIG_MFD_T7L66XB is not set # CONFIG_MISC_DEVICES is not set @@ -327,7 +325,8 @@ CONFIG_S3C2410_PM=y CONFIG_S3C2410_WATCHDOG=y CONFIG_S3C2440_DMA=y # CONFIG_S3C24XX_ADC is not set -CONFIG_S3C24XX_GPIO_EXTRA=0 +CONFIG_S3C24XX_GPIO_EXTRA=64 +CONFIG_S3C24XX_GPIO_EXTRA64=yes CONFIG_S3C24XX_PWM=y # CONFIG_S3C_BOOT_ERROR_RESET is not set CONFIG_S3C_BOOT_UART_FORCE_FIFO=y @@ -371,7 +370,7 @@ CONFIG_SOUND=m # CONFIG_SOUND_OSS_CORE is not set CONFIG_SPI=y CONFIG_SPI_BITBANG=y -# CONFIG_SPI_GPIO is not set +CONFIG_SPI_GPIO=y CONFIG_SPI_MASTER=y CONFIG_SPI_S3C24XX=y CONFIG_SPI_S3C24XX_GPIO=y diff --git a/target/linux/s3c24xx/files-2.6.30/arch/arm/mach-s3c2442/mach-gta02.c b/target/linux/s3c24xx/files-2.6.30/arch/arm/mach-s3c2442/mach-gta02.c index 88377dac28..b5a9fa6218 100644 --- a/target/linux/s3c24xx/files-2.6.30/arch/arm/mach-s3c2442/mach-gta02.c +++ b/target/linux/s3c24xx/files-2.6.30/arch/arm/mach-s3c2442/mach-gta02.c @@ -38,6 +38,7 @@ #include <linux/spi/spi_gpio.h> #include <linux/spi/spi_bitbang.h> #include <linux/mmc/host.h> +#include <linux/leds.h> #include <linux/mtd/mtd.h> #include <linux/mtd/nand.h> @@ -1079,7 +1080,7 @@ static struct platform_device gta02_bl_dev = { static void gta02_jbt6k74_reset(int devidx, int level) { - gpio_set_value(GTA02_GPIO_GLAMO(4), level); + gpio_set_value(GTA02_GPIO_GLAMO(4), level); } static void gta02_jbt6k74_probe_completed(struct device *dev) @@ -1246,26 +1247,30 @@ static struct platform_device gta02_spi_gpio_dev = { /*----------- / SPI: Accelerometers attached to SPI of s3c244x ----------------- */ -static struct resource gta02_led_resources[] = { +static struct gpio_led gta02_gpio_leds[] = { { .name = "gta02-power:orange", - .start = GTA02_GPIO_PWR_LED1, - .end = GTA02_GPIO_PWR_LED1, + .gpio = GTA02_GPIO_PWR_LED1, }, { .name = "gta02-power:blue", - .start = GTA02_GPIO_PWR_LED2, - .end = GTA02_GPIO_PWR_LED2, + .gpio = GTA02_GPIO_PWR_LED2, }, { .name = "gta02-aux:red", - .start = GTA02_GPIO_AUX_LED, - .end = GTA02_GPIO_AUX_LED, + .gpio = GTA02_GPIO_AUX_LED, }, }; +static struct gpio_led_platform_data gta02_gpio_leds_pdata = { + .leds = gta02_gpio_leds, + .num_leds = ARRAY_SIZE(gta02_gpio_leds), +}; + struct platform_device gta02_led_dev = { - .name = "gta02-led", - .num_resources = ARRAY_SIZE(gta02_led_resources), - .resource = gta02_led_resources, + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = >a02_gpio_leds_pdata, + }, }; static struct resource gta02_button_resources[] = { @@ -1433,9 +1438,9 @@ static struct glamo_mmc_platform_data gta02_glamo_mmc_pdata = { static struct glamo_platform_data gta02_glamo_pdata = { .fb_data = >a02_glamo_fb_pdata, .mmc_data = >a02_glamo_mmc_pdata, - .gpio_base = GTA02_GPIO_GLAMO_BASE, + .gpio_base = GTA02_GPIO_GLAMO_BASE, - .osci_clock_rate = 32768, + .osci_clock_rate = 32768, .glamo_irq_is_wired = glamo_irq_is_wired, .glamo_external_reset = gta02_glamo_external_reset, @@ -1500,10 +1505,10 @@ struct spi_gpio_platform_data spigpio_platform_data = { static struct platform_device spigpio_device = { .name = "spi_gpio", - .id = 2, + .id = 2, .dev = { .platform_data = &spigpio_platform_data, - .parent = >a02_glamo_dev.dev, + .parent = >a02_glamo_dev.dev, }, }; @@ -1572,10 +1577,10 @@ static struct platform_device *gta02_devices_pmu_children[] = { static void gta02_register_glamo(void) { platform_device_register(>a02_glamo_dev); - if (gpio_request(GTA02_GPIO_GLAMO(4), "jbt6k74 reset")) - printk("gta02: Failed to request jbt6k74 reset pin\n"); - if (gpio_direction_output(GTA02_GPIO_GLAMO(4), 1)) - printk("gta02: Failed to configure jbt6k74 reset pin\n"); + if (gpio_request(GTA02_GPIO_GLAMO(4), "jbt6k74 reset")) + printk("gta02: Failed to request jbt6k74 reset pin\n"); + if (gpio_direction_output(GTA02_GPIO_GLAMO(4), 1)) + printk("gta02: Failed to configure jbt6k74 reset pin\n"); platform_device_register(&spigpio_device); } @@ -1595,8 +1600,8 @@ static void gta02_pmu_regulator_registered(struct pcf50633 *pcf, int id) pdev = >a02_pm_gps_dev; break; case PCF50633_REGULATOR_HCLDO: - gta02_register_glamo(); - return; + gta02_register_glamo(); + return; default: return; } @@ -1623,7 +1628,7 @@ static void gta02_pmu_attach_child_devices(struct pcf50633 *pcf) platform_add_devices(gta02_devices_pmu_children, ARRAY_SIZE(gta02_devices_pmu_children)); - regulator_has_full_constraints(); + regulator_has_full_constraints(); } static void gta02_poweroff(void) diff --git a/target/linux/s3c24xx/files-2.6.30/drivers/leds/leds-gta02.c b/target/linux/s3c24xx/files-2.6.30/drivers/leds/leds-gta02.c deleted file mode 100644 index 48559b1136..0000000000 --- a/target/linux/s3c24xx/files-2.6.30/drivers/leds/leds-gta02.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * LED driver for the Openmoko GTA02 GSM phone - * - * (C) 2006-2008 by Openmoko, Inc. - * Author: Harald Welte <laforge@openmoko.org> - * 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 as - * published by the Free Software Foundation. - * - */ - -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/leds.h> -#include <mach/hardware.h> -#include <asm/mach-types.h> -#include <mach/gta02.h> -#include <plat/regs-timer.h> - -#define MAX_LEDS 3 -#define COUNTER 256 - -struct gta02_led_priv -{ - spinlock_t lock; - struct led_classdev cdev; - unsigned int gpio; -}; - -struct gta02_led_bundle -{ - int num_leds; - struct gta02_led_priv led[MAX_LEDS]; -}; - -static inline struct gta02_led_priv *to_priv(struct led_classdev *led_cdev) -{ - return container_of(led_cdev, struct gta02_led_priv, cdev); -} - -static inline struct gta02_led_bundle *to_bundle(struct led_classdev *led_cdev) -{ - return dev_get_drvdata(led_cdev->dev->parent); -} - -static void gta02led_set(struct led_classdev *led_cdev, - enum led_brightness value) -{ - unsigned long flags; - struct gta02_led_priv *lp = to_priv(led_cdev); - - spin_lock_irqsave(&lp->lock, flags); - s3c2410_gpio_setpin(lp->gpio, value ? 1 : 0); - spin_unlock_irqrestore(&lp->lock, flags); -} - -#ifdef CONFIG_PM -static int gta02led_suspend(struct platform_device *pdev, pm_message_t state) -{ - struct gta02_led_bundle *bundle = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < bundle->num_leds; i++) - led_classdev_suspend(&bundle->led[i].cdev); - - return 0; -} - -static int gta02led_resume(struct platform_device *pdev) -{ - struct gta02_led_bundle *bundle = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < bundle->num_leds; i++) - led_classdev_resume(&bundle->led[i].cdev); - - return 0; -} -#endif - -static int __init gta02led_probe(struct platform_device *pdev) -{ - int i, rc; - struct gta02_led_bundle *bundle; - - if (!machine_is_neo1973_gta02()) - return -EIO; - - bundle = kzalloc(sizeof(struct gta02_led_bundle), GFP_KERNEL); - if (!bundle) - return -ENOMEM; - platform_set_drvdata(pdev, bundle); - - for (i = 0; i < pdev->num_resources; i++) { - struct gta02_led_priv *lp; - struct resource *r; - - if (i >= MAX_LEDS) - break; - - r = platform_get_resource(pdev, 0, i); - if (!r || !r->start || !r->name) - continue; - - lp = &bundle->led[i]; - - lp->gpio = r->start; - lp->cdev.name = r->name; - lp->cdev.brightness_set = gta02led_set; - - switch (lp->gpio) { - case S3C2410_GPB0: - case S3C2410_GPB1: - case S3C2410_GPB2: - s3c2410_gpio_cfgpin(lp->gpio, S3C2410_GPIO_OUTPUT); - break; - default: - break; - } - - spin_lock_init(&lp->lock); - rc = led_classdev_register(&pdev->dev, &lp->cdev); - } - - bundle->num_leds = i; - - return 0; -} - -static int gta02led_remove(struct platform_device *pdev) -{ - struct gta02_led_bundle *bundle = platform_get_drvdata(pdev); - int i; - - for (i = 0; i < bundle->num_leds; i++) { - struct gta02_led_priv *lp = &bundle->led[i]; - gta02led_set(&lp->cdev, 0); - led_classdev_unregister(&lp->cdev); - } - - platform_set_drvdata(pdev, NULL); - kfree(bundle); - - return 0; -} - -static struct platform_driver gta02led_driver = { - .probe = gta02led_probe, - .remove = gta02led_remove, -#ifdef CONFIG_PM - .suspend = gta02led_suspend, - .resume = gta02led_resume, -#endif - .driver = { - .name = "gta02-led", - }, -}; - -static int __init gta02led_init(void) -{ - return platform_driver_register(>a02led_driver); -} - -static void __exit gta02led_exit(void) -{ - platform_driver_unregister(>a02led_driver); -} - -module_init(gta02led_init); -module_exit(gta02led_exit); - -MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>"); -MODULE_DESCRIPTION("Openmoko GTA02 LED driver"); -MODULE_LICENSE("GPL"); |