From patchwork Sun Dec 29 11:11:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13922654 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9B67156678; Sun, 29 Dec 2024 11:14:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735470851; cv=none; b=jVIPuTNdKjjcM6yuRir8V7LpqPG/bm2ngqy4oGsrauQkg6v9bCc3YWnvgUHLweNCVXdJg3LUKzy8zulalFnWvk3F4Md/XU5VqSmaMSfWA41pTql+4GIIxaNKbLXJB7TLrmD9H14UZr7YckMVBOfFmEy+IOUNVsURo7sVsxgtT4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735470851; c=relaxed/simple; bh=O3rKEWl5r7FbliJwJ7bQIkLZxxlXeVzYgSqaveO1SG0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ie9F5gVKnWkaIS/5TG07Kmr9v8pDtifOTs/hgivuryhjMcofJy6zFKe/SjYBtMWnJutCnlxklHaVanGlBeYNVufV6jaN58ZCPIxvPlLOIHljsOcjBHt2m3DjI/zZ03a8nD8jNTXwF6kLhxEl2xIZxNRvvBclUAcm0i3LSd7TecY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QCerw5/L; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QCerw5/L" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2156e078563so94013525ad.2; Sun, 29 Dec 2024 03:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735470849; x=1736075649; darn=vger.kernel.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=V0h+wOrNYOq1rWia66zWwU+kYGms7B8E2S8S2isesVU=; b=QCerw5/LQLgBHPhTJoxzV8hz/R6DVRr7QSyAyRiziCc2NnXsTH0SY3hxtAQha8O6uv HdKY3HRwJquYRfQs79YUp9rACvsQ1/cLlQd8gMM/gOFs2Vt7a2QG/31QULRr7plJWVr8 OOuSZfIDJV4ENqrhzEJ8wZdu+SUHlSs8YRMNpO+s+3UiC5qKMHXw0WP+YNH0YqT4ect8 QCO/e0MMbc2cdxOoV+XH8ZHHdXU572Ae68RjUqtIG5M+UIGHR2ScfHtqBBOIVPatSo8D HYIgAhPYjyfdTZ/wb+WJDRnkmAbCdWT2aRVywgi08r15hpcBnlEambboeCnPakbcXFhM 2hjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735470849; x=1736075649; 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=V0h+wOrNYOq1rWia66zWwU+kYGms7B8E2S8S2isesVU=; b=P41R9kbLRPTBQHitMU4NCaLyV1fSf6Ab99VhfUcLBcu7hd05GUIklz4XgTZ0n1De00 k42bJBbm3qGxNtqypWeQzghU7mbc7Q/9M7k6AcXZmuZgKuJxAKazE6KmhWeQ+7FlUB6S 7y/yhmB1KcBdHcdTw+ZAR6uOjCO64TZnGPxoHWhwM8YHanwQh02+6ylZpqgw0AWnPUau ZC7v2WxlaDv8LlHkFqY+hfG3VAecXh+PB2bqoW7krjNyDYiOgZyMKM4BgnUkVRE3HAo6 wK81P9nV30rx++nIqpzUAY0fV1MxvMtN/eGRYwkxzUOe6yBTaOwcfEKvfJ6+2ydJeIEM T9CQ== X-Forwarded-Encrypted: i=1; AJvYcCVPT9FILXuxuo+5xGPQky5AMGzCScjzAAFARTBDCtkMF1F1OvRa962bFlFd5eVXjwpJlRk0velUKOaUmhE=@vger.kernel.org, AJvYcCVxOKpVijSUUXv+mOKK0HkOUR74CFTxmQG/tfgzB+JoLVbf9+YeRrAhyvISuS5uMVSwgUj3jA7rtEfPob8N@vger.kernel.org, AJvYcCWjYTw9yI5Nbd7pSLlTo26GTrgibm8f0HvtifS8qwIrGEnO2xjtHt6DGty6FF+3xztUrppRXff0dSFLIw==@vger.kernel.org, AJvYcCWrHv4PDmhOg1c6jG0XKsOtT4iz5drbmpw634KqzJ/iCI1kOwAVl+83RZw1XB6LhOyCv1nRQdreP2G0@vger.kernel.org X-Gm-Message-State: AOJu0YwhuKGrp9XxR4KlLNditHIEHDZkkFc3wTAE0tdi15h+GIJJrQix Ab/sFqoqmfgKqbxK5Hnl3yWaAtgd9T4MxwROQn4ygaAJA1tHi3Y1 X-Gm-Gg: ASbGnct5Wv9en8mqsAxRFbE8hl4m3M/Ntuf71/+FAqN/MAkIEqQvRsg8yb/iFTOblyO DEeecN2upEycHRlGaB5DHl0iJNgvAaqW0vgWIIAThUz2z3RHv1RJIBQGrN2oB9fC72qOI6thJW6 hXoQO6dggNDRq1vf12H2FXDVEjbwZaXzJjOwb89tmQVENSHxUJ/ovgJlfIaesnGQD2bUZvQNEqe 46S9COEsi2uGAAltnZUdCRSZ3cmPxmKApBFUyjJQxkR83NEvwr361qNXw== X-Google-Smtp-Source: AGHT+IHw2F+g8azy9+A2CTTjFUe3/G4dCC8p/k0dOHQU8Dj6MYf/830XflujqJ4t4aGM+bWVkhywyw== X-Received: by 2002:a17:903:94e:b0:215:96bc:b670 with SMTP id d9443c01a7336-219e6e9df70mr420824845ad.18.1735470849111; Sun, 29 Dec 2024 03:14:09 -0800 (PST) Received: from nick-mbp.. ([59.188.211.160]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-219dca02544sm161655895ad.255.2024.12.29.03.14.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 03:14:08 -0800 (PST) From: Nick Chan To: Hector Martin , 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 v4 RESEND 1/3] dt-bindings: leds: backlight: apple,dwi-bl: Add Apple DWI backlight Date: Sun, 29 Dec 2024 19:11:17 +0800 Message-ID: <20241229111322.4139-2-towinchenmi@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241229111322.4139-1-towinchenmi@gmail.com> References: <20241229111322.4139-1-towinchenmi@gmail.com> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add backlight controllers attached via Apple DWI 2-wire interface. Reviewed-by: Krzysztof Kozlowski 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 Sun Dec 29 11:11:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13922655 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92A4515ADA6; Sun, 29 Dec 2024 11:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735470855; cv=none; b=PzKV1ZYYc8o/Aelg38jjudWsrl3B44FM3WwTULVtp37//yv7Xr7XPQDEPmw89Q9ewJxav8V7cy6ZceH9AyuT/snGW2/TVUfDdRO0Q7+xol9PvPM3GbAac/MPrXvD05iAZWaRkzM3Nz3TjyxOBPZ4QlLMThgFJQYyiF++QdgwDQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735470855; c=relaxed/simple; bh=/NGZcEXzKfllPc1kHyrV4Jpt9+1VCGGg+ROxJ06pXvI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BGavmzl/O3fluaNeXsY5HVUqaDBV6r0Gxx0MwaZyyKCr7920KpBVD1hAU2p/MifdgxG0e2FTcvRINBFP5t2AthiQSdbm6Cd23GzRNXNOCCWdyQ8sUtwTPiL5eYPbKTMv44QCZQ4CW5J9iOvvJJtuN5F8Uqegn1vfMjf44miGKUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EAqefCn9; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EAqefCn9" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-216728b1836so93330915ad.0; Sun, 29 Dec 2024 03:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735470853; x=1736075653; darn=vger.kernel.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=jkHtq9idtKzQ6fNQxVQI03Qs+Bo7JPqfFg778nP11bo=; b=EAqefCn9pPO9id0TfXOE1tJtNfWut5GeFjQ2qkJlnV7SzvoLiwPtGx8tWtMO9TFdC9 UgfN0gFRrjgpAxXmJkuE93B0YAd7CeG4IRm+ozKfYSqATm2x8sRTD2yfaggeapskHqAh g+7W6ZXGQ2484TD75tswHNWmdnAT8egwk9H2zvxM16PkA2liEuKlUWtqLbAKYda71y5e kgJ4fLxma5YbrthRzR/nUcl5EF1kw0Ja2w3AxykheuSJzgNrOVDCtlvXPGwFis6fbHQY zRVryciFStAYzyE9SxpZsKjP29bQ6QNBsqSaFJeOlKQumvHLFL+Emozw5mZa+Y6PQyac OtpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735470853; x=1736075653; 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=jkHtq9idtKzQ6fNQxVQI03Qs+Bo7JPqfFg778nP11bo=; b=l32hHrRwclLdWyjpMA6Zed/A/eaCpbV7Qd3125TXWH9PUS5nukrCFFYpH5Pm+4Jda/ Simex+goij4B7b0ZBywYVkxOy0sNVakJfIAN4HwBzQ8jq4UQNEqWTKAkvzogjjciVCqa C9jFNrWEizfTHs6woExbCzo28/DiFSSxkOGkeweGr0jTzIUq5Kz7WKNyDyk0pR+pSwef a5mq2OJW5KT4uxYO9JFOuCTHqCIkqh/Exh5CFrMLPWBZ65O0bDKxd1C3oRt3TO/K0kqv SP+s3EuTbvds5t2FC5RDHZhyAAAyjXXpwBICJWqg1M9ayCON89040KTTCEJW9evwiope 3buQ== X-Forwarded-Encrypted: i=1; AJvYcCW5yeJf/A1iHKvkoMhOe83/+RTBjwHVnc0vWpQUXRoJ45XnhbeNtekT9VLy6he/Kx3swSZQRVGsxVYbsTM=@vger.kernel.org, AJvYcCWCAK/qilFaJfHjYuiFe1sCdssPqPZ16ojC6tMaN7eTKllFqpKFwLxd9Z7txKYsz2nzvrzRJTZ1hQeNXw2I@vger.kernel.org, AJvYcCWjywUFhOV/ghUNsZ0Sd0KPi6PalyIPPHqCYA5ToHS5ZWfV2IqnsBD71P/BEtJAOcg3tqzwqpKwZFho@vger.kernel.org, AJvYcCX7GKb+qHvHnJ6V827esWVUqmhz0Q3yjHOO2DZ5KzMZODmuKIsSHJesHS1MgyAkE2RBDRMyQhYzg2yR/g==@vger.kernel.org X-Gm-Message-State: AOJu0YzRTntzFOz4g/c0lyCf9HrbIoqkrTSf+6zdu4Hosb3VVStOzfPu H8A9PBsfxxq4jeColeU3m8uwD/TiGQCBSqhWE4JXqGOmKVlHV3w6 X-Gm-Gg: ASbGncu2UKGcuUtsvtkZzSNZdKEmChDeW7PrrwaYgOTfpIcNZJS3pMuEfGVAQvUF7oz Pskf7b5lgeA6sbJ66OTrZd+QG23a0sUhG+MGvI9uHS/fojVKx4Wm2S8T+w0eXJh1pb/EPlXekC+ 7McmFsh/mnAldsJ32e7lRyCyaHBGGn/n/q/q42g0swold7DpE2lWvMYHS43BwIUiP5iFMblUZcn wFA7KB2cBue1lFgxWO3cGZQDCe6WupEOc4TveqK0MMiOTH4+sXKx77Hcw== X-Google-Smtp-Source: AGHT+IEyIi6HUO2JQkKFOryXmvrGOODz762o8X1d/ZKS40A3Z+2xFbGPPKo+iWXpIpSeQRfaF7gWBg== X-Received: by 2002:a17:902:f54e:b0:215:e98c:c5b5 with SMTP id d9443c01a7336-219e6e8c5c5mr484887255ad.1.1735470852783; Sun, 29 Dec 2024 03:14:12 -0800 (PST) Received: from nick-mbp.. ([59.188.211.160]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-219dca02544sm161655895ad.255.2024.12.29.03.14.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 03:14:12 -0800 (PST) From: Nick Chan To: Hector Martin , 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 v4 RESEND 2/3] backlight: dwi_bl: Add Apple DWI backlight driver Date: Sun, 29 Dec 2024 19:11:18 +0800 Message-ID: <20241229111322.4139-3-towinchenmi@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241229111322.4139-1-towinchenmi@gmail.com> References: <20241229111322.4139-1-towinchenmi@gmail.com> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. Signed-off-by: Nick Chan --- drivers/video/backlight/Kconfig | 12 +++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/dwi_bl.c | 122 +++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 drivers/video/backlight/dwi_bl.c diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 3614a5d29c71..debb1326df63 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -290,6 +290,18 @@ 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 + default y + 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 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..45cc80d9ae22 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) += 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/dwi_bl.c b/drivers/video/backlight/dwi_bl.c new file mode 100644 index 000000000000..59e5cad0fbd8 --- /dev/null +++ b/drivers/video/backlight/dwi_bl.c @@ -0,0 +1,122 @@ +// 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_RAW; + props.max_brightness = DWI_BL_MAX_BRIGHTNESS; + + 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 = "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 Sun Dec 29 11:11:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13922656 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 183DC172BD5; Sun, 29 Dec 2024 11:14:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735470859; cv=none; b=CkIJge5lRgCvun8KuPQzJc8QZbMqTS79l4JUiJCcXMT8pSUYUP2eiR1YqVXvmzk+kN96y8tyOhH2EIO96VCNMFlxAEgJBe+mmNFJBYOp/zHqgALxXsJH0l7OyFB3N+34hXwCk9Rx0Ygv/qWreA9ZiDslTb3HyFRj+qEN0aQ9CvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735470859; c=relaxed/simple; bh=YYeDbhIsCX0ErJFbadBI6Svg8sUwSIAIaRJnDZ+vcPE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dxPC8INwmtZgEKXnF6EPR3iJ9/Lb/AD3XpWeXWWLRjixBgw4h9Ld+msTve/RqTEg0dvwNsuiQ1KiOyNu6b1kka0vAjhXz7qWNhzcZIOCr+1JQMi4DqTjb/ewYOO4F/URXW+Xnc1+MYFFK4GivV1kfPfIufmJ2r/nsZDCH4+pIR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lWOh41HU; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lWOh41HU" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-21654fdd5daso100430185ad.1; Sun, 29 Dec 2024 03:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735470857; x=1736075657; darn=vger.kernel.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=a9J38BNMU1Uzv4f7FCoN1Yfwc75lF73CELPPui56iYw=; b=lWOh41HUYl/tr9k1VTy+2B83r8Z8sLC6gr/QdYyg508EqjYX5w3AObaXgpXdR1eO8J 70Y6/kM1k8uFgmJMajFakpw+DgrxxxCxRRZjflqtJx2kIjkJNn4PQgLlrbqG40u+Znr1 hxT+ywR8HmaXKtnQ2QIuYpPksC+sjvL92bPgRTG+OXSqn49djhTvgWOn4iIEba2NGDV4 Yv5c/kTn+on7M6+6XpPfzm/yREW7GIcDjDxyjClazFy5j0Om1wbC78fhGV1aP9Tf/xz3 GQ0c47HTMr6YocqizcXHLoCWv7s40/4TPPwZKFayiEPkvofSKPS1wIC8rFo6hEpkBbhi sE1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735470857; x=1736075657; 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=a9J38BNMU1Uzv4f7FCoN1Yfwc75lF73CELPPui56iYw=; b=kKrIu1zM2UkFUNL7+jTpueesYQ1tpzbQdS/IgOAS5toa52aaebDG0ct9NwKzzjGk0e OdPdPGnd/m5dXN23BVQcycC71d8BAFSQDSj2NHKerl7q79n/F+eEm+S14r/l1FhuXHRh NOttM8Vl4hHXK1cc5wnYGsecLKCj5V2V8aZD9LqA6IyGhQRC7r3xdcbLSgb74GpJ35fK +mL+ibzTJf0kSe/FQy5XeuXaGjFiJFtFN0yv/RFCsskpX/DGU2N3qFlbBZySBnAoWMnd R9rw/lA9WKxN7uu6B2qBnSQDVL3aQA7swFpr7w14H7G+we2VO5j0nJXmf9hndkIA6bPv xHnQ== X-Forwarded-Encrypted: i=1; AJvYcCV3q7h+E/3WES9GfN77LM2MsNAUMGmtaMAeSUWzXdYC4K+tQV7/atz+Z6kpcf85rVufoWkA/aDALRQj@vger.kernel.org, AJvYcCVqWPeTT1gxWtSISwCKg5H7GDfA9Eno7PfJNmSVUEjKBh+vZm9HiNKTJ97/2woMWyzwTXB2lOdDVO3iKZSC@vger.kernel.org, AJvYcCW9cJC9D74mff2VW9yLWSFOiTJUTBoSTJ3oennuVZkdvepMLkdNGNub4bwcyM13LsUNzn+k1wWFwT0Y5Q==@vger.kernel.org, AJvYcCXdaerqE5HDNCcqEW1JqjansfEMwLxpSRRrFeUG4TqOC8goLdOcQx8BGySR5jSsALexo1a4Z+1DUfCaiG0=@vger.kernel.org X-Gm-Message-State: AOJu0YyYUiVNXdgDdvsYJwHd61WMhRq6zM5bXAAlGc94VwiaECmnN+8L nAyfnfYUlh8ba1NVY4Rl7cNtBRMWwVt5OizlOus0XOGhUfRvVDWM X-Gm-Gg: ASbGncsFAWbSMY1PaE3UdH5/+0N/5Jdl2pnomE3rVdjuSqj317rhBOYWJm0PfNhNPw1 Ey7585DEaZSKjA7TTLPdf4puJU+KTkbL7DAKw7ZINJ9y4yIJzP3dBCIfs7Svg/MF/MtYwzIBx+i yBMbMOIMVfOrOG1+QBlub5VY+svAKpdZ7FwUloLWRnvAItrLVGWZ9+aRtJ4qusmr0+Sj0OJMzqQ iLg2QTwMd8V4PLUPqHWIYhRZROlcnxPHDjx2GjAMRq/ZZq4+OkeRNMptg== X-Google-Smtp-Source: AGHT+IHj1y3F1X3HGHzS3Px3LuQKUEyT2NVI7IfSKzHwkiIrQ3sJyJpJf3UtrIia+cnNqjNTX6LRiw== X-Received: by 2002:a17:902:c412:b0:216:4972:f8e0 with SMTP id d9443c01a7336-219e6f2ffb4mr459732985ad.44.1735470857377; Sun, 29 Dec 2024 03:14:17 -0800 (PST) Received: from nick-mbp.. ([59.188.211.160]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-219dca02544sm161655895ad.255.2024.12.29.03.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2024 03:14:16 -0800 (PST) From: Nick Chan To: Hector Martin , 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 v4 RESEND 3/3] MAINTAINERS: Add entries for Apple DWI backlight controller Date: Sun, 29 Dec 2024 19:11:19 +0800 Message-ID: <20241229111322.4139-4-towinchenmi@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241229111322.4139-1-towinchenmi@gmail.com> References: <20241229111322.4139-1-towinchenmi@gmail.com> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add MAINTAINERS entries for the driver. Signed-off-by: Nick Chan --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 910305c11e8a..54a6c8ca7017 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2196,6 +2196,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 @@ -2221,6 +2222,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/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