Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1723336lqa; Mon, 29 Apr 2024 18:15:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWjJh2LpCo3cBGkABj2h5ak9K7g863moioCWiB9UGMzIgE8G+d616RhpWNy8Wnz11Oy27BeEVuA5SSgpx5RqehecdS2I65eaJdBm0csUA== X-Google-Smtp-Source: AGHT+IGLbaA/45AqzlXPXS4LkeF3AIi1H5iyZoP7noABm4ShHgvWXjMv1+As+2tdrOtKW5KYWfrP X-Received: by 2002:a50:c082:0:b0:572:7ca5:1b58 with SMTP id k2-20020a50c082000000b005727ca51b58mr4779641edf.6.1714439719794; Mon, 29 Apr 2024 18:15:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714439719; cv=pass; d=google.com; s=arc-20160816; b=uWdocnd4EA7Wnpwrj9QCUhUVGT2ma9MDikHvSogAPW3k8DSt0zROQLtZ+GqvxwdOXV f9fDfc2Q+iHdYUVnEGuZI1vC20c5w9GQGI8QzZVMiGirF4d7wWRhr+D1qLOGu9swfzKc XjzXWkA0VQBV/jCGOzOxN8M5Ov/SNeVCsILoV7JZ+JafD6dOxZ5Nli676o9BgZFU7oWa 4rqj2gJE+lDkhLVNKPGdz0Sp5IZW2+aZzFYq9tiXEkqqJdLkcS7ec0b8bIPjxenPdKpS 1G3bk4SPZUfXmh4wfPHwPw1Ca31N4u251X04kZrS8l3CWmOhTpP3WJeHNrQvTwXahbtC rKQQ== 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=B6BCyjHZeffhbukEtNqY0Q70YLnns0yN6wV8H7xbxEM=; fh=9+JPiKUqmiwg7nrgynbn+qu8x0UhUJwyp0gAHVwwYQs=; b=Y+jzqn8M75218wrduA9ECf2+0h9ia8uc7pfg3awYiPfQWicFmOKA5Yq0Lz7QABsLkK 0n4V6Ev5evc4ze87mz+bERrLkJ7qtLPlKS9xMFi6mcFS88x13dINg1hNVPbIdMbqWzMp iVY1w+HvRhOx4VIWSfJAwHLE6D+WtDzmAIXwwIjSIOjOCdAS2+eUdEcx11tC9erhgt5h +gzoE9qqnynESZCu/JgAf32Ff66IwSMhdi+PTWS4tK/C718r7mQM1uo9sE1lvplw/ao1 4sOuXeo3YZKrvimS3eELklXbLnzJUeumNGMndnYN8oaWWus0+tf2QZHJkQsMv2qXdH0N Uemw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sz3G6uQo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163211-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163211-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v16-20020a056402349000b005726d40165asi3398356edc.174.2024.04.29.18.15.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 18:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163211-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sz3G6uQo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163211-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163211-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 84B381F22FF2 for ; Tue, 30 Apr 2024 01:15:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D49B91FBA; Tue, 30 Apr 2024 01:15:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sz3G6uQo" 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 094B217F5 for ; Tue, 30 Apr 2024 01:15:10 +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=1714439712; cv=none; b=lGZQb64gFuc6I95Bp3B5ed/eIhngDjY9Z+cF/yN0dNvTI8UPLSmmS42xaKAne90Zj9eu/R0GUhQbJ+oZqKp6XFXdC1CPKpXTjBQcLbxFo3W+VFEN3AOFCS06416k+40pE45RuJQxkwSGt94610JXaLL4GkAlgaJCCoBrVtUO88Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714439712; c=relaxed/simple; bh=gQYHXdjYcm9SnzVQ18TbG2wPyA/Wtk9x8tzzwzKjkE8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GgKmEvwIGZa865R5YgAJMJRmIfDZ6HsFSmpSWMaEAwvHXR27w/v5ndWS9qjHCi5p5mtZ08tKu1rF+ekmKmBkA/vMncIcRY9AUFMde0pIYc7+/l+qfUzkULgXZLAmre22F11os946t4w4zVLsgPNUgLQG1fjkderjvLszW38VwZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sz3G6uQo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B3A4C113CD; Tue, 30 Apr 2024 01:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714439710; bh=gQYHXdjYcm9SnzVQ18TbG2wPyA/Wtk9x8tzzwzKjkE8=; h=From:To:Cc:Subject:Date:From; b=sz3G6uQoo+dXL/o10QUko0rSzSmyUBJqE/A4kr7Z1Gm5h5H7Tnd5CkjOWlSJhnq2L eLBeuv020xBXOlvMtEVIRlfMEn9BVi8Wjre3VabwRe0ltUCe7z25ppMwxLui2LGRsN 5Xdv3WPz2ecJvvaN6sjH9ocR+XqxApOrqJm7mkztWD8xMAy+Gj3jk2hf36gyEacayV fJrU3sZn6EiO1NWwQ2K2ZO3137N1bcGXiG2/LRyoP8jYRz9eeL2GQg0jZqDuupRICb OhiJGmfNS6AXnGPapd9QrCVWYG6MFSm+Oltc0HyrDecDdlWEWzU5bGwbOhGGsfXg0N Fook4ARNfV69A== From: Jisheng Zhang To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Subject: [PATCH] regulator: rt5739: Enable REGCACHE_FLAT Date: Tue, 30 Apr 2024 09:01:40 +0800 Message-ID: <20240430010140.2027-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/rt5739.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/regulator/rt5739.c b/drivers/regulator/rt5739.c index 91412c905ce6..47172b11301c 100644 --- a/drivers/regulator/rt5739.c +++ b/drivers/regulator/rt5739.c @@ -24,8 +24,11 @@ #define RT5739_REG_NSEL1 0x01 #define RT5739_REG_CNTL1 0x02 #define RT5739_REG_ID1 0x03 +#define RT5739_REG_ID2 0x04 +#define RT5739_REG_MON 0x05 #define RT5739_REG_CNTL2 0x06 #define RT5739_REG_CNTL4 0x08 +#define RT5739_MAX_REGS (RT5739_REG_CNTL4 + 1) #define RT5739_VSEL_MASK GENMASK(7, 0) #define RT5739_MODEVSEL1_MASK BIT(1) @@ -236,11 +239,46 @@ static void rt5739_init_regulator_desc(struct regulator_desc *desc, } } +static bool rt5739_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case RT5739_REG_NSEL0 ... RT5739_REG_CNTL1: + case RT5739_REG_CNTL2: + case RT5739_REG_CNTL4: + return true; + default: + return false; + } +} + +static bool rt5739_readable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case RT5739_REG_NSEL0 ... RT5739_REG_CNTL2: + case RT5739_REG_CNTL4: + return true; + default: + return false; + } +} + +static bool rt5739_volatile_reg(struct device *dev, unsigned int reg) +{ + if (reg == RT5739_REG_MON) + return true; + return false; +} + static const struct regmap_config rt5739_regmap_config = { .name = "rt5739", .reg_bits = 8, .val_bits = 8, .max_register = RT5739_REG_CNTL4, + .num_reg_defaults_raw = RT5739_MAX_REGS, + .cache_type = REGCACHE_FLAT, + .writeable_reg = rt5739_writeable_reg, + .readable_reg = rt5739_readable_reg, + .volatile_reg = rt5739_volatile_reg, }; static int rt5739_probe(struct i2c_client *i2c) -- 2.43.0