Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1722926lqa; Mon, 29 Apr 2024 18:14:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUR6Qz69FnWLsKDHkwPkU/CtCgSU9Zct88K2J150BWR2IiZR1TGO8Iy6r6OIqAq4a94tX5xe3M4wRONdwdNfpanpJ7dks5wtzQDO6DMmA== X-Google-Smtp-Source: AGHT+IG9g2I2ux945/u/m47cdbV3FW2sLIb2xCeNg14W9MMjROMpr5AnRnpq/MrC9Ud/GnT5GSVy X-Received: by 2002:a17:902:f601:b0:1eb:5222:7b8e with SMTP id n1-20020a170902f60100b001eb52227b8emr1759957plg.17.1714439651643; Mon, 29 Apr 2024 18:14:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714439651; cv=pass; d=google.com; s=arc-20160816; b=moJwJh8ITogRmc+pMYOAoHCyiCBZbQGzMg9KjtkXS2cGUAwg4pkQjQGinBZ37iYEwj swhM92ZFIrNbABQc38a1fhB+UttC/38cfPGzQIwX6Qr/2CmOwwuAZpEXvrVVDmfyYDAM UaFUKRSHFuhZgwIAmxJDBYta6Y0RqLv6WNarJ0Sti5jM/rgDhB9AFFXJje6qPEq4Jo3/ 8tm6kuO/t19WlmvTHeAWS4etnh1SYxjWOaFWRFIDglNnSRKvAmp82NTIXVenl3SUdyzp gOBypSN4R+6jcx1e+ILxwfI7yLKWI/38isBo0xRX7CfsTER3iZaP7zJSilM+KYUakYJf Yoow== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=hpRExwaPb72MrCGHa+BGcFXge7HEFf6AFegV0TMlqTk=; fh=9+JPiKUqmiwg7nrgynbn+qu8x0UhUJwyp0gAHVwwYQs=; b=UYm64nxFLXfoCEqWtFNhGW4SElIzvobmZbZ8QolY3/bK8ca1e8QJzdJ8Z0Og4dlfzV WHHG7KC+PzXKcRT8Vf13f24lch6BdJwaFjx9Fy7oGlo4DF/yUZP35w3WSAgEkFD521Wf BLJxl2MfnGwkpLwoJXwdYYBYm1WZzNbG8e/o9/bl5D08ZeuuolGOTLA2VHDRkAW8MKDb /sTdvq7RtXIfpzxOGwL2KBPJOlAa5pzqCJpIsgoijg+4KvmDp9mfllGKKSUiEV1A6R3i XValFDmgYRlhUKhTmMBCzdFGTu1WJHjay4QWMb5jeFrveCrlQOeEYlLHgZ2Xy8VM948N q9XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RY/Oe6je"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 h4-20020a170902680400b001e8c408be43si18361787plk.407.2024.04.29.18.14.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 18:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163208-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=@kernel.org header.s=k20201202 header.b="RY/Oe6je"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163208-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 4AB44282950 for ; Tue, 30 Apr 2024 01:14:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EE541FBA; Tue, 30 Apr 2024 01:14:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RY/Oe6je" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39B0E17F5 for ; Tue, 30 Apr 2024 01:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714439645; cv=none; b=kas9wq4NN1DL1SbYRIXFfGdqs2A/8ZM0bR4AHovi67Ue9N3mwx54+9mS1JW10t1iBhDe2ApZIbZfWicwC1MxC8Oa+FsgNcfHNJCTPSl4opdPsfA5mPGjuMIyM4sgt58hlLuImZDCDJEHShu7rLjJhqhwD7s7IU/fkahxJDCW3Ns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714439645; c=relaxed/simple; bh=9MnlGl0zcfF4okBZbEu5Jw7xYOCa4VEdKmUbyb/tXIc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=H14x+Js7RpGJs0ja3HQno/tLYvBnqU0/DR2gxCr77KfMbxvfBv2lBuV+Gl1/gzAFeOo6Dkuq8jz/bnvKW7K5Gznl1CPXbv1mSqQtJOZgssqgAW5lVm1qegyDNYfTLAXarIzIVfJI9MfzUM2R79izSmFR+0lw4vsGmrKXxw/4E8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RY/Oe6je; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E539DC113CD; Tue, 30 Apr 2024 01:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714439644; bh=9MnlGl0zcfF4okBZbEu5Jw7xYOCa4VEdKmUbyb/tXIc=; h=From:To:Cc:Subject:Date:From; b=RY/Oe6jeh3VtfvhYgAfb1pFe16xIGBgby9Q0xf6m2mgH8aLN4fp64DjenoU05B2jY nUCXMDUQ+4psjkVy0U5i4SqZGlRRicaRdoGPgTGN5UXM8l1c96HiSsmPe4KkTiXANO BPD7/3Vj+EMexTSSlFiNZHrtXHCyhmxxx3+yrnXQaKFsdDtB2Lra2wnI8w1b+aS+Pw GpwgOIHID2MLnQP3tEfVWOdLU72rN9neLYj4XhUo8919ER8PrNNZWMX+O/AALupybT xJ78e0dAuzyZQ4vXPHiibne/xN47x8BQ3j9RyW5uK8f7tpMctUCmM5wmiaF3ZjNtfG ibA02Uv8YS5WQ== From: Jisheng Zhang To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Subject: [PATCH] regulator: tps6286x-regulator: Enable REGCACHE_FLAT Date: Tue, 30 Apr 2024 09:00:19 +0800 Message-ID: <20240430010019.1980-1-jszhang@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Enable regmap cache to reduce i2c transactions and corresponding interrupts if regulator is accessed frequently. Since the register map is small, we use a FLAT regmap cache. Signed-off-by: Jisheng Zhang --- drivers/regulator/tps6286x-regulator.c | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/regulator/tps6286x-regulator.c b/drivers/regulator/tps6286x-regulator.c index 758c70269653..adef970972a7 100644 --- a/drivers/regulator/tps6286x-regulator.c +++ b/drivers/regulator/tps6286x-regulator.c @@ -19,13 +19,49 @@ #define TPS6286X_CONTROL_FPWM BIT(4) #define TPS6286X_CONTROL_SWEN BIT(5) +#define TPS6286X_STATUS 0x05 +#define TPS6286X_MAX_REGS (TPS6286X_STATUS + 1) + #define TPS6286X_MIN_MV 400 #define TPS6286X_MAX_MV 1675 #define TPS6286X_STEP_MV 5 +static bool tps6286x_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case TPS6286X_VOUT1 ... TPS6286X_CONTROL: + return true; + default: + return false; + } +} + +static bool tps6286x_readable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case TPS6286X_VOUT1 ... TPS6286X_CONTROL: + case TPS6286X_STATUS: + return true; + default: + return false; + } +} + +static bool tps6286x_volatile_reg(struct device *dev, unsigned int reg) +{ + if (reg == TPS6286X_STATUS) + return true; + return false; +} + static const struct regmap_config tps6286x_regmap_config = { .reg_bits = 8, .val_bits = 8, + .num_reg_defaults_raw = TPS6286X_MAX_REGS, + .cache_type = REGCACHE_FLAT, + .writeable_reg = tps6286x_writeable_reg, + .readable_reg = tps6286x_readable_reg, + .volatile_reg = tps6286x_volatile_reg, }; static int tps6286x_set_mode(struct regulator_dev *rdev, unsigned int mode) -- 2.43.0