Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp100664lqh; Thu, 30 May 2024 15:40:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVy0DjXzWliZGluJss/u16MhyLjl7PxsSl1dOJEXguwpaP2HtUG+d34B8QYwHMap0j1/GMdNZSEA/4ydgYP6T85VeHCguvxp3oVeXq7xw== X-Google-Smtp-Source: AGHT+IHmOX14Z71R0MS/DgP9zlQAHMcGt1kJfjFj/0XpW3gVNCkMJ0nmJyzmHudHZRr9OmU2YY5n X-Received: by 2002:a17:903:22cd:b0:1f3:7a3:8fc9 with SMTP id d9443c01a7336-1f636fc5292mr2853425ad.3.1717108820726; Thu, 30 May 2024 15:40:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717108820; cv=pass; d=google.com; s=arc-20160816; b=GIwN2TTUrpbmN5dl68QsmC5CSGYsFx9MPyTzDvIMMjAdcYMmm/kA5f7GWSxZadhkLH uOOO3pGJn+0YYNiLYECBJGHc/iOgW/NNTo/0q3Bnru2mB2aMznS54P1evtmpU5MbA7e3 IzHB8VP7pQXIinGMmc+q7ZJLOxf77EzygmMvyG4vUv8Nkf7AKT6SZeK4dEfzyogR6Pz/ 2O+KUH/DWaoQxH3cfIb2EtARIA85FLsUtblquhgc7M8STci1B+AG4nJI4st1EBlksyqA nBC4nMjdVX0QQgpYP2itR80Q6PvwnnKmfd97aAIUuvjl6touTz0LQazWclcbLjvQwfNq f7rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:sender:dkim-signature; bh=RATLX8vwG5qFLWJv5e+WyDP7UKBpMbaga/mz8MYejto=; fh=0ol3Vg8TLSsH2ItQlUn7jW6ng2cy5ytEWzeL10E4r5w=; b=Qla8OusTOAsalScHzNjFQWR3buhScT3O0pf3hQ5tvyukdJabge53HkewIjmW3G0bMT f+QPDRNEqDFprXrJ7zgyF+8d3+6WvrOZ6BQDtnCuy+VWxWJr7I0Q/vI4uQh6guYZPsyy 9YaL/zxwP0jnCDK9VbTO0bbJMYNXBdAKz1WwuUfTfqqQK4BrLVwgHZfcqiZQ6ONTvqci hBxmyGdEg+ciVqlar5RZXl/Zx0O9eWbgVULwtCGImril/gCCI3mrq+x/lGg4p8ViY2C9 ignj9JSRv4MgFbUDo13iiySMYcIMHkLEC8CD6ynVraaDHsdE7bW9ucH7EdW7Upqu1mLr 5MKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nGr8rYHP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-195975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195975-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233d298si4050135ad.15.2024.05.30.15.40.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 15:40:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nGr8rYHP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-195975-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195975-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E9FA8285245 for ; Thu, 30 May 2024 22:40:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A402C1862A2; Thu, 30 May 2024 22:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nGr8rYHP" Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 60EAD184135; Thu, 30 May 2024 22:39:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717108788; cv=none; b=aqQn0MNKcsP7Hd8AF0fFITpxYDNYTnaridjuBlrW3A/jXF9jcqOKC3R1MTCadCftk8uhdrV4Ini2y80SLuZAGmPu6W6WXAW2AjQCrt7FUVGv8eSUkLK1wtP5XC8Ixxc79Br9gsJ0HM25Pm2q6bWauxu+kbwpYQ2f5PAZ7Lb4Bho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717108788; c=relaxed/simple; bh=ObfyRu7oiPBL1J7xJbM/pHFssCtum2gBV4H+0RGWvNw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JhFDSzKfK0DODNPtL7yTWX90PyVez/jXjQyFkk5G8AZZVt+J9RYI96a4ANvXZQPcsufyIfDFZckHj92U5vkfSlG4TQbi+BoquyxzfoblyVrEwgfVjRe2AISNF82le1LTemScHAmYT/CeEsYniyZsCKvLfWPeT8UmUjJ7TFlQhAg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nGr8rYHP; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7024426c75dso206594b3a.1; Thu, 30 May 2024 15:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717108786; x=1717713586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=RATLX8vwG5qFLWJv5e+WyDP7UKBpMbaga/mz8MYejto=; b=nGr8rYHPAGJeG5NFK3wWdsisEj9FFzmssIwUu6rCHXot9GW+0tSbSytwGnELjbC8Wq pEgZA63/muyMoQ0+4Al2pFX2+fXRiuz5A3J95+xR8TLBI3EwbNz6rT/cBZ0tlS4LIduN dlHnNzFCHfASEEKkpDsNF4VUPoetxYerAFX7n7M0sSzkvcx4SZD4xyFQwg0osEUC58Fd +upRhrTTUDwodXnTFxrwOeCbpg0NRWts/7w06t/6ya6ChVGQSUMJ6cJgES30MckrnJPS rP4L3tV1Bp+o0buEK+CmBDcoaxB6zHOrwbWhr5FZHYbKd7ngYYsKbue77IhnuO9/ohIX agEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717108786; x=1717713586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=RATLX8vwG5qFLWJv5e+WyDP7UKBpMbaga/mz8MYejto=; b=DpGKaBdVohRu1+NnnHca+RWQ1P9g5F8Cyal2tUJpIlJRfCaSgvSnHX4c9qteHkwyE2 E64MXCYYVz+2OA3Fd89Grn+5AwXc0zzhE70uCeYwxMf+ImgBymv3EFEULT07GBsQJsi6 4DJ/Tv9KR87Y1vOIMle8pcyHJCRy3XgMGc/4tGIiZIyMci4uSZMoVRzw7UnaC3kvfOu9 giq5p4F45QAby75kESwGcNTOWGsdkPLHM9EedxT1cSMMMVaZD3b+9uZCDxOJnipfCNUZ b4+ED42D6wedGHc5Dh/HNfBHkeB7pFeYo6y8UgOqa/4c+cxvyTBHfQJaWR+kuNUHPwgA i1ww== X-Forwarded-Encrypted: i=1; AJvYcCUIeFaHhZDQAB6qOW1+gXCE+PWE9DPbenmBf87TlX3X/eqQbk8xeDIbmkoLc8/GynaHTGFBeP9HpTHACdQMQjABRHnHHPLBO+TV9gKr X-Gm-Message-State: AOJu0YzTYcACUfYrdkpqG8/XeM+9vvTdyP/dFRs3WFbxvi7mCeVFJ9Rl llsIOXAPJAR3gRWv12o3P+/g28bCWty+bg2iDE3/jcmbZ09yzfAu9Cw/dg== X-Received: by 2002:a05:6a00:18a9:b0:6ea:b48a:f971 with SMTP id d2e1a72fcca58-702477bd92fmr255317b3a.2.1717108786156; Thu, 30 May 2024 15:39:46 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-702423cce7asm227776b3a.40.2024.05.30.15.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 15:39:45 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-kernel@vger.kernel.org, Armin Wolf , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?Ren=C3=A9=20Rebe?= , Guenter Roeck Subject: [PATCH v2 3/3] hwmon: (spd5118) Add suspend/resume support Date: Thu, 30 May 2024 15:39:39 -0700 Message-Id: <20240530223939.1027659-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240530223939.1027659-1-linux@roeck-us.net> References: <20240530223939.1027659-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add suspend/resume support to ensure that limit and configuration registers are updated and synchronized after a suspend/resume cycle. Cc: Armin Wolf Signed-off-by: Guenter Roeck --- v2: New patch RFT: I tested the patch through a suspend/resume cycle, and it seems to work, but I am not sure if that had any effect because, after all, the memory is still active during suspend/resume. I was unable to test a hibernation cycle with my system. drivers/hwmon/spd5118.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c index 3c75964a0fba..ea807a77a4ee 100644 --- a/drivers/hwmon/spd5118.c +++ b/drivers/hwmon/spd5118.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -432,6 +433,8 @@ static int spd5118_probe(struct i2c_client *client) if (!spd5118_vendor_valid(bank, vendor)) return -ENODEV; + dev_set_drvdata(dev, regmap); + hwmon_dev = devm_hwmon_device_register_with_info(dev, "spd5118", regmap, &spd5118_chip_info, NULL); @@ -449,6 +452,31 @@ static int spd5118_probe(struct i2c_client *client) return 0; } +static int spd5118_suspend(struct device *dev) +{ + struct regmap *regmap = dev_get_drvdata(dev); + + regcache_cache_bypass(regmap, true); + regmap_update_bits(regmap, SPD5118_REG_TEMP_CONFIG, SPD5118_TS_DISABLE, + SPD5118_TS_DISABLE); + regcache_cache_bypass(regmap, false); + + regcache_cache_only(regmap, true); + regcache_mark_dirty(regmap); + + return 0; +} + +static int spd5118_resume(struct device *dev) +{ + struct regmap *regmap = dev_get_drvdata(dev); + + regcache_cache_only(regmap, false); + return regcache_sync(regmap); +} + +static DEFINE_SIMPLE_DEV_PM_OPS(spd5118_pm_ops, spd5118_suspend, spd5118_resume); + static const struct i2c_device_id spd5118_id[] = { { "spd5118", 0 }, { } @@ -466,6 +494,7 @@ static struct i2c_driver spd5118_driver = { .driver = { .name = "spd5118", .of_match_table = spd5118_of_ids, + .pm = pm_sleep_ptr(&spd5118_pm_ops), }, .probe = spd5118_probe, .id_table = spd5118_id, -- 2.39.2