Received: by 10.223.185.116 with SMTP id b49csp4545701wrg; Tue, 6 Mar 2018 18:41:41 -0800 (PST) X-Google-Smtp-Source: AG47ELsOH6MLCeQ42vfrnwIY+7EeOQ6kiRrvBg5J8WZ6bySSWOZJRwnGNQ95eI+7+sfVVm6Dir7b X-Received: by 10.101.82.12 with SMTP id o12mr16637066pgp.126.1520390501173; Tue, 06 Mar 2018 18:41:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520390501; cv=none; d=google.com; s=arc-20160816; b=Tj+PR1+yrXS5ouBA9TdFCEGsFSGuwEhOJu/0wdAh5DmdfVqz2N1a/sixjWma0KLsp3 HEGYr08tGUY3V9hFkL8M+iNCnCEFGURuUd0IH9wzMuCzKR7j4Yhlf6gnA58hhdX/HKki N9B2uNYoMXlkbkhnqLEDAtDW+LgPIjgYXbgdYZ2WViYoQ8CoAGezUpjxkU3fJClFq5qS f5zlIIm3efCk71HFh5fbMrnl1itTv1wiOeyxXfmoN8sh0UVGT5OEFjUL9uHFNbZtcjB8 rE5KNMcNEB2XeFw9DesGmSlMir2lutulEGlH16BvE7aAMlaZZzzjBaXzRmcymCLKmMbJ VEPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=O5EJwA0bwr8xyiWFoPrWFp49B3OFe3I+CP3SR4IJ8nQ=; b=SaVRZsvDrcdL4LC97Y8FSAmGISVWVXsrrEbfEwEctusJrxyO+Bld2jiORl732bUjfW dXp+W0e535YyYY7SLPdXjLLziJrTzP49udVCKEdP7FZn9UH2eBw6jlGpO18KFrajXqur CGA9RrAzayFirGRBpC0IMYVg7h5F+qNLya4/5D7dmbjmKK8WYuIp7beZs61ifnn+SfOw Y3gR82qbk0nJjFp/1bB7oanjWYvpmdl5R90w/3iyQWF96ufxx7YgNC2yG28zPVoxMcZy gB8u3etNoxvsAzTtUPZI9Aeo3Y7sjtPRdkjBxNJxYhjh1YxdcHN458kRtvddK3e95v9K P1gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTVppAWL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si12179836ply.22.2018.03.06.18.41.26; Tue, 06 Mar 2018 18:41:41 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTVppAWL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933020AbeCGCkc (ORCPT + 99 others); Tue, 6 Mar 2018 21:40:32 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34247 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753857AbeCGCka (ORCPT ); Tue, 6 Mar 2018 21:40:30 -0500 Received: by mail-pg0-f67.google.com with SMTP id m19so357877pgn.1 for ; Tue, 06 Mar 2018 18:40:30 -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; bh=O5EJwA0bwr8xyiWFoPrWFp49B3OFe3I+CP3SR4IJ8nQ=; b=qTVppAWLYMmmpTKqU7xRDTSXw2IO4vSfwk3XDQ14Y8PgO1G1XsK1jSLzJm0D9mrJdH PfPiGdGLiIC/Xn/wFuRItX3Vf1VCA+W3FO/MfDX+c9mSRR78lMZJ24YcU04NyDfaXm7t eykHNqfcTrx3xLKE6gkoJpvDT4jgjOw1ea+VJUANsqOJj5nJvfzQQEz0UVkSW+lthPGA kqulK8Nbrm2WNF5VYaebb28TC/Lkpc2uXoNtW65/OqyngPiHyuNiCw3Q1UFn8MCkbJgx GMRZr7/gdkm0nUehCMXXnAavuhFr0e0JAxxebC8VU4WRgqYArj+G/UiAusfyoEfV84F4 Y/UQ== 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; bh=O5EJwA0bwr8xyiWFoPrWFp49B3OFe3I+CP3SR4IJ8nQ=; b=DmofhB/T0LMDImQvKmDlkadt/k7AzRtpRH465rwAV+2J18fb6w8sZXKiIGEATFmT2y xKmF7mBnCbBNc3+mY78+7hM22x0HHjPzgWoOvIE9Bc8pRQOQQ4+V8cDAlTpOQEh4uKVm zYAMtBxVi8KCYXIkIR5I3SBJM4AybULbo+6qQdTSs6Bys9lLH3lOFjInOtl+VQdjFMIl r7awoboYuI0mqJc0v6Q+/NxKKpiWeN14IMF5zAwPXqWMLEnpUhuJeCezLGud7LTJqW2P TMsAQ1gg3xC0V9US30mf7XmawBcXDzGBHL9/QHPz7f32EQAyWY968onZLqQfihZ1NGHB tj0A== X-Gm-Message-State: APf1xPB+ZyqY3mPI4ivoQriyQLhrssIEpM15Tv+L6/M351JvjFf5TSGY oji7ouKCCPu+4qu1YWJwPeE= X-Received: by 10.98.80.15 with SMTP id e15mr20580495pfb.90.1520390430024; Tue, 06 Mar 2018 18:40:30 -0800 (PST) Received: from squirtle.westlake.spaceflightindustries.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id q87sm33870174pfa.29.2018.03.06.18.40.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Mar 2018 18:40:29 -0800 (PST) From: Andrey Smirnov To: Lee Jones Cc: Andrey Smirnov , Daniel Thompson , Jingoo Han , linux-kernel@vger.kernel.org, Chris Healy , Lucas Stach , Aleksander Morgado Subject: [PATCH 1/2] backlight: Add RAVE SP backlight driver Date: Tue, 6 Mar 2018 18:40:10 -0800 Message-Id: <20180307024011.25033-1-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver provides access to RAVE SP backlight control functionality. Cc: Lee Jones Cc: Daniel Thompson Cc: Jingoo Han Cc: linux-kernel@vger.kernel.org Cc: Chris Healy Cc: Lucas Stach Cc: Aleksander Morgado Signed-off-by: Andrey Smirnov --- drivers/video/backlight/Kconfig | 6 +++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/rave-sp-backlight.c | 82 +++++++++++++++++++++++++++++ include/linux/mfd/rave-sp.h | 1 + 4 files changed, 90 insertions(+) create mode 100644 drivers/video/backlight/rave-sp-backlight.c diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 4e1d2ad50ba1..5d2d0d7e8100 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -467,6 +467,12 @@ config BACKLIGHT_ARCXCNN If you have an ARCxCnnnn family backlight say Y to enable the backlight driver. +config BACKLIGHT_RAVE_SP + tristate "RAVE SP Backlight driver" + depends on RAVE_SP_CORE + help + Support for backlight control on RAVE SP device. + endif # BACKLIGHT_CLASS_DEVICE endif # BACKLIGHT_LCD_SUPPORT diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 5e28f01c8391..19da71d518bf 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -57,3 +57,4 @@ obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o obj-$(CONFIG_BACKLIGHT_TPS65217) += tps65217_bl.o obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o obj-$(CONFIG_BACKLIGHT_ARCXCNN) += arcxcnn_bl.o +obj-$(CONFIG_BACKLIGHT_RAVE_SP) += rave-sp-backlight.o diff --git a/drivers/video/backlight/rave-sp-backlight.c b/drivers/video/backlight/rave-sp-backlight.c new file mode 100644 index 000000000000..62836ba561db --- /dev/null +++ b/drivers/video/backlight/rave-sp-backlight.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/* + * LCD Backlight driver for RAVE SP + * + * Copyright (C) 2018 Zodiac Inflight Innovations + * + */ + +#include +#include +#include +#include +#include + +#define RAVE_SP_BACKLIGHT_LCD_EN BIT(7) + +static int rave_sp_backlight_update_status(struct backlight_device *bd) +{ + const struct backlight_properties *p = &bd->props; + const u8 intensity = + (p->power == FB_BLANK_UNBLANK) ? p->brightness : 0; + struct rave_sp *sp = dev_get_drvdata(&bd->dev); + u8 cmd[] = { + [0] = RAVE_SP_CMD_SET_BACKLIGHT, + [1] = 0, + [2] = intensity ? RAVE_SP_BACKLIGHT_LCD_EN | intensity : 0, + [3] = 0, + [4] = 0, + }; + + return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0); +} + +static const struct backlight_ops rave_sp_backlight_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = rave_sp_backlight_update_status, +}; + +static struct backlight_properties rave_sp_backlight_props = { + .type = BACKLIGHT_FIRMWARE, + .max_brightness = 100, + .brightness = 50, +}; + +static int rave_sp_backlight_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct backlight_device *bd; + + bd = devm_backlight_device_register(dev, pdev->name, dev->parent, + dev_get_drvdata(dev->parent), + &rave_sp_backlight_ops, + &rave_sp_backlight_props); + if (IS_ERR(bd)) + return PTR_ERR(bd); + + backlight_update_status(bd); + + return 0; +} + +static const struct of_device_id rave_sp_backlight_of_match[] = { + { .compatible = "zii,rave-sp-backlight" }, + {} +}; + +static struct platform_driver rave_sp_backlight_driver = { + .probe = rave_sp_backlight_probe, + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = rave_sp_backlight_of_match, + }, +}; +module_platform_driver(rave_sp_backlight_driver); + +MODULE_DEVICE_TABLE(of, rave_sp_backlight_of_match); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andrey Vostrikov "); +MODULE_AUTHOR("Nikita Yushchenko "); +MODULE_AUTHOR("Andrey Smirnov "); +MODULE_DESCRIPTION("RAVE SP Backlight driver"); diff --git a/include/linux/mfd/rave-sp.h b/include/linux/mfd/rave-sp.h index 796fb9794c9e..fe0ce7bc59cf 100644 --- a/include/linux/mfd/rave-sp.h +++ b/include/linux/mfd/rave-sp.h @@ -21,6 +21,7 @@ enum rave_sp_command { RAVE_SP_CMD_STATUS = 0xA0, RAVE_SP_CMD_SW_WDT = 0xA1, RAVE_SP_CMD_PET_WDT = 0xA2, + RAVE_SP_CMD_SET_BACKLIGHT = 0xA6, RAVE_SP_CMD_RESET = 0xA7, RAVE_SP_CMD_RESET_REASON = 0xA8, -- 2.14.3