From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932573AbcGDQFi (ORCPT ); Mon, 4 Jul 2016 12:05:38 -0400 Received: from bert.emutex.com ([91.103.1.109]:33773 "EHLO bert.emutex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138AbcGDQF1 (ORCPT ); Mon, 4 Jul 2016 12:05:27 -0400 From: "Dan O'Donovan" To: platform-driver-x86@vger.kernel.org, dvhart@infradead.org Cc: lee.jones@linaro.org, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, linux-kernel@vger.kernel.org, "Dan O'Donovan" Subject: [RESEND RFC PATCH 4/5] platform: x86: add UP Board CPLD LED driver Date: Mon, 4 Jul 2016 17:07:13 +0100 Message-Id: <1467648434-29080-5-git-send-email-dan@emutex.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1467648434-29080-1-git-send-email-dan@emutex.com> References: <1465762392-9205-1-git-send-email-dan@emutex.com> <1467648434-29080-1-git-send-email-dan@emutex.com> X-Spam-Score: -1.0 (-) X-Spam-Report: Spam detection software, running on the system "statler.emutex.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: This pinctrl driver manages the LED Control function provided by the I/O CPLD integrated on the UP Board. This allows basic on/off brightness control for each of the individual LEDs. Signed-off-by: Dan O'Donovan --- drivers/platform/x86/up_board_leds.c | 85 ++++++++++++++++++++++++++++++++++++ drivers/platform/x86/up_board_leds.h | 50 +++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 drivers/platform/x86/up_board_leds.c create mode 100644 drivers/platform/x86/up_board_leds.h [...] Content analysis details: (-1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This pinctrl driver manages the LED Control function provided by the I/O CPLD integrated on the UP Board. This allows basic on/off brightness control for each of the individual LEDs. Signed-off-by: Dan O'Donovan --- drivers/platform/x86/up_board_leds.c | 85 ++++++++++++++++++++++++++++++++++++ drivers/platform/x86/up_board_leds.h | 50 +++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 drivers/platform/x86/up_board_leds.c create mode 100644 drivers/platform/x86/up_board_leds.h diff --git a/drivers/platform/x86/up_board_leds.c b/drivers/platform/x86/up_board_leds.c new file mode 100644 index 0000000..4186475 --- /dev/null +++ b/drivers/platform/x86/up_board_leds.c @@ -0,0 +1,85 @@ +/* + * UP Board CPLD LEDs driver. + * + * Copyright (c) 2016, Emutex Ltd. All rights reserved. + * + * Author: Javier Arteaga + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include +#include +#include + +#include "up_board_leds.h" + +/* Internal context information for this driver */ +struct up_board_led { + struct up_board_leds_pdata *pdata; + unsigned int offset; + const char *name; + struct led_classdev cdev; +}; + +static void up_led_brightness_set(struct led_classdev *cdev, + enum led_brightness value) +{ + struct up_board_led *led = container_of(cdev, + struct up_board_led, + cdev); + struct up_board_cpld_info *cpld_info = &led->pdata->cpld_info; + + cpld_info->reg_set_bit(cpld_info->cpld, led->offset, value != LED_OFF); +} + +static int up_board_leds_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct up_board_leds_pdata *pdata = dev_get_platdata(dev); + struct up_board_led *up_led; + int ret = 0; + size_t i; + + for (i = 0; i < pdata->nled; i++) { + struct up_board_led_info *led_info = &pdata->leds[i]; + + up_led = devm_kzalloc(dev, sizeof(*up_led), GFP_KERNEL); + if (!up_led) + return -ENOMEM; + + up_led->pdata = pdata; + up_led->offset = led_info->cpld_offset; + up_led->cdev.brightness_set = up_led_brightness_set; + up_led->cdev.name = led_info->name; + + ret = devm_led_classdev_register(dev, &up_led->cdev); + if (ret) + return ret; + } + + return 0; +} + +static struct platform_driver up_board_leds_driver = { + .driver.name = "up-board-leds", + .driver.owner = THIS_MODULE, + .probe = up_board_leds_probe, +}; + +module_platform_driver(up_board_leds_driver); + +MODULE_AUTHOR("Javier Arteaga "); +MODULE_DESCRIPTION("UP Board LEDs driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:up-board-leds"); diff --git a/drivers/platform/x86/up_board_leds.h b/drivers/platform/x86/up_board_leds.h new file mode 100644 index 0000000..473b1ad --- /dev/null +++ b/drivers/platform/x86/up_board_leds.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016, Emutex Ltd. All rights reserved. + * + * Author: Dan O'Donovan + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef _UP_BOARD_LED_H_ +#define _UP_BOARD_LED_H_ + +#include "up_board_cpld.h" + +/** + * struct up_board_led_info - information for an UP Board LED + * @name: LED name + * @cpld_offset: CPLD register bit offset for LED control + * + * Information for a single CPLD-controlled LED on the UP Board. + */ +struct up_board_led_info { + const char *name; + unsigned int cpld_offset; +}; + +/** + * struct up_board_leds_pdata - platform driver data + * @cpld_info: CPLD configuration interface information + * @leds: Array of LED information structures + * @nled: Number of entries in leds array + * + * Platform data provided to UP Board CPLD LEDs platform device driver. + * Provides information for each CPLD-controlled LED on the UP Board. + */ +struct up_board_leds_pdata { + struct up_board_cpld_info cpld_info; + struct up_board_led_info *leds; + size_t nled; +}; + +#endif /* _UP_BOARD_LED_H_ */ -- 2.1.4