Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2324564ybv; Mon, 24 Feb 2020 03:18:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxaRXbxonuGrrIlDkGaF6+qq9GnlKlP5r5p2E4Y4cauRpkR4DzVukjKLyvw64HOQFZ+3vdJ X-Received: by 2002:a9d:53cb:: with SMTP id i11mr40741142oth.158.1582543112770; Mon, 24 Feb 2020 03:18:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582543112; cv=none; d=google.com; s=arc-20160816; b=j3xfCV6b+4UTP9MynkKQDm3UkZuXGkHh5xz8gepRm2Iw6zEN7OOnqkN4st+WcAlQqn oZrobdsTlhmIH0V/vDm6fI0AWqw4+a5t87WVe11/NNaran1/4ubrbSZicP5n5zxhcwPP 774FSzBJTpZTsXC+j4vB6zq1YIOYS6fqW0dEAH3hed1jTNkKm72//4viO/eOgdSlhdJy AMrbZPZVjrPo35/bRCbCOTe84g1JfsfI1s/Gp0s9IYXck+rFazsbs/gGo82VvlI8LuC4 LaZCzOi+3OisjnoO2CYve/OsJ5zyG9Ky1Z1zIxPt0Ntevx8IipBeJS5Exvulnn78rlqf GPXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AVBnz705/DqbWfl0JLRWaWRVmzmkmw2Y/ojfD6WZ8mI=; b=CHypxAlxtZDtdn8O7KtlDtO/BqAUrihJY/Y3mXdbGE8EimVBdy5b7sF3sRPfXWXaxL lBFfbapShsU/YTn/fxnWytj0gHfyFRDgzV2/anJI7c8i2QrA3wFMNRcyzW60rtNS+s3J tHsVpW9KE2a3gq+dkcX8+3j36llnaeJoRgpj5QSlyFFwkBuGTGtE+h/f9QA/MN9vmaaC V7VlI8jiiXpwlRLKFnm8lJ5qnAcIMIoA7zLXwdqFBGK7nuprrRm+JI/FngUeMU7QMsfV O4MpvoELKlOFnz8tXxds/v3peK5zIA3bLudSLLOREnHp3LzcJTDfMfXiusN8swPXiJhv kl3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s143si4959862oih.251.2020.02.24.03.18.20; Mon, 24 Feb 2020 03:18:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbgBXLRn (ORCPT + 99 others); Mon, 24 Feb 2020 06:17:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:56648 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726765AbgBXLRm (ORCPT ); Mon, 24 Feb 2020 06:17:42 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1E2D0ACE0; Mon, 24 Feb 2020 11:17:40 +0000 (UTC) From: Thomas Bogendoerfer To: Jacek Anaszewski , Pavel Machek Cc: Dan Murphy , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org Subject: [PATCH v5] leds: add SGI IP30 led support Date: Mon, 24 Feb 2020 12:17:33 +0100 Message-Id: <20200224111733.10320-1-tbogendoerfer@suse.de> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch implemenets a driver to support the front panel LEDs of SGI Octane (IP30) workstations. Reviewed-by: Dan Murphy Signed-off-by: Thomas Bogendoerfer --- Changes in v5: - use defines for led enumaration - name red led fault and white led system Changes in v4: - simplified ip30led_set by using gated value from led framework Changes in v3: - rebased to 5.6-rc2 Changes in v2: - use led names conforming to include/dt-bindings/leds/common.h - read LED state from firmware - leave setting up to user drivers/leds/Kconfig | 11 +++++ drivers/leds/Makefile | 1 + drivers/leds/leds-ip30.c | 86 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 drivers/leds/leds-ip30.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index d82f1dea3711..c664d84e1667 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -846,6 +846,17 @@ config LEDS_TPS6105X It is a single boost converter primarily for white LEDs and audio amplifiers. +config LEDS_IP30 + tristate "LED support for SGI Octane machines" + depends on LEDS_CLASS + depends on SGI_MFD_IOC3 + help + This option enables support for the Red and White LEDs of + SGI Octane machines. + + To compile this driver as a module, choose M here: the module + will be called leds-ip30. + comment "LED Triggers" source "drivers/leds/trigger/Kconfig" diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index d7e1107753fb..46bd611a03a9 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -86,6 +86,7 @@ obj-$(CONFIG_LEDS_TI_LMU_COMMON) += leds-ti-lmu-common.o obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o obj-$(CONFIG_LEDS_LM36274) += leds-lm36274.o obj-$(CONFIG_LEDS_TPS6105X) += leds-tps6105x.o +obj-$(CONFIG_LEDS_IP30) += leds-ip30.o # LED SPI Drivers obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o diff --git a/drivers/leds/leds-ip30.c b/drivers/leds/leds-ip30.c new file mode 100644 index 000000000000..e95ea786a43e --- /dev/null +++ b/drivers/leds/leds-ip30.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * LED Driver for SGI Octane machines + */ + +#include +#include +#include +#include + +#define IP30_LED_SYSTEM 0 +#define IP30_LED_FAULT 1 + +struct ip30_led { + struct led_classdev cdev; + u32 __iomem *reg; +}; + +static void ip30led_set(struct led_classdev *led_cdev, + enum led_brightness value) +{ + struct ip30_led *led = container_of(led_cdev, struct ip30_led, cdev); + + writel(value, led->reg); +} + +static int ip30led_create(struct platform_device *pdev, int num) +{ + struct resource *res; + struct ip30_led *data; + + res = platform_get_resource(pdev, IORESOURCE_MEM, num); + if (!res) + return -EBUSY; + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->reg = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(data->reg)) + return PTR_ERR(data->reg); + + + switch (num) { + case IP30_LED_SYSTEM: + data->cdev.name = "white:system"; + break; + case IP30_LED_FAULT: + data->cdev.name = "red:fault"; + break; + default: + return -EINVAL; + } + + data->cdev.brightness = readl(data->reg); + data->cdev.max_brightness = 1; + data->cdev.brightness_set = ip30led_set; + + return devm_led_classdev_register(&pdev->dev, &data->cdev); +} + +static int ip30led_probe(struct platform_device *pdev) +{ + int ret; + + ret = ip30led_create(pdev, IP30_LED_SYSTEM); + if (ret < 0) + return ret; + + return ip30led_create(pdev, IP30_LED_FAULT); +} + +static struct platform_driver ip30led_driver = { + .probe = ip30led_probe, + .driver = { + .name = "ip30-leds", + }, +}; + +module_platform_driver(ip30led_driver); + +MODULE_AUTHOR("Thomas Bogendoerfer "); +MODULE_DESCRIPTION("SGI Octane LED driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:ip30-leds"); -- 2.25.0