Received: by 10.223.185.116 with SMTP id b49csp6535101wrg; Thu, 8 Mar 2018 09:00:50 -0800 (PST) X-Google-Smtp-Source: AG47ELtZ0s8LwXIzz3Ws0JYBG2yxTHfEQ+txKCzd8kAlzGOn8QTHZLUgVBA0yvYIE0ZU8OzuC/do X-Received: by 2002:a17:902:b101:: with SMTP id q1-v6mr24741526plr.287.1520528450566; Thu, 08 Mar 2018 09:00:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520528450; cv=none; d=google.com; s=arc-20160816; b=vr/+R9RDhgyCh79c4UG0qhMRbW8gzeY+tRarlMQ067vDfJCofRQzu5Y6avbKKLeWSA aUTwy+VUAtTg6HzqT5oJIbFOdY4oLXljMNpmqYm9KwLsS08ZoPPFww/eKnRC4hcZx3u0 ZGBJoJY72cXF0pv0eUkNorEVX6fv7g1yQW8T/qxBfbYqYvEsst0DPB0GE6+k5EAVqO48 Hg8MlssswXqM//NvpWz2zXHeToa8GMe1Z6jqB1RzBu+Z66NCjynV2HIN0BrOOPnANGBx 6zciuL68wqtxWoQEBjr9A65UbZHQh08IHbcM7OHoMlpOCRlzs0S3ba6rMT0h+xi/YSw6 jjNg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=vJO2NT6oevlvpdHm3BmPoIksCVLIZww3Rn+l5boo6Fg=; b=nOP9YitI7r/LtfrzPo+65jSXQK1yft546Z5Q5cigJyRzA0+sSl4NdsdumVJjioq8YD n4sFKqozu7QBh0Io9E1MgQZiJ/gJejnRXZuHmLkaKKPdPTN/MboLIpx9CQqsTW0hTWKA 5+2VQcgBrptm1lQ+lcm1IW80nUIJK5wOUQwzmEfBUZY/uShOGN5RD3Pk36l4GyJgf1P1 /NEXx7icFSbK7C0Ez2jgtor8YcKWM1OJRYPsuHXpEuMmeHCgo78LXO26k92i9pBM6nmP 4LNbzJ6kJXC/lNP/ZdlOkKKdWb6fh4ek04/lmVM4QDvGwxm4cjrfVZ7bn+rfrl9YgOxT OzjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UdoTe4jD; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v12-v6si7668411plo.170.2018.03.08.09.00.33; Thu, 08 Mar 2018 09:00:50 -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=@linaro.org header.s=google header.b=UdoTe4jD; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936092AbeCHQ61 (ORCPT + 99 others); Thu, 8 Mar 2018 11:58:27 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:56242 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935923AbeCHQ6Y (ORCPT ); Thu, 8 Mar 2018 11:58:24 -0500 Received: by mail-wm0-f65.google.com with SMTP id q83so549870wme.5 for ; Thu, 08 Mar 2018 08:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vJO2NT6oevlvpdHm3BmPoIksCVLIZww3Rn+l5boo6Fg=; b=UdoTe4jDnaAXK3G52LrDYpNozwK4TrGrOqW+MisHCmMW6ppdWZM3x92TOatvUwpeUP Ki6/IwDR+5G+v6JizmCH91vi+xaeVgWlKIBo8J4GmK+lJd2V7VlzjkHEDJm5sDbk1Jan S4ADMsClaBDrwjBkO5oEtaozh3TGqjKKnrelM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vJO2NT6oevlvpdHm3BmPoIksCVLIZww3Rn+l5boo6Fg=; b=rOOqte8qGeW1DjP1Tgznq+IIsz7oLU3uuNzHow+kc1jXFiuCyvzFTVWe+6anuLIzVm CsOd3VXzv1OM0vYMEn7Eqm0RN9KmN3Iq0cyf5z+8DLdvHjwq7W4dmijVwVZjMvc930AS rfQQV64qt/7B3Lau7k0FZizL39B7KE4GGh12CeR+ylypnf7P5eLlrNhjw6oxytJVpuTG oGuvi/GJBWjKcqasTPEL0YS1IU0ZrqVGu5OBEeV44h39aH62LF1RkZB8DDQaFowcbl6b 4sNZlucsbB0AX440TUmeVvPQ3SCE0HAv07nGTWTqhVfslXTDJsXEf+iBmRhJU8IqDguc PgmA== X-Gm-Message-State: AElRT7G9VK/2uoYODztEzn69pyHox9NZQKiZsVwRZNLUK/d+vmds+K+I TyzHcCzf02PaN5wMoiT5tF2pRv9ss2s= X-Received: by 10.28.224.65 with SMTP id x62mr7703325wmg.6.1520528303489; Thu, 08 Mar 2018 08:58:23 -0800 (PST) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.googlemail.com with ESMTPSA id p199sm5185568wmb.42.2018.03.08.08.58.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 08:58:22 -0800 (PST) Subject: Re: [PATCH 1/2] backlight: Add RAVE SP backlight driver To: Andrey Smirnov , Lee Jones Cc: Jingoo Han , linux-kernel@vger.kernel.org, Chris Healy , Lucas Stach , Aleksander Morgado References: <20180307024011.25033-1-andrew.smirnov@gmail.com> From: Daniel Thompson Message-ID: Date: Thu, 8 Mar 2018 16:58:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180307024011.25033-1-andrew.smirnov@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/03/18 02:40, Andrey Smirnov wrote: > 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, I would have thought BACKLIGHT_PLATFORM would be more suitable here. BACKLIGHT_FIRMWARE is used for things like the ACPI backlight driver. Why did you select this one? Daniel. > + .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, > >