Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1117590rdb; Fri, 19 Jan 2024 08:39:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFD31gvocLvdq9ZITpGOP4B/CJCt9/r/s1rEyJesoDfLbKuxIkpXDk4u8o8CunfPo3XM9f X-Received: by 2002:a17:90a:ba8a:b0:28e:84eb:2958 with SMTP id t10-20020a17090aba8a00b0028e84eb2958mr24140pjr.76.1705682372040; Fri, 19 Jan 2024 08:39:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705682372; cv=pass; d=google.com; s=arc-20160816; b=vo+qcjAX2FsPy9Cp4lS/08CyUor4ZbImqubdOJb+9MlqLSrZcr8Y1bAHDB55DiqzfQ zdMIf5Rc69oC3mAepoF/KqgLaGM2IG0XEYV4XcPB5Pz5BtGaNOnKN8+kSmxsCHQlOJ1E bDpgeLbLaan95SUWai2J/Q1A+JR7jhuPQQOKGYOtq1x/GjLSLbFLLmPFPwHIm//AnAz7 MXaa/sB8A7zou711OEnu87YzOLMDfT6oPU7W9rqWPjM4/ztUMaJfX69FsVfqLdt4dAaK 8pjaG2qRXQtjtHaj/himN5Tl3KF73zYNtTyBN7zr9Il9zYMLvwH6HcvC5Tn88PjafZmW mxkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:autocrypt:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=SDxZgKlNAVXoBcadPIptelnRYZelMwfGQz1I00msJiA=; fh=732gGdoym7CavvOP81zzmDz9SczfWa/SZhwgzfjnE4Q=; b=GA+tR37/wS4yho2hzHbXWLF2SyKzdFM+uDmBZiUBmNO4e4YcRBke5MyrQ8NF22wbZB Mmzp9jEdXds18cpoXG/QE8zI+/IXAGl3Aysc7WRyA5qlE0CFjHY3R7//4CjdUUrXnFfY lYB2UxHfqGMLQFhFuzDhu2v8IWFCLbQJi6ZlSh4rSJt8rlF6FNqGedYq1WcAvEdUCZLs NTDWjO/0s2HZCFOx4nouIHrHIcoYyCBk6pQPBsmj14Tvw1GWIHxUd5l33OLLOeuKwoLK dnYu/TAd3NHTzzfAynwQRB11+j0asWAPvk5wyBOFLDF03p+KUJMyrxNGcMkZLGUA82mK QJmw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=skole.hr); spf=pass (google.com: domain of linux-kernel+bounces-31367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31367-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k8-20020a17090a3cc800b002905bf5778esi542522pjd.181.2024.01.19.08.39.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 08:39:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=skole.hr); spf=pass (google.com: domain of linux-kernel+bounces-31367-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31367-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E5CD5B2372D for ; Fri, 19 Jan 2024 16:37:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0488754F9D; Fri, 19 Jan 2024 16:37:20 +0000 (UTC) Received: from mx.skole.hr (mx2.hosting.skole.hr [161.53.165.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C685354F89; Fri, 19 Jan 2024 16:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=161.53.165.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705682239; cv=none; b=FtEKsi+QXkW+5Pn757K1e4rptEZR2aIV/yToKAI1yaSLgalb30Op7wa5qC8Kh21T2nNZZr10KuuCUilkM7yjD7YOfe2Ey8fgrWxtmzXroj7AkCrzVgbP1DPnmkeMK237edPsk3kN60aReh8PmGykvfh0BslZTpZolRaWQ0BIY/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705682239; c=relaxed/simple; bh=U6gHFx3lPChjn2zJs4iE1s5P9gyba00HSfbHHYoV1r0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g+Myoeih3qnlNJ8zA/JCL71FE0E5Zn4l+V1ZaHYgI6diboLP073U7U8IvM1gYEPVXkjU/O8CFa/mtvpapzEsYsa+Ku3fLXGKJWmeRoOLJJpuFsT+nbSEM8etzC3P7335azVhcysueFXKlTe8PKtxjLfZ7V4565Ef3KZkO5FCObU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=skole.hr; spf=pass smtp.mailfrom=skole.hr; arc=none smtp.client-ip=161.53.165.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=skole.hr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=skole.hr Received: from mx2.hosting.skole.hr (localhost.localdomain [127.0.0.1]) by mx.skole.hr (mx.skole.hr) with ESMTP id 55949868B1; Fri, 19 Jan 2024 17:37:12 +0100 (CET) From: Duje =?utf-8?B?TWloYW5vdmnEhw==?= To: Linus Walleij Cc: Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Helge Deller , Karel Balej , ~postmarketos/upstreaming@lists.sr.ht, 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 v2 2/2] backlight: Add Kinetic KTD2801 driver Date: Fri, 19 Jan 2024 17:36:37 +0100 Message-ID: <13440257.uLZWGnKmhe@radijator> In-Reply-To: References: <20240118-ktd2801-v2-0-425cf32e0769@skole.hr> <20240118-ktd2801-v2-2-425cf32e0769@skole.hr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Autocrypt: addr=duje.mihanovic@skole.hr; keydata= mQINBGBhuA8BEACtpIbYNfUtQkpVqgHMPlcQR/vZhB7VUh5S32uSyerG28gUxFs2be//GOhSHv+ DilYp3N3pnTdu1NPGD/D1bzxpSuCz6lylansMzpP21Idn3ydqFydDTduQlvY6nqR2p5hndQg6II pmVvNZXLyP2B3EE1ypdLIm6dJJIZzLm6uJywAePCyncRDJY0J7mn7q8Nwzd6LG74D8+6+fKptFS QYI8Ira7rLtGZHsbfO9MLQI/dSL6xe8ZTnEMjQMAmFvsd2M2rAm8YIV57h/B8oP5V0U4/CkHVho m+a2p0nGRmyDeluQ3rQmX1/m6M5W0yBnEcz5yWgVV63zoZp9EJu3NcZWs22LD6SQjTV1X8Eo999 LtviIj2rIeCliozdsHwv3lN0BzTg9ST9klnDgY0eYeSY1lstwCXrApZCSBKnz98nX9CuuZeGx0b PHelxzHW/+VtWu1IH5679wcZ7J/kQYUxhhk+cIpadRiRaXgZffxd3Fkv4sJ8gP0mTU8g6UEresg lm9kZKYIeKpaKreM7f/WadUbtpkxby8Tl1qp24jS1XcFTdnjTo3YB2i2Rm9mAL2Bun9rNSwvDjE fjM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er-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" On Friday, January 19, 2024 10:02:33 AM CET Linus Walleij wrote: > Hi Duje, >=20 > thanks for your patch! >=20 > On Thu, Jan 18, 2024 at 6:33=E2=80=AFPM Duje Mihanovi=C4=87 =20 wrote: > > Add driver for the Kinetic KTD2801 backlight driver.> > > Signed-off-by: Duje Mihanovi=C4=87 >=20 > Add some commit message? Besides the usual short explanation of the hardware I'd also add a link to = the=20 datasheet in the commit message if that's appropriate. > > +#include > > +#include > > +#include > > +#include >=20 > I don't think you need , the compatible table works without > that (is in the device driver core). Can confirm it compiles without. > > +/* These values have been extracted from Samsung's driver. */ > > +#define KTD2801_EXPRESSWIRE_DETECT_DELAY_US 150 > > +#define KTD2801_EXPRESSWIRE_DETECT_US 270 > > +#define KTD2801_LOW_BIT_HIGH_TIME_US 5 > > +#define KTD2801_LOW_BIT_LOW_TIME_US (4 * > > KTD2801_HIGH_BIT_LOW_TIME_US) +#define KTD2801_HIGH_BIT_LOW_TIME_US = =20 > > 5 > > +#define KTD2801_HIGH_BIT_HIGH_TIME_US (4 * > > KTD2801_HIGH_BIT_LOW_TIME_US) +#define KTD2801_DATA_START_US = =20 > > 5 > > +#define KTD2801_END_OF_DATA_LOW_US 10 > > +#define KTD2801_END_OF_DATA_HIGH_US 350 > > +#define KTD2801_PWR_DOWN_DELAY_US 2600 > > + > > +#define KTD2801_DEFAULT_BRIGHTNESS 100 > > +#define KTD2801_MAX_BRIGHTNESS 255 > > + > > +struct ktd2801_backlight { > > + struct backlight_device *bd; > > + struct gpio_desc *gpiod; > > + bool was_on; > > +}; > > + > > +static int ktd2801_update_status(struct backlight_device *bd) > > +{ > > + struct ktd2801_backlight *ktd2801 =3D bl_get_data(bd); > > + u8 brightness =3D (u8) backlight_get_brightness(bd); > > + > > + if (backlight_is_blank(bd)) { > > + gpiod_set_value(ktd2801->gpiod, 0); > > + udelay(KTD2801_PWR_DOWN_DELAY_US); >=20 > That's 2600 us, a pretty long delay in a hard loop or delay timer! >=20 > Can you use usleep_range() instead, at least for this one? Sounds like a good idea. Should I also make that GPIO pulldown _cansleep wh= ile=20 at it? > > + for (int i =3D 0; i < 8; i++) { > > + u8 next_bit =3D (brightness & 0x80) >> 7; >=20 > I would just: >=20 > #include >=20 > bool next_bit =3D !!(brightness & BIT(7)); Will do. Regards, =2D- Duje