From nobody Mon Nov 25 20:51:24 2024 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C02AF200CA0 for ; Thu, 24 Oct 2024 18:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793468; cv=none; b=ry/lQTZUAkaisf4vPUd7PRKvY2Zd6DrFIPnqmMftUMz34BvAXVArJKsEdICLvU/jReA1U9aeqybhVN30dioh0hXkjQdCUbPDd+X74I0SBwuUI5GJaU+eT/RKlTdo3uhc/2BNLGx68bYFY6LSqJZv4Q9RLzDwT1WnX2DXh0Y+12I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793468; c=relaxed/simple; bh=o/S07rQA5LKC++ibvZP8+btEUdTChzX9PQxEcexB2Fc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kgs05RuXD/L/8WYuENTGORmOaZLKgjjJcTGaYlWVxkzbJ5K6PBIB5yZE8wjawTFbWHMVSPAfLeHr8+klWilr/4SgbpmYS+e8JwnwqEy7DgYsmwTwey1wfEDy2gH8DEIxtpOYa72zSBV7UPp96maiKQfz2YzUxouwKHxteLQF4ng= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=aWgMIYIi; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="aWgMIYIi" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4314f38d274so16503095e9.1 for ; Thu, 24 Oct 2024 11:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729793464; x=1730398264; 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=cYYwPmz/G4AVlx/yjCM3Cevdc1UJIzYaJNcdAVGLoTM=; b=aWgMIYIibpNsPlvrGrigVTXokNhKjHEDUBzToWH/HG/ywaoHQrV/vpnCp5OcsK4oRY FQc9yKHNz2+oixKPHBsu5rRvV297INq9Ce8NhK3oJD35FRF+Uk/jU2O8psT0vTdkW9fd 8oq25YspHBMvbGPK+hSSbDMJb8ik0iZgxK81cNHdmqKJ9fq03OQulZbMe+E5i1YGC0O/ X5gBA5lmVGKt3/81al+dupsBWLJkel0+frrWM0D/Wc1iO0IxEKEs5+U95rdzeVXJm0QR Ua9tStY2loDEvatf87kCAhD8xOrJ9GR3Ar9rYoTh+/sSZlRLMXktvHHIATLx0tp6gVtL gsFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793464; x=1730398264; 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=cYYwPmz/G4AVlx/yjCM3Cevdc1UJIzYaJNcdAVGLoTM=; b=YGW5FN/kZLsjnUiUQVgL0WA4+rljIOsaBOnhsSbdy2Xnu3dat15Oq4KOFB+wozkJ6h 5ESWW58x3ZsmsdrSdpzfSnHMntUXp60ZG7TA84w+b2OJV1jfd+iYrosDAO0aZBznHj53 JgnmLlDeFzmy/Vz1DUzkCHDzLFFDfYD4xKwS4IqjWi3MXR/5Qw5N/zLj6N23sBjpG9yk HlVrF67f4OXiinT0FFI7jjSH8BZJyDTujvLFeQ5HWLVDHePZXM0lLlY2mhiwNSvG6tzV +D87IGysWtX0CXNJtTPD5XFrB5DlobBcgJfBEZWxoDMEBKCrQ6vgwLeqBZz1fEh6bpY/ wZCw== X-Forwarded-Encrypted: i=1; AJvYcCUhUXZzYzF7kxTPWG35QxUKtuweL17UgdidBFBkD5zvNO6G3JQGV6eVk8bxdeTRjlMaESGHmd6uuR8DYm0=@vger.kernel.org X-Gm-Message-State: AOJu0YzhahxeCxhft5N+2O8hZyo6HnplVVid3AvWauRc2hUdx+/eAZHp UZCE/4Vjb1hnNj3AhwVGUp2f86v8dQlGcNWxSDoLRKXIoYZELqe35gohoARrWMY= X-Google-Smtp-Source: AGHT+IHL2+uVpS3ikDQFYRZLH5E7XzwSPXFjTh7xVgWGIXAPqcMeyY/gkj1vyBdTNK3iZpTgY3cz7g== X-Received: by 2002:a05:600c:5250:b0:431:4f29:9539 with SMTP id 5b1f17b1804b1-4318424f1a4mr81750555e9.32.1729793463911; Thu, 24 Oct 2024 11:11:03 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:c04c:f30a:b45c:dbb]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43186c0f248sm52551275e9.37.2024.10.24.11.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 11:11:03 -0700 (PDT) From: Jerome Brunet Date: Thu, 24 Oct 2024 20:10:35 +0200 Subject: [PATCH v3 1/6] hwmon: (pmbus/core) allow drivers to override WRITE_PROTECT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241024-tps25990-v3-1-b6a6e9d4b506@baylibre.com> References: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> In-Reply-To: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> To: Jean Delvare , Guenter Roeck , Jonathan Corbet , Patrick Rudolph , Naresh Solanki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jerome Brunet , Delphine CC Chiu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1166; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=o/S07rQA5LKC++ibvZP8+btEUdTChzX9PQxEcexB2Fc=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnGo2vAVbdImCMdj783Ex0INoW6HwNWBuxtOWSv t0iBHLujqCJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZxqNrwAKCRDm/A8cN/La hUJED/wMYn0ebSATdu5mONHobOwZ3UCQWGqyMmqcDSKDUHGHAciT7QMU8ONAMelna4EsnJ/GdpO uD0jcNBGz0eWpBSrChB8ftYONkk7IfVQuSWVC1Q7e3xa0JMK4uv/ojV/6MG9pz30lWBF1jPBBp4 jlD8kLb9FT48dAnuQSur1Ka+yoDmdoQXioG2/m65B8hk1o43400u/DYwdUg8mHS/pFKctzbiRH7 uLeJAU9vdI2DsMLWV1N5BqIBWWF5ZdPoydjdBaAnl+1GYpdkfo1PZ+p5x3aDL3j/tpnAg4T+2x2 nn2ZwF7SYyChXJCNe5B/lz/fwQfO8eyNF+iAu0lxkG15YuiuNUhn+AG2UEQIBe2uZMzzaCDcJqb J/YiRV3mb5CjQC/SRFCGR1g0wg9VOxQPLXWFP8XPPYbsoAU5vjbNLArO4HV4NnR8csaEWiQugO8 T+pFlTEXFcTEVrUvdFyaGfBZnmD6WKMVsZufiuATwFHPx64ppQYGmpRuAX0nERi9dXmHs8FWIou yFzraIYnvMWqb8Jv1ivwTTTdPU3ZeDk6E2t+Z+2bNGf8z7jpUxPvA3sSmHwlmxFPbLCS1BL8Bv3 VjPaAN4AhqAV4DK4LSVZgbzpLK4iEvX9Pbr6Mcis8mvPCkagFuu8VHVAtOTxAeRXI0+2rHxWxdZ Za1zLd5j1UEyyWA== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 Use _pmbus_read_byte_data() rather than calling smbus directly to check the write protection status. This give a chance to device implementing write protection differently to report back on the actual write protection status. Signed-off-by: Jerome Brunet --- drivers/hwmon/pmbus/pmbus_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index ce7fd4ca9d89b0f0a02e6c99db391a7cfca924a8..085a4dc91d9bad3d2aacdd946b7= 4a094ea9ae458 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2719,9 +2719,7 @@ static int pmbus_init_common(struct i2c_client *clien= t, struct pmbus_data *data, * limit registers need to be disabled. */ if (!(data->flags & PMBUS_NO_WRITE_PROTECT)) { - pmbus_wait(client); - ret =3D i2c_smbus_read_byte_data(client, PMBUS_WRITE_PROTECT); - pmbus_update_ts(client, false); + ret =3D _pmbus_read_byte_data(client, 0xff, PMBUS_WRITE_PROTECT); =20 if (ret > 0 && (ret & PB_WP_ANY)) data->flags |=3D PMBUS_WRITE_PROTECTED | PMBUS_SKIP_STATUS_CHECK; --=20 2.45.2 From nobody Mon Nov 25 20:51:24 2024 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80E05201102 for ; Thu, 24 Oct 2024 18:11:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793471; cv=none; b=g8LyFaIjW6ZJYLJQLeYtaqzhzKV9KRCoW90YO6cn6itis90xiKf+EOVOypufKAciWlBcvARvPOUe6pJPACiWk5ZE1h5a4KFEr+tQY6cz5nd7aaNxZWBOkdnf9dxCvx14/ksF6Wlw8ogHYvkplMMWG46PqcKgkYn5jB/SylxTieo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793471; c=relaxed/simple; bh=bdFRv2raH+KCLJmgZO4a4Ytf5JCh6ZuWY7zPZdWyxiU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vgk3NgBcOJx1pOm8ilE2wBNu5z/s47304mAKMTFxAauz2G1jNaO/B2PvYG5foYNfa2tn1vOJEyLqY08uHsBNTGZzxbDsuNJm4+hpxE1t2ZkIvSVXbpGyJvoH3GhvMwl2DzRIYI8kIEK9ilIxRm6YA33kz/vGBQB199frz1cNSbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=3d1/eljZ; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="3d1/eljZ" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-43155abaf0bso12780275e9.0 for ; Thu, 24 Oct 2024 11:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729793465; x=1730398265; 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=Ug2lBpzs8RWHKP1Np79oVEQzEMuZF46YKLSwDulWpE0=; b=3d1/eljZXrj6wPFwy7D0wvEvRg6X923rpGeBScBfBb8ss2BHmnPuD4NZzXs411INLq /TG/HNhJ9b/jMNZWHM06jWot0P+QjZxLfHH0lBSsQHPHlJPNU5T7fsrf5O3cqoTwsN2O lCr/hykXcZLRkC+XjDYrstnzXDRUAOqptzDzt40mSR3/eziXeW5YUuC/QSZcDlb5Sgcu lpRDcp+n9kFy0VuYPwR595wPEgrAiLVszrBr0xSciHp4YRov4KLBPwsT8+y+wqiv3hFL NDApex5Z8PthXRmLIdquqbvLR4hYhadwTacPMVwntjOYPy8b8fssh2U56oOV9Q7tOiDf PZ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793465; x=1730398265; 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=Ug2lBpzs8RWHKP1Np79oVEQzEMuZF46YKLSwDulWpE0=; b=kvAgKSFZ2PNm+U8F3raQp6nHdZbYn/gwU/g0IlMP55jqMEnL3VIjIhk1SwxFU10shL yZjeX3CpSMtFfrIy2lGZk/oOnp8T1nDYKaEaJ582SgFKTZaLmI6TSpczahrmXdv/EowL H1I1SH6ukwMj9MQDuJ6pi+03VN0Onukk4mXkME76VT0X8jhwIoYEH82F+iqGG1m7BX4K +vCroTHfBIsOk8N8HMGSic8nCUzmJvNqxRs0es6rcT3RmHNcbGSmcPui3y3QzxVAT6x+ cI0kMQQO02PlJHpJUzRGU31EVnmD0YP8nf0lHkutgYp5lkMJapZ+xeoe0ly6SVpt8ry6 w2+Q== X-Forwarded-Encrypted: i=1; AJvYcCX7kyJ6rlU2UZwjqSx/iquJbST72A8hDeZY/OZVZZ3lUH8F8vOaUQ9jONJnQjif4Os0SUTY+1CtZQ49M5Y=@vger.kernel.org X-Gm-Message-State: AOJu0Ywcqje41CWyY4y7gq/nSTBSuUpmbNHbJSZvQoHZSev261LofFuP EsAMjDyon6qP4LYemh/zXrdAD1QkZKSfItEBPRLdJJ+IOVB04/cAJiQH7D0yxz0= X-Google-Smtp-Source: AGHT+IH2DW0bDE1/m2APidQKI5jd3nr0T6/JPFV0f0xHmO/7+Qb9aouj4Olh0pGuMpVMSjAz4q8gZw== X-Received: by 2002:a05:600c:4588:b0:425:80d5:b8b2 with SMTP id 5b1f17b1804b1-4318421772amr67743925e9.16.1729793465498; Thu, 24 Oct 2024 11:11:05 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:c04c:f30a:b45c:dbb]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43186c0f248sm52551275e9.37.2024.10.24.11.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 11:11:04 -0700 (PDT) From: Jerome Brunet Date: Thu, 24 Oct 2024 20:10:36 +0200 Subject: [PATCH v3 2/6] hwmon: (pmbus/core) improve handling of write protected regulators Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241024-tps25990-v3-2-b6a6e9d4b506@baylibre.com> References: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> In-Reply-To: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> To: Jean Delvare , Guenter Roeck , Jonathan Corbet , Patrick Rudolph , Naresh Solanki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jerome Brunet , Delphine CC Chiu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4955; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=bdFRv2raH+KCLJmgZO4a4Ytf5JCh6ZuWY7zPZdWyxiU=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnGo2wepJ2C+wcHQZHkZzvWl0mO2OX7kbggqvKW lSzVrLSGRWJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZxqNsAAKCRDm/A8cN/La hUQgEACaADc1xFNa9skN679kKhR7WLIYoMP8t/ytGLV0zzoMaizPENecCl2SVF2oCwci5H7VN23 P2Z0fN4p2fvXl7E25PpUpcdaR7/Vvn1SGqbHNIpd1Migi9rhlQ1zSpuWlYDi0eYOuunSg5VFOqS /iHON8ahTyc5MPtYDuYuU9ufmDMWJ8Q3CDHfnPYWXhW8uk/GvwcjydW6MroP0p81JMslbZTwoeG kYabXb5HzFBduMD9AEhfzzegTrTukW5aYitViK531Ouf+s+Ri+11O21w4EqBYKr7zAH6j/pbfs4 jJcfrobQY5NMQ40XEhaltUHkP8N5cAP9j2LMm/QG8/GsLNgx+ikv1bWXzTvWaJ7wMj2D23SgpOP ttZ573Pakl6WpyUoXluLHBAK7W4EAAMaGGkFXoJWRXTP2ILfFQhV+KxnBBHF/yK3kPuO3r6mnVk YNES/6eujPDbSrSKcUedM2hY5be8bCjizDLuC3lsRpCiQXO0qStpWn7iuKUi7IviE2bMhg1K4k0 Irb/63kCtdyGQOsCzWeR5S9f3fUwoUmWC+6mErJ7XWEMMOAjAckXcZ7wD6G6G2OHoiuva6Bjv2Z I0DFKxGoOnCY6OjwRneSGW1ZyHGDt5tkgh15x3qlnxIqiLrncc1gtEFvoyEXnpUKI/9/S1fnWrB wML5mn5K3Kt+N2w== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 Writing PMBus protected registers does succeed from the smbus perspective, even if the write is ignored by the device and a communication fault is raised. This fault will silently be caught and cleared by pmbus irq if one has been registered. This means that the regulator call may return succeed although the operation was ignored. With this change, the operation which are not supported will be properly flagged as such and the regulator framework won't even try to execute them. Signed-off-by: Jerome Brunet --- drivers/hwmon/pmbus/pmbus.h | 4 ++++ drivers/hwmon/pmbus/pmbus_core.c | 35 ++++++++++++++++++++++++++++++++++- include/linux/pmbus.h | 14 ++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index d605412a3173b95041524285ad1fde52fb64ce5a..ddb19c9726d62416244f83603b9= 2d81d82e64891 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -487,6 +487,8 @@ struct pmbus_driver_info { /* Regulator ops */ =20 extern const struct regulator_ops pmbus_regulator_ops; +int pmbus_regulator_init_cb(struct regulator_dev *rdev, + struct regulator_config *config); =20 /* Macros for filling in array of struct regulator_desc */ #define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step, _min_uV) \ @@ -501,6 +503,7 @@ extern const struct regulator_ops pmbus_regulator_ops; .n_voltages =3D _voltages, \ .uV_step =3D _step, \ .min_uV =3D _min_uV, \ + .init_cb =3D pmbus_regulator_init_cb, \ } =20 #define PMBUS_REGULATOR(_name, _id) PMBUS_REGULATOR_STEP(_name, _id, 0, = 0, 0) @@ -516,6 +519,7 @@ extern const struct regulator_ops pmbus_regulator_ops; .n_voltages =3D _voltages, \ .uV_step =3D _step, \ .min_uV =3D _min_uV, \ + .init_cb =3D pmbus_regulator_init_cb, \ } =20 #define PMBUS_REGULATOR_ONE(_name) PMBUS_REGULATOR_STEP_ONE(_name, 0, 0,= 0) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index 085a4dc91d9bad3d2aacdd946b74a094ea9ae458..7bdd8f2ffcabc51500437182f41= 1e9826cd7a55d 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2721,8 +2721,21 @@ static int pmbus_init_common(struct i2c_client *clie= nt, struct pmbus_data *data, if (!(data->flags & PMBUS_NO_WRITE_PROTECT)) { ret =3D _pmbus_read_byte_data(client, 0xff, PMBUS_WRITE_PROTECT); =20 - if (ret > 0 && (ret & PB_WP_ANY)) + switch (ret) { + case PB_WP_ALL: + data->flags |=3D PMBUS_OP_PROTECTED; + fallthrough; + case PB_WP_OP: + data->flags |=3D PMBUS_VOUT_PROTECTED; + fallthrough; + case PB_WP_VOUT: data->flags |=3D PMBUS_WRITE_PROTECTED | PMBUS_SKIP_STATUS_CHECK; + break; + + default: + /* Ignore manufacturer specific and invalid as well as errors */ + break; + } } =20 ret =3D i2c_smbus_read_byte_data(client, PMBUS_REVISION); @@ -3183,8 +3196,12 @@ static int pmbus_regulator_list_voltage(struct regul= ator_dev *rdev, { struct device *dev =3D rdev_get_dev(rdev); struct i2c_client *client =3D to_i2c_client(dev->parent); + struct pmbus_data *data =3D i2c_get_clientdata(client); int val, low, high; =20 + if (data->flags & PMBUS_VOUT_PROTECTED) + return 0; + if (selector >=3D rdev->desc->n_voltages || selector < rdev->desc->linear_min_sel) return -EINVAL; @@ -3219,6 +3236,22 @@ const struct regulator_ops pmbus_regulator_ops =3D { }; EXPORT_SYMBOL_NS_GPL(pmbus_regulator_ops, PMBUS); =20 +int pmbus_regulator_init_cb(struct regulator_dev *rdev, + struct regulator_config *config) +{ + struct pmbus_data *data =3D config->driver_data; + struct regulation_constraints *constraints =3D rdev->constraints; + + if (data->flags & PMBUS_OP_PROTECTED) + constraints->valid_ops_mask &=3D ~REGULATOR_CHANGE_STATUS; + + if (data->flags & PMBUS_VOUT_PROTECTED) + constraints->valid_ops_mask &=3D ~REGULATOR_CHANGE_VOLTAGE; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(pmbus_regulator_init_cb, PMBUS); + static int pmbus_regulator_register(struct pmbus_data *data) { struct device *dev =3D data->dev; diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h index fa9f08164c365a541ee1c6480bafd8c3a8f98138..884040e1383bf41d2eb3b6de72c= 40e2650178dc6 100644 --- a/include/linux/pmbus.h +++ b/include/linux/pmbus.h @@ -73,6 +73,20 @@ */ #define PMBUS_USE_COEFFICIENTS_CMD BIT(5) =20 +/* + * PMBUS_OP_PROTECTED + * Set if the chip OPERATION command is protected and protection is not + * determined by the standard WRITE_PROTECT command. + */ +#define PMBUS_OP_PROTECTED BIT(6) + +/* + * PMBUS_VOUT_PROTECTED + * Set if the chip VOUT_COMMAND command is protected and protection is not + * determined by the standard WRITE_PROTECT command. + */ +#define PMBUS_VOUT_PROTECTED BIT(7) + struct pmbus_platform_data { u32 flags; /* Device specific flags */ =20 --=20 2.45.2 From nobody Mon Nov 25 20:51:24 2024 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 276D92022C1 for ; Thu, 24 Oct 2024 18:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793472; cv=none; b=YyR1K9v1xcJSogBPuaXbDa6FpPrLGIejYdzGKtYbaO0lpZFl8La9Iew7ZjB+KRjpjp3gfzeNG/Dz2glmBoluK0L0dEqnrcW/e/0EsJSRVI59U2koF4AdocWbJjCwDj+NiAKstc6VKGMJll/+qkpm/QwfPYtPx21LopXX1jPEDy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793472; c=relaxed/simple; bh=1RUvmeu4nLIw4F/R4FU3E8L2fpBrm/KNeTkrcWULZz8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ERqJ5It8ujs9l1FbqbomHYpQnqpjQeUScK+AS5QaKwaRJYdz19QFM9adaKNPbfkfTLA1GW4Jqv0+CzmGut0Nak08IMnsJjehjRdw/btvqUAj4sKW1x81b3TGMFVN/7K+CIkx+TgMpZMQWOOZ1Vg6a+IJAGOSghrqUo7tBKgQOts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=zhZ093l2; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="zhZ093l2" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-37d6ff1cbe1so839353f8f.3 for ; Thu, 24 Oct 2024 11:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729793467; x=1730398267; 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=+eOmi43Jby+szoL0o0TudIR+Wk2BylfVEIJOGm6GajI=; b=zhZ093l25vd54dJPG9i1i7L7xuIoImFfGqDUpchrcaKuy3uhK17kpDjPepddUazbNg eIwJBRlavMm8OnCTDXVH3wBgdth0TGiS+QNLhHKkOox4QUtWkXNqz+VIGGzUrygvd+9F KvNZUIGsE8Zo/kJIrzasvCz/LM8fm5akO0Af33qXRss0JtUcPwm4YBU9Vp4ZvNBebu3Q xBlk+T4vsQAgPRM0nWUsU8z4X5HmyVVgrCaPiD5M7EKTmA7eCI0uy6Zv1YwFD+xQqQ8S JlMxFqT8tiXjRBQF8aktAZJVtVqA9A3i66YupL0bxFTvHZ5Lrxlg/vig55OCXWtDE9Z0 E6/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793467; x=1730398267; 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=+eOmi43Jby+szoL0o0TudIR+Wk2BylfVEIJOGm6GajI=; b=cVYLlFpfF9SLQrPHWadpd+ZScR+jAFpmjHdUjYXX+oMj/WkE9ut8vsJSarCV0+xH4E uz5Py++Sk1ssBgQdr7ZRFeMzIhsy5tuUqUQ8Vkh04c7MvgjDuUKspjHF+csZ+RM4Ilmm BBn0FI4ZgMEvIjUEEKDEqv/8EJkA2pOSusjGjRgyI4yogLh3kPgDzFFjm+ebBvYoI0eI x88sL8iVP7cJryDKJU7K82T2nZhUtMc5cLee+JL6tC/t/AcORFJvxTwOvNBWTcna3Gff 6wJaR2UnQl+sdO51XIQGzqoBwl9VGzBiyJ9SlyiQ54vFZDfLxtqlrpfpt4CaCdGfGi0D PeXg== X-Forwarded-Encrypted: i=1; AJvYcCXy5SzhIVXDNkD/FayRid/KvCvJUNNxi/Wn0WUH9x63tIJKqsIxNPYQWdZph/ODhnRz2FfOJvxCdXSgnfE=@vger.kernel.org X-Gm-Message-State: AOJu0Yyn18V6S7iQluum5ga7XVAungsNt6vvMvMQxrgQcLXf6NBfAbIQ BuGWFkandVszFYFaDltskNXV1BPIlCaxuFTQRzOrjyNxONULEI100HZhyNP8yXY= X-Google-Smtp-Source: AGHT+IFLZgWsGUPyWhrcipgaMB5PPuZFsd4gBEIEpZg9BK409FgjZ9vFaXq5SD7emAtHfO/sPfR5TQ== X-Received: by 2002:adf:e311:0:b0:37d:37b8:3778 with SMTP id ffacd0b85a97d-37efcf8460bmr4558854f8f.45.1729793467135; Thu, 24 Oct 2024 11:11:07 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:c04c:f30a:b45c:dbb]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43186c0f248sm52551275e9.37.2024.10.24.11.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 11:11:06 -0700 (PDT) From: Jerome Brunet Date: Thu, 24 Oct 2024 20:10:37 +0200 Subject: [PATCH v3 3/6] hwmon: (pmbus/core) add wp module param Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241024-tps25990-v3-3-b6a6e9d4b506@baylibre.com> References: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> In-Reply-To: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> To: Jean Delvare , Guenter Roeck , Jonathan Corbet , Patrick Rudolph , Naresh Solanki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jerome Brunet , Delphine CC Chiu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4442; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=1RUvmeu4nLIw4F/R4FU3E8L2fpBrm/KNeTkrcWULZz8=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnGo2x9dk7+jpaxTWiAk61vydnQ6U77tni0qxKx dgiMCLMPK2JAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZxqNsQAKCRDm/A8cN/La hcS8EACMq9Gnoa8PyayjPvYHtF8zQaQktxGrW+pGWTERlZCNM/QSiUU12WlScMwXfp7bBlZ9crM 9H46BLLbqkNLIjDDUdEeSg/HKqCc8fCN82efJ8dh+UxknRYQLo8hQsW8u+FOXORcVoS0fG5TJmF qvSws41TL7TGuaRC5VqeN9KQ2fIT58VxjVqViOJxSVZy/aqENZbMM0xG3oDKGoEr0KXWI3Ir1Jw KE7KRLtytyjznNiYhwHXhks1VRXdInUXKPqtLO/i5yWtGQCwoOxl54BduXSfgyhdATK6oYBbNKG QdYb9X1oykTzkgMX7ExNp18WEP/wWZ55mh1TgU0t+kkxSdfXmj6JN7jODVWnghhLNNrwl4kRYBy 7smnJ7zPVY3aDxShzjjJ7etNALkoSzflsiCwjxCsTpRqS4zZOVjV0PHSuGcwINXmLfnnZbI2FDb M0WeEGmbpasGCC/NPDVqho9FzIcta8WJbPRNV7K/5j6XNdsjSjfDOw+w6rt95DZJ778LK44YdYE BZhsXh2a1falIF4ukLu1cTaqUXLz73NmaBJmK4WPDs9UsvWk5v4gl2XxnEayfEAyNs/7LMzl8h6 Kz9PuCnwLi1pRF9KtAXRzHsKnhoQ3HmKc3LjU8uyu1tgQKGkYuDVbVjwks7v/iCm8U3mhIcTx9F koUs+9ok3zDRGBg== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 Add a module parameter to force the write protection mode of pmbus chips. 2 protections modes are provided to start with: * 0: Remove the write protection if possible * 1: Enable full write protection if possible Of course, if the parameter is not provided, the default write protection status of the pmbus chips is left untouched. Suggested-by: Guenter Roeck Signed-off-by: Jerome Brunet --- Documentation/admin-guide/kernel-parameters.txt | 4 ++ drivers/hwmon/pmbus/pmbus_core.c | 74 ++++++++++++++++++---= ---- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 1518343bbe2237f1d577df5656339d6224b769be..aa79242fe0a9238f618182289f1= 8563ed63cba1c 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4733,6 +4733,10 @@ Format: { parport | timid | 0 } See also Documentation/admin-guide/parport.rst. =20 + pmbus.wp=3D [HW] PMBus Chips write protection forced mode + Format: { 0 | 1 } + See drivers/hwmon/pmbus/pmbus_core.c + pmtmr=3D [X86] Manual setup of pmtmr I/O Port. Override pmtimer IOPort with a hex value. e.g. pmtmr=3D0x508 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index 7bdd8f2ffcabc51500437182f411e9826cd7a55d..ce697ca03de01c0e5a352f8f6b7= 2671137721868 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -31,6 +31,20 @@ #define PMBUS_ATTR_ALLOC_SIZE 32 #define PMBUS_NAME_SIZE 24 =20 +/* + * PMBus write protect forced mode: + * PMBus may come up with a variety of write protection configuration. + * 'pmbus_wp' may be used if a particular write protection is necessary. + * The ability to actually alter the protection may also depend on the chip + * so the actual runtime write protection configuration may differ from + * the requested one. pmbus_core currently support the following value: + * - 0: write protection removed + * - 1: write protection fully enabled, including OPERATION and VOUT_COMMA= ND + * registers. Chips essentially become read-only with this. + */ +static int wp =3D -1; +module_param(wp, int, 0444); + struct pmbus_sensor { struct pmbus_sensor *next; char name[PMBUS_NAME_SIZE]; /* sysfs sensor name */ @@ -2665,6 +2679,45 @@ static void pmbus_remove_pec(void *dev) device_remove_file(dev, &dev_attr_pec); } =20 +static void pmbus_init_wp(struct i2c_client *client, struct pmbus_data *da= ta) +{ + int ret; + + switch (wp) { + case 0: + _pmbus_write_byte_data(client, 0xff, + PMBUS_WRITE_PROTECT, 0); + break; + + case 1: + _pmbus_write_byte_data(client, 0xff, + PMBUS_WRITE_PROTECT, PB_WP_ALL); + break; + + default: + /* Ignore the other values */ + break; + } + + ret =3D _pmbus_read_byte_data(client, 0xff, PMBUS_WRITE_PROTECT); + + switch (ret) { + case PB_WP_ALL: + data->flags |=3D PMBUS_OP_PROTECTED; + fallthrough; + case PB_WP_OP: + data->flags |=3D PMBUS_VOUT_PROTECTED; + fallthrough; + case PB_WP_VOUT: + data->flags |=3D PMBUS_WRITE_PROTECTED | PMBUS_SKIP_STATUS_CHECK; + break; + + default: + /* Ignore manufacturer specific and invalid as well as errors */ + break; + } +} + static int pmbus_init_common(struct i2c_client *client, struct pmbus_data = *data, struct pmbus_driver_info *info) { @@ -2718,25 +2771,8 @@ static int pmbus_init_common(struct i2c_client *clie= nt, struct pmbus_data *data, * faults, and we should not try it. Also, in that case, writes into * limit registers need to be disabled. */ - if (!(data->flags & PMBUS_NO_WRITE_PROTECT)) { - ret =3D _pmbus_read_byte_data(client, 0xff, PMBUS_WRITE_PROTECT); - - switch (ret) { - case PB_WP_ALL: - data->flags |=3D PMBUS_OP_PROTECTED; - fallthrough; - case PB_WP_OP: - data->flags |=3D PMBUS_VOUT_PROTECTED; - fallthrough; - case PB_WP_VOUT: - data->flags |=3D PMBUS_WRITE_PROTECTED | PMBUS_SKIP_STATUS_CHECK; - break; - - default: - /* Ignore manufacturer specific and invalid as well as errors */ - break; - } - } + if (!(data->flags & PMBUS_NO_WRITE_PROTECT)) + pmbus_init_wp(client, data); =20 ret =3D i2c_smbus_read_byte_data(client, PMBUS_REVISION); if (ret >=3D 0) --=20 2.45.2 From nobody Mon Nov 25 20:51:24 2024 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3956C202F61 for ; Thu, 24 Oct 2024 18:11:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793473; cv=none; b=HSFSXMKTVB8KkBbo9Fli7s8axhIoSj6BqImNV2B5XmGynkeNi1k58qByQ2daPT5rMJb2shoahFj5CfJu/BVhHJ7lL9vF0jRd3ANibTNijMZOzXdjSvctjXSUhu8IVeyb/8RWeMECFVS803/N1pvEhMqZbZ8DGe79/o1tb1IiNYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793473; c=relaxed/simple; bh=CcZS2lMSjKQk5DMr0lcBympx6MFOZa91kBCFmmmRsgU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=asuklQTATTxFNFtYCGqrc7IUV7Ni8K/N5tUa0oV0sHSxNgEC7aUZjeT4HoYoRu2/wW31iluDOKUEDVQiVY0LXK3WJanCNy25gBnrODOiFkr/tgVuTOEiIxZ4PtsTRZazzdWnDf+NuokcRpQ4AxD0MM7D4jzHpbo5kxjXnpiv8OY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=y31vqQRN; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="y31vqQRN" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4315839a7c9so12576965e9.3 for ; Thu, 24 Oct 2024 11:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729793468; x=1730398268; 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=s4za7fmNR/tTyyrtswW0yMGY0yUgT5apkN6SQXTSibU=; b=y31vqQRNYFwt3d/d/JzDCaaQ61/MkK8Ov1UI+ayTIqMiKi6AP88ytfxKqMlG9soWNw D2YnFPaMvp7zWEBdi8GrHw3fSXMS3TiMhC88MuQ/yl3eZ4F7cousLH4CjDnYmzloLJQ8 AG6NLKuq54EsZ/O7yOXVsb2EVWtLKYz9c1jUc4FfVvgP0aC4Hxn0t6ujXwwy8sN7LFbo sj4ppd8UzvC7AtoVolhQkBZkIHkNIqSKkaIaoG9Z/w2Y0EzQGRm+bqdxOPjtoSsM+Hbo i7yt8nIOwRwqWq+71kIUc+s3cQouRX3P6J0HKqQFbZffi7aWGf6qeg+YO63pVUGqjQkM Qmbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793468; x=1730398268; 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=s4za7fmNR/tTyyrtswW0yMGY0yUgT5apkN6SQXTSibU=; b=OgSMH6IVMdhqEvJNMaZM4siqQAYuq53RbNzGAT5117ACopRc3tM2z2mxZrOQc8SRVH Ty6FnCH+1Dhro7uJAulP1pmmNxWQ2lF6xMIBcz8Wvjk+nLQUeS+ohUUFFM7JF/ySm+oo LPdYAIG3lAF9ZR2UIRh9cZCP10extMAbkSizUznJAAyBEEzj0iM2iTx9qWHc+4wx3kDy h3nVVrOEiC7iBZ/WgI63/gkCDxXUNXejvyz7c9Nzhoe6V/x8wCDx9kMmzYhhb/Uq/StC KW7l1EnLRCT9+E3L6r6nd5IKw3Qc+C+fD+o+T7phv/HZNWgEvbppZg6LDeH+qDVr8aHs Fnaw== X-Forwarded-Encrypted: i=1; AJvYcCVbiehWTCfmy68PLToiyF0+ygnxp9gzVwwZ0+vHgFyuIYiTyDrwxddWuZcHiv9qePl2PlM9IpqRKnKa0zY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+cfqGDoc0DOrZMDpi5wMH2mfgJyJzYng2kVa1oou3+QfVmF8+ Fx8zFyB4d2yofzg3SbylaXtEaB58jRSX8W/+GaIlFzwFX+4tmZbdmNeLBZDpgvU= X-Google-Smtp-Source: AGHT+IGHJg0fHhXtA8gDbMxMxbB2At5z4+omPGcUx0dUgnP8DW+c0l41BYOBqmo1S0mPMy+ZYI8YRg== X-Received: by 2002:a05:600c:1390:b0:431:12a8:7f1a with SMTP id 5b1f17b1804b1-4318c703d37mr26782415e9.16.1729793468158; Thu, 24 Oct 2024 11:11:08 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:c04c:f30a:b45c:dbb]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43186c0f248sm52551275e9.37.2024.10.24.11.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 11:11:07 -0700 (PDT) From: Jerome Brunet Date: Thu, 24 Oct 2024 20:10:38 +0200 Subject: [PATCH v3 4/6] hwmon: (pmbus/core) clear faults after setting smbalert mask Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241024-tps25990-v3-4-b6a6e9d4b506@baylibre.com> References: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> In-Reply-To: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> To: Jean Delvare , Guenter Roeck , Jonathan Corbet , Patrick Rudolph , Naresh Solanki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jerome Brunet , Delphine CC Chiu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1725; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=CcZS2lMSjKQk5DMr0lcBympx6MFOZa91kBCFmmmRsgU=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnGo2yVz0maAGcDLQLTYmUMd/l96aXLzFYemkLH HthHzP6Qe2JAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZxqNsgAKCRDm/A8cN/La hTMfD/0Zb/NqTaM5V+B4N89l1jXZzBdwslbuWfKti7RPxJq0nYeYJNGQbFWDiPU1yfQehuHIc24 MbpugM2sV6qvbcMHzvohZrTArL0ysRvU6HjJxzhhfLIi/Ptcgw1dTAhG8jP0Tl3OwSqXhs9PI0t OLI6M2GfN3AziKwNiDUrZwRvFJ984bsvNB1/EuXy5/k0iPio9/coBjxB88/ozaXz3yNtlR+es66 0S/UapET8t5/1UpIIYceRbrEIQhzcODE4w3E9UMUVli4mHsrcPfqwV8jc2QGeyIYWngdTrX8YYB sfXMdXPfhEvvGaN8xGhY++SFFHn8irLpHXNLb/QjvMIVNj1PEyg5yYVZyI3aQSwzliBGkwGLh4B Lexfzef62pbSb+14e5rOCE36dF1uAGlvvatJPbLvb7ETMExQA+CxZKnRfjugSTXBt/p4BQztvOx 7FrJuiCeRXHYk05qMz3TCSmdWGkjCXevxP1Su0jXM/3nG32rejxShKx/G3QeGG6dHLrtSzjK/CU 1EdSjTVE+kBNhqoVy0ri0rhEgLTeg3mO5p6jn+wSOUsca7ElHzepWoHkUMOMMPiAHWAfEvqSLSD oUWrNOMX7dVFK1bQm6lPpkPD6nOaDDNgnYs0OO9kMgQQ7n4bYVbQ/uwM9F3tZevtA9hpApUb+NV qeJPns3qZ+2f5LA== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 pmbus_write_smbalert_mask() ignores the errors if the chip can't set smbalert mask the standard way. It is not necessarily a problem for the irq support if the chip is otherwise properly setup but it may leave an uncleared fault behind. pmbus_core will pick the fault on the next register_check(). The register check will fails regardless of the actual register support by the chip. This leads to missing attributes or debugfs entries for chips that should provide them. We cannot rely on register_check() as PMBUS_SMBALERT_MASK may be read-only. Unconditionally clear the page fault after setting PMBUS_SMBALERT_MASK to avoid the problem. Suggested-by: Guenter Roeck Fixes: 221819ca4c36 ("hwmon: (pmbus/core) Add interrupt support") Signed-off-by: Jerome Brunet --- drivers/hwmon/pmbus/pmbus_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_c= ore.c index ce697ca03de01c0e5a352f8f6b72671137721868..a0a397d571caa1a6620ef095f9c= f63d94e8bda1d 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3346,7 +3346,12 @@ static int pmbus_regulator_notify(struct pmbus_data = *data, int page, int event) =20 static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u= 8 reg, u8 val) { - return _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (v= al << 8)); + int ret; + + ret =3D _pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (= val << 8)); + pmbus_clear_fault_page(client, -1); + + return ret; } =20 static irqreturn_t pmbus_fault_handler(int irq, void *pdata) --=20 2.45.2 From nobody Mon Nov 25 20:51:24 2024 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55DDB20370B for ; Thu, 24 Oct 2024 18:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793475; cv=none; b=lfU3IYQOZrxyZ5ajnEQ3Dz1UJHu2dmwx6KJLNCSzxaDBhP8gZy18nyRa5NtG4Afm29Uq8mUJbGk1zSdcDhYbP9QZQvaxlvVgvR4BOhWTlV+7ylVdJWq8hX+sCbFmIf7pBZpn9CEqgdXkZWPiwV+aUt3vuI1f/YQ8RRNNO49XyU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793475; c=relaxed/simple; bh=zqSinmggbyALtFlgHQGiPOP1CMvPeMaz0BwXU0S0Uyc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P5rNryu9NqPG4miQqESr/1bWsVIbdnPTXvdNrxS7knFCWVLtHZXlizwQT4CxVc49SSDXhIChyJLB3WDkAVeoEsrHfrgHMdudQMSMgvvvotBr8b5e5qpZk8KLvjYZz9XeSQcj19ENEdg+nCWuw6TJoYhHC3YCtE/u7Unr3UOK9r4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=mowqlSie; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="mowqlSie" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4314b316495so11612295e9.2 for ; Thu, 24 Oct 2024 11:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729793470; x=1730398270; 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=urkkRzU5D9fbLL7/NswuGkiZi7jgfQyHM4AVm24QR80=; b=mowqlSie//kEyXaQT3cJ7hV/XhpaaB64aiR+gmuMH8SoSiFzZ0tozccSneAnXYJ2bQ Ne3fjEKVVTVxQA0W9jHcNUd0SQYNxTw+XTznJPSBzgCZdL2Pf0UdD8yGhKjPOx27zzD7 /C537SWhF6sfaoxJ1MDPkmMgclaWhm0D+ZvRiEiSYRpBpch2zvfjz0gQMXE6OV41Clc+ 6BzukxX+X3ludpHT5VkkE6ITHwUg53r/4KLsupaak9bbH5vBKNG1+7scCKKGPg2O/QcA v4aO2ggtdRVTFSDo1+v5g3a2V89tED10pcESawRz5AVHAB8r2TnfKwOLazsrHiONHunB LJYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793470; x=1730398270; 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=urkkRzU5D9fbLL7/NswuGkiZi7jgfQyHM4AVm24QR80=; b=wZhJiXANmvwoZezv/SqCLbn0VxqKVPAVrrTt1NKHMPG2EcmDOBUnJjuujhQrLNI2zt zLdIFFqWGceOqPpAM670jvtEcXiMnT3LN1TzmISjw13IeTGQ4CxIFK8lYaiqb/XW7YYY dPgyqGarkcfYbwOsmygxBSDhIgmMNF4ZvvkL6DupU0TIzS8V6ijeQsLMckyf2Q82japx qoLDUwMh73N0NfTTa05WVLWtVoSIO/e+nd4Z3c6JiLj+oRepdMNY1cIfYK5ZH/PtIPEs iLUBnwNdrh2DVjOILl9zedRSd2tFQkGGnKxRZoaSpHcPNL66+LFywf+MGn9fjpn4WQ/L x87g== X-Forwarded-Encrypted: i=1; AJvYcCUkevu9nZNsRoJ44t9djCEDBAU8bR68FPaRyspXwfF0QWSeapYWYIz87bEEO2Q+OXSQaAq3GYvT7bKceOc=@vger.kernel.org X-Gm-Message-State: AOJu0YxQRB4aUmRRJs2gmSDyxnTwzdZq9lFyrLvgirjisveFPL9iXEjo w4xJqTz1f+LNUK5fk3xVXQvROiNGD06RRs8fKa1doVHHIr21sBjdSoHs60V24PA= X-Google-Smtp-Source: AGHT+IFwYi40XB5lkPBV0kIJQvlY450vcar/Ftp28V95b/qWnB423ETtHbKWltn4MFsqSTWOVjPiTA== X-Received: by 2002:a05:600c:1d27:b0:431:57d2:d7b4 with SMTP id 5b1f17b1804b1-43184189bf9mr63441695e9.26.1729793470523; Thu, 24 Oct 2024 11:11:10 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:c04c:f30a:b45c:dbb]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43186c0f248sm52551275e9.37.2024.10.24.11.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 11:11:09 -0700 (PDT) From: Jerome Brunet Date: Thu, 24 Oct 2024 20:10:39 +0200 Subject: [PATCH v3 5/6] dt-bindings: hwmon: pmbus: add ti tps25990 support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241024-tps25990-v3-5-b6a6e9d4b506@baylibre.com> References: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> In-Reply-To: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> To: Jean Delvare , Guenter Roeck , Jonathan Corbet , Patrick Rudolph , Naresh Solanki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jerome Brunet , Delphine CC Chiu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, Conor Dooley X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2682; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=zqSinmggbyALtFlgHQGiPOP1CMvPeMaz0BwXU0S0Uyc=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnGo2zzvMa4LhaAd7cvZuyPbrarjWEtJKxEkfg5 J9sFTWmMN+JAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZxqNswAKCRDm/A8cN/La hfSdD/48DvCbKe7R8NGvLbLx+lm0Ie/2fZ1S/mKVBNWcOoUnNNqaDk9h1a42EfsL8pPHFqJEBt2 eIdnwln/u5sbCRwc1lomu6wG0xc+sO2ri4E1zO/PY6W7OsBfGxCF1ua9PkPiUoTRJTfa+lrpMdG ke0QMimf/XGXH+3Wi+ulZj3a3/8Sb+XCRUBtL3d/6mb0HzwSTZn9J70BqLEad+++0fqzAxj1wR6 Gw9pYShLgWJuvIiVFrsrODNwnh4zGRIB2Wmmbr+SGPx2pg1zv9a8mZaGuyC4TsCliaeRehwW/wu klwgOXDfYwpIRLyfVLwRfnyLFKDXUDWz51PbDMhrsZy5YUpHqiIHSoon2qiaidBvkNjTJm1kRx9 wXTShnVo4eONUW3aSYy0SCt0I6F+ZNTivqjLHmBwvXyUn5Yee1ZpZ3ePxGg2PCPgyNLUdL95ES6 Hnbo4zEOeEcbVMBKEhe7ROjdf7ct8WI2SPccwHBRdWgXIn43IU7NDwCNL77SpGBzgloPDoI7bfx 7CMy3ko84m3YZJ/jjwWaVBlB2X6eFUnWgTg6+JoevxpSXzFuZ2HiIW3g1/SVYE1VilWhdmP7Xiy fgimdAfXhQgV7pAY+NKBLpIoQC/THU2HP5OwPZ5AjHTVijCT/xMnjE4b0npX1Zt0LJKobWDMB08 oPLBZl63Z76PjBw== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 Add DT binding for the Texas Instruments TPS25990 eFuse Reviewed-by: Conor Dooley Signed-off-by: Jerome Brunet --- .../bindings/hwmon/pmbus/ti,tps25990.yaml | 83 ++++++++++++++++++= ++++ 1 file changed, 83 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml= b/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f4115870e4509425e88c913f350= 789ffc8d396c2 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/pmbus/ti,tps25990.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments TPS25990 Stackable eFuse + +maintainers: + - Jerome Brunet + +description: + The TI TPS25990 is an integrated, high-current circuit + protection and power management device with PMBUS interface + +properties: + compatible: + const: ti,tps25990 + + reg: + maxItems: 1 + + ti,rimon-micro-ohms: + description: + micro Ohms value of the resistance installed between the Imon pin + and the ground reference. + + interrupts: + description: PMBUS SMB Alert Interrupt. + maxItems: 1 + + regulators: + type: object + description: + list of regulators provided by this controller. + + properties: + vout: + $ref: /schemas/regulator/regulator.yaml# + type: object + unevaluatedProperties: false + + gpdac1: + $ref: /schemas/regulator/regulator.yaml# + type: object + unevaluatedProperties: false + + gpdac2: + $ref: /schemas/regulator/regulator.yaml# + type: object + unevaluatedProperties: false + additionalProperties: false + +required: + - compatible + - reg + - ti,rimon-micro-ohms + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + hw-monitor@46 { + compatible =3D "ti,tps25990"; + reg =3D <0x46>; + + interrupt-parent =3D <&gpio>; + interrupts =3D <42 IRQ_TYPE_LEVEL_LOW>; + ti,rimon-micro-ohms =3D <1370000000>; + + regulators { + cpu0_vout: vout { + regulator-name =3D "main_cpu0"; + }; + }; + }; + }; --=20 2.45.2 From nobody Mon Nov 25 20:51:24 2024 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E0AE200BB2 for ; Thu, 24 Oct 2024 18:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793478; cv=none; b=U5py4we98RUFo+TRawho0OIVUZI/N5nwJir+O9rFPszQeD0G07tYNfuyD5hi9atjTmvTKp5NLCjwZ00UHHvV3dhKUZ9EtYkr9v/eBgW+SkIEMNDIqUN4bh+O7HKkSa3QVr/Cnps2ph3QlZ1tgF36D7nJ8RTLY9KYRG1QhpOXX44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729793478; c=relaxed/simple; bh=dnVmdKGfMttMrhnLQqDF6zBl6BlDDz2flspxyvtR8h0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uo6E2+0Acq+/wtWb1bk5wuxDimCnjLb7IUM1GvKfjhUkjRnf1d7MUzF71NxndnFexm4jNtXIrjKCc/iagaX5zC4RQY1MrV3LniyOZGEwzbPW1QKUYXpLcbVnlrKHbTsP1dK+0AFaqrN229XWTWAzUbrlQfckRhaPdM9rI68+2JM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=q3IrSMpK; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="q3IrSMpK" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43161e7bb25so12155615e9.2 for ; Thu, 24 Oct 2024 11:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729793471; x=1730398271; 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=9fBlSDoY+5BLQB4T9iJPW3gISJHh53NPyolTJhArp4s=; b=q3IrSMpKBq2LwCMBviEYnWXYJkec9eumRGQThZwqVkj9JCB8/KrRa9DrmPYLm0aFgS Rsqfxpkgq4sspjZq5CNgHddlBTuf74pu0ofXF9PQiiQbWrjkqZR2p54BfMVl/Y/COyL0 fE+nCiSZEvUiP/kbfpon6NSbcEFgit3N1pCcm6Xownelvjv1c7Y8qQeVcgwq8Y6oZzi8 ozPShtqxi9dfqcUPx27RCmVuQvvTAqmLAoBWCYq39cEvrls6KHOPL4YbUtyaZHQaxu8L MpAmknCM0+KpplIyuLXh1HrG6MDoRRkOzzNUAkuIFL6O93KpiOZ/ccWSrR/rp+e7pmxL iGow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729793471; x=1730398271; 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=9fBlSDoY+5BLQB4T9iJPW3gISJHh53NPyolTJhArp4s=; b=TWbHqhYVwZWmgKPqM3IxihEUn5MfGHN3r3tyzgSp8gVgr3G5SjinY0eOTQv0qp6uzh bdjM/e9atE9oTROvUyjISebf/T43h/l72xfcEBUjvLepvOf5lBnGEV3DGHAbYXF/zikT 9zrK0kXEr3q0blaJokEWzgwJ8LEQY3lZmgsFoJxv7H5l4UMQMbE7CCB7mAb0p2EwsrjI DB8vak+63JT56UWyUhPaQ2Ffg4T1lnvPvx+NMJmPJSbqofDBCxnj9RFV3CN/tWbI6ZGu Hy3IrAGPpfTVVUbv6CYxAJIYQ+eLKMQUw2Mg07W/xcFtQFqx1ColU0T3xoU707ad0dh9 +VbA== X-Forwarded-Encrypted: i=1; AJvYcCU8Q3Wpi+njfe/k2nlMopr8MTYMCNMDciK2SzoxQ3/j4A51fz6oR8mnly3xlFJrVaDbydZ68XHVnJVcl3U=@vger.kernel.org X-Gm-Message-State: AOJu0YxQIC+B1LAv+WgazLpO+nPgQ7hvoOt9Y4zULKSr1cS4gW3nj03w gGAI+IgL3HiKx+dm/xtX6k1Nb/VksSLF8rYp9VcMn77XmySI2R4584M/Q0cxrcg= X-Google-Smtp-Source: AGHT+IGnJ7UXHQSQv9VwCwcuhJCbOBSacO9Xjqh6fDmXVVextwa7v9crkMuTvZCttaMnsxO+9KKUNw== X-Received: by 2002:a05:600c:4750:b0:431:60ec:7a91 with SMTP id 5b1f17b1804b1-43184130160mr58600405e9.2.1729793471465; Thu, 24 Oct 2024 11:11:11 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:c04c:f30a:b45c:dbb]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-43186c0f248sm52551275e9.37.2024.10.24.11.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 11:11:11 -0700 (PDT) From: Jerome Brunet Date: Thu, 24 Oct 2024 20:10:40 +0200 Subject: [PATCH v3 6/6] hwmon: (pmbus/tps25990): add initial support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241024-tps25990-v3-6-b6a6e9d4b506@baylibre.com> References: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> In-Reply-To: <20241024-tps25990-v3-0-b6a6e9d4b506@baylibre.com> To: Jean Delvare , Guenter Roeck , Jonathan Corbet , Patrick Rudolph , Naresh Solanki , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jerome Brunet , Delphine CC Chiu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, linux-i2c@vger.kernel.org, Vaishnav Achath X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=17614; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=dnVmdKGfMttMrhnLQqDF6zBl6BlDDz2flspxyvtR8h0=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnGo20PyvNTjqqcXPBmS6F7j9CpNnxqycecokU4 msjgcyRM3WJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZxqNtAAKCRDm/A8cN/La ha0JD/wLII2AZhDufKeOzwaPF+VGMYlHQvkAADxMq7RsNe+s3bgozJL56t/DuBI8160blOA9YJB Ei4HRBQdXnlEHiPku7kv9X87yUubNOhG+SixqkFGiT4KtUO+4cl9bf1otlK5REt66NyetumDSnP bCwWbLzwe86MIXBbMBX/ydf2leuNHn7/Ojo63Hbyh4OIKmbHY+v1trSXrA+ckHJg1Zn75bGkrBi GaeogrTXXtFglBOk4FXDkDYPo9XHdaVjWpib8mQRuViELyPAJvJaghBvzFpToMeE6mGfPCShH6t PEyWdcRWXogPXzEXRhAPPPHeUeELK0viITmDQhp3Kqr2Qgb34wFxEKu6zURaZxZLEdnGiPXjadf zT8J6ItVCBfPDHymoHuNT9Fc6UWh8ibxAEhq31u7NfPd2s8bujzDsYN/cgj8mLI5Aioho6RtnjB F07Dwsye5yf9g/UhCRiDbpY6KJWc49Lr8nOZQ6RHnkWji+NAOzUXhi/iE7gP2lVyjcsxEaS9gmU O+0KLxS0eyYl5d6exvJMbRBS33yD9WKNKEasDJV/PNn2T58ct87m4+Y6bx2giI9UFOcm5hPLWMc kioUkdBbI/XhFW7RpZV9jJQeBxNQgLD41GXun5MCfyeL2rnrxU1oocarbeWIdA8Bcdp9rtU/0eB vwYMoxPlNwAGpXA== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 Add initial support for the Texas Instruments TPS25990 eFuse. This adds the basic PMBUS telemetry support for the device. Tested-by: Vaishnav Achath Signed-off-by: Jerome Brunet --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/tps25990.rst | 148 ++++++++++++++ drivers/hwmon/pmbus/Kconfig | 17 ++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/tps25990.c | 427 +++++++++++++++++++++++++++++++++++= ++++ 5 files changed, 594 insertions(+) diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 4d15664bc41e3a675154d60759a73d827c5a0b67..7a59f3374439fe39949b46f73fb= 0f9a68fb168ef 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -235,6 +235,7 @@ Hardware Monitoring Kernel Drivers tmp464 tmp513 tps23861 + tps25990 tps40422 tps53679 tps546d24 diff --git a/Documentation/hwmon/tps25990.rst b/Documentation/hwmon/tps2599= 0.rst new file mode 100644 index 0000000000000000000000000000000000000000..ed9e74d43e2c2f070d3abe987d9= 3bcdfcf2162ec --- /dev/null +++ b/Documentation/hwmon/tps25990.rst @@ -0,0 +1,148 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver tps25990 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Supported chips: + + * TI TPS25990 + + Prefix: 'tps25990' + + * Datasheet + + Publicly available at Texas Instruments website: https://www.ti.com/li= t/gpn/tps25990 + +Author: + + Jerome Brunet + +Description +----------- + +This driver implements support for TI TPS25990 eFuse. +This is an integrated, high-current circuit protection and power +management device with PMBUS interface + +Device compliant with: + +- PMBus rev 1.3 interface. + +Device supports direct format for reading input voltages, +output voltage, input current, input power and temperature. + +Due to the specificities of the chip, all history reset attributes +are tied together. Resetting the history of a sensor, resets the +history of all the sensors. + +The driver exports the following attributes via the 'sysfs' files +for input current: + +**curr1_average** + +**curr1_crit** + +**curr1_crit_alarm** + +**curr1_highest** + +**curr1_input** + +**curr1_label** + +**curr1_max** + +**curr1_max_alarm** + +**curr1_reset_history** + +The driver provides the following attributes for main input voltage: + +**in1_average** + +**in1_crit** + +**in1_crit_alarm** + +**in1_highest** + +**in1_input** + +**in1_label** + +**in1_lcrit** + +**in1_lcrit_alarm** + +**in1_lowest** + +**in1_max** + +**in1_max_alarm** + +**in1_min** + +**in1_min_alarm** + +**in1_reset_history** + +The driver provides the following attributes for auxiliary input voltage: + +**in2_input** + +**in2_label** + +The driver provides the following attributes for output voltage: + +**in3_average** + +**in3_input** + +**in3_label** + +**in3_lowest** + +**in3_min** + +**in3_min_alarm** + +**in3_reset_history** + +The driver provides the following attributes for input power: + +**power1_alarm** + +**power1_average** + +**power1_input** + +**power1_input_highest** + +**power1_label** + +**power1_max** + +**power1_reset_history** + +The driver provides the following attributes for temperature: + +**temp1_average** + +**temp1_crit** + +**temp1_crit_alarm** + +**temp1_highest** + +**temp1_input** + +**temp1_max** + +**temp1_max_alarm** + +**temp1_reset_history** + +The driver provides the following attributes for sampling: + +**samples** + diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index a4f02cad92fdadaafb15bb8459bf56f8e1722568..a3fd442e02774bf3909bf348e47= 1e04c4ab0043a 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -510,6 +510,23 @@ config SENSORS_TDA38640_REGULATOR If you say yes here you get regulator support for Infineon TDA38640 as regulator. =20 +config SENSORS_TPS25990 + tristate "TI TPS25990" + help + If you say yes here you get hardware monitoring support for TI + TPS25990. + + This driver can also be built as a module. If so, the module will + be called tps25990. + +config SENSORS_TPS25990_REGULATOR + bool "Regulator support for TPS25990 and compatibles" + depends on SENSORS_TPS25990 && REGULATOR + default SENSORS_TPS25990 + help + If you say yes here you get regulator support for Texas Instruments + TPS25990. + config SENSORS_TPS40422 tristate "TI TPS40422" help diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index d00bcc758b97200b80158e33b0ac41e6e5ac3231..3d3183f8d2a7060eb513f54f4f0= a78ba37c09393 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -51,6 +51,7 @@ obj-$(CONFIG_SENSORS_PXE1610) +=3D pxe1610.o obj-$(CONFIG_SENSORS_Q54SJ108A2) +=3D q54sj108a2.o obj-$(CONFIG_SENSORS_STPDDC60) +=3D stpddc60.o obj-$(CONFIG_SENSORS_TDA38640) +=3D tda38640.o +obj-$(CONFIG_SENSORS_TPS25990) +=3D tps25990.o obj-$(CONFIG_SENSORS_TPS40422) +=3D tps40422.o obj-$(CONFIG_SENSORS_TPS53679) +=3D tps53679.o obj-$(CONFIG_SENSORS_TPS546D24) +=3D tps546d24.o diff --git a/drivers/hwmon/pmbus/tps25990.c b/drivers/hwmon/pmbus/tps25990.c new file mode 100644 index 0000000000000000000000000000000000000000..03848d671c1014bdccabea62c2b= ce1b94e568df1 --- /dev/null +++ b/drivers/hwmon/pmbus/tps25990.c @@ -0,0 +1,427 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2024 BayLibre, SAS. +// Author: Jerome Brunet + +#include +#include +#include +#include +#include +#include +#include + +#include "pmbus.h" + +#define TPS25990_READ_VAUX 0xd0 +#define TPS25990_READ_VIN_MIN 0xd1 +#define TPS25990_READ_VIN_PEAK 0xd2 +#define TPS25990_READ_IIN_PEAK 0xd4 +#define TPS25990_READ_PIN_PEAK 0xd5 +#define TPS25990_READ_TEMP_AVG 0xd6 +#define TPS25990_READ_TEMP_PEAK 0xd7 +#define TPS25990_READ_VOUT_MIN 0xda +#define TPS25990_READ_VIN_AVG 0xdc +#define TPS25990_READ_VOUT_AVG 0xdd +#define TPS25990_READ_IIN_AVG 0xde +#define TPS25990_READ_PIN_AVG 0xdf +#define TPS25990_VIREF 0xe0 +#define TPS25990_PK_MIN_AVG 0xea +#define PK_MIN_AVG_RST_PEAK BIT(7) +#define PK_MIN_AVG_RST_AVG BIT(6) +#define PK_MIN_AVG_RST_MIN BIT(5) +#define PK_MIN_AVG_AVG_CNT GENMASK(2, 0) +#define TPS25990_MFR_WRITE_PROTECT 0xf8 +#define TPS25990_UNLOCKED BIT(7) + +#define TPS25990_8B_SHIFT 2 +#define TPS25990_VIN_OVF_NUM 525100 +#define TPS25990_VIN_OVF_DIV 10163 +#define TPS25990_VIN_OVF_OFF 155 +#define TPS25990_IIN_OCF_NUM 953800 +#define TPS25990_IIN_OCF_DIV 129278 +#define TPS25990_IIN_OCF_OFF 157 + +#define PK_MIN_AVG_RST_MASK (PK_MIN_AVG_RST_PEAK | \ + PK_MIN_AVG_RST_AVG | \ + PK_MIN_AVG_RST_MIN) + +/* + * Arbitrary default Rimon value: 1kOhm + * This correspond to an overcurrent limit of 55A, close to the specified = limit + * of un-stacked TPS25990 and makes further calculation easier to setup in + * sensor.conf, if necessary + */ +#define TPS25990_DEFAULT_RIMON 1000000000 + +static void tps25990_set_m(int *m, u32 rimon) +{ + u64 val =3D ((u64)*m) * rimon; + + /* Make sure m fits the s32 type */ + *m =3D DIV_ROUND_CLOSEST_ULL(val, 1000000); +} + +static int tps25990_mfr_write_protect_set(struct i2c_client *client, + u8 protect) +{ + /* + * The chip has a single protection mode, set it regardless of + * the specific protection requested + */ + return pmbus_write_byte_data(client, -1, TPS25990_MFR_WRITE_PROTECT, + protect ? 0x0 : 0xa2); +} + +static int tps25990_mfr_write_protect_get(struct i2c_client *client) +{ + int ret =3D pmbus_read_byte_data(client, -1, TPS25990_MFR_WRITE_PROTECT); + + if (ret < 0) + return ret; + + return (ret & TPS25990_UNLOCKED) ? 0 : PB_WP_ALL; +} + +static int tps25990_read_word_data(struct i2c_client *client, + int page, int phase, int reg) +{ + int ret; + + switch (reg) { + case PMBUS_VIRT_READ_VIN_MAX: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_VIN_PEAK); + break; + + case PMBUS_VIRT_READ_VIN_MIN: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_VIN_MIN); + break; + + case PMBUS_VIRT_READ_VIN_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_VIN_AVG); + break; + + case PMBUS_VIRT_READ_VOUT_MIN: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_VOUT_MIN); + break; + + case PMBUS_VIRT_READ_VOUT_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_VOUT_AVG); + break; + + case PMBUS_VIRT_READ_IIN_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_IIN_AVG); + break; + + case PMBUS_VIRT_READ_IIN_MAX: + return TPS25990_READ_IIN_PEAK; + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_IIN_PEAK); + break; + + case PMBUS_VIRT_READ_TEMP_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_TEMP_AVG); + break; + + case PMBUS_VIRT_READ_TEMP_MAX: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_TEMP_PEAK); + break; + + case PMBUS_VIRT_READ_PIN_AVG: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_PIN_AVG); + break; + + case PMBUS_VIRT_READ_PIN_MAX: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_PIN_PEAK); + break; + + case PMBUS_VIRT_READ_VMON: + ret =3D pmbus_read_word_data(client, page, phase, + TPS25990_READ_VAUX); + break; + + case PMBUS_VIN_UV_WARN_LIMIT: + case PMBUS_VIN_UV_FAULT_LIMIT: + case PMBUS_VIN_OV_WARN_LIMIT: + case PMBUS_VOUT_UV_WARN_LIMIT: + case PMBUS_IIN_OC_WARN_LIMIT: + case PMBUS_OT_WARN_LIMIT: + case PMBUS_OT_FAULT_LIMIT: + case PMBUS_PIN_OP_WARN_LIMIT: + /* + * These registers provide an 8 bits value instead of a + * 10bits one. Just shifting twice the register value is + * enough to make the sensor type conversion work, even + * if the datasheet provides different m, b and R for + * those. + */ + ret =3D pmbus_read_word_data(client, page, phase, reg); + if (ret < 0) + break; + ret <<=3D TPS25990_8B_SHIFT; + break; + + case PMBUS_VIN_OV_FAULT_LIMIT: + ret =3D pmbus_read_word_data(client, page, phase, reg); + if (ret < 0) + break; + ret =3D DIV_ROUND_CLOSEST(ret * TPS25990_VIN_OVF_NUM, + TPS25990_VIN_OVF_DIV); + ret +=3D TPS25990_VIN_OVF_OFF; + break; + + case PMBUS_IIN_OC_FAULT_LIMIT: + /* + * VIREF directly sets the over-current limit at which the eFuse + * will turn the FET off and trigger a fault. Expose it through + * this generic property instead of a manufacturer specific one. + */ + ret =3D pmbus_read_byte_data(client, page, TPS25990_VIREF); + if (ret < 0) + break; + ret =3D DIV_ROUND_CLOSEST(ret * TPS25990_IIN_OCF_NUM, + TPS25990_IIN_OCF_DIV); + ret +=3D TPS25990_IIN_OCF_OFF; + break; + + case PMBUS_VIRT_SAMPLES: + ret =3D pmbus_read_byte_data(client, page, TPS25990_PK_MIN_AVG); + if (ret < 0) + break; + ret =3D 1 << FIELD_GET(PK_MIN_AVG_AVG_CNT, ret); + break; + + case PMBUS_VIRT_RESET_TEMP_HISTORY: + case PMBUS_VIRT_RESET_VIN_HISTORY: + case PMBUS_VIRT_RESET_IIN_HISTORY: + case PMBUS_VIRT_RESET_PIN_HISTORY: + case PMBUS_VIRT_RESET_VOUT_HISTORY: + ret =3D 0; + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +static int tps25990_write_word_data(struct i2c_client *client, + int page, int reg, u16 value) +{ + int ret; + + switch (reg) { + case PMBUS_VIN_UV_WARN_LIMIT: + case PMBUS_VIN_UV_FAULT_LIMIT: + case PMBUS_VIN_OV_WARN_LIMIT: + case PMBUS_VOUT_UV_WARN_LIMIT: + case PMBUS_IIN_OC_WARN_LIMIT: + case PMBUS_OT_WARN_LIMIT: + case PMBUS_OT_FAULT_LIMIT: + case PMBUS_PIN_OP_WARN_LIMIT: + value >>=3D TPS25990_8B_SHIFT; + value =3D clamp_val(value, 0, 0xff); + ret =3D pmbus_write_word_data(client, page, reg, value); + break; + + case PMBUS_VIN_OV_FAULT_LIMIT: + value -=3D TPS25990_VIN_OVF_OFF; + value =3D DIV_ROUND_CLOSEST(((unsigned int)value) * TPS25990_VIN_OVF_DIV, + TPS25990_VIN_OVF_NUM); + value =3D clamp_val(value, 0, 0xf); + ret =3D pmbus_write_word_data(client, page, reg, value); + break; + + case PMBUS_IIN_OC_FAULT_LIMIT: + value -=3D TPS25990_IIN_OCF_OFF; + value =3D DIV_ROUND_CLOSEST(((unsigned int)value) * TPS25990_IIN_OCF_DIV, + TPS25990_IIN_OCF_NUM); + value =3D clamp_val(value, 0, 0x3f); + ret =3D pmbus_write_byte_data(client, page, TPS25990_VIREF, value); + break; + + case PMBUS_VIRT_SAMPLES: + value =3D clamp_val(value, 1, 1 << PK_MIN_AVG_AVG_CNT); + value =3D ilog2(value); + ret =3D pmbus_update_byte_data(client, page, TPS25990_PK_MIN_AVG, + PK_MIN_AVG_AVG_CNT, + FIELD_PREP(PK_MIN_AVG_AVG_CNT, value)); + break; + + case PMBUS_VIRT_RESET_TEMP_HISTORY: + case PMBUS_VIRT_RESET_VIN_HISTORY: + case PMBUS_VIRT_RESET_IIN_HISTORY: + case PMBUS_VIRT_RESET_PIN_HISTORY: + case PMBUS_VIRT_RESET_VOUT_HISTORY: + /* + * TPS25990 has history resets based on MIN/AVG/PEAK instead of per + * sensor type. Exposing this quirk in hwmon is not desirable so + * reset MIN, AVG and PEAK together. Even is there effectively only + * one reset, which resets everything, expose the 5 entries so + * userspace is not required map a sensor type to another to trigger + * a reset + */ + ret =3D pmbus_update_byte_data(client, 0, TPS25990_PK_MIN_AVG, + PK_MIN_AVG_RST_MASK, + PK_MIN_AVG_RST_MASK); + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +static int tps25990_read_byte_data(struct i2c_client *client, + int page, int reg) +{ + int ret; + + switch (reg) { + case PMBUS_WRITE_PROTECT: + ret =3D tps25990_mfr_write_protect_get(client); + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +static int tps25990_write_byte_data(struct i2c_client *client, + int page, int reg, u8 byte) +{ + int ret; + + switch (reg) { + case PMBUS_WRITE_PROTECT: + ret =3D tps25990_mfr_write_protect_set(client, byte); + break; + + default: + ret =3D -ENODATA; + break; + } + + return ret; +} + +#if IS_ENABLED(CONFIG_SENSORS_TPS25990_REGULATOR) +static const struct regulator_desc tps25990_reg_desc[] =3D { + PMBUS_REGULATOR_ONE("vout"), +}; +#endif + +static const struct pmbus_driver_info tps25990_base_info =3D { + .pages =3D 1, + .format[PSC_VOLTAGE_IN] =3D direct, + .m[PSC_VOLTAGE_IN] =3D 5251, + .b[PSC_VOLTAGE_IN] =3D 0, + .R[PSC_VOLTAGE_IN] =3D -2, + .format[PSC_VOLTAGE_OUT] =3D direct, + .m[PSC_VOLTAGE_OUT] =3D 5251, + .b[PSC_VOLTAGE_OUT] =3D 0, + .R[PSC_VOLTAGE_OUT] =3D -2, + .format[PSC_TEMPERATURE] =3D direct, + .m[PSC_TEMPERATURE] =3D 140, + .b[PSC_TEMPERATURE] =3D 32100, + .R[PSC_TEMPERATURE] =3D -2, + /* + * Current and Power measurement depends on the ohm value + * of Rimon. m is multiplied by 1000 below to have an integer + * and -3 is added to R to compensate. + */ + .format[PSC_CURRENT_IN] =3D direct, + .m[PSC_CURRENT_IN] =3D 9538, + .b[PSC_CURRENT_IN] =3D 0, + .R[PSC_CURRENT_IN] =3D -6, + .format[PSC_POWER] =3D direct, + .m[PSC_POWER] =3D 4901, + .b[PSC_POWER] =3D 0, + .R[PSC_POWER] =3D -7, + .func[0] =3D (PMBUS_HAVE_VIN | + PMBUS_HAVE_VOUT | + PMBUS_HAVE_VMON | + PMBUS_HAVE_IIN | + PMBUS_HAVE_PIN | + PMBUS_HAVE_TEMP | + PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_SAMPLES), + .read_word_data =3D tps25990_read_word_data, + .write_word_data =3D tps25990_write_word_data, + .read_byte_data =3D tps25990_read_byte_data, + .write_byte_data =3D tps25990_write_byte_data, + +#if IS_ENABLED(CONFIG_SENSORS_TPS25990_REGULATOR) + .reg_desc =3D tps25990_reg_desc, + .num_regulators =3D ARRAY_SIZE(tps25990_reg_desc), +#endif +}; + +static const struct i2c_device_id tps25990_i2c_id[] =3D { + { "tps25990" }, + {} +}; +MODULE_DEVICE_TABLE(i2c, tps25990_i2c_id); + +static const struct of_device_id tps25990_of_match[] =3D { + { .compatible =3D "ti,tps25990" }, + {} +}; +MODULE_DEVICE_TABLE(of, tps25990_of_match); + +static int tps25990_probe(struct i2c_client *client) +{ + struct device *dev =3D &client->dev; + struct pmbus_driver_info *info; + u32 rimon =3D TPS25990_DEFAULT_RIMON; + int ret; + + ret =3D device_property_read_u32(dev, "ti,rimon-micro-ohms", &rimon); + if (ret < 0 && ret !=3D -EINVAL) + return dev_err_probe(dev, ret, "failed to get rimon\n"); + + info =3D devm_kmemdup(dev, &tps25990_base_info, sizeof(*info), GFP_KERNEL= ); + if (!info) + return -ENOMEM; + + /* Adapt the current and power scale for each instance */ + tps25990_set_m(&info->m[PSC_CURRENT_IN], rimon); + tps25990_set_m(&info->m[PSC_POWER], rimon); + + return pmbus_do_probe(client, info); +} + +static struct i2c_driver tps25990_driver =3D { + .driver =3D { + .name =3D "tps25990", + .of_match_table =3D tps25990_of_match, + }, + .probe =3D tps25990_probe, + .id_table =3D tps25990_i2c_id, +}; +module_i2c_driver(tps25990_driver); + +MODULE_AUTHOR("Jerome Brunet "); +MODULE_DESCRIPTION("PMBUS driver for TPS25990 eFuse"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(PMBUS); --=20 2.45.2