From patchwork Fri Feb 14 04:02:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13974434 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C36B8C02198 for ; Fri, 14 Feb 2025 04:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Bvsk07Lzw6XdWgB2cdXk97Y7I1cSDuStLmoSGezH+tI=; b=07bWfVpqmtzRtxo3xLu7b4lvTz sX9UQQE4G9Y4h2Bc99T1Ak8AXiawry86peBNvdGVKaSO6Hvi9czQsxFGKjsvuaBp7J+h/cKPYV9Wv r7RdyO88fU4di9IHeFzHdqQ+W/XbHH+d+/mS8sdbIXBHKa+iPlny0icGHZU/8XOOq9RuYx7WhVLyq R945Y8JhiG6tlHIv8bvC7Qjfg78uylTDFTIW9ccexE7CdvrdXuWxyTBlLHyIy/A4o0rKk85k0UWFk M8Q/EakI740s6UPAxVtWTwvUHQGuA4nno9XL8rxk3NwgM2hWycMRGI8vCl8Coy3qOlyd+az273YJP VDjKxbRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1timyg-0000000DZ5j-1iwS; Fri, 14 Feb 2025 04:06:58 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1timvw-0000000DYbH-1CgB for linux-arm-kernel@lists.infradead.org; Fri, 14 Feb 2025 04:04:09 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2fc32756139so51394a91.1 for ; Thu, 13 Feb 2025 20:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739505847; x=1740110647; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bvsk07Lzw6XdWgB2cdXk97Y7I1cSDuStLmoSGezH+tI=; b=m1elYkFfv+yO466p0OKLEJeqw1chQHYff5BcWgYFUFtpxeQcthAlqxLe1g3PcYtkMY VtinhQEOzYvkfgRlnJx4tNiiyC+YuhBZgloi5OmSh5ykBSSuZOwy5/U+9M67xT9SdGD2 f214OW1dG5wQqCyXOrKr87UrafsO/zvYBe6GDgTrnvLkTWclUWpCkQEvE630GFxjFEz+ bBhLZ25dcxmIr76ezkNMGKSIgAyJNlkQbwQdQPza5Jrgt3OuzH6YePaYcC66+JmQriaY IkwUOE2Ayz67zhGDsU/e0HzZJKnp3HLU4aS1jbws3hUvup6I65vJ9FpZUaE1t8T6qO8v xLnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739505847; x=1740110647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bvsk07Lzw6XdWgB2cdXk97Y7I1cSDuStLmoSGezH+tI=; b=EL5xQghX5M26PqaMx3ofMSEWrgmdLpyrhhNb7gyvCJV88EQKF79rvZQEPtV8s8n7k0 Z4IUzFzUCETkfoBoEXZVozbVq7nTQC/x6K52f7TTN/rBYpuUB39AQ4LVgJc9lY1MhY9a TA75fSef/VnNKq0aBA0gS+RlyXW4JajVnNtrJNNGOA9dM2E/PHOdoZJIUMii9ZMj6oF6 OmDy8wFXzICZ27P4sncZN7mk+CIkHZe6Q7KnGXW7cwJUs7rfPGiPWRw7QKO0LDy5smwv Jk1becay0Jq4CLKAQn0V7sXxmJihPIgD+vCbjGkCliupPJ9avwDqg7euGd49Q6zdz7jZ QLmw== X-Forwarded-Encrypted: i=1; AJvYcCUeV33BGpcIVjEMwoAJ1ljpDyBXWs9Ta7TYdOkMP+FWq/LbPUM9q/VUeEIxGdTlCQk9U+EXBNQ5Z0l6vAH5vaxK@lists.infradead.org X-Gm-Message-State: AOJu0YydNs0nbS9tVjbQkdGCj2vVsk3JyvI7EOEOiYWyJID8xvPvXzEf VYnPLl25iEm5uvgoYl72dcIPKdEWnfg2UjbeVOz7RIrAD/pNsvcH X-Gm-Gg: ASbGncuouWGzj5+YT0ZyYG/XRSL7OkaMYKZTy4wNoTs1xkRGHrq04Sj56kpKNG5TlZ8 xVPzzqXIBTSUaaVgYM9qJ49tEUBMd3lxWyRvwGhnfvK6jV/+kNJJA9yHuWoSyfWl6byPBv3O15G /i2g8KRfaCzyHTfRdG+I1hXS4lLk/2/4Zp8p5sbY4z/3ICnyY2VOMsI/JYXf4XxiCNYBSIl+RAK O+iEI5a/OJu/PuG0gEepXpEa4E1yfCuRXe6dzXm/Wl8EbLYqoRHSi+xaVs3SfwS4XPFiDwh6tzA swfkXVjO1OGzBqc= X-Google-Smtp-Source: AGHT+IGgz94u5dSaKE5PwBYaLjtoVurlg0X6dABIb3PB35R+FknVncdnfvcsPkYesVe9CLDNkNni2w== X-Received: by 2002:aa7:8894:0:b0:725:9f02:489a with SMTP id d2e1a72fcca58-7322c3f4d96mr13423478b3a.17.1739505847127; Thu, 13 Feb 2025 20:04:07 -0800 (PST) Received: from nick-mbp.. ([49.130.17.220]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-7324273e3e7sm2181227b3a.91.2025.02.13.20.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 20:04:06 -0800 (PST) From: Nick Chan To: Janne Grunau , Sven Peter , Alyssa Rosenzweig , Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Helge Deller , Nick Chan , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH v6 1/3] dt-bindings: leds: backlight: apple,dwi-bl: Add Apple DWI backlight Date: Fri, 14 Feb 2025 12:02:12 +0800 Message-ID: <20250214040306.16312-2-towinchenmi@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214040306.16312-1-towinchenmi@gmail.com> References: <20250214040306.16312-1-towinchenmi@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250213_200408_322784_D7FCE025 X-CRM114-Status: GOOD ( 13.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add backlight controllers attached via Apple DWI 2-wire interface. Reviewed-by: Krzysztof Kozlowski Reviewed-by: Daniel Thompson (RISCstar) Signed-off-by: Nick Chan --- .../bindings/leds/backlight/apple,dwi-bl.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml diff --git a/Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml b/Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml new file mode 100644 index 000000000000..29caeb356e6f --- /dev/null +++ b/Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/backlight/apple,dwi-bl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple DWI 2-Wire Interface Backlight Controller + +maintainers: + - Nick Chan + +description: + Apple SoCs contain a 2-wire interface called DWI. On some Apple iPhones, + iPads and iPod touches with a LCD display, 1-2 backlight controllers + are connected via DWI. Interfacing with DWI controls all backlight + controllers at the same time. As such, the backlight controllers are + treated as a single controller regardless of the underlying + configuration. + +allOf: + - $ref: common.yaml# + +properties: + compatible: + items: + - enum: + - apple,s5l8960x-dwi-bl + - apple,t7000-dwi-bl + - apple,s8000-dwi-bl + - apple,t8010-dwi-bl + - apple,t8015-dwi-bl + - const: apple,dwi-bl + + reg: + maxItems: 1 + + power-domains: + maxItems: 1 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + dwi_bl: backlight@20e200010 { + compatible = "apple,s5l8960x-dwi-bl", "apple,dwi-bl"; + reg = <0x2 0x0e200010 0x0 0x8>; + power-domains = <&ps_dwi>; + }; + }; From patchwork Fri Feb 14 04:02:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13974435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B083C021A4 for ; Fri, 14 Feb 2025 04:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=THGbXf//SrScK+32A3BUuAqCods80KxGwHDBckzXHsI=; b=uWWIEtRSVM4itdAnM8O6P6vKD6 0AUwP55BHqkcAJOJXFi9LorKHxgyjwAcaC1qY1qtZZoBgoNdU6uea2paWSgss3FN0OVyZSUgleweE e7ye3cRUuXCQiDEIfXmSC6gDQWIhnEdxSbgJIZTuXHDdsSYsBEUnnxlf08tzU59/4dxnhg7zn0pAe R6OWbG301tpVFpFKidADJV5CiWxo/33H6+vhbXoQ6f3dhCGltd57u4JnWe7nTh5m1WOc3ljb2vNmd +j7pK9hdK31EuzYLz0p3/qJ+yfLXRTBPxha4sEyeXLuW8s+kLGqtzZjsTP56/E0A5BGnwXWLg8tLp na3lImDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tin05-0000000DZGg-0LZW; Fri, 14 Feb 2025 04:08:25 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1timw2-0000000DYdX-14Tt for linux-arm-kernel@lists.infradead.org; Fri, 14 Feb 2025 04:04:15 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21f92258aa6so42275585ad.3 for ; Thu, 13 Feb 2025 20:04:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739505853; x=1740110653; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=THGbXf//SrScK+32A3BUuAqCods80KxGwHDBckzXHsI=; b=bgSHGLKkgnBL63czeZDcTrMqwgwSLoWJ3687sBHY5tWnor8VGLe9GTM22TFIUNSWWI YP6MpJft+Cw2SnjHVl+wzpBrjGZXh5Q0FmH9+rplXV5FjnYPt3TMz2vG6tT/0qE59ZVQ Jfs8a5gm9XClhtl1sBXgWVcfgftRhz/23AJPJRa09VK0tR3hlySCE+nEyM/e62oihl5j eE8dxcZ9OUV/yFINQuWJq9tPU+cVd8AtTYDff8CN91EM+o5vPXMEV+jMAs+deg042P1B hstiPyMKhfQr92MjcbrltOyPDffdwzODOZixWWAcSdgmhkKZMW/SyhxMW3Tpe9kVlH6D +eMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739505853; x=1740110653; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=THGbXf//SrScK+32A3BUuAqCods80KxGwHDBckzXHsI=; b=qz43bv7525pgNniy6F77/lNBPlrkvzbuRMHTF+zxdoacBz5FGfZnEQtSaXfV2AAp2N uIxcuzRrXnM2K/z7bwHIgbLIPvU1/oFxPYvfs0n29vCxMFZU79gwzrnGseFpN3jouV8t uEBPHyamDkHwWP5CnBOww7DVCL1GNiQZIVwqSTvwfq8/ODlXSwNDMg/KO4LrOMWUaXCG 8K7lhUICgpNT/YRgCLMyIkP5MKqk+CunsZO3SdRr4KoIobWq8rVzHOzg7JjSygaORMjL ATxKELZa8u1a+NRKZbOJWlNsuyj1CHOqifNIzKdJH4fswGugb/5AGDcMCZHXmwHSulWs nh3g== X-Forwarded-Encrypted: i=1; AJvYcCWClU/kPkDTisP7V7WLHnHxRZc1LasEhLSqpqFEJ+jzbSTW75Au0gW3eITLQiPXGRpy31MYgrObBYVIiXQsGwCj@lists.infradead.org X-Gm-Message-State: AOJu0YwB49ltlSUeBL4VMO56DaxzelIgkvR0BItR9LxGmDdlJe693KjX 3g9FPKC10aHQ7y107KHWbBtQNzBDY5cGLGj0oz08f7Euy/GUFDzR X-Gm-Gg: ASbGncs/INUaNoW0FV2ty5vsiY7HZDuZ4LBVB8aqDpJolQw459OcnDGjbIKdE2Q4HRj qDQ/Ng9yUeOL/k5WrpINWxtwoRRKc5ZbWSQ91JyQU+dkZoH17PNlitB4Tj991SXOXPgySGopk4+ CXYfea+7+0/+MIGmuBkwEqvN9B+cr3Q0lMAUzj7xfAtS8I9ZIZJ5I8F+SPYXtEnq6SvTvz+O4AQ u28w3F/ra45FXdpppB9xAHDE3/wKw2+Q8adT0GXEOUJWA1mjca27CQIA0JJhRMkaanzu8H34uYG lYDONWzvWecZjq0= X-Google-Smtp-Source: AGHT+IGxivn76yELBYxib0w0BFCjx4VgWlcePDuyKrKPnZS1ISzc7Gxg04wRI/FeWDE8mSYuN0bpnA== X-Received: by 2002:a05:6a20:2585:b0:1ed:a812:8860 with SMTP id adf61e73a8af0-1ee5c796e7fmr16856578637.25.1739505853270; Thu, 13 Feb 2025 20:04:13 -0800 (PST) Received: from nick-mbp.. ([49.130.17.220]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-7324273e3e7sm2181227b3a.91.2025.02.13.20.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 20:04:12 -0800 (PST) From: Nick Chan To: Janne Grunau , Sven Peter , Alyssa Rosenzweig , Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Helge Deller , Nick Chan , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, 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: [PATCH v6 2/3] backlight: apple_dwi_bl: Add Apple DWI backlight driver Date: Fri, 14 Feb 2025 12:02:13 +0800 Message-ID: <20250214040306.16312-3-towinchenmi@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214040306.16312-1-towinchenmi@gmail.com> References: <20250214040306.16312-1-towinchenmi@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250213_200414_292488_1F790348 X-CRM114-Status: GOOD ( 23.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add driver for backlight controllers attached via Apple DWI 2-wire interface, which is found on some Apple iPhones, iPads and iPod touches with a LCD display. Although there is an existing apple_bl driver, it is for backlight controllers on Intel Macs attached via PCI, which is completely different from the Samsung-derived DWI block. Reviewed-by: Daniel Thompson (RISCstar) Signed-off-by: Nick Chan --- drivers/video/backlight/Kconfig | 11 +++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/apple_dwi_bl.c | 123 +++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 drivers/video/backlight/apple_dwi_bl.c diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 3614a5d29c71..cee113bba30f 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -290,6 +290,17 @@ config BACKLIGHT_APPLE If you have an Intel-based Apple say Y to enable a driver for its backlight. +config BACKLIGHT_APPLE_DWI + tristate "Apple DWI 2-Wire Interface Backlight Driver" + depends on ARCH_APPLE || COMPILE_TEST + help + Say Y to enable the backlight driver for backlight controllers + attached via the Apple DWI 2-wire interface which is found in some + Apple iPhones, iPads and iPod touches. + + To compile this driver as a module, choose M here: the module will + be called apple_dwi_bl. + config BACKLIGHT_QCOM_WLED tristate "Qualcomm PMIC WLED Driver" select REGMAP diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 8fc98f760a8a..156ff9461fb3 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o obj-$(CONFIG_BACKLIGHT_ADP8870) += adp8870_bl.o obj-$(CONFIG_BACKLIGHT_APPLE) += apple_bl.o +obj-$(CONFIG_BACKLIGHT_APPLE_DWI) += apple_dwi_bl.o obj-$(CONFIG_BACKLIGHT_AS3711) += as3711_bl.o obj-$(CONFIG_BACKLIGHT_BD6107) += bd6107.o obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o diff --git a/drivers/video/backlight/apple_dwi_bl.c b/drivers/video/backlight/apple_dwi_bl.c new file mode 100644 index 000000000000..93bd744972d6 --- /dev/null +++ b/drivers/video/backlight/apple_dwi_bl.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Driver for backlight controllers attached via Apple DWI 2-wire interface + * + * Copyright (c) 2024 Nick Chan + */ + +#include +#include +#include +#include +#include +#include + +#define DWI_BL_CTL 0x0 +#define DWI_BL_CTL_SEND1 BIT(0) +#define DWI_BL_CTL_SEND2 BIT(4) +#define DWI_BL_CTL_SEND3 BIT(5) +#define DWI_BL_CTL_LE_DATA BIT(6) +/* Only used on Apple A9 and later */ +#define DWI_BL_CTL_SEND4 BIT(12) + +#define DWI_BL_CMD 0x4 +#define DWI_BL_CMD_TYPE GENMASK(31, 28) +#define DWI_BL_CMD_TYPE_SET_BRIGHTNESS 0xa +#define DWI_BL_CMD_DATA GENMASK(10, 0) + +#define DWI_BL_CTL_SEND (DWI_BL_CTL_SEND1 | \ + DWI_BL_CTL_SEND2 | \ + DWI_BL_CTL_SEND3 | \ + DWI_BL_CTL_LE_DATA | \ + DWI_BL_CTL_SEND4) + +#define DWI_BL_MAX_BRIGHTNESS 2047 + +struct apple_dwi_bl { + void __iomem *base; +}; + +static int dwi_bl_update_status(struct backlight_device *bl) +{ + struct apple_dwi_bl *dwi_bl = bl_get_data(bl); + + int brightness = backlight_get_brightness(bl); + + u32 cmd = 0; + + cmd |= FIELD_PREP(DWI_BL_CMD_DATA, brightness); + cmd |= FIELD_PREP(DWI_BL_CMD_TYPE, DWI_BL_CMD_TYPE_SET_BRIGHTNESS); + + writel(cmd, dwi_bl->base + DWI_BL_CMD); + writel(DWI_BL_CTL_SEND, dwi_bl->base + DWI_BL_CTL); + + return 0; +} + +static int dwi_bl_get_brightness(struct backlight_device *bl) +{ + struct apple_dwi_bl *dwi_bl = bl_get_data(bl); + + u32 cmd = readl(dwi_bl->base + DWI_BL_CMD); + + return FIELD_GET(DWI_BL_CMD_DATA, cmd); +} + +static const struct backlight_ops dwi_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, + .get_brightness = dwi_bl_get_brightness, + .update_status = dwi_bl_update_status +}; + +static int dwi_bl_probe(struct platform_device *dev) +{ + struct apple_dwi_bl *dwi_bl; + struct backlight_device *bl; + struct backlight_properties props; + struct resource *res; + + dwi_bl = devm_kzalloc(&dev->dev, sizeof(*dwi_bl), GFP_KERNEL); + if (!dwi_bl) + return -ENOMEM; + + dwi_bl->base = devm_platform_get_and_ioremap_resource(dev, 0, &res); + if (IS_ERR(dwi_bl->base)) + return PTR_ERR(dwi_bl->base); + + memset(&props, 0, sizeof(struct backlight_properties)); + props.type = BACKLIGHT_PLATFORM; + props.max_brightness = DWI_BL_MAX_BRIGHTNESS; + props.scale = BACKLIGHT_SCALE_LINEAR; + + bl = devm_backlight_device_register(&dev->dev, dev->name, &dev->dev, + dwi_bl, &dwi_bl_ops, &props); + if (IS_ERR(bl)) + return PTR_ERR(bl); + + platform_set_drvdata(dev, dwi_bl); + + bl->props.brightness = dwi_bl_get_brightness(bl); + + return 0; +} + +static const struct of_device_id dwi_bl_of_match[] = { + { .compatible = "apple,dwi-bl" }, + {}, +}; + +MODULE_DEVICE_TABLE(of, dwi_bl_of_match); + +static struct platform_driver dwi_bl_driver = { + .driver = { + .name = "apple-dwi-bl", + .of_match_table = dwi_bl_of_match + }, + .probe = dwi_bl_probe, +}; + +module_platform_driver(dwi_bl_driver); + +MODULE_DESCRIPTION("Apple DWI Backlight Driver"); +MODULE_AUTHOR("Nick Chan "); +MODULE_LICENSE("Dual MIT/GPL"); From patchwork Fri Feb 14 04:02:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13974436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BC27C02198 for ; Fri, 14 Feb 2025 04:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Uc4uCqsleGcCsKVC2kCtafnEyIcpxj+3QblkARK4r2c=; b=f4SV+nd7wQxolfxiZvyuAK3Pq0 o8K2d4Lngt4plKv3VL3ZcRiHhYL8wrQyFuTgK9Gr0FBHYDci97CcsmiMwFkwJ+XVBDH0znV0j3wBG Z/xpeaaM/hhZSxvYae80spl7q1sF5FWogmfDBjKIAp3tNH98UUSwzb786unMxwHbEa9WRzK6eg5Qy mOJWupjrJZLBA+8Id0MIJ+c5Y8SZ26VPLDd542/eZgT7/eS384RhpLk+2/qjK/JvJugUcEoc207kW k1rstvsBxD7WZBC+2n+17IijYFyZ93wnjjYmxzobVp2/MfLTUCyI3grKWSJArQJ3A5PnL4wYpYxa8 EygdPZhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tin1U-0000000DZNt-0g4a; Fri, 14 Feb 2025 04:09:52 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1timw8-0000000DYfw-0Qor for linux-arm-kernel@lists.infradead.org; Fri, 14 Feb 2025 04:04:21 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-21f5660c2fdso32443345ad.2 for ; Thu, 13 Feb 2025 20:04:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739505859; x=1740110659; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Uc4uCqsleGcCsKVC2kCtafnEyIcpxj+3QblkARK4r2c=; b=NBcqwnDngQnMlviqdGGn5q9sCfPJlz1Prz0B5Ij4QekQY8+xpO/ilPnA0HVz8I667z s4jcbrV7+jXqdVjc231ao8IOdcN29XB4UZMp/vPwxFyHX+e1LLJ2SP6OfxcVO/S4TPXn i4khp1FbOmH7eEVtpvIF2xEhxUacPie0Z8sOtn5MQjKjbKTq/lwoZJpPeBpKnGJQK651 k07VYIYEy3iE4qiN7hB0VU6EpVYM4xCaZo1BxiBLdWkW54QnpED8cgXDwf/l6c3igIBK 6hRAMhTxKWOLKxkKUJ04fupBZ9E3GJ6X5etAPLAZIYyZTptSdvhBl2u8hMkMADypCVdu FLvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739505859; x=1740110659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uc4uCqsleGcCsKVC2kCtafnEyIcpxj+3QblkARK4r2c=; b=JbTHOHyyIhykwp4HiDwYY8mo0TMiXfCp62Dz1rjshLQwnqIUw1/JvUzKa/MnMtC7PL uigLSnVqc+gptELKrWy+3p3zKle1BYeklMdsKfHthPyv+gPozBBeUMhwOyPF6LwV9Ava MOTHlK5K/FcKo3Uu3whTbU+btPm5woiiu2FvwJh7MFcm5JWX2u4AEy75EHYpSIZHnP86 lsc5XIf34H+BOLMAWRj/MH6T++CDQABwhPg+SHI6VWpj8kWUVhAALIOGMj+gxQAqmYMF Rf42UEoFkt3iWvCHmW37s4nG21Z//nULy9SYtFwDag2Uszu5T9p7MBBOlMt06iZslDWJ V4JA== X-Forwarded-Encrypted: i=1; AJvYcCWV9ZmEHy5HUrr+NqcIfcshG4WAe3R3kif+F/dzoEPJjSztlQb7gLgj4fLdjeg4zvj6Mq2GLzBFGQiVWaQx/PK3@lists.infradead.org X-Gm-Message-State: AOJu0YxZVsaVAqlqXJSSe+j0Mikkqenh6rSsF8bFi0sByBh0lBA5eY55 23Ux0WUKqu80JjrQ3UHG9IXS5nWaxVRbnXPayvKKYMuxk3VjcbPJ X-Gm-Gg: ASbGncsmJ2JEofHdgUMhtMj/TrutFnbue2ayxFZaZazDaXIBRN9Z4EYzTStmqcPjOHd ZqabKqB2M/4gr9fQXQoAfk9+RCq59DXWnewRvJVEQLL/AR6m7ZnJEDVn0YOcj2YsgaYVIv2vkW4 xOtbhyNA5y+uC4vj9hKsB5mxGj6P0WcXvC8IeBM1ivU7kgCKjBfAROTdr0rygrJwRFF7TEyvQlj d/jmuvjmJKWW3pcDCdM9CeA7r0gvjac4b6izRrkUNSHrpCr6S5vuwanDEHOoy5f/B9jD++wZUF/ PQaEU9SaRm9nLGQ= X-Google-Smtp-Source: AGHT+IHkN1crcRx1umsgU8oqxNqZWEWNVP7TrG7rSyx2t22hQspF82Y6IBy/bUusVKbjj5NHW6Qt4w== X-Received: by 2002:a05:6300:614a:b0:1ee:1bc6:2341 with SMTP id adf61e73a8af0-1ee6b2fe438mr10767975637.15.1739505859444; Thu, 13 Feb 2025 20:04:19 -0800 (PST) Received: from nick-mbp.. ([49.130.17.220]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-7324273e3e7sm2181227b3a.91.2025.02.13.20.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2025 20:04:19 -0800 (PST) From: Nick Chan To: Janne Grunau , Sven Peter , Alyssa Rosenzweig , Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Helge Deller , Nick Chan , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, 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: [PATCH v6 3/3] MAINTAINERS: Add entries for Apple DWI backlight controller Date: Fri, 14 Feb 2025 12:02:14 +0800 Message-ID: <20250214040306.16312-4-towinchenmi@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250214040306.16312-1-towinchenmi@gmail.com> References: <20250214040306.16312-1-towinchenmi@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250213_200420_138292_80D15A8F X-CRM114-Status: GOOD ( 10.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add MAINTAINERS entries for the driver. Reviewed-by: Daniel Thompson (RISCstar) Signed-off-by: Nick Chan --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 896a307fa065..a576324807f5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2228,6 +2228,7 @@ F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml F: Documentation/devicetree/bindings/interrupt-controller/apple,* F: Documentation/devicetree/bindings/iommu/apple,dart.yaml F: Documentation/devicetree/bindings/iommu/apple,sart.yaml +F: Documentation/devicetree/bindings/leds/backlight/apple,dwi-bl.yaml F: Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml F: Documentation/devicetree/bindings/net/bluetooth/brcm,bcm4377-bluetooth.yaml F: Documentation/devicetree/bindings/nvme/apple,nvme-ans.yaml @@ -2253,6 +2254,7 @@ F: drivers/nvmem/apple-efuses.c F: drivers/pinctrl/pinctrl-apple-gpio.c F: drivers/pwm/pwm-apple.c F: drivers/soc/apple/* +F: drivers/video/backlight/apple_dwi_bl.c F: drivers/watchdog/apple_wdt.c F: include/dt-bindings/interrupt-controller/apple-aic.h F: include/dt-bindings/pinctrl/apple.h