From patchwork Fri Jan 17 13:01:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13943290 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 2647C1FF1AA; Fri, 17 Jan 2025 13:01:37 +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=1737118899; cv=none; b=AJ79bAZaPcwpSyZCrThWuM2SmP9Zrj+HOk05x3zvzWcIorErwYmZnmKZ9so3Kom40orzi+pY5Kw7afEVi8HGCJhQ5idgcZ9PzRbZsW6wAyTjNn4Flhxh+N/3LoTM082BNEhNmLV6+y5VsXVIHXJWn4ywmeMLYl9/L2P2oG20/Ts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118899; c=relaxed/simple; bh=ZWC4hTW8OX+rf9YyrITr/fbrivvcEKd/ZFRltutvR5I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WX299Tkk5ugfQeNZ9JkglGmoBNdeLEAvvtcYBzuCPZxW+WaW7WYRP+z9Dwmj5Zu/h1cZB22748ukNc3ZoFJNKv1tLbpzprYkoNGftDLQXExROEOpfTEvgKSPSgJfVLARFuRCI7tw4/FnOP1+AcOhx0x4M06at/vXtN6T01UPcCU= 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=NUA4V6Qy; 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="NUA4V6Qy" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aaf3c3c104fso402784166b.1; Fri, 17 Jan 2025 05:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737118896; x=1737723696; 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=mXFt2Epd/aqgYjad/PpLtB0pMU+3tYAiirkAkrUh6A4=; b=NUA4V6Qysb9rjRXKIqOSNOJNy6gP3FbkjmqnDbyVLSocRRcpKQc8U1RbxOVXj2Qyuw tXUruoPbukP3WzhvoD1D2JRUmDfTBJxvOpHVbgha3KzU0yfurKH/aCY0xpRhzzjmcC/8 fi5T3p86zdXvhI6UXf9GgCaQcfyot9+r0LdBdAz2+LSurB5TX0qUyOAxbBuXNYUIQOB4 N3Vq9WAnftKPCq+lIVcA3AJk56KyiAPMCVLFjGpsJ01+GM5BlKWBQzOJldCRkWncb/Mr 7QyiizrSerVP2/JkWvLiKqxNUsYcNgW03LnmctbpgdjCnlstP5zmDEEpjnalCN3vs+E2 zv+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737118896; x=1737723696; 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=mXFt2Epd/aqgYjad/PpLtB0pMU+3tYAiirkAkrUh6A4=; b=mlM8vMzquvuW7qsdFITVGfNJMC+AoGC6Kj/x2YNG04naclaN/Ph9JikAIjDlcwCbva Mwry8aSeUd5+8kuuZzgXnyIKzRdJyExyA8D2bIMYnM9E29tDGl4bRKl/tdhKu+rvZJEQ ARu2n/teIRO4EnP+WVGAVC/LRacndqam/BzAd+nKj/aYw71ZBtn3dPNkO+KTngkQR0jp Wh27CvoyI7RoSQCdoYdz3nuTTv8cmLKs008FmDAUrfX+TMOV0P6O2Xuv9uRXQxmeL/zi 87rWVyb7Ow0jLG2gRTusC5JBp6OZJABWLoTc/n5wg9fOvDIf+ACBiTdHjMe3RNx8pGV0 lhhA== X-Forwarded-Encrypted: i=1; AJvYcCUcptbqayh1VsMyMdyKdNlZ4fdcc2msrwL5IbRFMZgoRezExtOcQ+8ioSo2XxDLTfeg3ImBkVdQCvZ0mw==@vger.kernel.org, AJvYcCVQGhKCyt0ufllxNOsF7JYw14oZ90M4myVyYTuRM0UvfzWbvtK4kx5fOgqqfn4WpwLJxUThFRTqThvtPcI=@vger.kernel.org, AJvYcCW5EZMsozvL18sWrzutKcUQ13wVmvIw4/NQsHXrptMOZaDIWW9OJfroqrFDMf+BeiW8PxC1dyO6vxK8@vger.kernel.org, AJvYcCW8z8+TO4toxFH4kJcRshIbBIch9nnuURn+SlXP4gg8F77+B1NUKb2xaZiKLgixGeJJAxqGB+/eG3Zh4zsC@vger.kernel.org X-Gm-Message-State: AOJu0YwXMKecuG04I2SeIt1Zudw9+UqdJhPPApg1CaS8QP3CiCAnhUt5 bhBEI/ca4/O3l2lWFsIyYawf3oeETN3oksUzg7uVRL1jZPDMf8U8 X-Gm-Gg: ASbGnctK58msGhxgvGyQbYpcFoLhdP+s44dluA+XYTNzfpmidTb+eyOUzrYfNuXTil+ TuoEc2UUjv4t9TvZaNn650f7Bh0HL4wX7xSqTpyXLURpfvl/1ZwJYYpYPVfy6iZSJ8FmucWWcSR OELzrPd6T+IhVMJmsKCVkq1zGuImWuTvvKjjryaMbLlbXVstNQ/fruMd2VItr43CdZo73QAKiQD SWaUslgjjh4FAjrs2tTzTGgRKZZCk5Ub7v2iOZEZx4wPKWCS6EPD/0/FMr+1C7lhUGgXfYkGex2 35tLWWOtnZMH1GZZGST32j5Jag== X-Google-Smtp-Source: AGHT+IFuxJHn8Hdx+fZq4w0A7yUUyQKN8llsHOTjd+YrJC/QkSKfmI1lQ5EGzWsF5d/tmcjuv8UsFg== X-Received: by 2002:a17:907:da1:b0:aa6:2a17:b54c with SMTP id a640c23a62f3a-ab38b0b90cemr205523366b.6.1737118895838; Fri, 17 Jan 2025 05:01:35 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-ab384d2d69fsm166289166b.79.2025.01.17.05.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:01:35 -0800 (PST) From: Dzmitry Sankouski Date: Fri, 17 Jan 2025 16:01:28 +0300 Subject: [PATCH v16 1/7] 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: <20250117-starqltechn_integration_upstream-v16-1-11afa877276c@gmail.com> References: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@gmail.com> In-Reply-To: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@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 , Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737118892; l=1879; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=ZWC4hTW8OX+rf9YyrITr/fbrivvcEKd/ZFRltutvR5I=; b=c/uiPiAxZNyM96yZI08HPxUovO8lOYeHN1mn/UacwSnaTxnwzZeEG3dhZbK5e5MvVXdL4E+Sh rjVmS31VflXDgqxKc0m2woolglZbC2nIfBKCZQRItoGz3zoa1xxl8I3 X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 charger binding. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Dzmitry Sankouski --- Changes in v14: - fix required children nodes order: reverse reg and compatible - add reviewed trailers --- 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..bce7fabbd9d3 --- /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: + - compatible + - reg + - 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 Fri Jan 17 13:01:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13943291 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38FD01FF7AC; Fri, 17 Jan 2025 13:01:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118901; cv=none; b=mUXzQVNBLmg6AvdqRVoEmTDl+UHux4mKkgDmFZJhu6s6Fq5YQgNQVvtPmWr41i58e9/AMpsn3kkRLmSmjxPCMcPbprs2NEoABPBX6k7KJSeZBpur5JD3ZlszLz2iEUezPFaky+6JducU8J5dLa2relKs40R9fgiJgMem8JlBYrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118901; c=relaxed/simple; bh=s0/CVJn5Z6GB25apRpp3jyDUE+HEG3h8rcgOQY8LjaM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OfqtY3yyLgE9AzSnYBKtu6iY1uHTmiAMLbvpsShONEeDl5T67OtGb1q9PipCH2x6xjK2T0sBXfewGnYJYf+sVylLYhJGjEtrkzioFDbjy4frhosdMIBxjc31WZl1vDp5YJTKa7O+rGvAasfcdpKlrDF5B8mANUjEkOS6S87YyuI= 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=O3omWUm8; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O3omWUm8" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a9e44654ae3so326025166b.1; Fri, 17 Jan 2025 05:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737118898; x=1737723698; 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=udekqa5IGYQ6//30MEBfC3nhcQXiHzNdob8oRA9txmE=; b=O3omWUm8PCEz2zqXwgxN/9TYGhO+QVHdudpWW/xNLGC/YY5bF53Ced+BsLSORthcQR LCoU9ovBLjwAeLmmvEvNqt62vsZ5KDiaviriGyZGES+aNyRFHRAsBfW/Aa7w1bF+BpkP Td2WvTag3IEvOjgkGmLivyP7wltpDi/8GUnlpkpPAj8fVuqFR+l64/oVqZ6O+ShyCuKr CL6ZDAi3VkhCxgYBK2Fl4Ki8GlMEtHtx2LQCQ+c379+0rY3ZyOEqvKfH3/9H12akJwcL LOkpuOeHSyw0Rg7fqsKaxLGn+nUSBjvdkqp1Q7C70e9lrohWdvfc0wqso+kf6tc0jXl/ CsWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737118898; x=1737723698; 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=udekqa5IGYQ6//30MEBfC3nhcQXiHzNdob8oRA9txmE=; b=RgH/mHeACHiLXkGyb1gZScJ7KbgEaJpHVqC1bA/tQmRhralqGPDYMSqy7wSFucZ24L 7VwaoTg0DNWk6Ej8cywBDo33vrrvZZOg7R1B06f+dzxj4cALaPXROEXKfXO4Z6334cJJ tP7e66NDzZUle9fVmKjWyZErr5QmvZpoaxIgdIgdK8IoX1JW0EBCQ8jCmSCrUk9O6Vqh LdjyCq3XWD6X2+IHVZoReVIvi1lcjFN1vERQDEV3OHPYd764xzhlP6F2+a1CzM01EvsF 4BSQHQVFtEY0RNiHhYNaB2XTXnM7Wiu9UgexuNcs8ofbPmlR2U8utfYbVjuqP6kYocdO UoGQ== X-Forwarded-Encrypted: i=1; AJvYcCVGJTIYZWi8ksQrqTaTuHz6IktoyJ2N0+G4zve+vBTW3nHvcQuM+NomnKzT/R9dRFrCe+8XBH/e17tjGroV@vger.kernel.org, AJvYcCVcpMk+StRYxJqMeD9VUzh7o6nzwV7+oYGdv6Rmysq3x5m1Wunuerry4eJDtm9nQHX9165xZ1IODPH8tQ8=@vger.kernel.org, AJvYcCVyKH0bLiWggx28zD9ZSKxmjpEFZt7WbVnTlVkqh7MFT9LUuOrwHqNgyffHIgONMIQA5DibFSlz9ctP@vger.kernel.org, AJvYcCXtEWje+2lph0+5QrSDXcppGCpM97TxrYOMjosWe407CotYQ9g+uB0S/NSz89GZKIG9VZF3ZX/eQ2w1JA==@vger.kernel.org X-Gm-Message-State: AOJu0YyYFy93VFQ4ZflL8Qxu6D5OeaQSBZHNag1KBclmGcF0jI8oCsSM VAq3VVqcpxkFPwhuW0vWMe0b9k5xWnsMfTE14pjPVyPj/ed/kzzv X-Gm-Gg: ASbGncvASfX2Dy9NpGD4Z+7WmpBZuqA4HhdtkWl1mCEQiupByyDBkwtOlISMRAQ8vt2 4nlh1AzwbjcBNylAT9Kf4MPQZYFX19tM9v/nyFZhfSWKqLvoo6E++BbEq0XIBqmcR4vZxK0lHTj w4qKlnbtFbjDZdAbNuXACXDzUSUPI2A22+degh52sgnR+lyF67JC5/ZEwsO9baMbin9VS0yHFEU it7Q7Q6wfdm6moWjxVIhRbCC10r7Uq6qSqMD/nIA+LrqXqqCcX5A3expi07XdPI3VisO1zW1BkZ yD5+IR7LjdQEHP89SQJQZiwVaA== X-Google-Smtp-Source: AGHT+IF/2tW7mX1skotjDF56i5TZwvWrs8uzZSq805YoYHF0vPmt0LBTEpx33iKT2A6M3izTaz+h3w== X-Received: by 2002:a17:907:7b81:b0:aa5:44a8:9ae7 with SMTP id a640c23a62f3a-ab38b3d64e3mr218766366b.47.1737118897250; Fri, 17 Jan 2025 05:01:37 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-ab384d2d69fsm166289166b.79.2025.01.17.05.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:01:36 -0800 (PST) From: Dzmitry Sankouski Date: Fri, 17 Jan 2025 16:01:29 +0300 Subject: [PATCH v16 2/7] dt-bindings: mfd: add maxim,max77705 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250117-starqltechn_integration_upstream-v16-2-11afa877276c@gmail.com> References: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@gmail.com> In-Reply-To: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@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=1737118892; l=6790; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=s0/CVJn5Z6GB25apRpp3jyDUE+HEG3h8rcgOQY8LjaM=; b=5IT9b0bHeUlMnmH3kjpeKeuUK3h4IBtzra3m7MxugkflVn2cFNwG+StkZoc3vTMjmO0EcH/b1 29I/6iT8dNFAQE1DhuX5A9cFY8b7S+Y3lgNNNvWBiDrUT/44A5ekXoD X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add maxim,max77705 binding part, containing leds controller and haptics. Charger and fuel gauge are separate device, thus not included. Reviewed-by: Rob Herring (Arm) Signed-off-by: Dzmitry Sankouski --- Changes in v14: - add reviewed trailers - move "patternProperties" after the "properties:" block Changes in v13: - drop unused address-cells and size-cells properties Changes in v12: - revert: description: mention this is a part - adjust commit message Changes in v12: - move fuelgauge bindings to separate patch because separate device - move charger bindings to separate patch because separate device - description: mention this is a part Changes in v11: - remove reviewed tags because of major changes - none of children are supposed to have addresses, all nodes are unit-less Changes in v10: - leds: replace label with color and function properties - leds: add support for leds-class-multicolor - move fuelgauge node to patternProperties "^fuel-gauge@[0-9a-f]+$" to comply with max17042 binding Changes in v9: - replace max77705 fuel gauge with max17042 - remove monitored battery because not supported by max17042 Changes in v8: - fix leds compatible Changes in v6: - unevaluatedProperties must be false - drop excessive sentence from description, just describe the device - change leds compatible to maxim,max77705-rgb Changes in v5: - formatting changes - add unevaluatedProperties: false for nodes referencing common schemas - remove additionalProperties on nodes with unevaluatedProperties: false - add min and max to led index Changes in v4: - change dts example intendation from tabs to spaces - remove interrupt-names property - remove obvious reg description - split long(>80) lines --- Documentation/devicetree/bindings/mfd/maxim,max77705.yaml | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 159 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..0ec89f0adc64 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/maxim,max77705.yaml @@ -0,0 +1,158 @@ +# 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 + + 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. + + 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 + + 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"; + + 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 6e04c83eb5cb..08a9548cd49c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14184,6 +14184,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 Fri Jan 17 13:01:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13943292 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA2A41FFC4D; Fri, 17 Jan 2025 13:01:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118903; cv=none; b=Bzgql1WYHMtGXIoHEMb7AVRPrN0kRP0AJfRMA3AQh1/LD0mi5gCnVG+Ded5nfd8WMmcf0ddAvMmBoycHfzDGIBtqkq3d7Eyl1vRjs4KrCJxjd+/l05ieXflw5sDbvQjwWVHf3nK2tlPJeuv2715RI7CwTWa06NIKwrtML+lsmTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118903; c=relaxed/simple; bh=drGuKYBczYigOqpz5WbXyy7RX56j5p0Vni1Ru1Tdt1Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B4vC0foZcM+/YPE3MnyfE37zOsjGJcpteORz//+XJdIYn41SESao/rXikuHrDVPNlokkoMEixs1AvUxaourc84hF9tm85OC2qQX/GKPQrjfsh9T4xL+YSowmArRGOsqqQbng2wlu5fwjp4f+ge8whQztyyW25B4YxfBLvnnI1lU= 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=fMt1ndtC; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fMt1ndtC" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5d647d5df90so3572460a12.2; Fri, 17 Jan 2025 05:01:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737118899; x=1737723699; 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=si4uiOLw1C4PEZ6HOHWPFzUJPL/ZOvo2nf0QgAdR8Dk=; b=fMt1ndtCVT4xszgi2McUtZQ8El2mupqs08a5lk4raXXCyjhNVhOSGHM/LMZLaOiETJ mFc613Kr9pSWv+7b/R+7JIua1GfNfHrXh9fAQYleaWaIXW/n5KcbxWCvTGUAQ79wEey+ DR3kWgWYpZaaPlPPscz9rdCL05Nn2qsZnlsKpLAyQzRHiJBA5szDBsm5TevsA12zZrIH Q5kxXQ+3g+mhYSIEH2a+eumfXxE2s2VRqXbW0S6WGyjWDQTrtwlxwHHjnueXnBT2dvCN vdiOmT8vf/DobUTs8Lyp89hdQ13oiL4JjC3Rw3DRYwI6OD6fhvPv+XH1RURSSKoKnYsL +joQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737118899; x=1737723699; 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=si4uiOLw1C4PEZ6HOHWPFzUJPL/ZOvo2nf0QgAdR8Dk=; b=knXN4a65FzOUDFSH+6ji1C2OIkzckAehApYmLr/E6FFAs2rAiX3o/9TgvbJUxokv3x BrM6njKAStzgoi+aGkDrSm1jW6n7X8RvhIaE0HfTWhX25jPVuXX+qBJSpqc13MOKuznp i842B0oJUxqnNbuuNeDaBOiX1w7UcOD9OKUvgPTdsRrYt8fmBDsGqNZh1tAkM8XAtAyX dquGi4Bxe52b2+5tztdnBxtQb2XvYzeS8U8SjiPv/qT3+IUTcqqbn4cCJdjVm6cg8dOL 0fTYtzCJafXUowlxbYvXN5wA2vM/jCQUJ1LLTwXNILgV6QtYLoDgt1VEUa+C4Eay1wYk 6Zlw== X-Forwarded-Encrypted: i=1; AJvYcCW+VPCgf+E/IVHcwe3+XxOI52DOx99c5fE8bgVddbgFNF6WxqL3dNafYcGSZsN5v+228VNrTJyXoRw0unXQ@vger.kernel.org, AJvYcCW1pbR97td5tXRp2K7/6G5c50X4s2PSDW9QO4KLtQ3njOuF8va+L4wbV8q/R0I/O54CorRsKiiGrjQs@vger.kernel.org, AJvYcCWUo7UK8kfd6kOfm4IJnPmnoaAOqaj+5u4Wd5exCKG0WJQx2POzG6P6xpdI8DGUf5ZWURh4PWccMj1XbA==@vger.kernel.org, AJvYcCXtaq1sYJDWAMdYDjoLpDM7FFQkcjyyV5IBHV9tr9pH9ijCnbIb4d7lhFrY2N2WjSPeYPqH3K3mrL6++Dc=@vger.kernel.org X-Gm-Message-State: AOJu0YwMf3FQDwM2NLoMAFVweA6977pW4jRwYjlcqktmlO6GKNOoABZs LWGVmboAAf+CkcPGLHg1W0zQyzjIgZAkZWNG5KdeuaIzkz6Edhry X-Gm-Gg: ASbGncu0YtPbhjkaJz1e6bpwjbpy+JmDJfwGKP9wSVNA5BMGcd7mBAYEV0Hb7TVJ2mK DrbTwSr9/ylwOIPuYbSRqxKln2/52POwic6BGwXZznhV5QAbttSbBf2U/R9flt2GwXapf+Tng/A OsnenjAYFG8cvW/+NMMn8UwCZO2xDC73z8rLee9DmotpUHso8xOTeqgA4T5mwpPtrJ3fVm6dDxt s1inVUrhz4UnIAxchq92HIGRGe+YeCilKYbJnJMlV3eYVahKxqVXHHOBS5Y8+DCcfkN1hFEMjAu qVDwYUc4mw1dZWMYvD5tvx78ww== X-Google-Smtp-Source: AGHT+IGcWLd9Uyl3BMvLUGdkI+nMN3aeFvOjhihGd2OooFrT0lIWN86l5AqfqWOOwttMtxowV1bg/Q== X-Received: by 2002:a17:907:1701:b0:ab3:76fe:e27a with SMTP id a640c23a62f3a-ab38b1665cfmr255411466b.30.1737118898639; Fri, 17 Jan 2025 05:01:38 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-ab384d2d69fsm166289166b.79.2025.01.17.05.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:01:38 -0800 (PST) From: Dzmitry Sankouski Date: Fri, 17 Jan 2025 16:01:30 +0300 Subject: [PATCH v16 3/7] 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: <20250117-starqltechn_integration_upstream-v16-3-11afa877276c@gmail.com> References: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@gmail.com> In-Reply-To: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@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=1737118892; l=30405; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=drGuKYBczYigOqpz5WbXyy7RX56j5p0Vni1Ru1Tdt1Q=; b=BoZaBt+8MOjAfbg0GT8RLIMZlAXsN/zyrMe1WcwX4+Kwsl4d26VRBITvhzvZPTYiFXa1445WK pQ/cle465n+AcOuAwWcaSy/sPHP8v0SdUtDUTGtwV8Kt2V8el4XLjAR 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 v15: - convert mA to uA in get_input_current, [s|g]et_fload_voltage, get_charge_current - fix copyright year - replace pscfg.of_node = dev->of_node to psycfg.fwnode = dev_fwnode(dev); - drop unneeded else - s/INIT_WORK/devm_work_autocancel - move minimum current to MAX77705_CURRENT_CHGIN_MIN constant - move current steps to constants - tested with selftests/power_supply/test_power_supply_properties.sh - see output below the fold 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 tools/testing/selftests/power_supply/test_power_supply_properties.sh: # Testing device max77705-charger ok 34 max77705-charger.exists ok 35 max77705-charger.uevent.NAME ok 36 max77705-charger.sysfs.type ok 37 max77705-charger.uevent.TYPE ok 38 max77705-charger.sysfs.usb_type # SKIP # Reported: '1' () ok 39 max77705-charger.sysfs.online # Reported: '1' () ok 40 max77705-charger.sysfs.present # Reported: 'Charging' ok 41 max77705-charger.sysfs.status ok 42 max77705-charger.sysfs.capacity # SKIP ok 43 max77705-charger.sysfs.capacity_level # SKIP ok 44 max77705-charger.sysfs.model_name # SKIP ok 45 max77705-charger.sysfs.manufacturer # SKIP ok 46 max77705-charger.sysfs.serial_number # SKIP ok 47 max77705-charger.sysfs.technology # SKIP ok 48 max77705-charger.sysfs.cycle_count # SKIP ok 49 max77705-charger.sysfs.scope # SKIP # Reported: '900000' uA (900 mA) ok 50 max77705-charger.sysfs.input_current_limit ok 51 max77705-charger.sysfs.input_voltage_limit # SKIP ok 52 max77705-charger.sysfs.voltage_now # SKIP ok 53 max77705-charger.sysfs.voltage_min # SKIP ok 54 max77705-charger.sysfs.voltage_max # SKIP ok 55 max77705-charger.sysfs.voltage_min_design # SKIP # Reported: '4350000' uV (4.35 V) ok 56 max77705-charger.sysfs.voltage_max_design ok 57 max77705-charger.sysfs.current_now # SKIP ok 58 max77705-charger.sysfs.current_max # SKIP ok 59 max77705-charger.sysfs.charge_now # SKIP ok 60 max77705-charger.sysfs.charge_full # SKIP ok 61 max77705-charger.sysfs.charge_full_design # SKIP ok 62 max77705-charger.sysfs.power_now # SKIP ok 63 max77705-charger.sysfs.energy_now # SKIP ok 64 max77705-charger.sysfs.energy_full # SKIP ok 65 max77705-charger.sysfs.energy_full_design # SKIP ok 66 max77705-charger.sysfs.energy_full_design # SKIP # Totals: pass:27 fail:0 xfail:0 xpass:0 skip:39 error:0 --- drivers/power/supply/Kconfig | 6 ++++ drivers/power/supply/Makefile | 1 + drivers/power/supply/max77705_charger.c | 581 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/power/max77705_charger.h | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 783 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 7b18358f194a..c120d8ed870f 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 b55cc48a4c86..a4669383d53e 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..eec5e9ef795e --- /dev/null +++ b/drivers/power/supply/max77705_charger.c @@ -0,0 +1,581 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on max77650-charger.c + * + * Copyright (C) 2025 Dzmitry Sankouski + * + * Battery charger driver for MAXIM 77705 charger/power-supply. + */ + +#include +#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 = MAX77705_CURRENT_CHGIN_MIN; + else if (reg_data >= MAX77705_CHG_CHGIN_LIM_MASK) + get_current = MAX77705_CURRENT_CHGIN_MAX; + else + get_current = (reg_data + 1) * MAX77705_CURRENT_CHGIN_STEP; + + *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 ? MAX77705_CURRENT_CHGIN_MIN : reg_data * MAX77705_CURRENT_CHG_STEP; + + 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; + int voltage_mv; + struct regmap *regmap = charger->regmap; + + regmap_read(regmap, MAX77705_CHG_REG_CNFG_04, ®_data); + reg_data &= MAX77705_CHG_PRM_MASK; + voltage_mv = reg_data <= 0x04 ? reg_data * 50 + 4000 : + (reg_data - 4) * 10 + 4200; + *val = voltage_mv * 1000; + + 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.fwnode = dev_fwnode(dev); + 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"); + + ret = devm_work_autocancel(dev, &chg->chgin_work, max77705_chgin_isr_work); + if (ret) + return dev_err_probe(dev, ret, "failed to initialize interrupt work\n"); + + max77705_charger_initialize(chg); + + ret = max77705_charger_enable(chg); + if (ret) + return dev_err_probe(dev, ret, "failed to enable charge\n"); + + 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..fdec9af9c541 --- /dev/null +++ b/include/linux/power/max77705_charger.h @@ -0,0 +1,195 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Maxim MAX77705 definitions. + * + * Copyright (C) 2015 Samsung Electronics, Inc. + * Copyright (C) 2025 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 + +/* uA */ +#define MAX77705_CURRENT_CHGIN_STEP 25000 +#define MAX77705_CURRENT_CHG_STEP 50000 +#define MAX77705_CURRENT_CHGIN_MIN 100000 +#define MAX77705_CURRENT_CHGIN_MAX 3200000 + +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 Fri Jan 17 13:01:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13943293 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D811200100; Fri, 17 Jan 2025 13:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118904; cv=none; b=PxdbiA0PrfDb1ciHkgIIbkWrDDvdzu5y9rKwoZzJasxjWWoegbAHPneh5OKlmR+vx9TPQRLY2uYsipAvEJJW12BsPij+GPfCgcLg6ye5Ba+nxvz12CDHoZ6k4hUGALrwS2v2dg9QPodHtLysnKZbLGN8b8M+2lsf3K2Q3cWbFts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118904; c=relaxed/simple; bh=I7mtjfCVJ1O2Vg6443qyW0B5WFDFjRpanCU/ThHHH0E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=keU2JGtdZBofTQHgkvRa4dtJUwLGP51j8m1AekzBsESkQHdpn7XZISxZqYxOvmPeqTCZnxUkuQnQhDWLVYWNqDicxvqRKEEJHWIPDihzeV1awNAPS/ADFndam5LmsvSaTUdyVqt3yBFN1c2SUyWWqMhz420Awn2nkhwGwwQYoAg= 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=PQu1mkSl; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PQu1mkSl" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5d9f0a6adb4so4292764a12.1; Fri, 17 Jan 2025 05:01:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737118901; x=1737723701; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QAsrsTp1vVx4HKavdMezqlK1BcLoKSQ4OHEn1+GzS2A=; b=PQu1mkSllt/Db5gr4TtXGzBHUIJr1ITm4xSmxDpv+l73qVMCUOWHnB1TZsFM1uQdsQ aRnbRWWjiDDevNoKRohZTMJQcxIzEtlhP3XGsD0jDvG+Lqww4/J87XpwN5FkeP/4gEm0 Wft1+aZCZFXu20R7gPxXZOzNWdlx2325SEq+etWxs2XEK40wR1wQlvDNHtpPb8bYXGMP ToBlljrJeYOVFdQOmnnlYAht1fH8kq8J0A8pS8TwbDMHsOfDGcKZPcBN9Mp0Ka9NJnaa NDrFrOZDjA3pKNGE4OvAizsY0EwGpcoL5HH2zuvNyONHyPQ79GY9HmZ5IsMee6WnKUTs Vvyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737118901; x=1737723701; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QAsrsTp1vVx4HKavdMezqlK1BcLoKSQ4OHEn1+GzS2A=; b=w8wfu4MFUUKWUUBAmCtBVg3A+wA2DO1rP8j23yYh3kb5y7aTBgaPLUYegQRhi0XIQw mOeDyn5KIY7LwHoNYlGjhQUlzrdLPCnXP+ZN+hhVmu75PmsrkYU8UL0u2vQu2ERsoqq2 eMU2IpH7koAcXZpSkHW+9GR3NRS8f622LGhtUOKFIZiqU+wjdCr4RCfLk8rvP3BrRwAq fxXgkOWq6p6RLYjnMx5WOR77k4TWTHvy1uYcszDQBxTBfp+NpauwmX6m5Tne8EWmqbuV TdvD2tH4cuu+JSxs9kvibQbT30Y0CJlBcDSezsPGWJrBAY4BxDHmoigLI7ZuYdGsP2RI 5Mqg== X-Forwarded-Encrypted: i=1; AJvYcCULPHW3hqFyaUuW3lJMCvkAyEjP1TD8MSMqW4OCc4F5Z48+gVYLCV4FYmQY9XyjcYq3BS9yLIwAgrErbg==@vger.kernel.org, AJvYcCVZtz7WaGhgHoeyIe68Ho6MEJQa19LVwGJx8SO0FZC2EZCdxJE4g8ttT9sdnJAWk3NMFl0cY9DSsHFOXxu6@vger.kernel.org, AJvYcCVl2oR+AtIwzcsNCSGesU7j009ywPv/nNkEQrM4lPtxAPqjqWtCkQ03ztT/1k6AIAxc7qnVn00COlgg@vger.kernel.org, AJvYcCWxDb6Cd62hNwLiTbM3y2Jo0Y7aYAJpyW/uR+ackARYZl66dOIF1Ikjbg1ysBDRqjiFKnlXCb9NuniQpP8=@vger.kernel.org X-Gm-Message-State: AOJu0YxwnInyLfu2XsQ6eJUJQS2nZ03Jpmq1lEHBNJwy4rG6mNrVZCJU C7TDIlvbH3Kuu6MAv6qCWt8QAenCiFX+jtpoNVI05OH1OlewJ1R1 X-Gm-Gg: ASbGncvER7i5CcYZzcH36kzLDKYkxC+mR9POyZu2Gzul6RYvElLjDakVgmbTDOxFZpf mZQQFTcQwtCJI7x0UbHzI49zaQUGue5KvhdWlTVBTUHgbBtbGrIMOonEhkAB5B2ylrE4AwAecuq zJsmFdGT+KP9PBD9I2SAE3/0Hx9nO6Jo3vwjLZWbZ0JJ8uh+UQKRGe5iDAaZomGGF1V0B04XTBv CPMI/XdzWXStHM+xobkAfLhKND39Z0Uz1KdDvBrnne/jaSkoO/q5J7SnQTp3wXN4vQyavJ3RSKY JGsibcff2saOCPWJql67/09xmQ== X-Google-Smtp-Source: AGHT+IEAckyTOMgZk9zMie+3QTGmiDbVRuLtrBUtSt/jKNocNun+q1jiUIFg+LbTHAX6/1Zvcfcw7w== X-Received: by 2002:a17:907:9691:b0:aa6:519c:ef9a with SMTP id a640c23a62f3a-ab38b3d5ebdmr252695466b.53.1737118899940; Fri, 17 Jan 2025 05:01:39 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-ab384d2d69fsm166289166b.79.2025.01.17.05.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:01:39 -0800 (PST) From: Dzmitry Sankouski Date: Fri, 17 Jan 2025 16:01:31 +0300 Subject: [PATCH v16 4/7] 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: <20250117-starqltechn_integration_upstream-v16-4-11afa877276c@gmail.com> References: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@gmail.com> In-Reply-To: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@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=1737118892; l=1436; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=I7mtjfCVJ1O2Vg6443qyW0B5WFDFjRpanCU/ThHHH0E=; b=E8YhlKkeFkWOcv3MPCSRxBmfpFOHhiKYyrEZ3Q6GRWyZ5+GjdJ6/qVckO/dZbTOOC3OqakKvQ BJeaDrmFcOLA4Ki/DK3ZAn28NNVGrRJYXMxPv1A9Eh+4hpMG3QeAl6c X-Developer-Key: i=dsankouski@gmail.com; a=ed25519; pk=YJcXFcN1EWrzBYuiE2yi5Mn6WLn6L1H71J+f7X8fMag= Add MAX77705 support - fuel gauge and hwmon devices. Hwmon provides charger input and system bus measurements. Signed-off-by: Dzmitry Sankouski --- Changes in v13: - remove compatible from cells - change mfd compatible to match max77705 fuel gauge node --- drivers/mfd/simple-mfd-i2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c index 6eda79533208..22159913bea0 100644 --- a/drivers/mfd/simple-mfd-i2c.c +++ b/drivers/mfd/simple-mfd-i2c.c @@ -83,11 +83,22 @@ static const struct simple_mfd_data maxim_max5970 = { .mfd_cell_size = ARRAY_SIZE(max5970_cells), }; +static const struct mfd_cell max77705_sensor_cells[] = { + { .name = "max77705-battery" }, + { .name = "max77705-hwmon", }, +}; + +static const struct simple_mfd_data maxim_mon_max77705 = { + .mfd_cell = max77705_sensor_cells, + .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), +}; + static const struct of_device_id simple_mfd_i2c_of_match[] = { { .compatible = "kontron,sl28cpld" }, { .compatible = "silergy,sy7636a", .data = &silergy_sy7636a}, { .compatible = "maxim,max5970", .data = &maxim_max5970}, { .compatible = "maxim,max5978", .data = &maxim_max5970}, + { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, {} }; MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match); From patchwork Fri Jan 17 13:01:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13943294 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EE46200BB2; Fri, 17 Jan 2025 13:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118906; cv=none; b=nMmfhPUG39iU6EU8dn8Bk/K5ibbcn+tjr0EvxuF9BKx/UkJ/HHEF5i5TDhPhCedhdHzPL1UuFCQdhihmVHEkISPeSdkaeGtgn6dX55mKTLFtSLMsJ4ImP6+bOsXEYRD+ii4RnU8x4+RVxFgtqUeo7kM0kQv77JVoPO/PXqn38RI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118906; c=relaxed/simple; bh=CUzrF/qNqKFHNTJ8HrHJ6OA6neylQBhw/NBp5HPk1XU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GsYDUEkIUHTfy22BC/ytn3JLatD3G2k/kFIzPQpafzBuon3GXArK2j2WHuMnBYwdhOIiVm7w89eCvG3lWolB7RnVw7TgEqTzyhHUbMNWx2AdT6UY36f/4Yfs5KXaK0UJCuz5eqQCUZbsPruPRL51EXkCSg41/i0JnePkKJ86aR0= 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=OXBbDYf/; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OXBbDYf/" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-aaeec07b705so395980766b.2; Fri, 17 Jan 2025 05:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737118902; x=1737723702; 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=jmIeQtv9q2JTlBTq8ytov0FR/ePflY96XhsxqekD5Fc=; b=OXBbDYf/X03a0xGw7QRHEc2wlD2zqIjd7buWS+zN6jRr7qQSPDhnH6QmsMBFA3ejwR GEwgLPL0tuIJ58r3QSbAvHTtEgDg/VTJKxt/E/ioK3iodYFHw4wKktaamUxDApiPAT0R ThFNncZbBO07M48W2jgmD6IkVpKkTasFz6suCeWWMQ6Ns8fh6fajewtetD3vu3TlwFDk 1vyXYTLbFv7z9ECpNVaoWgislbiOaKoIuuJhqSkHr/LxVoMrE2OiECPc4T/CmFvp/IfQ IKqCyRn8oPnVMYydlayY/V5VTXsHRAjJPpolrf20AxHfFC2IXQk0JsbUoAKoSqJGyUml XdzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737118902; x=1737723702; 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=jmIeQtv9q2JTlBTq8ytov0FR/ePflY96XhsxqekD5Fc=; b=RSSOZx7msZDfq+96iNc39WXe7kWHCR7OCBFBKNcRAL34jN3hzjbndHteDKbSJG03Du OxGnEbALmvrGUBfIypdb3yR/IeOKnFeLp74s9Xo3YOt6y/YH6iUpSEzsglR4wp8MqLSb dwjz2vXIWrsFmqxdGP8KFwgxxO+bqhb2opazkDVRo3Xf861rtkfnbELd91WV09DioAD5 mCRX9u/8oEMwpe0J3UT/9Ds+IDHGY0VFnmjrxKZwTItIXAg7B5qCgUe+U7cN7rbW0+1R Px8ekX+qP52fdOWkOHCYh53et4P/nQB7c8ZJttbzkAYi1DHvz5zYuTnIyElgjnrhyNts L5xA== X-Forwarded-Encrypted: i=1; AJvYcCV/JFbcvfHfXOg0hA7dQCeVEjBeCjc9GPFOw9siHlF+k5P9I3bOlEjAhCex2oTHrJOyDSsii/7ynhqLbsaH@vger.kernel.org, AJvYcCW0AE3ML00byHkc+UDXvxJtVZdzHeBGcM45/EozUwj5MGPUtjx7M1ij9UdZMbgfg88Gs/aqOxYcY4cR@vger.kernel.org, AJvYcCWLvGBDOYl/Q6R/21sUwhnEU3BSuuWD3v3oXTo4jF+YS80Hb5vo93V6RrCwqCvK5gpCTPM8ahu7+/jTj/Q=@vger.kernel.org, AJvYcCWR1ZLN6xCg4HnoZqBXiHpIdQLp6l9jeiWRuxVa+3rRTUGtotUJkaKzbA9wMR86sqrFAmxk5BYeAX36Tw==@vger.kernel.org X-Gm-Message-State: AOJu0Yxds7Nnc3TUsAL/wYVdryvnb0PvssPXq6P4abISVjLKNKfRZpJw iKEGGToXSPPtn9OF5maqhtDqAuC9IGPIWsTy+OTS7FWghBIrERVS X-Gm-Gg: ASbGncud6YgiRa8TnLizsa26o/Byae07iUKWm7yNNDKtJIIK+O9mXWEi7YAZFf+ROWE cN0oD9j+cdU/Qum2y8CzO4MRGf2RnlpukF/vxUtKe+Ivrj2ZYLirjU8DPJeQi3vX6usgGSleajf G8sl4uq+g75uOU1Q2Y/jiC0DCCUzK3nSemEVvtYbPoPAWzpvnOLdd9nbs9ftgmF5cSO1aImS9C3 DTLAdJ5vDInwWk4mPCBDlhQ5kVvPGmPNnb/OT0/jpX/jAwZp5YvyrpEWrzAszXc2SS+aOAWUew5 BebUhGlPkX3ze77jtJbGDr+UFg== X-Google-Smtp-Source: AGHT+IHIETZySw2NUOQNv8XeRTEX8z6jUW41MYDJ+xBdOHwzlVnEWMDvo2NUguTwTxYcCPHF4XarDQ== X-Received: by 2002:a17:907:9710:b0:aa6:a21b:2a9 with SMTP id a640c23a62f3a-ab38b3e2ed0mr272918466b.57.1737118901258; Fri, 17 Jan 2025 05:01:41 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-ab384d2d69fsm166289166b.79.2025.01.17.05.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:01:40 -0800 (PST) From: Dzmitry Sankouski Date: Fri, 17 Jan 2025 16:01:32 +0300 Subject: [PATCH v16 5/7] 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: <20250117-starqltechn_integration_upstream-v16-5-11afa877276c@gmail.com> References: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@gmail.com> In-Reply-To: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@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=1737118892; l=18532; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=CUzrF/qNqKFHNTJ8HrHJ6OA6neylQBhw/NBp5HPk1XU=; b=itSeexPkeUrn7E3ufZz7pRWw6LcGJwe6KKCdwWJ2EJzIiNF7tAJNfdEpEdDXfabrVWjMOh8kh Tt7cav+RfNaDkWkmMgJ8pDqZJ/PAKdSVkQHy7qr/1tL2pN33K6gDPUT 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 v16: - remove suppress_bind_attrs = true, because not core SoC components - remove wrong unused s2dos05 entry in Makefile Changes for v15: - leave C++ style comments only for the SPDX - update the copyright date - Use MFD_CELL_OF() - remove empty line - remove the double spaces - remove the superfluous tab - reorder variables in max77705_i2c_probe - do not populate max77705->dev and max77705->irq as they can be retrieved from i2c_client - take the function all out of the if statement - place dev into a local variable and save yourself lots of chars each time - join lines in log statements - s/irq/IRQ - use i2c->irq instead of max77705->irq in suspend/resume - move led regmap creation to LED driver 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 | 1 + drivers/mfd/max77705.c | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-common.h | 4 +++- include/linux/mfd/max77705-private.h | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 379 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 08a9548cd49c..705458b6e0ad 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14191,6 +14191,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 @@ -14198,6 +14199,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..8247d655fd31 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 diff --git a/drivers/mfd/max77705.c b/drivers/mfd/max77705.c new file mode 100644 index 000000000000..60c457c21d95 --- /dev/null +++ b/drivers/mfd/max77705.c @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Maxim MAX77705 PMIC core driver + * + * Copyright (C) 2025 Dzmitry Sankouski + **/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct mfd_cell max77705_devs[] = { + MFD_CELL_OF("max77705-rgb", NULL, NULL, 0, 0, "maxim,max77705-rgb"), + MFD_CELL_OF("max77705-charger", NULL, NULL, 0, 0, "maxim,max77705-charger"), + MFD_CELL_OF("max77705-haptic", NULL, NULL, 0, 0, "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_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 device *dev = &i2c->dev; + struct max77693_dev *max77705; + struct regmap_irq_chip_data *irq_data; + struct irq_domain *domain; + enum max77705_hw_rev pmic_rev; + unsigned int pmic_rev_value; + int ret; + + max77705 = devm_kzalloc(dev, sizeof(*max77705), GFP_KERNEL); + if (!max77705) + return -ENOMEM; + + max77705->i2c = i2c; + 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); + + ret = regmap_read(max77705->regmap, MAX77705_PMIC_REG_PMICREV, &pmic_rev_value); + if (ret < 0) + return -ENODEV; + + pmic_rev = pmic_rev_value & MAX77705_REVISION_MASK; + if (pmic_rev != MAX77705_PASS3) + return dev_err_probe(dev, -ENODEV, "Rev.0x%x is not tested\n", pmic_rev); + + ret = devm_regmap_add_irq_chip(dev, max77705->regmap, + i2c->irq, + IRQF_ONESHOT | IRQF_SHARED, 0, + &max77705_topsys_irq_chip, + &irq_data); + if (ret) + return dev_err_probe(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(dev, ret, "Could not unmask interrupts in INTSRC\n"); + + domain = regmap_irq_get_domain(irq_data); + + ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, + max77705_devs, ARRAY_SIZE(max77705_devs), + NULL, 0, domain); + if (ret) + return dev_err_probe(dev, ret, "Failed to register child devices\n"); + + device_init_wakeup(dev, true); + + return 0; +} + +static int max77705_suspend(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + + disable_irq(i2c->irq); + + if (device_may_wakeup(dev)) + enable_irq_wake(i2c->irq); + + return 0; +} + +static int max77705_resume(struct device *dev) +{ + struct i2c_client *i2c = to_i2c_client(dev); + + if (device_may_wakeup(dev)) + disable_irq_wake(i2c->irq); + + enable_irq(i2c->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), + }, + .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..0c8b07abfb9d --- /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) 2025 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 Fri Jan 17 13:01:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13943295 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 779DA201026; Fri, 17 Jan 2025 13:01: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=1737118908; cv=none; b=RMOUVBoZp6xbRA8hhJzMXGXuQ1HQeXtpe93K4ARTE6QzFmdayO/C1BoZZiYj+idXifsBNs0wLXBix9QQgz4/2RKcJkA+KbFNql+We/oOHazFcI/jdHp0ZhleXeVZ4F/myEfmC5w/0lL6e26mRR1rRLU6LVkzXPcW4VOfNilOzK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118908; c=relaxed/simple; bh=ISDDYs49rWXOUlJxJE1Z00bffGid5L5PmU5XQ7cyvXY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MeXvUyYeF7KNN18ZC9pc4V7LfPCAAcSadmJ8FdKaEq6BXKA1DtIKLuVoMKe1Zg0mYN81mO6qbDbBygMxtwViSJKJArS8R9fT7tcKok8lmSdn3sGZHI3U4ZhCAMHhzBACCoCbPSKFLvlYNZWmMwAOdy5yEQ07ECe6WoIp1WOX4rg= 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=eb+Mcdn9; 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="eb+Mcdn9" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-aa66c1345caso119035266b.3; Fri, 17 Jan 2025 05:01:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737118905; x=1737723705; 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=+CCIFdmzB6o4lArRy/ux3cMMGIy1P+Jk6WtvkNN403k=; b=eb+Mcdn9Z5A0lx6B1XWC9INkK6lwwqajUXhLWQwuCleN5VOs27wNSY39UXRIGS0f7H GIjyWEdILyhe+FKzR0m/Jv4oEzrr88/b9SQ+1RkAKRqh1o2V2oQRI/OWgAQHnKP+l7c7 4yNHVXVA751OFdqnc7bAQsMaxeHcvPvTxHx9YQ7eVsrx+GXuX+lm19c80vx1H6wT8Oxo M/t5rFQhKlDPrtKx9QWBoZHRIyf22fEzjTs5YgLJbZBjwBAnhwFmznZ3pscuai+ts9ER y5IBpPvnUujiyaiPWPjEbWQZNPO1UJuNTyf8VFRNSIpCB3mYnCEgQzy9PZoA49XZ/i61 WFyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737118905; x=1737723705; 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=+CCIFdmzB6o4lArRy/ux3cMMGIy1P+Jk6WtvkNN403k=; b=auPxQIABwoRl0Z7uVk/BnWTYbSw/6MzlbCgd2w9Y1xmD/REplMDrvzIW3JReEjQbXr vacbdzCGJY31Ri2H7+G9/p4D7yt8QPutyv++ezcOM/f8Pxq73qOj8wWzKyA6GOcSp/fw tSHu6Keo2PzWmb+plHGfR4/ZnW1qF3hAtB4iddi0s/KvwG3RqhVhF4D8fMpp0k/IeRIL vi1DlGgdz4RZlgEG0XKtespzheRQopGU6Aunp7UvMrU7t9FAaPMjkA5TCnT23a7tVijG OKh5U0gl093uXU/zeDI3wRISgmiIEAijztpfibFRsBRTmzYFNEWvXyS1jxX+o9Jgu2ej u2jg== X-Forwarded-Encrypted: i=1; AJvYcCURulMbeHUI1sWlFX1uTXki3iwOdSSlP961f4JvgAAVbQwV9YE7CZ3eXj4UMZn8nvB6gRkeIh3QcCJOBQ==@vger.kernel.org, AJvYcCVUsXYFR6UyxbdvSybtaLzjOU+vCT6eHmFA5QkTUh/+OTG5bJjPJSqXIIa1FCPcLCLs8TYBa1g5S+yCrHo=@vger.kernel.org, AJvYcCW6ccErmCm50rDq44eiVPJLduwPLV3B8/NOVH7ScuRCW3p7OAH8WPQ/TpCYdeFp6hSNRfUTwRUviZ9WqLPV@vger.kernel.org, AJvYcCXuvNXQeOe/XZxdBZ5wsnv6AwyrwRlTOlJ5C4d2m99m91xHaumUUfV0pKbf5PsCD4dBEnArm8HSh3C2@vger.kernel.org X-Gm-Message-State: AOJu0YyL+G7Z9/8b7iUfeQNZY6BZGJkX+GSf1qLKwKNc59YYQsHVOH2X aOx08dstn51TJuuS3W920e2sCTvn+s9+dqZBzczT2zsOjykyEZ9V X-Gm-Gg: ASbGnctGG+XrKzPPLe0QvDrOjxH7BjuRtTjUIl4QDBqwwyQJH/F3b4twnDf7U+jDexs WB7WWeJRyTLaqgp/x/z+hBir51M4X20CRAnN+r+VIkprjQaw2ZjtMw7NNc1K8bmMeEy4lAUVpK9 bOlfM2TapJ0qU9IrqsFqimbvv97UswDZ38B8Nn35sNC0i8yDphNy1jMaTkV7ZCL0w7FVBnoz3qh FwVbVs30xkxnBIGx1j4XNdUlwqXadx0+nn4mEo7MjiUU75X9Y8jWAF/1vz+RMkW7DiiZbglfPX3 i6Efd52SPM3tQTTJHeAHyUovZA== X-Google-Smtp-Source: AGHT+IHubOJwB/qhAdXnifeCN8Q+B17N41NtddTLrcYB8s/S+VJXZFWYkfYxLfsiu5uMvlp/pBV2eA== X-Received: by 2002:a17:906:6a25:b0:aaf:afb3:ad63 with SMTP id a640c23a62f3a-ab38b44e0e2mr242986766b.43.1737118902723; Fri, 17 Jan 2025 05:01:42 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-ab384d2d69fsm166289166b.79.2025.01.17.05.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:01:42 -0800 (PST) From: Dzmitry Sankouski Date: Fri, 17 Jan 2025 16:01:33 +0300 Subject: [PATCH v16 6/7] 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: <20250117-starqltechn_integration_upstream-v16-6-11afa877276c@gmail.com> References: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@gmail.com> In-Reply-To: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@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=1737118892; l=3819; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=ISDDYs49rWXOUlJxJE1Z00bffGid5L5PmU5XQ7cyvXY=; b=SMjIIn9wu2YxDkfcN6PB1Q1BJKx64910ZOlTZ0yD304qgyDtBaDaMeski5x+bl88YSGYLYHeK VDTN0QNMmHNDtTd84cMYW85mcJBjvY7gWlYeKsiLkP0i9eBN1X3Ar5y 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 v16: - merge case statements in max77693_haptic_probe with TYPE_MAX77843 - add MAX77705 to config option summary - remove useless statement from Kconfig Changes in v4: - add max77705 haptic support to max77693 driver - delete max77705-haptic --- drivers/input/misc/Kconfig | 6 +++--- drivers/input/misc/max77693-haptic.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 6a852c76331b..fe7d821ad02f 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -240,12 +240,12 @@ config INPUT_MAX77650_ONKEY will be called max77650-onkey. config INPUT_MAX77693_HAPTIC - tristate "MAXIM MAX77693/MAX77843 haptic controller support" - depends on (MFD_MAX77693 || MFD_MAX77843) && PWM + tristate "MAXIM MAX77693/MAX77705/MAX77843 haptic controller support" + 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/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c index 0e646f1b257b..849c16218b2e 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,7 @@ static int max77693_haptic_probe(struct platform_device *pdev) case TYPE_MAX77693: haptic->regmap_haptic = max77693->regmap_haptic; break; + case TYPE_MAX77705: case TYPE_MAX77843: haptic->regmap_haptic = max77693->regmap; break; @@ -407,6 +416,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 +424,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 +443,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 Fri Jan 17 13:01:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzmitry Sankouski X-Patchwork-Id: 13943296 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.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 32BC2201022; Fri, 17 Jan 2025 13:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118909; cv=none; b=nlvc3a3wixu0+YKyUPHacIwciY8hA9eyaORV7oc1LTJDSPcgoCp1Gvy+9EP7G1kEkmbDoULzfo97JiLgg2LBDh2Z16+/YHjonfjnKAQiA89JLTnV59kdhpVIvBLbXoWA82w6CEYRJ9y/xluoeQ5/7sTA7mlgA0ahJ3hN8TfKFhI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737118909; c=relaxed/simple; bh=xOqBeSBIJwxouVgCQIyYna4a+/oQv9D67CT+l4Jdw+M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Oszd3Xzp4on+URmBAf+/aPQOPG1Sxe2eYBJugQMz40W6szDYw5lf4aDSfKcpQDdmpr6uziK9cQq25GIWEyWZJyr5bjf8bITVcXTs65TjNhNzR6H5KohWCNZr5h6kByp+7oqThG1g6kdz/s4b9/1a2sROYribyMpL/mO+Re1Rbbk= 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=MMyZ9/Al; arc=none smtp.client-ip=209.85.218.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="MMyZ9/Al" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-aa66c1345caso119034666b.3; Fri, 17 Jan 2025 05:01:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737118904; x=1737723704; 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=QyiorjbF6kcMXz/sUET45sJgYyIj4axNjcybQTsL8To=; b=MMyZ9/AlaO2yk5gViHVQiU61+rQlIRlSZapsB3CI9ECS8xl2OzVGvNjCynoV+WmJMt TN8VY3+bqHEp9rbN/CQOIwirqyoPmeMwY99zcyfJ71KPn1ybSo2CL1FNHEPfXlhwuSsu fbExRQucbAmSQVtxr1biE0j5oFvE+RtIWAyj9dfWoFUnVSn+YgSWThTkPW7TATAUY2RC U/u9/9Rr3i2/i1GMv3SgTcGT1biEqHrkClhRmsVGvGrgDlCZOYY0HoACq6FT/DZNIDGH RkmP6lGDdc0UO4LIqKAOUzyURGWTGcqrm+0aONYIJQTQpHLewBuCANzqltroZ/WCNGFO +Tfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737118904; x=1737723704; 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=QyiorjbF6kcMXz/sUET45sJgYyIj4axNjcybQTsL8To=; b=f0hhQ5U+yKAGd4inc81ilC8YrxlnIGm7uHtbcHO6wnPZ8onbdq1+ZeXW079BHn66cG BkZiXOXt0B531v3fBQHvNi0cLWrYJ94HHEA6qGMsMnPzDI3XkIM8pHPRrRiVCLcsyELl AObPyX+V+9kLqZ10JhA8e+h1ag5IlYLQ68KrqF9NU0j7S4+jcq3g6hmHiX2XBSI66vyL KrhQTJ3oFQ94vaFdLtjH3PBi09rAc83BwQuBn3i1ODZXabetfPVNE6Fsma8ckoFxMVsc G/zWP3CL2p0bvI5JUVCv80O6KFPFBlLlP8DPAlNJLVl156aWkE5QBys6qPBEciF7H3DO MXbg== X-Forwarded-Encrypted: i=1; AJvYcCUAyInDKT378O9RugrR6nvgtLdk/wLxJwv0/X1k1jjz2AlmTQpnOzFZ7aAtB8lt6LkBjMGMb4ve4ktUnp3L@vger.kernel.org, AJvYcCULM9DbjiDzb6aUk9PWYh57r/dmhj+iKb7WSQ3W5D1QUpCbi/A/M/UQEM6YVJ9Ed/o+PkT3YnlQwZrYoN8=@vger.kernel.org, AJvYcCVt64hEdZHzYPe50DLJ/wB50YPfey6t68nv9K46/AGf6tyxthb+D+rR9PDAF584SdU75efJYuBPtzzi2A==@vger.kernel.org, AJvYcCX6CrjEeddbY1ZQl4s/kcr+6+xhQmQ0rSaDK7a9f6G9dv8v7gB3qRmIuhr1RBNbhr4lRHUl1i5QUvVB@vger.kernel.org X-Gm-Message-State: AOJu0YxhBZf7WmWYh4Rfd790sjdJZBYNGgaggrZsM2pClHVIOKKBKth5 YiVNKiDq3brVxPCy2FieMZBrbWgAtpusY7/0PGzDuR+vLgi9306u X-Gm-Gg: ASbGncvNoAOEThjYzm8MpurOYE9GVlQwzbM/RwOGNS9sEP1mTZVsZlx4H4OtfTdFbsM 0mou0T1wpGxgllD4T1A96Az3mFGjxFgkW4P0Sb5AKUk+GqOIxdGMJ3E45SQg1dtZEwXZHg5Uvy0 jRnRSOVyUAIv6RHcvWIXpdllmXBkiH7I23YMBhgEmzy59LzuZ958RXUFTU8qoq4IV5kcoBjz3Yv mZXa8Jdgq+XMK779GOrQncziUk0iQuySnc8aiS0bLOsaNzpeQyNlVFaMwBjF1QVKQxOahUsy310 yc2GuOq9i8g3eyWF11/h70Y4iA== X-Google-Smtp-Source: AGHT+IHMuCdh5KiIXDUE9dey7WQ9OfgGeEkB/d7LiLo6ZhIQcQRogT8ZqKMHoAcg1r1GHNCKHCZ86A== X-Received: by 2002:a17:907:969f:b0:aae:c159:9e10 with SMTP id a640c23a62f3a-ab38b43bc13mr278955866b.42.1737118904032; Fri, 17 Jan 2025 05:01:44 -0800 (PST) Received: from [127.0.1.1] (nat6-minsk-pool-46-53-210-232.telecom.by. [46.53.210.232]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-ab384d2d69fsm166289166b.79.2025.01.17.05.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 05:01:43 -0800 (PST) From: Dzmitry Sankouski Date: Fri, 17 Jan 2025 16:01:34 +0300 Subject: [PATCH v16 7/7] 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: <20250117-starqltechn_integration_upstream-v16-7-11afa877276c@gmail.com> References: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@gmail.com> In-Reply-To: <20250117-starqltechn_integration_upstream-v16-0-11afa877276c@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=1737118893; l=13442; i=dsankouski@gmail.com; s=20240619; h=from:subject:message-id; bh=xOqBeSBIJwxouVgCQIyYna4a+/oQv9D67CT+l4Jdw+M=; b=LrOxno3wNnQsVbS7MT+CnWvY+r20WiNO6NL1WMp3TWOOqJM0QyTZEMITQZq044iwzTMGkRaOM XPkL8xhmWtUCOldK/yv04G6UzbfFKTAiRRLSPuU2k+IY/Gg3FEaIEc6 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 v14: - s/led/LED - move led regmap creation to LED driver - update copyright year 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 | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/max77705-private.h | 17 +++++++++++++++++ 5 files changed, 306 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 705458b6e0ad..b3a894ddbf27 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14187,6 +14187,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..8be0c455d0a9 --- /dev/null +++ b/drivers/leds/leds-max77705.c @@ -0,0 +1,279 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Based on leds-max77650 driver + * + * LED driver for MAXIM 77705 PMIC. + * Copyright (C) 2025 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 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 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 i2c_client *i2c = to_i2c_client(dev); + struct regmap *regmap; + int ret; + + regmap = devm_regmap_init_i2c(i2c, &max77705_leds_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), "Failed to register LEDs regmap\n"); + + 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 0c8b07abfb9d..214de7feeb8c 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,