Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Wim de With <wf@dewith.io>
Cc: Lee Jones <lee@kernel.org>, Daniel Thompson <danielt@kernel.org>,
	 Jingoo Han <jingoohan1@gmail.com>,
	Pavel Machek <pavel@kernel.org>, Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Helge Deller <deller@gmx.de>,
	 dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org,
	devicetree@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-fbdev@vger.kernel.org
Subject: Re: [PATCH v3 2/2] backlight: Add support for Orient Chip OCP8178
Date: Tue, 18 Aug 2026 09:34:14 +0200	[thread overview]
Message-ID: <20260818-crazy-corgi-of-sorcery-abaa23@quoll> (raw)
In-Reply-To: <20260816-ocp8178-backlight-v3-2-caf95c453c50@dewith.io>

On Sun, Aug 16, 2026 at 12:57:04PM +0200, Wim de With wrote:
> Add a driver for the Orient Chip OCP8178 backlight controller.
> 
> The OCP8178 supports either PWM or a vendor-specific onewire protocol
> over GPIO. This driver implements the onewire protocol, which enables
> setting static brightness levels without requiring a continuous PWM
> signal from the host CPU. Note that while the vendor calls the protocol
> 1-Wire, it is not the 1-Wire protocol from Dallas Semiconductor as
> implemented in drivers/w1.
> 
> Signed-off-by: Wim de With <wf@dewith.io>
> Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
> ---
>  MAINTAINERS                          |   1 +
>  drivers/video/backlight/Kconfig      |  10 ++
>  drivers/video/backlight/Makefile     |   1 +
>  drivers/video/backlight/ocp8178_bl.c | 231 +++++++++++++++++++++++++++++++++++
>  4 files changed, 243 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3ca99d9c32ef1..7146e4dea8d78 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -19682,6 +19682,7 @@ OCP8178 BACKLIGHT DRIVER
>  M:	Wim de With <wf@dewith.io>
>  S:	Maintained
>  F:	Documentation/devicetree/bindings/leds/backlight/ocs,ocp8178.yaml
> +F:	drivers/video/backlight/ocp8178_bl.c
>  
>  OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER
>  M:	Mahesh J Salgaonkar <mahesh@linux.ibm.com>
> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index 7aa1c4b21111f..aa845230c5f58 100644
> --- a/drivers/video/backlight/Kconfig
> +++ b/drivers/video/backlight/Kconfig
> @@ -226,6 +226,16 @@ config BACKLIGHT_LOCOMO
>  	  If you have a Sharp Zaurus SL-5500 (Collie) or SL-5600 (Poodle) say y to
>  	  enable the LCD/backlight driver.
>  
> +config BACKLIGHT_OCP8178
> +	tristate "OCP8178 Backlight Driver"
> +	depends on GPIOLIB
> +	help
> +	  If you have an Orient Chip OCP8178, say Y to enable the backlight
> +	  driver.
> +
> +	  To compile this driver as a module, choose M here: the module will
> +	  be called ocp8178_bl.
> +
>  config BACKLIGHT_OMAP1
>  	tristate "OMAP1 PWL-based LCD Backlight"
>  	depends on ARCH_OMAP1 || COMPILE_TEST
> diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
> index 21c8313cfb121..c4e87b708ae21 100644
> --- a/drivers/video/backlight/Makefile
> +++ b/drivers/video/backlight/Makefile
> @@ -51,6 +51,7 @@ obj-$(CONFIG_BACKLIGHT_MAX25014)	+= max25014.o
>  obj-$(CONFIG_BACKLIGHT_MAX8925)		+= max8925_bl.o
>  obj-$(CONFIG_BACKLIGHT_MP3309C)		+= mp3309c.o
>  obj-$(CONFIG_BACKLIGHT_MT6370)		+= mt6370-backlight.o
> +obj-$(CONFIG_BACKLIGHT_OCP8178)		+= ocp8178_bl.o
>  obj-$(CONFIG_BACKLIGHT_OMAP1)		+= omap1_bl.o
>  obj-$(CONFIG_BACKLIGHT_PANDORA)		+= pandora_bl.o
>  obj-$(CONFIG_BACKLIGHT_PWM)		+= pwm_bl.o
> diff --git a/drivers/video/backlight/ocp8178_bl.c b/drivers/video/backlight/ocp8178_bl.c
> new file mode 100644
> index 0000000000000..6c1e8c9451f12
> --- /dev/null
> +++ b/drivers/video/backlight/ocp8178_bl.c
> @@ -0,0 +1,231 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Orient Chip OCP8178 Backlight Driver
> + *
> + * Copyright (C) 2026 Wim de With
> + *
> + * Author: Wim de With <wf@dewith.io>
> + */
> +
> +#include <linux/backlight.h>
> +#include <linux/bitfield.h>
> +#include <linux/bits.h>
> +#include <linux/delay.h>
> +#include <linux/device.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/irqflags.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +
> +#define OCP8178_MAX_BRIGHTNESS 0x1F /* 5 bits */
> +
> +#define OCP8178_DEVICE_ADDRESS 0x72
> +
> +#define OCP8178_DATA_RFA BIT(7)
> +#define OCP8178_DATA_ADDR GENMASK(6, 5)
> +#define OCP8178_DATA_VALUE GENMASK(4, 0)
> +
> +#define OCP8178_1W_INIT_MAX_RETRIES 5
> +#define OCP8178_1W_INIT_SLEEP_US (50 * 1000)
> +
> +#define OCP8178_T_OFF_US (3 * 1000) /* datasheet specifies at least 2.5 ms */
> +#define OCP8178_1W_T_DELAY_US (100 + 10) /* 10 us as safety factor */
> +#define OCP8178_1W_T_DETECT_US (260 + 10) /* 10 us as safety factor */
> +#define OCP8178_1W_T_START_US 2
> +#define OCP8178_1W_T_EOS_US 2
> +#define OCP8178_1W_T_WIN_NS (1000 * 1000)
> +
> +/*
> + * The datasheet specifies 1.7 Kbps to 160 Kbps.
> + * 1 / (160 Kbps) is about 6.67 us, so using 7 us per bit should be fine.
> + * T_HIGH + T_LOW = 7 us
> + * T_HIGH > 2 * T_LOW for high bits
> + * T_LOW > 2 * T_HIGH for low bits
> + */
> +#define OCP8178_1W_HIGH_BIT_T_LOW_US 2
> +#define OCP8178_1W_HIGH_BIT_T_HIGH_US 5
> +#define OCP8178_1W_LOW_BIT_T_LOW_US 5
> +#define OCP8178_1W_LOW_BIT_T_HIGH_US 2
> +
> +struct ocp8178_bl {
> +	struct device *dev;
> +	struct gpio_desc *gpiod;
> +};
> +
> +static int ocp8178_bl_enable_onewire(struct ocp8178_bl *ocp8178)
> +{
> +	u64 start, duration;
> +

It seems you re-implemented one-wire interface instead of using w1. Why?
What sort of one-wire bus/interface is this?

Best regards,
Krzysztof


  reply	other threads:[~2026-08-18  7:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16 10:57 [PATCH v3 0/2] backlight: Add support for Orient Chip OCP8178 Wim de With
2026-08-16 10:57 ` [PATCH v3 1/2] dt-bindings: backlight: Add " Wim de With
2026-08-17  9:40   ` Daniel Thompson
2026-08-18  7:35   ` Krzysztof Kozlowski
2026-08-16 10:57 ` [PATCH v3 2/2] backlight: Add support for " Wim de With
2026-08-18  7:34   ` Krzysztof Kozlowski [this message]
2026-08-18  8:19     ` Wim de With
2026-08-18  8:21       ` Krzysztof Kozlowski

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=20260818-crazy-corgi-of-sorcery-abaa23@quoll \
    --to=krzk@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=robh@kernel.org \
    --cc=wf@dewith.io \
    /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