From patchwork Wed Jul 6 12:34:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Wu X-Patchwork-Id: 949592 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p66CcPZa027977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 6 Jul 2011 12:38:46 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QeRMy-0006ew-1O; Wed, 06 Jul 2011 12:38:20 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QeRMx-0002ie-Kc; Wed, 06 Jul 2011 12:38:19 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QeRMu-0002iP-5O for linux-arm-kernel@canuck.infradead.org; Wed, 06 Jul 2011 12:38:16 +0000 Received: from adelie.canonical.com ([91.189.90.139]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QeRMp-00013Z-BB for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2011 12:38:14 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QeRMp-00050P-6N; Wed, 06 Jul 2011 12:38:11 +0000 Received: from [116.227.244.46] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1QeRMf-0007Z7-I7; Wed, 06 Jul 2011 12:38:11 +0000 From: Bryan Wu To: linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, rpurdie@rpsys.net, linux@arm.linux.org.uk, nicolas.pitre@linaro.org, arnd@arndb.de, eric.y.miao@gmail.com, tony@atomide.com Subject: [PATCH 06/17] mach-shark: retire custom LED code Date: Wed, 6 Jul 2011 20:34:36 +0800 Message-Id: <1309955687-19365-7-git-send-email-bryan.wu@canonical.com> X-Mailer: git-send-email 1.7.5 In-Reply-To: <1309955687-19365-1-git-send-email-bryan.wu@canonical.com> References: <1309955687-19365-1-git-send-email-bryan.wu@canonical.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110706_133811_477941_44AF57A2 X-CRM114-Status: GOOD ( 22.46 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2-r929478 on casper.infradead.org summary: Content analysis details: (-4.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [91.189.90.139 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org 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: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 06 Jul 2011 12:38:46 +0000 (UTC) The CPU activity LED is now handled by the trigger in the leds subsystem, retire this old CONFIG_LEDS-based code. Signed-off-by: Bryan Wu --- arch/arm/Kconfig | 6 + arch/arm/mach-shark/Makefile | 4 +- arch/arm/mach-shark/core.c | 1 - arch/arm/mach-shark/leds.c | 222 ++++++++++++++++-------------------------- 4 files changed, 90 insertions(+), 143 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9adc278..df971c7 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -783,6 +783,12 @@ config ARCH_SHARK select ZONE_DMA select PCI select ARCH_USES_GETTIMEOFFSET + select NEW_LEDS + select LEDS_CLASS + select LEDS_TRIGGERS + select LEDS_TRIGGER_CPU + select LEDS_TRIGGER_HEARTBEAT + select LEDS_TRIGGER_DEFAULT_ON help Support for the StrongARM based Digital DNARD machine, also known as "Shark" (). diff --git a/arch/arm/mach-shark/Makefile b/arch/arm/mach-shark/Makefile index 45be9b0..2965718 100644 --- a/arch/arm/mach-shark/Makefile +++ b/arch/arm/mach-shark/Makefile @@ -4,9 +4,7 @@ # Object file lists. -obj-y := core.o dma.o irq.o pci.o +obj-y := core.o dma.o irq.o pci.o leds.o obj-m := obj-n := obj- := - -obj-$(CONFIG_LEDS) += leds.o diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c index 5cf7f94..f4b6288 100644 --- a/arch/arm/mach-shark/core.c +++ b/arch/arm/mach-shark/core.c @@ -13,7 +13,6 @@ #include #include -#include #include #include diff --git a/arch/arm/mach-shark/leds.c b/arch/arm/mach-shark/leds.c index c9e32de..77cf16b 100644 --- a/arch/arm/mach-shark/leds.c +++ b/arch/arm/mach-shark/leds.c @@ -1,166 +1,110 @@ /* - * arch/arm/mach-shark/leds.c - * by Alexander Schulz - * - * derived from: - * arch/arm/kernel/leds-footbridge.c - * Copyright (C) 1998-1999 Russell King - * * DIGITAL Shark LED control routines. * - * The leds use is as follows: - * - Green front - toggles state every 50 timer interrupts - * - Amber front - Unused, this is a dual color led (Amber/Green) - * - Amber back - On if system is not idle + * Driver for the 3 user LEDs found on the Shark + * Based on Versatile and RealView machine LED code * - * Changelog: + * License terms: GNU General Public License (GPL) version 2 + * Author: Bryan Wu */ #include -#include #include -#include -#include #include +#include +#include +#include -#include -#include +struct shark_led { + struct led_classdev cdev; + u8 mask; +}; -#define LED_STATE_ENABLED 1 -#define LED_STATE_CLAIMED 2 +/* + * The triggers lines up below will only be used if the + * LED triggers are compiled in. + */ +static const struct { + const char *name; + const char *trigger; +} shark_leds[] = { + { "shark:amber0", "default-on", }, /* Bit 5 */ + { "shark:green", "heartbeat", }, /* Bit 6 */ + { "shark:amber1", "cpu" }, /* Bit 7 */ +}; + +static u16 led_reg_read(void) +{ + outw(0x09, 0x24); + return inw(0x26); +} -#define SEQUOIA_LED_GREEN (1<<6) -#define SEQUOIA_LED_AMBER (1<<5) -#define SEQUOIA_LED_BACK (1<<7) +static void led_reg_write(u16 value) +{ + outw(0x09, 0x24); + outw(value, 0x26); +} -static char led_state; -static short hw_led_state; -static short saved_state; +static void shark_led_set(struct led_classdev *cdev, + enum led_brightness b) +{ + struct shark_led *led = container_of(cdev, + struct shark_led, cdev); + u16 reg = led_reg_read(); -static DEFINE_SPINLOCK(leds_lock); + if (b != LED_OFF) + reg |= led->mask; + else + reg &= ~led->mask; -short sequoia_read(int addr) { - outw(addr,0x24); - return inw(0x26); + led_reg_write(reg); } -void sequoia_write(short value,short addr) { - outw(addr,0x24); - outw(value,0x26); +static enum led_brightness shark_led_get(struct led_classdev *cdev) +{ + struct shark_led *led = container_of(cdev, + struct shark_led, cdev); + u16 reg = led_reg_read(); + + return (reg & led->mask) ? LED_FULL : LED_OFF; } -static void sequoia_leds_event(led_event_t evt) +static int __init shark_leds_init(void) { - unsigned long flags; - - spin_lock_irqsave(&leds_lock, flags); - - hw_led_state = sequoia_read(0x09); - - switch (evt) { - case led_start: - hw_led_state |= SEQUOIA_LED_GREEN; - hw_led_state |= SEQUOIA_LED_AMBER; -#ifdef CONFIG_LEDS_CPU - hw_led_state |= SEQUOIA_LED_BACK; -#else - hw_led_state &= ~SEQUOIA_LED_BACK; -#endif - led_state |= LED_STATE_ENABLED; - break; - - case led_stop: - hw_led_state &= ~SEQUOIA_LED_BACK; - hw_led_state |= SEQUOIA_LED_GREEN; - hw_led_state |= SEQUOIA_LED_AMBER; - led_state &= ~LED_STATE_ENABLED; - break; - - case led_claim: - led_state |= LED_STATE_CLAIMED; - saved_state = hw_led_state; - hw_led_state &= ~SEQUOIA_LED_BACK; - hw_led_state |= SEQUOIA_LED_GREEN; - hw_led_state |= SEQUOIA_LED_AMBER; - break; - - case led_release: - led_state &= ~LED_STATE_CLAIMED; - hw_led_state = saved_state; - break; - -#ifdef CONFIG_LEDS_TIMER - case led_timer: - if (!(led_state & LED_STATE_CLAIMED)) - hw_led_state ^= SEQUOIA_LED_GREEN; - break; -#endif - -#ifdef CONFIG_LEDS_CPU - case led_idle_start: - if (!(led_state & LED_STATE_CLAIMED)) - hw_led_state &= ~SEQUOIA_LED_BACK; - break; - - case led_idle_end: - if (!(led_state & LED_STATE_CLAIMED)) - hw_led_state |= SEQUOIA_LED_BACK; - break; -#endif - - case led_green_on: - if (led_state & LED_STATE_CLAIMED) - hw_led_state &= ~SEQUOIA_LED_GREEN; - break; - - case led_green_off: - if (led_state & LED_STATE_CLAIMED) - hw_led_state |= SEQUOIA_LED_GREEN; - break; - - case led_amber_on: - if (led_state & LED_STATE_CLAIMED) - hw_led_state &= ~SEQUOIA_LED_AMBER; - break; - - case led_amber_off: - if (led_state & LED_STATE_CLAIMED) - hw_led_state |= SEQUOIA_LED_AMBER; - break; - - case led_red_on: - if (led_state & LED_STATE_CLAIMED) - hw_led_state |= SEQUOIA_LED_BACK; - break; - - case led_red_off: - if (led_state & LED_STATE_CLAIMED) - hw_led_state &= ~SEQUOIA_LED_BACK; - break; - - default: - break; - } + int i; + u16 reg; - if (led_state & LED_STATE_ENABLED) - sequoia_write(hw_led_state,0x09); + for (i = 0; i < ARRAY_SIZE(shark_leds); i++) { + struct shark_led *led; - spin_unlock_irqrestore(&leds_lock, flags); -} + led = kzalloc(sizeof(*led), GFP_KERNEL); + if (!led) + break; -static int __init leds_init(void) -{ - extern void (*leds_event)(led_event_t); - short temp; - - leds_event = sequoia_leds_event; + led->cdev.name = shark_leds[i].name; + led->cdev.brightness_set = shark_led_set; + led->cdev.brightness_get = shark_led_get; + led->cdev.default_trigger = shark_leds[i].trigger; + + /* Count in 5 bits offset */ + led->mask = BIT(i + 5); + + if (led_classdev_register(NULL, &led->cdev) < 0) { + kfree(led); + break; + } + } /* Make LEDs independent of power-state */ - request_region(0x24,4,"sequoia"); - temp = sequoia_read(0x09); - temp |= 1<<10; - sequoia_write(temp,0x09); - leds_event(led_start); + request_region(0x24, 4, "led_reg"); + reg = led_reg_read(); + reg |= 1 << 10; + led_reg_write(reg); + return 0; } -__initcall(leds_init); +/* + * Since we may have triggers on any subsystem, defer registration + * until after subsystem_init. + */ +fs_initcall(shark_leds_init);