From patchwork Thu Dec 13 05:29:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 1012573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aoguHyB+"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="plB6otkn"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43Fj2v5kR7z9s9h for ; Thu, 13 Dec 2018 16:31:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XqVxBQ8MqnoR9QP01WAPHx76G5sZHH/bIclpq7+IARo=; b=aoguHyB+954m8I Ki2dnHY/+vuZ91nQQguONtcpzEWnKjhBHfXIuMHef+yUaMBkiro1/M/vhb/r6bFovcaKrk1SbLa+Q q6NKCFYJMW194xVdV7vYPnaLSQdXBPuvWx2tnTYzKK2ny1apvg1791+F9TJtpIAmuzThW0IBsbal7 XdPDsk8wfsa2ZvMqF9DejGv64gl3teFnMnNpGAVQHGosvTTRYrcm9XweeOWJu652Jaqcx+CjMjjWP gl2kWP3HfmPWfyQUTU/3VJNyYRdyPOI2iVVTnD7VBGpKa2vdxKP/PfZigFnkkevzTcoTnv/bOGG4j wYfRaP6a2bxB/nHPHE9Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJab-0001Bs-PX; Thu, 13 Dec 2018 05:31:13 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJZo-0000Bp-0D for openwrt-devel@lists.openwrt.org; Thu, 13 Dec 2018 05:30:29 +0000 Received: by mail-ed1-x543.google.com with SMTP id h50so974312ede.5 for ; Wed, 12 Dec 2018 21:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MVOBEHavr/H7Z+ziL6S++LNjP2hzuDLEC0h7X3L9Wn8=; b=plB6otkny7cruNlMlWcNq1EbqeeY59LlBcLoyTATffOVrZ7y1akhxXOxjD/OPUTP3b JxeY7YKGJ4CpoXpOQKGMpspOEclDqXZH3KoEgN3jslIThsvMtlM7Pm9e6eUdStBiNtg+ Dk1E/3Fey2h/LPYueH0xRzGVMxc0TAYhCqVHz1gtQ7htUOs1JJhXeeXub27475+Xf8g6 q5VEuyVM7sXlj1ysXcTRaOhWip9Io0Gre2V6iCJW2vIzaBosgxVefsMHdSBCJXloouJx WeI0PchcVqYzDSD2JQx5UXHz4LBgusxwD9O65zrAXMU6K6iCdwSC6b7kohC7ePLoTSCl lzGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MVOBEHavr/H7Z+ziL6S++LNjP2hzuDLEC0h7X3L9Wn8=; b=Bvvy+Rc1HgG0C89sbepr9RVBlBvFdCX8OG6D3rfgFzmxKruyP1NtlFnO6aRE76PDXx TSsy3ocBgnNn8HLLwXj8o9c1wNkbNextVcyrnO9oKUo1O/jW+xgMmTNa+XcdOATZjtei vawWgBPqkbsSE3Se0B3IPzE12k2cSA2Nmcpr2+YSE0bQ47KV1yXA28Gh2TzqrpJ7772l 3CAbQMVkafkN2/KFy3QArdpMBMtPac+ASouQrGMv7PzJopy6CYDxsrhvOc8uZWI/xIt1 Etf5C5JrMjiQ2kw2HUESrDojwbAiGClUXrpCtmDQrK7uhjewWoVKMgyKvxnVKmRVodb6 2Ong== X-Gm-Message-State: AA+aEWYozA//N/FZZnCtkaBe5MKnsUf6MrpY3pnHrIrzZhzXF3vAYlhx ueJaxosEawuQL0F+wA/ryJXKnKsv X-Google-Smtp-Source: AFSGD/UaeKaRNP3MjJTvrE7poD5jdk8S4S+qwtSdUnoYjmFCwejDwaiEqyTtlpGV3jyw/Z3mQ7YYUQ== X-Received: by 2002:a50:c017:: with SMTP id r23mr22006046edb.278.1544679011175; Wed, 12 Dec 2018 21:30:11 -0800 (PST) Received: from mars.lan ([2a02:168:6806:0:e862:1a6:be96:624b]) by smtp.gmail.com with ESMTPSA id s12sm331526edb.43.2018.12.12.21.30.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 21:30:10 -0800 (PST) From: Klaus Kudielka To: openwrt-devel@lists.openwrt.org Date: Thu, 13 Dec 2018 06:29:49 +0100 Message-Id: <20181213052952.3744-2-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213052952.3744-1-klaus.kudielka@gmail.com> References: <20181213052952.3744-1-klaus.kudielka@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181212_213024_045029_30F8BFDB X-CRM114-Status: GOOD ( 16.74 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:543 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (klaus.kudielka[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 T_MIXED_ES Too many es are not es Subject: [OpenWrt-Devel] [PATCH 1/4] mvebu: add Turris Omnia LED support X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Kudielka MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The kernel driver is directly pulled from TurrisOS. https://gitlab.labs.nic.cz/turris/turris-build/commit/60f75b6b I have added the associated extension of the device tree. Signed-off-by: Klaus Kudielka --- .../mvebu/patches-4.14/490-omnia-leds.patch | 568 ++++++++++++++++++ 1 file changed, 568 insertions(+) create mode 100644 target/linux/mvebu/patches-4.14/490-omnia-leds.patch diff --git a/target/linux/mvebu/patches-4.14/490-omnia-leds.patch b/target/linux/mvebu/patches-4.14/490-omnia-leds.patch new file mode 100644 index 0000000000..e819eb247f --- /dev/null +++ b/target/linux/mvebu/patches-4.14/490-omnia-leds.patch @@ -0,0 +1,568 @@ +--- a/drivers/leds/Kconfig ++++ b/drivers/leds/Kconfig +@@ -632,6 +632,13 @@ config LEDS_IS31FL32XX + + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" + ++config LEDS_OMNIA ++ tristate "LED support for the Turris Omnia board" ++ depends on LEDS_CLASS ++ help ++ Say Y here to include support for the LED driver on Turris Omnia ++ board. ++ + config LEDS_BLINKM + tristate "LED support for the BlinkM I2C RGB LED" + depends on LEDS_CLASS +--- a/drivers/leds/Makefile ++++ b/drivers/leds/Makefile +@@ -73,6 +73,7 @@ obj-$(CONFIG_LEDS_PM8058) += leds-pm805 + obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o + obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o + obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o ++obj-$(CONFIG_LEDS_OMNIA) += leds-omnia.o + + # LED SPI Drivers + obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o +--- /dev/null ++++ b/drivers/leds/leds-omnia.c +@@ -0,0 +1,457 @@ ++/* ++ * Copyright 2016 CZ.NIC, z.s.p.o. ++ * ++ * Author: Tomas Hlavacek ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MAX_LEDS 13 ++#define ALL_LEDS_INDEX 12 ++ ++#define LED_AUTONOMOUS_ADDR 3 ++#define LED_ONOFF_ADDR 4 ++#define LED_COLOR_ADDR 5 ++#define GLOB_BRIGHTNESS_READ 8 ++#define GLOB_BRIGHTNESS_WRITE 7 ++ ++ ++ ++struct omnia_platform_data { ++ struct led_platform_data leds; ++}; ++ ++static const struct i2c_device_id omnia_id[] = { ++ { "omnia", 0 }, ++ { } ++}; ++MODULE_DEVICE_TABLE(i2c, omnia_id); ++ ++struct omnia_led_mcu { ++ struct mutex mutex; ++ struct i2c_client *client; ++ struct omnia_led *leds; ++}; ++ ++struct omnia_led { ++ struct omnia_led_mcu *chip; ++ struct led_classdev led_cdev; ++ int led_num; /* 0 .. 11 + 12=ALL */ ++ char name[32]; ++ u8 autonomous; ++ u8 r; ++ u8 g; ++ u8 b; ++ struct work_struct work; ++ enum led_brightness new_brightness; ++}; ++ ++static int omnia_led_brightness_set(struct omnia_led *led, ++ enum led_brightness brightness) ++{ ++ int ret; ++ ++ mutex_lock(&led->chip->mutex); ++ ++ ret = i2c_smbus_write_byte_data(led->chip->client, LED_ONOFF_ADDR, ++ (led->led_num | ((brightness != LED_OFF)<<4))); ++ ++ mutex_unlock(&led->chip->mutex); ++ return ret; ++} ++ ++static int omnia_led_autonomous_set(struct omnia_led *led, int autonomous) ++{ ++ int ret, i; ++ ++ mutex_lock(&led->chip->mutex); ++ ++ if (led->autonomous == (autonomous != 0)) { ++ mutex_unlock(&led->chip->mutex); ++ return 0; ++ } ++ ++ led->autonomous = (autonomous != 0); ++ ++ if (led->led_num == ALL_LEDS_INDEX) { ++ for (i=0; i<(MAX_LEDS-1); i++) ++ led->chip->leds[i].autonomous = led->autonomous; ++ } ++ ++ ret = i2c_smbus_write_byte_data(led->chip->client, LED_AUTONOMOUS_ADDR, ++ (u8)(led->led_num | ((!led->autonomous) << 4))); ++ ++ mutex_unlock(&led->chip->mutex); ++ return ret; ++} ++ ++static int omnia_glob_brightness_set(struct omnia_led_mcu *chip, ++ int glob_brightness) ++{ ++ int ret; ++ ++ mutex_lock(&chip->mutex); ++ ++ ret = i2c_smbus_write_byte_data(chip->client, GLOB_BRIGHTNESS_WRITE, ++ (u8)glob_brightness); ++ ++ mutex_unlock(&chip->mutex); ++ return ret; ++} ++ ++static int omnia_glob_brightness_get(struct omnia_led_mcu *chip) ++{ ++ int ret; ++ ++ mutex_lock(&chip->mutex); ++ ++ ret = i2c_smbus_read_byte_data(chip->client, GLOB_BRIGHTNESS_READ); ++ ++ mutex_unlock(&chip->mutex); ++ return ret; ++} ++ ++static int omnia_led_color_set(struct omnia_led *led, u8 r, u8 g, u8 b) ++{ ++ int ret, i; ++ u8 buf[5]; ++ ++ buf[0] = LED_COLOR_ADDR; ++ buf[1] = led->led_num; ++ buf[2] = r; ++ buf[3] = g; ++ buf[4] = b; ++ ++ mutex_lock(&led->chip->mutex); ++ ++ ret = i2c_master_send(led->chip->client, buf, 5); ++ ++ if (led->led_num == ALL_LEDS_INDEX) { ++ for (i=0; i<(MAX_LEDS-1); i++) { ++ led->chip->leds[i].r = led->r; ++ led->chip->leds[i].g = led->g; ++ led->chip->leds[i].b = led->b; ++ } ++ } ++ ++ mutex_unlock(&led->chip->mutex); ++ return -(ret<=0); ++} ++ ++static void omnia_led_set_async(struct led_classdev *led_cdev, ++ enum led_brightness value) ++{ ++ struct omnia_led *led = ++ container_of(led_cdev, struct omnia_led, led_cdev); ++ ++ led->new_brightness = value; ++ ++ schedule_work(&led->work); ++} ++ ++static void omnia_led_work(struct work_struct *work) ++{ ++ struct omnia_led *led; ++ led = container_of(work, struct omnia_led, work); ++ ++ omnia_led_brightness_set(led, led->new_brightness); ++} ++ ++static struct omnia_platform_data * ++omnia_dt_init(struct i2c_client *client) ++{ ++ struct device_node *np = client->dev.of_node, *child; ++ struct omnia_platform_data *pdata; ++ struct led_info *leds; ++ int count; ++ ++ count = of_get_child_count(np); ++ if (!count || count > MAX_LEDS) ++ return ERR_PTR(-ENODEV); ++ ++ leds = devm_kzalloc(&client->dev, ++ sizeof(struct led_info) * MAX_LEDS, GFP_KERNEL); ++ if (!leds) ++ return ERR_PTR(-ENOMEM); ++ ++ for_each_child_of_node(np, child) { ++ u32 reg; ++ int res; ++ ++ res = of_property_read_u32(child, "reg", ®); ++ if ((res != 0) || (reg >= MAX_LEDS)) ++ continue; ++ leds[reg].name = ++ of_get_property(child, "label", NULL) ? : child->name; ++ leds[reg].default_trigger = ++ of_get_property(child, "linux,default-trigger", NULL); ++ } ++ pdata = devm_kzalloc(&client->dev, ++ sizeof(struct omnia_platform_data), GFP_KERNEL); ++ if (!pdata) ++ return ERR_PTR(-ENOMEM); ++ ++ pdata->leds.leds = leds; ++ pdata->leds.num_leds = MAX_LEDS; ++ ++ return pdata; ++} ++ ++static ssize_t global_brightness_show(struct device *d, ++ struct device_attribute *attr, char *buf) ++{ ++ struct i2c_client *client = to_i2c_client(d); ++ struct omnia_led_mcu *chip = i2c_get_clientdata(client); ++ ++ return scnprintf(buf, PAGE_SIZE, "%d\n", ++ omnia_glob_brightness_get(chip)); ++} ++ ++static ssize_t global_brightness_store(struct device *d, ++ struct device_attribute *attr, const char *buf, size_t count) ++{ ++ struct i2c_client *client = to_i2c_client(d); ++ struct omnia_led_mcu *chip = i2c_get_clientdata(client); ++ int ret; ++ int global_brightness; ++ ++ if ((sscanf(buf, "%i", &global_brightness)) != 1) ++ return -EINVAL; ++ ++ ret = omnia_glob_brightness_set(chip, global_brightness); ++ if (ret < 0) ++ return ret; ++ ++ return count; ++} ++static DEVICE_ATTR_RW(global_brightness); ++ ++static ssize_t autonomous_show(struct device *d, ++ struct device_attribute *attr, char *buf) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(d); ++ struct omnia_led *led = ++ container_of(led_cdev, struct omnia_led, led_cdev); ++ ++ return scnprintf(buf, PAGE_SIZE, "%d\n", led->autonomous); ++} ++ ++static ssize_t autonomous_store(struct device *d, ++ struct device_attribute *attr, const char *buf, size_t count) ++{ ++ int ret, autonomous; ++ struct led_classdev *led_cdev = dev_get_drvdata(d); ++ struct omnia_led *led = ++ container_of(led_cdev, struct omnia_led, led_cdev); ++ ++ if ((sscanf(buf, "%i", &autonomous)) != 1) ++ return -EINVAL; ++ ++ ret = omnia_led_autonomous_set(led, autonomous); ++ if (ret < 0) ++ return ret; ++ ++ led->autonomous = autonomous; ++ return count; ++} ++static DEVICE_ATTR_RW(autonomous); ++ ++static ssize_t color_show(struct device *d, ++ struct device_attribute *attr, char *buf) ++{ ++ struct led_classdev *led_cdev = dev_get_drvdata(d); ++ struct omnia_led *led = ++ container_of(led_cdev, struct omnia_led, led_cdev); ++ ++ return scnprintf(buf, PAGE_SIZE, "%d %d %d\n", led->r, led->g, led->b); ++} ++ ++static ssize_t color_store(struct device *d, ++ struct device_attribute *attr, const char *buf, size_t count) ++{ ++ int ret, r, g, b; ++ struct led_classdev *led_cdev = dev_get_drvdata(d); ++ struct omnia_led *led = ++ container_of(led_cdev, struct omnia_led, led_cdev); ++ ++ if ((sscanf(buf, "%i %i %i", &r, &g, &b)) != 3) ++ return -EINVAL; ++ ++ ret = omnia_led_color_set(led, r, g, b); ++ if (ret < 0) ++ return ret; ++ ++ led->r = r; ++ led->g = g; ++ led->b = b; ++ return count; ++} ++static DEVICE_ATTR_RW(color); ++ ++ ++static const struct of_device_id of_omnia_match[] = { ++ { .compatible = "turris-leds,omnia", }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, of_omnia_match); ++ ++static int omnia_probe(struct i2c_client *client, ++ const struct i2c_device_id *id) ++{ ++ struct omnia_led_mcu *chip; ++ struct omnia_led *leds; ++ struct omnia_platform_data *pdata; ++ int i, err; ++ ++ pdata = dev_get_platdata(&client->dev); ++ ++ if (!pdata) { ++ pdata = omnia_dt_init(client); ++ if (IS_ERR(pdata)) { ++ dev_warn(&client->dev, "could not parse configuration\n"); ++ pdata = NULL; ++ } ++ } ++ ++ chip = devm_kzalloc(&client->dev, sizeof(*chip), ++ GFP_KERNEL); ++ if (!chip) ++ return -ENOMEM; ++ leds = devm_kzalloc(&client->dev, MAX_LEDS * sizeof(*leds), ++ GFP_KERNEL); ++ if (!leds) ++ return -ENOMEM; ++ ++ i2c_set_clientdata(client, chip); ++ ++ mutex_init(&chip->mutex); ++ chip->client = client; ++ chip->leds = leds; ++ ++ for (i = 0; i < MAX_LEDS; i++) { ++ leds[i].led_num = i; ++ leds[i].chip = chip; ++ INIT_WORK(&leds[i].work, omnia_led_work); ++ ++ /* Platform data can specify LED names and default triggers */ ++ if (pdata && i < pdata->leds.num_leds) { ++ if (pdata->leds.leds[i].name) ++ snprintf(leds[i].name, ++ sizeof(leds[i].name), "omnia-led:%s", ++ pdata->leds.leds[i].name); ++ if (pdata->leds.leds[i].default_trigger) ++ leds[i].led_cdev.default_trigger = ++ pdata->leds.leds[i].default_trigger; ++ } ++ if (!pdata || i >= pdata->leds.num_leds || ++ !pdata->leds.leds[i].name) ++ snprintf(leds[i].name, sizeof(leds[i].name), ++ "omnia-led:%d", i); ++ ++ leds[i].led_cdev.name = leds[i].name; ++ leds[i].led_cdev.brightness_set = omnia_led_set_async; ++ ++ err = led_classdev_register(&client->dev, &leds[i].led_cdev); ++ if (err < 0) ++ goto exit; ++ ++ err = device_create_file(leds[i].led_cdev.dev, ++ &dev_attr_autonomous); ++ if (err < 0) { ++ dev_err(leds[i].led_cdev.dev, ++ "failed to create attribute autonomous\n"); ++ goto exit; ++ } ++ ++ err = device_create_file(leds[i].led_cdev.dev, ++ &dev_attr_color); ++ if (err < 0) { ++ dev_err(leds[i].led_cdev.dev, ++ "failed to create attribute color\n"); ++ goto exit; ++ } ++ ++ /* Set AUTO for all LEDs by default */ ++ leds[i].autonomous = 0; ++ omnia_led_autonomous_set(&leds[i], 1); ++ ++ /* Set brightness to LED_OFF by default */ ++ omnia_led_brightness_set(&leds[i], LED_OFF); ++ ++ /* MCU default color is white */ ++ leds[i].r = 255; ++ leds[i].g = 255; ++ leds[i].b = 255; ++ } ++ ++ err = device_create_file(&client->dev, &dev_attr_global_brightness); ++ if (err < 0) { ++ dev_err(&client->dev, ++ "failed to create attribute global_brightness\n"); ++ goto exit; ++ } ++ ++ return 0; ++ ++exit: ++ device_remove_file(&client->dev, &dev_attr_global_brightness); ++ while (i--) { ++ device_remove_file(chip->leds[i].led_cdev.dev, ++ &dev_attr_color); ++ device_remove_file(chip->leds[i].led_cdev.dev, ++ &dev_attr_autonomous); ++ ++ led_classdev_unregister(&leds[i].led_cdev); ++ } ++ ++ return err; ++} ++ ++static int omnia_remove(struct i2c_client *client) ++{ ++ struct omnia_led_mcu *chip = i2c_get_clientdata(client); ++ int i; ++ ++ device_remove_file(&client->dev, &dev_attr_global_brightness); ++ ++ for (i = 0; i < MAX_LEDS; i++) { ++ device_remove_file(chip->leds[i].led_cdev.dev, ++ &dev_attr_color); ++ device_remove_file(chip->leds[i].led_cdev.dev, ++ &dev_attr_autonomous); ++ ++ led_classdev_unregister(&chip->leds[i].led_cdev); ++ } ++ ++ return 0; ++} ++ ++static struct i2c_driver omnia_driver = { ++ .driver = { ++ .name = "leds-omnia", ++ .of_match_table = of_match_ptr(of_omnia_match), ++ }, ++ .probe = omnia_probe, ++ .remove = omnia_remove, ++ .id_table = omnia_id, ++}; ++ ++module_i2c_driver(omnia_driver); ++ ++MODULE_AUTHOR("Tomas Hlavacek "); ++MODULE_DESCRIPTION("Turris Omnia LED driver"); ++MODULE_LICENSE("GPL v2"); ++ +--- a/arch/arm/boot/dts/armada-385-turris-omnia.dts ++++ b/arch/arm/boot/dts/armada-385-turris-omnia.dts +@@ -168,7 +168,78 @@ + reg = <0>; + + /* STM32F0 command interface at address 0x2a */ +- /* leds device (in STM32F0) at address 0x2b */ ++ ++ leds@2b { ++ compatible = "turris-leds,omnia"; ++ reg = <0x2b>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ led0 { ++ label = "user2"; ++ reg = <0x0>; ++ }; ++ ++ led1 { ++ label = "user1"; ++ reg = <0x1>; ++ }; ++ ++ led2 { ++ label = "pci3"; ++ reg = <0x2>; ++ }; ++ ++ led3 { ++ label = "pci2"; ++ reg = <0x3>; ++ }; ++ ++ led4 { ++ label = "pci1"; ++ reg = <0x4>; ++ }; ++ ++ led5 { ++ label = "wan"; ++ reg = <0x5>; ++ }; ++ ++ led6 { ++ label = "lan4"; ++ reg = <0x6>; ++ }; ++ ++ led7 { ++ label = "lan3"; ++ reg = <0x7>; ++ }; ++ ++ led8 { ++ label = "lan2"; ++ reg = <0x8>; ++ }; ++ ++ led9 { ++ label = "lan1"; ++ reg = <0x9>; ++ }; ++ ++ led10 { ++ label = "lan0"; ++ reg = <0xa>; ++ }; ++ ++ led11 { ++ label = "power"; ++ reg = <0xb>; ++ }; ++ ++ led12 { ++ label = "all"; ++ reg = <0xc>; ++ }; ++ }; + + eeprom@54 { + compatible = "atmel,24c64"; From patchwork Thu Dec 13 05:29:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 1012571 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="H55g02gt"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E/s+2HtD"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43Fj2K62NXz9s9h for ; Thu, 13 Dec 2018 16:30:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IibIzVPuwK2fBLOAZ8+6a6n1KAvkMnQmyP1sQ3QyY3E=; b=H55g02gt8m98KY V+ZH/kUxPVmITeIyZiIjx7Jgl1deZRvkjKSsPNVN1/fHg5igD5SZ7W2cjOmlaMw+oWXVSdjLkRgjv 5a3w/vB9O0hBXwN5y0AMP7IMx20W2iA1zSrkdTX521eP/R/OIP2ggh7y5bEpvCtiA1WRTFnLKUY81 fnMg5qJFjCTCDvF9ZgSWkq6P3fxGyVe/ytz+WovvUK5LMFCic7QjI/QJhfUUIzKwE5R3Z++s0Yflx GLLl8hKWgCckHUjRGDm7tIcetRuYOcvNkhEgRmJanhov6rH0Y55ts9H7Cvve2r+oHOkEpE7zLgoHH bx+DBSlqWo2hBUxV7yWg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJaB-0000a5-3Z; Thu, 13 Dec 2018 05:30:47 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJZn-0000Bq-MQ for openwrt-devel@lists.openwrt.org; Thu, 13 Dec 2018 05:30:26 +0000 Received: by mail-ed1-x544.google.com with SMTP id x30so992428edx.2 for ; Wed, 12 Dec 2018 21:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1f3fi28q7eD7/5OJgyJ9rSOVKqP5Xfe6Zp5aHeCRiVM=; b=E/s+2HtDR/iJ/PfK2adIVDK1sSgEa6f9EwUqP326OtNynv24faGKXWdE24GDERkPrE WxG6/emGfqTa2YRb/ngMwW6TyMf6U75eP22Ta5Emmpr16IMXs1HNQZ1kLxKRRp6WQOB9 whG89CKcFrT2XizWnMz8sGiLqTkK8z34EfJGHildoKtzvgsUiv4588QvVnG0DvQ45nFy kWOjdCZyaT3+gn7NiiP3g6FUc2UdXQ0tX9VItKXRXbfeXFPOGvsirUHnH6QtjND4QUG9 +CtMkqffEnqrVeqYwmb956lEjM7lk422drNJSJpyUaa1zkhNNlvp5SwLIU53cyH+gRcc IGyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1f3fi28q7eD7/5OJgyJ9rSOVKqP5Xfe6Zp5aHeCRiVM=; b=W5av3ArMHCPjCg9zeSk5qz9RiOOQt+7j9DQbyUgK5CeWhzIUQyjCIXApjChh4CMWQI hxWFeXm/e1AQ9STRVayYigW30wtQQooDLsshkQVcWYuWW/sAUvYRvh5RpdE3WBgzMHXD WZh0LxZ0vg6ugMta4In5EUBQjpUOoe2Xh6/0/AUNwHnzHNMITXTL5Pyqks1PjDV10Uax AVp/ZZthsgAs2vd/OwxE2XzmAdb9iRvCNt7Yfsgqk6hZg1WoELFhizIfrs/tdVBzWCaK duyauabpedsZWvrtp/wkCYnkq0WnHCW/PgHOrCN2o8HdQe/vd8C7iQxh8pPi9HkV9QiX UWnQ== X-Gm-Message-State: AA+aEWbemvZujXHRWj0OMqcRME2hXxeI24GSjzsoDdtxbJAXQqLKk0Lk rggNYcJX9GYKPA5Wrod45O/3ZQmj X-Google-Smtp-Source: AFSGD/UTiYna7Pfv9rqSaSt0ltZ7VHyGL3k0vE0GK9mCWHUsMXM7jiy+/Pa8lgTaFL5D8GrreDoEFQ== X-Received: by 2002:a50:d1d4:: with SMTP id i20mr21092015edg.268.1544679011796; Wed, 12 Dec 2018 21:30:11 -0800 (PST) Received: from mars.lan ([2a02:168:6806:0:e862:1a6:be96:624b]) by smtp.gmail.com with ESMTPSA id s12sm331526edb.43.2018.12.12.21.30.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 21:30:11 -0800 (PST) From: Klaus Kudielka To: openwrt-devel@lists.openwrt.org Date: Thu, 13 Dec 2018 06:29:50 +0100 Message-Id: <20181213052952.3744-3-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213052952.3744-1-klaus.kudielka@gmail.com> References: <20181213052952.3744-1-klaus.kudielka@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181212_213023_748922_5F73B473 X-CRM114-Status: GOOD ( 10.52 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:544 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (klaus.kudielka[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [OpenWrt-Devel] [PATCH 2/4] mvebu: enable Turris Omnia LED support as module X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Kudielka MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org leds.mk: - Define kmod-leds-omnia including dependencies. - Load early, in order to support LED diagnostics during preinit. cortex-a9.mk: - Select kmod-leds-omnia for the turris-omnia image. i2c.mk: - LED controller is behind i2c mux. Therefore, load i2c-mux-pca954x early as well. Signed-off-by: Klaus Kudielka --- package/kernel/linux/modules/i2c.mk | 2 +- package/kernel/linux/modules/leds.mk | 16 ++++++++++++++++ target/linux/mvebu/image/cortex-a9.mk | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/package/kernel/linux/modules/i2c.mk b/package/kernel/linux/modules/i2c.mk index 4cf37dae07..d7a07a733f 100644 --- a/package/kernel/linux/modules/i2c.mk +++ b/package/kernel/linux/modules/i2c.mk @@ -176,7 +176,7 @@ I2C_MUX_PCA954x_MODULES:= \ CONFIG_I2C_MUX_PCA954x:drivers/i2c/muxes/i2c-mux-pca954x define KernelPackage/i2c-mux-pca954x - $(call i2c_defaults,$(I2C_MUX_PCA954x_MODULES),51) + $(call i2c_defaults,$(I2C_MUX_PCA954x_MODULES),51,1) TITLE:=Philips PCA954x I2C mux/switches DEPENDS:=kmod-i2c-mux endef diff --git a/package/kernel/linux/modules/leds.mk b/package/kernel/linux/modules/leds.mk index 7019f04779..a8673c4af9 100644 --- a/package/kernel/linux/modules/leds.mk +++ b/package/kernel/linux/modules/leds.mk @@ -145,3 +145,19 @@ define KernelPackage/leds-pca963x/description endef $(eval $(call KernelPackage,leds-pca963x)) + + +define KernelPackage/leds-omnia + SUBMENU:=$(LEDS_MENU) + TITLE:=Turris Omnia LED support + DEPENDS:=@TARGET_mvebu_cortexa9 +kmod-i2c-core +kmod-i2c-mux +kmod-i2c-mux-pca954x + KCONFIG:=CONFIG_LEDS_OMNIA + FILES:=$(LINUX_DIR)/drivers/leds/leds-omnia.ko + AUTOLOAD:=$(call AutoLoad,60,leds-omnia,1) +endef + +define KernelPackage/leds-omnia/description + Driver for the Turris Omnia LED controller. +endef + +$(eval $(call KernelPackage,leds-omnia)) diff --git a/target/linux/mvebu/image/cortex-a9.mk b/target/linux/mvebu/image/cortex-a9.mk index 79c3bc7bdb..272e381db0 100644 --- a/target/linux/mvebu/image/cortex-a9.mk +++ b/target/linux/mvebu/image/cortex-a9.mk @@ -162,6 +162,7 @@ define Device/turris-omnia DEVICE_TITLE := Turris Omnia DEVICE_PACKAGES := \ mkf2fs e2fsprogs kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 \ + kmod-leds-omnia \ wpad-basic kmod-ath9k kmod-ath10k-ct ath10k-firmware-qca988x-ct IMAGES := $$(IMAGE_PREFIX)-sysupgrade.img.gz omnia-medkit-$$(IMAGE_PREFIX)-initramfs.tar.gz IMAGE/$$(IMAGE_PREFIX)-sysupgrade.img.gz := boot-img | sdcard-img | gzip | append-metadata From patchwork Thu Dec 13 05:29:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 1012570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="n3NywmVf"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="io+3+WjA"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43Fj2G5zWkz9s9h for ; Thu, 13 Dec 2018 16:30:46 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ajhn/xILpdzBpreTVG4IoqMvxFXtxSowGKQeexRVbnk=; b=n3NywmVfiJQtZT ySPfnBO9MbXiblkwbfUEEVTvkAz1fpiOwEGlFH+K9S0JX54HhsAgCMsHqqCkfvcE9pJu95caCO4P/ JztjMqzNs9u8AAl8zb+XUsZzeploo5kndpWbkyNdr2DpXHMLwtv+BuEEBeo19FL5T9HwMpbliIYzu 50IfMn248YvzcbiDUkLuHESWyGbO3YBzOP+FhE/SOOevq280/Meh4rvM8PPr8fQU7U3HV8KI9VB/7 lkNg4KqaJ0Saey/SGZtJqhjY5WRbTB0Uh/cwW0az/rJBHGhr+xTn2OhSgT7yVeBjr7W6Hlw0Lcpr7 BufiMfTyIqtCVBbWwRhg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJZz-0000Lq-C9; Thu, 13 Dec 2018 05:30:35 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJZn-0000Br-Fg for openwrt-devel@lists.openwrt.org; Thu, 13 Dec 2018 05:30:25 +0000 Received: by mail-ed1-x542.google.com with SMTP id z28so961213edi.8 for ; Wed, 12 Dec 2018 21:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3vAOPbPbVuYx5jBfCWAbebwgxIzzi8wwT5c08bjO4FA=; b=io+3+WjAD0ipDGRNmfihkTnpyGVuKQwpppLf7sLfTQ/DbdJtPFgc7ig95qJ6KKNcWu HeuvxGqt1qg2OSMzj/RESRa68qR3XLWiIPunOuBjp0T1Af8SOb9fgYLaFVb+JbQ93fcX 6TlB0S+LQMJRxaXh4lycKgYQRdS8PsV7p0/q22pHxkv5FHi+witQG/8iDHQFTAifAR0h wifLX9XRwY3o6xs/ORkVgAkY//+WMkFsDh/QMSJ6OHe4p9Ja7OKFrHhIcOxZR/XtMiJ2 hpvNl9Sf/lK/7ySX702gjqCGGoJUz7QXXUygKTv5ftnwxUap7eXzCL4GW+1IGvCJzfws 8/kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3vAOPbPbVuYx5jBfCWAbebwgxIzzi8wwT5c08bjO4FA=; b=ZliK37MRR0honlmWiL5zHDdCYbWxKJd/d5mHkHC6a+qjM8wihRJaV/ijdrVpKAov2l ZEWlvNTtN7LdhDpe4r8Z7h33VeSTdi0D8+UqlbJGd/sFPbPHYC+ISx9YQDbWT26ajEkJ LZ4p9CcqKemkewmJq02NurR/iDtFFcwOd0CqkU1xOLG2AtFkPHfvhnacwJq8uGa4mh6g +VbR+DB8LwD8fJJxJ4ONIvse1dqlwG+NEPS9jjbosDIyxI8NPGnMeXD7boU7hUhlftvd wd5uwBJ7DI245PtZ8oDG4TNJ4frjSqVRimmRWbDhGC36hyYjsgtoxUykOGczHCPvQbyP gBlg== X-Gm-Message-State: AA+aEWZoxnUbs+TqhtUELYNgXWJlW2I54Rr4lo7o0ct38IC1VCOmtzOH TpRd9Vpz7GMKPQrZzt/sDogDMxK2 X-Google-Smtp-Source: AFSGD/Xfz4YFNcn5zydaLbmFhKK3IsQX+cVZQ8VLvqIaIicSsYObc5CmOIa07b3gmq7l3YtwVzSUBQ== X-Received: by 2002:a17:906:1859:: with SMTP id w25-v6mr17315835eje.3.1544679012624; Wed, 12 Dec 2018 21:30:12 -0800 (PST) Received: from mars.lan ([2a02:168:6806:0:e862:1a6:be96:624b]) by smtp.gmail.com with ESMTPSA id s12sm331526edb.43.2018.12.12.21.30.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 21:30:12 -0800 (PST) From: Klaus Kudielka To: openwrt-devel@lists.openwrt.org Date: Thu, 13 Dec 2018 06:29:51 +0100 Message-Id: <20181213052952.3744-4-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213052952.3744-1-klaus.kudielka@gmail.com> References: <20181213052952.3744-1-klaus.kudielka@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181212_213023_558579_DEA83E64 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:542 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (klaus.kudielka[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [OpenWrt-Devel] [PATCH 3/4] mvebu: enable LED diagnostics for Turris Omnia X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Kudielka MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Just before starting LED diagnostics, a preinit hook disables the 'autonomous' flag for all LEDs. This way, the power LED will start blinking during preinit, as desired. As a benefit, all other LEDs remain dark, until boot is finished (and the desired LED configuration is loaded). This avoids the rather distracting on/off behaviour of some LAN LEDs during boot. Signed-off-by: Klaus Kudielka --- target/linux/mvebu/base-files/etc/diag.sh | 3 +++ .../mvebu/base-files/lib/preinit/09_initialize_leds | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 target/linux/mvebu/base-files/lib/preinit/09_initialize_leds diff --git a/target/linux/mvebu/base-files/etc/diag.sh b/target/linux/mvebu/base-files/etc/diag.sh index 327a82df93..f81dba083f 100644 --- a/target/linux/mvebu/base-files/etc/diag.sh +++ b/target/linux/mvebu/base-files/etc/diag.sh @@ -22,6 +22,9 @@ get_status_led() { armada-385-linksys-venom) status_led="venom:blue:power" ;; + armada-385-turris-omnia) + status_led="omnia-led:power" + ;; armada-xp-linksys-mamba) status_led="mamba:white:power" ;; diff --git a/target/linux/mvebu/base-files/lib/preinit/09_initialize_leds b/target/linux/mvebu/base-files/lib/preinit/09_initialize_leds new file mode 100644 index 0000000000..c83fa671e1 --- /dev/null +++ b/target/linux/mvebu/base-files/lib/preinit/09_initialize_leds @@ -0,0 +1,12 @@ +#!/bin/sh + +do_initialize_leds() { + case $(board_name) in + armada-385-turris-omnia) + led_set_attr omnia-led:all autonomous 0 + ;; + esac +} + +boot_hook_add preinit_main do_initialize_leds + From patchwork Thu Dec 13 05:29:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Kudielka X-Patchwork-Id: 1012572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="j8pj+ksV"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vSlKJaOb"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43Fj2c0Nbwz9s9h for ; Thu, 13 Dec 2018 16:31:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zqe4mFzorriL5qLoXlTeYJKL9eU6OmHxg63JwmRCW8s=; b=j8pj+ksVzDYqHs OKXqk3sVTkUwdXqAyQcdswcXM/ll/9rKu+t+yyaL79pSuGlmoVTYTVZa2JUTlQGphmyc+Mi0c7ZuN M5sue+wXuD9YdAf2tfN4GMfkjW9L4tlYo+u/E/tagrdUAe7jvx1P3V0lP2BPp3o1/wNJuWQqqWE1T Hf46OXrM4pZwiCmZIUdwFNTm3gk+FMw3lc+oweq1WDAaauCA//m1NFeQvjov7iSRxcMLS51tKIhOc j9NcgUVvMINrbEN5bviJj4bNvX+aqyHbWTrZMVKrXsR8WWtxd+HBcjzfz0WVj+xP//bYq5rSS6o2q f5S2LmZLi2HwbYpTcY5Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJaP-0000sV-6M; Thu, 13 Dec 2018 05:31:01 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXJZp-0000Bt-Hu for openwrt-devel@lists.openwrt.org; Thu, 13 Dec 2018 05:30:30 +0000 Received: by mail-ed1-x541.google.com with SMTP id f9so946395eds.10 for ; Wed, 12 Dec 2018 21:30:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IPJQnCYFSR4ucqThK5rjpmNHMbHrkbb8/6TciUi75IQ=; b=vSlKJaObvVF2ZS8CQQCIZ9a0DvaH6OsL5LVFv0ltOYGLcFhVcaagUfp5oRZ5haSgrO zzTI3UMFYk+9Xnan+ixQwFcC/NTdtOfnxvP3SQz+arI9B8kHixDt0Jy4W+FQpUSU4gpp C/y75M7KYArVDSANU1vizw62CelWL+x1zZ2SpAIuC/Mtf4qMhMLpvJ8RV2jeyFDcFXbN IPPeYOUEciCGGjrAOlKxD7Rsk/CSSpVWekEHUfOYOsV+fXSOBLSjwlaygr2JV3yBAYfd 2NUmWBujFafuNzB8XBi+I0dpFoKbCILLf1en9K26k54xmfY/a4vvxiBrJu7iCkOFyj8n bJJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IPJQnCYFSR4ucqThK5rjpmNHMbHrkbb8/6TciUi75IQ=; b=knfAFMnYLIl5X1PpUuZ4A0LXk1swxsoeeByf2OdgR4y7jYZLZo6tAWH4O8ZkjEu8yT P4nyCxS2rSUR9yqA2KPY5QbK464rVK8JLEDvt0jpCEdMrdSfSco0hSmFigw3DChyICnC OdUa2W2aLq3M2Bl+DSKaMmlTh/Obj7uDRI2FdCzOkjHyTU8WiN+jIMIj+LuiUdYzRi/N mniHfqK/6CUeMJd1JdVnYOB+UTrWfWKURE8xuUEqNJrH2564+8EDPZ16YURnhugdrqZA PFo+MXZBItrx6VViNZf/CixNguuXWZ3chMVsYTxcgGksIK51xKUogUthtnUF5lS92T1L gD1A== X-Gm-Message-State: AA+aEWbHB7l0nfMwpNmZszW9UdH43HuJLifi1ifNCUipFfiXQXJntQPO NZdlhhyV64GkJU/iqOqPtZwcf4BT X-Google-Smtp-Source: AFSGD/U6Yx4gdqv5mDz7Qh+lf3s/lLtZpQYYtLh6e0BeurC2tX7d9gx8esdnlE+G+NXCWTpvrTuKWA== X-Received: by 2002:a17:906:3e47:: with SMTP id t7-v6mr16850670eji.201.1544679013520; Wed, 12 Dec 2018 21:30:13 -0800 (PST) Received: from mars.lan ([2a02:168:6806:0:e862:1a6:be96:624b]) by smtp.gmail.com with ESMTPSA id s12sm331526edb.43.2018.12.12.21.30.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 21:30:12 -0800 (PST) From: Klaus Kudielka To: openwrt-devel@lists.openwrt.org Date: Thu, 13 Dec 2018 06:29:52 +0100 Message-Id: <20181213052952.3744-5-klaus.kudielka@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213052952.3744-1-klaus.kudielka@gmail.com> References: <20181213052952.3744-1-klaus.kudielka@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181212_213025_597644_3B702FD8 X-CRM114-Status: GOOD ( 13.13 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (klaus.kudielka[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Subject: [OpenWrt-Devel] [PATCH 4/4] mvebu: add Turris Omnia LED configuration X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Klaus Kudielka MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org With this commit users are able to configure all extra features of the Turris Omnia LED driver (global brightness, individual LED color, individual autonomous flag). For example: uci set omnia_led.main.global_brightness='6' uci set omnia_led.power.color='255 0 0' service omnia_led start uci commit This is achieved by the /etc/init.d/omnia_led script, which generates its own default configuration /etc/config/omnia_led upon the first boot. In the default configuration, all LAN and PCI LEDs (5+3) function autonomously. The remaining 4 LEDs are driven by software (autonomous=0) and have sensible UCI defaults. The WAN LED uses the netdev trigger (benefit: this also works with SFP). Signed-off-by: Klaus Kudielka --- .../mvebu/base-files/etc/board.d/01_leds | 6 ++ .../mvebu/base-files/etc/init.d/omnia_led | 90 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100755 target/linux/mvebu/base-files/etc/init.d/omnia_led diff --git a/target/linux/mvebu/base-files/etc/board.d/01_leds b/target/linux/mvebu/base-files/etc/board.d/01_leds index ff8d4a21c0..96723d0295 100755 --- a/target/linux/mvebu/base-files/etc/board.d/01_leds +++ b/target/linux/mvebu/base-files/etc/board.d/01_leds @@ -41,6 +41,12 @@ armada-385-linksys-venom) ucidef_set_led_usbport "usb2" "USB 2" "pca963x:venom:blue:usb3_1" "usb2-port1" "usb3-port1" ucidef_set_led_usbport "usb2_ss" "USB 2 SS" "pca963x:venom:blue:usb3_2" "usb3-port1" ;; +armada-385-turris-omnia) + ucidef_set_led_default "power" "POWER" "omnia-led:power" "1" + ucidef_set_led_netdev "wan" "WAN" "omnia-led:wan" "eth2" + ucidef_set_led_default "user1" "A" "omnia-led:user1" "0" + ucidef_set_led_default "user2" "B" "omnia-led:user2" "0" + ;; armada-xp-linksys-mamba) ucidef_set_led_netdev "wan" "WAN" "mamba:white:wan" "eth1" ucidef_set_led_usbport "usb1" "USB 1" "mamba:white:usb2" "usb1-port1" diff --git a/target/linux/mvebu/base-files/etc/init.d/omnia_led b/target/linux/mvebu/base-files/etc/init.d/omnia_led new file mode 100755 index 0000000000..bbe605d75a --- /dev/null +++ b/target/linux/mvebu/base-files/etc/init.d/omnia_led @@ -0,0 +1,90 @@ +#!/bin/sh /etc/rc.common + +START=96 + +. /lib/functions/leds.sh + +config=omnia_led + +omnia_set() { + local type + local sect + + type=$1 + sect=$2 + uci set $config.$sect=$type + shift + shift + while [ -n "$1" ]; do + uci set $config.$sect.$1="$2" + shift + shift + done +} + +omnia_generate_config() { + echo "Generating /etc/config/$config" + touch /etc/config/$config + omnia_set controller main global_brightness 100 + omnia_set led all sysfs omnia-led:all color "255 255 255" + omnia_set led power sysfs omnia-led:power autonomous 0 + omnia_set led lan0 sysfs omnia-led:lan0 autonomous 1 + omnia_set led lan1 sysfs omnia-led:lan1 autonomous 1 + omnia_set led lan2 sysfs omnia-led:lan2 autonomous 1 + omnia_set led lan3 sysfs omnia-led:lan3 autonomous 1 + omnia_set led lan4 sysfs omnia-led:lan4 autonomous 1 + omnia_set led wan sysfs omnia-led:wan autonomous 0 + omnia_set led pci1 sysfs omnia-led:pci1 autonomous 1 + omnia_set led pci2 sysfs omnia-led:pci2 autonomous 1 + omnia_set led pci3 sysfs omnia-led:pci3 autonomous 1 + omnia_set led user1 sysfs omnia-led:user1 autonomous 0 + omnia_set led user2 sysfs omnia-led:user2 autonomous 0 + uci commit $config +} + +omnia_load_global_brightness() { + local path + local global_brightness + + path=/sys/bus/i2c/devices/1-002b + config_get global_brightness main global_brightness 100 + + [ -d $path ] && { + echo "Setting up led controller" + echo "$global_brightness" >$path/global_brightness 2>/dev/null || + echo " Failed to set global_brightness to '$global_brightness'" + } || echo "Could not find led controller at $path" +} + +omnia_load_led() { + local sysfs + local color + local autonomous + + config_get sysfs $1 sysfs + config_get color $1 color + config_get autonomous $1 autonomous + + [ -n "$sysfs" ] && { + [ -d "/sys/class/leds/$sysfs" ] && { + echo "Setting up $sysfs" + [ -n "$color" ] && { + led_set_attr "$sysfs" color "$color" 2>/dev/null || + echo " Failed to set color to '$color'" + } || true + [ -n "$autonomous" ] && { + led_set_attr "$sysfs" autonomous "$autonomous" 2>/dev/null || + echo " Failed to set autonomous to '$autonomous'" + } || true + } || echo "Could not find $sysfs in /sys/class/leds" + } || echo "Could not find sysfs option in led section '$1'" +} + +start() { + [ $(board_name) = armada-385-turris-omnia -a -d /sys/bus/i2c/drivers/leds-omnia ] && { + [ ! -s /etc/config/$config ] && omnia_generate_config + config_load $config + omnia_load_global_brightness + config_foreach omnia_load_led led + } +}