From patchwork Mon Dec 9 11:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 848511 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 BD6E721B8EE; Mon, 9 Dec 2024 11:29:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743763; cv=none; b=EYQ3+lI1yDy+oL88rRxezS0nFXqjwZVb23VZR0lsLUu+0wpsK1HFU1N0oDDjzNM0M9qD05xLU15qiJnn4J2HSp5RLNLXn4xi9yXiQG3vWifs8XxelHDJohXEnFHIRvWOnx3Y9TW9Bk8TlKysnBWhZV34cT+UHKqgMW9gapuhnQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743763; c=relaxed/simple; bh=w0q8rLNlEn36s1ZZTa5PlSCwUgC3hcO3Cuy8zeZ1xD8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dikQa6uyQAZWEwzezkWajxajMDnfEmuxwvjdyHJUc6c+uAf7RfXCEmQW+bmzuiIRNK2x3Sj9zgCZxUFoCmuMERiOpTZvVCA8b1r1UW19pKFE436Yj++08O4qyU+5jF1ADB9YP42Bz9Z5JVN1mB5NSfXmQWZNGUlyagw2bZRX/go= 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=EYzoqu5Y; arc=none smtp.client-ip=209.85.218.52 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="EYzoqu5Y" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a9a68480164so569665166b.3; Mon, 09 Dec 2024 03:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743760; x=1734348560; 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=AKaMSh7JgpkFzTixh+i3hm1CFn8OPlofH+VQYbnd7Xg=; b=EYzoqu5Yt1zaagvg7HKVmquKbQw5lWl7L+BtLMHeCfGL+igXRiGTSeGXLquyae6VDz 809rFfQ+LtgFzcW1rSjxoRMzVO5ZME/EPLnJeCsaaf5L0E6GS17WZYGY6/uL75ybImZ1 WE/pDBcVHeYdeF9g39W19Dh1EHjhp5NXxxtt3rCiaooUghyixF15Q18h4ZQlNYosQXzO ulL9Et85uchKL4Uvvsz69v8nLSf+2QjbvH+Kt7HCJLVw04J5RBGQcjg9myPI13hd7yw1 2T5tZjL5YN3peDOGMyY1zQxMZENpwc0n8NepyHjKNU9CQVH019vI7MvS0+4K5pxYBS+s 055w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743760; x=1734348560; 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=AKaMSh7JgpkFzTixh+i3hm1CFn8OPlofH+VQYbnd7Xg=; b=m/dDkcNW4E2eF/GncPoxbkhp59NaiY+ghV0dxEQlSlI33EgO1pUcQNnkX6UfEY9VbV B3wd1GmdC3R5sfCZ8SpP1rWDCNcbDWJCMLCtm1MjRRUWHwQBafC+6+P7LxvO6f21co6G DcfWwYgZRF/GXluzt9gseVLqjgAXmMA5akIBUcvwIIuYibMyNe3qrjPnH5Mf4f+LFpjw AHEuIrqVJU5pRH+TBFhigo94GnyGnoHBCiajPscdPs4dQocdAFpgyf9FFcxAkkDmYgg1 gPRKRNGECCpqLZjBmjRZzp+GAwzsClyyj9ffSL1J5oYXhRouba0FaL81tfw4V4shBlHh F8Ag== X-Forwarded-Encrypted: i=1; AJvYcCUuEnkexRQtFA7dh2jsBbhB3u9Q8HHgYi0mJctcwVXj9iHA0mJuoQlr4dKTDNrxnTL/rtYcSZeyWRYYTw==@vger.kernel.org, AJvYcCVYdrm7YBQqlppG0fY73EUjLrddBuy8nWTSoF1mO3IKIv6szFRag5Z1/3KuoYSHvaynSt8x8ABA1zpq4Wc=@vger.kernel.org, AJvYcCX+YOs/5E524+xKL174aU1XneyPG/pJVnG2cDe4orLy+xDzDeeTxLYFfOTQa2WF7A6g/ijBjPsx93NS@vger.kernel.org, AJvYcCXCGxFOQBSkzcSiE1YbsXzHd+7BKds2HSPnarr3uG7l5fbe88UU7zxUksew8XAbljdcgUZfr3mSQitOUQZV@vger.kernel.org X-Gm-Message-State: AOJu0YxuX4X7OE/JgD/p7Xt+IHI57mv/+7OPYpGNu+Yiws04M2hWBwyj t4Eiy72JUGkjSxAtuR1Ko0Iaf6P+CIsHkrnKA7/sUNA9rCD4W5ZYZ96hSkHb X-Gm-Gg: ASbGncssEgHSmWD3NZyj2HhURVa6vdDyLYTQ1CuBfQ+8zwFoEYYyyog4UUfE/EtG79S cbe2jBszUdHYhqBM/JnXxTLd78/QoVbuFF9q8Ek+VsTJMKbNo60BgIyr8dKDbwYGcGj1s8FZPOn MyrJCdOF3qK1S2m3SXYG+JIzHj48sFb9/HTS5rCuz+PYqUdcGfT1zy2NOmClrmFbKeblTEURn8a ZBljAQcddcLRDsRvjqlbgYqVd7Lgy2KCdEN4SC8LffUdYqo X-Google-Smtp-Source: AGHT+IG71JrYd26BSFxXv+0U0QAIuW9ZnzerLPbx/c3JNhA5JevN+OJI89AsRi4jXhVm80DPvvqDdw== X-Received: by 2002:a17:906:4c2:b0:aa5:308c:3489 with SMTP id a640c23a62f3a-aa63a2519b0mr971929666b.58.1733743759766; Mon, 09 Dec 2024 03:29:19 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d14b608faesm5980350a12.44.2024.12.09.03.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:19 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:25 +0300 Subject: [PATCH v11 1/9] power: supply: add undervoltage health status property Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-starqltechn_integration_upstream-v11-1-dc0598828e01@gmail.com> References: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@gmail.com> In-Reply-To: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@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=1733743755; l=2343; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=w0q8rLNlEn36s1ZZTa5PlSCwUgC3hcO3Cuy8zeZ1xD8=; b=qyb9HK1XZB6acVNb7GFFm4/lqnt/97CSWSRh4qKrbW/5CSwEu5LDoZFanaNoMs2h8TDk6Zjxt EkPGXwWVK+sDR21lL+b7ZBlV5HSPw392zQJh8Ujbdojrzl+nQMZDUwq 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 99bfe1f03eb8..09e3f544aad6 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 9 11:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 848510 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.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 9957E21CFE3; Mon, 9 Dec 2024 11:29:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743767; cv=none; b=isSOH6yPbSK0Ppe8aNpxiSXaMZo/nvM7cyZbi/LfAyrz/eCEN2AYud1hLb0xeSrBdtzW/NE7S+BtFp3clR0aTzDiVyQKtDBQV/y2tbguPOYI/2n5KqIEykcJWUfs6If+Da4Y9DOoGhfY7mLSVDhSCxsTih9Wms19eLI+IxybkSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743767; c=relaxed/simple; bh=yJnAUnOBisZ3dhz3HnsbKm2/RZKkA9XAwjdJuK7c2Mc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qwtKRrGJZcwjwC04YsDRUA1oWYWWxllVnkpgTcWYqidPBl4z+AE+rG/aVOPc9ploGptwkBmVr+evK46bQsXnnQQa38Ru0CiaeS4f0N16KHVJ23PlATD51sWlkD7BplKtp8/V5WiyFdRQcUEYG/ne3fSKkHcb8NEsleQHrsuUKCw= 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=YQaEQ5E/; arc=none smtp.client-ip=209.85.218.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="YQaEQ5E/" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-aa1e6ecd353so684806466b.1; Mon, 09 Dec 2024 03:29:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743764; x=1734348564; 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=wXzm1cjWJaSGl7IBhydp6k3erZJuc8jy+xEzIOAkkH4=; b=YQaEQ5E/ujb48MkBDV/u+CEhL8WNZPHPreiTTD6Aei81eCWNR6x2/pm7x8WP8XdLKo mrHjLEeyNrI77DauIk0Ok3klfZ0i9DyYedUZl+UFhy5MAU16qOmiiGaORHKubOEiRE0+ tCejGuWMBTArR9yBBYAcpbuh0JkPDId4c3huIHHM7kdX1flmEHnTCjSCGI8QrlOC4PBa DqEczRhftlJECCsnkphhbtVklM6FiWBj4WQuqP4a7ONRwxH0OUjDL9qi5sxbf1Gvzvuf MCN0oMNvwewiQDGzusyXKEM0GfxppOvXP5+RqZq9uHI7erkEyABZbzUmN2+YHAE7O9F5 3DjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743764; x=1734348564; 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=wXzm1cjWJaSGl7IBhydp6k3erZJuc8jy+xEzIOAkkH4=; b=V0nL7sXr8jtyeQA7Ppys1hU/uhucUILIyC98krxZL9qOmjhQJztxphtKJv29TistxO 0LBs2gmNJztC6OHnZs67tPyvdE2OFZk7kTfvSY8ac/g7z4FnfU+cUrQf6PWLh3NGiF7u EScziuSM4ktCfoeffnG+R3PLIJ5t3Yqokk8aO4gdpKL1mkEl4IzQlFQA/xY61tfXJcNs Nzj7FkXcg8sbXlrAc2U68c6gD3jjZeTHWTxhxOJJ98OqDsXfK+FWJVue7Sux/aVXgrhl WrgOlXy0WNEXGgbeZzSwLdizui0nmjbSv1PI5QlcDq32Lsq9alBDTVv4kIpXgnWCXpKI LqRQ== X-Forwarded-Encrypted: i=1; AJvYcCV+ioE68VxYWB4cA0b0mDtckUuMPKcoU82IamWPirf0K9gWe4gvzawUUwcoDpiqVMu7k42pXhQl8JSm4Q==@vger.kernel.org, AJvYcCWcmTHCEagBHay5Tnm1G3YcyNzQR6MdkDUDSAvby9ynu9GtcWUlEbD0LRtFmDkJc/Qf+si7mh5+6kww@vger.kernel.org, AJvYcCWgjwhSXrOeXHPXlEWaYuXaqtAAnmOv0KxHqKMH3hrLmA7c6ffCJaAbjVmCVNV+fW4O27andV5w9s9u2d0=@vger.kernel.org, AJvYcCXNLDf/qm697k8rUzSMN1UJLQWdSBjgupv7PcdkUOJo+KaqKyHMbp9xlaBTV0CfCbwQ9rLJWT90YGLKUhLq@vger.kernel.org X-Gm-Message-State: AOJu0YycfNuw0B7cmCY1eKosP7v3033c2LWfku+Fitl0DHzkDAR9fUrt AGVQBIJanJJhhNlt0Zw4EDR1xVXwMAZ+UBvTHIvzPuSnGqKU/8xw X-Gm-Gg: ASbGncvojhH6RBiFPGrE0A5bpDOmnjG/jCe9KINGIVi/04eTF/OUD3uHRe+iPRh2fxJ BVX62iXzSr7t/Cnlq0ADCbC5vEe8rdW7P/GFIXhcu833YZoda5hVTJwuAicYW4ceo/FCtGELoGF OlDyS69BZtCBgGuJpfV3a9JgZp9tsQj5SbHe5Kq8zMA8o6eujpyGcJ9bcBwE7P5rcsGLfFuf6Bf bn/rQb3WBhoHYpZ1VAVKDYbHY56121qwjZZZM9EzLntJbp0 X-Google-Smtp-Source: AGHT+IFIVAHf1m/IHG+sqVnl4++noMovd2qOxnl5VkzWewM/f+8vOhFT49UajQMFDxAaTO4bUgfyIQ== X-Received: by 2002:a05:6402:541a:b0:5d0:c7a7:ac13 with SMTP id 4fb4d7f45d1cf-5d418604dbbmr418021a12.34.1733743763722; Mon, 09 Dec 2024 03:29:23 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d14b608faesm5980350a12.44.2024.12.09.03.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:22 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:27 +0300 Subject: [PATCH v11 3/9] dt-bindings: power: supply: max17042: split on 2 files Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-starqltechn_integration_upstream-v11-3-dc0598828e01@gmail.com> References: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@gmail.com> In-Reply-To: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@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=1733743755; l=5484; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=yJnAUnOBisZ3dhz3HnsbKm2/RZKkA9XAwjdJuK7c2Mc=; b=r1Onup4zVHBfmvpzuY/NZ5gfdH7I4VJyKGDYKGrdG1RPJBJBb6XvNBhpu6jfih9rk/6WIW/an TnJvBFqAxNhCt55v5So7Ct7zVz3YFNGiSHYdJtMafMLMGmK9XircOdr X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Move max17042 common binding part to separate file, to reuse it for MFDs with platform driver version. Signed-off-by: Dzmitry Sankouski --- Documentation/devicetree/bindings/power/supply/maxim,max17042-base.yaml | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 49 +------------------------------------------------ MAINTAINERS | 2 +- 3 files changed, 68 insertions(+), 49 deletions(-) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042-base.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042-base.yaml new file mode 100644 index 000000000000..1653f8ae11f7 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042-base.yaml @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/maxim,max17042-base.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim 17042 fuel gauge series + +maintainers: + - Sebastian Reichel + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + enum: + - maxim,max17042 + - maxim,max17047 + - maxim,max17050 + - maxim,max17055 + - maxim,max77705-battery + - maxim,max77849-battery + + interrupts: + maxItems: 1 + description: | + The ALRT pin, an open-drain interrupt. + + maxim,rsns-microohm: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000). + Defining this property enables current-sense functionality. + + maxim,cold-temp: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Temperature threshold to report battery as cold (in tenths of degree Celsius). + Default is not to report cold events. + + maxim,over-heat-temp: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Temperature threshold to report battery as over heated (in tenths of degree Celsius). + Default is not to report over heating events. + + maxim,dead-volt: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Voltage threshold to report battery as dead (in mV). + Default is not to report dead battery events. + + maxim,over-volt: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Voltage threshold to report battery as over voltage (in mV). + Default is not to report over-voltage events. + + power-supplies: true + +required: + - compatible + +additionalProperties: false + diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml index 14242de7fc08..b7fd714cc72e 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml @@ -10,60 +10,13 @@ maintainers: - Sebastian Reichel allOf: - - $ref: power-supply.yaml# + - $ref: maxim,max17042-base.yaml# properties: - compatible: - enum: - - maxim,max17042 - - maxim,max17047 - - maxim,max17050 - - maxim,max17055 - - maxim,max77705-battery - - maxim,max77849-battery - reg: maxItems: 1 - interrupts: - maxItems: 1 - description: | - The ALRT pin, an open-drain interrupt. - - maxim,rsns-microohm: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000). - Defining this property enables current-sense functionality. - - maxim,cold-temp: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Temperature threshold to report battery as cold (in tenths of degree Celsius). - Default is not to report cold events. - - maxim,over-heat-temp: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Temperature threshold to report battery as over heated (in tenths of degree Celsius). - Default is not to report over heating events. - - maxim,dead-volt: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Voltage threshold to report battery as dead (in mV). - Default is not to report dead battery events. - - maxim,over-volt: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Voltage threshold to report battery as over voltage (in mV). - Default is not to report over-voltage events. - - power-supplies: true - required: - - compatible - reg additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index 7700208f6ccf..cd5532afbfe4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14157,7 +14157,7 @@ R: Sebastian Krzyszkowiak R: Purism Kernel Team L: linux-pm@vger.kernel.org S: Maintained -F: Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +F: Documentation/devicetree/bindings/power/supply/maxim,max17042*.yaml F: drivers/power/supply/max17042_battery.c MAXIM MAX20086 CAMERA POWER PROTECTOR DRIVER From patchwork Mon Dec 9 11:26:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 848509 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 AF0BC21E081; Mon, 9 Dec 2024 11:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743770; cv=none; b=t9hXqcVGZ7BjJpkLMvxnDqs0dUaYQ0exKc1nQnzEJRP/I6vkTetDDPLnh1CfBfEqcpve0akCbuDw/BE/HpTIO6MZ7iePGXS+cWCyuxM7WFx7sEtbUDwgKc4jar/22TzGzut7esx8qKr+8uY5CwBzrfi7hHK1EhQcRxkvOV0sHg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743770; c=relaxed/simple; bh=vFeQHkYSxuAZeTAwrYPzxxx9evHLZtMuXvBsR0hAdeU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ku6ET1trA6NVI87VOXFm2xdeHbYC/KV8toRVnPpl2tpdKMxvsi+XF3W8UTXZeMo5c+5IWFk4Mi1Xcz2/aqFaxDZVlkcwa4TvDRt5HTGs8O+B2QZXx48BtknU/peaPzGdtX2iiGv34EeGzHMeozW0lqk9glGBjbvB0Hy47+hhIlU= 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=GsoCd4GY; arc=none smtp.client-ip=209.85.208.51 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="GsoCd4GY" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5d3e8f64d5dso2335696a12.3; Mon, 09 Dec 2024 03:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743765; x=1734348565; 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=HAwZbwTlkZ996+qccsIMu6qIR18JftNBDn0G8yU/QvA=; b=GsoCd4GYQoJk86Ej8mho1DUP0HH+RGNeWknKpF4cEow/qm9wONUTnoWttPLPl8+CQ9 mpZSBHS1xCrlCKBTIoSwREMyXw2fz1nN4rWzOx7hnGNl1Z8kRkqwkdOABpTebMaaAubv v/bBhKNY04/N7QjNuEmVS7pfHRZHzHo7EwnFvptaZSw3uUFgxB5SZBYHVUvR5COJOE/S EpYJxUabV2eWLixdBjF/EH5fqpppzoVjA02Bm7RRB86S/PHzlNUF+lIt3MymzO5YpvGH KKOceijWBr9QjBq6fImCw449rEjsUeJ++n+IdwX/bnyuZtbKGgnscXB2SKAtpfccuOeF ZBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743765; x=1734348565; 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=HAwZbwTlkZ996+qccsIMu6qIR18JftNBDn0G8yU/QvA=; b=G4/2jwMPrt5/Lw1S7Cnxur+h53rucKGaH6TsuZvGpeeO1fVi4V0WT6eVuC/CDb/f7V gXQgDj2XJCImbahvLV5lsNzvGYhpwSbUola9MnZun5LtFg4HxRphTxwwZUi7uL1jLicz YH0B72c/ppodTh8pMO1PMpODBJp90hwlnBMXFgq8qx0HpXkTmsX/m6CHSnydcvnRNsMY 3LfBbmg3gSZOMCUu7Ku0NokynCsmaPpbBcF7YJTEiiWHwg4b5Zx1rP1oT9Iu32uHIax8 v+X+J4D4R/9eSF7SAXwN35VeTSeJWjpsyH3nDUIM+KkxApt0Va+uRU3is4dYH2WlLSIO HcJQ== X-Forwarded-Encrypted: i=1; AJvYcCVD4Fbkt4J0zyCmHVLJcXYm/LSKNZSFnJxx5oVipNb+3HgTg/vQHgfrUwY4ou/9+aoAh0S61DRwE6TWgj6s@vger.kernel.org, AJvYcCVvv2TF46g3aUdz97XcOVbJaz3+sHSrmVJTgKPjxvJ+vqEcn2IB4zvyB7C/s42D8vra+k6BJNHpcWmL3A==@vger.kernel.org, AJvYcCXCSl5bu5pXddvAyRDhhepzCmCFJOencVPP3YuKGg+4sLXa1eUwK6GarS3Pbz1ozlcD5LYqXh2+K5mrZcE=@vger.kernel.org, AJvYcCXNc1InbhGhd2zXHqX5pHZ/0mcs580d0zBnaakILPAVhZr9i3mMSb9srMFACUrULKXmD6ONVN/4Xj1H@vger.kernel.org X-Gm-Message-State: AOJu0YxuOsgfOHymDXPgxibrAwsFtm+ouIDwlE5wzP5sX/zyhwOoP+J9 YQyLVzL4e68mOuzi/HUlodzH/bANP6thU7BAIDW7NdfR+CglPSdb X-Gm-Gg: ASbGncspUBTR6Op7EbtjQqS7KOK+BINnlNxLnNcM0hIylgOO+uLWGujwMC7ldrrzaZ+ 8pZuL45UyfKKBfmDeJEtOHjpTWnQMAy7YJGoS3b2NNf5e0LrUnfa6Bm2pTyib1tgTKs2oS2Tdk2 SjX8K/dsXBbdeXcNQa7oCYSHzOLDu2C4XrtZPbOW3ZRUtXuQGUSy5t0EE74hbbBsHpCzDguweSk D8Auk+apbJYJQraqz9+PyMrRQ7hSQfkT0FF0SidfhvlubKydRF5 X-Google-Smtp-Source: AGHT+IHQFtdxjxI2mCjsVT5GXlJXZ1kiuNBjqf98ccSvwGt7iXJld0dI3ecWeVtmVw555f8DLumhJA== X-Received: by 2002:a05:6402:3715:b0:5d0:c9e6:30b9 with SMTP id 4fb4d7f45d1cf-5d3be65d5f6mr12282377a12.3.1733743765324; Mon, 09 Dec 2024 03:29:25 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d14b608faesm5980350a12.44.2024.12.09.03.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:24 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:28 +0300 Subject: [PATCH v11 4/9] dt-bindings: mfd: add maxim,max77705 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-starqltechn_integration_upstream-v11-4-dc0598828e01@gmail.com> References: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@gmail.com> In-Reply-To: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@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=1733743755; l=6967; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=vFeQHkYSxuAZeTAwrYPzxxx9evHLZtMuXvBsR0hAdeU=; b=ffu9QcdDqkWOfSH+Mb4Ojsx2Lu1RjVn8VgTKhfcVMnxXLtyr8MgdZIoNNhXz5zz3hFUQIbC/r rOAGovaXBshACY7zLVsaKXSyvtYVJnjDOG/j+1Jh/4CZq1+KH6q7sIe X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 binding. Signed-off-by: Dzmitry Sankouski --- Changes in v11: - remove reviewed tags because of major changes - none of children are supposed to have addresses, all nodes are unit-less Changes in v10: - leds: replace label with color and function properties - leds: add support for leds-class-multicolor - move fuelgauge node to patternProperties "^fuel-gauge@[0-9a-f]+$" to comply with max17042 binding 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 | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 191 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..78d177211205 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml @@ -0,0 +1,190 @@ +# 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 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + 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-base.yaml# + unevaluatedProperties: false + + 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 LED channels supported. + + patternProperties: + "^led@[0-3]$": + type: object + $ref: /schemas/leds/common.yaml# + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + required: + - reg + + properties: + compatible: + const: maxim,max77705-rgb + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + multi-led: + type: object + $ref: /schemas/leds/leds-class-multicolor.yaml# + unevaluatedProperties: false + + properties: + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^led@[0-3]$": + type: object + $ref: /schemas/leds/common.yaml# + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + required: + - reg + + required: + - compatible + +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"; + #address-cells = <1>; + #size-cells = <0>; + + leds { + compatible = "maxim,max77705-rgb"; + + multi-led { + color = ; + function = LED_FUNCTION_STATUS; + #address-cells = <1>; + #size-cells = <0>; + + led@1 { + reg = <1>; + color = ; + }; + + led@2 { + reg = <2>; + color = ; + }; + + led@3 { + reg = <3>; + color = ; + }; + }; + }; + + 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 cd5532afbfe4..9b656d57ed1b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14227,6 +14227,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 9 11:26:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 848508 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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 2713E21B8FC; Mon, 9 Dec 2024 11:29:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743774; cv=none; b=ltwseSTj87zzF2Gswz1RxtwaSpyw25k2AweC2xr1XEMMVBT/NSPwgHWNC6p9A6dNrWLLxA4H1yGfmDAD5yoxSuIgxi1L5iQ5nq/ZSltNSP17zPsug38tk3nLk5M2gA4Bxlwst24v5VpxuLATF0WS/dvap1slbiOXuvmZbw079r8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743774; c=relaxed/simple; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oYYZ2UuThoRlUiF8Vqu3O4BPt5uuSlmrnPlptyxXb4Zd88wMI6xhtQ8xvKDtJE8B4aSrrGjlQ4+xEgYwzjRXyEvt7NZ979J25CDm5fs3XRfLbzBZvjwZnVYPXPm7EyJMVMAp4J3ONZfQPWJDYkJYdPT1ADyR4HlnWieSLm1jQo4= 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=APdchls+; arc=none smtp.client-ip=209.85.208.44 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="APdchls+" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5d41848901bso133627a12.0; Mon, 09 Dec 2024 03:29:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743770; x=1734348570; 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=APdchls+gagYyeSnUs/XYWhfow7kPaA49Ry3McFdl11q4qrhgXNXXWcFpK1qwOW984 XEI+gzyZKp3ip61Cnf55urQJhD++7nCj3UkH9piu8ty2fgwgwsXo2tckD3K2bQxY1ab4 qmVOyEdozvpTWddmexi45T4aUrgW3qb/YtmNdDdrKicSvEmW+XMm0+/kWCjGbmU59zCu JdUCLx5+tfnx8nCMekYCwgv7Ug4+IfZdXsCTC67sMHOX18rpzX83Yb13Iu3DlsTO23E6 +XX/1PFg0J8jaeV6E/epadv4SWxuQlKZYYpytHaAb6QK3Zw1E3dOF+ioIVMCbN6aeBFc GaYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743770; x=1734348570; 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=pudYB8wPYX+TDKXWBMV8pmMtba79826SfMhXr3lYFacySETvEGpBnsDpX45MeeTi/x +LCap2ROl7A4ZmS0/EqSJVdae61nqfeXguD/JhEcwdo7RtbaH/q+9r0HBUmy3gLeV0Zr HFPCHkWNnmYlFfJ0m6Of59iq0Vw1UHd9eOC/WipFITCzbWYWtfdDgMgsyDo149gVwlyg DNhciH8B8e+eiP0aWHOHqCgkHWozxhR8s5tXBq5kC4MAzqtZq79EAnbKhdBsHMbgOFFB 4jz/EAYPZBvZnNEguf16mat9xWyvY6yPFsK8sQ6zB9UWb/6oD/WC6t4/reNlFydqK/zy eGBg== X-Forwarded-Encrypted: i=1; AJvYcCVhJkjBR8bDP+x26w/DZWofs5gfH4Ogog5OLk67jz7pXD4koGXTISN//tXxeDgjAwdfpdfzhkiyrx51OQ==@vger.kernel.org, AJvYcCVzfSszxxkh3gbsL6yhpL3/ZsECz4WFWdFNYBN4+ZMLtLoArXc1vfZlgavUiWYAI7OGFMwim6okJmL1sHiZ@vger.kernel.org, AJvYcCWjUIJiTqtINu/dCoOzc+JCj0dTZgXA3yxJMSygJRCCM318B7EE8CUaiGvhydWqs/tQUKvOkhDk+JEXn5k=@vger.kernel.org, AJvYcCX8QxesXwU6IlhylQZIn/iUQIedYJCqWs3u6XpyfFkg0oQEnxHyLo/6fi9DV1Ans0eHNJOZ/jpZMuQD@vger.kernel.org X-Gm-Message-State: AOJu0Yy772j3bxvIodpYwQGa+vZ1oQRoAiTGr6ZvcTU7sKEGUrZ9hhtW 7QIJ4to0ad5FpcSzyfg6KBOCnbXHrGyL8X+mklwgv0uQud6wLNdw X-Gm-Gg: ASbGncuGZUGr97VOfkWW6/WrR3wp/ZVYWAbBskV6hgBTsLvQa+s6LH8G5EZLTBQjltx HJe8D4dZxoQipooHX2d8Wwhftej+c6phtld4Lvc1KKLoh8prxkwTvuFW0EEAK0giI8BFTGVybP5 FATia4CH8/80UTQLkXx10mNWWjmUyM3Als24cBAOhPgrK8HhOsi6CXrlXNLJDg3JOYHqnX848/j e2Gkea8a3dU3CRc8k7AM43Nt+2+SGBai3uJ5DTO5zDyKpVm X-Google-Smtp-Source: AGHT+IHilM1vWrJDSZEVZLg37j5igTbmYXqZzyGoTPcUgpaMbLrQIafk2jwdY5E/jvXSNjc7fmDR3w== X-Received: by 2002:a05:6402:280f:b0:5d0:9d7b:2064 with SMTP id 4fb4d7f45d1cf-5d3bd6475ccmr14523920a12.1.1733743770297; Mon, 09 Dec 2024 03:29:30 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d14b608faesm5980350a12.44.2024.12.09.03.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:29 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:31 +0300 Subject: [PATCH v11 7/9] input: max77693: add max77705 haptic support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-starqltechn_integration_upstream-v11-7-dc0598828e01@gmail.com> References: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@gmail.com> In-Reply-To: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@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=1733743755; l=4280; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; b=6rrS3vg5ZZqnA4h2oic5mSlisnQfHhwsugorLgdOQ0BV6e4GK8r/6gNgJwFLx/yoeaZqq39o0 MP0E3xJEmV7AmF95isMvD3aEbNArqTVt0l65xMKi+L8I2eXa3DKZ+7L 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 9 11:26:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 848507 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 1ACAA22371E; Mon, 9 Dec 2024 11:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743779; cv=none; b=j+pdQphnr4Akn3bE8tB3J9P0JX6K/J6AvlwaLS9OGam0iktkCa7Vbx5hZc6tidXIyVSW91tMrwr5Jta12rdXyOt+O0JKegN82YxB8saMV3f0gdA8OcwJ74PtezxvggqQ8Km7dPAOuYy4NQ2f64tDucSseZpec/IKTZw4kDgbm3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743779; c=relaxed/simple; bh=NzOXsoCzbUeQfHUsRZ4NJIWaPxoZJF1J5dkwdApc5FM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LlETFYB8e2pKoJKggjxMF4xlHfA5hS6vei3tzWKjkRwUC95+qnArWi9HAQ+fWJuzR37ydeWu8k0O/GFaZl7U9HOFfjRtN0lPwH4HdZFgX1OFMHBBtmzs9Cq6TA6cIebFWwbByRjlKdlWKf1SVRvupFVRPDHVLF68Vc3gABbECZo= 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=OEQfQTZG; arc=none smtp.client-ip=209.85.208.45 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="OEQfQTZG" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5d3ecae02beso1682145a12.0; Mon, 09 Dec 2024 03:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743775; x=1734348575; 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=UQ+/5vhkA7SFa09z69ZqE2BWJsck8tUytuODte0Gx3A=; b=OEQfQTZG4X/v6yxwkual0c361fx7g9Z0aAaWd0SR+ob/v8Vwv+XeNo0PDlkafISC0D DNki1wzro69Fr3qgmSuRavuqLdJyFMqYcZRbamQUZjsJxvfrfmhqR5GaeRHMY5TUTpOT K8SClKXjWTujfB8LCv4mli2SW3MyXrx+UQwivDrkiTgDSf4A7X2K5USWXsIFwt9kV4gd 6ktGi5vX15b5TYw29XbRSPqlG03MCjcqeB8/+CuQd2nrBObMZlKUP2vzT40BOYXe5eYK ewXvVj9/pcGEilEuM2yopjKTDKEfO/K38kvtK/CpXRLJJsJwwnXsXwjpew5Ub4Rk3tLY RAYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743775; x=1734348575; 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=UQ+/5vhkA7SFa09z69ZqE2BWJsck8tUytuODte0Gx3A=; b=kTG0F6dTAqET8y4abF3QoCqj1dg88jJXqI5z918vLTjtJhv2W1sIADy/usV2LrE6jL S6Yj9/2SFfBatxbGv0cIR9zLlTfgNaUvVyzDXqyPZZoajjrMHYEyuwnTeNhVO6XuuzV+ aa1tqH9q8kWO4fPN57KDktwevGyz7zkVw0NApFpOxUinSoyIa2mkCKj9ORNeTEg8ylG4 xxp+tB3uo18fuku97T7VNTbroDsHRef49HjRaVpouKV6sfA4lEMHoUW4dBXX6Ra4CvX0 5Tq2U0WPYrmjzeWLZe+hO2f/ekxKEgYSvsinwRXYLKECah1YyHntoDRH9W43hdGjVHXM X0YQ== X-Forwarded-Encrypted: i=1; AJvYcCUnPIQvgmLMUtbkQRYbJ1xRM7LB7KblNzE1io5ntkhqaSSyYHsGRaDthy6zNAwjF1/5gm47tMb58GIHaDw=@vger.kernel.org, AJvYcCWVE1ZbseBsa6wzEkKhI5+kFAz14k1XbttlZhUt0Gf1HydFZeRMaLJ6ajyZoMfPxqus+JhtIE80oiuYVBFV@vger.kernel.org, AJvYcCWtbFgfGVv9EA/+KJkkVKuhse6NDsTX9EHaAJpcDfs6ZviEA/jTb4LGcng57reh9qiyqeTVra/QytKszw==@vger.kernel.org, AJvYcCXFmiP4idTjOajy2I297rLhiKJOwdWKa2OIJ/w5tOmBmRfpir03FaPoXiV3ovrOOLtrOe8ydvkan5xx@vger.kernel.org X-Gm-Message-State: AOJu0Yz72B3KAtcbRS8t02XnIFTepr57oHMiJioqHcPtueNzOlnZFUR5 e/1oDRIf0JG5RFlgGv6fKViGtcPlC9XR3a6MO882fFhSddGV0pWe X-Gm-Gg: ASbGncvX+LZHhEW4k9soFTzJwfByXT+UGq9qvgbB1xBZ/G2+xEazDgHm6JUnN+cPqJi djpfA5T3zppL1vztigZNjOnn3uWrFrWm7TvBiFc4wmsg3SYoff2uiNznL6rslNG5Ed8WiIc2Tdj XkqQfYVcMuBcm9IZGPXva4lC9C2FoxSsSCeLbCmMgoSF5PSoPWKd8vhTuIjYMD5xqnVrII0t/N+ ObzM+RXPWmdWqiO2UJDxwLQPJ5NibEJsYTUTTaSN/GZQKig X-Google-Smtp-Source: AGHT+IFqNrHxraxk1FWM4T8pzDq0HrzNk+T9GajDD/YiMURQzzhOGHeGpV4A1SOo3nZ+yMA5gF83PA== X-Received: by 2002:a05:6402:4007:b0:5d2:729f:995f with SMTP id 4fb4d7f45d1cf-5d3be816a47mr10105250a12.29.1733743775134; Mon, 09 Dec 2024 03:29:35 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d14b608faesm5980350a12.44.2024.12.09.03.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:34 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:33 +0300 Subject: [PATCH v11 9/9] leds: max77705: Add LEDs support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241209-starqltechn_integration_upstream-v11-9-dc0598828e01@gmail.com> References: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@gmail.com> In-Reply-To: <20241209-starqltechn_integration_upstream-v11-0-dc0598828e01@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=1733743755; l=12665; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=NzOXsoCzbUeQfHUsRZ4NJIWaPxoZJF1J5dkwdApc5FM=; b=o7E91FyqSTCHpJqooBI26yFzbwIuXZN/nW9EhrB53TTaLBm5ADELwn5kvtmWeT7RZXWakhPRk 6uovyabYk+eD88Y0xiVoZNV2xTzwxuRgknj9XHMsDvJ6Ng94itVHqeC 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 v10: - remove multiple line break - replace en_shift, reg_brightness values with macros - add support for leds-class-multicolor (inspired from leds-qcom-lpg.c): - replace max77705_to_led helper with container_of, because it's no longer covers all cases - add max77705_add_led, max77705_parse_subled functions to parse device tree - split max77705_led_brightness_set into *multi and *single versions 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 | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77705-private.h | 17 ++++++++++ 5 files changed, 292 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0d6e77bf6593..a43745895f97 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14230,6 +14230,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..15fa4b3cbcd6 --- /dev/null +++ b/drivers/leds/leds-max77705.c @@ -0,0 +1,267 @@ +// 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 +#include + +#define MAX77705_LED_NUM_LEDS 4 +#define MAX77705_LED_EN_MASK GENMASK(1, 0) +#define MAX77705_LED_MAX_BRIGHTNESS 0xff +#define MAX77705_LED_EN_SHIFT(reg) (reg * MAX77705_RGBLED_EN_WIDTH) +#define MAX77705_LED_REG_BRIGHTNESS(reg) (reg + MAX77705_RGBLED_REG_LED0BRT) + +struct max77705_led { + struct led_classdev cdev; + struct led_classdev_mc mcdev; + struct regmap *regmap; + + struct mc_subled *subled_info; +}; + +static int max77705_rgb_blink(struct led_classdev *cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct max77705_led *led = container_of(cdev, struct max77705_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 regmap *regmap, struct mc_subled *subled, + int num_colors) +{ + int ret; + + for (int i = 0; i < num_colors; i++) { + unsigned int channel, brightness; + + channel = subled[i].channel; + brightness = subled[i].brightness; + + if (brightness == LED_OFF) { + /* Flash OFF */ + ret = regmap_update_bits(regmap, + MAX77705_RGBLED_REG_LEDEN, + MAX77705_LED_EN_MASK << MAX77705_LED_EN_SHIFT(channel), 0); + } else { + /* Set current */ + ret = regmap_write(regmap, MAX77705_LED_REG_BRIGHTNESS(channel), + brightness); + if (ret < 0) + return ret; + + ret = regmap_update_bits(regmap, + MAX77705_RGBLED_REG_LEDEN, + LED_ON << MAX77705_LED_EN_SHIFT(channel), + MAX77705_LED_EN_MASK << MAX77705_LED_EN_SHIFT(channel)); + } + } + + return ret; +} + +static int max77705_led_brightness_set_single(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct max77705_led *led = container_of(cdev, struct max77705_led, cdev); + + led->subled_info->brightness = brightness; + + return max77705_led_brightness_set(led->regmap, led->subled_info, 1); +} + +static int max77705_led_brightness_set_multi(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct led_classdev_mc *mcdev = lcdev_to_mccdev(cdev); + struct max77705_led *led = container_of(mcdev, struct max77705_led, mcdev); + + led_mc_calc_color_components(mcdev, brightness); + + return max77705_led_brightness_set(led->regmap, led->mcdev.subled_info, mcdev->num_colors); +} + +static int max77705_parse_subled(struct device *dev, struct fwnode_handle *np, + struct mc_subled *info) +{ + u32 color = LED_COLOR_ID_GREEN; + u32 reg; + int ret; + + ret = fwnode_property_read_u32(np, "reg", ®); + if (ret || !reg || reg >= MAX77705_LED_NUM_LEDS) + return dev_err_probe(dev, -EINVAL, "invalid \"reg\" of %pOFn\n", np); + + info->channel = reg; + + ret = fwnode_property_read_u32(np, "color", &color); + if (ret < 0 && ret != -EINVAL) + return dev_err_probe(dev, ret, + "failed to parse \"color\" of %pOF\n", np); + + info->color_index = color; + + return 0; +} + +static int max77705_add_led(struct device *dev, struct regmap *regmap, struct fwnode_handle *np) +{ + int ret, i = 0; + unsigned int color, reg; + struct max77705_led *led; + struct led_classdev *cdev; + struct mc_subled *info; + struct fwnode_handle *child; + struct led_init_data init_data = {}; + + led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); + if (!led) + return -ENOMEM; + + ret = fwnode_property_read_u32(np, "color", &color); + if (ret < 0 && ret != -EINVAL) + return dev_err_probe(dev, ret, + "failed to parse \"color\" of %pOF\n", np); + + led->regmap = regmap; + init_data.fwnode = np; + + if (color == LED_COLOR_ID_RGB) { + int num_channels = of_get_available_child_count(to_of_node(np)); + + ret = fwnode_property_read_u32(np, "reg", ®); + if (ret || reg >= MAX77705_LED_NUM_LEDS) + ret = -EINVAL; + + info = devm_kcalloc(dev, num_channels, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + cdev = &led->mcdev.led_cdev; + cdev->max_brightness = MAX77705_LED_MAX_BRIGHTNESS; + cdev->brightness_set_blocking = max77705_led_brightness_set_multi; + cdev->blink_set = max77705_rgb_blink; + + fwnode_for_each_available_child_node(np, child) { + ret = max77705_parse_subled(dev, child, &info[i]); + if (ret < 0) + return ret; + + info[i].intensity = 0; + i++; + } + + led->mcdev.subled_info = info; + led->mcdev.num_colors = num_channels; + led->cdev = *cdev; + + ret = devm_led_classdev_multicolor_register_ext(dev, &led->mcdev, &init_data); + if (ret) + return ret; + + ret = max77705_led_brightness_set_multi(&led->cdev, LED_OFF); + if (ret) + return ret; + } else { + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + max77705_parse_subled(dev, np, info); + + led->subled_info = info; + led->cdev.brightness_set_blocking = max77705_led_brightness_set_single; + led->cdev.blink_set = max77705_rgb_blink; + led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS; + + ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); + if (ret) + return ret; + + ret = max77705_led_brightness_set_single(&led->cdev, LED_OFF); + if (ret) + return ret; + } + + return 0; +} + +static int max77705_led_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct regmap *regmap; + int ret; + + regmap = dev_get_regmap(dev->parent, NULL); + if (!regmap) + return -ENODEV; + + device_for_each_child_node_scoped(dev, child) { + ret = max77705_add_led(dev, regmap, child); + 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 cf4184063390..49509c0352b1 100644 --- a/include/linux/mfd/max77705-private.h +++ b/include/linux/mfd/max77705-private.h @@ -33,6 +33,23 @@ #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,