From patchwork Mon Dec 2 09:47:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846813 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 3F1721FBE91; Mon, 2 Dec 2024 09:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132890; cv=none; b=OCxL/BHKsx3rgqUdZDODxi9WiNpbQSmYXx1+oR0id9h3Mj3DLFEDJq4aeDtzh9XKlcqlfWrqVjMYD34nbg1JUGimNRD8/R7MqApCy5ULrauU7Hzx4zrP/DTI/KSzfpJACOgpq0WTloNYCTGtggmRkOcGKTyIfY2672K4FBtqzx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132890; c=relaxed/simple; bh=tdGTuOCygyKLTzrZkn4w+l/pmKktzi0hDq2Y4cLiQJI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aGfm4QhBxpO29FC3sPLIme6o9QkWq0RGLc/TfmhEDG4LlmSENQZziZdxCdUihMytQzvIk53Z0H/tQvE4vzOXtgKCZC7UYddbyX/n7v1pvc6LzXBq/45oYpxKD6w7Z15ixT+lX0uL8xxv6hsmtu7Uk0qRXHMMTAvGhlM71qMdWrQ= 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=JQPt6Asa; arc=none smtp.client-ip=209.85.218.53 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="JQPt6Asa" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aa530a94c0eso660814866b.2; Mon, 02 Dec 2024 01:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132887; x=1733737687; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FKMQu9Put2whTLlJmXR7bTTxcNbkqOf+6o99Kc/4Euo=; b=JQPt6AsaOfPmvZ+N+L6FgragsTyriJGhbg8y/5OwiWQZBWP0h7aK6YT3oG7MSSW7tw 5TYwYCcreShaUcc3d6sXBEnE5gOrRDiWW2UU1z/gkiC1XuedZRi5t/qt3HmNbX61Hm1o r2ZXD8l7rXkXi2SIsLjSQ3+uXbZBcwd1/G1cQAD7iMo7C8fs8u9B1A+AhK42/huriVzB qowQ4vmuZlsTxPobnVwBPbscVP/kFF/HCV5sJ/AAnx/AOswq8TPbpTGkO4XBaeKq4/FS /753fAQpU4lXuMKViutYdktm4xmtE/kdmDqqohmxH3wgVlu1/gwbitUgHjQnMC8esqzn RZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132887; x=1733737687; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FKMQu9Put2whTLlJmXR7bTTxcNbkqOf+6o99Kc/4Euo=; b=kHlGhuoZUZvMfyoQHAdEGGpQVJqzVEBx9AcremVVpLKzM5a4D5tmaOzmvc7YRMfhHp OT8brkKXGtf2544DJceJLr8ecnezP7215JgEks+7ldeZz3AwIyQzZXntPpxIDv1mink2 l6E7Lxb51blSSqxCkASh44zyFM/Vg2QXcuATbLncWW6WMczuhg0c8a/pNuGG9bEgpyWN HiH3X0MTs2U8mhjd8VIyt5hvG4u+n1Y38cAD0bqbALkYh0haPC/sYDlSEo5/uf+AoMmA jbNfEO0RzKz8x2ALn25fbMYNRLrjmMtnCizjJeb5fqngESpKKHxhCbV5vbFttsCl44ig 1Pzg== X-Forwarded-Encrypted: i=1; AJvYcCVvvKCNvt589nz2cjpon5HFiDcpVBgIqxtxDfDYHhp3w/eCAPq7CLyjZLsYQaQqIBxp8awQeagl2y3t@vger.kernel.org, AJvYcCX6agzsN2eWypjfJ1xs9OlqkIqBK+v/IVslY1fpI3Rib6Vkv5p4EIm6vLJYuFHVpO0IsXQGKUbNxeLjR4U=@vger.kernel.org, AJvYcCX8rmw4h5/J8NsSnplcvOHOAFetkPwsX9lKuNnZdN5aykM502hobcyIGwOzrEUtNAhNZaLI7O3vKeI0gg==@vger.kernel.org, AJvYcCXNm96/+Ph6R0rNF3LEnt72evjdAM+rAhSCGCcInRQteqIMWuZvsyEyeLF/Hv77tpwu7my9iCAdtlFpi61P@vger.kernel.org X-Gm-Message-State: AOJu0Yzr+MVpBdgJ7dLA36GcwItLuaV3dXBfOJuFVcoBimltANM/Ri8S mD3HzeN47ncR23hvcfXz/zj+oyG+29QN9Ovvbr8TTZVKmZmp/URa X-Gm-Gg: ASbGncuGp/PeLPwZWB+S5ccZjLbNGTRu6VmD2EvPcqzv69HH43IvqH26FaFEkr9kzks RfPt/AIsIPcIuEmjJbl+UplVLmKkPmP9S5IJO9jy7XRSAbBl6mEPywcpEgOwejAo3AKJxF4XVl9 uTs9uKzcNhjmsnE9LbtqbT/34nsw/ZXSnETmQzrLh8isTqp6ZCpFigi4TKaTnsJPLh/NEWYX5y9 EMt1mq3hJZWj121EnKG54GXO0YmuyXuIbB5Dh/jTIlQHQdZ X-Google-Smtp-Source: AGHT+IGJh660APdyPaRenyDkc/Sr6gQpwtz0yPFS9TqaLYSUTvYP7MviS1z06zKjqFW8zY4aBMR2JQ== X-Received: by 2002:a17:906:3085:b0:aa5:35fc:cc21 with SMTP id a640c23a62f3a-aa580f2be0cmr2006372366b.19.1733132885771; Mon, 02 Dec 2024 01:48:05 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:05 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:54 +0300 Subject: [PATCH v9 1/9] power: supply: add undervoltage health status property Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-1-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=2343; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=tdGTuOCygyKLTzrZkn4w+l/pmKktzi0hDq2Y4cLiQJI=; b=xgO7pUxB26f/cMg2PFnh0BWsWGEwTE43hhHhmBylkVzSIk0phGl5iDzv9a2RN9E29v/RE2Sfo SkWeE3g0OqFCD8L2zzkOcmnADJQxwSpXCbyH/WR2A7tjgeK34zuwKIc X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add POWER_SUPPLY_HEALTH_UNDERVOLTAGE status for power supply to report under voltage lockout failures. Signed-off-by: Dzmitry Sankouski --- Changes for v5: - update Documentation/ABI/testing/sysfs-class-power and drivers/power/supply/power_supply_sysfs.c --- Documentation/ABI/testing/sysfs-class-power | 2 +- drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 45180b62d426..32c018c5d088 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -433,7 +433,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", - "Over voltage", "Unspecified failure", "Cold", + "Over voltage", "Under voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", "Over current", "Calibration required", "Warm", "Cool", "Hot", "No battery" diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 571de43fcca9..247c2910ba34 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -99,6 +99,7 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_OVERHEAT] = "Overheat", [POWER_SUPPLY_HEALTH_DEAD] = "Dead", [POWER_SUPPLY_HEALTH_OVERVOLTAGE] = "Over voltage", + [POWER_SUPPLY_HEALTH_UNDERVOLTAGE] = "Under voltage", [POWER_SUPPLY_HEALTH_UNSPEC_FAILURE] = "Unspecified failure", [POWER_SUPPLY_HEALTH_COLD] = "Cold", [POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE] = "Watchdog timer expire", diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index b98106e1a90f..e96d262f3c2b 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -58,6 +58,7 @@ enum { POWER_SUPPLY_HEALTH_OVERHEAT, POWER_SUPPLY_HEALTH_DEAD, POWER_SUPPLY_HEALTH_OVERVOLTAGE, + POWER_SUPPLY_HEALTH_UNDERVOLTAGE, POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, POWER_SUPPLY_HEALTH_COLD, POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, From patchwork Mon Dec 2 09:47:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846812 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 8E61A1FC0FE; Mon, 2 Dec 2024 09:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132893; cv=none; b=GHwTQukh6uHexlx3FbP5GEaoIkZK2NK5WqY4OsAysmBBXEtyHcnsyfmGoNkzxjEZ0cVxPLQYNlm9LkVgx8NhIqJvEPvwJZWYNq0MPF0WOMkbgBMAWda9xmuY+FNFSLlzFSCbTlfPoNkGMLqmblre/9Dis0rwPHSFGB6YYmkc//0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132893; c=relaxed/simple; bh=kSoIMsEyI5FQ+mbQvFip9d0Bq8H/VWKwGdAEJhaEXzU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uvk0wjFcN/CtouIvG1sy/dS+Y8rzNq7ZHMl1Dg/xOIlDSRGS5zPygU3Y8Qk8QpaXGX3Zno2oDiqVkSVZ1alWdI9zdSIQz7TgnqJJBqeXukLpFKG+Nsbc3usPD4poHO7kbI2PKxQayQtEZRfXwX7TIGVFhUZsLns5oqoEhdnz2EI= 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=YJ3OgW0j; arc=none smtp.client-ip=209.85.218.41 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="YJ3OgW0j" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a9a0ec0a94fso535980066b.1; Mon, 02 Dec 2024 01:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132890; x=1733737690; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ROh+ssRkigaZFqJs0rde83s3PLdGc63hrLp1rlTw+Eg=; b=YJ3OgW0jJmvEi6v5e3/tsiaj0hh8xI2t6C/tpdM/ToUfkNE3kevi293tICKpDE5kAI gKZhoIxqbOkOntp3XmJPf/1EqcoPXG5AAAX/9/QR1GH7xhV3n8rs+0IxR/fttye8mMxH gohPqi/NVEb2iYqbAIpAP7UblToZ2msURrTF1gxXEbZ+sH9ag3m39t03f6cH97ml9kNt bMuTmqzeRcIT5MjSzAPWH3p73vqs+30T2CTYGIvuy4vz29Gk1DQSoFY4I1Su0YMYJ72z vQVpDrn5yp0EUwaMGY2v/FcGE+jwh1C1TLDhxL1aCkjk9kQ35TMPNzUBjeyITTspCXqD vp5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132890; x=1733737690; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ROh+ssRkigaZFqJs0rde83s3PLdGc63hrLp1rlTw+Eg=; b=q0w152kIvnwTr9Phsy1Q1Jnf3CWgiF/bKpVHZYm2xa7HTfcfymR3/jFL+IR9hKLtbA sale/n2ETHaIa1IIP5v43FC5viphBGgn/2SGL7VcOW2aeBqlc5yquHFtW/aP6cSuwdzq D/R5ZlG3X0tLavyYJY+vmxA7AHgymUa4ozW75QguyJq8hkMkNr/G/QbnWKaPOkQI0a9D DBfJSq98ydontxOeKTU0PrT7TA1z4mIWFIj1WI5II3CFvebp6nDGKhzu79ApcbDi6vs5 Puoza+JdtX9B3cSb6zPk/frIyxU1UEUHNF+c2Hzl6tjo3buR9cGzbgrIkeRO7kq6JaU3 Pm7A== X-Forwarded-Encrypted: i=1; AJvYcCWGTeuMgeX9mMdk1UD3gKls5tG2ooQJe9OX2dNepDU1/N8GWL+1U/LEQ3f7eJyxpcRa+Zn9hrb2EZrOmeWy@vger.kernel.org, AJvYcCWJibu/Xg3R43ONU3ZDgvrzH0TGsCYpTwpupGRNI0GA7YvaTDPPsrA/wqWKfk6Aq7WkEMXeFVA4iPIMDA==@vger.kernel.org, AJvYcCX308EBmEubISn5y07pRmKNaYhIdlqyaoVUof0iEwdIFnEB4fHpEq6w33GLSU0SRMR7sY4LeYDvOodz@vger.kernel.org, AJvYcCXdKlKru5UkQyRlqxxImjlllTEOmlGzIGXjr6Y389QtGmg5ZxtBMSL9gZXu4EPsPv9IidyDkY88LbHMljE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy86lnq3koIRJeNOVqWmxy25e4hVIgEm0SBm8TnA1ivn9n4ZXuL w5Kpow1uTA2zFHGkEBydepmtNiaAf8B46h7SsGE8aIuStk9gFBvG X-Gm-Gg: ASbGncveteE+oU1JnawbnusT5TojG3anvJjskN1APv+LPrnErFPNYV2761+D786EyTC hkwFMWZRQZ41SsFUKgUE5ptKc30C4An9u2fww2y3SUydgLYt+ZmupQ5vShvEH90dl4PqpGn56h0 Pol6kKhLyKgIZN2FRqh7W/OGaCWas+7UEZ/XnM/U6glWiBkysLF718hcUTtoWLjLJD8PZmDaiPC XCKQMablWpuB/cWhR7ieQLxnHKbonMg6K6Yrh9T857bWQSQ X-Google-Smtp-Source: AGHT+IG8Db/Agjn5e1HtabRO5f1TOXAQx/7QpO92hEeRm/dqL0aQHHy2kwrWGo5egZag+7w+i1K+bQ== X-Received: by 2002:a17:906:9d2:b0:aa5:4104:4a8c with SMTP id a640c23a62f3a-aa581044168mr1788011766b.40.1733132889666; Mon, 02 Dec 2024 01:48:09 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:09 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:57 +0300 Subject: [PATCH v9 4/9] dt-bindings: mfd: add maxim,max77705 Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-4-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=5789; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=kSoIMsEyI5FQ+mbQvFip9d0Bq8H/VWKwGdAEJhaEXzU=; b=EjAneaGYwe7c+6qfiStq/18Xmwg3lgHXm/wVxX56HBfndpbD4B8AD3oGCYGn+dqShrvCa8NxN LySSX//jckcAqJb44Mj9e5zBNxYqIYU7D1Rdv3RjQt5QFmBdxMCn7hn X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 binding. Reviewed-by: Rob Herring (Arm) Signed-off-by: Dzmitry Sankouski --- Changes in v9: - replace max77705 fuel gauge with max17042 - remove monitored battery because not supported by max17042 Changes in v8: - fix leds compatible Changes in v6: - unevaluatedProperties must be false - drop excessive sentence from description, just describe the device - change leds compatible to maxim,max77705-rgb Changes in v5: - formatting changes - add unevaluatedProperties: false for nodes referencing common schemas - remove additionalProperties on nodes with unevaluatedProperties: false - add min and max to led index Changes in v4: - change dts example intendation from tabs to spaces - remove interrupt-names property - remove obvious reg description - split long(>80) lines --- Documentation/devicetree/bindings/mfd/maxim,max77705.yaml | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 156 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file mode 100644 index 000000000000..fbc264cfc609 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml @@ -0,0 +1,155 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC + +maintainers: + - Dzmitry Sankouski + +description: | + The Maxim MAX77705 is a Companion Power Management and Type-C + interface IC which includes charger, fuelgauge, LED, haptic motor driver and + Type-C management IC. + +properties: + compatible: + const: maxim,max77705 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + charger: + $ref: /schemas/power/supply/power-supply.yaml + unevaluatedProperties: false + properties: + compatible: + const: maxim,max77705-charger + + required: + - compatible + - monitored-battery + + fuel-gauge: + $ref: /schemas/power/supply/maxim,max17042.yaml# + + haptic: + type: object + additionalProperties: false + + properties: + compatible: + const: maxim,max77705-haptic + + haptic-supply: true + + pwms: + maxItems: 1 + + required: + - compatible + - haptic-supply + - pwms + + leds: + type: object + additionalProperties: false + description: + Up to 4 LEDs supported. One LED is represented by one child node. + + properties: + compatible: + const: maxim,max77705-rgb + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^led@[0-3]$": + $ref: /schemas/leds/common.yaml# + type: object + unevaluatedProperties: false + + properties: + reg: + description: LED index. + minimum: 0 + maximum: 3 + + required: + - reg + + required: + - compatible + - "#address-cells" + - "#size-cells" + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@66 { + compatible = "maxim,max77705"; + reg = <0x66>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&chg_int_default>; + pinctrl-names = "default"; + + leds { + compatible = "maxim,max77705-rgb"; + #address-cells = <1>; + #size-cells = <0>; + + led@1 { + reg = <1>; + label = "red:usr1"; + }; + + led@2 { + reg = <2>; + label = "green:usr2"; + }; + + led@3 { + reg = <3>; + label = "blue:usr3"; + }; + }; + + max77705_charger: charger { + compatible = "maxim,max77705-charger"; + monitored-battery = <&battery>; + }; + + fuel-gauge { + compatible = "maxim,max77705-battery"; + power-supplies = <&max77705_charger>; + maxim,rsns-microohm = <5000>; + }; + + haptic { + compatible = "maxim,max77705-haptic"; + haptic-supply = <&vib_regulator>; + pwms = <&vib_pwm 0 50000>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 1240e75ecf4b..c3f66093edd1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14185,6 +14185,7 @@ B: mailto:linux-samsung-soc@vger.kernel.org F: Documentation/devicetree/bindings/*/maxim,max14577.yaml F: Documentation/devicetree/bindings/*/maxim,max77686.yaml F: Documentation/devicetree/bindings/*/maxim,max77693.yaml +F: Documentation/devicetree/bindings/*/maxim,max77705*.yaml F: Documentation/devicetree/bindings/*/maxim,max77843.yaml F: Documentation/devicetree/bindings/clock/maxim,max77686.txt F: drivers/*/*max77843.c From patchwork Mon Dec 2 09:48:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846811 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 C0E6A1FBE9B; Mon, 2 Dec 2024 09:48:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132897; cv=none; b=fk93bSznJFMUDCXmcgkhPxdV+sFlQPbR8IpPvj5s+fOJI3FzZIb2DHW/TyKiZ5g+e+6rSlL88HKIuXsOv71GrJB3affh4K+9kM/sLGTGvnkXxksRYGsn99yYUDwCkkUSolTAB/SlWe8NsHKIoyUb1aUgz15z072FBMN0yZ2kKNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132897; c=relaxed/simple; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nNU2LaZD8GwCr3KUyd5IF1esYgdUAGeypVSiMlsH1pGA0u4vsL1zB4KwznWrBXCXDPUbaKP0vvj1nEgY2MwVXCVPNhhFD3L3K269oZP1Xkj1ry8sWBiNX6kbmyhiMdOi4I2woQgcY3VhUWTOtBehtt8PZJIQZQCcXSp0ZfV3K/U= 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=Wa8RtJbc; arc=none smtp.client-ip=209.85.167.46 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="Wa8RtJbc" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-53df63230d0so4749567e87.3; Mon, 02 Dec 2024 01:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132894; x=1733737694; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7hehp6Fk0LGkDDofz88Jg2c9t6Nm0JquDsf7Y75Rrc0=; b=Wa8RtJbcqLlAmmo7GtU4csuU9J5kNUdtdJ6b3NGBo+jvrGNMvBzKSGou/9vS9BfCsJ T7hPqioLyipq8ZxnwxJcM1+o+X4m2yOvVCC/VqKqzzMbxX+yMlbD4OoaUe3bNN+vBwZT VGXlHkWhrDAWGEL0mFGAyv2hxV08zVGulY3oULHWCOSYceYfxz1k4/VYOkwc7aCP5b4f wT1vo0MKJXwUT0aj7ghb6W9Yy/okhQPBOjjo0k2PTjrLvkzWhbgDDw38AmOTEXt5Ir4a HaFzM+gOwB+I1DFx3sOeU70v6a2Mc9axguvXGj73aqBGAJA1Ju7ftxG4QshYePsD2VFS EPDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132894; x=1733737694; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7hehp6Fk0LGkDDofz88Jg2c9t6Nm0JquDsf7Y75Rrc0=; b=puLHuf+32twbJO8YOQS9+xSLkq9fpcupKO6/nrrBlpa6D0m3Tkp/IKBqzu+PrlRBlb A/I2rRAr3afnZH6Oq1NrGz3OMZgplHyY3Ayv8R4fmv3dbwoKrkTOgiAz7vEAEAE46QlA vpPFMAlAzGjt6BOMhLMnDFHG2qe6ngb+pRoy4y7nmcaMgbgUxAhm0hjD2Ze7e5LjC4Uh VaADEPas3m9h6gmqZRgK9ynz6ONVeawNX+KehUd32O4bl8EvEftfjAWsbXrj3/lfd/oT 5rik1XgTPSdUzu/Wu29h5sY4q7RByD5JswSpPsc1hzfBxGjCmU7R+v4v5G4FjLLebkk5 4R6w== X-Forwarded-Encrypted: i=1; AJvYcCUvN+/wH1OjnNxcsGPM4khx0f5vvUG4fRZDGzjJnBhKP/g17zl0Y0GcAVcMjJgJtxtDhg13Tlc+T018@vger.kernel.org, AJvYcCUyE3YA37kuXEU5qU1WPLtPm+MX0tRUkcFKs7G6io8OX5xmHJoV5qahtOkbiRjEcOgstQ8FYhvdNWCslMWq@vger.kernel.org, AJvYcCWikQRZYGBNpzCrwcvbVbjSssKHDu4DL791Y3MiPg2RW73vO58mx++N8BBB14LbOcSEczCzfEnTAvQgRrk=@vger.kernel.org, AJvYcCWxWQV6wr9ZIgtbDJzlEGeD+ascqAxQWehaAgWorbdSZNd5HjYffIzvZYMchHyyGR18rFACDO4yJTEfaw==@vger.kernel.org X-Gm-Message-State: AOJu0YwTTeCYmr2+slTeOio4x9taGcoW3N/fcUFswYcCpxC2PdXYnPaU NUKNH0atkAuFvU8MIqUryWTPPZuk8YAAEqDAZxUHgxCWocVYNA2f X-Gm-Gg: ASbGncuNCUTsS1jm40dlWYW9cjuse4v62o9N5XDW9LOE/2lVB+IhmHtIox+9cTURoO5 GzO0O7hvD+TJpUOiFAGU9Q73DHb4aM+pJyQoYEno43gHx1cUQjF7EhJ6WbXjomYI/ef+UN3DEYR cF/z5cjCdYRiL2fB9MK4lm9TdVXFvD/8KMHToBjzRz+maWrqVoOLKj2T95qPNCl0UTRusHl8cW/ 1s91I0lkqY+Z9Rimvf4iofyEbmztLeYC8JIYr6dyhbZFyfu X-Google-Smtp-Source: AGHT+IFy8nKAQ/+EZGxu8B3T/ru6KKXg8q4mm69HrTLXSsWCE/wGfNtxj/ujG6Lv0PSykozra5Q99Q== X-Received: by 2002:a05:6512:3f1f:b0:53d:dc02:794f with SMTP id 2adb3069b0e04-53df00c6085mr11967885e87.2.1733132893443; Mon, 02 Dec 2024 01:48:13 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:13 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:48:00 +0300 Subject: [PATCH v9 7/9] input: max77693: add max77705 haptic support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-7-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=4280; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; b=c9Uc8al4EyOOH5r5xins8idhHLAwnltQUeKqsgz6o8D/IqBs8bozF8+96zhQEJR8vKvPfQPlh 00feA+j3VdZBTzK73kRkgo/kHiHsP3bowtsPOJuh9uKxDBTkYYfAGJW X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add support for haptic controller on MAX77705 Multifunction device. This driver supports external pwm and LRA (Linear Resonant Actuator) motor. User can control the haptic device via force feedback framework. Acked-by: Dmitry Torokhov Signed-off-by: Dzmitry Sankouski --- Changes in v4: - add max77705 haptic support to max77693 driver - delete max77705-haptic --- drivers/input/misc/Kconfig | 4 ++-- drivers/input/misc/Makefile | 1 + drivers/input/misc/max77693-haptic.c | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 6a852c76331b..b4515c4e5cf6 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -241,11 +241,11 @@ config INPUT_MAX77650_ONKEY config INPUT_MAX77693_HAPTIC tristate "MAXIM MAX77693/MAX77843 haptic controller support" - depends on (MFD_MAX77693 || MFD_MAX77843) && PWM + depends on (MFD_MAX77693 || MFD_MAX77705 || MFD_MAX77843) && PWM select INPUT_FF_MEMLESS help This option enables support for the haptic controller on - MAXIM MAX77693 and MAX77843 chips. + MAXIM MAX77693, MAX77705 and MAX77843 chips. To compile this driver as module, choose M here: the module will be called max77693-haptic. diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 4f7f736831ba..3e3532b27990 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o +obj-$(CONFIG_INPUT_MAX77705_HAPTIC) += max77705-haptic.o obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c index 0e646f1b257b..c3b9d33608d7 100644 --- a/drivers/input/misc/max77693-haptic.c +++ b/drivers/input/misc/max77693-haptic.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #define MAX_MAGNITUDE_SHIFT 16 @@ -115,6 +116,13 @@ static int max77693_haptic_configure(struct max77693_haptic *haptic, MAX77693_HAPTIC_PWM_DIVISOR_128); config_reg = MAX77693_HAPTIC_REG_CONFIG2; break; + case TYPE_MAX77705: + value = ((haptic->type << MAX77693_CONFIG2_MODE) | + (enable << MAX77693_CONFIG2_MEN) | + (haptic->mode << MAX77693_CONFIG2_HTYP) | + MAX77693_HAPTIC_PWM_DIVISOR_128); + config_reg = MAX77705_PMIC_REG_MCONFIG; + break; case TYPE_MAX77843: value = (haptic->type << MCONFIG_MODE_SHIFT) | (enable << MCONFIG_MEN_SHIFT) | @@ -312,6 +320,9 @@ static int max77693_haptic_probe(struct platform_device *pdev) case TYPE_MAX77693: haptic->regmap_haptic = max77693->regmap_haptic; break; + case TYPE_MAX77705: + haptic->regmap_haptic = max77693->regmap; + break; case TYPE_MAX77843: haptic->regmap_haptic = max77693->regmap; break; @@ -407,6 +418,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, static const struct platform_device_id max77693_haptic_id[] = { { "max77693-haptic", }, + { "max77705-haptic", }, { "max77843-haptic", }, {}, }; @@ -414,6 +426,7 @@ MODULE_DEVICE_TABLE(platform, max77693_haptic_id); static const struct of_device_id of_max77693_haptic_dt_match[] = { { .compatible = "maxim,max77693-haptic", }, + { .compatible = "maxim,max77705-haptic", }, { .compatible = "maxim,max77843-haptic", }, { /* sentinel */ }, }; @@ -432,5 +445,5 @@ module_platform_driver(max77693_haptic_driver); MODULE_AUTHOR("Jaewon Kim "); MODULE_AUTHOR("Krzysztof Kozlowski "); -MODULE_DESCRIPTION("MAXIM 77693/77843 Haptic driver"); +MODULE_DESCRIPTION("MAXIM 77693/77705/77843 Haptic driver"); MODULE_LICENSE("GPL"); From patchwork Mon Dec 2 09:48:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846810 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 245021FDE1A; Mon, 2 Dec 2024 09:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132900; cv=none; b=lOaQ7PuO7kGPCestd4iu+m1UiIJGaG9nmduxdH9WgWhLtPBgQ+2FdT94uGzk0VZKBYAMxGyGNRo65RYP0YpBhghCZY6SFp6wRvoXVtVXS4/VcctDOEXuHtmCaLxLmqmUAJCI5sKr7wfyRiuw7ZvItKUzSuSSeVxGg4b4kAMSl5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132900; c=relaxed/simple; bh=nNKdt6aAQ4O8gBwlr5BJKCp3j+YjqzXknQ+peKB2yLI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jp3nJaISAMrp5WxDVa75wwEB3FQm0NsL93KCtPcR42624cctiflqjxozYX+96BRvpff2yACn1J5qR+X97K/E5GywIWKjQOb1NMrqIeitvDdyMPfQ0jzAArwSUQIbh9GheouuqWQHa51cJTHz1YXCo0pHhfFkaEjBKCXM9CUmpx0= 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=I7BCR6/J; arc=none smtp.client-ip=209.85.218.48 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="I7BCR6/J" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aa5366d3b47so658983666b.0; Mon, 02 Dec 2024 01:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132896; x=1733737696; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7LBTuoCDOxxqO2y3YAKj2vln0gXaFFLFmx9hGGgry74=; b=I7BCR6/JorJiUQBCeQOLi9aerEJyRZPtO2yg74ByHkP/zrFkojUiBPjdO6VxdGZlyt Zv22/G392VPKV7knFn2f8Xkl7G4VpL4Lps/gJ7K2UGPQL8u4FxXEHcnjM1/fod7IAnie ijPV9+DynSMcK/UOi4c14LZcxncNhLW2djQrRkKkbnCIow5xW6yPPKcG8vJNxBbn/uG4 waxCEziGUc3Pyrj4nK/aVxY23VfIY6cg1Lgt1VwPQ1oiMCtCrFJqLgsCSaOkPuLO2ae7 a9oS4ryGs0rVMd+7GJzbJyDYSL/6pnMhqe0E7liCI/fq1bBwTD3qoY6I6K9KZCgEh8KI L9Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132896; x=1733737696; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7LBTuoCDOxxqO2y3YAKj2vln0gXaFFLFmx9hGGgry74=; b=TxHTRn/TsrRYk6/wlodrYzobX6oFUFs/MupgfpSJ0keMHEKOgRF3eHkgLWCaeHruLX FqbHKp1WIPGCjTq1XLFRXRDdAFwFE7A14wckzaSiAfNXkRRTDB+v2ZI+M1A/jbwVZYyA 7hw6HO7Cy6dRcI+8Q0CCljwNGXvrIwJ3zhUqli3sswCGEuQGYFM/zU1RakCjrmXGWdHX eyoWI7G3Xlb5KYI09Perkh9/Nw4boOnRVFMlrI8iXe6sAHtrRH1WaiRV0jkRlgjNKDAe teoFjQ45n1xj7e35m7qiq6T665cPnZtT3/Nz/roN4tSBWjbm0vB27enMQT3ChOcl2SHU 6Zwg== X-Forwarded-Encrypted: i=1; AJvYcCUO+e8Fs5Ozk3u3DOp1u/jWti4bwQJ3XxDjXU7MqGCtdNGVgZi53nGGuM6RNwzKDIow8XVnyEpZ7CUB@vger.kernel.org, AJvYcCUmFSaICuR2uLg1jzFlCzIUep7T553g3bLTMo1ddGXRuJh2/ht5Y6SME2++vxE8sMLK5EtkWioBTAEzFw==@vger.kernel.org, AJvYcCUvmyMlYl9pf1+Gr95rxVcfouJCCZNcTcztw7+iRLz5nOz18BailVwstSBuLhfUQ1grOMf2gk+nEnmJXjgN@vger.kernel.org, AJvYcCXvZw5kseB8T6fkP88ktw05K+i4yZEF9ee+VQeBF8hN5gY/FF5jIy3CUvkQPW9OCBt+fdhEyY3VSyQ7+BU=@vger.kernel.org X-Gm-Message-State: AOJu0YzBkob99VrBUDWqNavejnHRn4u+hahEgqLySrXqbOhUlXaEs4Yn +dMVmCFMKCgn0iRM1ncUdDAani8GQPWbjBlmAo0n0NPJSOe0EwGrYraZMJGw X-Gm-Gg: ASbGncsaVI4fHIHL1qUlKdIfv1vbuUeViwUPwuqWXuCBygwblq1wnz4jG8TFlIkr6ce GJ1sqjDB4Kl6z0LPJmWkFaUQYYSgaERXERM2gWYHArq8R8/ddP3MZvx9OU2oIjyUdZrPll5lDzn D8Gnsu1m1EYv9+rl6c8mcCDYGzvoRsOxLuiMOhfNaBdW2ui06BSg11mmM/lXZfRMXLz79v4OW4H xfx1cQ3VrlHqzrmKCLg5wD1m+ErrMTjyiJB5UcwoHX8HfiX X-Google-Smtp-Source: AGHT+IHsaeJj8mT7GOA42WhtBau+dDuXWqOnDvfQuTAh9WNbaNkUzyrQhibpZTRFojC5RUS0VNNy/Q== X-Received: by 2002:a17:906:329b:b0:aa5:241a:dc75 with SMTP id a640c23a62f3a-aa58103b03amr2068889466b.41.1733132896299; Mon, 02 Dec 2024 01:48:16 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:15 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:48:02 +0300 Subject: [PATCH v9 9/9] leds: max77705: Add LEDs support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-9-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=9372; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=nNKdt6aAQ4O8gBwlr5BJKCp3j+YjqzXknQ+peKB2yLI=; b=lqOL710ADYdroNvivLFtJqxDW/B2k0YIEfUdTW1AoSgfn6y4OztdCSKy404OknY/71n9B739U SmwXihpZKFcDE83MuGFeiDdNsMETjse/ldrlO+TaBki7RoBzSq0Vn3i X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= This adds basic support for LEDs for the max77705 PMIC. Signed-off-by: Dzmitry Sankouski --- Changes for v8: - join line where possible to fit in 100 chars - change comment style C++ -> C Changes for v6: - change compatible suffix to 'rgb' - remove I2C dependency in Kconfig - remove copyright and author from 'based on' header statement - replace MFD abbreviation with PMIC - MAINTAINERS: alphabetic order - max77705_rgb_blink: replace ternary operators with if..else if sequence - max77705_rgb_blink: move hardcoded numbers to constants - max77705_led_brightness_set: move ret to the bottom - s/map/regmap - replace device_for_each_child_node with scoped version - s/rv/ret Changes for v5: - use same hardware name in Kconfig and module descriptions - remove copyrighter owner from module authors Changes in v4: - inline BLINK_(ON|OFF) macro - remove camel case - drop backwards compatibility(new driver) - drop module alias --- MAINTAINERS | 1 + drivers/leds/Kconfig | 6 ++++++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77705-private.h | 18 ++++++++++++++++ 5 files changed, 193 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index b269d0456da3..7a21e871ba7c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14188,6 +14188,7 @@ F: Documentation/devicetree/bindings/*/maxim,max77693.yaml F: Documentation/devicetree/bindings/*/maxim,max77705*.yaml F: Documentation/devicetree/bindings/*/maxim,max77843.yaml F: Documentation/devicetree/bindings/clock/maxim,max77686.txt +F: drivers/leds/leds-max77705.c F: drivers/*/*max77843.c F: drivers/*/max14577*.c F: drivers/*/max77686*.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index b784bb74a837..27ce55b32543 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -753,6 +753,12 @@ config LEDS_MAX77650 help LEDs driver for MAX77650 family of PMICs from Maxim Integrated. +config LEDS_MAX77705 + tristate "LED support for Maxim MAX77705 PMIC" + depends on MFD_MAX77705 && LEDS_CLASS + help + LED driver for MAX77705 PMIC from Maxim Integrated. + config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 18afbb5a23ee..096bf244527d 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_LEDS_LP8860) += leds-lp8860.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o +obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c new file mode 100644 index 000000000000..29db23702231 --- /dev/null +++ b/drivers/leds/leds-max77705.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on leds-max77650 driver + * + * LED driver for MAXIM 77705 PMIC. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include +#include + +#define MAX77705_LED_NUM_LEDS 4 +#define MAX77705_LED_EN_MASK GENMASK(1, 0) +#define MAX77705_LED_MAX_BRIGHTNESS 0xff + +struct max77705_led { + struct led_classdev cdev; + struct regmap *regmap; + unsigned int en_shift; + unsigned int reg_brightness; +}; + +static struct max77705_led *max77705_to_led(struct led_classdev *cdev) +{ + return container_of(cdev, struct max77705_led, cdev); +} + +static int max77705_rgb_blink(struct led_classdev *cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct max77705_led *led = max77705_to_led(cdev); + int value, on_value, off_value; + + if (*delay_on < MAX77705_RGB_DELAY_100_STEP) + on_value = 0; + else if (*delay_on < MAX77705_RGB_DELAY_100_STEP_LIM) + on_value = *delay_on / MAX77705_RGB_DELAY_100_STEP - 1; + else if (*delay_on < MAX77705_RGB_DELAY_250_STEP_LIM) + on_value = (*delay_on - MAX77705_RGB_DELAY_100_STEP_LIM) / + MAX77705_RGB_DELAY_250_STEP + + MAX77705_RGB_DELAY_100_STEP_COUNT; + else + on_value = 15; + + on_value <<= 4; + + if (*delay_off < 1) + off_value = 0; + else if (*delay_off < MAX77705_RGB_DELAY_500_STEP) + off_value = 1; + else if (*delay_off < MAX77705_RGB_DELAY_500_STEP_LIM) + off_value = *delay_off / MAX77705_RGB_DELAY_500_STEP; + else if (*delay_off < MAX77705_RGB_DELAY_1000_STEP_LIM) + off_value = (*delay_off - MAX77705_RGB_DELAY_1000_STEP_LIM) / + MAX77705_RGB_DELAY_1000_STEP + + MAX77705_RGB_DELAY_500_STEP_COUNT; + else if (*delay_off < MAX77705_RGB_DELAY_2000_STEP_LIM) + off_value = (*delay_off - MAX77705_RGB_DELAY_2000_STEP_LIM) / + MAX77705_RGB_DELAY_2000_STEP + + MAX77705_RGB_DELAY_1000_STEP_COUNT; + else + off_value = 15; + + value = on_value | off_value; + return regmap_write(led->regmap, MAX77705_RGBLED_REG_LEDBLNK, value); +} + +static int max77705_led_brightness_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct max77705_led *led = max77705_to_led(cdev); + unsigned long blink_default = 0; + int ret; + + if (brightness == LED_OFF) { + /* Flash OFF */ + ret = regmap_update_bits(led->regmap, + MAX77705_RGBLED_REG_LEDEN, + MAX77705_LED_EN_MASK << led->en_shift, 0); + max77705_rgb_blink(cdev, &blink_default, &blink_default); + } else { + /* Set current */ + ret = regmap_write(led->regmap, led->reg_brightness, brightness); + if (ret < 0) + return ret; + + ret = regmap_update_bits(led->regmap, + MAX77705_RGBLED_REG_LEDEN, LED_ON << led->en_shift, + MAX77705_LED_EN_MASK << led->en_shift); + } + + return ret; +} + +static int max77705_led_probe(struct platform_device *pdev) +{ + struct max77705_led *leds, *led; + struct device *dev = &pdev->dev; + struct regmap *regmap; + int ret, num_leds; + u32 reg; + + leds = devm_kcalloc(dev, sizeof(*leds), MAX77705_LED_NUM_LEDS, GFP_KERNEL); + if (!leds) + return -ENOMEM; + + regmap = dev_get_regmap(dev->parent, NULL); + if (!regmap) + return -ENODEV; + + num_leds = device_get_child_node_count(dev); + if (num_leds < 0 || num_leds > MAX77705_LED_NUM_LEDS) + return -ENODEV; + + device_for_each_child_node_scoped(dev, child) { + struct led_init_data init_data = {}; + + ret = fwnode_property_read_u32(child, "reg", ®); + if (ret || reg >= MAX77705_LED_NUM_LEDS) + ret = -EINVAL; + + led = &leds[reg]; + led->regmap = regmap; + led->reg_brightness = MAX77705_RGBLED_REG_LED0BRT + reg; + led->en_shift = MAX77705_RGBLED_EN_WIDTH * reg; + led->cdev.brightness_set_blocking = max77705_led_brightness_set; + led->cdev.blink_set = max77705_rgb_blink; + led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS; + + init_data.fwnode = child; + + ret = devm_led_classdev_register_ext(dev, &led->cdev, + &init_data); + if (ret) + return ret; + + ret = max77705_led_brightness_set(&led->cdev, LED_OFF); + if (ret) + return ret; + } + + return 0; +} + +static const struct of_device_id max77705_led_of_match[] = { + { .compatible = "maxim,max77705-rgb" }, + { } +}; +MODULE_DEVICE_TABLE(of, max77705_led_of_match); + +static struct platform_driver max77705_led_driver = { + .driver = { + .name = "max77705-led", + .of_match_table = max77705_led_of_match, + }, + .probe = max77705_led_probe, +}; +module_platform_driver(max77705_led_driver); + +MODULE_DESCRIPTION("Maxim MAX77705 LED driver"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h index be781a0f9802..2140693ce747 100644 --- a/include/linux/mfd/max77705-private.h +++ b/include/linux/mfd/max77705-private.h @@ -35,6 +35,24 @@ #define MAX77705_SYSTEM_IRQ_SYSOVLO_INT BIT(5) #define MAX77705_SYSTEM_IRQ_TSHDN_INT BIT(6) #define MAX77705_SYSTEM_IRQ_TM_INT BIT(7) +/* MAX77705_RGBLED_REG_LEDEN register */ +#define MAX77705_RGBLED_EN_WIDTH 2 +/* MAX77705_RGBLED_REG_LEDBLNK register */ +#define MAX77705_RGB_DELAY_100_STEP_LIM 500 +#define MAX77705_RGB_DELAY_100_STEP_COUNT 4 +#define MAX77705_RGB_DELAY_100_STEP 100 +#define MAX77705_RGB_DELAY_250_STEP_LIM 3250 +#define MAX77705_RGB_DELAY_250_STEP 250 +#define MAX77705_RGB_DELAY_500_STEP 500 +#define MAX77705_RGB_DELAY_500_STEP_COUNT 10 +#define MAX77705_RGB_DELAY_500_STEP_LIM 5000 +#define MAX77705_RGB_DELAY_1000_STEP_LIM 8000 +#define MAX77705_RGB_DELAY_1000_STEP_COUNT 13 +#define MAX77705_RGB_DELAY_1000_STEP 1000 +#define MAX77705_RGB_DELAY_2000_STEP 2000 +#define MAX77705_RGB_DELAY_2000_STEP_COUNT 13 +#define MAX77705_RGB_DELAY_2000_STEP_LIM 12000 + enum max77705_hw_rev { MAX77705_PASS1 = 1,