Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1723373lqa; Mon, 29 Apr 2024 18:15:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDnP1AUyqZckque5U7PhYsZC2zeBjkG/Xqq7DzShGNhpNQJcLuvTEOK4Yq2ODS1SNixcTZ+7rWuiIRbvsHA/M4gf04TSKTFqJ+hMe1Jw== X-Google-Smtp-Source: AGHT+IGHJLZaAl3KUKqK/DOP/eZPUv6BguwUajlUMlRmnUTfxsDsrvfWhicOT5278mHZLPEMaUrn X-Received: by 2002:a05:6358:3115:b0:186:b6ac:8ce2 with SMTP id c21-20020a056358311500b00186b6ac8ce2mr1377361rwe.6.1714439725968; Mon, 29 Apr 2024 18:15:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714439725; cv=pass; d=google.com; s=arc-20160816; b=ZyH57KshrTwcdSL7EJrUyI2AzFID+WtazaPdPi9KLAbE2EtdLc971Fy+K2xFv4TVnD trYjWfCCyH7v3FsB1rtkY/cjh7HC7P4AxXTrjlZ4j3pSDjo6K/CM3BtLgKOWtDENSSea wpjQ8rzPrgAuld6tgCNICEJs9OLrnYisQOWOz8DHPJkLy/feXkgkcrAUcidCwh3EuR1+ bSQODBIqNGERArg5A1Q5Ro+Wtyse2s2uYLZeic1ZK8cV7pNX/Sq7U07K+/59P1fzWqEZ bOa6nHOJkq8eO5DY2AHLpxtu8JH8O9vaakdcFKzCiQa6/aO7buF3M7/Pf3LcBZMbZkdJ OHIQ== 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=wBAFsFKXQO2dxzh4xHCsSBLfjFrkZseJH5ITMTuLd4g=; fh=9+JPiKUqmiwg7nrgynbn+qu8x0UhUJwyp0gAHVwwYQs=; b=gDMV1a4xU+RORbaK7ewhklH9wkImZWyVjeELOfY+4U4C5sRVFaR0PsASkM2tImlbVP sV3wqHUq8PIkzX/d5dSAOA64PcIlSZWubM6POC56GG3Yw5WIuUlayM3L3ZlEAoo16chW Z0UHUa6FRRSEkCefSnXmRz4V1xRcBnbXCc9XyBczCZ3SKuEo+33uDmu8Q5lpdMc2hKWS 6s3Euyuhe2mkFDNugc2oIzo8evL0LtqTtegCiz2/BL9oI86HMmVDOEDxtCnsn6W+5lCw dKyQ1pTid/ZGRrzhs6swdeSDZRDIVwwz7XZj2FJRv4fxOL6BT1Ydiywn8BoxCJ1NBAP1 0xeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f2rLBRUZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 32-20020a631960000000b005f751900b65si20518691pgz.486.2024.04.29.18.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 18:15:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f2rLBRUZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163210-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3534AB22526 for ; Tue, 30 Apr 2024 01:14:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FD012107; Tue, 30 Apr 2024 01:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f2rLBRUZ" 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 476291870 for ; Tue, 30 Apr 2024 01:14:48 +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=1714439688; cv=none; b=Mpfa1ym/gMh8TZyII7xlQxpkfpshcPHvQwKpH4rTrdEKcOaV9BeRvz3WEePWuSmb9Mpv8AqxFC6ashEelzdbgEHxilwdsmt3t+TqTzU+7pfxdgZCP+MwQxaVYsLgmYQmODVWU/einAz49ELQsZl3ZWrREgWqpuKANStbImkPPwg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714439688; c=relaxed/simple; bh=8J0qweWKPI2qSY7aVbqXXKii2wzAW9xiIZPhy3dnyfQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WPmmj8lWcSN3sdapuLBOa1x+ISkr6B6HnKgg/vn1Sn+vOyOMBbduxw/JarY1fy9LwXkGhw3ZqbpZ5Tngwcduj14V0uy0noC0vWEOeuHhLkHQMEZ8qrhMGtOUCQ2g3hDp4krPFP4GV365khmUndPRHnfZypwODzLhC76RY/Mj3es= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f2rLBRUZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38096C113CD; Tue, 30 Apr 2024 01:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714439687; bh=8J0qweWKPI2qSY7aVbqXXKii2wzAW9xiIZPhy3dnyfQ=; h=From:To:Cc:Subject:Date:From; b=f2rLBRUZ8q95v9pN0mAu9T3AXQCIXMlpuJCzWVfZ2qv7QN4TpECelLSXrljMtH06H qsDMvuE3b2lRHn6wTMc5cIg3u4IQSFJjY3ZZ2YXt+7obYIHJR1W6raDjPQO3hzDjNa X+j2FZ+JodyRVLtOab1welxqI8jB8bUckpuFbgaQ+RYWY/rPvCezXIFwxS4m2srs8R 91U/yC6azHI4DpAGtcqxqlgXQCJ0gAq/LMM5fcF7kaFO2Wh8JX4DBXVzgX4AWVpPY0 2Ugwb1s/zPLPg8nO8rFVWj5pbmxySj0juuWNIuSwBBYNcPgohoK2Vy0mpbTbEnUpGq dcuvbtNf5GHDQ== From: Jisheng Zhang To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Subject: [PATCH] regulator: tps6287x: Enable REGCACHE_FLAT Date: Tue, 30 Apr 2024 09:01:08 +0800 Message-ID: <20240430010108.2004-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/tps6287x-regulator.c | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/regulator/tps6287x-regulator.c b/drivers/regulator/tps6287x-regulator.c index 9b7c3d77789e..d4dffb87e858 100644 --- a/drivers/regulator/tps6287x-regulator.c +++ b/drivers/regulator/tps6287x-regulator.c @@ -26,11 +26,44 @@ #define TPS6287X_CTRL2_VRANGE GENMASK(3, 2) #define TPS6287X_CTRL3 0x03 #define TPS6287X_STATUS 0x04 +#define TPS6287X_MAX_REGS (TPS6287X_STATUS + 1) + +static bool tps6287x_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case TPS6287X_VSET ... TPS6287X_CTRL3: + return true; + default: + return false; + } +} + +static bool tps6287x_readable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case TPS6287X_VSET ... TPS6287X_STATUS: + return true; + default: + return false; + } +} + +static bool tps6287x_volatile_reg(struct device *dev, unsigned int reg) +{ + if (reg == TPS6287X_STATUS) + return true; + return false; +} static const struct regmap_config tps6287x_regmap_config = { .reg_bits = 8, .val_bits = 8, .max_register = TPS6287X_STATUS, + .num_reg_defaults_raw = TPS6287X_MAX_REGS, + .cache_type = REGCACHE_FLAT, + .writeable_reg = tps6287x_writeable_reg, + .readable_reg = tps6287x_readable_reg, + .volatile_reg = tps6287x_volatile_reg, }; static const struct linear_range tps6287x_voltage_ranges[] = { -- 2.43.0