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: 13899360 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:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13899361 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 9024721B1A8; Mon, 9 Dec 2024 11:29:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743765; cv=none; b=Y7Z0Gzw7nKuQCUhxoGcbh7LLFNFLYy3HfrcIy422PtFvSkeihLNpLCff1Uvciln+yW7trot7FZAnyAYMuvEzOz5AVtwPAJlqsVnvr5KLu1Liuo/QCY07Tod13Wo6ZQbH2DrTtl9lmhyV4L9BK+78SHvtlCq/cyaFZEpVsdU7iBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743765; c=relaxed/simple; bh=RPQPYzIUrIV7KUtwuEchVeJdACROjNk9ItK/nS5eUAg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QM9jfwYDl3akMvcCyVA/URYPLkl+io060AiJNppVtTcDZp0A9pwxkDXYm0hGedLIKTE2tNhDGp6aoFQhAfZhR8HvyiDrGzPmXh2nEtdVLb9SU09DCaGdHZx3iPWcOW3aAa5fDrzru0QaYSJaBRVk0wIEACAcOeq10u7a58r8tfg= 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=IiHGBSHX; arc=none smtp.client-ip=209.85.218.42 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="IiHGBSHX" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-aa5ec8d6f64so498432766b.2; Mon, 09 Dec 2024 03:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743762; x=1734348562; 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=TvEYgr/6tTPCr/J7KKhyXeJ8K6wnSFjt2RRmJPjvqmw=; b=IiHGBSHXZeqZG5fGBYC7WnKH+k8GJI7jCJrgitd+RqEDMw+htBnUBdBxNuVLnOB2cH 6F2FojbDkIRb+v7PQc6LYlQF3uuPWl4OcfFIkj3pfvW4EDsVvVvSDFTaHZXLXeXDAe10 MeWatLbzNgjqpdrMeM9XtHZU1h2F5i6WPWWsmYup+VXaLf36yKcr1RZ35iuZ9cwN/aTn ZfMoBDcn0xdPfLFV+khWl/bvtXXNaRGoo1qDIZCA1feeukeiarMu0lLtPPoyYQLEQvzu 0DRleTN2az+GoDQmRLxzWcMOYeZG3IYKO7O0TI8rh9tdnmQN86VU9OWI+hPZG3eRKg5w 2wuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743762; x=1734348562; 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=TvEYgr/6tTPCr/J7KKhyXeJ8K6wnSFjt2RRmJPjvqmw=; b=Nfs9Sy3AFCcZbIVrkV+6Vv9oE102o4Pb2yZF19Nuf8m7hbxzEpkNvV30qVuYH2mg5r AG292+rZS2/NW1QSTk6FW4GULkx4bIkdJwnrryKxrRcE5ShfR99SPNOm6bo7hT5qrpcn bzaR5Ln8Jq5NLCELQ5UazGUMthAFY6m36BzPowgaCEsv4j6tYAoIehhWAsPFMYEUOkVb 9QfE6b1Z41Bwh/5jn4MfMjdcHRDCUujdBbzn0l2ndvg+VT5JOJvZqq9tB6ZfpnMYrd99 7dzzfLI8XW1CNsKUygcGuCjfzFYOzx80lIs/R4NH+YXUroLUZSpi3Igg1FcgrUIgXKVH pPsA== X-Forwarded-Encrypted: i=1; AJvYcCU8tZ8CFWqGuI3qGPpSxOvulJNa4x7W7oeBxHkTWkrIv0FvyABSHJVLstrNXIIjGeVFCoZGxxB0JVSSwC0=@vger.kernel.org, AJvYcCUUxQELM2hncBfzhH7SKVrSPmf1HxIQPQSnZ8O6NmUtvWhtpEtVpLLCTkxEme4oKFM2FOaoK2vLRNGXD+SE@vger.kernel.org, AJvYcCWBf9sQRT922QyY85upPAlfSo5uoUdU5R9HucRAHEs2ra1Qx5QjOthUmbd7rQ59WOQzGiDe26UWGvPeXQ==@vger.kernel.org, AJvYcCXc7IgatTIwlsSHs8DH//VszY6PrHN/rDksY4SnYkrTQQfrrTURTAh4Acq2hYmze0K1XCIs2X357f2k@vger.kernel.org X-Gm-Message-State: AOJu0YxSah42HcR0fXtYmyAVFq83PhOyNYZ2ambk0GUSMr2W4v2qFMcP JbjYvhnnf6qofW4UXiOG1tA+gIsEWNXVSG5052SL1+xSLzZRDP/v9KKKSQ== X-Gm-Gg: ASbGnctx9UoiWvgi7WNi+tdbvhXz7ROq5WKx1b5wXOjZjjibw6aKZD1bc88/1xv7ZzQ uxcsuG2uUvykVFsilmA8hx/cMiQTWdySabvqN1oX2CPKGZ7wN+0E2mWsKivL6nh8zK+hvkiKWQA spdG1CAek6SdqkwUHJDw2YU33Z1O0sKLtRTLISf5rzkHL0t/U7IK/SCqM01MFsUPqK5nqnUGURh UY4ftwjiMOo7MTsM3idWYdVbMW/C+H32/5i9atJ1BVChZv5PAOP X-Google-Smtp-Source: AGHT+IE4gs5bVGF4Efd0vXCuAIwDvwPQnzP/yWs8XUJERA8YDStoszTKI/POiU6VQYHF6KvSX+AP3g== X-Received: by 2002:a05:6402:51c6:b0:5d0:d818:559d with SMTP id 4fb4d7f45d1cf-5d4185073dcmr540205a12.11.1733743761597; Mon, 09 Dec 2024 03:29:21 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:20 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:26 +0300 Subject: [PATCH v11 2/9] dt-bindings: power: supply: max17042: add max77705 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-2-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=797; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=RPQPYzIUrIV7KUtwuEchVeJdACROjNk9ItK/nS5eUAg=; b=PcsZPGM5ttfml/v9I7fKER3SlrhCh2gT+ei5fBdYIpBrF4vcT9i4xPdvVO1cEOoCcWjD4Q5/E j40ylz4qH2RD9xk3/Rt1PWRB59aAbSmNkA0tdyOyvDH/npspORKHkaw X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add max77705 fuel gauge support. Signed-off-by: Dzmitry Sankouski --- Changes in v10: - keep alphabetical order --- Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml index 085e2504d0dc..14242de7fc08 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml @@ -19,6 +19,7 @@ properties: - maxim,max17047 - maxim,max17050 - maxim,max17055 + - maxim,max77705-battery - maxim,max77849-battery reg: 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: 13899362 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: 13899364 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:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13899363 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 AB4D221E080; Mon, 9 Dec 2024 11:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743770; cv=none; b=eiawggeQtmsFdb9Skq2Red3ROeKTQUjEMPRGftx+zp5qPKItECKg7PGhPfidp1Dt6lER3ehlsJfahWS0cNWZLayh9Ryz1rXsWZYpCXPpOiWcygHLgE4UfTbd3II7lQtwdLa37DZV8xry9NvT9Rn9bMAfvCrbtx9ZhVebMtiAOpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743770; c=relaxed/simple; bh=B9Jbf+WbkiUfqaxn+TOcx+7YMUZN7KJwybjo44749ec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hy0Vpm14PJjX8MZ/paAhRWgVD08trYjTy7NT+OEpNg0CD2mlXMjvh2oOPYuqkn8fV96ytMG2NI2+9oHVDHdEHYsSqxwkbJq/E7qWUYQqUi/Ans0uRuPwyXOJgbI99Rs/Wd4hnVEMACLEkBh2NcMNB2VwwDmaOry5FhpXfg7SgVo= 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=AsLJwvYo; arc=none smtp.client-ip=209.85.208.50 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="AsLJwvYo" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5d3e9f60bf4so2408801a12.3; Mon, 09 Dec 2024 03:29:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743767; x=1734348567; 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=93Jf5nOyXsKVNvOE6Npmd8LTxOlqIpdv9VlXWGYeyOo=; b=AsLJwvYoFSsJoJUGuwgA+hnkiLymibc3IhrnUVO0RBHSPxb9bQwrlzfy10h7YKvw6L ve3MaYoYbbF1NPuVIzGjsUjWpiXX+x+0tNGw+aq79Cd+kNG/y957kiQTX+R7LrKEWftu XELHIXQwCGJVcSCzaPa1emL8h3ImNRx+5GPlheRH0fTSeq1GVYsMmwfmb4O1ebhGSLmB 7VmeOtoLjgenOKpdJ9Cih9qwrGdgRZpx7lVHbLvCz75H7XoaOdCdTm7BMlw/sIAYWTR3 LZ/pzj9bb7c+k8nLgAfAf/7Zal6Me+xXi5XYVKwQCqJHdhshF2+14qN/Kx3ZgbSKG1jG nGCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743767; x=1734348567; 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=93Jf5nOyXsKVNvOE6Npmd8LTxOlqIpdv9VlXWGYeyOo=; b=p+qLuyZ2OQPc/4jgB/Keyo/ubNw1nlgpIZPmkP7YeSJbOcKm+6+EEXO5uWB6WgvjU/ 2kIn5hhNTNq/Aflj/SR8Rj34BNZT0DJpFm2+9wdqwdXsdJBT2fCQLQN3KT0nxeKdalP8 R70KX2ydqLevSrbNoUHckIpyFNov00DzqUb/zpTAZ04T5J5+Gwt8pByCBJHkrbol045O bV/bq3Q5Hz2J6zLuwW6ouwqk+d72xE543apf3lVYPLJv/DMdP8LDFZOwucRS0ShN4r2T nAcKMj7qv1bOO9hOWyrpUFp7oApKHtDNeHNhcjsDCeVpxHshVkNxE7N7vUjnXi6WbLuK 9FPQ== X-Forwarded-Encrypted: i=1; AJvYcCU+mr19LdQM8s4aDvLCifNDB3IqmIFL2jMRoWWaOYfLHM2vcDnPimaABLpUUT/aiD1FTLqvWCldrPhNRa0=@vger.kernel.org, AJvYcCUSH+obS+m94IXU2vc1P1lQOmjY7VXx2Yw3gY2Zt7KYooH5jl5h102iUWPztSdLlqf/eyVCYmTN5RaY@vger.kernel.org, AJvYcCUn43pAwNw92vfejLgA+S6iF/vmLrNaWzU6ynSBn8L8+UnrExT97oA7SJD+YUC+fckLz9SKYVp7480g+Q==@vger.kernel.org, AJvYcCWH9ygkjMYGB9F16m6bRMSseULEsXXiRFkqu9auirpZySXtYgZ+Lr4B7XHnSP72KA8plWdqkP/spoujEgAH@vger.kernel.org X-Gm-Message-State: AOJu0Yxfad8IBOddAIJCUZlDLuAFKmUS7UYzGOzDXdnxuLgGctE2pkNl 7jzSpdPmUXMCsF+1H8JRW0QO4HlziyNjnUY2SkmoCmfRX6DFHvVMRcdEYJoU X-Gm-Gg: ASbGnctzrArq1AiGSrJZsIy9W7iDSSasr2IPfICbqTm6lEPh/1p9OLRu4/7T6vhrhhr gPS8P/F4/dCKukO+91VRbhy25FLYIXzGpqQrOuMkEbp+1NZr6lqWVVqzuv4eP8up7g7OVte8urV zPQnWgaMppjXAEN3SnxjY1npGaj6j/xZuFt7eL8IxXILsj3aw9nvChtIgEqFxjHYTHKfMYIL0+5 2KKKs8+hklmGmuq7rBuyGXlhCK43IVHKZQjKTlfonUtfB+R X-Google-Smtp-Source: AGHT+IGlNJ4iK26DG1tYcNZtRm473HIjKWV9GLKFxYf1JOW25imu8t/AkG3YEm59TGatSswfM0IYsQ== X-Received: by 2002:aa7:d3c8:0:b0:5d3:cd5b:64a9 with SMTP id 4fb4d7f45d1cf-5d3cd5b656dmr8927328a12.34.1733743766889; Mon, 09 Dec 2024 03:29:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:26 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:29 +0300 Subject: [PATCH v11 5/9] power: supply: max17042: add max77705 fuel gauge 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-5-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=1475; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=B9Jbf+WbkiUfqaxn+TOcx+7YMUZN7KJwybjo44749ec=; b=qTvYP6gEi0pAQhJ8MoVJ4Rd3PYyFLHDblDXQxCl/oboj2gSqUTCSdAeobCDTM9ldgzBPpj/pr JY46ChZC18cC87J1SRd0numIbA91kJ7e/XJpxB+CVpmwdWfeomzmki/ X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add max77705 fuel gauge support. Signed-off-by: Dzmitry Sankouski --- Changes in v10: - keep alphabetical order --- drivers/power/supply/max17042_battery.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 6a1bfc4a7b13..d52757e70eda 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -1211,6 +1211,7 @@ static const struct of_device_id max17042_dt_match[] = { { .compatible = "maxim,max17047" }, { .compatible = "maxim,max17050" }, { .compatible = "maxim,max17055" }, + { .compatible = "maxim,max77705-battery" }, { .compatible = "maxim,max77849-battery" }, { }, }; @@ -1222,6 +1223,7 @@ static const struct i2c_device_id max17042_id[] = { { "max17047", MAXIM_DEVICE_TYPE_MAX17047 }, { "max17050", MAXIM_DEVICE_TYPE_MAX17050 }, { "max17055", MAXIM_DEVICE_TYPE_MAX17055 }, + { "max77705-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { } }; @@ -1232,6 +1234,7 @@ static const struct platform_device_id max17042_platform_id[] = { { "max17047", MAXIM_DEVICE_TYPE_MAX17047 }, { "max17050", MAXIM_DEVICE_TYPE_MAX17050 }, { "max17055", MAXIM_DEVICE_TYPE_MAX17055 }, + { "max77705-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { } }; From patchwork Mon Dec 9 11:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13899365 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 7E5CF21E09B; Mon, 9 Dec 2024 11:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743773; cv=none; b=ffqLl12zqWlcQ4VGY3iNTL2BDPN3sbSX7wj3yfOjMsqXq0juz+xkRLDtrAzHTlCO7Y6cemcmz/e1W0Ca4meXFkBXrjKBxOqt8168HGQM8M3tZTc8o3hc8nXwgIt5ADW51t62eXnlxCNF1tBD9+yyMFWpFBYfaVxep4DsnUn/qaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743773; c=relaxed/simple; bh=K7QOqnc7uUs9OZeDgnomcQG4pecl77Zx8sWAVzKome8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U1X7cwNItW5EKS3S9xUSgoI9P70NmW7BYGrGiFS1qtCyTwDmOUehrLkkRSXugs2ZjzhicF7C7ypRr5iDM4sibdFI158QfHG6OEmw1lkGpnGpEHfLuH+zR0r6W+GtHRVix+OeO2Jnbin/8fB2Wci5Cdw0eiTeRWtvGKZxm9aSSzw= 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=L3h1V14C; arc=none smtp.client-ip=209.85.208.49 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="L3h1V14C" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5cf6f804233so5167851a12.2; Mon, 09 Dec 2024 03:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743769; x=1734348569; 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=9Uy3I7ln4GskV6VahqQuJzNKrlh2FELvshiKSnXJXi4=; b=L3h1V14CVUoWmCSImM3UEVE6FI3JEXQVNsnJHLfi7affulibsQYtUtkHPz+pWfx8gr S19BFRus609ypD0lkqA1WK+lECKCp012F+YZI6ohxNo3qbCAICznM6Ui6WmJqjmoXuFZ R+oqzDNaw6hxvLqj3YvH0iG6dsmTXDaUg8eRhEU4qTbaMRZMyj8wgaNNdXykxQd2kwul 7azAZg6CMz9Asa2bv8ohCOL4aGqR1hgjoAYoj0ONbCzxO2IJkOcZGe++P0BI785LAS5V evBSfEitZOQ6r05CSDqIHw5ttFHP5BPTrt6vCipjRLJ7zxJnrBZXz0shfPFK/WMzCDtu 7tiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743769; x=1734348569; 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=9Uy3I7ln4GskV6VahqQuJzNKrlh2FELvshiKSnXJXi4=; b=UcLEAjz0gMlzCt3Pq+wHIRwDaKmnLLeykAEsUOFjDvYhQ8xG68Eq8GuLaxs71hV3P8 jzvUv66vKkfKpcsuGToDBQAkjM8Zw7FnY/vbBBB9NRlN+86sfQDjrXHowvF9w6jAtEbh LKEYMPZygfbe8x4FXhq6HvfrGL5dKlBrujXOkKlKRJeqZ13Y6StmoGI/bD7MT6be1CbZ mpfANWjmSNZXW+PtczCfFFsLQ+CLDIVj37aN/48YPXdroIfL1yWIqLmUWiILSokhXRwL OmlgbXxcPq6gA5R0PwtMkOx8wEQYkT2qCWvMthL/IPRhzyG2vW30PQHj/OH66BvIcgzt SNDA== X-Forwarded-Encrypted: i=1; AJvYcCUWmiLwddPjLPOE3E7R1b6cLUblQQK6UgX0Rj8LLbSArc5HnrH78yxcqcaZFpQOIk/GMqvCw7qLjr1LMgA=@vger.kernel.org, AJvYcCWpBt3aqV9piSEXcU7Z8cXye1S0Awar3+ZanQN1O8B3KnZDqUfeohRue4fmjAZxE/iXdLWQXR0JGRNERg==@vger.kernel.org, AJvYcCX+jkK37acimgZ2kyI+36b7T6dZOSYg0oKTiUt1wGfhNO2l3GVsOZVO/Ij3PJZ0ALBQIgFbwc6SxLCC@vger.kernel.org, AJvYcCXRKssWSMHXnboAnDjcVltD0oLJdXHUhGUNU9u0XFSx9+3cADiepWUm+aXpgR++sDspn7Od09g1RmsWF0+o@vger.kernel.org X-Gm-Message-State: AOJu0Yxm5IuLUWL3JDXNYH08ruft/csFq3IDRv2io1bxtGjF1anQxYtz MOmc22EtcG4CyVSOPwsLd4Rd1dnN1xucDT6cFDALX1XleXzucVp2 X-Gm-Gg: ASbGncviyz9DOOw+6H5TxujzEYI28R9hREQdh8oWcVfQ+xp6/fuK0Tdc+6jiVpteebx 1oBBfT32rdG/+c9btW1TpPeTBaTW5YDO3Hs5l5iBhYHSWAb1z+3DTAj5CFUDHyCi7jno+0f+xuM lWXsD79U78VxU5plWHLFOnxSLy7Qi6Ubr/mgHXVrZuvKsb9tMrRbsv7acIHrzH6yhwlAKRhx210 3MOPdc8HJ4CukLwiRzPKyjucLHFkRUlRJnpHwfiw6O/LtJ9XiHK X-Google-Smtp-Source: AGHT+IGR24NFSndJq0XG2MZu72+6YgbRR4fFiNngJnaMpqMpH7BRfSiYWL+8S8QYl6OIPgK8OAB/BA== X-Received: by 2002:a05:6402:320c:b0:5d3:cdb3:a60 with SMTP id 4fb4d7f45d1cf-5d41863ea0cmr202554a12.34.1733743768616; Mon, 09 Dec 2024 03:29:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:27 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:30 +0300 Subject: [PATCH v11 6/9] mfd: Add new driver for MAX77705 PMIC 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-6-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=19196; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=K7QOqnc7uUs9OZeDgnomcQG4pecl77Zx8sWAVzKome8=; b=7Ur4byv7Bmcs1uNFZHUDxbaZ5cvMwbPg7J35LVmE87lBVh6LAJjiLgn6hi4OXDj8dnV5Q0/Ri uHc/WP9EnU1ARsiMstU3CCXVoMHaJ+h0JFSB0sRqV7CFNX51zt1VR3f X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add the core MFD driver for max77705 PMIC. We define five sub-devices for which the drivers will be added in subsequent patches. Signed-off-by: Dzmitry Sankouski --- Changes for v10: - never blank line between call and its error check - remove unnecessary line wrap - revert wrong changes in max77693-common.h - move max77705_pm_ops from header to c file - fail probe, when fuelgauge is not found in sub device list - remove fuelgauge compatible, because with compatible, platform matches using compatible, and platform_device id_entry is empty. With no compatible, platform matches by device id, and id_entry is populated. - use dev_err_probe for error handling Changes for v9: - use max17042 as fuel gauge chip - initialize max17042 i2c dummy device in mfd device, because bus can be used for reading additional values, not related to fuelgauge, like chip input current, system bus current - fix pmic_rev kernel test robot error Changes for v8: - fix comment style C++ -> C - remove unused pmic_ver Changes for v6: - add PMIC suffix in Kconfig - remove filename from file header - reorder headers alphabetically - move out fg and chg adresses definitions - rename led name and compatible - remove overbracketing - move charger and fuel gauge i2c initialization to their drivers - fix max77705_i2c_driver tabbing - formatting fixes Changes for v5: - license change to 2.0 - use same hardware name in Kconfig and module descriptions Changes for v4: - rework driver from scratch - migrate to regmap_add_irq_chip, remove max77705-irq.c, rename max77705-core.c to max77705.c - cleanup headers - remove debugfs code - migrate to use max77693_dev structure - remove max77705.h --- MAINTAINERS | 2 ++ drivers/mfd/Kconfig | 12 ++++++++ drivers/mfd/Makefile | 2 ++ drivers/mfd/max77705.c | 233 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-common.h | 4 ++- include/linux/mfd/max77705-private.h | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 429 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 9b656d57ed1b..0d6e77bf6593 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14234,6 +14234,7 @@ F: drivers/*/*max77843.c F: drivers/*/max14577*.c F: drivers/*/max77686*.c F: drivers/*/max77693*.c +F: drivers/*/max77705*.c F: drivers/clk/clk-max77686.c F: drivers/extcon/extcon-max14577.c F: drivers/extcon/extcon-max77693.c @@ -14241,6 +14242,7 @@ F: drivers/rtc/rtc-max77686.c F: include/linux/mfd/max14577*.h F: include/linux/mfd/max77686*.h F: include/linux/mfd/max77693*.h +F: include/linux/mfd/max77705*.h MAXIRADIO FM RADIO RECEIVER DRIVER M: Hans Verkuil diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index ae23b317a64e..17951a9d5a93 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -916,6 +916,18 @@ config MFD_MAX77693 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77705 + tristate "Maxim MAX77705 PMIC Support" + depends on I2C + select MFD_CORE + help + Say yes here to add support for Maxim Integrated MAX77705 PMIC. + This is a Power Management IC with Charger, safe LDOs, Flash, Haptic + and MUIC controls on chip. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + config MFD_MAX77714 tristate "Maxim Semiconductor MAX77714 PMIC Support" depends on I2C diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index e057d6d6faef..d981690b5a12 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -168,6 +168,7 @@ obj-$(CONFIG_MFD_MAX77620) += max77620.o obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o +obj-$(CONFIG_MFD_MAX77705) += max77705.o obj-$(CONFIG_MFD_MAX77714) += max77714.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o @@ -233,6 +234,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o obj-$(CONFIG_MFD_RK8XX_SPI) += rk8xx-spi.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o +obj-$(CONFIG_MFD_S2DOS05) += s2dos05.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_MFD_VEXPRESS_SYSREG) += vexpress-sysreg.o diff --git a/drivers/mfd/max77705.c b/drivers/mfd/max77705.c new file mode 100644 index 000000000000..bf71d4399b23 --- /dev/null +++ b/drivers/mfd/max77705.c @@ -0,0 +1,233 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Maxim MAX77705 PMIC core driver +// +// Copyright (C) 2024 Dzmitry Sankouski + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_ADDR_FG 0x36 +#define FUEL_GAUGE_NAME "max77705-battery" + +const struct dev_pm_ops max77705_pm_ops; + +static struct mfd_cell max77705_devs[] = { + { + .name = "max77705-rgb", + .of_compatible = "maxim,max77705-rgb", + }, + { + .name = "max77705-charger", + .of_compatible = "maxim,max77705-charger", + }, + { + .name = "max77705-haptic", + .of_compatible = "maxim,max77705-haptic", + }, + { + .name = FUEL_GAUGE_NAME, + } +}; + +static const struct regmap_range max77705_readable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_PMICID1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), +}; + +static const struct regmap_range max77705_writable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_MAINCTRL1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), + +}; + +static const struct regmap_access_table max77705_readable_table = { + .yes_ranges = max77705_readable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_readable_ranges), +}; + +static const struct regmap_access_table max77705_writable_table = { + .yes_ranges = max77705_writable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_writable_ranges), +}; + +static const struct regmap_config max77705_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .rd_table = &max77705_readable_table, + .wr_table = &max77705_writable_table, + .max_register = MAX77705_PMIC_REG_USBC_RESET, +}; + +static const struct regmap_config max77705_leds_regmap_config = { + .reg_base = MAX77705_RGBLED_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_LED_REG_END, +}; + +static const struct regmap_irq max77705_topsys_irqs[] = { + { .mask = MAX77705_SYSTEM_IRQ_BSTEN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSUVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSOVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TSHDN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TM_INT, }, +}; + +static const struct regmap_irq_chip max77705_topsys_irq_chip = { + .name = "max77705-topsys", + .status_base = MAX77705_PMIC_REG_SYSTEM_INT, + .mask_base = MAX77705_PMIC_REG_SYSTEM_INT_MASK, + .num_regs = 1, + .irqs = max77705_topsys_irqs, + .num_irqs = ARRAY_SIZE(max77705_topsys_irqs), +}; + +static int max77705_i2c_probe(struct i2c_client *i2c) +{ + struct max77693_dev *max77705; + struct i2c_client *i2c_fg; + struct regmap_irq_chip_data *irq_data; + struct irq_domain *domain; + int ret; + unsigned int pmic_rev_value; + enum max77705_hw_rev pmic_rev; + + max77705 = devm_kzalloc(&i2c->dev, sizeof(*max77705), GFP_KERNEL); + if (!max77705) + return -ENOMEM; + + max77705->i2c = i2c; + max77705->dev = &i2c->dev; + max77705->irq = i2c->irq; + max77705->type = TYPE_MAX77705; + i2c_set_clientdata(i2c, max77705); + + max77705->regmap = devm_regmap_init_i2c(i2c, &max77705_regmap_config); + if (IS_ERR(max77705->regmap)) + return PTR_ERR(max77705->regmap); + + if (regmap_read(max77705->regmap, MAX77705_PMIC_REG_PMICREV, &pmic_rev_value) < 0) + return -ENODEV; + + pmic_rev = pmic_rev_value & MAX77705_REVISION_MASK; + if (pmic_rev != MAX77705_PASS3) + return dev_err_probe(max77705->dev, -ENODEV, + "Rev.0x%x is not tested\n", pmic_rev); + + max77705->regmap_leds = devm_regmap_init_i2c(i2c, &max77705_leds_regmap_config); + if (IS_ERR(max77705->regmap_leds)) + return dev_err_probe(max77705->dev, PTR_ERR(max77705->regmap_leds), + "Failed to register leds regmap\n"); + + ret = devm_regmap_add_irq_chip(max77705->dev, max77705->regmap, + max77705->irq, + IRQF_ONESHOT | IRQF_SHARED, 0, + &max77705_topsys_irq_chip, + &irq_data); + if (ret) + return dev_err_probe(max77705->dev, ret, "Failed to add irq chip\n"); + + /* Unmask interrupts from all blocks in interrupt source register */ + ret = regmap_update_bits(max77705->regmap, + MAX77705_PMIC_REG_INTSRC_MASK, + MAX77705_SRC_IRQ_ALL, (unsigned int)~MAX77705_SRC_IRQ_ALL); + if (ret < 0) + return dev_err_probe(max77705->dev, ret, + "Could not unmask interrupts in INTSRC\n"); + + domain = regmap_irq_get_domain(irq_data); + + i2c_fg = devm_i2c_new_dummy_device(max77705->dev, max77705->i2c->adapter, I2C_ADDR_FG); + if (IS_ERR(i2c_fg)) + return dev_err_probe(max77705->dev, PTR_ERR(i2c_fg), "Failed to add irq chip\n"); + + for (int i = 0;; i++) { + if (i >= ARRAY_SIZE(max77705_devs)) + return -EINVAL; + + if (!strcmp(max77705_devs[i].name, FUEL_GAUGE_NAME)) { + max77705_devs[i].platform_data = &i2c_fg; + max77705_devs[i].pdata_size = sizeof(i2c_fg); + break; + } + } + + ret = devm_mfd_add_devices(max77705->dev, PLATFORM_DEVID_NONE, + max77705_devs, ARRAY_SIZE(max77705_devs), + NULL, 0, domain); + if (ret) + return dev_err_probe(max77705->dev, ret, "Failed to register child devices\n"); + + device_init_wakeup(max77705->dev, true); + + return 0; +} + +static int max77705_suspend(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + struct max77693_dev *max77705 = i2c_get_clientdata(i2c); + + disable_irq(max77705->irq); + + if (device_may_wakeup(dev)) + enable_irq_wake(max77705->irq); + + return 0; +} + +static int max77705_resume(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + struct max77693_dev *max77705 = i2c_get_clientdata(i2c); + + if (device_may_wakeup(dev)) + disable_irq_wake(max77705->irq); + + enable_irq(max77705->irq); + + return 0; +} +DEFINE_SIMPLE_DEV_PM_OPS(max77705_pm_ops, max77705_suspend, max77705_resume); + +static const struct of_device_id max77705_i2c_of_match[] = { + { .compatible = "maxim,max77705" }, + { }, +}; +MODULE_DEVICE_TABLE(of, max77705_i2c_of_match); + +static struct i2c_driver max77705_i2c_driver = { + .driver = { + .name = "max77705", + .of_match_table = max77705_i2c_of_match, + .pm = pm_sleep_ptr(&max77705_pm_ops), + .suppress_bind_attrs = true, + }, + .probe = max77705_i2c_probe, +}; +module_i2c_driver(max77705_i2c_driver); + +MODULE_DESCRIPTION("Maxim MAX77705 PMIC core driver"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/max77693-common.h b/include/linux/mfd/max77693-common.h index a5bce099f1ed..ec2e1b2dceb8 100644 --- a/include/linux/mfd/max77693-common.h +++ b/include/linux/mfd/max77693-common.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Common data shared between Maxim 77693 and 77843 drivers + * Common data shared between Maxim 77693, 77705 and 77843 drivers * * Copyright (C) 2015 Samsung Electronics */ @@ -11,6 +11,7 @@ enum max77693_types { TYPE_MAX77693_UNKNOWN, TYPE_MAX77693, + TYPE_MAX77705, TYPE_MAX77843, TYPE_MAX77693_NUM, @@ -32,6 +33,7 @@ struct max77693_dev { struct regmap *regmap_muic; struct regmap *regmap_haptic; /* Only MAX77693 */ struct regmap *regmap_chg; /* Only MAX77843 */ + struct regmap *regmap_leds; /* Only MAX77705 */ struct regmap_irq_chip_data *irq_data_led; struct regmap_irq_chip_data *irq_data_topsys; diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h new file mode 100644 index 000000000000..cf4184063390 --- /dev/null +++ b/include/linux/mfd/max77705-private.h @@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Maxim MAX77705 definitions. + * + * Copyright (C) 2015 Samsung Electronics, Inc. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#ifndef __LINUX_MFD_MAX77705_PRIV_H +#define __LINUX_MFD_MAX77705_PRIV_H + +#define MAX77705_SRC_IRQ_CHG BIT(0) +#define MAX77705_SRC_IRQ_TOP BIT(1) +#define MAX77705_SRC_IRQ_FG BIT(2) +#define MAX77705_SRC_IRQ_USBC BIT(3) +#define MAX77705_SRC_IRQ_ALL (MAX77705_SRC_IRQ_CHG | MAX77705_SRC_IRQ_TOP | \ + MAX77705_SRC_IRQ_FG | MAX77705_SRC_IRQ_USBC) + +/* MAX77705_PMIC_REG_PMICREV register */ +#define MAX77705_VERSION_SHIFT 3 +#define MAX77705_REVISION_MASK GENMASK(2, 0) +#define MAX77705_VERSION_MASK GENMASK(7, MAX77705_VERSION_SHIFT) +/* MAX77705_PMIC_REG_MAINCTRL1 register */ +#define MAX77705_MAINCTRL1_BIASEN_SHIFT 7 +#define MAX77705_MAINCTRL1_BIASEN_MASK BIT(MAX77705_MAINCTRL1_BIASEN_SHIFT) +/* MAX77705_PMIC_REG_MCONFIG2 (haptics) register */ +#define MAX77705_CONFIG2_MEN_SHIFT 6 +#define MAX77705_CONFIG2_MODE_SHIFT 7 +#define MAX77705_CONFIG2_HTYP_SHIFT 5 +/* MAX77705_PMIC_REG_SYSTEM_INT_MASK register */ +#define MAX77705_SYSTEM_IRQ_BSTEN_INT BIT(3) +#define MAX77705_SYSTEM_IRQ_SYSUVLO_INT BIT(4) +#define MAX77705_SYSTEM_IRQ_SYSOVLO_INT BIT(5) +#define MAX77705_SYSTEM_IRQ_TSHDN_INT BIT(6) +#define MAX77705_SYSTEM_IRQ_TM_INT BIT(7) + +enum max77705_hw_rev { + MAX77705_PASS1 = 1, + MAX77705_PASS2, + MAX77705_PASS3, +}; + +enum max77705_reg { + MAX77705_PMIC_REG_PMICID1 = 0x00, + MAX77705_PMIC_REG_PMICREV = 0x01, + MAX77705_PMIC_REG_MAINCTRL1 = 0x02, + MAX77705_PMIC_REG_BSTOUT_MASK = 0x03, + MAX77705_PMIC_REG_FORCE_EN_MASK = 0x08, + MAX77705_PMIC_REG_MCONFIG = 0x10, + MAX77705_PMIC_REG_MCONFIG2 = 0x11, + MAX77705_PMIC_REG_INTSRC = 0x22, + MAX77705_PMIC_REG_INTSRC_MASK = 0x23, + MAX77705_PMIC_REG_SYSTEM_INT = 0x24, + MAX77705_PMIC_REG_RESERVED_25 = 0x25, + MAX77705_PMIC_REG_SYSTEM_INT_MASK = 0x26, + MAX77705_PMIC_REG_RESERVED_27 = 0x27, + MAX77705_PMIC_REG_RESERVED_28 = 0x28, + MAX77705_PMIC_REG_RESERVED_29 = 0x29, + MAX77705_PMIC_REG_BOOSTCONTROL1 = 0x4C, + MAX77705_PMIC_REG_BOOSTCONTROL2 = 0x4F, + MAX77705_PMIC_REG_SW_RESET = 0x50, + MAX77705_PMIC_REG_USBC_RESET = 0x51, + + MAX77705_PMIC_REG_END, +}; + +enum max77705_chg_reg { + MAX77705_CHG_REG_BASE = 0xB0, + MAX77705_CHG_REG_INT = 0, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHG_REG_INT_OK, + MAX77705_CHG_REG_DETAILS_00, + MAX77705_CHG_REG_DETAILS_01, + MAX77705_CHG_REG_DETAILS_02, + MAX77705_CHG_REG_DTLS_03, + MAX77705_CHG_REG_CNFG_00, + MAX77705_CHG_REG_CNFG_01, + MAX77705_CHG_REG_CNFG_02, + MAX77705_CHG_REG_CNFG_03, + MAX77705_CHG_REG_CNFG_04, + MAX77705_CHG_REG_CNFG_05, + MAX77705_CHG_REG_CNFG_06, + MAX77705_CHG_REG_CNFG_07, + MAX77705_CHG_REG_CNFG_08, + MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_REG_CNFG_10, + MAX77705_CHG_REG_CNFG_11, + MAX77705_CHG_REG_CNFG_12, + MAX77705_CHG_REG_CNFG_13, + MAX77705_CHG_REG_CNFG_14, + MAX77705_CHG_REG_SAFEOUT_CTRL, +}; + +enum max77705_fuelgauge_reg { + STATUS_REG = 0x00, + VALRT_THRESHOLD_REG = 0x01, + TALRT_THRESHOLD_REG = 0x02, + SALRT_THRESHOLD_REG = 0x03, + REMCAP_REP_REG = 0x05, + SOCREP_REG = 0x06, + TEMPERATURE_REG = 0x08, + VCELL_REG = 0x09, + TIME_TO_EMPTY_REG = 0x11, + FULLSOCTHR_REG = 0x13, + CURRENT_REG = 0x0A, + AVG_CURRENT_REG = 0x0B, + SOCMIX_REG = 0x0D, + SOCAV_REG = 0x0E, + REMCAP_MIX_REG = 0x0F, + FULLCAP_REG = 0x10, + RFAST_REG = 0x15, + AVR_TEMPERATURE_REG = 0x16, + CYCLES_REG = 0x17, + DESIGNCAP_REG = 0x18, + AVR_VCELL_REG = 0x19, + TIME_TO_FULL_REG = 0x20, + CONFIG_REG = 0x1D, + ICHGTERM_REG = 0x1E, + REMCAP_AV_REG = 0x1F, + FULLCAP_NOM_REG = 0x23, + LEARN_CFG_REG = 0x28, + FILTER_CFG_REG = 0x29, + MISCCFG_REG = 0x2B, + QRTABLE20_REG = 0x32, + FULLCAP_REP_REG = 0x35, + RCOMP_REG = 0x38, + VEMPTY_REG = 0x3A, + FSTAT_REG = 0x3D, + DISCHARGE_THRESHOLD_REG = 0x40, + QRTABLE30_REG = 0x42, + ISYS_REG = 0x43, + DQACC_REG = 0x45, + DPACC_REG = 0x46, + AVGISYS_REG = 0x4B, + QH_REG = 0x4D, + VSYS_REG = 0xB1, + TALRTTH2_REG = 0xB2, + VBYP_REG = 0xB3, + CONFIG2_REG = 0xBB, + IIN_REG = 0xD0, + OCV_REG = 0xEE, + VFOCV_REG = 0xFB, + VFSOC_REG = 0xFF, + + MAX77705_FG_END, +}; + +enum max77705_led_reg { + MAX77705_RGBLED_REG_BASE = 0x30, + MAX77705_RGBLED_REG_LEDEN = 0, + MAX77705_RGBLED_REG_LED0BRT, + MAX77705_RGBLED_REG_LED1BRT, + MAX77705_RGBLED_REG_LED2BRT, + MAX77705_RGBLED_REG_LED3BRT, + MAX77705_RGBLED_REG_LEDRMP, + MAX77705_RGBLED_REG_LEDBLNK, + MAX77705_LED_REG_END +}; + +enum max77705_charger_battery_state { + MAX77705_BATTERY_NOBAT, + MAX77705_BATTERY_PREQUALIFICATION, + MAX77705_BATTERY_DEAD, + MAX77705_BATTERY_GOOD, + MAX77705_BATTERY_LOWVOLTAGE, + MAX77705_BATTERY_OVERVOLTAGE, + MAX77705_BATTERY_RESERVED, +}; + +enum max77705_charger_charge_type { + MAX77705_CHARGER_CONSTANT_CURRENT = 1, + MAX77705_CHARGER_CONSTANT_VOLTAGE, + MAX77705_CHARGER_END_OF_CHARGE, + MAX77705_CHARGER_DONE, +}; + +#endif /* __LINUX_MFD_MAX77705_PRIV_H */ 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: 13899366 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:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13899367 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 078DC21B8FF; Mon, 9 Dec 2024 11:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743777; cv=none; b=Qdaa9xkc9Dv0omyVHB+jI2Qk+ffRjR8lNYd4Jw7kV1bbzFitEQArIPTwULDfMSh72SJqhxVmp/8uDHFFHlrnAvYxYk8KuNefy4r+5pWFEYiz0wFvBy6/FnSoroDNPiAI+BQMDJbpU4dECJ68KZGA9Vi4ZzQhJs+yCLlLOCDO86E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733743777; c=relaxed/simple; bh=rN9hGlthg/kYq7SaIPoJfascgOz1C20LFdB/2ikrWdY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iJWckd/89IbrHdkw8gu+ELR/kU/Ycq8+H9hHNKU5pyIrEYztzT+e9UqbT3CjfOYUnM9fR5Eay12pKk6RUcpUm0+2hwBDLwbsnsOyJ26V/2f5Z4EW/AI3z1IBbb7X5jXsqPaFme2bV3yxE48aWkiG78dl+zpcF89gyWQw7H9a0ec= 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=Fgv6LkMT; arc=none smtp.client-ip=209.85.208.47 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="Fgv6LkMT" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5ceb03aadb1so5485318a12.0; Mon, 09 Dec 2024 03:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733743773; x=1734348573; 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=XJyG0VljDYT5KY0vyto81RBvY0buF7EjYJR+rWwlULQ=; b=Fgv6LkMTL53RbUYUWdekqZ2UCNOk5Mmyeg+XcIhgfpxSgMKyKWft3gMg3q3Y+ug1Uz nbmv6fLzo1Xt6bkhi3tfVd5zVZtrkWPOnUp6iaCcjgPcGWm64iBbkytwC81TSae2VOm8 GPiJ88o8x33yrF8YVtNfKkn5IpH5ltEyEf9l1D0yszVpQZq7aeAhT4VFFfpDe+59421Z v7ndJ7+HIIxP65/UuAK3062HzkZGqAz09eu5zNZMRlX07F4ZOrPsQNNTk3VN+PFn2ekt pJlukYah3jwc7ETMJzc9cTTEmJygtHFz37Lf+YpDASsMA46zL46bya2a4Vvp8Jn0AhcD 4spA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733743773; x=1734348573; 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=XJyG0VljDYT5KY0vyto81RBvY0buF7EjYJR+rWwlULQ=; b=Xi/C+NrkGd3gIrbh95AJwpOetgaJdvROUse6Furpm0cN5qrFGFMw6SiBGlSjNVGklI So2GhCBM8UidsTwAuTo3Ilzks4bTlwL6BQnN9Tul92JgIFdyvnzwdXrHE4emLNxPfTXQ BSUHDEwx7UW+evgpHv8WDVLyLsAN9+c9VL6xtzXSQ9Xyc7+UtFTHWILRWCBPERC063Z0 aJPDobISKtJ0WcL3j3725V+sWOTxqijBC2QVimNE0rFUP6phRKFy5F34lG1jpK89ISZ0 vxa0Q889pRfHv4US27SiLHHVZXvNGuseNAFmaPrh/RqYhmcYisEiiKrF079fZBfHj1oc kYeA== X-Forwarded-Encrypted: i=1; AJvYcCV78hd4gRc28Tq93zkjW2NpTF5fdnq83WfO50uGdpDvejDE4zsFvH7ueGDxzlEoF7/FW3/U80jgpDTv1w==@vger.kernel.org, AJvYcCW6Y+MT+LNcsHYb8lPV9ZwFBEuCufaqzXsmpFn8bXedOkrwk9kR1LIB7hMlqgS1fqE0EiLXnJ803t5E@vger.kernel.org, AJvYcCWJlFxlhuEkvUPkWNOfxizTIUNk/lNXKmwE5kqPsWJDxM2p9EThiIwz5hbnIVeMpL1S3TJLdrLmdHBxA78=@vger.kernel.org, AJvYcCXz6ecjWUobz7q7vqlBzA8gxZyfHKUDlLFIqAaMgmY1rmhIkxBhJswcP7LvuT6IvvD1npv3RqLvFSeRToIH@vger.kernel.org X-Gm-Message-State: AOJu0Yzl4a/h2KZd4k+edrenwTpKRYPV46qxm9hreiM8uPk4HrrDwwcq dIZv6hfxBjU0XKOrX0W0yNU9P9m2EqOJvDwopuAIUBA06lTbjxG8 X-Gm-Gg: ASbGncvHUlqGQdyTFbgxrIw841T2LdtTnACeA8oUddbpC1kJVjCfcoBhetheNWjLt2f YpDPtW+5J3FQMtZTNp7kRVBtP6RBSp0tFV7kdE+OWpRbZ3rALvBx1aBYbhVVyXK3iewYEDUR/Xf ryrPrUJZ0wpYjyNoWJn0BukfNTL0izhsOOZZmbEn6oDrpuNoUuZ4b7KE4nca4/6s9U57apH/igi X4DUVcyg/vEtX5b9zePMtn5ooyj/RSNt2I0GpPqP0XjVzpc X-Google-Smtp-Source: AGHT+IGaGFiPCiHdKjn15Viml36dqcmLhiGclUWP5pimcpTl94eB53ORT2G0/vMMsA/l6RCE0mevig== X-Received: by 2002:a05:6402:2744:b0:5d1:22d2:8965 with SMTP id 4fb4d7f45d1cf-5d41863b7e8mr235238a12.30.1733743773120; Mon, 09 Dec 2024 03:29:33 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 03:29:32 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 09 Dec 2024 14:26:32 +0300 Subject: [PATCH v11 8/9] power: supply: max77705: Add charger driver for Maxim 77705 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-8-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=27537; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=rN9hGlthg/kYq7SaIPoJfascgOz1C20LFdB/2ikrWdY=; b=MCBkMNpkge48UwggreyepSN/eAZ8GW1KZ+LnmDpocun5kUwxlkWQ+htecm5Y3FSZvTzwTCtPR Y3SWtgFkPWgAi2+we/leTphsFoD0cs+91f2TyKkLld4XoVW6da3j39U X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add driver for Maxim 77705 switch-mode charger (part of max77705 MFD driver) providing power supply class information to userspace. The driver is configured through DTS (battery and system related settings). Signed-off-by: Dzmitry Sankouski --- Changes in v11: - remove multiple blank lines - return dev_err_probe - fit on one line where possible; Changes in v10: - never blank line between call and its error check - replace remove function with devm_add_action_or_reset - remove unused inline functions from header - use dev_err_probe for error handling Changes in v9: - move power supply registration before interrupts to prevent NULL exceptions when handling interrupts Changes for v8: - join lines, where fits 100 chars - change comment style C++ -> C - remove author from 'based on' file header statement Changes for v6: - add i2c init in driver - replace remove_new back on remove - handle IS_ERR(i2c_chg) Changes for v5: - remove const modifier from max77705_charger_irq_chip because it's modified with irq_drv_data in probe function - fix license to GPL 2.0 only, where old vendor code used GPL 2.0 only - move power header to power include dir - use same hardware name in Kconfig and module descriptions Changes for v4: - start from scratch - change word delimiters in filenames to '_' - use GENMASK in header - remove debugfs code - migrate to regmap_add_irq_chip - fix property getters to follow the same style --- drivers/power/supply/Kconfig | 6 ++ drivers/power/supply/Makefile | 1 + drivers/power/supply/max77705_charger.c | 586 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_charger.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 787 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 9f2eef6787f7..66264036b65d 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -583,6 +583,12 @@ config CHARGER_MAX77693 help Say Y to enable support for the Maxim MAX77693 battery charger. +config CHARGER_MAX77705 + tristate "Maxim MAX77705 battery charger driver" + depends on MFD_MAX77705 + help + Say Y to enable support for the Maxim MAX77705 battery charger. + config CHARGER_MAX77976 tristate "Maxim MAX77976 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 59c4a9f40d28..85d65b7aee1c 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o obj-$(CONFIG_CHARGER_DETECTOR_MAX14656) += max14656_charger_detector.o obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o +obj-$(CONFIG_CHARGER_MAX77705) += max77705_charger.o obj-$(CONFIG_CHARGER_MAX77976) += max77976_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o diff --git a/drivers/power/supply/max77705_charger.c b/drivers/power/supply/max77705_charger.c new file mode 100644 index 000000000000..0a4f0619c735 --- /dev/null +++ b/drivers/power/supply/max77705_charger.c @@ -0,0 +1,586 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on max77650-charger.c + * + * Copyright (C) 2024 Dzmitry Sankouski + * + * Battery charger driver for MAXIM 77705 charger/power-supply. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_ADDR_CHG 0x69 + +static const char *max77705_charger_model = "max77705"; +static const char *max77705_charger_manufacturer = "Maxim Integrated"; + +static const struct regmap_config max77705_chg_regmap_config = { + .reg_base = MAX77705_CHG_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_CHG_REG_SAFEOUT_CTRL, +}; + +static enum power_supply_property max77705_charger_props[] = { + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CHARGE_TYPE, + POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, +}; + +static int max77705_chgin_irq(void *irq_drv_data) +{ + struct max77705_charger_data *charger = irq_drv_data; + + queue_work(charger->wqueue, &charger->chgin_work); + + return 0; +} + +static const struct regmap_irq max77705_charger_irqs[] = { + { .mask = MAX77705_BYP_IM, }, + { .mask = MAX77705_INP_LIMIT_IM, }, + { .mask = MAX77705_BATP_IM, }, + { .mask = MAX77705_BAT_IM, }, + { .mask = MAX77705_CHG_IM, }, + { .mask = MAX77705_WCIN_IM, }, + { .mask = MAX77705_CHGIN_IM, }, + { .mask = MAX77705_AICL_IM, }, +}; + +static struct regmap_irq_chip max77705_charger_irq_chip = { + .name = "max77705-charger", + .status_base = MAX77705_CHG_REG_INT, + .mask_base = MAX77705_CHG_REG_INT_MASK, + .handle_post_irq = max77705_chgin_irq, + .num_regs = 1, + .irqs = max77705_charger_irqs, + .num_irqs = ARRAY_SIZE(max77705_charger_irqs), +}; + +static int max77705_charger_enable(struct max77705_charger_data *chg) +{ + int rv; + + rv = regmap_update_bits(chg->regmap, MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_EN_MASK, MAX77705_CHG_EN_MASK); + if (rv) + dev_err(chg->dev, "unable to enable the charger: %d\n", rv); + + return rv; +} + +static void max77705_charger_disable(void *data) +{ + struct max77705_charger_data *chg = data; + int rv; + + rv = regmap_update_bits(chg->regmap, + MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_EN_MASK, + MAX77705_CHG_DISABLE); + if (rv) + dev_err(chg->dev, "unable to disable the charger: %d\n", rv); +} + +static int max77705_get_online(struct regmap *regmap, int *val) +{ + unsigned int data; + int ret; + + ret = regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &data); + if (ret < 0) + return ret; + + *val = !!(data & MAX77705_CHGIN_OK); + + return 0; +} + +static int max77705_check_battery(struct max77705_charger_data *charger, int *val) +{ + unsigned int reg_data; + unsigned int reg_data2; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_INT_OK, ®_data); + + dev_dbg(charger->dev, "CHG_INT_OK(0x%x)\n", reg_data); + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_00, ®_data2); + + dev_dbg(charger->dev, "CHG_DETAILS00(0x%x)\n", reg_data2); + + if ((reg_data & MAX77705_BATP_OK) || !(reg_data2 & MAX77705_BATP_DTLS)) + *val = true; + else + *val = false; + + return 0; +} + +static int max77705_get_charge_type(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + if (!MAX77705_CHARGER_CHG_CHARGING(reg_data)) { + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + reg_data &= MAX77705_CHG_DTLS; + + switch (reg_data) { + case 0x0: + case MAX77705_CHARGER_CONSTANT_CURRENT: + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + *val = POWER_SUPPLY_CHARGE_TYPE_FAST; + return 0; + default: + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + return 0; +} + +static int max77705_get_status(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + if (!MAX77705_CHARGER_CHG_CHARGING(reg_data)) { + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + reg_data &= MAX77705_CHG_DTLS; + + switch (reg_data) { + case 0x0: + case MAX77705_CHARGER_CONSTANT_CURRENT: + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + *val = POWER_SUPPLY_STATUS_CHARGING; + return 0; + case MAX77705_CHARGER_END_OF_CHARGE: + case MAX77705_CHARGER_DONE: + *val = POWER_SUPPLY_STATUS_FULL; + return 0; + /* those values hard coded as in vendor kernel, because of */ + /* failure to determine it's actual meaning. */ + case 0x05: + case 0x06: + case 0x07: + *val = POWER_SUPPLY_STATUS_NOT_CHARGING; + return 0; + case 0x08: + case 0xA: + case 0xB: + *val = POWER_SUPPLY_STATUS_DISCHARGING; + return 0; + default: + *val = POWER_SUPPLY_STATUS_UNKNOWN; + return 0; + } + + return 0; +} + +static int max77705_get_vbus_state(struct regmap *regmap, int *value) +{ + int ret; + unsigned int charge_dtls; + + ret = regmap_read(regmap, MAX77705_CHG_REG_DETAILS_00, &charge_dtls); + if (ret) + return ret; + + charge_dtls = ((charge_dtls & MAX77705_CHGIN_DTLS) >> + MAX77705_CHGIN_DTLS_SHIFT); + + switch (charge_dtls) { + case 0x00: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x01: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x02: + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + case 0x03: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + default: + return 0; + } + return 0; +} + +static int max77705_get_battery_health(struct max77705_charger_data *charger, + int *value) +{ + struct regmap *regmap = charger->regmap; + unsigned int bat_dtls; + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, &bat_dtls); + bat_dtls = ((bat_dtls & MAX77705_BAT_DTLS) >> MAX77705_BAT_DTLS_SHIFT); + + switch (bat_dtls) { + case MAX77705_BATTERY_NOBAT: + dev_dbg(charger->dev, "%s: No battery and the charger is suspended\n", + __func__); + *value = POWER_SUPPLY_HEALTH_NO_BATTERY; + break; + case MAX77705_BATTERY_PREQUALIFICATION: + dev_dbg(charger->dev, "%s: battery is okay but its voltage is low(~VPQLB)\n", + __func__); + break; + case MAX77705_BATTERY_DEAD: + dev_dbg(charger->dev, "%s: battery dead\n", __func__); + *value = POWER_SUPPLY_HEALTH_DEAD; + break; + case MAX77705_BATTERY_GOOD: + case MAX77705_BATTERY_LOWVOLTAGE: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + case MAX77705_BATTERY_OVERVOLTAGE: + dev_dbg(charger->dev, "%s: battery ovp\n", __func__); + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + default: + dev_dbg(charger->dev, "%s: battery unknown\n", __func__); + *value = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; + break; + } + + return 0; +} + +static int max77705_get_health(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + int ret, is_online = 0; + + ret = max77705_get_online(regmap, &is_online); + if (ret) + return ret; + if (is_online) { + ret = max77705_get_vbus_state(regmap, val); + if (ret || (*val != POWER_SUPPLY_HEALTH_GOOD)) + return ret; + } + return max77705_get_battery_health(charger, val); +} + +static int max77705_get_input_current(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data; + int get_current = 0; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + + reg_data &= MAX77705_CHG_CHGIN_LIM_MASK; + + if (reg_data <= 3) + get_current = 100; + else if (reg_data >= MAX77705_CHG_CHGIN_LIM_MASK) + get_current = MAX77705_CURRENT_CHGIN_MAX; + else + get_current = (reg_data + 1) * 25; + + *val = get_current; + + return 0; +} + +static int max77705_get_charge_current(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_02, ®_data); + reg_data &= MAX77705_CHG_CC; + + *val = reg_data <= 0x2 ? 100 : reg_data * 50; + + return 0; +} + +static int max77705_set_float_voltage(struct max77705_charger_data *charger, + int float_voltage) +{ + int float_voltage_mv; + unsigned int reg_data = 0; + struct regmap *regmap = charger->regmap; + + float_voltage_mv = float_voltage / 1000; + reg_data = float_voltage_mv <= 4000 ? 0x0 : + float_voltage_mv >= 4500 ? 0x23 : + (float_voltage_mv <= 4200) ? (float_voltage_mv - 4000) / 50 : + (((float_voltage_mv - 4200) / 10) + 0x04); + + return regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_04, + MAX77705_CHG_CV_PRM_MASK, + (reg_data << MAX77705_CHG_CV_PRM_SHIFT)); +} + +static int max77705_get_float_voltage(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data = 0; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, ®_data); + reg_data &= MAX77705_CHG_PRM_MASK; + *val = reg_data <= 0x04 ? reg_data * 50 + 4000 : + (reg_data - 4) * 10 + 4200; + + return 0; +} + +static int max77705_chg_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct max77705_charger_data *charger = power_supply_get_drvdata(psy); + struct regmap *regmap = charger->regmap; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + return max77705_get_online(regmap, &val->intval); + case POWER_SUPPLY_PROP_PRESENT: + return max77705_check_battery(charger, &val->intval); + case POWER_SUPPLY_PROP_STATUS: + return max77705_get_status(charger, &val->intval); + case POWER_SUPPLY_PROP_CHARGE_TYPE: + return max77705_get_charge_type(charger, &val->intval); + case POWER_SUPPLY_PROP_HEALTH: + return max77705_get_health(charger, &val->intval); + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + return max77705_get_input_current(charger, &val->intval); + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + return max77705_get_charge_current(charger, &val->intval); + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + return max77705_get_float_voltage(charger, &val->intval); + case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: + val->intval = charger->bat_info->voltage_max_design_uv; + break; + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = max77705_charger_model; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = max77705_charger_manufacturer; + break; + default: + return -EINVAL; + } + return 0; +} + +static const struct power_supply_desc max77705_charger_psy_desc = { + .name = "max77705-charger", + .type = POWER_SUPPLY_TYPE_USB, + .properties = max77705_charger_props, + .num_properties = ARRAY_SIZE(max77705_charger_props), + .get_property = max77705_chg_get_property, +}; + +static void max77705_chgin_isr_work(struct work_struct *work) +{ + struct max77705_charger_data *charger = + container_of(work, struct max77705_charger_data, chgin_work); + power_supply_changed(charger->psy_chg); +} + +static void max77705_charger_initialize(struct max77705_charger_data *chg) +{ + u8 reg_data; + struct power_supply_battery_info *info; + struct regmap *regmap = chg->regmap; + + if (power_supply_get_battery_info(chg->psy_chg, &info) < 0) + return; + + chg->bat_info = info; + + /* unlock charger setting protect */ + /* slowest LX slope */ + reg_data = MAX77705_CHGPROT_MASK | MAX77705_SLOWEST_LX_SLOPE; + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_06, reg_data, + reg_data); + + /* fast charge timer disable */ + /* restart threshold disable */ + /* pre-qual charge disable */ + reg_data = (MAX77705_FCHGTIME_DISABLE << MAX77705_FCHGTIME_SHIFT) | + (MAX77705_CHG_RSTRT_DISABLE << MAX77705_CHG_RSTRT_SHIFT) | + (MAX77705_CHG_PQEN_DISABLE << MAX77705_PQEN_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_01, + (MAX77705_FCHGTIME_MASK | + MAX77705_CHG_RSTRT_MASK | + MAX77705_PQEN_MASK), + reg_data); + + /* OTG off(UNO on), boost off */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + MAX77705_OTG_CTRL, 0); + + /* charge current 450mA(default) */ + /* otg current limit 900mA */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, + MAX77705_OTG_ILIM_MASK, + MAX77705_OTG_ILIM_900 << MAX77705_OTG_ILIM_SHIFT); + + /* BAT to SYS OCP 4.80A */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_05, + MAX77705_REG_B2SOVRC_MASK, + MAX77705_B2SOVRC_4_8A << MAX77705_REG_B2SOVRC_SHIFT); + /* top off current 150mA */ + /* top off timer 30min */ + reg_data = (MAX77705_TO_ITH_150MA << MAX77705_TO_ITH_SHIFT) | + (MAX77705_TO_TIME_30M << MAX77705_TO_TIME_SHIFT) | + (MAX77705_SYS_TRACK_DISABLE << MAX77705_SYS_TRACK_DIS_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_03, + (MAX77705_TO_ITH_MASK | + MAX77705_TO_TIME_MASK | + MAX77705_SYS_TRACK_DIS_MASK), reg_data); + + /* cv voltage 4.2V or 4.35V */ + /* MINVSYS 3.6V(default) */ + if (info->voltage_max_design_uv < 0) { + dev_warn(chg->dev, "missing battery:voltage-max-design-microvolt\n"); + max77705_set_float_voltage(chg, 4200000); + } else { + max77705_set_float_voltage(chg, info->voltage_max_design_uv); + } + + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, + MAX77705_VCHGIN_REG_MASK, MAX77705_VCHGIN_4_5); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, + MAX77705_WCIN_REG_MASK, MAX77705_WCIN_4_5); + + /* Watchdog timer */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + MAX77705_WDTEN_MASK, 0); + + /* Active Discharge Enable */ + regmap_update_bits(regmap, MAX77705_PMIC_REG_MAINCTRL1, 1, 1); + + /* VBYPSET=5.0V */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_11, MAX77705_VBYPSET_MASK, 0); + + /* Switching Frequency : 1.5MHz */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_08, MAX77705_REG_FSW_MASK, + (MAX77705_CHG_FSW_1_5MHz << MAX77705_REG_FSW_SHIFT)); + + /* Auto skip mode */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, MAX77705_REG_DISKIP_MASK, + (MAX77705_AUTO_SKIP << MAX77705_REG_DISKIP_SHIFT)); +} + +static int max77705_charger_probe(struct platform_device *pdev) +{ + struct power_supply_config pscfg = {}; + struct i2c_client *i2c_chg; + struct max77693_dev *max77705; + struct max77705_charger_data *chg; + struct device *dev, *parent; + struct regmap_irq_chip_data *irq_data; + int ret; + + dev = &pdev->dev; + parent = dev->parent; + max77705 = dev_get_drvdata(parent); + + chg = devm_kzalloc(dev, sizeof(*chg), GFP_KERNEL); + if (!chg) + return -ENOMEM; + + platform_set_drvdata(pdev, chg); + + i2c_chg = devm_i2c_new_dummy_device(dev, max77705->i2c->adapter, I2C_ADDR_CHG); + if (IS_ERR(i2c_chg)) + return PTR_ERR(i2c_chg); + + chg->regmap = devm_regmap_init_i2c(i2c_chg, &max77705_chg_regmap_config); + if (IS_ERR(chg->regmap)) + return PTR_ERR(chg->regmap); + + chg->dev = dev; + + ret = regmap_update_bits(chg->regmap, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHGIN_IM, 0); + if (ret) + return ret; + + pscfg.of_node = dev->of_node; + pscfg.drv_data = chg; + + chg->psy_chg = devm_power_supply_register(dev, &max77705_charger_psy_desc, &pscfg); + if (IS_ERR(chg->psy_chg)) + return PTR_ERR(chg->psy_chg); + + max77705_charger_irq_chip.irq_drv_data = chg; + ret = devm_regmap_add_irq_chip(chg->dev, chg->regmap, max77705->irq, + IRQF_ONESHOT | IRQF_SHARED, 0, + &max77705_charger_irq_chip, + &irq_data); + if (ret) + return dev_err_probe(dev, ret, "failed to add irq chip\n"); + + chg->wqueue = create_singlethread_workqueue(dev_name(dev)); + if (IS_ERR(chg->wqueue)) + return dev_err_probe(dev, PTR_ERR(chg->wqueue), "failed to create workqueue\n"); + + INIT_WORK(&chg->chgin_work, max77705_chgin_isr_work); + + max77705_charger_initialize(chg); + + ret = devm_add_action_or_reset(dev, max77705_charger_disable, chg); + if (ret) + return ret; + + return max77705_charger_enable(chg); +} + +static const struct of_device_id max77705_charger_of_match[] = { + { .compatible = "maxim,max77705-charger" }, + { } +}; +MODULE_DEVICE_TABLE(of, max77705_charger_of_match); + +static struct platform_driver max77705_charger_driver = { + .driver = { + .name = "max77705-charger", + .of_match_table = max77705_charger_of_match, + }, + .probe = max77705_charger_probe, +}; +module_platform_driver(max77705_charger_driver); + +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_DESCRIPTION("Maxim MAX77705 charger driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/power/max77705_charger.h b/include/linux/power/max77705_charger.h new file mode 100644 index 000000000000..cb5cd03e54e2 --- /dev/null +++ b/include/linux/power/max77705_charger.h @@ -0,0 +1,194 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Maxim MAX77705 definitions. + * + * Copyright (C) 2015 Samsung Electronics, Inc. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#ifndef __MAX77705_CHARGER_H +#define __MAX77705_CHARGER_H __FILE__ + +/* MAX77705_CHG_REG_CHG_INT */ +#define MAX77705_BYP_I BIT(0) +#define MAX77705_INP_LIMIT_I BIT(1) +#define MAX77705_BATP_I BIT(2) +#define MAX77705_BAT_I BIT(3) +#define MAX77705_CHG_I BIT(4) +#define MAX77705_WCIN_I BIT(5) +#define MAX77705_CHGIN_I BIT(6) +#define MAX77705_AICL_I BIT(7) + +/* MAX77705_CHG_REG_CHG_INT_MASK */ +#define MAX77705_BYP_IM BIT(0) +#define MAX77705_INP_LIMIT_IM BIT(1) +#define MAX77705_BATP_IM BIT(2) +#define MAX77705_BAT_IM BIT(3) +#define MAX77705_CHG_IM BIT(4) +#define MAX77705_WCIN_IM BIT(5) +#define MAX77705_CHGIN_IM BIT(6) +#define MAX77705_AICL_IM BIT(7) + +/* MAX77705_CHG_REG_CHG_INT_OK */ +#define MAX77705_BYP_OK BIT(0) +#define MAX77705_DISQBAT_OK BIT(1) +#define MAX77705_BATP_OK BIT(2) +#define MAX77705_BAT_OK BIT(3) +#define MAX77705_CHG_OK BIT(4) +#define MAX77705_WCIN_OK BIT(5) +#define MAX77705_CHGIN_OK BIT(6) +#define MAX77705_AICL_OK BIT(7) + +/* MAX77705_CHG_REG_DETAILS_00 */ +#define MAX77705_BATP_DTLS BIT(0) +#define MAX77705_WCIN_DTLS GENMASK(4, 3) +#define MAX77705_WCIN_DTLS_SHIFT 3 +#define MAX77705_CHGIN_DTLS GENMASK(6, 5) +#define MAX77705_CHGIN_DTLS_SHIFT 5 + +/* MAX77705_CHG_REG_DETAILS_01 */ +#define MAX77705_CHG_DTLS GENMASK(3, 0) +#define MAX77705_CHG_DTLS_SHIFT 0 +#define MAX77705_BAT_DTLS GENMASK(6, 4) +#define MAX77705_BAT_DTLS_SHIFT 4 + +/* MAX77705_CHG_REG_DETAILS_02 */ +#define MAX77705_BYP_DTLS GENMASK(3, 0) +#define MAX77705_BYP_DTLS_SHIFT 0 + +/* MAX77705_CHG_REG_CNFG_00 */ +#define MAX77705_CHG_SHIFT 0 +#define MAX77705_UNO_SHIFT 1 +#define MAX77705_OTG_SHIFT 1 +#define MAX77705_BUCK_SHIFT 2 +#define MAX77705_BOOST_SHIFT 3 +#define MAX77705_WDTEN_SHIFT 4 +#define MAX77705_MODE_MASK GENMASK(3, 0) +#define MAX77705_CHG_MASK BIT(MAX77705_CHG_SHIFT) +#define MAX77705_UNO_MASK BIT(MAX77705_UNO_SHIFT) +#define MAX77705_OTG_MASK BIT(MAX77705_OTG_SHIFT) +#define MAX77705_BUCK_MASK BIT(MAX77705_BUCK_SHIFT) +#define MAX77705_BOOST_MASK BIT(MAX77705_BOOST_SHIFT) +#define MAX77705_WDTEN_MASK BIT(MAX77705_WDTEN_SHIFT) +#define MAX77705_UNO_CTRL (MAX77705_UNO_MASK | MAX77705_BOOST_MASK) +#define MAX77705_OTG_CTRL (MAX77705_OTG_MASK | MAX77705_BOOST_MASK) + +/* MAX77705_CHG_REG_CNFG_01 */ +#define MAX77705_FCHGTIME_SHIFT 0 +#define MAX77705_FCHGTIME_MASK GENMASK(2, 0) +#define MAX77705_CHG_RSTRT_SHIFT 4 +#define MAX77705_CHG_RSTRT_MASK GENMASK(5, 4) +#define MAX77705_FCHGTIME_DISABLE 0 +#define MAX77705_CHG_RSTRT_DISABLE 0x3 + +#define MAX77705_PQEN_SHIFT 7 +#define MAX77705_PQEN_MASK BIT(7) +#define MAX77705_CHG_PQEN_DISABLE 0 +#define MAX77705_CHG_PQEN_ENABLE 1 + +/* MAX77705_CHG_REG_CNFG_02 */ +#define MAX77705_OTG_ILIM_SHIFT 6 +#define MAX77705_OTG_ILIM_MASK GENMASK(7, 6) +#define MAX77705_OTG_ILIM_500 0 +#define MAX77705_OTG_ILIM_900 1 +#define MAX77705_OTG_ILIM_1200 2 +#define MAX77705_OTG_ILIM_1500 3 +#define MAX77705_CHG_CC GENMASK(5, 0) + +/* MAX77705_CHG_REG_CNFG_03 */ +#define MAX77705_TO_ITH_SHIFT 0 +#define MAX77705_TO_ITH_MASK GENMASK(2, 0) +#define MAX77705_TO_TIME_SHIFT 3 +#define MAX77705_TO_TIME_MASK GENMASK(5, 3) +#define MAX77705_SYS_TRACK_DIS_SHIFT 7 +#define MAX77705_SYS_TRACK_DIS_MASK BIT(7) +#define MAX77705_TO_ITH_150MA 0 +#define MAX77705_TO_TIME_30M 3 +#define MAX77705_SYS_TRACK_ENABLE 0 +#define MAX77705_SYS_TRACK_DISABLE 1 + +/* MAX77705_CHG_REG_CNFG_04 */ +#define MAX77705_CHG_MINVSYS_SHIFT 6 +#define MAX77705_CHG_MINVSYS_MASK GENMASK(7, 6) +#define MAX77705_CHG_PRM_SHIFT 0 +#define MAX77705_CHG_PRM_MASK GENMASK(5, 0) + +#define MAX77705_CHG_CV_PRM_SHIFT 0 +#define MAX77705_CHG_CV_PRM_MASK GENMASK(5, 0) + +/* MAX77705_CHG_REG_CNFG_05 */ +#define MAX77705_REG_B2SOVRC_SHIFT 0 +#define MAX77705_REG_B2SOVRC_MASK GENMASK(3, 0) +#define MAX77705_B2SOVRC_DISABLE 0 +#define MAX77705_B2SOVRC_4_5A 6 +#define MAX77705_B2SOVRC_4_8A 8 +#define MAX77705_B2SOVRC_5_0A 9 + +/* MAX77705_CHG_CNFG_06 */ +#define MAX77705_WDTCLR_SHIFT 0 +#define MAX77705_WDTCLR_MASK GENMASK(1, 0) +#define MAX77705_WDTCLR 1 +#define MAX77705_CHGPROT_MASK GENMASK(3, 2) +#define MAX77705_CHGPROT_UNLOCKED GENMASK(3, 2) +#define MAX77705_SLOWEST_LX_SLOPE GENMASK(6, 5) + +/* MAX77705_CHG_REG_CNFG_07 */ +#define MAX77705_CHG_FMBST 4 +#define MAX77705_REG_FMBST_SHIFT 2 +#define MAX77705_REG_FMBST_MASK BIT(MAX77705_REG_FMBST_SHIFT) +#define MAX77705_REG_FGSRC_SHIFT 1 +#define MAX77705_REG_FGSRC_MASK BIT(MAX77705_REG_FGSRC_SHIFT) + +/* MAX77705_CHG_REG_CNFG_08 */ +#define MAX77705_REG_FSW_SHIFT 0 +#define MAX77705_REG_FSW_MASK GENMASK(1, 0) +#define MAX77705_CHG_FSW_3MHz 0 +#define MAX77705_CHG_FSW_2MHz 1 +#define MAX77705_CHG_FSW_1_5MHz 2 + +/* MAX77705_CHG_REG_CNFG_09 */ +#define MAX77705_CHG_CHGIN_LIM_MASK GENMASK(6, 0) +#define MAX77705_CHG_EN_MASK BIT(7) +#define MAX77705_CHG_DISABLE 0 +#define MAX77705_CHARGER_CHG_CHARGING(_reg) \ + (((_reg) & MAX77705_CHG_EN_MASK) > 1) + + +/* MAX77705_CHG_REG_CNFG_10 */ +#define MAX77705_CHG_WCIN_LIM GENMASK(5, 0) + +/* MAX77705_CHG_REG_CNFG_11 */ +#define MAX77705_VBYPSET_SHIFT 0 +#define MAX77705_VBYPSET_MASK GENMASK(6, 0) + +/* MAX77705_CHG_REG_CNFG_12 */ +#define MAX77705_CHGINSEL_SHIFT 5 +#define MAX77705_CHGINSEL_MASK BIT(MAX77705_CHGINSEL_SHIFT) +#define MAX77705_WCINSEL_SHIFT 6 +#define MAX77705_WCINSEL_MASK BIT(MAX77705_WCINSEL_SHIFT) +#define MAX77705_VCHGIN_REG_MASK GENMASK(4, 3) +#define MAX77705_WCIN_REG_MASK GENMASK(2, 1) +#define MAX77705_REG_DISKIP_SHIFT 0 +#define MAX77705_REG_DISKIP_MASK BIT(MAX77705_REG_DISKIP_SHIFT) +/* REG=4.5V, UVLO=4.7V */ +#define MAX77705_VCHGIN_4_5 0 +/* REG=4.5V, UVLO=4.7V */ +#define MAX77705_WCIN_4_5 0 +#define MAX77705_DISABLE_SKIP 1 +#define MAX77705_AUTO_SKIP 0 + +/* mA */ +#define MAX77705_CURRENT_STEP 25 +#define MAX77705_CURRENT_WCIN_MAX 1600 +#define MAX77705_CURRENT_CHGIN_MAX 3200 + +struct max77705_charger_data { + struct device *dev; + struct regmap *regmap; + struct power_supply_battery_info *bat_info; + struct workqueue_struct *wqueue; + struct work_struct chgin_work; + struct power_supply *psy_chg; +}; + +#endif /* __MAX77705_CHARGER_H */ 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: 13899368 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,