From patchwork Tue Dec 17 17:29: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: 13912270 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 406401448DC; Tue, 17 Dec 2024 17:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456639; cv=none; b=josSxOt7/Z1Vb7zJByJ+CTNp87ZfsUkCDGgp5eFmIvOTTNNF1+caJYTevnWIcYYrdTHwnfbkkuRcJnmZKsLqJsmtnGTiMjno7svpaDcy1l6yUIqMD7NMevBTXfhgAttisCvhMsjRbvwzIeckS4mi4JGDDRhNji3VGTGIXmtGllg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456639; c=relaxed/simple; bh=bo2DbfNN/XV8PtjOQRgHUQdty7u8Klx2lq7gG+DGLCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lPHkkKmaWYHNxBsd4FDmLsVAWSpQcAVUn0s41jAdfymYwMIJ3ZRsKoW3FKJ8M2WYyFfajaT/blegsAuf8elClnTyvF2/JSW684hSoUsuw42LlFMZTuT5u3WanVhID67AywWb84In48iSdyt2lkaO50znSKAvRyrWTobTwkLgcSY= 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=J2QWcNIZ; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J2QWcNIZ" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-aa66e4d1d5aso898568166b.2; Tue, 17 Dec 2024 09:30:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456635; x=1735061435; 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=bZy+ohxzeE+ar21picC9h4eYdaG+4qliNlci3KD4Vgw=; b=J2QWcNIZto7yvpBQrh6mKvrblVxLtmlC3JUhf5Y/Zt/KUbeQwJm2tujQOIvgusdpeH OxQtg6/ukf/qG0i0qAZDAbt8Kty4R5sgHtx5KI/RjBs7r2m8URM0HPZv/0EsUYauOBt8 SQlWvdZEx8cjc5Bl24O0YGoVqC5nN/N/wedkjlsO7JKYQFawBAfQUG/eqxRjc0Da7m8w G8kYqB8fURb99e+wh7ROZF9pgzB/BXqu79hpSje6BKD5fRJ4Lcw6CapYSg6HedEEybXP Tx3LE1WQqRwQ+WmtOYYXKYoSTX1SpRlCGF9W973gHZhIATRBNlIi5HWaLmLgyVwUzaLB 16ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456635; x=1735061435; 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=bZy+ohxzeE+ar21picC9h4eYdaG+4qliNlci3KD4Vgw=; b=oEgmersRMyTI7lzDsPzlqPgd4hqE6xOvXJsNqkABI3cOavWKGxTbN8HjLf8ciWGV/v CvqEoMSnLObzhN+/9kHVNgWHaDUGu5VFF8aUUnBWZhTZIZkabctHqyvc8zxxnbL5dFi/ JItvN+Ripv5hfeuvIloiVq4XxcyYG42nCoyyeWmgoz6Oe1ecpd8T/r92XmiiCykoPzop OjNxXJHaG4MkRRtDnt09BoCXCns+tBIauwRtsAcQ1aZPaGwyq3LmEFZ48q8XoL4bT8xs 9UWyrP2bPpj/TsaIGecym1LV11Aqc2XWarcvIm18gder2ahzn5hM4RDaVb4VfT2QsjHL oMgg== X-Forwarded-Encrypted: i=1; AJvYcCUHRfvTNJZFtvesd6p8zUj0q091P/W/1Ep/qdTNPQ3Aa08ib/r+mnHRfH9H4J9ROVfECV2pBPn83k4yv4Nu@vger.kernel.org, AJvYcCVZXm1jCRjxudfOKcpOCcELsnDbzi62icREKgkqj/e6ZDLvNxDUZhpQNoEJfeaVV0WO7rLIIycfCGrI@vger.kernel.org, AJvYcCVijTEppTC6POJ6pYtwgo++Q8TdSbse5+rrHHxaIS+8cAOLhSIaYLyzMRjLDD1El0iaY69v1BQVBOKsjQ==@vger.kernel.org, AJvYcCWTwtRJ8ZKgRGB3iUn3Re5s7aEin992Co+RRIEAcCEzlsUOhZ8LnCrM8PJV7kjI1eCsdam2EMerqQeUVWU=@vger.kernel.org X-Gm-Message-State: AOJu0YxzkqHBbMblzGhLMU9konJ/WEYDQlPlxHoxNqyrVOhcgAOQHgV5 dpMqmGRXsrKy/XmyngvDutFwPM0ae3KVhccHAWwkK93Kcwnw81hU X-Gm-Gg: ASbGncvOFtCvPkxczOHObaVMtHgt1qp6TnUVCnj253x8WgQGvJTJSKAh6WJtqTxLy8w jrxM93zZpgb4FrSHne1Ji2sqQJVIfa+1DWYjC2V63oF8OLpXF/GPCtu4z2AC9mtgkEObeJOSPkb zXUPzH/Yeyzo/Hnm3D97t+lyHZrn8Tce551zOzlVLL0M/yhzvH81o4OcpAYMy3Btfa/fANaqFgn lNqVOnQ/ekL+UWlXfNiTgPOPBrquovtCVT2FTnwdYxEcametDNy0IM= X-Google-Smtp-Source: AGHT+IGMkuBncT8lElD9P3YrJ70TME9c3m4qa9hU2ssUTgbon80nWBjZySY6aCea1aCoalXp5XwBJw== X-Received: by 2002:a17:907:94c9:b0:aa6:8186:5cab with SMTP id a640c23a62f3a-aab77eb0050mr1580211466b.54.1734456635427; Tue, 17 Dec 2024 09:30:35 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:35 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:29:59 +0300 Subject: [PATCH v12 01/11] power: supply: add undervoltage health status property Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-1-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=2343; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=bo2DbfNN/XV8PtjOQRgHUQdty7u8Klx2lq7gG+DGLCE=; b=QJ+YAFJnHGGHjUI5m+u3aYVTvUx4EpohYZTIjiT5zMWnkzwvXD0fDJzHx/ldz47xhTeNyPZfk TY3hM+3jZSTCFFmJ2msPA3ID1wY3oRYO2Si8WozV8+v27RjZ9HdyWpU 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 74050dfb5fc0..546e36802ff7 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -453,7 +453,7 @@ Description: Valid values: "Unknown", "Good", "Overheat", "Dead", - "Over voltage", "Unspecified failure", "Cold", + "Over voltage", "Under voltage", "Unspecified failure", "Cold", "Watchdog timer expire", "Safety timer expire", "Over current", "Calibration required", "Warm", "Cool", "Hot", "No battery" diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index e18f1ee53f21..f440c8a54aaf 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 0d96657d1a2b..bb3c33de45c8 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 Tue Dec 17 17:30: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: 13912271 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 B89BE1F8696; Tue, 17 Dec 2024 17:30:38 +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=1734456640; cv=none; b=S4WDVK/QlHC1CHAJjl6DUjp3rP7mdyKAmRuD1ot2gH2fWFFcunpTE6rNAAOLbLkzoNaAmlqUfkvaIDdGTRtXwiK9njm0BQx1ub8dLNkNraaIoZFYzW4lpOnGVQGku439QVpteYLTLxrrOz8abvBEvGuvGerSjPMWqSfc2r+rBdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456640; c=relaxed/simple; bh=Ysdm0MPXNFcWymQ1oyL7kJl3xM+8vynFf2bNEkduhGY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TNQNjhW24mxy4sG3uPn4Tj8y0M2dIZRhVq5KiZB4KW9BbS3OQ2YVvDcgkF65SNXXIoYAPyCys79bcCA/vkNnV7oK4+3Y/c88BNM6NEobbeDRbYrWYzhC+5iNxc2Nl48iNdG2xsjWg6tNH1LqKg4sTaKq9CHB5ZFDAg25hRTYrLQ= 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=AXsAMxZv; 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="AXsAMxZv" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aa69107179cso1034747366b.0; Tue, 17 Dec 2024 09:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456637; x=1735061437; 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=Cz+dnEpOOSJD4rTGFvNS16veou5VGvcPUuKa01+C17g=; b=AXsAMxZv1P/DfilUZTqGPNTX8DVnpVrlN28hhYHFJsoVc/UeMVmPtr8O5qcNwwLohJ XnyCCLa1xBgts9CC5XSO9p8APkgmVukh6TepcrdLqJ+zH4/R656Sm2BcJnnayVeMQ7km H76luKodFa1yd+vCHqNq8FZb2Zvbpi2ypMvtRRfbuu+xm17UjbM6vXotHDQCWkUMMHeD +J4XHI4dS+4nLdkZpQ1Ol2mutBP6cE8d+j7raou9hPX03U/GL2SPjAJuWtDzCAKaaupQ inRICrWpldwFkksZtp58/QdG2uVL3IfvI+dwV00qlZdb4e/JBM0zATOOZd6iyUDzqL9Y zDPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456637; x=1735061437; 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=Cz+dnEpOOSJD4rTGFvNS16veou5VGvcPUuKa01+C17g=; b=bcbMHqIcNXv6MTUsl8+l9+aCtyLLNdTaGCdOTuwSRtbrAOGd6+bqMIEdg1J/CcvUD8 /tTZJcdu/kLHDvqvVeUwtG2g4v0Nf492FDZy46i3WomUrMe7uYv9d8GigmCHaL7P5dFm 1CCA+Mk8kA7MPY2giFhJzXtBwnW7XqH6atRhd6s21ytz4WOHX9vg9/OSOcuxVTOvS05X farbCSxixM8ZuI7rXhwJ96sHeoY7Dq4/WQ7FQmiOIDCjXl52d00hnW21IU/XsBqDKPGJ /IjW0Kl+lNyBQbzh00ITmnWi9V9LyUrQVoediQpUuGKK57kazb014vQPWy2gLSU5buLf f7XA== X-Forwarded-Encrypted: i=1; AJvYcCV9yXs9UHqzxCbOfbHWmj4nQC477K2GjoXeU4wX9hwEHr76c6QFHOt7UuvAx7Fe4q1HvUCv0kqwlbOrVxLW@vger.kernel.org, AJvYcCVQOEM4Bnim0f+CyWdDHlwEiD5ZNis2M+UWKTVZwPa7HWq+GqrnjoKJiR3N5NKTCxYRKxPAdEXH/3bS@vger.kernel.org, AJvYcCVbaDsm6KBQJ/4ACFqOWL4ujkeYIE6dpmreducD5rkTveVbHFzX69k4+hSVWRTmOpx+xiQoDfBfQMS927w=@vger.kernel.org, AJvYcCWO5UC+XLkG7jurjWR8BUkIUj40ryz/BTI8Zss8swZAwD80k6B8HsSM7YnCoJ9/Alu0ra1IcbSpHpi27Q==@vger.kernel.org X-Gm-Message-State: AOJu0YwjcrFsuvz2Q9Q3Fs1XU0ZD8a6CgPmOnw7Zfdnx0Dz6B2TzfDZf HHVC03+Ecf4FJ1wqKfrma149e5Gur/A/JWphwG6NIEvoOnChd47j X-Gm-Gg: ASbGncvN1O1G472VpKkXjUM70Eeb8kW4+JkrA2ERlip7xrMwEa8v3KpLCwfh3ge6ZvK 3R35Ru5Edmd4UHy0iJELoH6UlWrT2Q8gBArX5v223+MPcqS9ApeJZmH1iD14q3iRPWymz9t9jYe W234c6Pza0j/qzpVwu1UjGoEIqAFFdXLIpVjPLLz4uf9reVaBXsVWy7QU5XtrzmBukBX30SpPpm 56PbOd7YmiSX8fiGzD4thpwTWTJuDS71gbpyPN1X5UTdElYFrzK6+M= X-Google-Smtp-Source: AGHT+IGwmz9YnrEkFF8KJaxjIXYmB5yyVIVxDSOSbE4ZkDUdZr0/8ybnU98EgeGum7+g1K9/fJchlg== X-Received: by 2002:a17:907:7290:b0:aa6:a7cb:4b9e with SMTP id a640c23a62f3a-aab778d9d91mr2038215266b.1.1734456636690; Tue, 17 Dec 2024 09:30:36 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:36 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:00 +0300 Subject: [PATCH v12 02/11] dt-bindings: power: supply: max17042: split on 2 files Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-2-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=5442; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=Ysdm0MPXNFcWymQ1oyL7kJl3xM+8vynFf2bNEkduhGY=; b=HNp31paxlevWLqOZGpyGyV9rCN9EiCyf9tWLkAlifleRTF3H4WY3mjsOzqRQ/Hw3wM7p1m3Wk iRt2P46qoemDnnf2ObbY/dcU+5mUmvMtXaPOidlTH+opOG43+jJb0U9 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Move max17042 common binding part to separate file, to reuse it for MFDs with platform driver version. Signed-off-by: Dzmitry Sankouski Changes on v12: - add addtionalProperties: true on common file - rename *-base file to *-common - remove compatibles from shared shema - move required properties to final schema - remove max77705 compatible from binding - it will be used in mfd77705 binding --- Documentation/devicetree/bindings/power/supply/maxim,max17042-common.yaml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml | 43 +++---------------------------------------- MAINTAINERS | 2 +- 3 files changed, 58 insertions(+), 41 deletions(-) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042-common.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042-common.yaml new file mode 100644 index 000000000000..67e673ca7970 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042-common.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/maxim,max17042-common.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim 17042 fuel gauge series + +maintainers: + - Sebastian Reichel + +allOf: + - $ref: power-supply.yaml# + +properties: + interrupts: + maxItems: 1 + description: | + The ALRT pin, an open-drain interrupt. + + maxim,rsns-microohm: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000). + Defining this property enables current-sense functionality. + + maxim,cold-temp: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Temperature threshold to report battery as cold (in tenths of degree Celsius). + Default is not to report cold events. + + maxim,over-heat-temp: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Temperature threshold to report battery as over heated (in tenths of degree Celsius). + Default is not to report over heating events. + + maxim,dead-volt: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Voltage threshold to report battery as dead (in mV). + Default is not to report dead battery events. + + maxim,over-volt: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Voltage threshold to report battery as over voltage (in mV). + Default is not to report over-voltage events. + + power-supplies: true + +additionalProperties: true + diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml index 085e2504d0dc..0832aa5f5eb0 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml @@ -10,7 +10,7 @@ maintainers: - Sebastian Reichel allOf: - - $ref: power-supply.yaml# + - $ref: maxim,max17042-common.yaml# properties: compatible: @@ -24,48 +24,11 @@ properties: reg: maxItems: 1 - interrupts: - maxItems: 1 - description: | - The ALRT pin, an open-drain interrupt. - - maxim,rsns-microohm: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Resistance of rsns resistor in micro Ohms (datasheet-recommended value is 10000). - Defining this property enables current-sense functionality. - - maxim,cold-temp: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Temperature threshold to report battery as cold (in tenths of degree Celsius). - Default is not to report cold events. - - maxim,over-heat-temp: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Temperature threshold to report battery as over heated (in tenths of degree Celsius). - Default is not to report over heating events. - - maxim,dead-volt: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Voltage threshold to report battery as dead (in mV). - Default is not to report dead battery events. - - maxim,over-volt: - $ref: /schemas/types.yaml#/definitions/uint32 - description: | - Voltage threshold to report battery as over voltage (in mV). - Default is not to report over-voltage events. - - power-supplies: true - required: - - compatible - reg + - compatible -additionalProperties: false +unevaluatedProperties: false examples: - | diff --git a/MAINTAINERS b/MAINTAINERS index 81348dbce8ca..0816fe0f3c80 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14164,7 +14164,7 @@ R: Sebastian Krzyszkowiak R: Purism Kernel Team L: linux-pm@vger.kernel.org S: Maintained -F: Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml +F: Documentation/devicetree/bindings/power/supply/maxim,max17042*.yaml F: drivers/power/supply/max17042_battery.c MAXIM MAX20086 CAMERA POWER PROTECTOR DRIVER From patchwork Tue Dec 17 17:30: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: 13912272 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 038031F8933; Tue, 17 Dec 2024 17:30:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456641; cv=none; b=RFDMTPHcohTsgQ4vQW9I7+zNLPsXwHAt2aphLNTs0R71MNWt0KTdJdcBLA7kqeiwbZlAdzfgR2hIWy8vXKLXirxlDvGPQmR76j4u8Kmg7M9Mkuq5hNdf2f+k77xugk8qprxT0ECVJu+3M683Ipbj+o8yyAx+T54tI30AVtqiB6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456641; c=relaxed/simple; bh=W3R0sAEsh89KI9k2TtMER4sOCc8bejuu1Gu7C+v3ml0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cLYiUywwhRzW8B8iRtwnxgeA5RS6ewHTKpY6A9MaZxRHO4fyzvCewXnS6iY+p/tDg4ff1mWM1xr4k+Cf5+mxVXf7r1+EHcwj6cwBI2GYXLQkX4D6xplKA3ofOew5dQuQJcw3Ko0CNRZTLfE5vo99rdsLaD/TpX3BoyfyJXzVIyg= 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=fPewXTM3; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fPewXTM3" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-aa67f31a858so1027969566b.2; Tue, 17 Dec 2024 09:30:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456638; x=1735061438; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LyNrH/v1nn6Cpsrp8y8ejskaGapYhbwc7aBDhXiWAeU=; b=fPewXTM3bWZciTUnFPeI1RBiaEqUdYupV0tIAA7WmNKQcO3A+AsYMiZl9Uo/sa8dT4 gwQK+i0LqlVHSMTpBTVLAyVBuj6wr5olfLsMsIi6Y5fxIpjundAXY2a3HULO3yQWxuKi gIY86bd1reH8gyaAvvcLlNbAXkRNWSt3HkZiqXWgWAMmNnyYPejLZB+8OysMHhuIP2ik 8kUWPItOXYvYDWFpx85TOZhXzETTdCX53msmaC6VO4BMj2LPxH0GCIUcwaaBiZN31Gru aGFdEUJ5w+7jpd6VVptvW70qAbff8GgHc3ohZ/401OwSR/Lsi7bjhp+mNL3TjxdShw6d i60g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456638; x=1735061438; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LyNrH/v1nn6Cpsrp8y8ejskaGapYhbwc7aBDhXiWAeU=; b=gwijbkq7zHjAsA6DnHircDhSXVCCeJ1UIgx87x6bdU7q5xlYLAWcgSprK2yK0NA2+M Xox4wSHjETaQwv5Ot+gUSiXiXRI9pIk1zT2ab8O/WoGczIm61jbYaJNYn33n8eoS8547 rFx+AkrvmAjQZsDSoWgGnhV0YemPxuTaA/IsjemcD3LCKuqh9qO9u3L1yWKfJ7t8H5vN ZXDFt4YBVWrnjflITBJDWcC9l4kc2KayDC5tlCKRHS7QRm1sUeF54U8+dQQQwl9Qct/V 16TVtA/RqGelehJWckijMBWzQ63YkJgkATqN80daeohiuryCegg1di+35ZhAJKQLkFCl iN+Q== X-Forwarded-Encrypted: i=1; AJvYcCUV5pI9qV/5yhVKxdCH8gthAA1mhcn599M18EciVIRxbyj5MP0Wgtp4/AZdyHs90nODxuYTERoujBXCFQUa@vger.kernel.org, AJvYcCUXawXKTqSkCUzbOjTMVQn0PBm0Jfyme+BTu6M6t7yD7lrNjjUOk28mch2d8HJQg1L8cbHwHHEJLlTG2RY=@vger.kernel.org, AJvYcCXaDe4nnq67KE3Wj6G1198Ct6lPH2t7i3/3bIdgQLaKPmLO5qEOKkPahv+VHTtECIWtmcqLUYDDiD8H@vger.kernel.org, AJvYcCXdqt6aYCk1zUq4YZ89n1ley+DbRBfNryLapzO0psTwl5vEjKhLUhtZfRi+xPtnGh/pTbeL0jJCPkpMzw==@vger.kernel.org X-Gm-Message-State: AOJu0YxSDb/jkng9n6YKZHj3SnTiPQG3mSZXaVA7/Yz6nooJiuFBxkcR Y3Hst1oropONztzaaYaYKy5vcJ6llvkw33dIDfftbs9D64sGESB3 X-Gm-Gg: ASbGncu5ywXR4tpbkbDGJqsXTQpUD6hMYwdo8oUeCAyVPQKMDAh4UVW/zMcEhOIKhLy yTaxQ8MNUrgy5Sy4yppXNGltt5kXbKhiMgWKhBIx9n0jdfdlZfKM2viceIUU0XpYEzFo0863iVK KD/Ihf84hGqAi2S2xnF86/OETYbdcRhLiPfmYkVsjm5TWxj7hO708BYXDPu3i10wOO/hV2WC9cT p1M6BT0sZ7T/pxm8rIF2X9A7u3YEYcInL6QAIMg74RBun4FrA6Ohyo= X-Google-Smtp-Source: AGHT+IEX5DsX3uuQNAGWOJWqSwoA/U/+l9Wt+lhs4egjIHxsEhiy2iP8f53/VTVpKThB/vwSVrgqfQ== X-Received: by 2002:a17:907:7809:b0:aa6:6a52:974 with SMTP id a640c23a62f3a-aab779cead3mr1427429766b.35.1734456637970; Tue, 17 Dec 2024 09:30:37 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:37 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:01 +0300 Subject: [PATCH v12 03/11] dt-bindings: power: supply: add maxim,max77705 charger Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-3-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=1700; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=W3R0sAEsh89KI9k2TtMER4sOCc8bejuu1Gu7C+v3ml0=; b=SM5St0LyO+ja3lX8zb58WPKKdXoze8dzgIQ3PU9IyvnkWFBb5NgDdhQKwOMrcj9Xf4feleha3 uAmxJFpfB0IDidFXRkR2gTFRy7zCP3thrB8kFgRIksQvR1Jz+00PWJT X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 charger binding. Signed-off-by: Dzmitry Sankouski --- Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml new file mode 100644 index 000000000000..e42dbd48d838 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77705.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX777705 charger + +maintainers: + - Dzmitry Sankouski + +description: | + This is a device tree bindings for charger found in Maxim MAX77705 chip. + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + const: maxim,max77705-charger + + interrupts: + maxItems: 1 + + reg: + maxItems: 1 + +required: + - reg + - compatible + - monitored-battery + +unevaluatedProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@69 { + compatible = "maxim,max77705-charger"; + reg = <0x69>; + monitored-battery = <&battery>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + }; + }; From patchwork Tue Dec 17 17:30: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: 13912273 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DA081F8ADF; Tue, 17 Dec 2024 17:30:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456643; cv=none; b=TUiHlU6hEB5mqnLQdyXeI2gxZr5dwF+Dj3f4aDAHk+PZI4Jpap+wo2m7JJHhw2/iFonhdbyzKYt7VJesbjAMdXfgj3tCLVfsATyH5bywKUgfDnWRlIYHfOl2zuw+UVMrXz3RQL309/r1OB83esVynBHWEtZ1jtU1j2jaT4MzdIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456643; c=relaxed/simple; bh=m/prkZca79DAlfiiiu1BVx+1KofCiOIkNU49AA2iruk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H7yrWY95LDrWk3x/5HqspWFVH4ew4Soizi/+nta91UdDJeYIWolf2sQ3WNpknBqzfNMN6KaDjQ7scj/igdgUv42oObulcmWsc75BJ/lkp1ts2jwl5Odsw7qSkbXGiFBsHzs0pDLCNCEOcPxsyjtpnJtPLwpxXNaVAg0b6L7lcB0= 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=fdeRJR5h; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fdeRJR5h" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-aab6fa3e20eso795986566b.2; Tue, 17 Dec 2024 09:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456640; x=1735061440; 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=vZuCH1LtCnuis9NiU0vyHp/qhWwCsXWkEnPZSwSkxTA=; b=fdeRJR5hi+0bMgrh7ecuhKPXQyp9e13wFYciFUBLJV30FbGaQpd5fMhUOFhbqxuNAe 1vfORLUN1Czub53rXCyrWeWoQXgqaQIBfENtsL1MkJOIHLPblMFf2184Idru4bc2UyOt 1vJsN4FafeYuXMbp043ndA9pO2se3CP8ELgeMnTCmgZkIlRunPvQkHUP9JJpFJywuWq0 SXNObQV++9V26SShyN3Ca6JWyNgBEJ5eSsNQ1S9Rrv7zTbRUe9KGYxn5Ky5Pu5fGPYHY jkFqr0LR5uegCw1wrplxp8cCMLMN48xKzQN5LVi0Zr2K6QxvhmMxAZ0bnOV2+VxirfEB h1Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456640; x=1735061440; 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=vZuCH1LtCnuis9NiU0vyHp/qhWwCsXWkEnPZSwSkxTA=; b=RWlv0WqXCqMJIJ2MXGvPePmMqOK+V08IcGh1ixyaZtEkUOX3NC2oO5ivh7r8hji4Yd dM39/ghPfM2cE0LbuQsxLrkh60lsi0UlfK88Ifu269YLMi12OtUdiwtRP0aeH2kMDLDy gFHPRcFxSINK2VZh/yXeb695eGhCMOOfcw3k0AtZcF+3JheAKHNTyViqn/qxufNYB+aX jHqFr3fEsU2C+JFlWdweqWEvxe5hyGm+czWK4Kdfc+Vy4s9TRzSPMUwMw4q5cZwwkGOX jEdTcU411+ZFy1nupgVTOBMrw8P972Vkj+O+1kV6gWO0S8madtRepRCWdNZGqqgijCIq l+aQ== X-Forwarded-Encrypted: i=1; AJvYcCUYf3j1PkzfmTbl2g3SlmBSW4UiO5gSi9osI11d0pUevAC0LvMMiefbDZAB2E3qK9f66kWzSLZemJB+Jw==@vger.kernel.org, AJvYcCW/Ae0tZXu6M6D8PHr8ZSpJR+icP51uEbTzQTHM0cOX94Ka/aBixcT9Jg75paPksP4wH7izXds1w2tg@vger.kernel.org, AJvYcCWfRHugH8JaCQ5gSc44ILEnz6X0fQ6bOziJHWSvhElA/FJC/Iu0FtguTFQsiU+jyZLz5jmxGC9DhDPZsa2n@vger.kernel.org, AJvYcCXXsUUV10MD6v9OonPAIwl5TdkdHAkaHckkGteZFzStmTn39zOVMX/YIG5d0mBW7zteioGEkkmVYVXp2XE=@vger.kernel.org X-Gm-Message-State: AOJu0YxdgXMu7kS4Psk9UA5tT5si4kMTNkwyNHcsX+SkYVXA99fZyu5M Od6YW9zeTxJfX6UGAdhLaEXlVLoX60QsmBtHc8FcfBdrklw3DCRf X-Gm-Gg: ASbGncvRqO6sAP+JLUsLgXW61N5PLciQFpGzo4qeUUJK0nVJqxieQsA0LY7w/sKMa/V bt9swSh76wHGcIsQWr/xS/1pzejCGQ3Xa8U958oqAtspLbCAE8S0LqU/SJVqZtOLdMLqJXnOgm9 zSeCUZIexl6gI+MzXf4PjgB0U4ScweX3RqHcDPXoNjryNjAGYoPta72yFlb9/K++0+5d4oT6c/A Qr3wvLpgj5b6fCUn8Ma/pvRL+TlH1thKwSwIlKpcm0SeALvGFafms4= X-Google-Smtp-Source: AGHT+IFbl1t6QkoO2tti1kssbTrzYKE4NxkeremULCMcMWnAIQQfH3roCqYU8OtSTTYLiNccjJgh4w== X-Received: by 2002:a17:907:1c0b:b0:aa6:7c36:3423 with SMTP id a640c23a62f3a-aab778bf059mr1355828366b.1.1734456639330; Tue, 17 Dec 2024 09:30:39 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:39 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:02 +0300 Subject: [PATCH v12 04/11] dt-bindings: mfd: add maxim,max77705 core Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-4-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=6563; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=m/prkZca79DAlfiiiu1BVx+1KofCiOIkNU49AA2iruk=; b=vMVMTIUoA2A2hyCzw5De4IiuHs7+/OARq0jHwyt58g9WargsGCuAcJhmn1m8LAru4/LXhFkIF bT+t72wVmXEBkenRciWnWDaQqkaz78qOaNmUDP/9o/DzWAuXNQ1VXn/ X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 binding part, containing leds controller and haptics. Signed-off-by: Dzmitry Sankouski --- Changes in v12: - move fuelgauge bindings to separate patch because separate device - move charger bindings to separate patch because separate device - description: mention this is a part Changes in v11: - remove reviewed tags because of major changes - none of children are supposed to have addresses, all nodes are unit-less Changes in v10: - leds: replace label with color and function properties - leds: add support for leds-class-multicolor - move fuelgauge node to patternProperties "^fuel-gauge@[0-9a-f]+$" to comply with max17042 binding Changes in v9: - replace max77705 fuel gauge with max17042 - remove monitored battery because not supported by max17042 Changes in v8: - fix leds compatible Changes in v6: - unevaluatedProperties must be false - drop excessive sentence from description, just describe the device - change leds compatible to maxim,max77705-rgb Changes in v5: - formatting changes - add unevaluatedProperties: false for nodes referencing common schemas - remove additionalProperties on nodes with unevaluatedProperties: false - add min and max to led index Changes in v4: - change dts example intendation from tabs to spaces - remove interrupt-names property - remove obvious reg description - split long(>80) lines --- Documentation/devicetree/bindings/mfd/maxim,max77705.yaml | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 167 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml new file mode 100644 index 000000000000..c1db861a2d38 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml @@ -0,0 +1,166 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77705.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management and USB Type-C interface + +maintainers: + - Dzmitry Sankouski + +description: | + This is a part of device tree bindings for Maxim MAX77705. + + Maxim MAX77705 is a Companion Power Management and Type-C + interface IC which includes charger, fuelgauge, LED, haptic motor driver and + Type-C management. + +properties: + compatible: + const: maxim,max77705 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + haptic: + type: object + additionalProperties: false + + properties: + compatible: + const: maxim,max77705-haptic + + haptic-supply: true + + pwms: + maxItems: 1 + + required: + - compatible + - haptic-supply + - pwms + + leds: + type: object + additionalProperties: false + description: + Up to 4 LED channels supported. + + patternProperties: + "^led@[0-3]$": + type: object + $ref: /schemas/leds/common.yaml# + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + required: + - reg + + properties: + compatible: + const: maxim,max77705-rgb + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + multi-led: + type: object + $ref: /schemas/leds/leds-class-multicolor.yaml# + unevaluatedProperties: false + + properties: + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^led@[0-3]$": + type: object + $ref: /schemas/leds/common.yaml# + unevaluatedProperties: false + + properties: + reg: + maxItems: 1 + + required: + - reg + + required: + - compatible + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@66 { + compatible = "maxim,max77705"; + reg = <0x66>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + pinctrl-0 = <&chg_int_default>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + + leds { + compatible = "maxim,max77705-rgb"; + + multi-led { + color = ; + function = LED_FUNCTION_STATUS; + #address-cells = <1>; + #size-cells = <0>; + + led@1 { + reg = <1>; + color = ; + }; + + led@2 { + reg = <2>; + color = ; + }; + + led@3 { + reg = <3>; + color = ; + }; + }; + }; + + haptic { + compatible = "maxim,max77705-haptic"; + haptic-supply = <&vib_regulator>; + pwms = <&vib_pwm 0 50000>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 0816fe0f3c80..75e4e122bb44 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14234,6 +14234,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 Tue Dec 17 17:30:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13912274 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 731381F8F01; Tue, 17 Dec 2024 17:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456644; cv=none; b=oGleuuo70ZGHHkz4XRH/EvGHjor3bYYiEr2DVL5GktPmCNCVINu6JuOvvtcYL+B5TC4/8lIai9zd68TDQMhFiblhrPVjmZL/sndAOMvgsCvN+5hJtUtYq0Ej+tPJiNkDSM8DUSv6f0IVWvckzOyL4/YgrkXv+dFv8HZoPGZqlWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456644; c=relaxed/simple; bh=HLrHYIHXMkyG4Fwgr6WuFYzxC5tdGkSvazBo4iDni8I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EhpDfi/bxR+4heHoz7ivft/Y2HwuowrojZMqcW++lHSh4svOT9VGtcz/TO/SHEkmwzhATwwA+BMp+k5Db1y3KVTuGIBWNxj36q51GB9iSkVRoLTQAspn2rdPCxFOGtEpECZND8XCaKKYgVrQtE2AnKOXjo4g2j2y39oKfC89S/0= 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=nL/OO8Vn; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nL/OO8Vn" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-aa696d3901bso1073576566b.1; Tue, 17 Dec 2024 09:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456641; x=1735061441; 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=3AnNgcY5ekZdw7uqYzFEU9H2mYEP8P6/02tOjay8D1Q=; b=nL/OO8VnMaK+p3QrNGAXkPo7IU9du3CjY8fouVL3262BDBgspRNzJmuOX7rk+LbeGX koXRWyi3fjNKGpYcKkBwFof8h3EuHwvgIJofCjwXcz7gy+yhZUUsWCiAe3pVZ1JWcAhN bXH/9/XhuLdPzk90JbOH1oR72Up+wkdHEOjiEd0uckxdpTrKgIDWlM95p9e9OueiKnO+ pdDNlSGPTtGXfdg/YLBHI62wnhjRJ1uzYCNjvR61fSGtLvjTR2BOAdXgkgR6Ok6C4fD2 v2Hwjt7rwwzFT+Ffpy8Rhq4GKjWFBEK/A4H475ozmMTvNdpq+GKGIPB9d05Sy3WJMpuu noNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456641; x=1735061441; 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=3AnNgcY5ekZdw7uqYzFEU9H2mYEP8P6/02tOjay8D1Q=; b=kqIapH3rC8z8KMog6UsIdlRu/g1iM20N7I7n/JMRoYU7MzA8mZPBnDCYop49gp+1dq BJ6Dn/AuJ+c/2FPMecVAnjXIJksIyey5op6hqb51vxXZ4NLSiD7X0J5aLxc78+AHFJhk NkvXLy28vZICUdTtXD2G2sWUufo3QLvo9IfZarjrHOlDs2qUp0yfGAc7oie/DiMWZwdU nV6k6kblUFoaCVWk/QPz8WyPheJxGimDXpv3sjIUZUItEOdnXDqAALIb6CP75zZEbIty B9EguQ8slTYGPawLvwdJEGNibrQhIayPRdJxGbmak7IaTWD4QoC0V0834LUrpYhAqdZg gitQ== X-Forwarded-Encrypted: i=1; AJvYcCWm4+E+BCjJ8hJZPryd59Nw1uQwlYlpWArmzuvD2BgCPGX8gK6l9KZIA3ypHqBauSX6M70kCPVitqynfFrK@vger.kernel.org, AJvYcCWpwbMDsv8/438mCZLKcAppxRJzqMQmZPZ5J8aAthrpU1iN3qoy+moI0YqfKJodkG8dT3IVxeC/GWyWfwM=@vger.kernel.org, AJvYcCX+og+HYMfLHbfmynOhx0xfTjjH/aRwq/ID8JQu9wm1wqtmX9tCJQkcsen3anwxR9nhiC1hGolR172B/g==@vger.kernel.org, AJvYcCXGVq2u7+HdY2XJThxp+lo5tF0WiNRipP7wyvBqBcjYdAy48jpYzCpoC7v25h/GsvOlUP37cGAYoKJi@vger.kernel.org X-Gm-Message-State: AOJu0Yyt6T0V4VRFEItxGHVIhJU4DX11LHhQtIoU0xidPm1Bq09Iw0Mk Pm+i9uIwb64XNmDvYSek4S+x1P63+duyYT0xoGglq1kP6suSe8vL X-Gm-Gg: ASbGncvluZ89e94xU9ZvnEmN2+LdivlMBArzJD1mlmN5KsBI3mKmzkIrbFYuwSqRfcE L3YYXfTNGwnXTKS023cz8oAZiq3FmGutvI/xR03Jcw6x2X/oiEMsGM3yo638aaWZnYwVMznO90U ZxsrUup5JXHA0/g2XMXkdyCmxBm8AI8tfwuKwoxtQHvOKzTAxuPK0dSYl7deg2p90X6SpR8HiaB TuXtIIJrgj8ZwIFKNSrfnvpgFlNx+AS7z7wcXXs9wNTjlo/T+8c2/0= X-Google-Smtp-Source: AGHT+IG4Edmfcef/dr0yYLNFr+03s5FAfwTfyIJ0kgNSIF2POJmxSpsxI6ZjruxttETQW8VqH0+6YA== X-Received: by 2002:a17:907:9491:b0:a9a:9df:5580 with SMTP id a640c23a62f3a-aab7792d75cmr1457401366b.19.1734456640555; Tue, 17 Dec 2024 09:30:40 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:40 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:03 +0300 Subject: [PATCH v12 05/11] dt-bindings: mfd: add maxim,max77705 sensors Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-5-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=2261; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=HLrHYIHXMkyG4Fwgr6WuFYzxC5tdGkSvazBo4iDni8I=; b=Zvbf/rv/sL68cyHnSXZqMjs8FHEP26M9Gh2YkhBdiTDi0HRMzmUmhl6cwIheaEvE32+gU38FB /sxiQ1XOF4ZBzrmmNm6tTnUq/iU0/pbBYxGuwOpEX1TZLDTgHHvA4fm X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 sensors binding part. This includes fuelgauge and voltage/current sensor on chip input and system bus. Signed-off-by: Dzmitry Sankouski --- Documentation/devicetree/bindings/mfd/maxim,max77705-sensors.yaml | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/maxim,max77705-sensors.yaml b/Documentation/devicetree/bindings/mfd/maxim,max77705-sensors.yaml new file mode 100644 index 000000000000..738ce30ca72d --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705-sensors.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/maxim,max77705-sensors.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX77705 Companion Power Management IC sensors part + +maintainers: + - Dzmitry Sankouski + +description: | + The Maxim MAX77705 is a Companion Power Management sensors part includes + fuelgauge and current/voltage monitor for charger input, and system bus. + +properties: + compatible: + const: maxim,max77705-sensors + + reg: + maxItems: 1 + + fuel-gauge: + $ref: /schemas/power/supply/maxim,max17042-common.yaml# + properties: + compatible: + const: maxim,max77705-battery + + required: + - compatible + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + sensors@36 { + compatible = "maxim,max77705-sensors"; + reg = <0x36>; + + fuel-gauge { + compatible = "maxim,max77705-battery"; + power-supplies = <&max77705_charger>; + maxim,rsns-microohm = <5000>; + maxim,dead-volt = <3400>; + maxim,over-volt = <4350>; + interrupt-parent = <&pm8998_gpios>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + }; + }; + }; From patchwork Tue Dec 17 17:30:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13912275 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 891F81F9409; Tue, 17 Dec 2024 17:30:43 +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=1734456645; cv=none; b=jX2Q2oFLoC4TB5fggu7QO3nUzvTKgUH7qosvL/K3iwmkyWmLFMpB3XP89P0g0irxaNKcb580GI9uNiyQnH8RJlpU2HCYhg2mkOW/lTdvBDPHrl8lgfOguGorr5J7waiEfsYNY3JZ/39Yvhr+/a1GwrTcSGRx4Z6Bkvgq/pmkv+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456645; c=relaxed/simple; bh=ov88MZvaoV/gsvJQTFMLzJ21tbwH+Yq0QbAua0kHSkY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bir6l7mbV2MHQQBXSAw+yRuDPXfxLGYTPSfHL9T6cYndzb7fyqBuhSs1uoWY/0sH/YBDB9Gh5pAvjqIifAGvKy24sAWiPbVBY3H9IOzHwFLGiU+cR22uppZhhJP3r3QYT1VaAgQf232V7JdC8cqR5TMy+awyWlC/Icri8Htavzo= 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=LTE8IGJD; 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="LTE8IGJD" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aa692211331so1039877166b.1; Tue, 17 Dec 2024 09:30:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456642; x=1735061442; 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=QL0NB4wZEOA9rq/xLXkLm9tFDuVeVMes+GSNBIWRSr4=; b=LTE8IGJDPobQ4VRuMszeu2hqMEX9BEXIwuzLGeRdnBD1lBWn+WqbtSV+igORQ36kiJ mmu3kGGbnVPGOm2QAL4OCojLQzW2pBMZoRRBJloaQ8gI7j2ij2O65jQnO7hWDVkdoMei 0RYqDxvsZapoS0DQdLExQkFE99SsHtcObo2rrtPkNgjVhsIthPZXFzR2eFcjh8F6oA0L HkhETa3MZWO4O60x505jhwp457N46aO69o0M0Aqoo+Y3k62OZ5KFLAB5I4G8F6KlfNfJ xFb7E3jukdX6DJvI+K1vXWCWgtLF7u69dl+EazphkwGcY2YlZY7g7EnccCHAZm+pSLmh gdTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456642; x=1735061442; 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=QL0NB4wZEOA9rq/xLXkLm9tFDuVeVMes+GSNBIWRSr4=; b=V7ILn7/tFxN/R/lQVR23DWDB0X3eKRkXhT2ztIfNXsCdz/mjImMOieZ1x19u2q1a9Z E/diLUpE44aqFYsBg8vEvrMbsy4T2bjb5bbdm0sCMnGteLzDH7WW/DiYpHal+H6wIHG5 MJKBDcBCza+a+joC8AZvLvUHvns7w2NzjlOpxYUeAapbV+lsvcHyJGBDV208ccu0ewdH MbpR1DPlIwLfKb/jSBJeprh4vzzjF9lTpMcqxQuTzHn5R6OowjaZGkxqj/btN5aszZ7R /fKzMuDYWQNzCXF66g53G33iD/arjryeFMrLFkFvhkETly/z30ze1xsNqx7HyedbHGuT AAbg== X-Forwarded-Encrypted: i=1; AJvYcCVG2Nss89IoxNRiQ5eO45ABKhXYNGCUPS2tzUEPKXHJKWlbREmshFWtYn1xLHc9+T2/sWs0nr0ZW0fHzsVT@vger.kernel.org, AJvYcCVYNOVY4jrJQMF8BlCfZwcwvi6fiuklWWbJLCTx3wKVQXcMXR2e4I3I2QInMdkwUyrkHTMHSaPXU8yJ@vger.kernel.org, AJvYcCWgQhl5l+W8e/4hvDFrdoY7wj6RtrBk8wvPJhBKV1DTKsL0xBlaIzOFBrsXXN+7PCOkf/9T7MaR62oUiQ==@vger.kernel.org, AJvYcCX5bbcC83lpbJStP9RPJ1davZq4SngF/EEuQ5DoZ5NnoiupyTR++KY7Wey/SQmMUEAG6eogDdeTrON9AT4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz22LiLjn+mjdIIQ2GjPLLkLm5Z8i1tHMayhiEU7MR52p3uGazP QREtjsXwYogoaxvz5+HviRPlyZ4KEIAQNSUIBUJYi4VvDl3h2mqL X-Gm-Gg: ASbGncuIReuHJUnsOWAPn8KgrbxEdr7DW9iJEb0Yw3k8Fn9Jy/zY3JQjd9Q6JEz6Jt1 Gmy5RiBZVoL2FkoURxqvc/WqWap9sn+g+KnalfPOp+Xm5RJUQCDZl7KuXfvPa7SYe4hzqFAoIpN +k2argLu/SxppPx2pN6FcwzWXO6uqN+aFq7AWb48YIsDxLki07lKN0hWLIuoUfprgPQiwoNYSzt BBie8K2NXkABfyJuHVuEbgYNDqB4/mCiB/+1ucn7c1FvyYOTCPcjXw= X-Google-Smtp-Source: AGHT+IEtHTtnPcyrOy04wnZ4nQ2TcNi89mpKpHr0ALzOfO/hQ7Cw7ZfU+4vHa/HDAKoQUWhCvctoLg== X-Received: by 2002:a17:906:32d9:b0:aa6:79c0:d8ce with SMTP id a640c23a62f3a-aabdc8815b8mr359015466b.1.1734456641773; Tue, 17 Dec 2024 09:30:41 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:41 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:04 +0300 Subject: [PATCH v12 06/11] power: supply: max17042: add max77705 fuel gauge support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-6-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=1366; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=ov88MZvaoV/gsvJQTFMLzJ21tbwH+Yq0QbAua0kHSkY=; b=0+R8VqdXHH5BDKIxbGZ1rR+AbmiM4f5fColan0su7Tb8PoYmIyTe4o6MdkgCFrqC66LOA6RKz sQK6pkyEtUCBVwrs1eypTudcUz+4rnMvbB8wVgPaBNcvNf+3rP5uehU X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add max77705 fuel gauge support. Signed-off-by: Dzmitry Sankouski --- Changes in v12: - add only to platform version IDs Changes in v11: - add device type to compatible Changes in v10: - keep alphabetical order --- drivers/power/supply/max17042_battery.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 9424c1c108e3..a254967eef1b 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -1233,6 +1233,8 @@ static const struct of_device_id max17042_dt_match[] __used = { .data = (void *) MAXIM_DEVICE_TYPE_MAX17050 }, { .compatible = "maxim,max17055", .data = (void *) MAXIM_DEVICE_TYPE_MAX17055 }, + { .compatible = "maxim,max77705-battery", + .data = (void *) MAXIM_DEVICE_TYPE_MAX17047 }, { .compatible = "maxim,max77849-battery", .data = (void *) MAXIM_DEVICE_TYPE_MAX17047 }, { }, @@ -1255,6 +1257,7 @@ static const struct platform_device_id max17042_platform_id[] = { { "max17047", MAXIM_DEVICE_TYPE_MAX17047 }, { "max17050", MAXIM_DEVICE_TYPE_MAX17050 }, { "max17055", MAXIM_DEVICE_TYPE_MAX17055 }, + { "max77705-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { "max77849-battery", MAXIM_DEVICE_TYPE_MAX17047 }, { } }; From patchwork Tue Dec 17 17:30:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13912276 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EF3E1F9A8E; Tue, 17 Dec 2024 17:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456647; cv=none; b=Ojwje/HL5bBPwG1r08j5P91eIRDmv6NPPmE4nrVKefXJQbaUlH6Ny/o7P6oeLmTjsY2uJLoErYWS9WaohTc3MT1hmUveHzOHfOKFc5JILs/5Hspz/vCB7GoUTAieZDfPCCCdGBEUqnMPmRasW5MXoZP6gGeRFg9uqkwghlz2fnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456647; c=relaxed/simple; bh=em1c6fB/SFJ5OvDhJapdczlQ9dG2X04MTOywpnS+/6g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BWyH7pm888GIT5Pfn7NP/yy4Shw91Kj2rHmfZkiaYqDhYL5I52hVbBp5c3xmbagXRd1K7IqkzShHOwcP/xgMlNggjc91LfNy1lXYc1m3HLqU5A1RAEVGs4KTCdN/qBmLC8aziP7EEht11eEtrCjs/Yo6NYi1SG9GaInqYp3ZZBI= 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=fn0DlgKg; arc=none smtp.client-ip=209.85.208.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fn0DlgKg" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5d3e6f6cf69so2401412a12.1; Tue, 17 Dec 2024 09:30:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456643; x=1735061443; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=C6R02xkTOu2ZFN8lj6E3rQYmgVukaGWewoigfIcZyGQ=; b=fn0DlgKg1JmfXOAMpmgqBhhUPd60VhGCUTwEzpTX6DkSaWaP/YZkdsly/xZ2rqSh59 iH18+Gy6d/Z9xQeSyMY+lmDRu/twiNxhpj1rmyXZalPCUwhaZr++8mEJFqxX36CdXtRz AUTaKnrF7c827JzHXuoWC4+oCYMNHf0gjSq9OPd+tvko4B6xadE5fYsjEIRI3hAYRC8J im5UnMmPjsFW5KiRvzKXjXaPQUOB/hAwXVzd74jLUgETAMEu88jgM2eFxSdJTBj7kWEc rube4tcw5Ibm6kcxvq45Ejz+UJyr1V0mEwZfFm/F/A2n2MAuSg0QtMC5EUPin6N+qECn 2arQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456643; x=1735061443; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C6R02xkTOu2ZFN8lj6E3rQYmgVukaGWewoigfIcZyGQ=; b=GG28SgiFQsNH3HlTx4LtzyhNe2vJdyHGlHcr7MXiQgguy9OPuKhs8Nlh0bYLNNDs3m BibL7Ga6H2NoVXZoXpB+Wp+ka54yb1WrOi0VWQ2RaHBzAeODL4+d7Sp1lNb8J2QsdkVa kRWMwdBPIiW82vYI0GBoG+YyCjspKr3Oey7tg0+/Ooq0X3jBfN30hcye9yPeNz5VwYV/ VQhtyTOCbkflPbqHUkuK0+CEcmTRJ+OV+ZEfnVxlv6aruhB6v85W0Tg1TRCiCtdmJNzO fBb2CQNE2JQfJVo48XAHaJiHqtEEsBW9z8jAruShF4gcR5TILnZnF22anxUtHjXAkpxX kyKQ== X-Forwarded-Encrypted: i=1; AJvYcCUHmbcZxBc5RCnFX4zABb7H4vBVmMWbS7knaWJVu7UwDg/A5MseXi2AZOnwhrndLj0grecPvHvB6bEd@vger.kernel.org, AJvYcCUjvyxXL45oMcUaNwON4Ls4GW7y/O39lyiLDI33DZW5Tmc+NfkGYzjtOD3mvbT4Fz7IaOQn/tIl3agyonSm@vger.kernel.org, AJvYcCVkdhYAzexGsgplQ6t8STWs9QdTYiRWkt7oCwh0AgmzcQlarnlJSL5iHxd6Dqtvgj4ACNkYsOqYPjXX6g==@vger.kernel.org, AJvYcCWRtRdq3b2+dLYq1opIjveIGacOCOPRrxTr6utKUdUBr9jWdYAzKeO59gzhH8ja5fnx2jGQ2EJeg9SwoLM=@vger.kernel.org X-Gm-Message-State: AOJu0YyaT5LG0XsraMbbwW79fcJEBT4vjPON9AEdfaAEuD2onZxYQSB+ Lx7M6bDTyCi2/AUS3UrP4fXcsBBi8zf0ZIGoOXDXYZ/zQssFXGqP X-Gm-Gg: ASbGncsBK7UwkuJFsI/CgnsogPSI/vvQk9f1zLZj4xGpcjiTOHURwgYUc7Pyvbgxsm5 mrcH+Xsqbhk3HnMsc7nG3s8/c7l8SSjc9t6gMcngXUHXY8VEBn1euQ3wTgBidkYu+sSoAOBYPhN Lt+Fa5ETBCXepGreefzxEYYEkbR73wjZ5EWpO0isrwNC3RJeFamyY34gFWG6p4rn7dIMgoNgNMN v5Nd1FPW2gbCbJ5sH1Rc4QMBHEn4fmnTS9AfAWWCriXwKsH4QA7qf8= X-Google-Smtp-Source: AGHT+IGeaC8TwXE8rc5Uq5HaiJcSGlWcxOJ+QhgYgk3tCcNH9seB9l1Y1cPXYRJJ38y2Smll4p7eZw== X-Received: by 2002:a17:907:7ba3:b0:aa6:aa8a:9088 with SMTP id a640c23a62f3a-aab77e9f771mr1896784666b.41.1734456643067; Tue, 17 Dec 2024 09:30:43 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:42 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:05 +0300 Subject: [PATCH v12 07/11] power: supply: max77705: Add charger driver for Maxim 77705 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-7-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=27669; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=em1c6fB/SFJ5OvDhJapdczlQ9dG2X04MTOywpnS+/6g=; b=lSG/MftyetdABthhgMkL0YhCxbna57pYKq+FLQuXT1lPL+HXW59g1qwNly1R0J8ca8mJokTkg zcPqMVm+5obD0h7A9seKd5PexDGwGfI9xI9UyI7dxRhYcLAvQqEPZa9 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add driver for Maxim 77705 switch-mode charger. It providing power supply class information to userspace. The driver is configured through DTS (battery and system related settings). Signed-off-by: Dzmitry Sankouski --- Changes in v12: - add missing new line - reorder max77705_charger_enable and max77705_charger_disable action - convert driver from platform to i2c, adjust commit msg accordingly Changes in v11: - remove multiple blank lines - return dev_err_probe - fit on one line where possible; Changes in v10: - never blank line between call and its error check - replace remove function with devm_add_action_or_reset - remove unused inline functions from header - use dev_err_probe for error handling Changes in v9: - move power supply registration before interrupts to prevent NULL exceptions when handling interrupts Changes for v8: - join lines, where fits 100 chars - change comment style C++ -> C - remove author from 'based on' file header statement Changes for v6: - add i2c init in driver - replace remove_new back on remove - handle IS_ERR(i2c_chg) Changes for v5: - remove const modifier from max77705_charger_irq_chip because it's modified with irq_drv_data in probe function - fix license to GPL 2.0 only, where old vendor code used GPL 2.0 only - move power header to power include dir - use same hardware name in Kconfig and module descriptions Changes for v4: - start from scratch - change word delimiters in filenames to '_' - use GENMASK in header - remove debugfs code - migrate to regmap_add_irq_chip - fix property getters to follow the same style --- drivers/power/supply/Kconfig | 6 ++++ drivers/power/supply/Makefile | 1 + drivers/power/supply/max77705_charger.c | 576 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_charger.h | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 777 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 9f2eef6787f7..66264036b65d 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -583,6 +583,12 @@ config CHARGER_MAX77693 help Say Y to enable support for the Maxim MAX77693 battery charger. +config CHARGER_MAX77705 + tristate "Maxim MAX77705 battery charger driver" + depends on MFD_MAX77705 + help + Say Y to enable support for the Maxim MAX77705 battery charger. + config CHARGER_MAX77976 tristate "Maxim MAX77976 battery charger driver" depends on I2C diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index 59c4a9f40d28..85d65b7aee1c 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o obj-$(CONFIG_CHARGER_DETECTOR_MAX14656) += max14656_charger_detector.o obj-$(CONFIG_CHARGER_MAX77650) += max77650-charger.o obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o +obj-$(CONFIG_CHARGER_MAX77705) += max77705_charger.o obj-$(CONFIG_CHARGER_MAX77976) += max77976_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o diff --git a/drivers/power/supply/max77705_charger.c b/drivers/power/supply/max77705_charger.c new file mode 100644 index 000000000000..563b41420c7c --- /dev/null +++ b/drivers/power/supply/max77705_charger.c @@ -0,0 +1,576 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on max77650-charger.c + * + * Copyright (C) 2024 Dzmitry Sankouski + * + * Battery charger driver for MAXIM 77705 charger/power-supply. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static const char *max77705_charger_model = "max77705"; +static const char *max77705_charger_manufacturer = "Maxim Integrated"; + +static const struct regmap_config max77705_chg_regmap_config = { + .reg_base = MAX77705_CHG_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_CHG_REG_SAFEOUT_CTRL, +}; + +static enum power_supply_property max77705_charger_props[] = { + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_PRESENT, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CHARGE_TYPE, + POWER_SUPPLY_PROP_HEALTH, + POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, +}; + +static int max77705_chgin_irq(void *irq_drv_data) +{ + struct max77705_charger_data *charger = irq_drv_data; + + queue_work(charger->wqueue, &charger->chgin_work); + + return 0; +} + +static const struct regmap_irq max77705_charger_irqs[] = { + { .mask = MAX77705_BYP_IM, }, + { .mask = MAX77705_INP_LIMIT_IM, }, + { .mask = MAX77705_BATP_IM, }, + { .mask = MAX77705_BAT_IM, }, + { .mask = MAX77705_CHG_IM, }, + { .mask = MAX77705_WCIN_IM, }, + { .mask = MAX77705_CHGIN_IM, }, + { .mask = MAX77705_AICL_IM, }, +}; + +static struct regmap_irq_chip max77705_charger_irq_chip = { + .name = "max77705-charger", + .status_base = MAX77705_CHG_REG_INT, + .mask_base = MAX77705_CHG_REG_INT_MASK, + .handle_post_irq = max77705_chgin_irq, + .num_regs = 1, + .irqs = max77705_charger_irqs, + .num_irqs = ARRAY_SIZE(max77705_charger_irqs), +}; + +static int max77705_charger_enable(struct max77705_charger_data *chg) +{ + int rv; + + rv = regmap_update_bits(chg->regmap, MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_EN_MASK, MAX77705_CHG_EN_MASK); + if (rv) + dev_err(chg->dev, "unable to enable the charger: %d\n", rv); + + return rv; +} + +static void max77705_charger_disable(void *data) +{ + struct max77705_charger_data *chg = data; + int rv; + + rv = regmap_update_bits(chg->regmap, + MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_EN_MASK, + MAX77705_CHG_DISABLE); + if (rv) + dev_err(chg->dev, "unable to disable the charger: %d\n", rv); +} + +static int max77705_get_online(struct regmap *regmap, int *val) +{ + unsigned int data; + int ret; + + ret = regmap_read(regmap, MAX77705_CHG_REG_INT_OK, &data); + if (ret < 0) + return ret; + + *val = !!(data & MAX77705_CHGIN_OK); + + return 0; +} + +static int max77705_check_battery(struct max77705_charger_data *charger, int *val) +{ + unsigned int reg_data; + unsigned int reg_data2; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_INT_OK, ®_data); + + dev_dbg(charger->dev, "CHG_INT_OK(0x%x)\n", reg_data); + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_00, ®_data2); + + dev_dbg(charger->dev, "CHG_DETAILS00(0x%x)\n", reg_data2); + + if ((reg_data & MAX77705_BATP_OK) || !(reg_data2 & MAX77705_BATP_DTLS)) + *val = true; + else + *val = false; + + return 0; +} + +static int max77705_get_charge_type(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + if (!MAX77705_CHARGER_CHG_CHARGING(reg_data)) { + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + reg_data &= MAX77705_CHG_DTLS; + + switch (reg_data) { + case 0x0: + case MAX77705_CHARGER_CONSTANT_CURRENT: + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + *val = POWER_SUPPLY_CHARGE_TYPE_FAST; + return 0; + default: + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + return 0; +} + +static int max77705_get_status(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + unsigned int reg_data; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + if (!MAX77705_CHARGER_CHG_CHARGING(reg_data)) { + *val = POWER_SUPPLY_CHARGE_TYPE_NONE; + return 0; + } + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, ®_data); + reg_data &= MAX77705_CHG_DTLS; + + switch (reg_data) { + case 0x0: + case MAX77705_CHARGER_CONSTANT_CURRENT: + case MAX77705_CHARGER_CONSTANT_VOLTAGE: + *val = POWER_SUPPLY_STATUS_CHARGING; + return 0; + case MAX77705_CHARGER_END_OF_CHARGE: + case MAX77705_CHARGER_DONE: + *val = POWER_SUPPLY_STATUS_FULL; + return 0; + /* those values hard coded as in vendor kernel, because of */ + /* failure to determine it's actual meaning. */ + case 0x05: + case 0x06: + case 0x07: + *val = POWER_SUPPLY_STATUS_NOT_CHARGING; + return 0; + case 0x08: + case 0xA: + case 0xB: + *val = POWER_SUPPLY_STATUS_DISCHARGING; + return 0; + default: + *val = POWER_SUPPLY_STATUS_UNKNOWN; + return 0; + } + + return 0; +} + +static int max77705_get_vbus_state(struct regmap *regmap, int *value) +{ + int ret; + unsigned int charge_dtls; + + ret = regmap_read(regmap, MAX77705_CHG_REG_DETAILS_00, &charge_dtls); + if (ret) + return ret; + + charge_dtls = ((charge_dtls & MAX77705_CHGIN_DTLS) >> + MAX77705_CHGIN_DTLS_SHIFT); + + switch (charge_dtls) { + case 0x00: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x01: + *value = POWER_SUPPLY_HEALTH_UNDERVOLTAGE; + break; + case 0x02: + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + case 0x03: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + default: + return 0; + } + return 0; +} + +static int max77705_get_battery_health(struct max77705_charger_data *charger, + int *value) +{ + struct regmap *regmap = charger->regmap; + unsigned int bat_dtls; + + regmap_read(regmap, MAX77705_CHG_REG_DETAILS_01, &bat_dtls); + bat_dtls = ((bat_dtls & MAX77705_BAT_DTLS) >> MAX77705_BAT_DTLS_SHIFT); + + switch (bat_dtls) { + case MAX77705_BATTERY_NOBAT: + dev_dbg(charger->dev, "%s: No battery and the charger is suspended\n", + __func__); + *value = POWER_SUPPLY_HEALTH_NO_BATTERY; + break; + case MAX77705_BATTERY_PREQUALIFICATION: + dev_dbg(charger->dev, "%s: battery is okay but its voltage is low(~VPQLB)\n", + __func__); + break; + case MAX77705_BATTERY_DEAD: + dev_dbg(charger->dev, "%s: battery dead\n", __func__); + *value = POWER_SUPPLY_HEALTH_DEAD; + break; + case MAX77705_BATTERY_GOOD: + case MAX77705_BATTERY_LOWVOLTAGE: + *value = POWER_SUPPLY_HEALTH_GOOD; + break; + case MAX77705_BATTERY_OVERVOLTAGE: + dev_dbg(charger->dev, "%s: battery ovp\n", __func__); + *value = POWER_SUPPLY_HEALTH_OVERVOLTAGE; + break; + default: + dev_dbg(charger->dev, "%s: battery unknown\n", __func__); + *value = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; + break; + } + + return 0; +} + +static int max77705_get_health(struct max77705_charger_data *charger, int *val) +{ + struct regmap *regmap = charger->regmap; + int ret, is_online = 0; + + ret = max77705_get_online(regmap, &is_online); + if (ret) + return ret; + if (is_online) { + ret = max77705_get_vbus_state(regmap, val); + if (ret || (*val != POWER_SUPPLY_HEALTH_GOOD)) + return ret; + } + return max77705_get_battery_health(charger, val); +} + +static int max77705_get_input_current(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data; + int get_current = 0; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_09, ®_data); + + reg_data &= MAX77705_CHG_CHGIN_LIM_MASK; + + if (reg_data <= 3) + get_current = 100; + else if (reg_data >= MAX77705_CHG_CHGIN_LIM_MASK) + get_current = MAX77705_CURRENT_CHGIN_MAX; + else + get_current = (reg_data + 1) * 25; + + *val = get_current; + + return 0; +} + +static int max77705_get_charge_current(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_02, ®_data); + reg_data &= MAX77705_CHG_CC; + + *val = reg_data <= 0x2 ? 100 : reg_data * 50; + + return 0; +} + +static int max77705_set_float_voltage(struct max77705_charger_data *charger, + int float_voltage) +{ + int float_voltage_mv; + unsigned int reg_data = 0; + struct regmap *regmap = charger->regmap; + + float_voltage_mv = float_voltage / 1000; + reg_data = float_voltage_mv <= 4000 ? 0x0 : + float_voltage_mv >= 4500 ? 0x23 : + (float_voltage_mv <= 4200) ? (float_voltage_mv - 4000) / 50 : + (((float_voltage_mv - 4200) / 10) + 0x04); + + return regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_04, + MAX77705_CHG_CV_PRM_MASK, + (reg_data << MAX77705_CHG_CV_PRM_SHIFT)); +} + +static int max77705_get_float_voltage(struct max77705_charger_data *charger, + int *val) +{ + unsigned int reg_data = 0; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, ®_data); + reg_data &= MAX77705_CHG_PRM_MASK; + *val = reg_data <= 0x04 ? reg_data * 50 + 4000 : + (reg_data - 4) * 10 + 4200; + + return 0; +} + +static int max77705_chg_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct max77705_charger_data *charger = power_supply_get_drvdata(psy); + struct regmap *regmap = charger->regmap; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + return max77705_get_online(regmap, &val->intval); + case POWER_SUPPLY_PROP_PRESENT: + return max77705_check_battery(charger, &val->intval); + case POWER_SUPPLY_PROP_STATUS: + return max77705_get_status(charger, &val->intval); + case POWER_SUPPLY_PROP_CHARGE_TYPE: + return max77705_get_charge_type(charger, &val->intval); + case POWER_SUPPLY_PROP_HEALTH: + return max77705_get_health(charger, &val->intval); + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + return max77705_get_input_current(charger, &val->intval); + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + return max77705_get_charge_current(charger, &val->intval); + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + return max77705_get_float_voltage(charger, &val->intval); + case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: + val->intval = charger->bat_info->voltage_max_design_uv; + break; + case POWER_SUPPLY_PROP_MODEL_NAME: + val->strval = max77705_charger_model; + break; + case POWER_SUPPLY_PROP_MANUFACTURER: + val->strval = max77705_charger_manufacturer; + break; + default: + return -EINVAL; + } + return 0; +} + +static const struct power_supply_desc max77705_charger_psy_desc = { + .name = "max77705-charger", + .type = POWER_SUPPLY_TYPE_USB, + .properties = max77705_charger_props, + .num_properties = ARRAY_SIZE(max77705_charger_props), + .get_property = max77705_chg_get_property, +}; + +static void max77705_chgin_isr_work(struct work_struct *work) +{ + struct max77705_charger_data *charger = + container_of(work, struct max77705_charger_data, chgin_work); + + power_supply_changed(charger->psy_chg); +} + +static void max77705_charger_initialize(struct max77705_charger_data *chg) +{ + u8 reg_data; + struct power_supply_battery_info *info; + struct regmap *regmap = chg->regmap; + + if (power_supply_get_battery_info(chg->psy_chg, &info) < 0) + return; + + chg->bat_info = info; + + /* unlock charger setting protect */ + /* slowest LX slope */ + reg_data = MAX77705_CHGPROT_MASK | MAX77705_SLOWEST_LX_SLOPE; + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_06, reg_data, + reg_data); + + /* fast charge timer disable */ + /* restart threshold disable */ + /* pre-qual charge disable */ + reg_data = (MAX77705_FCHGTIME_DISABLE << MAX77705_FCHGTIME_SHIFT) | + (MAX77705_CHG_RSTRT_DISABLE << MAX77705_CHG_RSTRT_SHIFT) | + (MAX77705_CHG_PQEN_DISABLE << MAX77705_PQEN_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_01, + (MAX77705_FCHGTIME_MASK | + MAX77705_CHG_RSTRT_MASK | + MAX77705_PQEN_MASK), + reg_data); + + /* OTG off(UNO on), boost off */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + MAX77705_OTG_CTRL, 0); + + /* charge current 450mA(default) */ + /* otg current limit 900mA */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_02, + MAX77705_OTG_ILIM_MASK, + MAX77705_OTG_ILIM_900 << MAX77705_OTG_ILIM_SHIFT); + + /* BAT to SYS OCP 4.80A */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_05, + MAX77705_REG_B2SOVRC_MASK, + MAX77705_B2SOVRC_4_8A << MAX77705_REG_B2SOVRC_SHIFT); + /* top off current 150mA */ + /* top off timer 30min */ + reg_data = (MAX77705_TO_ITH_150MA << MAX77705_TO_ITH_SHIFT) | + (MAX77705_TO_TIME_30M << MAX77705_TO_TIME_SHIFT) | + (MAX77705_SYS_TRACK_DISABLE << MAX77705_SYS_TRACK_DIS_SHIFT); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_03, + (MAX77705_TO_ITH_MASK | + MAX77705_TO_TIME_MASK | + MAX77705_SYS_TRACK_DIS_MASK), reg_data); + + /* cv voltage 4.2V or 4.35V */ + /* MINVSYS 3.6V(default) */ + if (info->voltage_max_design_uv < 0) { + dev_warn(chg->dev, "missing battery:voltage-max-design-microvolt\n"); + max77705_set_float_voltage(chg, 4200000); + } else { + max77705_set_float_voltage(chg, info->voltage_max_design_uv); + } + + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, + MAX77705_VCHGIN_REG_MASK, MAX77705_VCHGIN_4_5); + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, + MAX77705_WCIN_REG_MASK, MAX77705_WCIN_4_5); + + /* Watchdog timer */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_00, + MAX77705_WDTEN_MASK, 0); + + /* Active Discharge Enable */ + regmap_update_bits(regmap, MAX77705_PMIC_REG_MAINCTRL1, 1, 1); + + /* VBYPSET=5.0V */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_11, MAX77705_VBYPSET_MASK, 0); + + /* Switching Frequency : 1.5MHz */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_08, MAX77705_REG_FSW_MASK, + (MAX77705_CHG_FSW_1_5MHz << MAX77705_REG_FSW_SHIFT)); + + /* Auto skip mode */ + regmap_update_bits(regmap, MAX77705_CHG_REG_CNFG_12, MAX77705_REG_DISKIP_MASK, + (MAX77705_AUTO_SKIP << MAX77705_REG_DISKIP_SHIFT)); +} + +static int max77705_charger_probe(struct i2c_client *i2c) +{ + struct power_supply_config pscfg = {}; + struct max77705_charger_data *chg; + struct device *dev; + struct regmap_irq_chip_data *irq_data; + int ret; + + dev = &i2c->dev; + + chg = devm_kzalloc(dev, sizeof(*chg), GFP_KERNEL); + if (!chg) + return -ENOMEM; + + chg->dev = dev; + i2c_set_clientdata(i2c, chg); + + chg->regmap = devm_regmap_init_i2c(i2c, &max77705_chg_regmap_config); + if (IS_ERR(chg->regmap)) + return PTR_ERR(chg->regmap); + + ret = regmap_update_bits(chg->regmap, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHGIN_IM, 0); + if (ret) + return ret; + + pscfg.of_node = dev->of_node; + pscfg.drv_data = chg; + + chg->psy_chg = devm_power_supply_register(dev, &max77705_charger_psy_desc, &pscfg); + if (IS_ERR(chg->psy_chg)) + return PTR_ERR(chg->psy_chg); + + max77705_charger_irq_chip.irq_drv_data = chg; + ret = devm_regmap_add_irq_chip(chg->dev, chg->regmap, i2c->irq, + IRQF_ONESHOT | IRQF_SHARED, 0, + &max77705_charger_irq_chip, + &irq_data); + if (ret) + return dev_err_probe(dev, ret, "failed to add irq chip\n"); + + chg->wqueue = create_singlethread_workqueue(dev_name(dev)); + if (IS_ERR(chg->wqueue)) + return dev_err_probe(dev, PTR_ERR(chg->wqueue), "failed to create workqueue\n"); + + INIT_WORK(&chg->chgin_work, max77705_chgin_isr_work); + + max77705_charger_initialize(chg); + + ret = max77705_charger_enable(chg); + if (ret) + return dev_err_probe(dev, ret, "failed to enable charge\n"); + else + return devm_add_action_or_reset(dev, max77705_charger_disable, chg); +} + +static const struct of_device_id max77705_charger_of_match[] = { + { .compatible = "maxim,max77705-charger" }, + { } +}; +MODULE_DEVICE_TABLE(of, max77705_charger_of_match); + +static struct i2c_driver max77705_charger_driver = { + .driver = { + .name = "max77705-charger", + .of_match_table = max77705_charger_of_match, + }, + .probe = max77705_charger_probe, +}; +module_i2c_driver(max77705_charger_driver); + +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_DESCRIPTION("Maxim MAX77705 charger driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/power/max77705_charger.h b/include/linux/power/max77705_charger.h new file mode 100644 index 000000000000..cb5cd03e54e2 --- /dev/null +++ b/include/linux/power/max77705_charger.h @@ -0,0 +1,194 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Maxim MAX77705 definitions. + * + * Copyright (C) 2015 Samsung Electronics, Inc. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#ifndef __MAX77705_CHARGER_H +#define __MAX77705_CHARGER_H __FILE__ + +/* MAX77705_CHG_REG_CHG_INT */ +#define MAX77705_BYP_I BIT(0) +#define MAX77705_INP_LIMIT_I BIT(1) +#define MAX77705_BATP_I BIT(2) +#define MAX77705_BAT_I BIT(3) +#define MAX77705_CHG_I BIT(4) +#define MAX77705_WCIN_I BIT(5) +#define MAX77705_CHGIN_I BIT(6) +#define MAX77705_AICL_I BIT(7) + +/* MAX77705_CHG_REG_CHG_INT_MASK */ +#define MAX77705_BYP_IM BIT(0) +#define MAX77705_INP_LIMIT_IM BIT(1) +#define MAX77705_BATP_IM BIT(2) +#define MAX77705_BAT_IM BIT(3) +#define MAX77705_CHG_IM BIT(4) +#define MAX77705_WCIN_IM BIT(5) +#define MAX77705_CHGIN_IM BIT(6) +#define MAX77705_AICL_IM BIT(7) + +/* MAX77705_CHG_REG_CHG_INT_OK */ +#define MAX77705_BYP_OK BIT(0) +#define MAX77705_DISQBAT_OK BIT(1) +#define MAX77705_BATP_OK BIT(2) +#define MAX77705_BAT_OK BIT(3) +#define MAX77705_CHG_OK BIT(4) +#define MAX77705_WCIN_OK BIT(5) +#define MAX77705_CHGIN_OK BIT(6) +#define MAX77705_AICL_OK BIT(7) + +/* MAX77705_CHG_REG_DETAILS_00 */ +#define MAX77705_BATP_DTLS BIT(0) +#define MAX77705_WCIN_DTLS GENMASK(4, 3) +#define MAX77705_WCIN_DTLS_SHIFT 3 +#define MAX77705_CHGIN_DTLS GENMASK(6, 5) +#define MAX77705_CHGIN_DTLS_SHIFT 5 + +/* MAX77705_CHG_REG_DETAILS_01 */ +#define MAX77705_CHG_DTLS GENMASK(3, 0) +#define MAX77705_CHG_DTLS_SHIFT 0 +#define MAX77705_BAT_DTLS GENMASK(6, 4) +#define MAX77705_BAT_DTLS_SHIFT 4 + +/* MAX77705_CHG_REG_DETAILS_02 */ +#define MAX77705_BYP_DTLS GENMASK(3, 0) +#define MAX77705_BYP_DTLS_SHIFT 0 + +/* MAX77705_CHG_REG_CNFG_00 */ +#define MAX77705_CHG_SHIFT 0 +#define MAX77705_UNO_SHIFT 1 +#define MAX77705_OTG_SHIFT 1 +#define MAX77705_BUCK_SHIFT 2 +#define MAX77705_BOOST_SHIFT 3 +#define MAX77705_WDTEN_SHIFT 4 +#define MAX77705_MODE_MASK GENMASK(3, 0) +#define MAX77705_CHG_MASK BIT(MAX77705_CHG_SHIFT) +#define MAX77705_UNO_MASK BIT(MAX77705_UNO_SHIFT) +#define MAX77705_OTG_MASK BIT(MAX77705_OTG_SHIFT) +#define MAX77705_BUCK_MASK BIT(MAX77705_BUCK_SHIFT) +#define MAX77705_BOOST_MASK BIT(MAX77705_BOOST_SHIFT) +#define MAX77705_WDTEN_MASK BIT(MAX77705_WDTEN_SHIFT) +#define MAX77705_UNO_CTRL (MAX77705_UNO_MASK | MAX77705_BOOST_MASK) +#define MAX77705_OTG_CTRL (MAX77705_OTG_MASK | MAX77705_BOOST_MASK) + +/* MAX77705_CHG_REG_CNFG_01 */ +#define MAX77705_FCHGTIME_SHIFT 0 +#define MAX77705_FCHGTIME_MASK GENMASK(2, 0) +#define MAX77705_CHG_RSTRT_SHIFT 4 +#define MAX77705_CHG_RSTRT_MASK GENMASK(5, 4) +#define MAX77705_FCHGTIME_DISABLE 0 +#define MAX77705_CHG_RSTRT_DISABLE 0x3 + +#define MAX77705_PQEN_SHIFT 7 +#define MAX77705_PQEN_MASK BIT(7) +#define MAX77705_CHG_PQEN_DISABLE 0 +#define MAX77705_CHG_PQEN_ENABLE 1 + +/* MAX77705_CHG_REG_CNFG_02 */ +#define MAX77705_OTG_ILIM_SHIFT 6 +#define MAX77705_OTG_ILIM_MASK GENMASK(7, 6) +#define MAX77705_OTG_ILIM_500 0 +#define MAX77705_OTG_ILIM_900 1 +#define MAX77705_OTG_ILIM_1200 2 +#define MAX77705_OTG_ILIM_1500 3 +#define MAX77705_CHG_CC GENMASK(5, 0) + +/* MAX77705_CHG_REG_CNFG_03 */ +#define MAX77705_TO_ITH_SHIFT 0 +#define MAX77705_TO_ITH_MASK GENMASK(2, 0) +#define MAX77705_TO_TIME_SHIFT 3 +#define MAX77705_TO_TIME_MASK GENMASK(5, 3) +#define MAX77705_SYS_TRACK_DIS_SHIFT 7 +#define MAX77705_SYS_TRACK_DIS_MASK BIT(7) +#define MAX77705_TO_ITH_150MA 0 +#define MAX77705_TO_TIME_30M 3 +#define MAX77705_SYS_TRACK_ENABLE 0 +#define MAX77705_SYS_TRACK_DISABLE 1 + +/* MAX77705_CHG_REG_CNFG_04 */ +#define MAX77705_CHG_MINVSYS_SHIFT 6 +#define MAX77705_CHG_MINVSYS_MASK GENMASK(7, 6) +#define MAX77705_CHG_PRM_SHIFT 0 +#define MAX77705_CHG_PRM_MASK GENMASK(5, 0) + +#define MAX77705_CHG_CV_PRM_SHIFT 0 +#define MAX77705_CHG_CV_PRM_MASK GENMASK(5, 0) + +/* MAX77705_CHG_REG_CNFG_05 */ +#define MAX77705_REG_B2SOVRC_SHIFT 0 +#define MAX77705_REG_B2SOVRC_MASK GENMASK(3, 0) +#define MAX77705_B2SOVRC_DISABLE 0 +#define MAX77705_B2SOVRC_4_5A 6 +#define MAX77705_B2SOVRC_4_8A 8 +#define MAX77705_B2SOVRC_5_0A 9 + +/* MAX77705_CHG_CNFG_06 */ +#define MAX77705_WDTCLR_SHIFT 0 +#define MAX77705_WDTCLR_MASK GENMASK(1, 0) +#define MAX77705_WDTCLR 1 +#define MAX77705_CHGPROT_MASK GENMASK(3, 2) +#define MAX77705_CHGPROT_UNLOCKED GENMASK(3, 2) +#define MAX77705_SLOWEST_LX_SLOPE GENMASK(6, 5) + +/* MAX77705_CHG_REG_CNFG_07 */ +#define MAX77705_CHG_FMBST 4 +#define MAX77705_REG_FMBST_SHIFT 2 +#define MAX77705_REG_FMBST_MASK BIT(MAX77705_REG_FMBST_SHIFT) +#define MAX77705_REG_FGSRC_SHIFT 1 +#define MAX77705_REG_FGSRC_MASK BIT(MAX77705_REG_FGSRC_SHIFT) + +/* MAX77705_CHG_REG_CNFG_08 */ +#define MAX77705_REG_FSW_SHIFT 0 +#define MAX77705_REG_FSW_MASK GENMASK(1, 0) +#define MAX77705_CHG_FSW_3MHz 0 +#define MAX77705_CHG_FSW_2MHz 1 +#define MAX77705_CHG_FSW_1_5MHz 2 + +/* MAX77705_CHG_REG_CNFG_09 */ +#define MAX77705_CHG_CHGIN_LIM_MASK GENMASK(6, 0) +#define MAX77705_CHG_EN_MASK BIT(7) +#define MAX77705_CHG_DISABLE 0 +#define MAX77705_CHARGER_CHG_CHARGING(_reg) \ + (((_reg) & MAX77705_CHG_EN_MASK) > 1) + + +/* MAX77705_CHG_REG_CNFG_10 */ +#define MAX77705_CHG_WCIN_LIM GENMASK(5, 0) + +/* MAX77705_CHG_REG_CNFG_11 */ +#define MAX77705_VBYPSET_SHIFT 0 +#define MAX77705_VBYPSET_MASK GENMASK(6, 0) + +/* MAX77705_CHG_REG_CNFG_12 */ +#define MAX77705_CHGINSEL_SHIFT 5 +#define MAX77705_CHGINSEL_MASK BIT(MAX77705_CHGINSEL_SHIFT) +#define MAX77705_WCINSEL_SHIFT 6 +#define MAX77705_WCINSEL_MASK BIT(MAX77705_WCINSEL_SHIFT) +#define MAX77705_VCHGIN_REG_MASK GENMASK(4, 3) +#define MAX77705_WCIN_REG_MASK GENMASK(2, 1) +#define MAX77705_REG_DISKIP_SHIFT 0 +#define MAX77705_REG_DISKIP_MASK BIT(MAX77705_REG_DISKIP_SHIFT) +/* REG=4.5V, UVLO=4.7V */ +#define MAX77705_VCHGIN_4_5 0 +/* REG=4.5V, UVLO=4.7V */ +#define MAX77705_WCIN_4_5 0 +#define MAX77705_DISABLE_SKIP 1 +#define MAX77705_AUTO_SKIP 0 + +/* mA */ +#define MAX77705_CURRENT_STEP 25 +#define MAX77705_CURRENT_WCIN_MAX 1600 +#define MAX77705_CURRENT_CHGIN_MAX 3200 + +struct max77705_charger_data { + struct device *dev; + struct regmap *regmap; + struct power_supply_battery_info *bat_info; + struct workqueue_struct *wqueue; + struct work_struct chgin_work; + struct power_supply *psy_chg; +}; + +#endif /* __MAX77705_CHARGER_H */ From patchwork Tue Dec 17 17:30:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13912277 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 C51F11F9EBB; Tue, 17 Dec 2024 17:30:46 +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=1734456648; cv=none; b=fNTPEwem7Z6UE12Pi16pV8f8wFHnorqC5RToJ1aJld/hjnRWMz23HtAKj507AzgBFSLL9dHOYd5G3g8hod/05T17CZ6XaQczRzt9BCdIRAoo5ZdI/WyfFBRKGEeraR0xJ4MreqBOmQFOrFdufTjsowoiG3D84xp+OTLTY0OeTa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456648; c=relaxed/simple; bh=+FFiRlSo99k/2BJM4fC8uS16GzJJXvxO8BQM/0zU0VA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I+8PKJuXDFM11zf4dMcKOCCKFQEUmO95LRybOsQb20gPRsuMyzcdt3m+3CmARjTyoildiX8ciSQj6weFqDZm7WACHmvwEvzXGVPly6oCgVtOTJDN9mfRg4pqnwusLyvGQqGEvQXn9ma7Mx4f6Og0T4G775Xs+t6kRgVvJi3xq9U= 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=acxmSJJ3; 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="acxmSJJ3" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aa684b6d9c7so918384966b.2; Tue, 17 Dec 2024 09:30:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456645; x=1735061445; 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=6LqDPKMP8x/bUFI6SrSGeUk5x3byOylHQFv08vPFx6w=; b=acxmSJJ3VHL3aOyn9omp/W4ZMECKOKru94+nFh6A6xBgLk6DNHfHkJ81mIHGM1fCXO Z6cbvtkFyUn5hhp50LVj+3vi7L48W1vvpY8XfZdGr2eMp0CjxzWXQkHkPJqr36C3biup zknIw2NOfLk17Sb/rtqX35TlRNV8ai/RY/i865ZHL5RxeWNMN+G2QTY4qU1vm4hWeaUU dNuS9BiBlI8bbVcGC3JK5MEehH9VdqmPd9S1msKO8s26uzUa2ysQIJyE4ocdUNBfeA7k oJXuITwliBxs56eQix0B5Em7joK2bRZDIFI8d8sJBcJLzHy47hs1+0S7vdyi49oTke3q KLoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456645; x=1735061445; 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=6LqDPKMP8x/bUFI6SrSGeUk5x3byOylHQFv08vPFx6w=; b=SXJrC4bvz7R/CtxzBB6nlzrUpeRYGof0nuoriciA2wjideHJsAvOEPkpdCLrqm9Lmb pICa8B//D870BMW4OcQpuPlqlizJlytILD0VelVaVb7TCPgfJvH4CX3pKXIsSg+FjDsF TXRUmSV3i1mahqOq2ur3hpCF8M4YlbdTRmFlbDOGqjFS0zMk992SmHtGtQ4lpLdW0usF WqmSpCL28iasTAPBkcnFTy3CxIh3oPYypC6zyDQ8GKsYt8FNYsAWEulujdzexwp4OLeD k6DheMR3Gd4Sgl9Y9VbwVS8vq5zmgQv+iZM8ESaWLxKAPJjzRUEqP30KZbq7v1kK3sNm eRnA== X-Forwarded-Encrypted: i=1; AJvYcCULPIC4bI623PPHFv3w8tdS1lirkCfLCXykFgmIglhRPBrkpOCQR9rA0JxjDMCN0VeIzNn/assa9C+iD3Q=@vger.kernel.org, AJvYcCVV7rl2UFoUSJu0pc9yFmdsE9IySFKRbTYWYoUPuqvtYgSfOSuoIbv6Ywiz/PhECGY69zcXAkwuGm/5/R16@vger.kernel.org, AJvYcCWAXQXG5HvUroLuiTlAAvhQg07TDa+oZ279vnYYrs4ippr6GnN+aWwNwG/K+nby8YpflwQFfwKZbroP/g==@vger.kernel.org, AJvYcCX8LxGjNUJmKS5ssfAZLK5emAYNrVr96a6j9GOGae+T/gjm0rjmJyHLZ7jPIX63W1HHluqpVvPB20Ry@vger.kernel.org X-Gm-Message-State: AOJu0YzEPwI/LSp9semewNzj7AycDa0sVmK/GSXoeyppdMiUA6rCyeu/ cZPyH55xonmhaSQH/BCnsSQMrFlG/VelI1lIbM17ERHg3KjXDGDfQvqSbg== X-Gm-Gg: ASbGncuKC/DrCjgPs9fHa458kz6oYncKFgrlO6d9ZdaeOYnKJY9jGKTNR/RWctyR7EZ vljk3kImpqIv5XKY562I1kXYmDDeLH3dQrXkhqZUgdkOUjOYVEXZlTyngcMdKjYOWWzc+6PjO0n 4Cl3Qzjcdm2zBm7zwCaVAWTVqSsKd1ZWS5hdJhOcCdG9xFCUH0hRJ51Gr0KB71/QUBYyG4uWSdr Nc+r9wrcp4AI+FapIeqyD3qOoGuGW/qb6ba0G1nDpvgsNkpkLhzPB0= X-Google-Smtp-Source: AGHT+IHyJ1xzTMr00z/xVI0EuUuBw+7rjBe7/iaEUnQtszYu7MmySsEEdGvbwvxqylshhTNr7ZLyFA== X-Received: by 2002:a17:907:3f23:b0:aa6:9fad:3c1d with SMTP id a640c23a62f3a-aab77ea5969mr1931278366b.39.1734456645114; Tue, 17 Dec 2024 09:30:45 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:44 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:06 +0300 Subject: [PATCH v12 08/11] mfd: simple-mfd-i2c: Add MAX77705 support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-8-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=1366; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=+FFiRlSo99k/2BJM4fC8uS16GzJJXvxO8BQM/0zU0VA=; b=rdErnLbkKIKZVkHDkkOh5Tel0i3+R4O2Q7EKdJjNVI0Ci7/Tvap+dguurlHkl5U0M3Rn1fVG/ 6Cx68MdA7jBCrdRW4tDiKhg79AA34VQcstDC7zAgjK4SkOQUwDXUDQN X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add MAX77705 support - fuel gauge and hwmon devices. Hwmon provides charger input and system bus measurements. Signed-off-by: Dzmitry Sankouski --- drivers/mfd/simple-mfd-i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c index 6eda79533208..d6563f4263dd 100644 --- a/drivers/mfd/simple-mfd-i2c.c +++ b/drivers/mfd/simple-mfd-i2c.c @@ -83,11 +83,22 @@ static const struct simple_mfd_data maxim_max5970 = { .mfd_cell_size = ARRAY_SIZE(max5970_cells), }; +static const struct mfd_cell max77705_sensor_cells[] = { + { .name = "max77705-battery", .of_compatible = "maxim,max77705-battery" }, + { .name = "max77705-hwmon", }, +}; + +static const struct simple_mfd_data maxim_mon_max77705 = { + .mfd_cell = max77705_sensor_cells, + .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), +}; + static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible = "kontron,sl28cpld" }, { .compatible = "silergy,sy7636a", .data = &silergy_sy7636a}, { .compatible = "maxim,max5970", .data = &maxim_max5970}, { .compatible = "maxim,max5978", .data = &maxim_max5970}, + { .compatible = "maxim,max77705-sensors", .data = &maxim_mon_max77705}, {} }; MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match); From patchwork Tue Dec 17 17:30:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13912278 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 728DB1F9F60; Tue, 17 Dec 2024 17:30:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456650; cv=none; b=fOkyRV+Rcm3pJYwyv6eUhtNDvQfi05DKr1s/xJOGTn7iNgWRJprR0ck8bMCfe8spJ215NUK5EgQ/S5I22LqQgc0XFTfhWFPAlOrT5nQn2UuywSq51H+OBSly0UjE7gvmpZ1Nyt5JRaz2AnPGSCSl4vUVIVJlJ6tEzwUD5qFKW1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456650; c=relaxed/simple; bh=bzyMSSDFGgqd9aTvpe+Y2tTJQQEWGRh3xA3BY7P6RYU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q9jVUMzdF0rxQghIEdavDyjC8uUkV93AsYuj9BSTXP+yeKbElJoVtrStYMNB7pob8OtMxqPkIa1sz8h/H5pl1B6srRKgCghbE0OlhS05yt3RCsrcvirpUWViTHREgs6Du7kfzs90ND6HQs8roHyTKT793cPi3CAaBk7z1wGGiSo= 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=gQReY2JW; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gQReY2JW" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-aa66ead88b3so990020666b.0; Tue, 17 Dec 2024 09:30:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456647; x=1735061447; 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=UD/+EWrwsgCuQyJxW73B3B7Hgq5NAPjjKmuT/EP+i6Y=; b=gQReY2JWTivNEsUwhx36iVyRFz9iPx9PomDmNTbIc2FYTx/xwEHM85OhJeHA4vuQQs pjSRTUJmBLYwbxXm/yn2pWJ4ymjOBEv1rE/tuVKE/2XiC9BIKpedUXsbu8QuXRjY3Hy7 uug5kMOVI1sFrjompJk6vp96pCtRPr5E/Oo3JzeUGT55bt0R3aX7rsOgiz2WHaRadwfl a0snapJ4XiuXc33wa0G3GAN3DjYLiAxYONzFGyddbCOjWzunOFUcHj1dtVKiDDsuV12N 1msjPyso+wDk66OI9h8IWD32K3xftTySNNRXvv14xYQu1rNeZvnoOX2iSPw7RQwqquLX 22Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456647; x=1735061447; 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=UD/+EWrwsgCuQyJxW73B3B7Hgq5NAPjjKmuT/EP+i6Y=; b=tV8n43OdDRjGP4B4zYk0XHbdiihllZAYrbh8tfW9sLWU8FfSCsjfr2qFqVT/KoZ2cd P3aSb5WL36nkg57hd4qA2fsZmfd3DHNyrtao61gNw52d75dx3bsdMwmg4asGfaX8pL7Y UdmydnvKUcvpPRHpSZReWhYEwoZZR7MHBDS6oTgv7h3Hzgdoba6BDx5r3P9+oyl1YY4W UBL6guwBbb+mTn5mnNAIBEx/R0fFlSaQ3N65elWTYZBkBiMwkukJKDbh2Lou3LRcmVVa aDJFaJBJDaO6noNlQefrCaxp57xxy565B5b0pSJJvyjEjBMVCUBA2LFlxGuhf9+HlR/P cD5w== X-Forwarded-Encrypted: i=1; AJvYcCUnex4LzMpzDjn0KFIHlLrmy/5uCWtFJs1LOQtdKVjqgAu5TxWZ/vP0Cukd2cJQBPzXwWObIvnlbUIMVw==@vger.kernel.org, AJvYcCVKr77L3Qvgog+CLVsrs3PvOxHUy82Y8PKIbhbwTyOBD9Tq2dO/6+iP6dbsaX57j56XS2fgHB9GKjZYQS4=@vger.kernel.org, AJvYcCVT9HoEk8I82bGmXjbSph2ZYtHfjMuhydmKuKzFd6CrWvV1AIDQoZ25u00DbRgI+rYzUYlEOC10X5Tn@vger.kernel.org, AJvYcCX0mqrpi7EZvNIHjT8aHSwi3XNt/N7V28TWjdxASFoAsA53JYOqsko4fUmxY4P+PxyGywg/i/fm4m1N7IVR@vger.kernel.org X-Gm-Message-State: AOJu0YzOCqdqphLbg7JSp3fJpEp4zIScVMjKU/YQDcXDkq1M0sKfWrBU blXfBf7AmDapO8siJJD9M0cmrnr/FbAjCuLQdb+LxJ/TT06qL2wH X-Gm-Gg: ASbGncsViTrUlz09jY2wSLK7MWwtCBtIPzBl/5UsRSM20TTlvdo369tOUl4b+MBH4NV bDF5CHdj+cXGlh6s9+rWlCNRC/tmTihEQRA+eLjDKmoW7DgAJqwKA0ODbNLXRT6HeJA2sNET6i2 mANsLF9hUuUgc47smHYBUQiRVa9xNF8hE2ErFsSzHZ4BxdxkDuuk+grrcMoFaMyuVkd5SmunIay qgptNO0nrvpydU3ev2/V0b2dd0tTJRyZkU4lUhZhjqWDO5UKDOm1ko= X-Google-Smtp-Source: AGHT+IEpfM4nqCi3/AcIBz7sSXeV3jI9ZjxaxIIENf1ykkr1VrKjKbGL/gEcr0S4ynC1jI1VyYCDqQ== X-Received: by 2002:a17:906:314c:b0:aa6:519c:ef9a with SMTP id a640c23a62f3a-aabf1c90389mr14389266b.53.1734456646453; Tue, 17 Dec 2024 09:30:46 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:46 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:07 +0300 Subject: [PATCH v12 09/11] mfd: Add new driver for MAX77705 PMIC Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-9-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=18961; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=bzyMSSDFGgqd9aTvpe+Y2tTJQQEWGRh3xA3BY7P6RYU=; b=0MMccYxjSYO8hSw41SKYLZuNcgUfd4yn8CmceVBJUz7V2BfqsaXzg4zgVkPFInbNWY2pyqWjH qxMe0oE7inYCb7qF+dRLmx/fRxKBay0AXMgjd6SKUPPUxPpzWs4gC2+ X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add the core MFD driver for max77705 PMIC. Drivers for sub-devices will be added in subsequent patches. Signed-off-by: Dzmitry Sankouski --- Changes for v12: - remove fuelgauge support (it's moved to simple-mfd-i2c, to reflect the fact it's a separate device with it's own i2c client) - remove unneeded ending comma - remove struct dev_pm_ops because defined by DEFINE_SIMPLE_DEV_PM_OPS - Kconfig: select MFD_SIMPLE_MFD_I2C Changes for v10: - never blank line between call and its error check - remove unnecessary line wrap - revert wrong changes in max77693-common.h - move max77705_pm_ops from header to c file - fail probe, when fuelgauge is not found in sub device list - remove fuelgauge compatible, because with compatible, platform matches using compatible, and platform_device id_entry is empty. With no compatible, platform matches by device id, and id_entry is populated. - use dev_err_probe for error handling Changes for v9: - use max17042 as fuel gauge chip - initialize max17042 i2c dummy device in mfd device, because bus can be used for reading additional values, not related to fuelgauge, like chip input current, system bus current - fix pmic_rev kernel test robot error Changes for v8: - fix comment style C++ -> C - remove unused pmic_ver Changes for v6: - add PMIC suffix in Kconfig - remove filename from file header - reorder headers alphabetically - move out fg and chg adresses definitions - rename led name and compatible - remove overbracketing - move charger and fuel gauge i2c initialization to their drivers - fix max77705_i2c_driver tabbing - formatting fixes Changes for v5: - license change to 2.0 - use same hardware name in Kconfig and module descriptions Changes for v4: - rework driver from scratch - migrate to regmap_add_irq_chip, remove max77705-irq.c, rename max77705-core.c to max77705.c - cleanup headers - remove debugfs code - migrate to use max77693_dev structure - remove max77705.h --- MAINTAINERS | 2 ++ drivers/mfd/Kconfig | 13 +++++++++++++ drivers/mfd/Makefile | 2 ++ drivers/mfd/max77705.c | 209 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-common.h | 4 +++- include/linux/mfd/max77705-private.h | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 407 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 75e4e122bb44..587570b12306 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14241,6 +14241,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 @@ -14248,6 +14249,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..914b6992613e 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -916,6 +916,19 @@ config MFD_MAX77693 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MAX77705 + tristate "Maxim MAX77705 PMIC Support" + depends on I2C + select MFD_CORE + select MFD_SIMPLE_MFD_I2C + help + Say yes here to add support for Maxim Integrated MAX77705 PMIC. + This is a Power Management IC with Charger, safe LDOs, Flash, Haptic + and MUIC controls on chip. + This driver provides common support for accessing the device; + additional drivers must be enabled in order to use the functionality + of the device. + config MFD_MAX77714 tristate "Maxim Semiconductor MAX77714 PMIC Support" depends on I2C diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 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..18d344620755 --- /dev/null +++ b/drivers/mfd/max77705.c @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0+ +// +// Maxim MAX77705 PMIC core driver +// +// Copyright (C) 2024 Dzmitry Sankouski + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct mfd_cell max77705_devs[] = { + { + .name = "max77705-rgb", + .of_compatible = "maxim,max77705-rgb", + }, + { + .name = "max77705-charger", + .of_compatible = "maxim,max77705-charger", + }, + { + .name = "max77705-haptic", + .of_compatible = "maxim,max77705-haptic", + }, +}; + +static const struct regmap_range max77705_readable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_PMICID1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), +}; + +static const struct regmap_range max77705_writable_ranges[] = { + regmap_reg_range(MAX77705_PMIC_REG_MAINCTRL1, MAX77705_PMIC_REG_BSTOUT_MASK), + regmap_reg_range(MAX77705_PMIC_REG_INTSRC, MAX77705_PMIC_REG_RESERVED_29), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_MCONFIG, MAX77705_PMIC_REG_MCONFIG2), + regmap_reg_range(MAX77705_PMIC_REG_FORCE_EN_MASK, MAX77705_PMIC_REG_FORCE_EN_MASK), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL1, MAX77705_PMIC_REG_BOOSTCONTROL1), + regmap_reg_range(MAX77705_PMIC_REG_BOOSTCONTROL2, MAX77705_PMIC_REG_BOOSTCONTROL2), + regmap_reg_range(MAX77705_PMIC_REG_SW_RESET, MAX77705_PMIC_REG_USBC_RESET), + +}; + +static const struct regmap_access_table max77705_readable_table = { + .yes_ranges = max77705_readable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_readable_ranges), +}; + +static const struct regmap_access_table max77705_writable_table = { + .yes_ranges = max77705_writable_ranges, + .n_yes_ranges = ARRAY_SIZE(max77705_writable_ranges), +}; + +static const struct regmap_config max77705_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .rd_table = &max77705_readable_table, + .wr_table = &max77705_writable_table, + .max_register = MAX77705_PMIC_REG_USBC_RESET, +}; + +static const struct regmap_config max77705_leds_regmap_config = { + .reg_base = MAX77705_RGBLED_REG_BASE, + .reg_bits = 8, + .val_bits = 8, + .max_register = MAX77705_LED_REG_END, +}; + +static const struct regmap_irq max77705_topsys_irqs[] = { + { .mask = MAX77705_SYSTEM_IRQ_BSTEN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSUVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_SYSOVLO_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TSHDN_INT, }, + { .mask = MAX77705_SYSTEM_IRQ_TM_INT, }, +}; + +static const struct regmap_irq_chip max77705_topsys_irq_chip = { + .name = "max77705-topsys", + .status_base = MAX77705_PMIC_REG_SYSTEM_INT, + .mask_base = MAX77705_PMIC_REG_SYSTEM_INT_MASK, + .num_regs = 1, + .irqs = max77705_topsys_irqs, + .num_irqs = ARRAY_SIZE(max77705_topsys_irqs), +}; + +static int max77705_i2c_probe(struct i2c_client *i2c) +{ + struct max77693_dev *max77705; + struct regmap_irq_chip_data *irq_data; + struct irq_domain *domain; + int ret; + unsigned int pmic_rev_value; + enum max77705_hw_rev pmic_rev; + + max77705 = devm_kzalloc(&i2c->dev, sizeof(*max77705), GFP_KERNEL); + if (!max77705) + return -ENOMEM; + + max77705->i2c = i2c; + max77705->dev = &i2c->dev; + max77705->irq = i2c->irq; + max77705->type = TYPE_MAX77705; + i2c_set_clientdata(i2c, max77705); + + max77705->regmap = devm_regmap_init_i2c(i2c, &max77705_regmap_config); + if (IS_ERR(max77705->regmap)) + return PTR_ERR(max77705->regmap); + + if (regmap_read(max77705->regmap, MAX77705_PMIC_REG_PMICREV, &pmic_rev_value) < 0) + return -ENODEV; + + pmic_rev = pmic_rev_value & MAX77705_REVISION_MASK; + if (pmic_rev != MAX77705_PASS3) + return dev_err_probe(max77705->dev, -ENODEV, + "Rev.0x%x is not tested\n", pmic_rev); + + max77705->regmap_leds = devm_regmap_init_i2c(i2c, &max77705_leds_regmap_config); + if (IS_ERR(max77705->regmap_leds)) + return dev_err_probe(max77705->dev, PTR_ERR(max77705->regmap_leds), + "Failed to register leds regmap\n"); + + ret = devm_regmap_add_irq_chip(max77705->dev, max77705->regmap, + max77705->irq, + IRQF_ONESHOT | IRQF_SHARED, 0, + &max77705_topsys_irq_chip, + &irq_data); + if (ret) + return dev_err_probe(max77705->dev, ret, "Failed to add irq chip\n"); + + /* Unmask interrupts from all blocks in interrupt source register */ + ret = regmap_update_bits(max77705->regmap, + MAX77705_PMIC_REG_INTSRC_MASK, + MAX77705_SRC_IRQ_ALL, (unsigned int)~MAX77705_SRC_IRQ_ALL); + if (ret < 0) + return dev_err_probe(max77705->dev, ret, + "Could not unmask interrupts in INTSRC\n"); + + domain = regmap_irq_get_domain(irq_data); + + ret = devm_mfd_add_devices(max77705->dev, PLATFORM_DEVID_NONE, + max77705_devs, ARRAY_SIZE(max77705_devs), + NULL, 0, domain); + if (ret) + return dev_err_probe(max77705->dev, ret, "Failed to register child devices\n"); + + device_init_wakeup(max77705->dev, true); + + return 0; +} + +static int max77705_suspend(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + struct max77693_dev *max77705 = i2c_get_clientdata(i2c); + + disable_irq(max77705->irq); + + if (device_may_wakeup(dev)) + enable_irq_wake(max77705->irq); + + return 0; +} + +static int max77705_resume(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + struct max77693_dev *max77705 = i2c_get_clientdata(i2c); + + if (device_may_wakeup(dev)) + disable_irq_wake(max77705->irq); + + enable_irq(max77705->irq); + + return 0; +} +DEFINE_SIMPLE_DEV_PM_OPS(max77705_pm_ops, max77705_suspend, max77705_resume); + +static const struct of_device_id max77705_i2c_of_match[] = { + { .compatible = "maxim,max77705" }, + { } +}; +MODULE_DEVICE_TABLE(of, max77705_i2c_of_match); + +static struct i2c_driver max77705_i2c_driver = { + .driver = { + .name = "max77705", + .of_match_table = max77705_i2c_of_match, + .pm = pm_sleep_ptr(&max77705_pm_ops), + .suppress_bind_attrs = true, + }, + .probe = max77705_i2c_probe +}; +module_i2c_driver(max77705_i2c_driver); + +MODULE_DESCRIPTION("Maxim MAX77705 PMIC core driver"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/max77693-common.h b/include/linux/mfd/max77693-common.h index a5bce099f1ed..ec2e1b2dceb8 100644 --- a/include/linux/mfd/max77693-common.h +++ b/include/linux/mfd/max77693-common.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Common data shared between Maxim 77693 and 77843 drivers + * Common data shared between Maxim 77693, 77705 and 77843 drivers * * Copyright (C) 2015 Samsung Electronics */ @@ -11,6 +11,7 @@ enum max77693_types { TYPE_MAX77693_UNKNOWN, TYPE_MAX77693, + TYPE_MAX77705, TYPE_MAX77843, TYPE_MAX77693_NUM, @@ -32,6 +33,7 @@ struct max77693_dev { struct regmap *regmap_muic; struct regmap *regmap_haptic; /* Only MAX77693 */ struct regmap *regmap_chg; /* Only MAX77843 */ + struct regmap *regmap_leds; /* Only MAX77705 */ struct regmap_irq_chip_data *irq_data_led; struct regmap_irq_chip_data *irq_data_topsys; diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h new file mode 100644 index 000000000000..e4309d3b6f2a --- /dev/null +++ b/include/linux/mfd/max77705-private.h @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Maxim MAX77705 definitions. + * + * Copyright (C) 2015 Samsung Electronics, Inc. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#ifndef __LINUX_MFD_MAX77705_PRIV_H +#define __LINUX_MFD_MAX77705_PRIV_H + +#define MAX77705_SRC_IRQ_CHG BIT(0) +#define MAX77705_SRC_IRQ_TOP BIT(1) +#define MAX77705_SRC_IRQ_FG BIT(2) +#define MAX77705_SRC_IRQ_USBC BIT(3) +#define MAX77705_SRC_IRQ_ALL (MAX77705_SRC_IRQ_CHG | MAX77705_SRC_IRQ_TOP | \ + MAX77705_SRC_IRQ_FG | MAX77705_SRC_IRQ_USBC) + +/* MAX77705_PMIC_REG_PMICREV register */ +#define MAX77705_VERSION_SHIFT 3 +#define MAX77705_REVISION_MASK GENMASK(2, 0) +#define MAX77705_VERSION_MASK GENMASK(7, MAX77705_VERSION_SHIFT) +/* MAX77705_PMIC_REG_MAINCTRL1 register */ +#define MAX77705_MAINCTRL1_BIASEN_SHIFT 7 +#define MAX77705_MAINCTRL1_BIASEN_MASK BIT(MAX77705_MAINCTRL1_BIASEN_SHIFT) +/* MAX77705_PMIC_REG_MCONFIG2 (haptics) register */ +#define MAX77705_CONFIG2_MEN_SHIFT 6 +#define MAX77705_CONFIG2_MODE_SHIFT 7 +#define MAX77705_CONFIG2_HTYP_SHIFT 5 +/* MAX77705_PMIC_REG_SYSTEM_INT_MASK register */ +#define MAX77705_SYSTEM_IRQ_BSTEN_INT BIT(3) +#define MAX77705_SYSTEM_IRQ_SYSUVLO_INT BIT(4) +#define MAX77705_SYSTEM_IRQ_SYSOVLO_INT BIT(5) +#define MAX77705_SYSTEM_IRQ_TSHDN_INT BIT(6) +#define MAX77705_SYSTEM_IRQ_TM_INT BIT(7) + +enum max77705_hw_rev { + MAX77705_PASS1 = 1, + MAX77705_PASS2, + MAX77705_PASS3 +}; + +enum max77705_reg { + MAX77705_PMIC_REG_PMICID1 = 0x00, + MAX77705_PMIC_REG_PMICREV = 0x01, + MAX77705_PMIC_REG_MAINCTRL1 = 0x02, + MAX77705_PMIC_REG_BSTOUT_MASK = 0x03, + MAX77705_PMIC_REG_FORCE_EN_MASK = 0x08, + MAX77705_PMIC_REG_MCONFIG = 0x10, + MAX77705_PMIC_REG_MCONFIG2 = 0x11, + MAX77705_PMIC_REG_INTSRC = 0x22, + MAX77705_PMIC_REG_INTSRC_MASK = 0x23, + MAX77705_PMIC_REG_SYSTEM_INT = 0x24, + MAX77705_PMIC_REG_RESERVED_25 = 0x25, + MAX77705_PMIC_REG_SYSTEM_INT_MASK = 0x26, + MAX77705_PMIC_REG_RESERVED_27 = 0x27, + MAX77705_PMIC_REG_RESERVED_28 = 0x28, + MAX77705_PMIC_REG_RESERVED_29 = 0x29, + MAX77705_PMIC_REG_BOOSTCONTROL1 = 0x4C, + MAX77705_PMIC_REG_BOOSTCONTROL2 = 0x4F, + MAX77705_PMIC_REG_SW_RESET = 0x50, + MAX77705_PMIC_REG_USBC_RESET = 0x51, + + MAX77705_PMIC_REG_END +}; + +enum max77705_chg_reg { + MAX77705_CHG_REG_BASE = 0xB0, + MAX77705_CHG_REG_INT = 0, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHG_REG_INT_OK, + MAX77705_CHG_REG_DETAILS_00, + MAX77705_CHG_REG_DETAILS_01, + MAX77705_CHG_REG_DETAILS_02, + MAX77705_CHG_REG_DTLS_03, + MAX77705_CHG_REG_CNFG_00, + MAX77705_CHG_REG_CNFG_01, + MAX77705_CHG_REG_CNFG_02, + MAX77705_CHG_REG_CNFG_03, + MAX77705_CHG_REG_CNFG_04, + MAX77705_CHG_REG_CNFG_05, + MAX77705_CHG_REG_CNFG_06, + MAX77705_CHG_REG_CNFG_07, + MAX77705_CHG_REG_CNFG_08, + MAX77705_CHG_REG_CNFG_09, + MAX77705_CHG_REG_CNFG_10, + MAX77705_CHG_REG_CNFG_11, + + MAX77705_CHG_REG_CNFG_12, + MAX77705_CHG_REG_CNFG_13, + MAX77705_CHG_REG_CNFG_14, + MAX77705_CHG_REG_SAFEOUT_CTRL +}; + +enum max77705_fuelgauge_reg { + STATUS_REG = 0x00, + VALRT_THRESHOLD_REG = 0x01, + TALRT_THRESHOLD_REG = 0x02, + SALRT_THRESHOLD_REG = 0x03, + REMCAP_REP_REG = 0x05, + SOCREP_REG = 0x06, + TEMPERATURE_REG = 0x08, + VCELL_REG = 0x09, + TIME_TO_EMPTY_REG = 0x11, + FULLSOCTHR_REG = 0x13, + CURRENT_REG = 0x0A, + AVG_CURRENT_REG = 0x0B, + SOCMIX_REG = 0x0D, + SOCAV_REG = 0x0E, + REMCAP_MIX_REG = 0x0F, + FULLCAP_REG = 0x10, + RFAST_REG = 0x15, + AVR_TEMPERATURE_REG = 0x16, + CYCLES_REG = 0x17, + DESIGNCAP_REG = 0x18, + AVR_VCELL_REG = 0x19, + TIME_TO_FULL_REG = 0x20, + CONFIG_REG = 0x1D, + ICHGTERM_REG = 0x1E, + REMCAP_AV_REG = 0x1F, + FULLCAP_NOM_REG = 0x23, + LEARN_CFG_REG = 0x28, + FILTER_CFG_REG = 0x29, + MISCCFG_REG = 0x2B, + QRTABLE20_REG = 0x32, + FULLCAP_REP_REG = 0x35, + RCOMP_REG = 0x38, + VEMPTY_REG = 0x3A, + FSTAT_REG = 0x3D, + DISCHARGE_THRESHOLD_REG = 0x40, + QRTABLE30_REG = 0x42, + ISYS_REG = 0x43, + DQACC_REG = 0x45, + DPACC_REG = 0x46, + AVGISYS_REG = 0x4B, + QH_REG = 0x4D, + VSYS_REG = 0xB1, + TALRTTH2_REG = 0xB2, + VBYP_REG = 0xB3, + CONFIG2_REG = 0xBB, + IIN_REG = 0xD0, + OCV_REG = 0xEE, + VFOCV_REG = 0xFB, + VFSOC_REG = 0xFF, + + MAX77705_FG_END +}; + +enum max77705_led_reg { + MAX77705_RGBLED_REG_BASE = 0x30, + MAX77705_RGBLED_REG_LEDEN = 0, + MAX77705_RGBLED_REG_LED0BRT, + MAX77705_RGBLED_REG_LED1BRT, + MAX77705_RGBLED_REG_LED2BRT, + MAX77705_RGBLED_REG_LED3BRT, + MAX77705_RGBLED_REG_LEDRMP, + MAX77705_RGBLED_REG_LEDBLNK, + MAX77705_LED_REG_END +}; + +enum max77705_charger_battery_state { + MAX77705_BATTERY_NOBAT, + MAX77705_BATTERY_PREQUALIFICATION, + MAX77705_BATTERY_DEAD, + MAX77705_BATTERY_GOOD, + MAX77705_BATTERY_LOWVOLTAGE, + MAX77705_BATTERY_OVERVOLTAGE, + MAX77705_BATTERY_RESERVED +}; + +enum max77705_charger_charge_type { + MAX77705_CHARGER_CONSTANT_CURRENT = 1, + MAX77705_CHARGER_CONSTANT_VOLTAGE, + MAX77705_CHARGER_END_OF_CHARGE, + MAX77705_CHARGER_DONE +}; + +#endif /* __LINUX_MFD_MAX77705_PRIV_H */ From patchwork Tue Dec 17 17:30:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13912279 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54C2E1FA144; Tue, 17 Dec 2024 17:30:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456651; cv=none; b=duOWSZaDthPd5p4sjGTBflk/Mg/ULJ6tCAPFrzQJBjiwUlfzsBnenZ7TqSJWJa2KKadzwS+Q3sw0u3Co5WCS/3VbUJv+ofEVln/qf+v9qhcM7sLEJboSJWpW+cPmsGikwCSg6Ux5OZVoMV7AuAgmO/+802ad6QvLNAeldOl1Pio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456651; c=relaxed/simple; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lel8Y2LoMEqfBPSKqLa5QJjAUClv8GYaC6JdnBwNyhmiK5+3QnRyjgE5058UBxv/20Qa7wjvlrrRzbb0cXdA+nEsOMac0R5OygahrRuo5BQ0ahYv6rcJQ+Zqp3RZe/1lJqn8znCcE6388LOZ+0VqsYf47BycghbhDTFPrmDiiko= 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=gg7Cf+b1; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gg7Cf+b1" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-aab9e281bc0so560833566b.3; Tue, 17 Dec 2024 09:30:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456648; x=1735061448; 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=gg7Cf+b1BHw2ZfMFNl3sFnJokzNJaRlOnBjBfsIqGLs0EOGdVgQl2YFj3EHNwg/tzN qnfliaHCw1sUrqJp7Y4KRC9576eTuLTMao7PUU+KW0aE8oUNDxj0HMzz2ybo7t0EYA3+ Ba2B2BQE99Uc0JE5xK+jGTP2J0CljtO5uDedc32wv8fgcDS/XA3p4r4yf1edCRqo90t4 vvOOSVGBmOJRSHgWyJA0CRE/v1o1LptxA9mlRumOK0lt3XJSaYM8kDlVbsxQ7qz8ArWA 9s2N+FFIvdndtKRQiIGxOVF2A9gRJWIqFvyACAJewzYjAByjRSPQAnT9jzzlBCMCP5/7 /6xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456648; x=1735061448; 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=MJJ3ps/nMU7h8uKE0Z/mByTKcdB9+tDNW/rctXMN0sQ9o7/tYDvEXp7LHTFf6cQFHS zjfM0s6wMCHBFL1zf+Wwgcu7gRuLxCKvqQ89oDD/66lqpIXsTtJuHKHytKgaIfq7gmDw XfjBKgQjB0oJXK/fnKqHvyxXsNKkmubhZ2HxGYAGte5zqUKDfYK3p/Xnc9B5tl8WJRHr Y3Xk5JDb5BX1ulRK3l8xsERj0VP0qKIe2Ehb6aatoZbFG87BuvTZi7AWWsdnRX5zcif0 rWsy5hueYw0qvyURtmhHgs8ykdf2hekEknLJXN0f5oCnW744EW7ucf8hUuAKRTebHic6 9IcQ== X-Forwarded-Encrypted: i=1; AJvYcCUNTH3MW/kwFFg1cPuq0FLl3RkjGc5KTsDxnRnESNzjjFiJx03obwu5H7OsIb4izAJzerNHn3g+n4Sq@vger.kernel.org, AJvYcCUjJ5V13vn/QoErUNYBkiJ/5cXzIipkNkQIVtEg9OC8eSORh0pPXbdc9vCejMtSPWuyJf2Fg9mQTlS8ljuV@vger.kernel.org, AJvYcCVpMbuxnDQ+zWyYxO+9GQcajE4ahF97UBPixzbi3DBfUE7eyqsB9EYWQ3tPBCnGk9ikAG4QNdDoRqSBmQ==@vger.kernel.org, AJvYcCWLedmw2+mVSn+Kmh/V4kjOTmx3lY2oaKlNnh/AMA1dE67oWRqWMGTmocJOGPktLhpYcsbRPh8iys/eEMQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyCCVklWK0d6014T62SKdue3abtHd88EhhLaVMJ9e0BX/4RBxiI 1JYDOjlgT2lxL4kxURKanGa9Ob+uoOrtvsKDLCRmwBPSHJk62fxU X-Gm-Gg: ASbGnctPFFMGmls/ywWD+jjPet41iv5U1FXEI/Hiyz8CFZV6H3jIHxrRQAL1YHVjWqq OWU1i8EPpmfq5EG1JMu3nyMfIlozmIwT/E82DNkouFwpxp+9P/3VxG2h6Fx7wg1oYh9DCt+s/SY IpnQLfOwqDVDrxjFyvJq9DiQU+uusBt9yPQTpCFpwy+VHcnUgsOuACka/ALybHF/MfzD3eD5f9z 5i6FDi8CzgdkG5KRFs1aRw9OAcg4rXJCNcqyfffNQpW4PUfVWDfCeU= X-Google-Smtp-Source: AGHT+IEgxmMS021zWALktfW0/WeeW1O/TeJwlg8Mpo4YHkquoQmwom2gF6hwY3fps47Aoe/az9TEuQ== X-Received: by 2002:a17:907:3fa7:b0:aa6:8fed:7c15 with SMTP id a640c23a62f3a-aab77959344mr1926500066b.17.1734456647675; Tue, 17 Dec 2024 09:30:47 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:47 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:08 +0300 Subject: [PATCH v12 10/11] input: max77693: add max77705 haptic support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-10-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=4280; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=Rfuhafs6uHguUFNmDxE8iSnOx6rCyPiSTsSr6WCgv7Y=; b=XrbgvSFa95p6bwek9PAO8aQ9cnnXAf8gFi0nBFP6aMUwFpFgleAa8ummKKhdWZWJ4EgjKS7hx d+Y43PyJ2BbDhb2+DjGQdpAUnj/6/JVH3VDsg5yRNeZubwLbbsq267Q 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 Tue Dec 17 17:30:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13912280 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 182661F8689; Tue, 17 Dec 2024 17:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456655; cv=none; b=OPo2d8TFXGCjknORsWkdsfQbze8PPL0Q/YNoMcJlcYTHjWHpLLos3Ity28gwTrxsB0RbuRc4O8F/a/NYaKzXi5EGwkxKa3Zly8SMNlF0ItkHPgRTCKjnLLtf4jJjscPmrLAvGaI8DXkGdD5BSAnM1BSnVgsEHHi77WVnSF6ipGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734456655; c=relaxed/simple; bh=TiZMVvm+8UQ1HC3K3CjkDCmPUVFUo1nd7pXVHRqG4oo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nhoXyawUu+TQaP1pF+E8qcqBl81+T3H+8hZAejFzSSURN9Ieo7vVZuM6gi47DxZjQw5qVSP3+CPLbd+3dpuXKqQNWdeWJQaEsGk05FF8HwGN8L2ckkEiqlL+7YbgqZwPf1zOcfvkhnI6zlUQNbClArEE9/k5a371+CB27nvVK9g= 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=f7WS3U6t; arc=none smtp.client-ip=209.85.208.43 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="f7WS3U6t" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5d3f28a4fccso8442363a12.2; Tue, 17 Dec 2024 09:30:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734456651; x=1735061451; 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=Wz2OSQR8MDKMUuykrxBkoV4TSMXKxe9vrA75hma9NN0=; b=f7WS3U6thz4sboIwcjXC6ijr1UXNeAbJjvmYm11dNmnlb4StpzP4YvtmEtf7zT3Ofd 8724gxeYmY3YMQeILZCLHbLxWtEoarcHCd33+05d7iatV5BGEEs52Jwt2erycBrhP42m AFJn/yOI7zQcAuldYQp6/92zR+xG3BmrvW9T4bJ0E852r8poBORAPt/DxXSnzENEL5VA qDtG0U/rRr7CUv8fVBKQqGnJcYMvUm8pQSgykVDtECli+KGMpHeS0QlFPs+CWH+ZrjUK toAkamgZCXkzCgbDPFmZwjMALCjVVo/cY2mX4gB12zWuqtaelHslv6XZUbijgcm54AEA Mvkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734456651; x=1735061451; 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=Wz2OSQR8MDKMUuykrxBkoV4TSMXKxe9vrA75hma9NN0=; b=hqRxoit6OgEOcGWOhDbpx+xAOerdgTRh29NtL72ji4byVquhEYim4GgblD+bRyq8IM 7p5V65naJp5qlx7b7efRyP+SA3/h54UdneIW76xMh7IpDpOknBiKKQIF+HISnUbGyeiy KqcKlFSeOyBm5KUlE2VeAa51vwsiOv/HNIUcM3lT871SkaCwc2xZQ0mECyNPuP+s8IVe miM/2TYjAiAlPPZ33UZERqm9G2yhcaKO39WtRxGdH2Rz1zSFKVdTiX7CwAD+OtQRWW+F kMZmN+F3IKrcDxqREPRRRpnDQtGs9dJqzURRsdMiGPMXDxiZctW///PQs9OJoppEKYn1 E/6Q== X-Forwarded-Encrypted: i=1; AJvYcCUJ5W0pVbEBkL9l5agSHrkT9MqnGuvGMPs4SFThdB1th5fMH9TZnuj8/SBMQ4J5/motSx2pnLA4OiYraw==@vger.kernel.org, AJvYcCVFVCAWTZ9gSYfzz4h7dcac/KsGubAGCEWg6iI8yHD2CLpwIyh5cwVZN68mQ48wmSCxMP9zVHosy4t/dmQ3@vger.kernel.org, AJvYcCVqJeQAOBVDFPsf7TfplC1b/uiFGNJ6B1ul1V7a1ijRqk0VUvb3Rqs10rjJUUi1K+h6tJDO5XfdHQxm@vger.kernel.org, AJvYcCX2alyuO5JhEsdWctvCItjdVwsNY2cmkxE5jiFOnNzrikb78zOLaG0XI2mE8HG1GdIi7l53ZKPe8MTDjoI=@vger.kernel.org X-Gm-Message-State: AOJu0YzF4IqFy/XSs4S1IovcbofPQtkUYMk9lj2FnctVNIapRUjjxg3T X/35SbEQgzUuwTjahfjjLA8n5LoAXOo02DLNUPXwXeqIso4EhR7U3xBN8g== X-Gm-Gg: ASbGnct9NtDESOxySNTy06W/fT1n0uzaoxA3zTaORmdawW0hdocoDqQKkh/bwSWYqHv Zs5CH6I7ujoEyAiIONvnf8SPtKrhrQRLubXARSobP+MHUUm92tPkWLuc9AJmzyp9rQ+to7jDks8 yIvn6FMGD3X6hvh346ZW0nqWEJmFbx366qz5AQFsxQKGs0NrvQbOPYk85aPp4DQEQS22sHV+ZvV 7CtHIRhcHuv1gwPrGly5SGBVSwg9OY+6nxf0U8+e/JZSI+gyHwGogM= X-Google-Smtp-Source: AGHT+IEiS8Z4L4SSyoGV4OrCB9URCPRX2dLT92jICNvvUa5aqi0PzQv3oXCEi7CNW4nfGjlBPwKsPA== X-Received: by 2002:a17:906:4ca:b0:aa6:a9fe:46dd with SMTP id a640c23a62f3a-aab77ea53d7mr1861991966b.38.1734456649710; Tue, 17 Dec 2024 09:30:49 -0800 (PST) Received: from [127.0.1.1] ([46.53.242.72]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aab95d813afsm470444166b.0.2024.12.17.09.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 09:30:48 -0800 (PST) From: Dzmitry Sankouski Date: Tue, 17 Dec 2024 20:30:09 +0300 Subject: [PATCH v12 11/11] leds: max77705: Add LEDs support Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241217-starqltechn_integration_upstream-v12-11-ed840944f948@gmail.com> References: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> In-Reply-To: <20241217-starqltechn_integration_upstream-v12-0-ed840944f948@gmail.com> To: Sebastian Reichel , Chanwoo Choi , Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Dmitry Torokhov , Pavel Machek , Hans de Goede , Marek Szyprowski , Sebastian Krzyszkowiak , Purism Kernel Team , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-input@vger.kernel.org, linux-leds@vger.kernel.org, Dzmitry Sankouski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1734456632; l=12909; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=TiZMVvm+8UQ1HC3K3CjkDCmPUVFUo1nd7pXVHRqG4oo=; b=VVoBJT/UHQf9OwsXKlQGMHLYFfkozC3/Cv0W1MXSi5mjz1KH2Zg1EhBQALyDGBVQqRaMQFzmV yeaMmaduNwBCkFgkXgF8uI3Y1lVuYj/OIfD5WbKHs8ZkjxzQ2MYDB9U X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= This adds basic support for LEDs for the max77705 PMIC. Signed-off-by: Dzmitry Sankouski --- Changes for v11: - add dependency on led multicolor class Changes for v10: - remove multiple line break - replace en_shift, reg_brightness values with macros - add support for leds-class-multicolor (inspired from leds-qcom-lpg.c): - replace max77705_to_led helper with container_of, because it's no longer covers all cases - add max77705_add_led, max77705_parse_subled functions to parse device tree - split max77705_led_brightness_set into *multi and *single versions Changes for v8: - join line where possible to fit in 100 chars - change comment style C++ -> C Changes for v6: - change compatible suffix to 'rgb' - remove I2C dependency in Kconfig - remove copyright and author from 'based on' header statement - replace MFD abbreviation with PMIC - MAINTAINERS: alphabetic order - max77705_rgb_blink: replace ternary operators with if..else if sequence - max77705_rgb_blink: move hardcoded numbers to constants - max77705_led_brightness_set: move ret to the bottom - s/map/regmap - replace device_for_each_child_node with scoped version - s/rv/ret Changes for v5: - use same hardware name in Kconfig and module descriptions - remove copyrighter owner from module authors Changes in v4: - inline BLINK_(ON|OFF) macro - remove camel case - drop backwards compatibility(new driver) - drop module alias --- MAINTAINERS | 1 + drivers/leds/Kconfig | 8 ++++++++ drivers/leds/Makefile | 1 + drivers/leds/leds-max77705.c | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77705-private.h | 17 +++++++++++++++++ 5 files changed, 294 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 587570b12306..d21afe41ff6c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14237,6 +14237,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..4b69676d8206 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -753,6 +753,14 @@ config LEDS_MAX77650 help LEDs driver for MAX77650 family of PMICs from Maxim Integrated. +config LEDS_MAX77705 + tristate "LED support for Maxim MAX77705 PMIC" + depends on MFD_MAX77705 + depends on LEDS_CLASS + depends on LEDS_CLASS_MULTICOLOR + help + LED driver for MAX77705 PMIC from Maxim Integrated. + config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 18afbb5a23ee..096bf244527d 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -60,6 +60,7 @@ obj-$(CONFIG_LEDS_LP8860) += leds-lp8860.o obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o obj-$(CONFIG_LEDS_MAX5970) += leds-max5970.o obj-$(CONFIG_LEDS_MAX77650) += leds-max77650.o +obj-$(CONFIG_LEDS_MAX77705) += leds-max77705.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c new file mode 100644 index 000000000000..15fa4b3cbcd6 --- /dev/null +++ b/drivers/leds/leds-max77705.c @@ -0,0 +1,267 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on leds-max77650 driver + * + * LED driver for MAXIM 77705 PMIC. + * Copyright (C) 2024 Dzmitry Sankouski + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MAX77705_LED_NUM_LEDS 4 +#define MAX77705_LED_EN_MASK GENMASK(1, 0) +#define MAX77705_LED_MAX_BRIGHTNESS 0xff +#define MAX77705_LED_EN_SHIFT(reg) (reg * MAX77705_RGBLED_EN_WIDTH) +#define MAX77705_LED_REG_BRIGHTNESS(reg) (reg + MAX77705_RGBLED_REG_LED0BRT) + +struct max77705_led { + struct led_classdev cdev; + struct led_classdev_mc mcdev; + struct regmap *regmap; + + struct mc_subled *subled_info; +}; + +static int max77705_rgb_blink(struct led_classdev *cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct max77705_led *led = container_of(cdev, struct max77705_led, cdev); + int value, on_value, off_value; + + if (*delay_on < MAX77705_RGB_DELAY_100_STEP) + on_value = 0; + else if (*delay_on < MAX77705_RGB_DELAY_100_STEP_LIM) + on_value = *delay_on / MAX77705_RGB_DELAY_100_STEP - 1; + else if (*delay_on < MAX77705_RGB_DELAY_250_STEP_LIM) + on_value = (*delay_on - MAX77705_RGB_DELAY_100_STEP_LIM) / + MAX77705_RGB_DELAY_250_STEP + + MAX77705_RGB_DELAY_100_STEP_COUNT; + else + on_value = 15; + + on_value <<= 4; + + if (*delay_off < 1) + off_value = 0; + else if (*delay_off < MAX77705_RGB_DELAY_500_STEP) + off_value = 1; + else if (*delay_off < MAX77705_RGB_DELAY_500_STEP_LIM) + off_value = *delay_off / MAX77705_RGB_DELAY_500_STEP; + else if (*delay_off < MAX77705_RGB_DELAY_1000_STEP_LIM) + off_value = (*delay_off - MAX77705_RGB_DELAY_1000_STEP_LIM) / + MAX77705_RGB_DELAY_1000_STEP + + MAX77705_RGB_DELAY_500_STEP_COUNT; + else if (*delay_off < MAX77705_RGB_DELAY_2000_STEP_LIM) + off_value = (*delay_off - MAX77705_RGB_DELAY_2000_STEP_LIM) / + MAX77705_RGB_DELAY_2000_STEP + + MAX77705_RGB_DELAY_1000_STEP_COUNT; + else + off_value = 15; + + value = on_value | off_value; + return regmap_write(led->regmap, MAX77705_RGBLED_REG_LEDBLNK, value); +} + +static int max77705_led_brightness_set(struct regmap *regmap, struct mc_subled *subled, + int num_colors) +{ + int ret; + + for (int i = 0; i < num_colors; i++) { + unsigned int channel, brightness; + + channel = subled[i].channel; + brightness = subled[i].brightness; + + if (brightness == LED_OFF) { + /* Flash OFF */ + ret = regmap_update_bits(regmap, + MAX77705_RGBLED_REG_LEDEN, + MAX77705_LED_EN_MASK << MAX77705_LED_EN_SHIFT(channel), 0); + } else { + /* Set current */ + ret = regmap_write(regmap, MAX77705_LED_REG_BRIGHTNESS(channel), + brightness); + if (ret < 0) + return ret; + + ret = regmap_update_bits(regmap, + MAX77705_RGBLED_REG_LEDEN, + LED_ON << MAX77705_LED_EN_SHIFT(channel), + MAX77705_LED_EN_MASK << MAX77705_LED_EN_SHIFT(channel)); + } + } + + return ret; +} + +static int max77705_led_brightness_set_single(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct max77705_led *led = container_of(cdev, struct max77705_led, cdev); + + led->subled_info->brightness = brightness; + + return max77705_led_brightness_set(led->regmap, led->subled_info, 1); +} + +static int max77705_led_brightness_set_multi(struct led_classdev *cdev, + enum led_brightness brightness) +{ + struct led_classdev_mc *mcdev = lcdev_to_mccdev(cdev); + struct max77705_led *led = container_of(mcdev, struct max77705_led, mcdev); + + led_mc_calc_color_components(mcdev, brightness); + + return max77705_led_brightness_set(led->regmap, led->mcdev.subled_info, mcdev->num_colors); +} + +static int max77705_parse_subled(struct device *dev, struct fwnode_handle *np, + struct mc_subled *info) +{ + u32 color = LED_COLOR_ID_GREEN; + u32 reg; + int ret; + + ret = fwnode_property_read_u32(np, "reg", ®); + if (ret || !reg || reg >= MAX77705_LED_NUM_LEDS) + return dev_err_probe(dev, -EINVAL, "invalid \"reg\" of %pOFn\n", np); + + info->channel = reg; + + ret = fwnode_property_read_u32(np, "color", &color); + if (ret < 0 && ret != -EINVAL) + return dev_err_probe(dev, ret, + "failed to parse \"color\" of %pOF\n", np); + + info->color_index = color; + + return 0; +} + +static int max77705_add_led(struct device *dev, struct regmap *regmap, struct fwnode_handle *np) +{ + int ret, i = 0; + unsigned int color, reg; + struct max77705_led *led; + struct led_classdev *cdev; + struct mc_subled *info; + struct fwnode_handle *child; + struct led_init_data init_data = {}; + + led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); + if (!led) + return -ENOMEM; + + ret = fwnode_property_read_u32(np, "color", &color); + if (ret < 0 && ret != -EINVAL) + return dev_err_probe(dev, ret, + "failed to parse \"color\" of %pOF\n", np); + + led->regmap = regmap; + init_data.fwnode = np; + + if (color == LED_COLOR_ID_RGB) { + int num_channels = of_get_available_child_count(to_of_node(np)); + + ret = fwnode_property_read_u32(np, "reg", ®); + if (ret || reg >= MAX77705_LED_NUM_LEDS) + ret = -EINVAL; + + info = devm_kcalloc(dev, num_channels, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + cdev = &led->mcdev.led_cdev; + cdev->max_brightness = MAX77705_LED_MAX_BRIGHTNESS; + cdev->brightness_set_blocking = max77705_led_brightness_set_multi; + cdev->blink_set = max77705_rgb_blink; + + fwnode_for_each_available_child_node(np, child) { + ret = max77705_parse_subled(dev, child, &info[i]); + if (ret < 0) + return ret; + + info[i].intensity = 0; + i++; + } + + led->mcdev.subled_info = info; + led->mcdev.num_colors = num_channels; + led->cdev = *cdev; + + ret = devm_led_classdev_multicolor_register_ext(dev, &led->mcdev, &init_data); + if (ret) + return ret; + + ret = max77705_led_brightness_set_multi(&led->cdev, LED_OFF); + if (ret) + return ret; + } else { + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + max77705_parse_subled(dev, np, info); + + led->subled_info = info; + led->cdev.brightness_set_blocking = max77705_led_brightness_set_single; + led->cdev.blink_set = max77705_rgb_blink; + led->cdev.max_brightness = MAX77705_LED_MAX_BRIGHTNESS; + + ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); + if (ret) + return ret; + + ret = max77705_led_brightness_set_single(&led->cdev, LED_OFF); + if (ret) + return ret; + } + + return 0; +} + +static int max77705_led_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct regmap *regmap; + int ret; + + regmap = dev_get_regmap(dev->parent, NULL); + if (!regmap) + return -ENODEV; + + device_for_each_child_node_scoped(dev, child) { + ret = max77705_add_led(dev, regmap, child); + if (ret) + return ret; + } + + return 0; +} + +static const struct of_device_id max77705_led_of_match[] = { + { .compatible = "maxim,max77705-rgb" }, + { } +}; +MODULE_DEVICE_TABLE(of, max77705_led_of_match); + +static struct platform_driver max77705_led_driver = { + .driver = { + .name = "max77705-led", + .of_match_table = max77705_led_of_match, + }, + .probe = max77705_led_probe, +}; +module_platform_driver(max77705_led_driver); + +MODULE_DESCRIPTION("Maxim MAX77705 LED driver"); +MODULE_AUTHOR("Dzmitry Sankouski "); +MODULE_LICENSE("GPL"); diff --git a/include/linux/mfd/max77705-private.h b/include/linux/mfd/max77705-private.h index e4309d3b6f2a..41bc9d1188a9 100644 --- a/include/linux/mfd/max77705-private.h +++ b/include/linux/mfd/max77705-private.h @@ -33,6 +33,23 @@ #define MAX77705_SYSTEM_IRQ_SYSOVLO_INT BIT(5) #define MAX77705_SYSTEM_IRQ_TSHDN_INT BIT(6) #define MAX77705_SYSTEM_IRQ_TM_INT BIT(7) +/* MAX77705_RGBLED_REG_LEDEN register */ +#define MAX77705_RGBLED_EN_WIDTH 2 +/* MAX77705_RGBLED_REG_LEDBLNK register */ +#define MAX77705_RGB_DELAY_100_STEP_LIM 500 +#define MAX77705_RGB_DELAY_100_STEP_COUNT 4 +#define MAX77705_RGB_DELAY_100_STEP 100 +#define MAX77705_RGB_DELAY_250_STEP_LIM 3250 +#define MAX77705_RGB_DELAY_250_STEP 250 +#define MAX77705_RGB_DELAY_500_STEP 500 +#define MAX77705_RGB_DELAY_500_STEP_COUNT 10 +#define MAX77705_RGB_DELAY_500_STEP_LIM 5000 +#define MAX77705_RGB_DELAY_1000_STEP_LIM 8000 +#define MAX77705_RGB_DELAY_1000_STEP_COUNT 13 +#define MAX77705_RGB_DELAY_1000_STEP 1000 +#define MAX77705_RGB_DELAY_2000_STEP 2000 +#define MAX77705_RGB_DELAY_2000_STEP_COUNT 13 +#define MAX77705_RGB_DELAY_2000_STEP_LIM 12000 enum max77705_hw_rev { MAX77705_PASS1 = 1,