From patchwork Mon Dec 2 09:47:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846813 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F1721FBE91; Mon, 2 Dec 2024 09:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132890; cv=none; b=OCxL/BHKsx3rgqUdZDODxi9WiNpbQSmYXx1+oR0id9h3Mj3DLFEDJq4aeDtzh9XKlcqlfWrqVjMYD34nbg1JUGimNRD8/R7MqApCy5ULrauU7Hzx4zrP/DTI/KSzfpJACOgpq0WTloNYCTGtggmRkOcGKTyIfY2672K4FBtqzx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132890; c=relaxed/simple; bh=tdGTuOCygyKLTzrZkn4w+l/pmKktzi0hDq2Y4cLiQJI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aGfm4QhBxpO29FC3sPLIme6o9QkWq0RGLc/TfmhEDG4LlmSENQZziZdxCdUihMytQzvIk53Z0H/tQvE4vzOXtgKCZC7UYddbyX/n7v1pvc6LzXBq/45oYpxKD6w7Z15ixT+lX0uL8xxv6hsmtu7Uk0qRXHMMTAvGhlM71qMdWrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JQPt6Asa; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JQPt6Asa" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aa530a94c0eso660814866b.2; Mon, 02 Dec 2024 01:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132887; x=1733737687; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FKMQu9Put2whTLlJmXR7bTTxcNbkqOf+6o99Kc/4Euo=; b=JQPt6AsaOfPmvZ+N+L6FgragsTyriJGhbg8y/5OwiWQZBWP0h7aK6YT3oG7MSSW7tw 5TYwYCcreShaUcc3d6sXBEnE5gOrRDiWW2UU1z/gkiC1XuedZRi5t/qt3HmNbX61Hm1o r2ZXD8l7rXkXi2SIsLjSQ3+uXbZBcwd1/G1cQAD7iMo7C8fs8u9B1A+AhK42/huriVzB qowQ4vmuZlsTxPobnVwBPbscVP/kFF/HCV5sJ/AAnx/AOswq8TPbpTGkO4XBaeKq4/FS /753fAQpU4lXuMKViutYdktm4xmtE/kdmDqqohmxH3wgVlu1/gwbitUgHjQnMC8esqzn RZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132887; x=1733737687; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FKMQu9Put2whTLlJmXR7bTTxcNbkqOf+6o99Kc/4Euo=; b=kHlGhuoZUZvMfyoQHAdEGGpQVJqzVEBx9AcremVVpLKzM5a4D5tmaOzmvc7YRMfhHp OT8brkKXGtf2544DJceJLr8ecnezP7215JgEks+7ldeZz3AwIyQzZXntPpxIDv1mink2 l6E7Lxb51blSSqxCkASh44zyFM/Vg2QXcuATbLncWW6WMczuhg0c8a/pNuGG9bEgpyWN HiH3X0MTs2U8mhjd8VIyt5hvG4u+n1Y38cAD0bqbALkYh0haPC/sYDlSEo5/uf+AoMmA jbNfEO0RzKz8x2ALn25fbMYNRLrjmMtnCizjJeb5fqngESpKKHxhCbV5vbFttsCl44ig 1Pzg== X-Forwarded-Encrypted: i=1; AJvYcCVvvKCNvt589nz2cjpon5HFiDcpVBgIqxtxDfDYHhp3w/eCAPq7CLyjZLsYQaQqIBxp8awQeagl2y3t@vger.kernel.org, AJvYcCX6agzsN2eWypjfJ1xs9OlqkIqBK+v/IVslY1fpI3Rib6Vkv5p4EIm6vLJYuFHVpO0IsXQGKUbNxeLjR4U=@vger.kernel.org, AJvYcCX8rmw4h5/J8NsSnplcvOHOAFetkPwsX9lKuNnZdN5aykM502hobcyIGwOzrEUtNAhNZaLI7O3vKeI0gg==@vger.kernel.org, AJvYcCXNm96/+Ph6R0rNF3LEnt72evjdAM+rAhSCGCcInRQteqIMWuZvsyEyeLF/Hv77tpwu7my9iCAdtlFpi61P@vger.kernel.org X-Gm-Message-State: AOJu0Yzr+MVpBdgJ7dLA36GcwItLuaV3dXBfOJuFVcoBimltANM/Ri8S mD3HzeN47ncR23hvcfXz/zj+oyG+29QN9Ovvbr8TTZVKmZmp/URa X-Gm-Gg: ASbGncuGp/PeLPwZWB+S5ccZjLbNGTRu6VmD2EvPcqzv69HH43IvqH26FaFEkr9kzks RfPt/AIsIPcIuEmjJbl+UplVLmKkPmP9S5IJO9jy7XRSAbBl6mEPywcpEgOwejAo3AKJxF4XVl9 uTs9uKzcNhjmsnE9LbtqbT/34nsw/ZXSnETmQzrLh8isTqp6ZCpFigi4TKaTnsJPLh/NEWYX5y9 EMt1mq3hJZWj121EnKG54GXO0YmuyXuIbB5Dh/jTIlQHQdZ X-Google-Smtp-Source: AGHT+IGJh660APdyPaRenyDkc/Sr6gQpwtz0yPFS9TqaLYSUTvYP7MviS1z06zKjqFW8zY4aBMR2JQ== X-Received: by 2002:a17:906:3085:b0:aa5:35fc:cc21 with SMTP id a640c23a62f3a-aa580f2be0cmr2006372366b.19.1733132885771; Mon, 02 Dec 2024 01:48:05 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:05 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:54 +0300 Subject: [PATCH v9 1/9] power: supply: add undervoltage health status property Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-1-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=2343; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=tdGTuOCygyKLTzrZkn4w+l/pmKktzi0hDq2Y4cLiQJI=; b=xgO7pUxB26f/cMg2PFnh0BWsWGEwTE43hhHhmBylkVzSIk0phGl5iDzv9a2RN9E29v/RE2Sfo SkWeE3g0OqFCD8L2zzkOcmnADJQxwSpXCbyH/WR2A7tjgeK34zuwKIc X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add POWER_SUPPLY_HEALTH_UNDERVOLTAGE status for power supply to report under voltage lockout failures. Signed-off-by: Dzmitry Sankouski --- Changes for v5: - update Documentation/ABI/testing/sysfs-class-power and drivers/power/supply/power_supply_sysfs.c --- Documentation/ABI/testing/sysfs-class-power | 2 +- drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 45180b62d426..32c018c5d088 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -433,7 +433,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", - "Over voltage", "Unspecified failure", "Cold", + "Over voltage", "Under voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", "Over current", "Calibration required", "Warm", "Cool", "Hot", "No battery" diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 571de43fcca9..247c2910ba34 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -99,6 +99,7 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = { [POWER_SUPPLY_HEALTH_OVERHEAT] = "Overheat", [POWER_SUPPLY_HEALTH_DEAD] = "Dead", [POWER_SUPPLY_HEALTH_OVERVOLTAGE] = "Over voltage", + [POWER_SUPPLY_HEALTH_UNDERVOLTAGE] = "Under voltage", [POWER_SUPPLY_HEALTH_UNSPEC_FAILURE] = "Unspecified failure", [POWER_SUPPLY_HEALTH_COLD] = "Cold", [POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE] = "Watchdog timer expire", diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index b98106e1a90f..e96d262f3c2b 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -58,6 +58,7 @@ enum { POWER_SUPPLY_HEALTH_OVERHEAT, POWER_SUPPLY_HEALTH_DEAD, POWER_SUPPLY_HEALTH_OVERVOLTAGE, + POWER_SUPPLY_HEALTH_UNDERVOLTAGE, POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, POWER_SUPPLY_HEALTH_COLD, POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE, From patchwork Mon Dec 2 09:47:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 847484 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDAF91FBCB1; Mon, 2 Dec 2024 09:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132890; cv=none; b=GPl8j5gYu6MJoVJ+loW1hNNAyAc4gY7ViQnpy28F+GLzKa1fNYivncGirYVsHg3ybPFobN6dgVVJsRwxiYQtKvS46JxoTwReAQeBxk1PZLL3O0+AwcVhePgKPiF1dOVv9kW1IUfPTmeJfV4yiuziuIR6ErOpccVJ/rao4W8YI68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132890; c=relaxed/simple; bh=iVyaZKxO2BmEs20P5C0zG17CFpaLKpfBWni/drskwwY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nDSwFomJ+BsPie1s0N84a6WXT+PQJSw/WVJ+TU2t8HrgsDDxe/hhlqh3HGmwXsUdgjBfDaNvtiP18ikOi+BChQjWDkwHaU7KUXDVh4jko3Po1RhRGTn9B2MdNA+iEBr5Tk/7ZWM9EcifsxoAg4+ZlKTX3Dz19Lu7y+yRYiR4fw4= 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=ALRiZqeh; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ALRiZqeh" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-aa53a971480so623256766b.1; Mon, 02 Dec 2024 01:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132887; x=1733737687; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6OlJi6DuwyfQMjGwJMUgh5OIHj779pVW3nNLD3+J98I=; b=ALRiZqeh7pPu//Q9zs8eSYUe7FHsPq45IQH5K9sGK9j22KJp5D8Vf+p6r5vokO11x4 dfyyFTw2Ssb+xvt8/sB2dXb1LX9CNKw7LRkLG5DxqTxY1bNj1EDr6U1r9ph3Hgj3x2vC BOhxQi8qeUipj7NLj3PWM88IU8YJLZhfCz5ZFrKrN4siBTR1Q0DFdzfnrc7ucPl5CX7t HbTRTxWjLeFFonfqGvnXtIcWijXxlqkAupgenG9QBP5jRjHGg3fqrAIdbQQOwWFJrSDL Hgl+D9dsZ8Uq1DBxgmCAojsWkI0/IYBzdU+GzlSO3ulHK7yM4bTmiZlBKpccdLJyEIQe +6IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132887; x=1733737687; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6OlJi6DuwyfQMjGwJMUgh5OIHj779pVW3nNLD3+J98I=; b=AZ4dGBO5xoMkWZ9eXRpUFQDWablO3Rz/6YLSi9qy8oBbp+FQP4ODJdTZcabnN9Exx1 NdxLauI5ue1vMSgnLcmtH5PmoGvpqg5qg8L0WfdniAnL6DaMlXOFVFUjz6dZjJ8IRXTI Q2yLW/crTl4fO/em7HizzUKyMkP372RXMe3cIoYkHhJBYWuFmDOaQVqeURDaQxmevrDl Dixt69iL6+d6ScFMFhUN+GMT9P5VRlNOSdJ8obyldsqXN8aZsfDSV7KxaxUak8fsp9qE oJW9V/LA01Uw/JmBvZneFW78D75C14oXjL6JNARev+8dKU0ox/uDXjdwwtViUkTq0MEz iudA== X-Forwarded-Encrypted: i=1; AJvYcCUFYKz7MkgNHAS6FbW+1D6C8yJ+eDbuDrVkoGQDw2ALiRTtToPKhcIdtnnCUS8Ga9RfovbKIHNI/oix@vger.kernel.org, AJvYcCVdt/XKFJ/wFpkZxVP5d46SEu8Xl+2c32r3gs7/s18QCnx5OGejrK1owPh5tAE6or+4AXpMIcrwtglJ+g==@vger.kernel.org, AJvYcCWErh8Rsywm1SReFx1EjhSonj23PQB3ul+/Z+Umc7X3Vx0t/kb0DLCCbfMHhwisHxLc+STcPMzi12wxV3OT@vger.kernel.org, AJvYcCWMzFNde35kkjklj1KjU1AFDSA55VhPrnM2p1pW0HuG27U7E1yPqfATeRdKWftIsUY4tZFi0/bk4ugePdY=@vger.kernel.org X-Gm-Message-State: AOJu0YyWfKrhSV6qZfMxGy/MArolt39+m875E1JbnNO0oDdr7ebKoRZ5 9atGDc6qZ8EzaGLwannITHvsNJf2riO8rc9fSNgu+bsfFejz7K14/US05aHE X-Gm-Gg: ASbGncsm8rZdqIxogmHgfrrnXbDnVwerqtj9We3NHv6SDr50TwwBcUh//jlLtYrilx5 rZJLiEKs1eZw7qz4JB7I3nd+99Fqkf+3Qajc1uu9rsx17TrYsEp2gosJIe1JX/fnfXkAEqmLUa8 cPGiGobHgxmRJhcRyFhpW06z+XxvpS/zBTppAY3FTHQb+/aPXN4SiB/d9JHkPrB9fOY3xtO/SXQ ZpINLZ8dq6M69fhCKDic87WBfbyXs4yCX923BYd6ST/GImd X-Google-Smtp-Source: AGHT+IGXhYTHcGl82HQ7c4wZOtPNRaymliGjINI9HRMz3yM+uAQl3MX7QUwfKvdheAJ5NWl3hmHrRg== X-Received: by 2002:a17:907:778b:b0:aa5:1224:ed78 with SMTP id a640c23a62f3a-aa580f2b453mr2247428766b.15.1733132887045; Mon, 02 Dec 2024 01:48:07 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:06 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:55 +0300 Subject: [PATCH v9 2/9] 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: <20241202-starqltechn_integration_upstream-v9-2-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=739; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=iVyaZKxO2BmEs20P5C0zG17CFpaLKpfBWni/drskwwY=; b=5feR+eQcmcJ3J+DcnmfEkHj/AQfS3NecPH/Qp5h+/Kiguf0ROFoDQVsAuAlVLBQvGIBp3dfHx tDzsVk2dK1iB0MG+QEkN15Jf5A12oFdve60vGct9T1tKSip81TUy86A X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add max77705 fuel gauge support. Signed-off-by: Dzmitry Sankouski --- 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..f929e7e2b82a 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml @@ -20,6 +20,7 @@ properties: - maxim,max17050 - maxim,max17055 - maxim,max77849-battery + - maxim,max77705-battery reg: maxItems: 1 From patchwork Mon Dec 2 09:47:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 847483 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C3CA1FBE9B; Mon, 2 Dec 2024 09:48:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132892; cv=none; b=RoPHRicLThEdMHOt+4g8SaybAbDIe3qQZ3s4LGLSCEeOYFCPi/fWhCchi1dCp/UFdhSj8BHrFCVE17D4m2WVkrRw101J3V/JPXRDykg8EqV1Np+wl73Lu4HHtujMqbQSqp4ALnK+caTKKsH9wMjWx9YKYvEpOw4BU8mL8ymiKbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132892; c=relaxed/simple; bh=XyK6JJc2MS6uiJOZtNGQ77axjfYzo4Aw4iRhr7Njxwg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IuS6BFnDV/ssFf3seB/Gad8L1TyZ+1/5WRdV7ZaUkeT/SHjbrqkH1g80C2VgfqfqgWgQpb70e30aGh82Iokccesgs9+IBje6AWvkDg8QT1DXJWCpCbpR+la32etNrdC4G4cKvlT62q00fcg1djNbTOZwOH32YcP1o1TzS1AcTkk= 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=mAxikhmM; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mAxikhmM" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a9a0ec0a94fso535978066b.1; Mon, 02 Dec 2024 01:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132888; x=1733737688; 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=IBK4652sYfOKYrGRBYDoSF0xs0OKs34l32mh6irIiV0=; b=mAxikhmMLZsfIM4XApoDjNr/F3agy43RPuuHwu1ictlDmoiJOTreseqkkeh14GVAV5 5j/xm9o76BggmdVceQrBSzKyjMjU7W31FeiOfgI6ZuAlSzpgh1aS5QFAkM1oNEYyiRW2 taZuqo8814pknToCcMjYwLj94l9oeGujrJACEHgojMY5XkzfA1BnaaX4IfnvC2tEu6ts GNNtisWPjzS8PUF7e0rdVIUM70glzExFUzXBZJ0I/25YZUALNU4LqD3E/v7v3C86wHjj CR/dR1GISsBr5XOqpB/PIlOdNXMPAEVRa70jL9r/R65sEF+YT0bU9Tv090rSRxc2W8rY x/3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132888; x=1733737688; 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=IBK4652sYfOKYrGRBYDoSF0xs0OKs34l32mh6irIiV0=; b=wlvqMoSoZrGw6ZyWdvDGkGZjwC0hC199Tu+LW/Luhq60MH31LztzOmDNLJxJeHpxNV MR0SrS6fkM0lam4yDbRqrak81vNx7wMo9h9CEXVYghX30CPQ97BBzWdwIP2UghLjnVPT wgd1ose6nhiMFy69s4z4U8kitebIhy0xc3ZDE6BtbtNr+hjA/9sWsr6CXqa520/GsvS2 S9flkUSBRsNzcfEjOYnY+PREk/ponOelDgEsVQALFwoWN6pEQRI08sXk4t669D4ZA6xR IB2VjxTYJEu6e6Z1v5YvJjc3gunQgOzqTyc51xLHetouSwA3YZ0HWstxhaJOyqadLzQM E6sw== X-Forwarded-Encrypted: i=1; AJvYcCUctqRf2GZcZKjfydtjNxq8FViB4zfhseU70n4tiF4PnOQbdn8sp+7U0e15pfwz3yQ3xn3iunMw8/pM2qw=@vger.kernel.org, AJvYcCUqWOsJgqqRtfaDawgEt4CyNX52NJBjbrTIByxwInh1SmNLl44dD+PNklsr5+Wf5Pnzg+VdAvkpDTLn4KRw@vger.kernel.org, AJvYcCV0sevSLGUy9s/UfuMqbCm2fFpYmvUWiNkgLISPhl1hWax0nboOcLwsH2Xv54mGA+XM2Jj2rQ4m23+ieA==@vger.kernel.org, AJvYcCXfie/CRJX5A7LC8V+FuSXwYWUNfSuOBGI5jk9FmtIAE4iVElyX2gRL35a2EHNTf94Ut0Cv8BVhRGdb@vger.kernel.org X-Gm-Message-State: AOJu0Yyg/4uwr0dTiZ0cBcdrguGLuYlh6yvwEWpP+wcFWqXP81C/1yTy oIO6afJbRaOWWcJtak8Y1rnsQfs5SvAhHCgB5gCyOXA0f86SFRvg X-Gm-Gg: ASbGncsDhbNRCJ+lV8o3UVtNjHyzyM0hU4dZ62qPdgDgi8/N963bqN5xSLFlJ78pg9x It2oGwGSUuAhiKGMNraRqeaKfYbk5j/hZQdM1ceNOip+oilKpYyaGXfuvH26pkfIpZxYwVZ+tSI OPFbFNNcvjdcOC/XGoSUUevXqhYGr12usVrCT430BIWFnVBNKxMc5dBq1nqWcOvm3ow+Lke5iXO EgfNVRe5agzt942MalXqIvpzt9S/qrtUMH+RKQCJE5mjxZN X-Google-Smtp-Source: AGHT+IGmVmWnm03Dt1T8R8SwyI/C3c1z+toD+fGD7aWYOwRJfXrS88BoIGjsfBRUVpTXtJBSEXjmHg== X-Received: by 2002:a17:906:30ce:b0:aa5:1551:99f2 with SMTP id a640c23a62f3a-aa581072b9amr2017019166b.49.1733132888427; Mon, 02 Dec 2024 01:48:08 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:08 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:56 +0300 Subject: [PATCH v9 3/9] dt-bindings: power: supply: max17042: remove reg from required Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-3-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=781; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=XyK6JJc2MS6uiJOZtNGQ77axjfYzo4Aw4iRhr7Njxwg=; b=dpX46eSH3O/jrTANusO9pbo8WAQDdhPlIhEVa9ReT6HLZCxAo3qxm6BJ1bUiE2klW2swf+ZG1 PYBqoYOLmgeDn5ucxFIloqxHVTqSsmyyXXMmtOGO/6TEPjDiNJlvmoz X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Remove 'reg' property from required list, because in platform variant it should not be present, because i2c client is passed from MFD driver. Signed-off-by: Dzmitry Sankouski --- Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml index f929e7e2b82a..7a26036a8890 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml @@ -64,7 +64,6 @@ properties: required: - compatible - - reg additionalProperties: false From patchwork Mon Dec 2 09:47:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846812 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E61A1FC0FE; Mon, 2 Dec 2024 09:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132893; cv=none; b=GHwTQukh6uHexlx3FbP5GEaoIkZK2NK5WqY4OsAysmBBXEtyHcnsyfmGoNkzxjEZ0cVxPLQYNlm9LkVgx8NhIqJvEPvwJZWYNq0MPF0WOMkbgBMAWda9xmuY+FNFSLlzFSCbTlfPoNkGMLqmblre/9Dis0rwPHSFGB6YYmkc//0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132893; c=relaxed/simple; bh=kSoIMsEyI5FQ+mbQvFip9d0Bq8H/VWKwGdAEJhaEXzU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uvk0wjFcN/CtouIvG1sy/dS+Y8rzNq7ZHMl1Dg/xOIlDSRGS5zPygU3Y8Qk8QpaXGX3Zno2oDiqVkSVZ1alWdI9zdSIQz7TgnqJJBqeXukLpFKG+Nsbc3usPD4poHO7kbI2PKxQayQtEZRfXwX7TIGVFhUZsLns5oqoEhdnz2EI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YJ3OgW0j; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YJ3OgW0j" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a9a0ec0a94fso535980066b.1; Mon, 02 Dec 2024 01:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132890; x=1733737690; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ROh+ssRkigaZFqJs0rde83s3PLdGc63hrLp1rlTw+Eg=; b=YJ3OgW0jJmvEi6v5e3/tsiaj0hh8xI2t6C/tpdM/ToUfkNE3kevi293tICKpDE5kAI gKZhoIxqbOkOntp3XmJPf/1EqcoPXG5AAAX/9/QR1GH7xhV3n8rs+0IxR/fttye8mMxH gohPqi/NVEb2iYqbAIpAP7UblToZ2msURrTF1gxXEbZ+sH9ag3m39t03f6cH97ml9kNt bMuTmqzeRcIT5MjSzAPWH3p73vqs+30T2CTYGIvuy4vz29Gk1DQSoFY4I1Su0YMYJ72z vQVpDrn5yp0EUwaMGY2v/FcGE+jwh1C1TLDhxL1aCkjk9kQ35TMPNzUBjeyITTspCXqD vp5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132890; x=1733737690; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ROh+ssRkigaZFqJs0rde83s3PLdGc63hrLp1rlTw+Eg=; b=q0w152kIvnwTr9Phsy1Q1Jnf3CWgiF/bKpVHZYm2xa7HTfcfymR3/jFL+IR9hKLtbA sale/n2ETHaIa1IIP5v43FC5viphBGgn/2SGL7VcOW2aeBqlc5yquHFtW/aP6cSuwdzq D/R5ZlG3X0tLavyYJY+vmxA7AHgymUa4ozW75QguyJq8hkMkNr/G/QbnWKaPOkQI0a9D DBfJSq98ydontxOeKTU0PrT7TA1z4mIWFIj1WI5II3CFvebp6nDGKhzu79ApcbDi6vs5 Puoza+JdtX9B3cSb6zPk/frIyxU1UEUHNF+c2Hzl6tjo3buR9cGzbgrIkeRO7kq6JaU3 Pm7A== X-Forwarded-Encrypted: i=1; AJvYcCWGTeuMgeX9mMdk1UD3gKls5tG2ooQJe9OX2dNepDU1/N8GWL+1U/LEQ3f7eJyxpcRa+Zn9hrb2EZrOmeWy@vger.kernel.org, AJvYcCWJibu/Xg3R43ONU3ZDgvrzH0TGsCYpTwpupGRNI0GA7YvaTDPPsrA/wqWKfk6Aq7WkEMXeFVA4iPIMDA==@vger.kernel.org, AJvYcCX308EBmEubISn5y07pRmKNaYhIdlqyaoVUof0iEwdIFnEB4fHpEq6w33GLSU0SRMR7sY4LeYDvOodz@vger.kernel.org, AJvYcCXdKlKru5UkQyRlqxxImjlllTEOmlGzIGXjr6Y389QtGmg5ZxtBMSL9gZXu4EPsPv9IidyDkY88LbHMljE=@vger.kernel.org X-Gm-Message-State: AOJu0Yy86lnq3koIRJeNOVqWmxy25e4hVIgEm0SBm8TnA1ivn9n4ZXuL w5Kpow1uTA2zFHGkEBydepmtNiaAf8B46h7SsGE8aIuStk9gFBvG X-Gm-Gg: ASbGncveteE+oU1JnawbnusT5TojG3anvJjskN1APv+LPrnErFPNYV2761+D786EyTC hkwFMWZRQZ41SsFUKgUE5ptKc30C4An9u2fww2y3SUydgLYt+ZmupQ5vShvEH90dl4PqpGn56h0 Pol6kKhLyKgIZN2FRqh7W/OGaCWas+7UEZ/XnM/U6glWiBkysLF718hcUTtoWLjLJD8PZmDaiPC XCKQMablWpuB/cWhR7ieQLxnHKbonMg6K6Yrh9T857bWQSQ X-Google-Smtp-Source: AGHT+IG8Db/Agjn5e1HtabRO5f1TOXAQx/7QpO92hEeRm/dqL0aQHHy2kwrWGo5egZag+7w+i1K+bQ== X-Received: by 2002:a17:906:9d2:b0:aa5:4104:4a8c with SMTP id a640c23a62f3a-aa581044168mr1788011766b.40.1733132889666; Mon, 02 Dec 2024 01:48:09 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:09 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:57 +0300 Subject: [PATCH v9 4/9] dt-bindings: mfd: add maxim,max77705 Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-4-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=5789; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=kSoIMsEyI5FQ+mbQvFip9d0Bq8H/VWKwGdAEJhaEXzU=; b=EjAneaGYwe7c+6qfiStq/18Xmwg3lgHXm/wVxX56HBfndpbD4B8AD3oGCYGn+dqShrvCa8NxN LySSX//jckcAqJb44Mj9e5zBNxYqIYU7D1Rdv3RjQt5QFmBdxMCn7hn X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 binding. Reviewed-by: Rob Herring (Arm) Signed-off-by: Dzmitry Sankouski --- Changes in v9: - replace max77705 fuel gauge with max17042 - remove monitored battery because not supported by max17042 Changes in v8: - fix leds compatible Changes in v6: - unevaluatedProperties must be false - drop excessive sentence from description, just describe the device - change leds compatible to maxim,max77705-rgb Changes in v5: - formatting changes - add unevaluatedProperties: false for nodes referencing common schemas - remove additionalProperties on nodes with unevaluatedProperties: false - add min and max to led index Changes in v4: - change dts example intendation from tabs to spaces - remove interrupt-names property - remove obvious reg description - split long(>80) lines --- Documentation/devicetree/bindings/mfd/maxim,max77705.yaml | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 156 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file mode 100644 index 000000000000..fbc264cfc609 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml @@ -0,0 +1,155 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC and USB Type-C interface IC + +maintainers: + - Dzmitry Sankouski + +description: | + The Maxim MAX77705 is a Companion Power Management and Type-C + interface IC which includes charger, fuelgauge, LED, haptic motor driver and + Type-C management IC. + +properties: + compatible: + const: maxim,max77705 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + charger: + $ref: /schemas/power/supply/power-supply.yaml + unevaluatedProperties: false + properties: + compatible: + const: maxim,max77705-charger + + required: + - compatible + - monitored-battery + + fuel-gauge: + $ref: /schemas/power/supply/maxim,max17042.yaml# + + haptic: + type: object + additionalProperties: false + + properties: + compatible: + const: maxim,max77705-haptic + + haptic-supply: true + + pwms: + maxItems: 1 + + required: + - compatible + - haptic-supply + - pwms + + leds: + type: object + additionalProperties: false + description: + Up to 4 LEDs supported. One LED is represented by one child node. + + properties: + compatible: + const: maxim,max77705-rgb + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^led@[0-3]$": + $ref: /schemas/leds/common.yaml# + type: object + unevaluatedProperties: false + + properties: + reg: + description: LED index. + minimum: 0 + maximum: 3 + + required: + - reg + + required: + - compatible + - "#address-cells" + - "#size-cells" + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@66 { + compatible = "maxim,max77705"; + reg = <0x66>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&chg_int_default>; + pinctrl-names = "default"; + + leds { + compatible = "maxim,max77705-rgb"; + #address-cells = <1>; + #size-cells = <0>; + + led@1 { + reg = <1>; + label = "red:usr1"; + }; + + led@2 { + reg = <2>; + label = "green:usr2"; + }; + + led@3 { + reg = <3>; + label = "blue:usr3"; + }; + }; + + max77705_charger: charger { + compatible = "maxim,max77705-charger"; + monitored-battery = <&battery>; + }; + + fuel-gauge { + compatible = "maxim,max77705-battery"; + power-supplies = <&max77705_charger>; + maxim,rsns-microohm = <5000>; + }; + + haptic { + compatible = "maxim,max77705-haptic"; + haptic-supply = <&vib_regulator>; + pwms = <&vib_pwm 0 50000>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 1240e75ecf4b..c3f66093edd1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14185,6 +14185,7 @@ B: mailto:linux-samsung-soc@vger.kernel.org F: Documentation/devicetree/bindings/*/maxim,max14577.yaml F: Documentation/devicetree/bindings/*/maxim,max77686.yaml F: Documentation/devicetree/bindings/*/maxim,max77693.yaml +F: Documentation/devicetree/bindings/*/maxim,max77705*.yaml F: Documentation/devicetree/bindings/*/maxim,max77843.yaml F: Documentation/devicetree/bindings/clock/maxim,max77686.txt F: drivers/*/*max77843.c From patchwork Mon Dec 2 09:47:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 847482 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.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 B39821FC7DB; Mon, 2 Dec 2024 09:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132894; cv=none; b=ozbC0YfEp93tQ3fo/VUS8a9TpbJtdEB3SbP0ui8+wlSxWDudOgLREpXMZ4WuOfpRLPeYZnTrXSulKYSa7KeB7BsQLt9WMOcBkzreU1OlVtoR3WE/SQjCqgdylbApK0veHDOVyduSe6MPu0kkQaOlN9cDYtbIfYzfwzk09bDoUso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132894; c=relaxed/simple; bh=25GZxtAq4n+C/Yvdz0amIVqfYjK/Qv0YaoQj/wQrB3U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pG+oFLV7C8mTWaAcLXWUnpQSPsOzHFOUn47q/LQF9MJoDJ9xx/C2BsACh8Y2DgShzVlY2ejLzJL3TS9JyMuFtxLa2fAwnsqFH5zIsMq3alw5JjDmFqUD06ooAj5sTFYeVnSIwgw8vrmB8WIEVrG4vv6pX2ntA3Ve1q3T2gpY4TI= 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=mw57USkM; arc=none smtp.client-ip=209.85.218.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="mw57USkM" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a9ec267b879so651685166b.2; Mon, 02 Dec 2024 01:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132891; x=1733737691; 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=xM6JAaZkYYk1PpNLi9iq+4RSHcDTGuGEA6QqhqV5EhM=; b=mw57USkMcaNlV/qYKC4GnrciwSS8lVK8AC1WjR82XOVeabyq3/TbWj12ivk2PDqJSe ZoPOCR+znX+JUzKadtQDV6NNqbklA2pmw1+4foCvus2fi/nfGpEtnArHSG+Szw1QTSx4 oGiQ17p7iNA9s78BoM/9tt+TZtaI6Bh0ChSiy+e9agQUvrpd4OSmqN+Bj4DKSXAQBxaC 2ffDD3o2H9gppcz0m5Exc6bNduta6Kg7POqBinXR1mRBvCJlkNoSv4N3RUWEw5bTGasz 8mX0sS0IFvwlCrHpmMCkOEQrUecBiCtT9k9p+Hkf45Q73VDlLiOki0whe8fx+d62NeAW Kx2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132891; x=1733737691; 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=xM6JAaZkYYk1PpNLi9iq+4RSHcDTGuGEA6QqhqV5EhM=; b=QeG5b66FtaEQ4TNof/WQOVA7AuXrCL3JzqQs3SjcyNDef+ePqZzQ+tusM/hJ5VKZZ6 r7kMvt65C+EjNWnRn0IgXYkzjIwhQiJEbmsYGogmcAurwfUHSK7fcDfLZ86yG8on24E7 DB6zb+QOGYaWed2UtplYLepOdlFnDkmE55Xzi9dUnCCq8HUAJWMXebffDywLs9Nmtq0l rxRvTR+DEkjdb1AkHmnJLKSPXNQysc0Ot+MBih5jFkH19EFIIXMYO0odXOFQIBqyZnlL ozM/m+afcWB1S2GSuC5Rohaz19zy0pPB1Cq+a+QMa87pid15v6fLFFJ6uK0c20gTrR7T IUYA== X-Forwarded-Encrypted: i=1; AJvYcCUmInYHoKWdpc0mK3ObWNr50fOh3MY26UQ0emMhpiexpIImt2ZodoTRd5CKvhrByLPKD3Tvbc6Q2qO0@vger.kernel.org, AJvYcCVh3SmVqTEkgVyYgSnKSFYg1loVsb6G6fFEcXAvOnLzfH0XLSqL1tfbYJcosZhvWPAXB4tqZxgvlV/8nw==@vger.kernel.org, AJvYcCWXTOoW70agjWz5LLbA6m1QkQvbO8OvDC7MDEEJtt6JoqlKAuHxs++IUs4bt3JCBQXxpdpt2fi4f+ztcDg=@vger.kernel.org, AJvYcCXaw/iblLsoeSUuf7L4frEg1O0Y8fCPEfshl55ddkH1+X7BIhTLQZkEvZtbLoB/2SYy2fBmE++i9zBWz3AU@vger.kernel.org X-Gm-Message-State: AOJu0YxIBeMma1I5Hy6OJGOZjsrhX9saeqZMhsw58xLVkAqkzWPyGHqZ WkM4a5bQH0LyEhdOZ9jnXB1ygD90IDTorGbrb59eyYcgwMIgJfy4Io2zEfkp X-Gm-Gg: ASbGncsL7Zl84xMTqUVrNUJGDXfTAfiZ5coAGBlNY4/I4FNCI7Ei/6cyCqX7O2ldJrR Kjt0oGfhbMw6wWsziOVMyf4o8iSycGeLsn3qQJVI77k42HbnBMMXVg4XW0vXc+UCTcBk3S4KGD6 4yhA0pYR4RsPbydz1bPx9IGidBwxQTCS4o6kkDdG8mP7x+5rbWYbfgGLaiuOWIr0SDJDhLC7S2r AwfWS9e24nl0jM7P/LrvV95/2R260gEh/yHT4fYsiqd6txX X-Google-Smtp-Source: AGHT+IGZG0fKD+yecn7TPHhSyNdq+I6v94rfB+0umVt5hkPNqC01neYZfSHTADkYcURer0+3iaEd1Q== X-Received: by 2002:a17:906:2192:b0:aa5:e01:1471 with SMTP id a640c23a62f3a-aa5810330a4mr1467684366b.37.1733132890902; Mon, 02 Dec 2024 01:48:10 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:10 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:58 +0300 Subject: [PATCH v9 5/9] 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: <20241202-starqltechn_integration_upstream-v9-5-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=1433; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=25GZxtAq4n+C/Yvdz0amIVqfYjK/Qv0YaoQj/wQrB3U=; b=PueYmnRPpCnczN6ZC/RImFFhEvkjdRxVjh3yCfa/ugTnJjpN8JVKk48XSnrGYrPNo6Jy1Itts ArL1IwTZDkfC1iTTsdvWNPmEeJze9UyaF4wBNhrv13x7I+UXt5RhGu/ X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add max77705 fuel gauge support. Signed-off-by: Dzmitry Sankouski --- drivers/power/supply/max17042_battery.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 6a1bfc4a7b13..8623c89ad274 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -1212,6 +1212,7 @@ static const struct of_device_id max17042_dt_match[] = { { .compatible = "maxim,max17050" }, { .compatible = "maxim,max17055" }, { .compatible = "maxim,max77849-battery" }, + { .compatible = "maxim,max77705-battery" }, { }, }; MODULE_DEVICE_TABLE(of, max17042_dt_match); @@ -1223,6 +1224,7 @@ static const struct i2c_device_id max17042_id[] = { { "max17050", MAXIM_DEVICE_TYPE_MAX17050 }, { "max17055", MAXIM_DEVICE_TYPE_MAX17055 }, { "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 }, + { "max77705-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { } }; MODULE_DEVICE_TABLE(i2c, max17042_id); @@ -1233,6 +1235,7 @@ static const struct platform_device_id max17042_platform_id[] = { { "max17050", MAXIM_DEVICE_TYPE_MAX17050 }, { "max17055", MAXIM_DEVICE_TYPE_MAX17055 }, { "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 }, + { "max77705-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { } }; MODULE_DEVICE_TABLE(platform, max17042_platform_id); From patchwork Mon Dec 2 09:47:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 847481 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 163321FBCA2; Mon, 2 Dec 2024 09:48:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132898; cv=none; b=O6e4I/nkjXrkzvVU2g/Nc+Fs8cT3IUQu8clDT76fk8dTQ9hN0i0MvnZW270+0ZGfPtcwYk0q9VW+xKtSWF6XcVge41PEk6VI4+DLipxZ5LC5tvxOEIxjc3LI4MKej8/eqdhwg/y++scOnqGOr81vlUKDcLLOl7j6u2Oa6uy7dFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132898; c=relaxed/simple; bh=3wSXtxlaGuN/rWpsGPpI2DywUSoCF1mihMzdG0lPZw0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aVbCcHdTS7KciWMdGia6y++p9rsii6uavJ91qLORk9XDnkn8RdbiTxHFRjPtWvgJOKcQ48+X6shFw44mMFTSoehyceFySbjTWM4GtfCZpBU9sH+Tl9shwOS9NVchWEjByDNSWEy2M74EBVH1ja+1woXuAprxrH/A7lmLoCncXqc= 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=T9PA4ohs; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T9PA4ohs" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-aa51b8c5f4dso593923566b.2; Mon, 02 Dec 2024 01:48:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132892; x=1733737692; 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=vfjDC06MTp2B47enl3KHHPiFOICyc7FV1MJ/+Hr1NB8=; b=T9PA4ohsrB7XUyeXHKIzYesR+AbUN6J59s0b+Ta/7GN+mE7Q7Gz3Ao6let2xtiiqUQ FMHExvBxR/LxECQHs1wNi/wEvrJNwEJ5XUPIgj1VkUXOXWxLIOatJ3r0cqUO2RBs5KN1 o5pzfKv24Og8hxiBQi3YE1DVIIFRR5rWsf2IufK/8PFqIhTYQrOU6PfDunxH76hh+Qbz 7ZzxcLhhtmefAdnCtrfKKN4I0ey51uKzzjnxBqUqxcxfk9azTyghWQhs0GEou6hnIC08 Wmuwpv9537kTUk2gigjHjbPdYzLXTwuEEmJ6OIWCLgxWsTw4uf2ZXclk/Dxq9K6VbP7Z NXEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132892; x=1733737692; 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=vfjDC06MTp2B47enl3KHHPiFOICyc7FV1MJ/+Hr1NB8=; b=MoSelU7JjiJ6fEX5MNA/KR/ep1I6xHMUYD/l3qJa6kooxnRjSpdDj77KXfWr1rskDV o7rC0Up0Ad8/j96JDKHI4c/4Z4MpWOd27qAcIaojhwE6aoNyYxwr0b4HAlaKDeJhBpR4 ZJv/KkVYtXYpN1LCfqg+ik75XltABd9tbxqgJ6/MV/gadM5VIRFQ9vGVU4o5k/Gby8QT 0fQD93w4lvpYjjWKBXH03B+sVtuJkWyKz1v24KyHZithJFnixM5++CFBLZAEfSxm7MwB 1jefInob+V3sDDN+lWcPGvLCwDtmDl/D2IfBLeYxY5xshrdLVZjzktHOp8NdHQ+joG1x fLSA== X-Forwarded-Encrypted: i=1; AJvYcCWzLS221ej2mgDjcCDPJqty4trIoySss+2dXVMP9Wx6fQjdsCv4pdpYP2VrbgZMupfDAcFckkFIs6XK7w==@vger.kernel.org, AJvYcCX0NRx5TqCjD3Y409Mt4mlcuu9Jtm/LTYYF9rxu47ueISjuyy/ButIcySMYG6g7dR5IMk/JZsi54v/hGGc=@vger.kernel.org, AJvYcCXIlqEcdJ0so7Nrc1mHPnmdHJK8oZB8B9NYFrBMidVxdso07Osoa9/tk/Foj7QhwjeTqnzpZ+Bk4NBJ@vger.kernel.org, AJvYcCXkl24+zVap6dRz0ND1i5oNz5uIKFXzQPuVJQc4LkPPs6Nzt6En4Mz/h1cIFb5WoFfbH/w/5Mp9j6UHODJd@vger.kernel.org X-Gm-Message-State: AOJu0Ywqy3mJ9P/Sb3zMjHMHO9jdgwP2eINKpQ6Sw5SFY/wFiZbDYZg/ kMRq3DPFt5Rn7KTtEjE1hlP9LxKD1Ahg5M+HuPfU5S3nY3euzqm1 X-Gm-Gg: ASbGncu28SkM5in9jGvgbrNmP+IQkgz2hBV1XP5rrWpgudzUwvXKw0c0w75zAqV92yj Mq2yNJt1CCHqdU6fr2Qu0CgICHJnTBwHa2K9EvZhERAw/pNl8vfWlpkh6VfesCKGPinhrXlvdzR xftOrXBCqBL+jfMXLsxIAxYorbpOiIsHrp3EPyqoh4UF/cB+oFTHA12pwC1yJGd2fKcZpmjpB6l cHmV3a7otHOSEWA3OWk+jDqd5deY3dEebJiRZxUC5D1ThhO X-Google-Smtp-Source: AGHT+IGvbE4ULrnjVfLZiXEKHJNLcEYlnbCJANeUtUSGMyoE4KXRCT0rD1bYG0eMczSln6rJkB5CKQ== X-Received: by 2002:a17:906:2182:b0:aa5:3853:5535 with SMTP id a640c23a62f3a-aa581028f7dmr2061245266b.38.1733132892168; Mon, 02 Dec 2024 01:48:12 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:11 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:47:59 +0300 Subject: [PATCH v9 6/9] 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: <20241202-starqltechn_integration_upstream-v9-6-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=18949; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=3wSXtxlaGuN/rWpsGPpI2DywUSoCF1mihMzdG0lPZw0=; b=McuqP1J8csujMy+qGwh2ItSn22S/1ta139FkrI0fXLepqE/pwSBmAbMi4mW2d2Ety+rQXiUd1 UAxPRGvhI1eC9gPNRLrpU5Qj+/L9LwZjdjSEYXrnAIlESqV8Ajvta3E X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add the core MFD driver for max77705 PMIC. We define five sub-devices for which the drivers will be added in subsequent patches. Signed-off-by: Dzmitry Sankouski --- Changes for v9: - use max17042 as fuel gauge chip - initialize max17042 i2c dummy device in mfd device, because bus can be used for reading additional values, not related to fuelgauge, like chip input current, system bus current - fix pmic_rev kernel test robot error Changes for v8: - fix comment style C++ -> C - remove unused pmic_ver Changes for v6: - add PMIC suffix in Kconfig - remove filename from file header - reorder headers alphabetically - move out fg and chg adresses definitions - rename led name and compatible - remove overbracketing - move charger and fuel gauge i2c initialization to their drivers - fix max77705_i2c_driver tabbing - formatting fixes Changes for v5: - license change to 2.0 - use same hardware name in Kconfig and module descriptions Changes for v4: - rework driver from scratch - migrate to regmap_add_irq_chip, remove max77705-irq.c, rename max77705-core.c to max77705.c - cleanup headers - remove debugfs code - migrate to use max77693_dev structure - remove max77705.h --- MAINTAINERS | 2 ++ drivers/mfd/Kconfig | 12 ++++++++ drivers/mfd/Makefile | 2 ++ drivers/mfd/max77705.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-common.h | 5 ++- include/linux/mfd/max77705-private.h | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 443 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index c3f66093edd1..b269d0456da3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14192,6 +14192,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 @@ -14199,6 +14200,7 @@ F: drivers/rtc/rtc-max77686.c F: include/linux/mfd/max14577*.h F: include/linux/mfd/max77686*.h F: include/linux/mfd/max77693*.h +F: include/linux/mfd/max77705*.h MAXIRADIO FM RADIO RECEIVER DRIVER M: Hans Verkuil diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index ae23b317a64e..17951a9d5a93 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -916,6 +916,18 @@ config MFD_MAX77693 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77705 + tristate "Maxim MAX77705 PMIC Support" + depends on I2C + select MFD_CORE + help + Say yes here to add support for Maxim Integrated MAX77705 PMIC. + This is a Power Management IC with Charger, safe LDOs, Flash, Haptic + and MUIC controls on chip. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + config MFD_MAX77714 tristate "Maxim Semiconductor MAX77714 PMIC Support" depends on I2C diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index e057d6d6faef..d981690b5a12 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -168,6 +168,7 @@ obj-$(CONFIG_MFD_MAX77620) += max77620.o obj-$(CONFIG_MFD_MAX77650) += max77650.o obj-$(CONFIG_MFD_MAX77686) += max77686.o obj-$(CONFIG_MFD_MAX77693) += max77693.o +obj-$(CONFIG_MFD_MAX77705) += max77705.o obj-$(CONFIG_MFD_MAX77714) += max77714.o obj-$(CONFIG_MFD_MAX77843) += max77843.o obj-$(CONFIG_MFD_MAX8907) += max8907.o @@ -233,6 +234,7 @@ obj-$(CONFIG_MFD_RK8XX_I2C) += rk8xx-i2c.o obj-$(CONFIG_MFD_RK8XX_SPI) += rk8xx-spi.o obj-$(CONFIG_MFD_RN5T618) += rn5t618.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o +obj-$(CONFIG_MFD_S2DOS05) += s2dos05.o obj-$(CONFIG_MFD_SYSCON) += syscon.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o obj-$(CONFIG_MFD_VEXPRESS_SYSREG) += vexpress-sysreg.o diff --git a/drivers/mfd/max77705.c b/drivers/mfd/max77705.c new file mode 100644 index 000000000000..42ef29e2bd76 --- /dev/null +++ b/drivers/mfd/max77705.c @@ -0,0 +1,242 @@ +// 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 + +#define I2C_ADDR_FG 0x36 +#define FUEL_GAUGE_NAME "max77705-battery" + +static struct mfd_cell max77705_devs[] = { + { + .name = "max77705-rgb", + .of_compatible = "maxim,max77705-rgb", + }, + { + .name = "max77705-charger", + .of_compatible = "maxim,max77705-charger", + }, + { + .name = "max77705-haptic", + .of_compatible = "maxim,max77705-haptic", + }, + { + .name = FUEL_GAUGE_NAME, + .of_compatible = "maxim,max77705-battery", + } +}; + +static const struct regmap_range max77705_readable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_PMICID1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), +}; + +static const struct regmap_range max77705_writable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_MAINCTRL1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), + +}; + +static const struct regmap_access_table max77705_readable_table = { + .yes_ranges = max77705_readable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_readable_ranges), +}; + +static const struct regmap_access_table max77705_writable_table = { + .yes_ranges = max77705_writable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_writable_ranges), +}; + +static const struct regmap_config max77705_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .rd_table = &max77705_readable_table, + .wr_table = &max77705_writable_table, + .max_register = MAX77705_PMIC_REG_USBC_RESET, +}; + +static const struct regmap_config max77705_leds_regmap_config = { + .reg_base = MAX77705_RGBLED_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_LED_REG_END, +}; + +static const struct regmap_irq max77705_topsys_irqs[] = { + { .mask = MAX77705_SYSTEM_IRQ_BSTEN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSUVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSOVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TSHDN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TM_INT, }, +}; + +static const struct regmap_irq_chip max77705_topsys_irq_chip = { + .name = "max77705-topsys", + .status_base = MAX77705_PMIC_REG_SYSTEM_INT, + .mask_base = MAX77705_PMIC_REG_SYSTEM_INT_MASK, + .num_regs = 1, + .irqs = max77705_topsys_irqs, + .num_irqs = ARRAY_SIZE(max77705_topsys_irqs), +}; + +static int max77705_i2c_probe(struct i2c_client *i2c) +{ + struct max77693_dev *max77705; + struct i2c_client *i2c_fg; + struct regmap_irq_chip_data *irq_data; + struct irq_domain *domain; + int ret; + unsigned int pmic_rev_value; + enum max77705_hw_rev pmic_rev; + + + max77705 = devm_kzalloc(&i2c->dev, sizeof(*max77705), GFP_KERNEL); + if (!max77705) + return -ENOMEM; + + max77705->i2c = i2c; + max77705->dev = &i2c->dev; + max77705->irq = i2c->irq; + max77705->type = TYPE_MAX77705; + i2c_set_clientdata(i2c, max77705); + + max77705->regmap = devm_regmap_init_i2c(i2c, &max77705_regmap_config); + + if (IS_ERR(max77705->regmap)) + return PTR_ERR(max77705->regmap); + + if (regmap_read(max77705->regmap, MAX77705_PMIC_REG_PMICREV, &pmic_rev_value) < 0) + return -ENODEV; + + pmic_rev = pmic_rev_value & MAX77705_REVISION_MASK; + + if (pmic_rev != MAX77705_PASS3) { + dev_err(max77705->dev, "rev.0x%x is not tested", + pmic_rev); + return -ENODEV; + } + + max77705->regmap_leds = devm_regmap_init_i2c(i2c, &max77705_leds_regmap_config); + + if (IS_ERR(max77705->regmap_leds)) + return PTR_ERR(max77705->regmap_leds); + + 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) + dev_err(max77705->dev, "failed to add irq chip: %d\n", ret); + + /* 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) { + dev_err(max77705->dev, + "Could not unmask interrupts in INTSRC: %d\n", ret); + return ret; + } + + domain = regmap_irq_get_domain(irq_data); + + i2c_fg = devm_i2c_new_dummy_device(max77705->dev, max77705->i2c->adapter, I2C_ADDR_FG); + + if (IS_ERR(i2c_fg)) + return PTR_ERR(i2c_fg); + + max77705->i2c_fg = i2c_fg; + + for (int i = 0; i < ARRAY_SIZE(max77705_devs); i++) { + if (!strcmp(max77705_devs[i].name, FUEL_GAUGE_NAME)) { + max77705_devs[i].platform_data = &i2c_fg; + max77705_devs[i].pdata_size = sizeof(i2c_fg); + } + } + + ret = devm_mfd_add_devices(max77705->dev, PLATFORM_DEVID_NONE, + max77705_devs, ARRAY_SIZE(max77705_devs), + NULL, 0, domain); + + if (ret) { + dev_err(max77705->dev, "Failed to register child devices: %d\n", ret); + return ret; + } + + 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..8665097892cd 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, @@ -25,6 +26,7 @@ struct max77693_dev { struct i2c_client *i2c_muic; /* 0x4A , MUIC */ struct i2c_client *i2c_haptic; /* MAX77693: 0x90 , Haptic */ struct i2c_client *i2c_chg; /* MAX77843: 0xD2, Charger */ + struct i2c_client *i2c_fg; /* MAX77843: 0xD2, Charger */ enum max77693_types type; @@ -32,6 +34,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..be781a0f9802 --- /dev/null +++ b/include/linux/mfd/max77705-private.h @@ -0,0 +1,181 @@ +/* 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 + +#include + +#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, +}; + +extern const struct dev_pm_ops max77705_pm_ops; + +#endif /* __LINUX_MFD_MAX77705_PRIV_H */ From patchwork Mon Dec 2 09:48:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846811 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0E6A1FBE9B; Mon, 2 Dec 2024 09:48:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132897; cv=none; b=fk93bSznJFMUDCXmcgkhPxdV+sFlQPbR8IpPvj5s+fOJI3FzZIb2DHW/TyKiZ5g+e+6rSlL88HKIuXsOv71GrJB3affh4K+9kM/sLGTGvnkXxksRYGsn99yYUDwCkkUSolTAB/SlWe8NsHKIoyUb1aUgz15z072FBMN0yZ2kKNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132897; c=relaxed/simple; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nNU2LaZD8GwCr3KUyd5IF1esYgdUAGeypVSiMlsH1pGA0u4vsL1zB4KwznWrBXCXDPUbaKP0vvj1nEgY2MwVXCVPNhhFD3L3K269oZP1Xkj1ry8sWBiNX6kbmyhiMdOi4I2woQgcY3VhUWTOtBehtt8PZJIQZQCcXSp0ZfV3K/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Wa8RtJbc; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wa8RtJbc" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-53df63230d0so4749567e87.3; Mon, 02 Dec 2024 01:48:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132894; x=1733737694; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7hehp6Fk0LGkDDofz88Jg2c9t6Nm0JquDsf7Y75Rrc0=; b=Wa8RtJbcqLlAmmo7GtU4csuU9J5kNUdtdJ6b3NGBo+jvrGNMvBzKSGou/9vS9BfCsJ T7hPqioLyipq8ZxnwxJcM1+o+X4m2yOvVCC/VqKqzzMbxX+yMlbD4OoaUe3bNN+vBwZT VGXlHkWhrDAWGEL0mFGAyv2hxV08zVGulY3oULHWCOSYceYfxz1k4/VYOkwc7aCP5b4f wT1vo0MKJXwUT0aj7ghb6W9Yy/okhQPBOjjo0k2PTjrLvkzWhbgDDw38AmOTEXt5Ir4a HaFzM+gOwB+I1DFx3sOeU70v6a2Mc9axguvXGj73aqBGAJA1Ju7ftxG4QshYePsD2VFS EPDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132894; x=1733737694; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7hehp6Fk0LGkDDofz88Jg2c9t6Nm0JquDsf7Y75Rrc0=; b=puLHuf+32twbJO8YOQS9+xSLkq9fpcupKO6/nrrBlpa6D0m3Tkp/IKBqzu+PrlRBlb A/I2rRAr3afnZH6Oq1NrGz3OMZgplHyY3Ayv8R4fmv3dbwoKrkTOgiAz7vEAEAE46QlA vpPFMAlAzGjt6BOMhLMnDFHG2qe6ngb+pRoy4y7nmcaMgbgUxAhm0hjD2Ze7e5LjC4Uh VaADEPas3m9h6gmqZRgK9ynz6ONVeawNX+KehUd32O4bl8EvEftfjAWsbXrj3/lfd/oT 5rik1XgTPSdUzu/Wu29h5sY4q7RByD5JswSpPsc1hzfBxGjCmU7R+v4v5G4FjLLebkk5 4R6w== X-Forwarded-Encrypted: i=1; AJvYcCUvN+/wH1OjnNxcsGPM4khx0f5vvUG4fRZDGzjJnBhKP/g17zl0Y0GcAVcMjJgJtxtDhg13Tlc+T018@vger.kernel.org, AJvYcCUyE3YA37kuXEU5qU1WPLtPm+MX0tRUkcFKs7G6io8OX5xmHJoV5qahtOkbiRjEcOgstQ8FYhvdNWCslMWq@vger.kernel.org, AJvYcCWikQRZYGBNpzCrwcvbVbjSssKHDu4DL791Y3MiPg2RW73vO58mx++N8BBB14LbOcSEczCzfEnTAvQgRrk=@vger.kernel.org, AJvYcCWxWQV6wr9ZIgtbDJzlEGeD+ascqAxQWehaAgWorbdSZNd5HjYffIzvZYMchHyyGR18rFACDO4yJTEfaw==@vger.kernel.org X-Gm-Message-State: AOJu0YwTTeCYmr2+slTeOio4x9taGcoW3N/fcUFswYcCpxC2PdXYnPaU NUKNH0atkAuFvU8MIqUryWTPPZuk8YAAEqDAZxUHgxCWocVYNA2f X-Gm-Gg: ASbGncuNCUTsS1jm40dlWYW9cjuse4v62o9N5XDW9LOE/2lVB+IhmHtIox+9cTURoO5 GzO0O7hvD+TJpUOiFAGU9Q73DHb4aM+pJyQoYEno43gHx1cUQjF7EhJ6WbXjomYI/ef+UN3DEYR cF/z5cjCdYRiL2fB9MK4lm9TdVXFvD/8KMHToBjzRz+maWrqVoOLKj2T95qPNCl0UTRusHl8cW/ 1s91I0lkqY+Z9Rimvf4iofyEbmztLeYC8JIYr6dyhbZFyfu X-Google-Smtp-Source: AGHT+IFy8nKAQ/+EZGxu8B3T/ru6KKXg8q4mm69HrTLXSsWCE/wGfNtxj/ujG6Lv0PSykozra5Q99Q== X-Received: by 2002:a05:6512:3f1f:b0:53d:dc02:794f with SMTP id 2adb3069b0e04-53df00c6085mr11967885e87.2.1733132893443; Mon, 02 Dec 2024 01:48:13 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:13 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:48:00 +0300 Subject: [PATCH v9 7/9] input: max77693: add max77705 haptic support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-7-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=4280; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; b=c9Uc8al4EyOOH5r5xins8idhHLAwnltQUeKqsgz6o8D/IqBs8bozF8+96zhQEJR8vKvPfQPlh 00feA+j3VdZBTzK73kRkgo/kHiHsP3bowtsPOJuh9uKxDBTkYYfAGJW X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add support for haptic controller on MAX77705 Multifunction device. This driver supports external pwm and LRA (Linear Resonant Actuator) motor. User can control the haptic device via force feedback framework. Acked-by: Dmitry Torokhov Signed-off-by: Dzmitry Sankouski --- Changes in v4: - add max77705 haptic support to max77693 driver - delete max77705-haptic --- drivers/input/misc/Kconfig | 4 ++-- drivers/input/misc/Makefile | 1 + drivers/input/misc/max77693-haptic.c | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 6a852c76331b..b4515c4e5cf6 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -241,11 +241,11 @@ config INPUT_MAX77650_ONKEY config INPUT_MAX77693_HAPTIC tristate "MAXIM MAX77693/MAX77843 haptic controller support" - depends on (MFD_MAX77693 || MFD_MAX77843) && PWM + depends on (MFD_MAX77693 || MFD_MAX77705 || MFD_MAX77843) && PWM select INPUT_FF_MEMLESS help This option enables support for the haptic controller on - MAXIM MAX77693 and MAX77843 chips. + MAXIM MAX77693, MAX77705 and MAX77843 chips. To compile this driver as module, choose M here: the module will be called max77693-haptic. diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 4f7f736831ba..3e3532b27990 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -53,6 +53,7 @@ obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o +obj-$(CONFIG_INPUT_MAX77705_HAPTIC) += max77705-haptic.o obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o obj-$(CONFIG_INPUT_MAX8997_HAPTIC) += max8997_haptic.o obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c index 0e646f1b257b..c3b9d33608d7 100644 --- a/drivers/input/misc/max77693-haptic.c +++ b/drivers/input/misc/max77693-haptic.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #define MAX_MAGNITUDE_SHIFT 16 @@ -115,6 +116,13 @@ static int max77693_haptic_configure(struct max77693_haptic *haptic, MAX77693_HAPTIC_PWM_DIVISOR_128); config_reg = MAX77693_HAPTIC_REG_CONFIG2; break; + case TYPE_MAX77705: + value = ((haptic->type << MAX77693_CONFIG2_MODE) | + (enable << MAX77693_CONFIG2_MEN) | + (haptic->mode << MAX77693_CONFIG2_HTYP) | + MAX77693_HAPTIC_PWM_DIVISOR_128); + config_reg = MAX77705_PMIC_REG_MCONFIG; + break; case TYPE_MAX77843: value = (haptic->type << MCONFIG_MODE_SHIFT) | (enable << MCONFIG_MEN_SHIFT) | @@ -312,6 +320,9 @@ static int max77693_haptic_probe(struct platform_device *pdev) case TYPE_MAX77693: haptic->regmap_haptic = max77693->regmap_haptic; break; + case TYPE_MAX77705: + haptic->regmap_haptic = max77693->regmap; + break; case TYPE_MAX77843: haptic->regmap_haptic = max77693->regmap; break; @@ -407,6 +418,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(max77693_haptic_pm_ops, static const struct platform_device_id max77693_haptic_id[] = { { "max77693-haptic", }, + { "max77705-haptic", }, { "max77843-haptic", }, {}, }; @@ -414,6 +426,7 @@ MODULE_DEVICE_TABLE(platform, max77693_haptic_id); static const struct of_device_id of_max77693_haptic_dt_match[] = { { .compatible = "maxim,max77693-haptic", }, + { .compatible = "maxim,max77705-haptic", }, { .compatible = "maxim,max77843-haptic", }, { /* sentinel */ }, }; @@ -432,5 +445,5 @@ module_platform_driver(max77693_haptic_driver); MODULE_AUTHOR("Jaewon Kim "); MODULE_AUTHOR("Krzysztof Kozlowski "); -MODULE_DESCRIPTION("MAXIM 77693/77843 Haptic driver"); +MODULE_DESCRIPTION("MAXIM 77693/77705/77843 Haptic driver"); MODULE_LICENSE("GPL"); From patchwork Mon Dec 2 09:48:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 847480 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35D0B1FDE1C; Mon, 2 Dec 2024 09:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132901; cv=none; b=S6J4mN8qP5wm5yiI0D1HB4kBuRvSL+1o4wWXFdOAHQZ1AfcW2xJtFA5rNNCSj7cHK11oTY5vuUT8+aY52NQOg+exOEcDXofUBUf8eRsVD4Xu6wTqYF9/2rBumbdhF6oj/EmFxqbwPaFJbzaE1esX65S+j85J74X+aoSfYxPJBjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132901; c=relaxed/simple; bh=kBOq8eZGtiUxkn9qHa2/kbUNEe6j6DiawO9NA6YXP8M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NdFktaHvF0kN2L4Xdws/dc03ZtqGYjwUT+KROIPTp9Pd7Q3WZTeNeiJhPg0+vW0StFiFmcrxhHTJg/vraB6GOqBbNUczcfzWkHZNe5BAoGSr3OG09x/deK5j57Cbp3etskI1q56ggpOgU5pnoZnmrSf7xGNLc0HF+w43b+L1FSU= 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=DjEmOsgf; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DjEmOsgf" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-53df67d6659so5775019e87.3; Mon, 02 Dec 2024 01:48:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132895; x=1733737695; 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=hM5eVSVR+00n+whOsRkT+8QJO3Bjd0wIvECNn8+Z9lk=; b=DjEmOsgfWRB7/P/VgzVuIB4ubw97JwkoryNnt7MSExOGyG7xAqPrzBI1L2h8GVUs2V tC/JsOUTHp5yTj/c3bc8Pr05/mcz3U0suugYYu7AmnJjQWtlVVY6exFwwpsw4OExpNd+ 5isMvJWLEH0gSANg1t+0elt8LgWmqmbVsAFzrfT6K+2EX8X4EMBZqR9wA7duk/Sr+YKa mm6Q5aZaNuFTq2GIpUE+h5KS1QcCBWsfcHv3ZiDV9Xs2yANiz5JLySmCRq4D4SOm3Wpm ex3eKXX5MZ3rR3P5J0ET6i1GgQFAl4JMJ9J4bDi0W4EiyBxNRxRTHQs9es6DmAC17C4Z qJkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132895; x=1733737695; 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=hM5eVSVR+00n+whOsRkT+8QJO3Bjd0wIvECNn8+Z9lk=; b=dkIWZ4A9gu67x98VQHV8pAVt1mlJqFtgMy7G1sV9NlpIf7GrRHL2IZJmQ1eC5CZWkX Z8Yy7o2GUxcTCF8O/pYawZc3/Tgd0/CJ+poGImZeHESbqmsOPjsU7ofKWCgqx2RRReMn LSVN9EkJcHcNlgN9CEeguwxwGhPXg30Ne0KNojZ8mIpJXlHDJfixUG4O/uimOa5XhskL bw2B3JbBI1Gbe6KJP0pG7Dv05UnlEjOEg8fU1QIsq0zidO8A8jRRhsGgPj2HsE2hQa43 Nd/ducTRBFw9lO8A70HtnuO357FNF8YHxb0B2zIzVHnAShwc4kndyCknDZ51IfQdRSKt hTBw== X-Forwarded-Encrypted: i=1; AJvYcCVFauKFpN8PkS4wIt4AzPBlCv10QcChWNgNq42mG8Y+GeEtYn7UG/iPJ+0CmQJUK2XQflfnuLWck6Qx@vger.kernel.org, AJvYcCVnVu1MwkwVJkPShVrVYMxFfD7CLB2R2IoUiG8aIMuaS3Ek7Vg9/UKwbJPmPJ2aGHZBlQsANTD/nNAGXkgj@vger.kernel.org, AJvYcCVrCyCAkId1zi34D2fqiUPKpt/RW7IgVpoQnOSCgnU58pe/ludwWYgKd5E3xw1WzCauRHP6R4AR00jUJMM=@vger.kernel.org, AJvYcCWeV4Sg7jwz7s7Vc44b/EqEJPKe2X6jjN02zNv4wZnNzl8VJXk4uI4oj/ykGQTNvcItiEC+q26tiuVoOQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyhwkQBL+2jJ2Whf5au96QSUpXrIQdZHuyt7mRHkI9WLRRe9ic5 HBIlH8QI3BVNf3i6eed5DFSldRs3JjzffzCMU15bJYDvfTacG94q X-Gm-Gg: ASbGncv826pnPx6i2CKjb/I2Qn1g/rW7qOTSj2ar2rNI0YwHTT92pBnmoihq3cCoA7v 0VZOJrCgujWu1gOl4jRXpdLyVbTe2xtxuNnQNX0D02Gh0wDKM5NU3kh31sHSpwTssfHaMzxYvkj FyUCh9yKrh4W1bRXKwhQCM1r9zLGMl3K9rRUP5UPOk05Yzd02ddZqLCFd4v0lubq/1fgmVFq5eK uQHMov4OJI+dnJYqeb6yv1jvPKxLEZsGGskl4vyuCscoSs6 X-Google-Smtp-Source: AGHT+IH6CInh7Fz0fDUQ6pCo7y7IbtVM2dSiA3+S/ZQFhYQESFCNncKKDBgQegtTOKad8DAgT9zCcg== X-Received: by 2002:a05:6512:3b06:b0:53d:ec46:342e with SMTP id 2adb3069b0e04-53df00a9738mr14376620e87.1.1733132894959; Mon, 02 Dec 2024 01:48:14 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:14 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:48:01 +0300 Subject: [PATCH v9 8/9] 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: <20241202-starqltechn_integration_upstream-v9-8-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=28066; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=kBOq8eZGtiUxkn9qHa2/kbUNEe6j6DiawO9NA6YXP8M=; b=8+0hEImukjj9UcD8BqxOZMAMFFPf8o9vUbdpVHg34+AqcTtDGB9sONjWxrWTwX01OPEM9ZGEc 0+ibZ44JvJbBkdj/n3DYTrbhkirxcxCq83ncN1kXtHSlZfAf5khmMo8 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add driver for Maxim 77705 switch-mode charger (part of max77705 MFD driver) providing power supply class information to userspace. The driver is configured through DTS (battery and system related settings). Signed-off-by: Dzmitry Sankouski --- Changes in 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 | 599 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_charger.h | 216 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 822 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..75092326825b --- /dev/null +++ b/drivers/power/supply/max77705_charger.c @@ -0,0 +1,599 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on max77650-charger.c + * + * Copyright (C) 2024 Dzmitry Sankouski + * + * Battery charger driver for MAXIM 77705 charger/power-supply. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_ADDR_CHG 0x69 + +static const char *max77705_charger_model = "max77705"; +static const char *max77705_charger_manufacturer = "Maxim Integrated"; + +static const struct regmap_config max77705_chg_regmap_config = { + .reg_base = MAX77705_CHG_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_CHG_REG_SAFEOUT_CTRL, +}; + +static enum power_supply_property max77705_charger_props[] = { + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CHARGE_TYPE, + POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, +}; + +static int max77705_chgin_irq(void *irq_drv_data) +{ + struct max77705_charger_data *charger = irq_drv_data; + + queue_work(charger->wqueue, &charger->chgin_work); + + return 0; +} + +static const struct regmap_irq max77705_charger_irqs[] = { + { .mask = MAX77705_BYP_IM, }, + { .mask = MAX77705_INP_LIMIT_IM, }, + { .mask = MAX77705_BATP_IM, }, + { .mask = MAX77705_BAT_IM, }, + { .mask = MAX77705_CHG_IM, }, + { .mask = MAX77705_WCIN_IM, }, + { .mask = MAX77705_CHGIN_IM, }, + { .mask = MAX77705_AICL_IM, }, +}; + +static struct regmap_irq_chip max77705_charger_irq_chip = { + .name = "max77705-charger", + .status_base = MAX77705_CHG_REG_INT, + .mask_base = MAX77705_CHG_REG_INT_MASK, + .handle_post_irq = max77705_chgin_irq, + .num_regs = 1, + .irqs = max77705_charger_irqs, + .num_irqs = ARRAY_SIZE(max77705_charger_irqs), +}; + +static int max77705_charger_enable(struct max77705_charger_data *chg) +{ + int rv; + + rv = regmap_update_bits(chg->regmap, MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_EN_MASK, MAX77705_CHG_EN_MASK); + if (rv) + dev_err(chg->dev, "unable to enable the charger: %d\n", rv); + + return rv; +} + +static void max77705_charger_disable(struct max77705_charger_data *chg) +{ + int rv; + + rv = regmap_update_bits(chg->regmap, + MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_EN_MASK, + MAX77705_CHG_DISABLE); + if (rv) + dev_err(chg->dev, "unable to disable the charger: %d\n", rv); +} + +static int max77705_get_online(struct regmap *regmap, int *val) +{ + unsigned int data; + int ret; + + ret = regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &data); + if (ret < 0) + return ret; + + *val = !!(data & MAX77705_CHGIN_OK); + + return 0; +} + +static int max77705_check_battery(struct max77705_charger_data *charger, int *val) +{ + unsigned int reg_data; + unsigned int reg_data2; + struct regmap *regmap = charger->regmap; + + + regmap_read(regmap, MAX77705_CHG_REG_INT_OK, ®_data); + + dev_dbg(charger->dev, "CHG_INT_OK(0x%x)\n", reg_data); + + regmap_read(regmap, + MAX77705_CHG_REG_DETAILS_00, ®_data2); + + dev_dbg(charger->dev, "CHG_DETAILS00(0x%x)\n", reg_data2); + + if ((reg_data & MAX77705_BATP_OK) || !(reg_data2 & MAX77705_BATP_DTLS)) + *val = true; + else + *val = false; + + return 0; +} + +static int max77705_get_charge_type(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + if (!MAX77705_CHARGER_CHG_CHARGING(reg_data)) { + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + reg_data &= MAX77705_CHG_DTLS; + + switch (reg_data) { + case 0x0: + case MAX77705_CHARGER_CONSTANT_CURRENT: + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + *val = POWER_SUPPLY_CHARGE_TYPE_FAST; + return 0; + default: + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + return 0; +} + +static int max77705_get_status(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + if (!MAX77705_CHARGER_CHG_CHARGING(reg_data)) { + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + reg_data &= MAX77705_CHG_DTLS; + + switch (reg_data) { + case 0x0: + case MAX77705_CHARGER_CONSTANT_CURRENT: + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + *val = POWER_SUPPLY_STATUS_CHARGING; + return 0; + case MAX77705_CHARGER_END_OF_CHARGE: + case MAX77705_CHARGER_DONE: + *val = POWER_SUPPLY_STATUS_FULL; + return 0; + /* those values hard coded as in vendor kernel, because of */ + /* failure to determine it's actual meaning. */ + case 0x05: + case 0x06: + case 0x07: + *val = POWER_SUPPLY_STATUS_NOT_CHARGING; + return 0; + case 0x08: + case 0xA: + case 0xB: + *val = POWER_SUPPLY_STATUS_DISCHARGING; + return 0; + default: + *val = POWER_SUPPLY_STATUS_UNKNOWN; + return 0; + } + + return 0; +} + +static int max77705_get_vbus_state(struct regmap *regmap, int *value) +{ + int ret; + unsigned int charge_dtls; + + ret = regmap_read(regmap, MAX77705_CHG_REG_DETAILS_00, &charge_dtls); + if (ret) + return ret; + + charge_dtls = ((charge_dtls & MAX77705_CHGIN_DTLS) >> + MAX77705_CHGIN_DTLS_SHIFT); + + switch (charge_dtls) { + case 0x00: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x01: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x02: + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + case 0x03: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + default: + return 0; + } + return 0; +} + +static int max77705_get_battery_health(struct max77705_charger_data *charger, + int *value) +{ + struct regmap *regmap = charger->regmap; + unsigned int bat_dtls; + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, &bat_dtls); + bat_dtls = ((bat_dtls & MAX77705_BAT_DTLS) >> MAX77705_BAT_DTLS_SHIFT); + + switch (bat_dtls) { + case MAX77705_BATTERY_NOBAT: + dev_dbg(charger->dev, "%s: No battery and the charger is suspended\n", + __func__); + *value = POWER_SUPPLY_HEALTH_NO_BATTERY; + break; + case MAX77705_BATTERY_PREQUALIFICATION: + dev_dbg(charger->dev, "%s: battery is okay but its voltage is low(~VPQLB)\n", + __func__); + break; + case MAX77705_BATTERY_DEAD: + dev_dbg(charger->dev, "%s: battery dead\n", __func__); + *value = POWER_SUPPLY_HEALTH_DEAD; + break; + case MAX77705_BATTERY_GOOD: + case MAX77705_BATTERY_LOWVOLTAGE: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + case MAX77705_BATTERY_OVERVOLTAGE: + dev_dbg(charger->dev, "%s: battery ovp\n", __func__); + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + default: + dev_dbg(charger->dev, "%s: battery unknown\n", __func__); + *value = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; + break; + } + + return 0; +} + +static int max77705_get_health(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + int ret, is_online = 0; + + ret = max77705_get_online(regmap, &is_online); + if (ret) + return ret; + if (is_online) { + ret = max77705_get_vbus_state(regmap, val); + if (ret || (*val != POWER_SUPPLY_HEALTH_GOOD)) + return ret; + } + return max77705_get_battery_health(charger, val); +} + +static int max77705_get_input_current(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data; + int get_current = 0; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, + MAX77705_CHG_REG_CNFG_09, ®_data); + + reg_data &= MAX77705_CHG_CHGIN_LIM_MASK; + + if (reg_data <= 3) + get_current = 100; + else if (reg_data >= MAX77705_CHG_CHGIN_LIM_MASK) + get_current = MAX77705_CURRENT_CHGIN_MAX; + else + get_current = (reg_data + 1) * 25; + + *val = get_current; + + return 0; +} + +static int max77705_get_charge_current(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data; + struct regmap *regmap = charger->regmap; + + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_02, ®_data); + reg_data &= MAX77705_CHG_CC; + + *val = reg_data <= 0x2 ? 100 : reg_data * 50; + + return 0; +} + +static int max77705_set_float_voltage(struct max77705_charger_data *charger, + int float_voltage) +{ + int float_voltage_mv; + unsigned int reg_data = 0; + struct regmap *regmap = charger->regmap; + + float_voltage_mv = float_voltage / 1000; + reg_data = float_voltage_mv <= 4000 ? 0x0 : + float_voltage_mv >= 4500 ? 0x23 : + (float_voltage_mv <= 4200) ? (float_voltage_mv - 4000) / 50 : + (((float_voltage_mv - 4200) / 10) + 0x04); + + return regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_04, + MAX77705_CHG_CV_PRM_MASK, + (reg_data << MAX77705_CHG_CV_PRM_SHIFT)); +} + +static int max77705_get_float_voltage(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data = 0; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, ®_data); + reg_data &= MAX77705_CHG_PRM_MASK; + *val = reg_data <= 0x04 ? reg_data * 50 + 4000 : + (reg_data - 4) * 10 + 4200; + + return 0; +} + +static int max77705_chg_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct max77705_charger_data *charger = power_supply_get_drvdata(psy); + struct regmap *regmap = charger->regmap; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + return max77705_get_online(regmap, &val->intval); + case POWER_SUPPLY_PROP_PRESENT: + return max77705_check_battery(charger, &val->intval); + case POWER_SUPPLY_PROP_STATUS: + return max77705_get_status(charger, &val->intval); + case POWER_SUPPLY_PROP_CHARGE_TYPE: + return max77705_get_charge_type(charger, &val->intval); + case POWER_SUPPLY_PROP_HEALTH: + return max77705_get_health(charger, &val->intval); + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + return max77705_get_input_current(charger, &val->intval); + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + return max77705_get_charge_current(charger, &val->intval); + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + return max77705_get_float_voltage(charger, &val->intval); + case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: + val->intval = charger->bat_info->voltage_max_design_uv; + break; + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = max77705_charger_model; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = max77705_charger_manufacturer; + break; + default: + return -EINVAL; + } + return 0; +} + +static const struct power_supply_desc max77705_charger_psy_desc = { + .name = "max77705-charger", + .type = POWER_SUPPLY_TYPE_USB, + .properties = max77705_charger_props, + .num_properties = ARRAY_SIZE(max77705_charger_props), + .get_property = max77705_chg_get_property, +}; + +static void max77705_chgin_isr_work(struct work_struct *work) +{ + struct max77705_charger_data *charger = + container_of(work, struct max77705_charger_data, chgin_work); + power_supply_changed(charger->psy_chg); +} + +static void max77705_charger_initialize(struct max77705_charger_data *chg) +{ + u8 reg_data; + struct power_supply_battery_info *info; + struct regmap *regmap = chg->regmap; + + if (power_supply_get_battery_info(chg->psy_chg, &info) < 0) + return; + + chg->bat_info = info; + + /* unlock charger setting protect */ + /* slowest LX slope */ + reg_data = MAX77705_CHGPROT_MASK | MAX77705_SLOWEST_LX_SLOPE; + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_06, reg_data, + reg_data); + + /* fast charge timer disable */ + /* restart threshold disable */ + /* pre-qual charge disable */ + reg_data = (MAX77705_FCHGTIME_DISABLE << MAX77705_FCHGTIME_SHIFT) | + (MAX77705_CHG_RSTRT_DISABLE << MAX77705_CHG_RSTRT_SHIFT) | + (MAX77705_CHG_PQEN_DISABLE << MAX77705_PQEN_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_01, + (MAX77705_FCHGTIME_MASK | + MAX77705_CHG_RSTRT_MASK | + MAX77705_PQEN_MASK), + reg_data); + + /* OTG off(UNO on), boost off */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + MAX77705_OTG_CTRL, 0); + + /* charge current 450mA(default) */ + /* otg current limit 900mA */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, + MAX77705_OTG_ILIM_MASK, + MAX77705_OTG_ILIM_900 << MAX77705_OTG_ILIM_SHIFT); + + /* BAT to SYS OCP 4.80A */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_05, + MAX77705_REG_B2SOVRC_MASK, + MAX77705_B2SOVRC_4_8A << MAX77705_REG_B2SOVRC_SHIFT); + /* top off current 150mA */ + /* top off timer 30min */ + reg_data = (MAX77705_TO_ITH_150MA << MAX77705_TO_ITH_SHIFT) | + (MAX77705_TO_TIME_30M << MAX77705_TO_TIME_SHIFT) | + (MAX77705_SYS_TRACK_DISABLE << MAX77705_SYS_TRACK_DIS_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_03, + (MAX77705_TO_ITH_MASK | + MAX77705_TO_TIME_MASK | + MAX77705_SYS_TRACK_DIS_MASK), reg_data); + + /* cv voltage 4.2V or 4.35V */ + /* MINVSYS 3.6V(default) */ + if (info->voltage_max_design_uv < 0) { + dev_warn(chg->dev, "missing battery:voltage-max-design-microvolt\n"); + max77705_set_float_voltage(chg, 4200000); + } else { + max77705_set_float_voltage(chg, info->voltage_max_design_uv); + } + + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, + MAX77705_VCHGIN_REG_MASK, MAX77705_VCHGIN_4_5); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, + MAX77705_WCIN_REG_MASK, MAX77705_WCIN_4_5); + + /* Watchdog timer */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + MAX77705_WDTEN_MASK, 0); + + /* Active Discharge Enable */ + regmap_update_bits(regmap, MAX77705_PMIC_REG_MAINCTRL1, 1, 1); + + /* VBYPSET=5.0V */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_11, MAX77705_VBYPSET_MASK, 0); + + /* Switching Frequency : 1.5MHz */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_08, MAX77705_REG_FSW_MASK, + (MAX77705_CHG_FSW_1_5MHz << MAX77705_REG_FSW_SHIFT)); + + /* Auto skip mode */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, MAX77705_REG_DISKIP_MASK, + (MAX77705_AUTO_SKIP << MAX77705_REG_DISKIP_SHIFT)); +} + +static int max77705_charger_probe(struct platform_device *pdev) +{ + struct power_supply_config pscfg = {}; + struct i2c_client *i2c_chg; + struct max77693_dev *max77705; + struct max77705_charger_data *chg; + struct device *dev, *parent; + struct regmap_irq_chip_data *irq_data; + int ret; + + dev = &pdev->dev; + parent = dev->parent; + max77705 = dev_get_drvdata(parent); + + chg = devm_kzalloc(dev, sizeof(*chg), GFP_KERNEL); + if (!chg) + return -ENOMEM; + + platform_set_drvdata(pdev, chg); + + i2c_chg = devm_i2c_new_dummy_device(dev, max77705->i2c->adapter, I2C_ADDR_CHG); + + if (IS_ERR(i2c_chg)) + return PTR_ERR(i2c_chg); + + chg->regmap = devm_regmap_init_i2c(i2c_chg, &max77705_chg_regmap_config); + + if (IS_ERR(chg->regmap)) + return PTR_ERR(chg->regmap); + + chg->dev = dev; + + ret = regmap_update_bits(chg->regmap, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHGIN_IM, 0); + + if (ret) + return ret; + + pscfg.of_node = dev->of_node; + pscfg.drv_data = chg; + + chg->psy_chg = devm_power_supply_register(dev, &max77705_charger_psy_desc, &pscfg); + if (IS_ERR(chg->psy_chg)) + return PTR_ERR(chg->psy_chg); + + max77705_charger_irq_chip.irq_drv_data = chg; + ret = devm_regmap_add_irq_chip(chg->dev, chg->regmap, max77705->irq, + IRQF_ONESHOT | IRQF_SHARED, 0, + &max77705_charger_irq_chip, + &irq_data); + if (ret) { + dev_err(dev, "failed to add irq chip: %d\n", ret); + return ret; + } + + chg->wqueue = create_singlethread_workqueue(dev_name(dev)); + if (IS_ERR(chg->wqueue)) { + dev_err(dev, "failed to create workqueue\n"); + return PTR_ERR(chg->wqueue); + } + INIT_WORK(&chg->chgin_work, max77705_chgin_isr_work); + + max77705_charger_initialize(chg); + + return max77705_charger_enable(chg); +} + +static void max77705_charger_remove(struct platform_device *pdev) +{ + struct max77705_charger_data *chg = platform_get_drvdata(pdev); + + 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 platform_driver max77705_charger_driver = { + .driver = { + .name = "max77705-charger", + .of_match_table = max77705_charger_of_match, + }, + .probe = max77705_charger_probe, + .remove = max77705_charger_remove, +}; +module_platform_driver(max77705_charger_driver); + +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_DESCRIPTION("Maxim MAX77705 charger driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/power/max77705_charger.h b/include/linux/power/max77705_charger.h new file mode 100644 index 000000000000..44ecd6b32cbe --- /dev/null +++ b/include/linux/power/max77705_charger.h @@ -0,0 +1,216 @@ +/* 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 + +/* Convert current in mA to corresponding CNFG09 value */ +inline u8 max77705_convert_ma_to_chgin_ilim_value(unsigned int cur) +{ + if (cur < MAX77705_CURRENT_STEP) + return 0; + if (cur < MAX77705_CURRENT_CHGIN_MAX) + return (cur / MAX77705_CURRENT_STEP) - 1; + else + return (MAX77705_CURRENT_CHGIN_MAX / MAX77705_CURRENT_STEP) - 1; +} + +/* Convert current in mA to corresponding CNFG10 value */ +inline u8 max77705_convert_ma_to_wcin_ilim_value(unsigned int cur) +{ + if (cur < MAX77705_CURRENT_STEP) + return 0; + if (cur < MAX77705_CURRENT_WCIN_MAX) + return (cur / MAX77705_CURRENT_STEP) - 1; + else + return (MAX77705_CURRENT_WCIN_MAX / MAX77705_CURRENT_STEP) - 1; +} + +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 2 09:48:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 846810 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 245021FDE1A; Mon, 2 Dec 2024 09:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132900; cv=none; b=lOaQ7PuO7kGPCestd4iu+m1UiIJGaG9nmduxdH9WgWhLtPBgQ+2FdT94uGzk0VZKBYAMxGyGNRo65RYP0YpBhghCZY6SFp6wRvoXVtVXS4/VcctDOEXuHtmCaLxLmqmUAJCI5sKr7wfyRiuw7ZvItKUzSuSSeVxGg4b4kAMSl5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733132900; c=relaxed/simple; bh=nNKdt6aAQ4O8gBwlr5BJKCp3j+YjqzXknQ+peKB2yLI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jp3nJaISAMrp5WxDVa75wwEB3FQm0NsL93KCtPcR42624cctiflqjxozYX+96BRvpff2yACn1J5qR+X97K/E5GywIWKjQOb1NMrqIeitvDdyMPfQ0jzAArwSUQIbh9GheouuqWQHa51cJTHz1YXCo0pHhfFkaEjBKCXM9CUmpx0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I7BCR6/J; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I7BCR6/J" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aa5366d3b47so658983666b.0; Mon, 02 Dec 2024 01:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733132896; x=1733737696; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7LBTuoCDOxxqO2y3YAKj2vln0gXaFFLFmx9hGGgry74=; b=I7BCR6/JorJiUQBCeQOLi9aerEJyRZPtO2yg74ByHkP/zrFkojUiBPjdO6VxdGZlyt Zv22/G392VPKV7knFn2f8Xkl7G4VpL4Lps/gJ7K2UGPQL8u4FxXEHcnjM1/fod7IAnie ijPV9+DynSMcK/UOi4c14LZcxncNhLW2djQrRkKkbnCIow5xW6yPPKcG8vJNxBbn/uG4 waxCEziGUc3Pyrj4nK/aVxY23VfIY6cg1Lgt1VwPQ1oiMCtCrFJqLgsCSaOkPuLO2ae7 a9oS4ryGs0rVMd+7GJzbJyDYSL/6pnMhqe0E7liCI/fq1bBwTD3qoY6I6K9KZCgEh8KI L9Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733132896; x=1733737696; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7LBTuoCDOxxqO2y3YAKj2vln0gXaFFLFmx9hGGgry74=; b=TxHTRn/TsrRYk6/wlodrYzobX6oFUFs/MupgfpSJ0keMHEKOgRF3eHkgLWCaeHruLX FqbHKp1WIPGCjTq1XLFRXRDdAFwFE7A14wckzaSiAfNXkRRTDB+v2ZI+M1A/jbwVZYyA 7hw6HO7Cy6dRcI+8Q0CCljwNGXvrIwJ3zhUqli3sswCGEuQGYFM/zU1RakCjrmXGWdHX eyoWI7G3Xlb5KYI09Perkh9/Nw4boOnRVFMlrI8iXe6sAHtrRH1WaiRV0jkRlgjNKDAe teoFjQ45n1xj7e35m7qiq6T665cPnZtT3/Nz/roN4tSBWjbm0vB27enMQT3ChOcl2SHU 6Zwg== X-Forwarded-Encrypted: i=1; AJvYcCUO+e8Fs5Ozk3u3DOp1u/jWti4bwQJ3XxDjXU7MqGCtdNGVgZi53nGGuM6RNwzKDIow8XVnyEpZ7CUB@vger.kernel.org, AJvYcCUmFSaICuR2uLg1jzFlCzIUep7T553g3bLTMo1ddGXRuJh2/ht5Y6SME2++vxE8sMLK5EtkWioBTAEzFw==@vger.kernel.org, AJvYcCUvmyMlYl9pf1+Gr95rxVcfouJCCZNcTcztw7+iRLz5nOz18BailVwstSBuLhfUQ1grOMf2gk+nEnmJXjgN@vger.kernel.org, AJvYcCXvZw5kseB8T6fkP88ktw05K+i4yZEF9ee+VQeBF8hN5gY/FF5jIy3CUvkQPW9OCBt+fdhEyY3VSyQ7+BU=@vger.kernel.org X-Gm-Message-State: AOJu0YzBkob99VrBUDWqNavejnHRn4u+hahEgqLySrXqbOhUlXaEs4Yn +dMVmCFMKCgn0iRM1ncUdDAani8GQPWbjBlmAo0n0NPJSOe0EwGrYraZMJGw X-Gm-Gg: ASbGncsaVI4fHIHL1qUlKdIfv1vbuUeViwUPwuqWXuCBygwblq1wnz4jG8TFlIkr6ce GJ1sqjDB4Kl6z0LPJmWkFaUQYYSgaERXERM2gWYHArq8R8/ddP3MZvx9OU2oIjyUdZrPll5lDzn D8Gnsu1m1EYv9+rl6c8mcCDYGzvoRsOxLuiMOhfNaBdW2ui06BSg11mmM/lXZfRMXLz79v4OW4H xfx1cQ3VrlHqzrmKCLg5wD1m+ErrMTjyiJB5UcwoHX8HfiX X-Google-Smtp-Source: AGHT+IHsaeJj8mT7GOA42WhtBau+dDuXWqOnDvfQuTAh9WNbaNkUzyrQhibpZTRFojC5RUS0VNNy/Q== X-Received: by 2002:a17:906:329b:b0:aa5:241a:dc75 with SMTP id a640c23a62f3a-aa58103b03amr2068889466b.41.1733132896299; Mon, 02 Dec 2024 01:48:16 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aa599957594sm487059766b.197.2024.12.02.01.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 01:48:15 -0800 (PST) From: Dzmitry Sankouski Date: Mon, 02 Dec 2024 12:48:02 +0300 Subject: [PATCH v9 9/9] leds: max77705: Add LEDs support Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241202-starqltechn_integration_upstream-v9-9-a1adc3bae2b8@gmail.com> References: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> In-Reply-To: <20241202-starqltechn_integration_upstream-v9-0-a1adc3bae2b8@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1733132883; l=9372; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=nNKdt6aAQ4O8gBwlr5BJKCp3j+YjqzXknQ+peKB2yLI=; b=lqOL710ADYdroNvivLFtJqxDW/B2k0YIEfUdTW1AoSgfn6y4OztdCSKy404OknY/71n9B739U SmwXihpZKFcDE83MuGFeiDdNsMETjse/ldrlO+TaBki7RoBzSq0Vn3i X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= This adds basic support for LEDs for the max77705 PMIC. Signed-off-by: Dzmitry Sankouski --- Changes for v8: - join line where possible to fit in 100 chars - change comment style C++ -> C Changes for v6: - change compatible suffix to 'rgb' - remove I2C dependency in Kconfig - remove copyright and author from 'based on' header statement - replace MFD abbreviation with PMIC - MAINTAINERS: alphabetic order - max77705_rgb_blink: replace ternary operators with if..else if sequence - max77705_rgb_blink: move hardcoded numbers to constants - max77705_led_brightness_set: move ret to the bottom - s/map/regmap - replace device_for_each_child_node with scoped version - s/rv/ret Changes for v5: - use same hardware name in Kconfig and module descriptions - remove copyrighter owner from module authors Changes in v4: - inline BLINK_(ON|OFF) macro - remove camel case - drop backwards compatibility(new driver) - drop module alias --- MAINTAINERS | 1 + drivers/leds/Kconfig | 6 ++++++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77705-private.h | 18 ++++++++++++++++ 5 files changed, 193 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index b269d0456da3..7a21e871ba7c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14188,6 +14188,7 @@ F: Documentation/devicetree/bindings/*/maxim,max77693.yaml F: Documentation/devicetree/bindings/*/maxim,max77705*.yaml F: Documentation/devicetree/bindings/*/maxim,max77843.yaml F: Documentation/devicetree/bindings/clock/maxim,max77686.txt +F: drivers/leds/leds-max77705.c F: drivers/*/*max77843.c F: drivers/*/max14577*.c F: drivers/*/max77686*.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index b784bb74a837..27ce55b32543 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -753,6 +753,12 @@ config LEDS_MAX77650 help LEDs driver for MAX77650 family of PMICs from Maxim Integrated. +config LEDS_MAX77705 + tristate "LED support for Maxim MAX77705 PMIC" + depends on MFD_MAX77705 && LEDS_CLASS + help + LED driver for MAX77705 PMIC from Maxim Integrated. + config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 18afbb5a23ee..096bf244527d 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_LEDS_LP8860) += leds-lp8860.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o +obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c new file mode 100644 index 000000000000..29db23702231 --- /dev/null +++ b/drivers/leds/leds-max77705.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on leds-max77650 driver + * + * LED driver for MAXIM 77705 PMIC. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include +#include + +#define MAX77705_LED_NUM_LEDS 4 +#define MAX77705_LED_EN_MASK GENMASK(1, 0) +#define MAX77705_LED_MAX_BRIGHTNESS 0xff + +struct max77705_led { + struct led_classdev cdev; + struct regmap *regmap; + unsigned int en_shift; + unsigned int reg_brightness; +}; + +static struct max77705_led *max77705_to_led(struct led_classdev *cdev) +{ + return container_of(cdev, struct max77705_led, cdev); +} + +static int max77705_rgb_blink(struct led_classdev *cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct max77705_led *led = max77705_to_led(cdev); + int value, on_value, off_value; + + if (*delay_on < MAX77705_RGB_DELAY_100_STEP) + on_value = 0; + else if (*delay_on < MAX77705_RGB_DELAY_100_STEP_LIM) + on_value = *delay_on / MAX77705_RGB_DELAY_100_STEP - 1; + else if (*delay_on < MAX77705_RGB_DELAY_250_STEP_LIM) + on_value = (*delay_on - MAX77705_RGB_DELAY_100_STEP_LIM) / + MAX77705_RGB_DELAY_250_STEP + + MAX77705_RGB_DELAY_100_STEP_COUNT; + else + on_value = 15; + + on_value <<= 4; + + if (*delay_off < 1) + off_value = 0; + else if (*delay_off < MAX77705_RGB_DELAY_500_STEP) + off_value = 1; + else if (*delay_off < MAX77705_RGB_DELAY_500_STEP_LIM) + off_value = *delay_off / MAX77705_RGB_DELAY_500_STEP; + else if (*delay_off < MAX77705_RGB_DELAY_1000_STEP_LIM) + off_value = (*delay_off - MAX77705_RGB_DELAY_1000_STEP_LIM) / + MAX77705_RGB_DELAY_1000_STEP + + MAX77705_RGB_DELAY_500_STEP_COUNT; + else if (*delay_off < MAX77705_RGB_DELAY_2000_STEP_LIM) + off_value = (*delay_off - MAX77705_RGB_DELAY_2000_STEP_LIM) / + MAX77705_RGB_DELAY_2000_STEP + + MAX77705_RGB_DELAY_1000_STEP_COUNT; + else + off_value = 15; + + value = on_value | off_value; + return regmap_write(led->regmap, MAX77705_RGBLED_REG_LEDBLNK, value); +} + +static int max77705_led_brightness_set(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct max77705_led *led = max77705_to_led(cdev); + unsigned long blink_default = 0; + int ret; + + if (brightness == LED_OFF) { + /* Flash OFF */ + ret = regmap_update_bits(led->regmap, + MAX77705_RGBLED_REG_LEDEN, + MAX77705_LED_EN_MASK << led->en_shift, 0); + max77705_rgb_blink(cdev, &blink_default, &blink_default); + } else { + /* Set current */ + ret = regmap_write(led->regmap, led->reg_brightness, brightness); + if (ret < 0) + return ret; + + ret = regmap_update_bits(led->regmap, + MAX77705_RGBLED_REG_LEDEN, LED_ON << led->en_shift, + MAX77705_LED_EN_MASK << led->en_shift); + } + + return ret; +} + +static int max77705_led_probe(struct platform_device *pdev) +{ + struct max77705_led *leds, *led; + struct device *dev = &pdev->dev; + struct regmap *regmap; + int ret, num_leds; + u32 reg; + + leds = devm_kcalloc(dev, sizeof(*leds), MAX77705_LED_NUM_LEDS, GFP_KERNEL); + if (!leds) + return -ENOMEM; + + regmap = dev_get_regmap(dev->parent, NULL); + if (!regmap) + return -ENODEV; + + num_leds = device_get_child_node_count(dev); + if (num_leds < 0 || num_leds > MAX77705_LED_NUM_LEDS) + return -ENODEV; + + device_for_each_child_node_scoped(dev, child) { + struct led_init_data init_data = {}; + + ret = fwnode_property_read_u32(child, "reg", ®); + if (ret || reg >= MAX77705_LED_NUM_LEDS) + ret = -EINVAL; + + led = &leds[reg]; + led->regmap = regmap; + led->reg_brightness = MAX77705_RGBLED_REG_LED0BRT + reg; + led->en_shift = MAX77705_RGBLED_EN_WIDTH * reg; + led->cdev.brightness_set_blocking = max77705_led_brightness_set; + led->cdev.blink_set = max77705_rgb_blink; + led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS; + + init_data.fwnode = child; + + ret = devm_led_classdev_register_ext(dev, &led->cdev, + &init_data); + if (ret) + return ret; + + ret = max77705_led_brightness_set(&led->cdev, LED_OFF); + if (ret) + return ret; + } + + return 0; +} + +static const struct of_device_id max77705_led_of_match[] = { + { .compatible = "maxim,max77705-rgb" }, + { } +}; +MODULE_DEVICE_TABLE(of, max77705_led_of_match); + +static struct platform_driver max77705_led_driver = { + .driver = { + .name = "max77705-led", + .of_match_table = max77705_led_of_match, + }, + .probe = max77705_led_probe, +}; +module_platform_driver(max77705_led_driver); + +MODULE_DESCRIPTION("Maxim MAX77705 LED driver"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h index be781a0f9802..2140693ce747 100644 --- a/include/linux/mfd/max77705-private.h +++ b/include/linux/mfd/max77705-private.h @@ -35,6 +35,24 @@ #define MAX77705_SYSTEM_IRQ_SYSOVLO_INT BIT(5) #define MAX77705_SYSTEM_IRQ_TSHDN_INT BIT(6) #define MAX77705_SYSTEM_IRQ_TM_INT BIT(7) +/* MAX77705_RGBLED_REG_LEDEN register */ +#define MAX77705_RGBLED_EN_WIDTH 2 +/* MAX77705_RGBLED_REG_LEDBLNK register */ +#define MAX77705_RGB_DELAY_100_STEP_LIM 500 +#define MAX77705_RGB_DELAY_100_STEP_COUNT 4 +#define MAX77705_RGB_DELAY_100_STEP 100 +#define MAX77705_RGB_DELAY_250_STEP_LIM 3250 +#define MAX77705_RGB_DELAY_250_STEP 250 +#define MAX77705_RGB_DELAY_500_STEP 500 +#define MAX77705_RGB_DELAY_500_STEP_COUNT 10 +#define MAX77705_RGB_DELAY_500_STEP_LIM 5000 +#define MAX77705_RGB_DELAY_1000_STEP_LIM 8000 +#define MAX77705_RGB_DELAY_1000_STEP_COUNT 13 +#define MAX77705_RGB_DELAY_1000_STEP 1000 +#define MAX77705_RGB_DELAY_2000_STEP 2000 +#define MAX77705_RGB_DELAY_2000_STEP_COUNT 13 +#define MAX77705_RGB_DELAY_2000_STEP_LIM 12000 + enum max77705_hw_rev { MAX77705_PASS1 = 1,