mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] video: Port RAVE SP backlight driver from Linux kernel
Date: Thu, 21 Jun 2018 13:42:35 +0200	[thread overview]
Message-ID: <20180621114235.cdwsyhsktio7zjun@pengutronix.de> (raw)
In-Reply-To: <20180619054609.31226-1-andrew.smirnov@gmail.com>

On Mon, Jun 18, 2018 at 10:46:09PM -0700, Andrey Smirnov wrote:
> This is a minimal port of a kernel commit 6552d3141064 ("backlight:
> Add RAVE SP backlight driver"). All of the changes were kept to a
> minimum and limited to impedance matching between Barebox/Linux driver
> API.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---

Applied, thanks

Sascha

>  drivers/video/Kconfig             |  7 +++
>  drivers/video/Makefile            |  2 +
>  drivers/video/rave-sp-backlight.c | 72 +++++++++++++++++++++++++++++++
>  3 files changed, 81 insertions(+)
>  create mode 100644 drivers/video/rave-sp-backlight.c
> 
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 1dcae48f8..79de32cf8 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -124,6 +124,13 @@ config DRIVER_VIDEO_BACKLIGHT_PWM
>  	help
>  	  Enable this to get support for backlight devices driven by a PWM.
>  
> +config BACKLIGHT_RAVE_SP
> +	tristate "RAVE SP Backlight driver"
> +	depends on RAVE_SP_CORE
> +	depends on DRIVER_VIDEO_BACKLIGHT
> +	help
> +	  Support for backlight control on RAVE SP device.
> +
>  comment "Video encoder chips"
>  
>  config DRIVER_VIDEO_MTL017
> diff --git a/drivers/video/Makefile b/drivers/video/Makefile
> index 081e4463d..01fabe880 100644
> --- a/drivers/video/Makefile
> +++ b/drivers/video/Makefile
> @@ -23,3 +23,5 @@ obj-$(CONFIG_DRIVER_VIDEO_SIMPLEFB) += simplefb.o
>  obj-$(CONFIG_DRIVER_VIDEO_IMX_IPUV3) += imx-ipu-v3/
>  obj-$(CONFIG_DRIVER_VIDEO_EFI_GOP) += efi_gop.o
>  obj-$(CONFIG_DRIVER_VIDEO_FB_SSD1307) += ssd1307fb.o
> +obj-$(CONFIG_BACKLIGHT_RAVE_SP)	+= rave-sp-backlight.o
> +
> diff --git a/drivers/video/rave-sp-backlight.c b/drivers/video/rave-sp-backlight.c
> new file mode 100644
> index 000000000..88ec86e73
> --- /dev/null
> +++ b/drivers/video/rave-sp-backlight.c
> @@ -0,0 +1,72 @@
> +/*
> + * LCD Backlight driver for RAVE SP
> + *
> + * Copyright (C) 2018 Zodiac Inflight Innovations
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that 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 <common.h>
> +#include <malloc.h>
> +#include <init.h>
> +#include <video/backlight.h>
> +#include <linux/mfd/rave-sp.h>
> +
> +#define	RAVE_SP_BACKLIGHT_LCD_EN	BIT(7)
> +
> +static int rave_sp_backlight_set(struct backlight_device *bd, int brightness)
> +{
> +	struct rave_sp *sp = bd->dev.priv;
> +	u8 cmd[] = {
> +		[0] = RAVE_SP_CMD_SET_BACKLIGHT,
> +		[1] = 0,
> +		[2] = brightness ? RAVE_SP_BACKLIGHT_LCD_EN | brightness : 0,
> +		[3] = 0,
> +		[4] = 0,
> +	};
> +
> +	return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0);
> +}
> +
> +static int rave_sp_backlight_probe(struct device_d *dev)
> +{
> +	struct backlight_device *bd;
> +	int ret;
> +
> +	bd = xzalloc(sizeof(*bd));
> +	bd->dev.priv = dev->parent->priv;
> +	bd->brightness_default = 50;
> +	bd->brightness_max = 100;
> +	bd->brightness_set = rave_sp_backlight_set;
> +
> +	ret = backlight_register(bd);
> +	if (ret) {
> +		free(bd);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id rave_sp_backlight_of_match[] = {
> +	{ .compatible = "zii,rave-sp-backlight" },
> +	{}
> +};
> +
> +static struct driver_d rave_sp_backlight_driver = {
> +	.name  = "rave-sp-backlight",
> +	.probe = rave_sp_backlight_probe,
> +	.of_compatible = DRV_OF_COMPAT(rave_sp_backlight_of_match),
> +};
> +device_platform_driver(rave_sp_backlight_driver);
> -- 
> 2.17.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2018-06-21 11:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19  5:46 Andrey Smirnov
2018-06-21 11:42 ` Sascha Hauer [this message]

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=20180621114235.cdwsyhsktio7zjun@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.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