From: "Dan O'Donovan" <dan@emutex.com>
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" <dan@emutex.com>
Subject: [RESEND RFC PATCH 4/5] platform: x86: add UP Board CPLD LED driver
Date: Mon, 4 Jul 2016 17:07:13 +0100 [thread overview]
Message-ID: <1467648434-29080-5-git-send-email-dan@emutex.com> (raw)
In-Reply-To: <1467648434-29080-1-git-send-email-dan@emutex.com>
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 <dan@emutex.com>
---
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 <javier@emutex.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/leds.h>
+#include <linux/platform_device.h>
+
+#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 <javier@emutex.com>");
+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 <dan@emutex.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+#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
next prev parent reply other threads:[~2016-07-04 16:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1465762392-9205-1-git-send-email-dan@emutex.com>
2016-07-04 16:07 ` [RESEND RFC PATCH 0/5] platform drivers for UP Board Dan O'Donovan
2016-07-04 16:07 ` [RESEND RFC PATCH 1/5] platform: x86: add driver for UP Board I/O CPLD Dan O'Donovan
2016-07-07 13:43 ` Bryan O'Donoghue
2016-07-08 17:05 ` Bryan O'Donoghue
2016-07-22 20:52 ` Darren Hart
2016-07-22 21:11 ` Paul Gortmaker
2016-07-04 16:07 ` [RESEND RFC PATCH 2/5] platform: x86: add UP Board I/O pinctrl driver Dan O'Donovan
2016-07-04 16:07 ` [RESEND RFC PATCH 3/5] platform: x86: add UP Board I/O gpio driver Dan O'Donovan
2016-07-04 16:07 ` Dan O'Donovan [this message]
2016-07-04 16:07 ` [RESEND RFC PATCH 5/5] platform: x86: add platform driver for UP Board Dan O'Donovan
2016-07-07 1:57 ` Bryan O'Donoghue
2016-07-04 16:17 ` [RESEND RFC PATCH 0/5] platform drivers " Andy Shevchenko
2016-09-13 9:42 ` Andy Shevchenko
2016-09-13 9:55 ` Mika Westerberg
2016-09-13 21:51 ` Dan O'Donovan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467648434-29080-5-git-send-email-dan@emutex.com \
--to=dan@emutex.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dvhart@infradead.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®