From patchwork Thu Nov 1 17:58:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Moll X-Patchwork-Id: 1685761 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 C35953FCDF for ; Thu, 1 Nov 2012 18:01:30 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TTz35-0002U3-Ts; Thu, 01 Nov 2012 17:59:23 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TTz31-0002Su-Bi for linux-arm-kernel@lists.infradead.org; Thu, 01 Nov 2012 17:59:21 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 01 Nov 2012 17:59:15 +0000 Received: from hornet.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 1 Nov 2012 17:59:14 +0000 From: Pawel Moll To: Bryan Wu , Richard Purdie Subject: [PATCH 2/2] mfd: vexpress-sysreg: Use MMIO driver for platform LEDs Date: Thu, 1 Nov 2012 17:58:42 +0000 Message-Id: <1351792722-15250-2-git-send-email-pawel.moll@arm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1351792722-15250-1-git-send-email-pawel.moll@arm.com> References: <1351792722-15250-1-git-send-email-pawel.moll@arm.com> X-OriginalArrivalTime: 01 Nov 2012 17:59:14.0577 (UTC) FILETIME=[9AB59010:01CDB85A] X-MC-Unique: 112110117591519201 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121101_135919_772234_1A117F4A X-CRM114-Status: GOOD ( 13.14 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [91.220.42.44 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org, Pawel Moll , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org 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 This patch removes custom code for controlling LEDs on Versatile Express platform and register MFD cell for the SYS_LED register for the leds-mmio-simple driver. Signed-off-by: Pawel Moll --- drivers/mfd/Kconfig | 1 + drivers/mfd/vexpress-sysreg.c | 125 +++++++++++++++-------------------------- 2 files changed, 46 insertions(+), 80 deletions(-) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 637bcdf..611d989 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1073,6 +1073,7 @@ endmenu config VEXPRESS_CONFIG bool + select MFD_CORE help Platform configuration infrastructure for the ARM Ltd. Versatile Express. diff --git a/drivers/mfd/vexpress-sysreg.c b/drivers/mfd/vexpress-sysreg.c index 059d6b1..2241b98 100644 --- a/drivers/mfd/vexpress-sysreg.c +++ b/drivers/mfd/vexpress-sysreg.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -406,6 +407,35 @@ static struct gpio_chip vexpress_sysreg_gpio_chip = { }; +static struct mfd_cell vexpress_sysreg_leds = { + .name = "leds-mmio-simple", + .platform_data = &(struct mmio_simple_leds_platform_data) { + .reg_size = 32, + .shift = 0, + .width = 8, + .names = (const char *[]) { + "v2m:green:user1", "v2m:green:user2", + "v2m:green:user3", "v2m:green:user4", + "v2m:green:user5", "v2m:green:user6", + "v2m:green:user7", "v2m:green:user8", + }, + .default_triggers = (const char *[]) { + "heartbeat", "mmc0", + "cpu0", "cpu1", + "cpu2", "cpu3", + "cpu4", "cpu5", + }, + .init_off = true, + }, + .pdata_size = sizeof(struct mmio_simple_leds_platform_data), + .num_resources = 1, + .resources = (struct resource []) { + DEFINE_RES_MEM(SYS_LED, 4), + }, + .ignore_resource_conflicts = true, +}; + + static ssize_t vexpress_sysreg_sys_id_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -438,14 +468,19 @@ static int __devinit vexpress_sysreg_probe(struct platform_device *pdev) setup_timer(&vexpress_sysreg_config_timer, vexpress_sysreg_config_complete, 0); + err = mfd_add_devices(&pdev->dev, 0, &vexpress_sysreg_leds, 1, + res, 0, NULL); + if (err) { + dev_err(&pdev->dev, "Failed to add LED device! (%d)\n", err); + goto error_mfd_add_devices; + } + vexpress_sysreg_gpio_chip.dev = &pdev->dev; err = gpiochip_add(&vexpress_sysreg_gpio_chip); if (err) { - vexpress_config_bridge_unregister( - vexpress_sysreg_config_bridge); dev_err(&pdev->dev, "Failed to register GPIO chip! (%d)\n", err); - return err; + goto error_gpiochip_add; } vexpress_sysreg_dev = &pdev->dev; @@ -453,6 +488,13 @@ static int __devinit vexpress_sysreg_probe(struct platform_device *pdev) device_create_file(vexpress_sysreg_dev, &dev_attr_sys_id); return 0; + +error_gpiochip_add: + mfd_remove_devices(&pdev->dev); +error_mfd_add_devices: + vexpress_config_bridge_unregister(vexpress_sysreg_config_bridge); + return err; + } static const struct of_device_id vexpress_sysreg_match[] = { @@ -473,80 +515,3 @@ static int __init vexpress_sysreg_init(void) return platform_driver_register(&vexpress_sysreg_driver); } core_initcall(vexpress_sysreg_init); - - -#if defined(CONFIG_LEDS_CLASS) - -struct vexpress_sysreg_led { - u32 mask; - struct led_classdev cdev; -} vexpress_sysreg_leds[] = { - { .mask = 1 << 0, .cdev.name = "v2m:green:user1", - .cdev.default_trigger = "heartbeat", }, - { .mask = 1 << 1, .cdev.name = "v2m:green:user2", - .cdev.default_trigger = "mmc0", }, - { .mask = 1 << 2, .cdev.name = "v2m:green:user3", - .cdev.default_trigger = "cpu0", }, - { .mask = 1 << 3, .cdev.name = "v2m:green:user4", - .cdev.default_trigger = "cpu1", }, - { .mask = 1 << 4, .cdev.name = "v2m:green:user5", - .cdev.default_trigger = "cpu2", }, - { .mask = 1 << 5, .cdev.name = "v2m:green:user6", - .cdev.default_trigger = "cpu3", }, - { .mask = 1 << 6, .cdev.name = "v2m:green:user7", - .cdev.default_trigger = "cpu4", }, - { .mask = 1 << 7, .cdev.name = "v2m:green:user8", - .cdev.default_trigger = "cpu5", }, -}; - -static DEFINE_SPINLOCK(vexpress_sysreg_leds_lock); - -static void vexpress_sysreg_led_brightness_set(struct led_classdev *cdev, - enum led_brightness brightness) -{ - struct vexpress_sysreg_led *led = container_of(cdev, - struct vexpress_sysreg_led, cdev); - unsigned long flags; - u32 val; - - spin_lock_irqsave(&vexpress_sysreg_leds_lock, flags); - - val = readl(vexpress_sysreg_base + SYS_LED); - if (brightness == LED_OFF) - val &= ~led->mask; - else - val |= led->mask; - writel(val, vexpress_sysreg_base + SYS_LED); - - spin_unlock_irqrestore(&vexpress_sysreg_leds_lock, flags); -} - -static int __init vexpress_sysreg_init_leds(void) -{ - struct vexpress_sysreg_led *led; - int i; - - /* Clear all user LEDs */ - writel(0, vexpress_sysreg_base + SYS_LED); - - for (i = 0, led = vexpress_sysreg_leds; - i < ARRAY_SIZE(vexpress_sysreg_leds); i++, led++) { - int err; - - led->cdev.brightness_set = vexpress_sysreg_led_brightness_set; - err = led_classdev_register(vexpress_sysreg_dev, &led->cdev); - if (err) { - dev_err(vexpress_sysreg_dev, - "Failed to register LED %d! (%d)\n", - i, err); - while (led--, i--) - led_classdev_unregister(&led->cdev); - return err; - } - } - - return 0; -} -device_initcall(vexpress_sysreg_init_leds); - -#endif