From patchwork Thu Nov 1 09:26:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 1683671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 029913FCDF for ; Thu, 1 Nov 2012 09:34:02 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TTr7X-0006EB-Me; Thu, 01 Nov 2012 09:31:27 +0000 Received: from smtp1.mail.ru ([94.100.176.129]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TTr3a-0005E8-Pd for linux-arm-kernel@lists.infradead.org; Thu, 01 Nov 2012 09:27:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=3uhI7Div5DDgJr1GLzxKThXnJ88NGr8fERxlPuuTcDE=; b=eEvks/VVr/lRGurbiTJv1Zx9pxUeM/Zo8BiY/OcskeNh561BvI70t/RijptLbIsF5UY5XQW29AyX5v4tbgVmu+BHaLZWPaYPM9DttWojTMifHjS2Gt1050uX7ISl0cL+; Received: from [188.134.40.128] (port=33548 helo=shc.zet) by smtp1.mail.ru with esmtpa (envelope-from ) id 1TTr3Z-0001ZR-CV; Thu, 01 Nov 2012 13:27:21 +0400 From: Alexander Shiyan To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 03/15] ARM: clps711x: p720t: Using "leds-gpio" driver for LED control Date: Thu, 1 Nov 2012 13:26:33 +0400 Message-Id: <1351762006-27368-3-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1351762006-27368-1-git-send-email-shc_work@mail.ru> References: <1351762006-27368-1-git-send-email-shc_work@mail.ru> X-Spam: Not detected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121101_052723_189212_75758D1F X-CRM114-Status: GOOD ( 14.42 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [94.100.176.129 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shc_work[at]mail.ru) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Olof Johansson , Russell King , Alexander Shiyan , Arnd Bergmann X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 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 Instead of manually create LED class device, we will use "leds-gpio" driver for LED control. Signed-off-by: Alexander Shiyan --- arch/arm/mach-clps711x/common.h | 3 + arch/arm/mach-clps711x/p720t.c | 79 ++++++++++++-------------------------- 2 files changed, 28 insertions(+), 54 deletions(-) diff --git a/arch/arm/mach-clps711x/common.h b/arch/arm/mach-clps711x/common.h index fc0f065..83cfece 100644 --- a/arch/arm/mach-clps711x/common.h +++ b/arch/arm/mach-clps711x/common.h @@ -4,6 +4,9 @@ * Common bits. */ +#define CLPS711X_NR_GPIO (4 * 8 + 3) +#define CLPS711X_GPIO(port,bit) ((port) * 8 + (bit)) + struct sys_timer; extern void clps711x_map_io(void); diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c index 96d54d4..7a96312 100644 --- a/arch/arm/mach-clps711x/p720t.c +++ b/arch/arm/mach-clps711x/p720t.c @@ -39,6 +39,8 @@ #include "common.h" +#define GPIO_USERLED CLPS711X_GPIO(3, 0) + /* * Map the P720T system PLD. It occupies two address spaces: * 0x10000000 and 0x10400000. We map both regions as one. @@ -104,67 +106,35 @@ static void __init p720t_init_early(void) } } -/* - * LED controled by CPLD - */ -#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) -static void p720t_led_set(struct led_classdev *cdev, - enum led_brightness b) -{ - u8 reg = clps_readb(PDDR); - - if (b != LED_OFF) - reg |= 0x1; - else - reg &= ~0x1; - - clps_writeb(reg, PDDR); -} +static struct gpio_led p720t_gpio_leds[] = { + { + .name = "User LED", + .default_trigger = "heartbeat", + .gpio = GPIO_USERLED, + }, +}; -static enum led_brightness p720t_led_get(struct led_classdev *cdev) -{ - u8 reg = clps_readb(PDDR); +static struct gpio_led_platform_data p720t_gpio_led_pdata = { + .leds = p720t_gpio_leds, + .num_leds = ARRAY_SIZE(p720t_gpio_leds), +}; - return (reg & 0x1) ? LED_FULL : LED_OFF; -} +static struct platform_device p720t_gpio_led_pdev = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &p720t_gpio_led_pdata, + }, +}; -static int __init p720t_leds_init(void) +static void __init p720t_init(void) { - - struct led_classdev *cdev; - int ret; - - if (!machine_is_p720t()) - return -ENODEV; - - cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); - if (!cdev) - return -ENOMEM; - - cdev->name = "p720t:0"; - cdev->brightness_set = p720t_led_set; - cdev->brightness_get = p720t_led_get; - cdev->default_trigger = "heartbeat"; - - ret = led_classdev_register(NULL, cdev); - if (ret < 0) { - kfree(cdev); - return ret; - } - - return 0; + platform_device_register_simple("uart-clps711x", 0, NULL, 0); } -/* - * Since we may have triggers on any subsystem, defer registration - * until after subsystem_init. - */ -fs_initcall(p720t_leds_init); -#endif - -static void __init p720t_init(void) +static void __init p720t_init_late(void) { - platform_device_register_simple("uart-clps711x", 0, NULL, 0); + platform_device_register(&p720t_gpio_led_pdev); } MACHINE_START(P720T, "ARM-Prospector720T") @@ -174,6 +144,7 @@ MACHINE_START(P720T, "ARM-Prospector720T") .map_io = p720t_map_io, .init_early = p720t_init_early, .init_machine = p720t_init, + .init_late = p720t_init_late, .init_irq = clps711x_init_irq, .restart = clps711x_restart, .timer = &clps711x_timer,