From patchwork Mon Dec 23 13:59:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853114 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D28C1F16B; Mon, 23 Dec 2024 13:59:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962398; cv=none; b=lr7mQwEaGqKEJmMEp9QdZZ8wsMIQ825pOKK2IiQamXK4QaPA3AYiPEtg7uWbA2fIglJtZQVVOAOiZU8hAZtItkrxd8dNIMtqIyBEFu87Zjd8nk7IFsQbGIbUR0PnkIUWSeQCzyFMLn2t6wvj30x/qODYK/S421VBZBlTzDW6Avc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962398; c=relaxed/simple; bh=rXMMoUEBWsz761qBBGBqdbWKIdj1EFYCUeoxnRId9F4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u4GuaGLmGkrrX78FRwz9R7Zfz2dFeKNkU0+DnAt9r3k3LXknLLvW0GuppQhLJRsUaryF7cWvQ3dduBlMKscdtLvJxh953VUIG0aA4yjuxHWMsX9ATQPO6Z2aK4qPRMkQMdlocB9Hvpvet2QLT7M4vcMk1t+cHhZoUgSMqNNLKIs= 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=keKU8rvK; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="keKU8rvK" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aa543c4db92so510281066b.0; Mon, 23 Dec 2024 05:59:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962394; x=1735567194; 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=EemsH4Zp9goG/DvipUIIJ+D3oeBJrKh5E5A6/JLDo5M=; b=keKU8rvKGx6nZBMxPFkhjAw9PRYqXl4kVGZ4ldcQfv/dYOqlYZBXrCotSeUmrWoeO7 ndOAGMnyqZ1Sn1OM8gv016M8iBqPTO7La40FX8bFxrKs2ixWoQdKTDZ+BKdBuauxGuMt CASuGGzOVw6sBLYj638jYX/mh+rNo2Ho/OAkpEapsrvMLG4gw9scd7ZAMvck6RQ0+12p 3NgJY8mcDz/uoPHyOtXG9khRoQOgNlvjW8bzHLQtyDhpi0pndKKa9sD08yFsoJoRHZyy 7PGsTjYITXV4Y0+r3T//5dNjaT3NmCNwgh6iQO8hoF75SzNUYm23nB/nGRlJD6BLgAMs aSUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962394; x=1735567194; 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=EemsH4Zp9goG/DvipUIIJ+D3oeBJrKh5E5A6/JLDo5M=; b=Cqw4iSRh/GjReote8xBvHLl7TO2x7i2VJEVLZLwoYtAv78e/Lcj75ThTFcTaltqiiY jcVPcViWNDu4AXWzSCXDp9su5hDfsGsu/mS16ZuRZWfDLsIsqqQxUU3rZsJzoZ291mU1 4M4i3M/inD7qdrw5NyBfBUDzlMzUhU19aCgViPs5/yDAFVD1gRowkaMIbr3oC7L9h2sU sMbvM2LW35lM2o3t4YJbqNxNiKk+gC5TGhTlA3JLGZyO5lFyNa22bOT/VXC2aAOUa8do VO/re6Iv7FrPBTF4+CMIuAH+QTtvGwU6m3zk/KDQGtnO6dl+OpLUvsRW1IeQe5dEsLe2 +QQw== X-Forwarded-Encrypted: i=1; AJvYcCUymDn6R0SzVsvqNfgqOeZykFNfF9sb3+kcZyble206AhCX9FSsjkCx5hkNpf+k85Z0tW6pEzWcLt7kT4mr@vger.kernel.org, AJvYcCVK6PXqyqCuXv6uoQlmd4qhZn4mi1ADe8t6NKTmq4oyMakooDKAKdDG5lNI0pEusM9EORJIU35YozEC@vger.kernel.org, AJvYcCX9I59kIWr+qFFI+3+F2l4O2igmo27ht/nnRD19KvOMzOnZYNGV2wnCxt6dpfWks9B+qYSlRlutPostGQ==@vger.kernel.org, AJvYcCXYI/R2atIHZ80/jTZ9y3GwN4Tyw9/jE4m7FNIlCqL31Lv8aGjuQA3rqECc/+1UyviC4RSwOTJeA/zsCQY=@vger.kernel.org X-Gm-Message-State: AOJu0YwHwi45TO+qXgM/9ZgcqT/kTybcJQaL/oeFSXgvveeaGfmkGbzA DnuOEQQjY5DU6K9CxFEIpeSckkMLAewYhLS/2beOTDEJWE4leG9nhI5rHA== X-Gm-Gg: ASbGncun7r16QhAmZhbqu4V2eXS6wxbXFoFya/+d5oYbcwGguUtwUMn+cBkT4PYeCWn oS2anbKqO9qyw/VEtwQKDBliG3DQuPeYhasYQrDcRQ7QhmTjFhBcW3fBpDX+yO5QQ5m+xbaOVN9 SrxVcc79cyrWQ71hz540Gi6N8Jtn1tMXjkZYaDR9/EF0M3P4sUUq+HHEyK/Ohg4ZfL1+VEOD1QY Lozgk6AG34rtAtgkTwHoYeQpftI4edICUR4XWCtUGfrWM4wzbA+1r8v1U3v6Bym61MySK3N4POT pMsVjz6p8BH9eCkLWveraG2vpg== X-Google-Smtp-Source: AGHT+IF0EbdUr/tJzpVwdi1m5M2HcJk6VLrzISyRN02kI778SSneOk1QaXf9+pybPSYjkL5mVa8DWQ== X-Received: by 2002:a17:907:2d29:b0:aa6:9503:aa73 with SMTP id a640c23a62f3a-aac3378bb24mr1110351566b.51.1734962394159; Mon, 23 Dec 2024 05:59:54 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.05.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 05:59:53 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:38 +0300 Subject: [PATCH v13 01/10] power: supply: add undervoltage health status property Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-1-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=2343; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=rXMMoUEBWsz761qBBGBqdbWKIdj1EFYCUeoxnRId9F4=; b=R0CTiByOwCpn2ajKwfow2P3ccBfioOfzIcXuNCmHH7ekm6fLRXch7MHrPG65WHKorMHjnXN5D bYo54tmz09fA7ln5bT2IGXBbXhiWpiqcadnK2jD5eHoXKm9OMdydZn0 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 cb53dde20a80..2a5c1a09a28f 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -453,7 +453,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 9ce5eda24093..edb058c19c9c 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 c3ce9f2b17d4..6ed53b292162 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -60,6 +60,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 23 13:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853771 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 C02051B0F11; Mon, 23 Dec 2024 13:59:58 +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=1734962400; cv=none; b=oGZMqF/3V2QX7DO+GBrLK38ZmF3sZkQ2p6KyMdChGDKeSbNMLTbbVebnk4bFIHn9LG5XRt0tuWEg8tM8kCzXxkg0WmFtX/lIODsqIdafKMoUVNrNS3jLcS0b2lOSgqyfIB50/DQW/P/MYbNvZ3ZtWXS8xywer2KW//sn+iufipU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962400; c=relaxed/simple; bh=uK2VytpAhIaw1vGXP3QtafCIlq4zr6S/aIWCWDyWjKo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dd29PJo2scFTb2DwEPY47ugxtDZrnjuZaYsEHgt+aXiPsync1b/tIeKeE1fW1OnqBTyrIHjC093QKHhmk2axwhpFtqIjOwr4tEgzM3QZH2P4wWeAr/hYpra9FpI+rWh14fOTUHVAsbaj7GnQknmn3WcCvXN/P0lkaAtVgV2cpQk= 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=ONpLbVqG; 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="ONpLbVqG" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5d3d14336f0so887022a12.3; Mon, 23 Dec 2024 05:59:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962397; x=1735567197; 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=z2aKeZ7sTU4LK+Isj7RaoM/yVOdhmMcPqm/rlVkOhUE=; b=ONpLbVqGXHNQq1JlXKNpi7lkmJTrhDkvZwHITwgiQXKIYCycKFgrE+NEzxPJObQOFL WPOAE8L4oE5rO/slkhnZ84DXaBCaM4+abjGgX7LPy20kKxpDZFnZ3vCFBurkNCe2od4D cT8ufPxccoDJCYButgelu7wX3Nl8FmkHKPfyTZcfi0J832peWhY00XqN4ILI7dt7Hs0D meKxUl0ZsdfiYG6dyEbb1I5ULHcsEiuDvvqUE7epCon9nX+6LPRCzbyIqydfGuEa/B9o AVLEZCrkNmKP0me/g6bAWYqImJdYxAtHORnT4sHhQfC8g/orSHpJHQZVuM0MVNUGAwIj k+PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962397; x=1735567197; 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=z2aKeZ7sTU4LK+Isj7RaoM/yVOdhmMcPqm/rlVkOhUE=; b=WUzh7BhzciiuhQO4fi7vCRr4F6DhcgFMWCA+YOnp/o6TIahKrx0GT1ubmd8D5oRikt HRW+NEV4SnV4aXu64kPE9IAGS9yz1rWOrZWeXusjRaH8pjbxVpaFHr0dHgdo+NMdU8Yz R9eQO9ntKYP9MGHf6SNHoZswTOM/asWl+kNIy5qkCwPNtHUQWPvsp5ccCB3tjoRLb5pi JILma+QC4b3KaGmckFtrWV7kpnFdlXkH1gH5DphVlR9tSAqilpbo6LHRbzmNlnB4zjO3 u/QAsggITzEzWBGg4zU5y9Tu0xMptetBXg9IQkUfwHyQzdjllvfY1nfn+LAmXTgFI/jc sCVg== X-Forwarded-Encrypted: i=1; AJvYcCUGMNs5d/YzCvuJnjsvVWNpdQ6s0+ZTBMkrdQjatnlI1ArASpFYewQbp9wJEQVC8sKOKq8BTE+q/9l/Ow==@vger.kernel.org, AJvYcCUOFesFii4U7lfCC1lMwct0otH7JbmwOt0F+i5QHSzCSSoy1QuCYgQt7/NoACoSiJQkGFYHmFi9/UUr@vger.kernel.org, AJvYcCWZZKqDCNEnPCbZRUzAt93pDN9Ev1V7gmik5iWz/k63cdmHAjD6JHqKVEBy7Qgq5G/tsqICceIEepgAchM=@vger.kernel.org, AJvYcCX9iBdWizQtZ74Tk+G/z69CimwgmqMGCFvfDeK/O21OOZYkSG5FqTLj2aLQ/QQRIPp1ohmwx35ZGBUhsdqQ@vger.kernel.org X-Gm-Message-State: AOJu0Ywd1129s3GAijhnEGq/sY6bUMpEZpVQb2oOoWYb2GgrIOMlpqWM e02YXLKA2CnViC7c57eJLAfAXm2v+SzXU9s8hRgL4TCIpRR4h2jiuDjYrw== X-Gm-Gg: ASbGncvG2oJm0mQIcRrVvMA2m0ptXp5oOP6KOvp/46SLrdSdkPojfMfZcKYM4XSHkAL qtsnFIfZMLiJRcj51Xl87EEetP4Dn6YnzI0tOkMhzLHK6i2NtqVaSV455SrHgvatowlLZXylbBv YjtfRB6tDXGLm58/19FzubSh0RJncuDjUuK8F1kZmePDXtg7ZjZbuw3QRk8l3HXgmQ5yJbAgJHL WsoPZiMtlSHgEAB8/48009oSaRiqLCvsfgS8A+IjV/Bd3oTugNxAaj8dqPeMTNFIb9wbcBfYvde OP68neDYFuSHo6gUek4tWUJTtQ== X-Google-Smtp-Source: AGHT+IHTfmT3ii1i2dJgNpjE2IqZYfi+fJgTM2xXw0SQlEkYnt2ovxRwwJDnN/nyJ9K9i3e6FVU9kQ== X-Received: by 2002:a05:6402:3589:b0:5d0:eb2d:db97 with SMTP id 4fb4d7f45d1cf-5d81ddf7fccmr10377640a12.25.1734962396804; Mon, 23 Dec 2024 05:59:56 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.05.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 05:59:55 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:39 +0300 Subject: [PATCH v13 02/10] dt-bindings: power: supply: max17042: add max77705 support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-2-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=795; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=uK2VytpAhIaw1vGXP3QtafCIlq4zr6S/aIWCWDyWjKo=; b=ugl74q59mV/wQrBKKqtejK6GTmpABtafWcPMnX1gkwiqYcdAjMVQzi3p6Lpbbvyl2YwWMS3zR RMb2jvgor7dChZGG794P3CVh0mqsdxSrExup5LxvzKQi4yBYqORd8pa 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 23 13:59:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853113 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3AD41B3934; Mon, 23 Dec 2024 14:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962403; cv=none; b=NPgutRha8lBhR7uGFIfP/SNn6lCl1FfRPrtqWtceQ7en1xBL2hPpHva7S/VcpxgRKcqSVBIJdrbnjzVvVdd8ynajbj4ToSMIK4eWo7J1I1okgTk0Gtr/GcPdGXc0lnLc7JuHIFr6VEYOb7JAhhErdT+f0tkJlpbi4jo7Z5FScyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962403; c=relaxed/simple; bh=W3R0sAEsh89KI9k2TtMER4sOCc8bejuu1Gu7C+v3ml0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ayuK6Wi7nkDj9jUumS3pR1xDyF4DfNLfZea0muyEB8dIg8pIB55WWnMxu82iaBHGUCiwNEIjdcOC6eR3dGYQLmHla49LQOCBppvaqw8DNJvARat+OfYK+uOT80YN5mJzPJAaiNmGnzp23315Z4XqTaculxJ0W1tRPN/JdUjjZfE= 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=C4RyGF54; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C4RyGF54" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5d647d5df90so6923657a12.2; Mon, 23 Dec 2024 06:00:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962400; x=1735567200; 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=LyNrH/v1nn6Cpsrp8y8ejskaGapYhbwc7aBDhXiWAeU=; b=C4RyGF54ue8KfzxBGyD75NFi1YXF5ZN7J5UyhSl2eyTQaq++bpdH+MUgiEYXjKxeW9 YLbs5XPhA7vkFDY1opOiximLXYzy8o/8PfLuTFDsyzGypEzRJhrPIA5Z8Qximefrjqxa AWahmO9vyRjf+60YqGnfFRWVF6lUqjnag7pYBf/mHm7BuGFsw9DMi/73DkH4TlBnWkUJ fJjCutPByYA5ELpFVzXomc3RHu4k1TvqgapZjhKUliSOcucpvw+Dhl5XBzmzqePuHaeC PAE0oYISF8NTRf0V0lShJ9wsR8hziVOsa8ynJDK+p0w6Ix2H4vqkZouJ2XiugWIVn8P8 cHzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962400; x=1735567200; 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=LyNrH/v1nn6Cpsrp8y8ejskaGapYhbwc7aBDhXiWAeU=; b=RmcOYurzDFRwzGQ9TVMFX+0NrPQRqOAMH+22ZVIPTx6aMW0AwUYs8ocbKGu1XbBRhw n1nyKe7JsAmx6N80aacfM4eu/sBfyMprxBitDxNL5ms+EOTl8FkHTFBAcAo4dIE7pxZv hyw7kLWDsaxdSXzJ0QpSJcYLkj3ZuStmIIVJCw7BNE0bHkuksfkZpNzWbCOH926xMVHb YVPstgcb1WAgobp4i7fEQExODd8wgwFG+xSFZugglP4F+0DDkvlaujc5KzYUeuoG7Jk3 iVF+1mBQANr+mQBpne2bg4XHldCg+pINXjGJitgp/YC/q73PzizsrqKi3VKDiJnLeeyD hAww== X-Forwarded-Encrypted: i=1; AJvYcCUD42q39DYzyfFEC207ttzmj1O+EeWveAptK5q52nm1hf4oj0ekwiBSVTjuKwK3dXIStrq1MSvFGQmsIg==@vger.kernel.org, AJvYcCV+DiNLIO0IXXT9XSn5Xf4jdHADEDhSaYTwDNXynrNGMCJg4vYcGT6f/Q2+lMTYcroS5MOCEeBpLLUpwh8=@vger.kernel.org, AJvYcCVB9gLZa1ELlbMKODZtLglmuNenzvMTwDbr1uzWLr7j5J6POkffZkbikBovKnm9DkB+Zf1cM2ID9o5M@vger.kernel.org, AJvYcCW4hO+rLC3bZ85dGU3T9XJCunBbFrx/8/Fz5zlz1WevmgmyGYPubKHNNldBROy3Y49NUBmukNfHaFwefMbo@vger.kernel.org X-Gm-Message-State: AOJu0Yy6BQStm6VJiFLe2g8+BSo11BoWzMZ58r4NHrU/RxMHd2zs5zqx hfy67tZI5aHl0cxjhsMjkRiq5aQawzv0+DUM5K6OO1NoxPLgpai78kZCWw== X-Gm-Gg: ASbGncuI31DVUnm5kZb2BeBHCuQZpY4emWAiGq9Bpd8Dq7Zrx/FdAWWmAbSi13TTKlJ vqjySs7zI3wcLd99pLAYN2Dk8dKHNwXVxHsmoN0ZytZy5UkQpO47DVmfsEuHffqLitEPmaYLVDV atW7OCyWMHdYyLM+QVIIE7QR9fLmLKtNn0U2IzcljGGDyZrOz5admCI1MuDd9Xvz+ngZiLKSjHe VbsBVwQy1OGlsu5eCn7u9yTWCOo18ECfpDQSEubjOZMDhIr7jICh2wtgeVkPwMtj7QryM1m83Ow g7rkHBjGxfBqZlkUVpzrGQk99Q== X-Google-Smtp-Source: AGHT+IF3EI3aiS8peDHQvCudeSD7IYB3OD6m/HHX6VoBtBuSM4Fb26SypNlJLZ8cqf1R2z5wkXVtaA== X-Received: by 2002:a05:6402:51cf:b0:5d0:d18f:cc64 with SMTP id 4fb4d7f45d1cf-5d81dd64086mr11269286a12.4.1734962399439; Mon, 23 Dec 2024 05:59:59 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.05.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 05:59:58 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:40 +0300 Subject: [PATCH v13 03/10] dt-bindings: power: supply: add maxim,max77705 charger Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-3-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=1700; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=W3R0sAEsh89KI9k2TtMER4sOCc8bejuu1Gu7C+v3ml0=; b=ZChh0VTDwOaZjm1PVOpEbL/9xASm6oG1B+pqr51srt6I2107IUk1rGinPBLHPGyO21F8obdWo y57PadPDp1jDZyNK+rYwECheWQz3RTddXYdoUbZRz6EsDS0Sr++MtgG X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 charger binding. Signed-off-by: Dzmitry Sankouski Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml new file mode 100644 index 000000000000..e42dbd48d838 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX777705 charger + +maintainers: + - Dzmitry Sankouski + +description: | + This is a device tree bindings for charger found in Maxim MAX77705 chip. + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + const: maxim,max77705-charger + + interrupts: + maxItems: 1 + + reg: + maxItems: 1 + +required: + - reg + - compatible + - monitored-battery + +unevaluatedProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@69 { + compatible = "maxim,max77705-charger"; + reg = <0x69>; + monitored-battery = <&battery>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + }; + }; From patchwork Mon Dec 23 13:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853770 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (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 BEC1D1B414B; Mon, 23 Dec 2024 14:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962405; cv=none; b=ddet3+WsXgF/j3pwqQu5QRlg0H2tGeZc+96gGS8jpbXqugkQIP+5/+eOEFml+78j+JrxklES4ExJyuxe5i3rxu4NavA2F6wsguViV2rYl1tYES2crJbsFmw79IFwhSWUHiQbKS/Lj6gu2EgXGAq5KPKmS3w/5zMT3SYm0CCFSKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962405; c=relaxed/simple; bh=++FqWduQtiYqIZJfFFYN58AQ4bYjWg2hDGDCZOV7O40=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JDSFmOF3hq3Sex+gWDh03RVI6d55G79WNohxa1wM9lRaM163lttKq3IJf4K/ELxFG4k15bp7SHeJBqQq9Ky2mMLEq9ug4XPmYwTJnZsjtJ1lORFnoLkOcRmXGjcL5wFRt6+bKaQ7ChI0+G+UROyL/G2rVSPVQ3mOXEQ1MREnzPk= 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=Hjo8MBGm; arc=none smtp.client-ip=209.85.208.54 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="Hjo8MBGm" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5d3ecae02beso5040120a12.0; Mon, 23 Dec 2024 06:00:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962402; x=1735567202; 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=8X9Jrp2ekeRKT58+p8rV9JAnlJ7wlIh9J/UZBXn68bo=; b=Hjo8MBGmxJVpn1ep+s9mp3F9ocVvSOMTCErUKAt/fo0EiA1aWuJDXbrSsZOxIIPzup LK9KLsVUdeXvLvUKcqoCk4EtUewPtXXLpznfbXHdADEEYFmjaRfvUHWqHMzmtr09IknN u4+9kwfF3q8xY0GNqmdvRsMBnOxZ5ocxDGMXlX1d9+EXbKl5BXpeZhP/ysXw1yJmCgC4 WxIwrric5yDKgtnUu+DaJsNQkgLItplR48f400FdsV54txjOitq7DFsiaw/KlezL5CY+ heEM2ZBliIQH4rPN+Fo5p61KWgqEvvsfa9jIoPdpn3CWPpEbONCXlZBYf4kw90hnhrHe XrPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962402; x=1735567202; 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=8X9Jrp2ekeRKT58+p8rV9JAnlJ7wlIh9J/UZBXn68bo=; b=Cktk+eoSbQfpuxNhztT7DJxOFDI5bRE0+zmm7fGHOVdTe+BkLq0iwPX5yp07b9A6nW zOWSJ5zo+aasAvzkTjZFTDMfhAKFThGMp73MmGc/aXLicUOoMFGrMuXQ0Hrcuz0n0XFy UY22XSvuXiy05JhgivSqjLXvGtSxS4d1RTiW6JMH34w6ekBst+zbqCPs+JplJ7pjrIGh vyvLwm2iCK3m1L2tnOmIjl7dUbPJFEyirWA7rIUgyXzDH9brn7+i4E0cUd2GSeW8upg3 AhjnckyUmF/64/9qcKnZY7eF4cTNUgFw+aT9tZZgmHQAZObY6J4QmevArPeng2CNhoTH FGPA== X-Forwarded-Encrypted: i=1; AJvYcCVAdIOCeYp1TeZdwiX+7bhdDG84X/aa3wzWyA+piZa83fxNgDg1KvPdWfYjY0dkUhnQZ6I4sGWwj0QlKCSE@vger.kernel.org, AJvYcCW7bKXeYhkIs3+LE4V9TrWgLWU89alXsyFTd6lIGZao6bOBFEn0/VYofg5lNLAVDBQIz3GJZoD6Zw9D@vger.kernel.org, AJvYcCXaoE47QDydC2oaHLJnDZG0LofQpaozgfVCcC8W/RzbMI5aNkf6Z49qcnWuO4Q0ol/zldOuM083JgnnIw==@vger.kernel.org, AJvYcCXhmbd9JI8IrzRQYwaigchZdWFNaOMk0JgKzbdP/1tSetWwraWEb9x/SM+v3OlVtVBRob+Dnnp9x0he8dE=@vger.kernel.org X-Gm-Message-State: AOJu0YwsIXwCukCwb5g2FZOxpHD0j41rKZr6ywW1QIiJzi5Ha0tzIN8L YBD1TBh3i1cOUSJNqNUjFDp+ctN7gzSfAig5F2xYHXN6IMrGFLfNWPW3EA== X-Gm-Gg: ASbGncuFqfblD92+I5Pzefv5zx1ynm6uwJzuUl71okcuBM7hU5cI7sR6SG6t+c5muSY EG9DzsTPygQtVsIB37+w59emi0kFF1N2jzLoF1VLQvcBSwODgbSOiwGoioDYZo1X4SFAstpe7b8 5pkGjInak7sWG/eKMlgnFYAEuXOEIFIhZBCoso8+5vEbaoxjtcsLocHKZ9Gpc5uwLBHktQhQ2Qx e+o2ggsxdvw/ZoJTxC0oLXc51x3Ob3SAUfm/aG5+tI6ZPycpsmV0Gj0+8IBb37F3EoXC+GXUf6q gZynhjm48IGmY4FUxymlJ8hKkA== X-Google-Smtp-Source: AGHT+IHwsERKIFwbiG5DYEEF/Sdt/c+mRr3/iVgL/SfK48DnQPRmJeselo9iLQWUUPtOjES8VGX+Tw== X-Received: by 2002:a05:6402:2109:b0:5cf:e66f:678d with SMTP id 4fb4d7f45d1cf-5d81de083bamr11948111a12.28.1734962401480; Mon, 23 Dec 2024 06:00:01 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.05.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 06:00:01 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:41 +0300 Subject: [PATCH v13 04/10] dt-bindings: mfd: add maxim,max77705 Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-4-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=6718; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=++FqWduQtiYqIZJfFFYN58AQ4bYjWg2hDGDCZOV7O40=; b=K4DDeS9alSFr9oOiNcPPnHScJ9o+ppz7tjZe3ZfskqViNqNrw6mvV0C4ltpnISlmbyELezenr YHDdvLMZGx8BZdHsdX3pqkbw3Y1JoQ9ewOha+vGql9zn6YP+JAG9SZJ X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 binding part, containing leds controller and haptics. Charger and fuel gauge are separate device, thus not included. Signed-off-by: Dzmitry Sankouski --- Changes in v12: - revert: description: mention this is a part - adjust commit message Changes in v12: - move fuelgauge bindings to separate patch because separate device - move charger bindings to separate patch because separate device - description: mention this is a part 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 | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 167 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..c1db861a2d38 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml @@ -0,0 +1,166 @@ +# 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 and USB Type-C interface + +maintainers: + - Dzmitry Sankouski + +description: | + This is a part of device tree bindings for Maxim MAX77705. + + Maxim MAX77705 is a Companion Power Management and Type-C + interface IC which includes charger, fuelgauge, LED, haptic motor driver and + Type-C management. + +properties: + compatible: + const: maxim,max77705 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + 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 = ; + }; + }; + }; + + haptic { + compatible = "maxim,max77705-haptic"; + haptic-supply = <&vib_regulator>; + pwms = <&vib_pwm 0 50000>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index d2ab799a0659..f0ad532b82f1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14260,6 +14260,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 23 13:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853112 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 A9EB71AB528; Mon, 23 Dec 2024 14:00:05 +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=1734962407; cv=none; b=YiISThugCO7WQDLH7CCqgR77Z77hn1NpREHQ0+8eMwt+pixiPH+ts6qs+UTSp0L2aiPlUd65g+drn3ua38srYqn585PA6TBfrF+nLf83WtWHrZboxoMTS3Hg8zIhUSl0oFIZhRYNrkZCfe9m7FM6VISKp0I5ICRnhEYTevblTMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962407; c=relaxed/simple; bh=iiRnf4Wt6mhhESchgHXjPJDU1ILplxAAXBKmr7mHB+o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tp0EX3Glyivuz6oM/ND51tDFy3qf0uXbSEMLV2PkIMqrS7rhS3oy9iee+FV5128Cs+NlWhf0GVnZTmQge/zE8D710Kv4ygjpIQnjrR7qC1NNqHo4gPGCKHhvg8tm2bZKXTjvHkr3k8I1Xy5s6WIuRqq2M/D5vUtQHvTJY+Gw8jg= 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=b6+9kZNb; 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="b6+9kZNb" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5d647d5df90so6923761a12.2; Mon, 23 Dec 2024 06:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962403; x=1735567203; 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=ny34XKwUX+MJKcT29KzUxMJWJuevNw9zT0IEL+SXaPw=; b=b6+9kZNbj00VRJHzFDKKexYsC58KoAUkfDye5yWmIUprC3BU4NF3Jy0E4GcZACOgbU JbGaVPK1nJxG6xOeUV3IWiqIR6G8jOnwOPAfq1BmcyAPubhtYwMTKDJfzjmtVSH+jd+R qug9++vwzBJgC/nzg9agMCnK+DfHquN7Pfrl60UAXwDxNbkbdtSZtOPlYNt6/zyahyxr BBg9D7S6eIBW6d2gblDudMs2ohrdfnZTgj23W5T5pdyCnwAXrRIsMzZF2YfhDj0Zreb/ udLjj5kKRRuMwe541urWdYiTVXgB2DQ9zW1xcN8mn5mtwmAnMMTcvoXJLr0aV604+xii mSzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962403; x=1735567203; 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=ny34XKwUX+MJKcT29KzUxMJWJuevNw9zT0IEL+SXaPw=; b=g3euoXxw7tPa/kz2YxPkX9m1WxJ0CmIdMd01r03O81N1aVdPuS5SkPpoNhAFo3pjiH guS3v7ZTvHvmrisRZRTsb0kWlFXeuN07Mo1/UmoxlSQMX7k6pkTSjCsOLwhg5YaRHEg3 QtbqsFHHKCXyYWUtVDfzTAYO6VdRFlOGBponjwafJEBYseDYoe0LGYGeetAAV4WEoxK1 NeeIzzSSpJCR7RESuiyZVeRSWv3kCL4hWqA3UTgcmEWgzpyNU4O0P2Pv/PmAHWmm52zf /v++EADlDA1GeldoA6e2ec2PzKSHCgZU29LV9x7BwDyS2WZEO00DolUfqh6804nQuP7a lpsQ== X-Forwarded-Encrypted: i=1; AJvYcCUA5Tv7kqNv9PktDGiLYD4rxNU2pdFkD/Pcxp9u8chjFUEe89mlVo7YJusXAEOGfeHJj1TPAiCbQOkvqA==@vger.kernel.org, AJvYcCVmN/emcZSw3fZNAEgmkD78He5c3FZ9CofXG33Bl3rd4j5zhLyQICwSMjK5P2HmkgtKi3Mi5hSeB7dylFU=@vger.kernel.org, AJvYcCWXR/mhBS0zaUt++qo6FjJ/YCpA5/qPFgmaytzs0sQJxxjhWIdXs1AcYGy6GrrZKFytjL84RuBDzWb4@vger.kernel.org, AJvYcCWyahWQDA1L0W2S1igin/LHvqWQJLB+UZghqe1ojnNs884pegGnY44YxoZIgzxMCYWPvO7mGK1vl7Kjb5mm@vger.kernel.org X-Gm-Message-State: AOJu0YwA7QFWYARtT9EoY8HOjRr6wjK9MS1Bccxm/W63DJSl11u94ZE1 DnyE9henSNY5MlUnk3QiQK3s0EfAGVkJb7Lx/Bamc2bEvGBj1pAYn85+SA== X-Gm-Gg: ASbGncsmPHJil0UBp6HC31Bgub7XD64GKBPLT455Oceb9RSS6U4eE1p2SafAr5PNlX1 cQHdMNJ6yxREe7tRji3wPUH+12YnnbFjeoWMcVkAK6DgZjUfPS/HqL2bLMa50/Hf1khdajTfg3R TEFf7dzxxTlILlELFDUyCNbVNhq0oFKsqjO3YNTrEq+KVl8rRRpSWuVK3E2u6zKJ921UkqmgO5v jGRHHYPurdVXwhyP4TU9LYDOGctDv14FulM5YtvFuIimWxp6Jn1isXjAtwc5Wrx18yEejO1XAvh nu7u57fnDDl0rA6PG93lexDzjQ== X-Google-Smtp-Source: AGHT+IGpn5wHrBJunR1KMzyucrBTjlRpbJha9jZ1iPfl8wogGhhi4lxWlgScM2CfhFfDWR4udtEPYA== X-Received: by 2002:a05:6402:2344:b0:5d0:e410:468b with SMTP id 4fb4d7f45d1cf-5d81dd64032mr9926960a12.2.1734962403472; Mon, 23 Dec 2024 06:00:03 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.06.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 06:00:03 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:42 +0300 Subject: [PATCH v13 05/10] power: supply: max17042: add max77705 fuel gauge support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-5-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=1366; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=iiRnf4Wt6mhhESchgHXjPJDU1ILplxAAXBKmr7mHB+o=; b=R4Hatde9fNd2nAj2joX9Unc4pmaSd8KkOnjVS/EwE3gEKrZHiv97Dteh0FTGnDrZ800oS0HZE nn3ers4mzZqD2KqkXRyIhtDFE1PzGevSveIQybwdycA9XUPFkLSZmzp X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add max77705 fuel gauge support. Signed-off-by: Dzmitry Sankouski --- Changes in v12: - add only to platform version IDs Changes in v11: - add device type to compatible 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 4037843e25bb..655b3f25dbd7 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -1234,6 +1234,8 @@ static const struct of_device_id max17042_dt_match[] __used = { .data = (void *) MAXIM_DEVICE_TYPE_MAX17050 }, { .compatible = "maxim,max17055", .data = (void *) MAXIM_DEVICE_TYPE_MAX17055 }, + { .compatible = "maxim,max77705-battery", + .data = (void *) MAXIM_DEVICE_TYPE_MAX17047 }, { .compatible = "maxim,max77849-battery", .data = (void *) MAXIM_DEVICE_TYPE_MAX17047 }, { }, @@ -1256,6 +1258,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 23 13:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853769 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3AAB1B4C35; Mon, 23 Dec 2024 14:00:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962410; cv=none; b=hw8vuo+LB7Z+46W65ozvcSKjPF8xxGn/LOCiJpJGBkqrawtu2XwLHVI1Ta0BpD1x+fKudBszsXxs33/esV/2xr+IekFecssxNgQwvOpolSssaUltrqL2fJQuuX56djIjv4sGGskhIH65kTLRtT/uocAlM+Qz/zA6+mu8/xT3oVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962410; c=relaxed/simple; bh=em1c6fB/SFJ5OvDhJapdczlQ9dG2X04MTOywpnS+/6g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d25ugaMac3zjFdlyT6G2hWBTuzxsYQ8cnzI/Vj8u66BZElQIdlxOJT41y4/FHGTSru5lxXUgJmTKAk7yf02x5AdltdD5mthk4MT3g0aS0C1Xlz/Xnw2zYIQaz7CG+d7KBb7UgpL2NBVNVt/SysxTrKelLaKvQKcc3VJFtl+tvi4= 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=LfJ4nP9J; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LfJ4nP9J" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aa689a37dd4so488037466b.3; Mon, 23 Dec 2024 06:00:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962406; x=1735567206; 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=C6R02xkTOu2ZFN8lj6E3rQYmgVukaGWewoigfIcZyGQ=; b=LfJ4nP9JqYOYZ1zuMA0bJGDrfHvdmNAhs06GsdJ3CC5oQ5SO5AdurDDNsVpCcxgdw7 BjLHYwn/CE/Lj1yOsimys1xxKByXb/zj0+eSku8zP21gKD3eX9jWglusIUo+NeNsSZin q8WmXzQ7ev3N5rH6s29IhZWB9Ars+OVIHmD3j39HUCJZWLU+2rxhfC6kh8PqyY4+qbbM jDkWYKp0cDkT09crhA+m8UyHbwsVyyOHZJDw5lQSsX/D+0cOyphc/pxJd41MNT52KGtp r9GtWgzNijgBXuRRDRCL0StA7oPdJd/bt/FmEkGp5UKzgRVIK4ACrhFVnM8Lc8JOpWaO i23A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962406; x=1735567206; 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=C6R02xkTOu2ZFN8lj6E3rQYmgVukaGWewoigfIcZyGQ=; b=F7Oh7yRmd4ncxgHoLjljcP1WeftJRpXl+Jjuu96uwzzd7hHi3zABmEXhVb1/6/lf+8 hppDHAxLV1zlQ+d2tiwa2GChrBGZ/3MLaI3zyQzgawPm69S1noVISHyPUd1zEtCxcCBz 54ctnYyhwYJU00ClZxE1/ChTJ47kmOIYguNJIudBknr0dgPBs571XtGMdSKQUk1Ebw8G aTM9JpiVNmBoDI8po2WdMizCOlzKR4mKG4T2tWYYZWojEmh9I0vvZz2ugbgnhVYHdH+9 G1iLo81Av+jnJYgVahSgemj/QkG99daD6DMqRu+mf7U0udEJXbqlrS6mslwC13W1a/vB vDAA== X-Forwarded-Encrypted: i=1; AJvYcCU1A2Fge+5BHijot4QoooYhlouiPSleKUD3Im8rBTn0Ovo0t2w7f3VmS+CBOYBcVFvV5tLp7uWjXZce8ss=@vger.kernel.org, AJvYcCUrI5W0wyGYCmyrQP0w8UEJIllCsgjBfr7/jFt/QL7A/MWFxZpbx2s9bzo7Q1dOyOMfLsULYNC8GY4b@vger.kernel.org, AJvYcCWKLLTZxc+7ZwomjFFVD9XSjctJElMPAk4Xyv0XkIlBzBUeKn3WZ6JPx0nBkfuk3jlmiIb0w6yQ+dViatTZ@vger.kernel.org, AJvYcCXPJUndfC7VQjvwb35WwzSy8IUGQmjV/f8iTWHvvsV4bTVZ4pSP0dcSQZvQci/abD4iXHwf/FGWh/8ofA==@vger.kernel.org X-Gm-Message-State: AOJu0YyWYHMkRhLZyL737zri8Bb7Giug8HtLTqWGlXMUsTOlOPz9ZrFF Y/yj7Qe4E7hNweiO/LMoDfpYGfKlTI7v6sO3dWe5awaLHSH2idwGn1J/7w== X-Gm-Gg: ASbGnculkvQ5THxkJrRx38wXgVIhR8XDiMlm6IWQF+Ziicy8fQ9QY1SLRZsrS9YC4w/ 5k/jXPVUO4bp26kZ+1xrsMRKzhwHofn81519fT3gRm5xEnMaMKzmbky/jIXRyl9eSZpHOmzpGJD uV0we0TkJG4O31c9vvRc7YDH/Zi5Ina7+eAFM7IrSsotAOdXdKYCYBZP/yYBo4UVztoYBz9vmT5 dY+a+vbRm+k/zIiCLYk/IQf4Wj6phYSxVOTaeA/A7d6zqIg3Y/5ECuYW2MPdI04R+H7dk4DKpPL D+BvwYkWvJbyQd4FsPgJ24s9dA== X-Google-Smtp-Source: AGHT+IGWYEuJOx/zksFx3wrzmgIRq7p9Jy5AReEB5ZaNY7AqQE5cZSyk5VGFdIFEORi0cnsa5+wSMg== X-Received: by 2002:a17:907:6d26:b0:aa6:256a:40a7 with SMTP id a640c23a62f3a-aac2ad81a59mr1027452866b.22.1734962405515; Mon, 23 Dec 2024 06:00:05 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.06.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 06:00:04 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:43 +0300 Subject: [PATCH v13 06/10] power: supply: max77705: Add charger driver for Maxim 77705 Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-6-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=27669; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=em1c6fB/SFJ5OvDhJapdczlQ9dG2X04MTOywpnS+/6g=; b=bbkrN7LS0Le1o5mSjJsDXZlAuqQoCcwryF9hfHhjPP86RdhjVlu0SbtwYTfodzHeBZ3g4+UOv UyiaopvX205DWMN+xqShso7SFyoUxy9/lz2tQEnTJ2JMWauxIj9xlqz X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add driver for Maxim 77705 switch-mode charger. It 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 v12: - add missing new line - reorder max77705_charger_enable and max77705_charger_disable action - convert driver from platform to i2c, adjust commit msg accordingly 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 | 576 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_charger.h | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 777 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..563b41420c7c --- /dev/null +++ b/drivers/power/supply/max77705_charger.c @@ -0,0 +1,576 @@ +// 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 + +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 i2c_client *i2c) +{ + struct power_supply_config pscfg = {}; + struct max77705_charger_data *chg; + struct device *dev; + struct regmap_irq_chip_data *irq_data; + int ret; + + dev = &i2c->dev; + + chg = devm_kzalloc(dev, sizeof(*chg), GFP_KERNEL); + if (!chg) + return -ENOMEM; + + chg->dev = dev; + i2c_set_clientdata(i2c, chg); + + chg->regmap = devm_regmap_init_i2c(i2c, &max77705_chg_regmap_config); + if (IS_ERR(chg->regmap)) + return PTR_ERR(chg->regmap); + + 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, i2c->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 = max77705_charger_enable(chg); + if (ret) + return dev_err_probe(dev, ret, "failed to enable charge\n"); + else + return devm_add_action_or_reset(dev, max77705_charger_disable, 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 i2c_driver max77705_charger_driver = { + .driver = { + .name = "max77705-charger", + .of_match_table = max77705_charger_of_match, + }, + .probe = max77705_charger_probe, +}; +module_i2c_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 23 13:59:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853111 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 4E8651BD000; Mon, 23 Dec 2024 14:00:10 +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=1734962412; cv=none; b=G54DejTeiQfiDUcxoU93sEcOf9NCbF/YDSBUbgHhEZ+MQ5vC5lL5guGqY9bwjqRHucyKW5avLpgu3Kbt6WtxXu4V93zL97uwxkIaMZhJpfZPEGezIo4rU60+vFOCqUi13tCnoIomQmpar8ktu7oWFI/mxQwgn/nLCW1+h1pyRTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962412; c=relaxed/simple; bh=I7mtjfCVJ1O2Vg6443qyW0B5WFDFjRpanCU/ThHHH0E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X+1QZICxcPmH/yIC0SR/9RrdIbcVCMWz+7/GS13lPIeBqBgC3dhRM9fk4BHd1slKMYGGbzsD/6ldBF9lBc+NiTa6h9rvSt3j033am5yzpBT6hInBEC/2hAa7n/nFrsYDGedpn2McixQhCorMvK2vNAGvcqWePGNicEvWck2l5Vw= 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=CRBLigh3; 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="CRBLigh3" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5d3d14336f0so887388a12.3; Mon, 23 Dec 2024 06:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962408; x=1735567208; 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=QAsrsTp1vVx4HKavdMezqlK1BcLoKSQ4OHEn1+GzS2A=; b=CRBLigh3Yg7vdvpXNvr7+E0tG3EmZ3Uc6V4uhsyUPsQpDDzT0OEnEh604rQYygMCz4 GUr1o9G6AIDJZUE9kCBr+mUtCUOCHK3qDuYwuj4pM4CYRGlQ3rKpW/dpXSopEnrUNTTC ADdpBj0iTE+Vsqb8Q41y3xhvkLoouXj5y7+4A0DTJG+1KRkZZjdoCvbibf7Lynctn+tV fUWQ928j9npAG2G0oViMfRg9yqqVbhkl1cW+s+n62nH5RTGEzbl4f5IrOoLP1dajVQiK Lp0YYJOCw054HGRWQ8fJ+fEZOgg233ObqIcEIc3lD0XxHeeoQ3twsHzo+mWvSiGmKS1W nIRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962408; x=1735567208; 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=QAsrsTp1vVx4HKavdMezqlK1BcLoKSQ4OHEn1+GzS2A=; b=gWcLwos07uq4xnugpzI/xsqx247SfwSHIFfF1pDpSfrKCPlU6t7G35kAo1RqBxNl+J aCJnlVmwfoRQChPiPJrlGzLF8yDx5odFM1/bDcowfQT41AEllGxHSAc8rZJo2zlJmwS3 6aAqSiAKt3apcFoYL+VCnXaZaxZP0ToQqrqTDynFfRFiUpmR7RU7TluAO1NPqvNiZOEc 8yvsVquCFD/K80WySF3anRZqLG0pI3D424ihwkK6ZVe4xZbS/zqfdmmlr+onTN6AMz9G DxobYqWyEVb4jP6KUGk+py5egVY+Ap/tVVZmFMubiqpuB3D0lzVwa/gagCOQHi7G+HwR TCfg== X-Forwarded-Encrypted: i=1; AJvYcCV57rqFjaxr5Sb5oO6zEg8eiXZ97OwZqDiAnc9p5gSBanYo+3d4DCo5bZv0imD8tbimVUrmb+RoGiSRxw==@vger.kernel.org, AJvYcCVK6Bqvtc3Vx3y2Hu1aP85hDi10Vn3OSL8nYAaYjpdV/HKnNwWo9brC94Q0gvHC/IJQmH3Lvks3J5iX@vger.kernel.org, AJvYcCVzlvI2YgyanvF73dq5UFLiwWDe7hx7Q0qgyFIjGu/rucX9/S0zXtdvLvpzm8fhop4HUwNyQNHvzUtc22Q6@vger.kernel.org, AJvYcCXCsTvjUCjAu/TXbENMkcnDzn9Ybexa2u4WdoHB68bwKcsNMBJa5OgzCfRlYpVAtV2+6qBCa3LXdajwcBU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9lsA2pgxSrlJX34uUcA5U66yqfXMqH5hAF+Nf7ELMJHZ0N5Fd af7MjFvB7sEh+kkhCAge9X4sZnM+6r9mhxdQVvi6tK4UzPVG9aNR1Jg4mg== X-Gm-Gg: ASbGnctRn7y7h+ZLQBBEqaUb7KvAiOpEz78S4iSNI4AFDuZVTknhpGbCySFxRAb/QEz 0vsEJNAckgpJb3EICk5igf1x7R9/sDeuvNhG/BCRPsUjXf7FRsTlSICg+ffsBx1xreyORVPM9H7 8iiMbFfEIZsvF+kXrrJcEnIssWUgdioUKnG6JJ/TwyE7EpgI3ZYNFOvTVIFABTkDBrzPswbJYxJ QDXRPnNUN3QdQ9rcPQhJIYSWu7yM/WOG0r+F6EAzuRXItf+Nt6PqKn6Lfpc5UP8iiWaloTqg6tk b7WF+57Szc7rR3Tvh7qWt24r+g== X-Google-Smtp-Source: AGHT+IGkX2twjYykPfvrcevPR5SmL9ufGNABslDrIHQ3V0lMHPJD3pH/auJVtXptIdL4bIYPQe+pOg== X-Received: by 2002:a05:6402:270d:b0:5d1:2652:42ba with SMTP id 4fb4d7f45d1cf-5d81dd9a22amr11538622a12.16.1734962408175; Mon, 23 Dec 2024 06:00:08 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.06.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 06:00:07 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:44 +0300 Subject: [PATCH v13 07/10] mfd: simple-mfd-i2c: Add MAX77705 support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-7-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=1436; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=I7mtjfCVJ1O2Vg6443qyW0B5WFDFjRpanCU/ThHHH0E=; b=F62UIeWI7IWnW8geVb+Negvf0pgv3ZePjOicrYlLicIi/pJdoe2BXXt77hd90QPoRrzRo+O3M ogs5lq+ur8WCZ+kNUTS3KU4kY+je6r6gv93jatMMFVCy2AWSLNZ7EPM X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add MAX77705 support - fuel gauge and hwmon devices. Hwmon provides charger input and system bus measurements. Signed-off-by: Dzmitry Sankouski --- Changes in v13: - remove compatible from cells - change mfd compatible to match max77705 fuel gauge node --- drivers/mfd/simple-mfd-i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c index 6eda79533208..22159913bea0 100644 --- a/drivers/mfd/simple-mfd-i2c.c +++ b/drivers/mfd/simple-mfd-i2c.c @@ -83,11 +83,22 @@ static const struct simple_mfd_data maxim_max5970 = { .mfd_cell_size = ARRAY_SIZE(max5970_cells), }; +static const struct mfd_cell max77705_sensor_cells[] = { + { .name = "max77705-battery" }, + { .name = "max77705-hwmon", }, +}; + +static const struct simple_mfd_data maxim_mon_max77705 = { + .mfd_cell = max77705_sensor_cells, + .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), +}; + static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible = "kontron,sl28cpld" }, { .compatible = "silergy,sy7636a", .data = &silergy_sy7636a}, { .compatible = "maxim,max5970", .data = &maxim_max5970}, { .compatible = "maxim,max5978", .data = &maxim_max5970}, + { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, {} }; MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match); From patchwork Mon Dec 23 13:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853768 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CC251C1AD4; Mon, 23 Dec 2024 14:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962416; cv=none; b=MTOWOBPfiNoMC3Q/4HD8wJC0CxPbF2ByzxbxwpcwdKC+ExNnZJRxlfEtsWj6OgM6HrbrRpZ0kZtkXDZ1Hoj0pj4ezW1omt2qJcfpjh5hRlYNOeceEeR63qZN8KLxZJgEWNaC1XQGiEpWQfAiA0i7IqS2GnLNV6nizMS1LL428xc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962416; c=relaxed/simple; bh=12j2D9nA5tFpv9K4yx+7uZb+U3q8vX31f9qFrr8MjXI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JxlWJaB8h3rD1PEHyI2RHpW7jDnvPo92pJstIpAvG//rCT2fGKnjp6zhIZBY3XS+Ceudm8U0c7llKl3dsCUwnViHJACqDnSQaMEufujGR3I2JuOLleznKdGGmisY0v+z/LlbH6Ha9nyFoHpm2mGpsZ0USbm+K9PyJxKaz/rNYTs= 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=JM5TyM6O; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JM5TyM6O" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aaecded863eso190783466b.3; Mon, 23 Dec 2024 06:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962411; x=1735567211; 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=IG+AYphUFjufLT7rb6hZ9f5mNQl1kDjUAqFseNiO18o=; b=JM5TyM6O18GpS1KRaReyp+2Rev6CTNyUzA3iERmllOQqNgJZgcBC9zBB4FxKrUyJfe yn4fJVYCFTeHf34fo7fOp4lvSa6q25gBMYz1WX8nSmYpnMU61VA6wPDbG34xo0b8EdMk 7ZSpEO6lrFyNM5MSoGXU8BTQzTE5PSuEdVUXPFrFi2igvO9UMeo3o2lw9OhfTvPub/HY uyUVX825CbIlUa3uhW0NyPK6RaZmQ42nswU40OcNSR8aszyZj7xbuD5Y43wFn+iz45MO DZmUCv5qraFTTVTBV+AP/lyBnsnXJ1AhVhXNFtqo8SeNXClGjD4sVG0SqHcYTtMaA07U zkbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962411; x=1735567211; 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=IG+AYphUFjufLT7rb6hZ9f5mNQl1kDjUAqFseNiO18o=; b=Ts8tj3jCzkYyDEFBTLotuHVJd11b/GvTf7UMO80j1ZHdIWu8c8uxzarWEcMQSQwQ1k U1BOXhDzZ96MVlaG1Trncx/1Y/W/flKu6K6dLtSCdfWZIiGASZEdfm9OR0QijoufE2VC /5I5y5AaceW7TsBE0ltRJXVwT5QqKw2ye2c+YCbUNfle9WMCRIUZvBX3FdKJJGiXIqOL yk+v6g4seMx6E5a/APhr8LrL2CxVfD96qgdl4LZspMXG/ZQGI9vzpyuEBrPI+VZ7LjOB XL9BP2/rUvLQyHTUmuI5zojGNx42uheERz7KuupI184AFWFV8WXj0ZVthnRWpKRbgTox 44jQ== X-Forwarded-Encrypted: i=1; AJvYcCU0NZf+5ZnM4fMhBmk5lhQGKCZH89BLRylqsby3gmfDByGhhb/3tg6935ps2pmLmnHJnpW5JI63+xE8KVc=@vger.kernel.org, AJvYcCUIxTCx9lMcg9cE8QoP/+qSutQLIas7aBh9/H2X3nUsR6IluIwh75UGWqvANRc6fRghs6eKFyifdy3ZuwDT@vger.kernel.org, AJvYcCUiPJ5p3joeBvYnT709Ct7la7sC6X8gt9uPUNWPdQ4TeLtzGRST/S6p4Zat7lu5PFoDtAwX1eKWBAXm@vger.kernel.org, AJvYcCVzs+glfyysBnrCSo9jDKrHGOoYYCHHqZnhE2Su24NRGq0ZziqM+/KJqpZ7fHiY8Wfg57+JmsY6nrN0qg==@vger.kernel.org X-Gm-Message-State: AOJu0YwDLTUHKSFGFawO+Log7AnG/V844g/pgo8k4TJ676hnxML0d+k0 MSq1cZX5R0utscplAhyDzKtoWOnaO7ewT4HKhpFkX1skSQq/lMm1xu+qoQ== X-Gm-Gg: ASbGncvsOJDukL8YR0WbrSLxfqPyNj/S5DkLfjcF7NAPl+Smhs5A/WaMStQvkeX+rjy MSRGNXMXkydR53POwWTuhMFPuBL6GxTHLG5jpbd3AgHwdEc7bddUYFgGomsLuTm8iRDuAAOYSU3 rmqB8X3i79JMfhFS8CLMl5iz47IDcVlBwnDRk1zSGkIfbn4HIPVxTHetRbRyg2MeTPm5vihnVjM 0oEvbYe1xWO/jDJxm90ymYoXNS8ygfIHghd9XV3BD3ZZRvovnnvhGmiAJUEfYxvxF1n3Jidae1s tKFAxCzgmP+5V1cfSxGKPAcTgA== X-Google-Smtp-Source: AGHT+IHFxc+gMBankghYjPmz+BmMr04SsUNTx3HBUVmkjnwavHZZPGfUZU/ga5EA20LunT/xfgyfPw== X-Received: by 2002:a17:907:6e89:b0:aa6:538e:a311 with SMTP id a640c23a62f3a-aac2b28eee7mr1357652566b.18.1734962410973; Mon, 23 Dec 2024 06:00:10 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.06.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 06:00:09 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:45 +0300 Subject: [PATCH v13 08/10] mfd: Add new driver for MAX77705 PMIC Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-8-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=18961; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=12j2D9nA5tFpv9K4yx+7uZb+U3q8vX31f9qFrr8MjXI=; b=7g99cYp3YhdMFwcFXXKISznEA2KSipk5o8pa79BQXj4RC2aFz+Cy2pMHD6hYMZQ8dEzpZSUl9 +6MCUHueH9EC2ey1aMVZ086IcUhRQjwzj9qxacdJVFbl8FCZR3ohDb/ X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add the core MFD driver for max77705 PMIC. Drivers for sub-devices will be added in subsequent patches. Signed-off-by: Dzmitry Sankouski --- Changes for v12: - remove fuelgauge support (it's moved to simple-mfd-i2c, to reflect the fact it's a separate device with it's own i2c client) - remove unneeded ending comma - remove struct dev_pm_ops because defined by DEFINE_SIMPLE_DEV_PM_OPS - Kconfig: select MFD_SIMPLE_MFD_I2C 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 | 13 +++++++++++++ drivers/mfd/Makefile | 2 ++ drivers/mfd/max77705.c | 209 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-common.h | 4 +++- include/linux/mfd/max77705-private.h | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 407 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index f0ad532b82f1..2f146b9b7a2a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14267,6 +14267,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 @@ -14274,6 +14275,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 6b0682af6e32..5064b1b42f76 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -916,6 +916,19 @@ 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 + select MFD_SIMPLE_MFD_I2C + 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 9220eaf7cf12..c18bb5a57734 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..18d344620755 --- /dev/null +++ b/drivers/mfd/max77705.c @@ -0,0 +1,209 @@ +// 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 + +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", + }, +}; + +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 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); + + 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..e4309d3b6f2a --- /dev/null +++ b/include/linux/mfd/max77705-private.h @@ -0,0 +1,178 @@ +/* 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 23 13:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853110 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.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 2B1381C1F29; Mon, 23 Dec 2024 14:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962417; cv=none; b=mzYGy6g3qwJBBGY33HdPs0KeddU7qrp9twgEDFUEJdnKGXkwyOYuk//6Z9eo9y1D9DSak5z4YUSPBNK4RqCS/OQdA8EcIEAIAITsYqugoFlRHtmnx44AWwXgrPpOX5nkPDoCucNeKr+vKu2f0qcq/LZGPl52hZfUi/G8rGIeDwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962417; c=relaxed/simple; bh=8tiL9gYxosgDGJy5CegOZ2k8C1ERDVZ0anDBBusV6lo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BCSZcVmUNzK6k1SbsA4SaL0+VwvU8DIH0cCMgikWcnaTtgDS04CkBfkoNb3Y4+rgKFzrpLd4vY8DWcLj/cuKH80UeETij5Y3Qt+P9SaoSaJa7EHoeX96c5hm4LKm44Vg5CQUeEbNBXMTJ25+b64TnUR2wd6mL5BFACuIweZtbt4= 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=kor+upiB; arc=none smtp.client-ip=209.85.208.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="kor+upiB" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5d3ecae02beso5040408a12.0; Mon, 23 Dec 2024 06:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962413; x=1735567213; 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=AFNHeHsI4W8KDDXKoBZPMpG1EACtJr6dX29X+XrkhzM=; b=kor+upiBFjDTTH8aYLvxxHFjBCGiZBnQGLsoegs+wWIi8UG8o1oCow8IjrQnE8NPI+ FWzOnTBWS8BaK8Ilo60mjU1VCr+yskSjESxnGLu43VrmlmrFqFYBKhkuL0k45nW3lWhg +oWML3aPsoNfOQwrTjElKfZTXPtGhZeNPzPRiktoqkxcv6am5bbOMWn69LCFKm6yp3f/ VDwbXvgYDETKCOrH5aI2xtZU90Oo3zEziRpkQnlx5Dc75QX4iy5G+9mjZfIclHChIJTN C07ajB4tNGVWf8FSglCyIGj2gqqm+ofzV1T+T1sK0EviKowOrUehZB6qicFdbahjU8av +nFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962413; x=1735567213; 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=AFNHeHsI4W8KDDXKoBZPMpG1EACtJr6dX29X+XrkhzM=; b=ApiYoCUE3MIUWrKI+doVUHmJzbWQOKEScAQ0x+DJXwbZzasVRPFgXdyvhuKvA6KX0g SQXfL89bk564EIpdPjVqSykM43wSjqHVr17iO/RCTynNvSo+nJ2WjYPs8vwoshpJhGS/ 1TGvcSkdi/jAgogsUl/NN7WgM4+9QXVfAH7Oc7ZJ05t0oIfgXTBWU6SttZtpi4kZhWOQ aFalaROguWThGMSl6DeuFG6t9GaoukPoRpT37Wklk9gpk91CdAxRicJpWEzqwr8hmrFK HzMmxw0rzi3lNsoUqETTpZvReZ6EpFWjIZmZvUKe1/elTMnfSEbLH7iidow7ch/zNkWb l91Q== X-Forwarded-Encrypted: i=1; AJvYcCV4KenF1O1yvVkNrgvONhuHxw8tN3O+ktYx3JIJs40i2M+qJLrcEcSfx0syX6difJdHwjGZgUGxAKKd@vger.kernel.org, AJvYcCV67yOiv3c5C9Z9FAsD8pTjhJGx3VhxyhfSMq3YdZRFaerRBAA2IwJHSx9X3LHDo/u/H4kFbxN7eXuZFt8=@vger.kernel.org, AJvYcCWO+Rvu2wUFdoxnre0vfXTf7D6Cb286dG0kOmswH+cIbX7OLyn8X5NMU0tieC2oZzViqfAa4R+O9ctD3g==@vger.kernel.org, AJvYcCXxmCevms1ADEbCOrRtiuja1Squ0s3TCawwFFfBGJ9v+Iik7c1CwV57f2MaWTtyk9HIbb1ZXRB/DqV5ROLg@vger.kernel.org X-Gm-Message-State: AOJu0Yz7UmyXfu+u0aSPBoulEpS3MiIHvzgWQefmMrZH54LyMVfciFgV WzQK/cx/sQDf52RuzZWCr3WanBZUoI91SnCtxKhEwO6QE36UImIVvGWFsA== X-Gm-Gg: ASbGncsH/1QCvHewCw9O6pm5lTDJo/7i3R9RMk4nFoezf0OVEpWggK6gKeAaUdjUtX1 leNtPE73eHc3KEEGpqX39yeKiSJ02CF602GcgJsTVrKtV7SM3CG4vI0TJHEOp1IH7MGmFKvkNXm +5eOtQcvdqxQc6lMHd3y9oYI+IdTryY0AD4/O4i5Ua22IDNppKvAzJ2Rgt/4tdeGP5uLI+mK8Lv NPVYDsmeuZ1vL3lKG5VHUhFCivby22gw8LdFlF7C2eJce5EIdYDoLKNkMtp5uuVd6S6NW5l/2fj 6VUAU8x0zXZZRhERjRPFS1915w== X-Google-Smtp-Source: AGHT+IEg61zEwDjPgzo8LK6a+eOlKVS1A0Ga4gpCDsVLKFS0Yws4ZyaLb+sCVfhID9KHdNSEFh55Bw== X-Received: by 2002:a17:907:d88:b0:aa6:86d1:c3fe with SMTP id a640c23a62f3a-aac27130bf5mr1169690866b.4.1734962412990; Mon, 23 Dec 2024 06:00:12 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.06.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 06:00:12 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:46 +0300 Subject: [PATCH v13 09/10] input: max77693: add max77705 haptic support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-9-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=4280; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=8tiL9gYxosgDGJy5CegOZ2k8C1ERDVZ0anDBBusV6lo=; b=K1UTD9G46syR4BLMtnY0dNcQUXDZpJcH7IuhPHxBxW+GlLEQZNFzliT+4P9cpkqQD/C2kNQAn buYXvdODMoxAjzcY2vTpwZixum2ffZMd/YDGfOa3ZM+PGNLtN+cfjug 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 13d135257e06..b9db5abcde08 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 6d91804d0a6f..e70164dd73c2 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 23 13:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 853767 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 43FC21AF0B5; Mon, 23 Dec 2024 14:00:16 +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=1734962420; cv=none; b=UzI+UT3g7JCZV02dnB0KXgHD5A7rBuWDJFDoHnTL52wr0Go/y/ENemiYu9u05l3FQs0PybAM4RuXEi90IaX7BZNvmT3iZMRfHn5whbo3ECDsuWPQV76xuN55Wks2IEfpPXpASSTZCdAZwiQL+oeoAoJxJ1fjBqDxgudUNvOxM4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734962420; c=relaxed/simple; bh=yK/XJU/3gqAAuGDw7ekM2t0lwZA3hV88jttdaU/xuwk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GlrflGKeSDAMRadiVj7n1coPFGMMG/spkIhpt/jcIlDbWJSnqHnJYnbnL+6wB1VnaUSDMIeU/xf6XDtXdTtClA38MmBgGeQpXVEf/v2vh8QhKjDDjPmUXTHUYdhuOqHDNhG3rwgJzzcLPAaY6vbKxejpJIICR5fUtuLeA6p3cu8= 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=QQ6urGrB; 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="QQ6urGrB" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5d7e527becaso6631831a12.3; Mon, 23 Dec 2024 06:00:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734962415; x=1735567215; 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=QnYCy9YiB+AH6Lr65YsEuPWUVNyF14hs9zU1gnQiAGo=; b=QQ6urGrBSRmQa8drUWczdM16k32Uy1i7VglmkNcsE4jKG/Cefu4RvF9yWborG6Py0a DLVuHmsKUIn4vb/CTY0xTrg+FEE48Gg2ybRNV0GMF3Blj6g4BhsGOy+VZlxcTsFxxtGr P7NAYWy0PNeZom/zWm6aLZxr6bPEoNTkfgYArv2M+ymYP+3hcEWFVky/qL+xlqgSMy+8 6zJMxsUD9LYJLHV3bI1V92pv5cC0RyKO7S2gMZg82b6y56yEf9fCsD27TAg3MhNgxPrh mQpQirZW7C3YM/YnIbdOtbMVPFBmn6lDi532P4dJOrmF4gCcQYZesmB/ENMukbKZ3czs XHXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734962415; x=1735567215; 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=QnYCy9YiB+AH6Lr65YsEuPWUVNyF14hs9zU1gnQiAGo=; b=EkMCfi1F6ks3vFtkOMxkWmnPfqTjNtAkoxQ3IpIKea8Pt0bJM8AW76CRPgcgQL2BN0 bYqZ1gGI0a5IAzfCWf4Jx9SRnQydkoMNlfC4EBksmUaM7xsJJrRuzNeji2nORnBcwsQv +fejY/0LoaCihjhOIMhV2OAezCfxmysLHhLVMqBU3943brFauBXnCkxjmD70yU/d1FYW rGAizQ3UexkL2fN0xZdh3ehuBaZK40TCUPcGtuK4jKGSCBASoDxtnJXn2SN5696pa2+g k5KtBeQ+OQz0jWGzpF2tY8y/4htzz8sykh8EPJWDeO9HQZTk6kPBVAVerKW96Sq/IlUG MoSQ== X-Forwarded-Encrypted: i=1; AJvYcCUI2qC1HYcSwe7/nWT5U/0p3grhJwWHUO0Z9kvQNrXmRBQJwaZJUnZ/tIwoNGFpxGl4dShwXo7Tvwc/9Af/@vger.kernel.org, AJvYcCUxjczseRkN53Z/08AaSTdMBnkhJyC3dp/wAyvYmkByRkjDHIfpXdFp8N2cRpwKdDWTNMQ31N+qBhpRbC4=@vger.kernel.org, AJvYcCV9OG+t1F9A3UQlSf1vMCN1AL163uu6c94/Iu/QYMhl3Vv5oPz6fF55AU+3yAjRJdd1agjf6kS2keF5BQ==@vger.kernel.org, AJvYcCWRN5A4oeT0X535AsrRghPILPAEsQA0QBSq9v/qL0lI7lee0Ky2KrkVuQDYHqXgWvM+FwBm5iH+Z6Lb@vger.kernel.org X-Gm-Message-State: AOJu0YzjoB2rqYq0fHw+S67htspzX8dow08NdrrSO6AOaWJpUy8ahFf0 TlN9/jqRZMXclenbFo4ZWp2Bj04L5rofAAROzznZKWsBA2Aul10ucZXBdA== X-Gm-Gg: ASbGnct/u3Fy+0/Pxlk6MrvjQIy7Dpe2TbpQlRU4MpsHcQ1ZPaJ9GAB62z8cNP753eK oCQoAvEXrJRB3acXcjqEBMI1qdv7ifYTSLnQa/XuFPkzRFh7u1Rrp6G+7TH01ev/D9Mv2MSsNhm 6DVfaGPqxVhzeiM/ORRcIcIUjQv7lHBe42ByjGgE8whFev6JvxQqR6JaMME4mt4d0PD/QU93B7O H5QyK5P9FOwv83N4K9vC7+1NX89dazo3e03TfmB+qOTT1U5mP+q0AY4p1KgfetV+aTqs79oAvXy Q6xRIoVr6kpQ3jwL3Rc0WhrtPA== X-Google-Smtp-Source: AGHT+IHeMA3Q8KKJpAgs6WgBCC8SiclTywAYDcbRbnVRQohN4/lGXDKbsvkWViIS44ZtC+OQZmaz9w== X-Received: by 2002:a05:6402:5291:b0:5d2:7396:b0ed with SMTP id 4fb4d7f45d1cf-5d81ddb3ae6mr29942601a12.14.1734962415018; Mon, 23 Dec 2024 06:00:15 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701ca31sm4911485a12.88.2024.12.23.06.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 06:00:13 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 23 Dec 2024 16:59:47 +0300 Subject: [PATCH v13 10/10] leds: max77705: Add LEDs support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241223-starqltechn_integration_upstream-v13-10-fbc610c70832@gmail.com> References: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@gmail.com> In-Reply-To: <20241223-starqltechn_integration_upstream-v13-0-fbc610c70832@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 , Krzysztof Kozlowski 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=1734962389; l=12909; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=yK/XJU/3gqAAuGDw7ekM2t0lwZA3hV88jttdaU/xuwk=; b=cb0rrQnUiTx21hI6IbPWqYqRIkUohRamsWjlG5lRVQThgqj8fOugOp9cya1J5UK010skOzMNv JWn6jvEidq5D17Rb5YRd8uU6z18g4bR8TtsTHcvWUsYn97r8qe3MTvO 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 v11: - add dependency on led multicolor class 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 | 8 ++++++++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77705-private.h | 17 +++++++++++++++++ 5 files changed, 294 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 2f146b9b7a2a..ea416c793cc8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14263,6 +14263,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 011216aa45cf..9677414a64c9 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -766,6 +766,14 @@ 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 + depends on LEDS_CLASS + depends on LEDS_CLASS_MULTICOLOR + 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 52bf8bf9c4ad..2e316e5e2f24 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 e4309d3b6f2a..41bc9d1188a9 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,