Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463AbYBCUqf (ORCPT ); Sun, 3 Feb 2008 15:46:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752108AbYBCUqZ (ORCPT ); Sun, 3 Feb 2008 15:46:25 -0500 Received: from py-out-1112.google.com ([64.233.166.179]:19680 "EHLO py-out-1112.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbYBCUqY (ORCPT ); Sun, 3 Feb 2008 15:46:24 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:to:cc:subject:message-id:organization:x-mailer:mime-version:content-type:from; b=PG11QHS1ukyNKBOF436x656/3qLQ+v64YBlJunV1pVgL5reavIKUfbiTUrVJ33lkH+nrWjApKOatYBg+jXCz6hEB3Jb+4BdKrKe0k0I5lVTQybB43Jmz6yT+sJoPfKMoBcgWZrBZZtMq7xdP6Mulms368Si4E/Ye6pgYctfYQdI= Date: Sun, 3 Feb 2008 21:46:15 +0100 To: Paul Mundt , rpurdie@openedhand.com Cc: linux-sh , linux-main Subject: [PATCH/LEDS] - Add support for leds on the HP Jornada 6xx series Message-Id: <20080203214615.5cff3eef.Kristoffer.ericson@gmail.com> Organization: JLime X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.5; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Sun__3_Feb_2008_21_46_15_+0100_OdNDQnrlmuQC2vr+" From: Kristoffer Ericson Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11065 Lines: 269 This is a multi-part message in MIME format. --Multipart=_Sun__3_Feb_2008_21_46_15_+0100_OdNDQnrlmuQC2vr+ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Greetings, Patch against linux-2.6.git (synced today) shortlog: The HP Jornada 6xx series have simple leds thats able to produce green or red light. This patch enables the leds to be used by the kernel and/or userland. signed-off-by: Kristoffer Ericson Richard please note that this driver makes use of include/asm-sh/hd6446x.h which is a merged header not yet available. I've sent patch to paul but gotten no answer yet. If you cannot commit it for that reason, then please just look through it. I've confirmed that this patch compiles for me (using local git-tree with header at place) and that it works as expected on jornada. Best wishes Kristoffer Ericson diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index ec568fa..0b0bca1 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -100,6 +100,14 @@ config LEDS_COBALT_RAQ help This option enables support for the Cobalt Raq series LEDs. +config LEDS_HP6XX + bool "LED Support for the HP Jornada 6xx" + depends on LEDS_CLASS && SH_HP6XX + select LEDS_TRIGGERS + help + This option enables led support for the handheld + HP Jornada 620/660/680/690. + config LEDS_GPIO tristate "LED Support for GPIO connected LEDs" depends on LEDS_CLASS && GENERIC_GPIO diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index a60de1b..a9a8ffb 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o +obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o # LED Triggers obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o diff --git a/drivers/leds/leds-hp6xx.c b/drivers/leds/leds-hp6xx.c new file mode 100644 index 0000000..f882e8f --- /dev/null +++ b/drivers/leds/leds-hp6xx.c @@ -0,0 +1,120 @@ +/* + * LED Triggers Core + * For the HP Jornada 620/660/680/690 handhelds + * + * Copyright 2008 Kristoffer Ericson + * this driver is based on leds-spitz.c by Richard Purdie. + * + * 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 +#include +#include +#include +#include +#include + +static void hp6xxled_green_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + u8 v8; + + v8 = inb(PKDR); + if (value) + outb(v8 & (~PKDR_LED_GREEN), PKDR); + else + outb(v8 | PKDR_LED_GREEN, PKDR); +} + +static void hp6xxled_red_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + u16 v16; + + v16 = inw(HD6446x_GPBDR); + if (value) + outw(v16 & (~HD64461_GPBDR_LED_RED), HD6446x_GPBDR); + else + outw(v16 | HD64461_GPBDR_LED_RED, HD6446x_GPBDR); +} + +static struct led_classdev hp6xx_red_led = { + .name = "hp6xx:red", + .default_trigger = "hp6xx-charge", + .brightness_set = hp6xxled_red_set, +}; + +static struct led_classdev hp6xx_green_led = { + .name = "hp6xx:green", + .default_trigger = "ide-disk", + .brightness_set = hp6xxled_green_set, +}; + +#ifdef CONFIG_PM +static int hp6xxled_suspend(struct platform_device *dev, pm_message_t state) +{ + led_classdev_suspend(&hp6xx_red_led); + led_classdev_suspend(&hp6xx_green_led); + return 0; +} + +static int hp6xxled_resume(struct platform_device *dev) +{ + led_classdev_resume(&hp6xx_red_led); + led_classdev_resume(&hp6xx_green_led); + return 0; +} +#endif + +static int hp6xxled_probe(struct platform_device *pdev) +{ + int ret; + + ret = led_classdev_register(&pdev->dev, &hp6xx_red_led); + if (ret < 0) + return ret; + + ret = led_classdev_register(&pdev->dev, &hp6xx_green_led); + if (ret < 0) + led_classdev_unregister(&hp6xx_red_led); + + return ret; +} + +static int hp6xxled_remove(struct platform_device *pdev) +{ + led_classdev_unregister(&hp6xx_red_led); + led_classdev_unregister(&hp6xx_green_led); + + return 0; +} + +static struct platform_driver hp6xxled_driver = { + .probe = hp6xxled_probe, + .remove = hp6xxled_remove, +#ifdef CONFIG_PM + .suspend = hp6xxled_suspend, + .resume = hp6xxled_resume, +#endif + .driver = { + .name = "hp6xx-led", + }, +}; + +static int __init hp6xxled_init(void) +{ + return platform_driver_register(&hp6xxled_driver); +} + +static void __exit hp6xxled_exit(void) +{ + platform_driver_unregister(&hp6xxled_driver); +} + +module_init(hp6xxled_init); +module_exit(hp6xxled_exit); + +MODULE_AUTHOR("Kristoffer Ericson "); +MODULE_DESCRIPTION("HP Jornada 6xx LED driver"); +MODULE_LICENSE("GPL"); --Multipart=_Sun__3_Feb_2008_21_46_15_+0100_OdNDQnrlmuQC2vr+ Content-Type: application/octet-stream; name="hp6xx-leds-support.patch" Content-Disposition: attachment; filename="hp6xx-leds-support.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2RyaXZlcnMvbGVkcy9LY29uZmlnIGIvZHJpdmVycy9sZWRzL0tjb25maWcK aW5kZXggZWM1NjhmYS4uMGIwYmNhMSAxMDA2NDQKLS0tIGEvZHJpdmVycy9sZWRzL0tjb25maWcK KysrIGIvZHJpdmVycy9sZWRzL0tjb25maWcKQEAgLTEwMCw2ICsxMDAsMTQgQEAgY29uZmlnIExF RFNfQ09CQUxUX1JBUQogCWhlbHAKIAkgIFRoaXMgb3B0aW9uIGVuYWJsZXMgc3VwcG9ydCBmb3Ig dGhlIENvYmFsdCBSYXEgc2VyaWVzIExFRHMuCiAKK2NvbmZpZyBMRURTX0hQNlhYCisJYm9vbCAi TEVEIFN1cHBvcnQgZm9yIHRoZSBIUCBKb3JuYWRhIDZ4eCIKKwlkZXBlbmRzIG9uIExFRFNfQ0xB U1MgJiYgU0hfSFA2WFgKKwlzZWxlY3QgTEVEU19UUklHR0VSUworCWhlbHAKKwkgIFRoaXMgb3B0 aW9uIGVuYWJsZXMgbGVkIHN1cHBvcnQgZm9yIHRoZSBoYW5kaGVsZAorCSAgSFAgSm9ybmFkYSA2 MjAvNjYwLzY4MC82OTAuCisKIGNvbmZpZyBMRURTX0dQSU8KIAl0cmlzdGF0ZSAiTEVEIFN1cHBv cnQgZm9yIEdQSU8gY29ubmVjdGVkIExFRHMiCiAJZGVwZW5kcyBvbiBMRURTX0NMQVNTICYmIEdF TkVSSUNfR1BJTwpkaWZmIC0tZ2l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YyB2b2lkIF9fZXhpdCBo cDZ4eGxlZF9leGl0KHZvaWQpCit7CisJcGxhdGZvcm1fZHJpdmVyX3VucmVnaXN0ZXIoJmhwNnh4 bGVkX2RyaXZlcik7Cit9CisKK21vZHVsZV9pbml0KGhwNnh4bGVkX2luaXQpOworbW9kdWxlX2V4 aXQoaHA2eHhsZWRfZXhpdCk7CisKK01PRFVMRV9BVVRIT1IoIktyaXN0b2ZmZXIgRXJpY3NvbiA8 a3Jpc3RvZmZlci5lcmljc29uQGdtYWlsLmNvbT4iKTsKK01PRFVMRV9ERVNDUklQVElPTigiSFAg Sm9ybmFkYSA2eHggTEVEIGRyaXZlciIpOworTU9EVUxFX0xJQ0VOU0UoIkdQTCIpOwo= --Multipart=_Sun__3_Feb_2008_21_46_15_+0100_OdNDQnrlmuQC2vr+-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/