Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1097395pxa; Thu, 20 Aug 2020 02:20:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaIx4l5GsnCSTFbFcBjwM+IgmUuHcy9hxB+Mjd3gJhBZmqNPZO+g4FZVCo1KK/kGq/JUfR X-Received: by 2002:a17:906:3f91:: with SMTP id b17mr1376827ejj.185.1597915206417; Thu, 20 Aug 2020 02:20:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1597915206; cv=pass; d=google.com; s=arc-20160816; b=S8w5bUx3EJOqGDqY87GyaOjYsp2Ta904hZy9byM3vsXcwtlJGsfigTBMJ8izP7qTpE x6RIhuE1oSUU56MDg2/OrY4Dii2WSasCOhNZVZ6V7sB+L9rlyLX1w5TDn/KbHxIJCtVC rd49F5kLCabr/fm/CdKUF6+oodocWW3UxHYIiha5hpjoxX5FLLLR5vOu/C+NNWCtstBq 6hp/IUHEOinXB4xqEcebQntC57LL5IE9xyrIhq8to97ps7ywVw2CKdSCoGN3Rb3jB9di dwxsTwycGvNEmqzMgXFOBkPgerIMGmPs/ca9zMuaaHFsrSdkKyrj/WmWpbOmdV4uajEq fo6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=GM6/JOlbgW/DXaQv1/61oneRFPp9b+EVt2boDh6c2DY=; b=YEEAYYV6sSB6ijNpAX76I+wIWwZzAh+R1KX4VHDIjzPCWjYcExAIGHhBy2uXdcgZzg LlKayCdUm04dtMbo6dukFS56iAv4SsAfMnDUbbYuqgeieq/N2usiuxbJ4qmD0WIqhlYC oq+LsLeGD0cxAGlBkXvOWHGCIgKRIHhNGzoWKDknAQQJXp0ro3uZqcEbO6jh3qFnmD1H IyNaDqDvUFaqjW5PvBLsfJERh7Fas2lqBEGRRsn8HN5Rz5l89abTEeA70uJsnwD8cSV+ Tj17ejnjN+GGfJPk+R9t/fKqMX2Wasb3vqhF+PKOFJYn9ASNlPGYGxcHTemg9PQFfObf XbNA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=d7BLIftl; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 24si1130340edv.581.2020.08.20.02.19.42; Thu, 20 Aug 2020 02:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=d7BLIftl; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=synaptics.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727067AbgHTJQw (ORCPT + 99 others); Thu, 20 Aug 2020 05:16:52 -0400 Received: from mail-mw2nam10on2068.outbound.protection.outlook.com ([40.107.94.68]:23675 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727125AbgHTJPm (ORCPT ); Thu, 20 Aug 2020 05:15:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NACtE7ZqtERHAYms3ER+qqy/Id2/cFdZmBLwAANqxCnhh9haV03f/K2CkIYRV4KjFRzJdHVPGIMy8yottARajx2uR2kCQ0aiCQpG2dr5OWJngyHgKp0Tov8Hp5EIP/AchoSZB9NVfkvAM69mEQNh1eiM2/t552TXRtjzNl4+nJcxFZ93Blk5lBweqeHKZipCo95QOVeRrdvlG72WnQlUN4I6hzhbWMANoqcc8eGCqcw8alv/DFp2Pv51GFh0HAe2CWfNiM/NM1Hx4oixco+9+ib0McviBCmS20jVBTEyoAo2hCaYQDmez1jDtpeYyDZsj2w4xot6W2+VAstdVcliww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GM6/JOlbgW/DXaQv1/61oneRFPp9b+EVt2boDh6c2DY=; b=YWpOgu3G7p5YPIVGmc6FNNJUmk8by+0VLRSNRi7Yykn2E9Y2TnNJAtmaj6+A+sa2BHia8c+AYcJVFwwu64BiJuEK/0geyhq4wXGM2xQIxue36yO5H/L9j2H367OE/hAikP+w62mQvnAgCTY+s7D7JMYjIfqRdGimfKV9S5nllR5eN8DLxxtwsky6oJr5hCn/pzsHOEahV8SIXXidK1DrvKoXvA8aPuduXSjc18kqwzZvERbsT+O+q9Ety09kg9PL7hTESsJG/xLJ6F7NSb3twMLbaDW6nMOguq9zf+yNJJOrccfuAqdhN7jYCyyWB4KDLbC4Y7YprNh23idBo1Oc2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GM6/JOlbgW/DXaQv1/61oneRFPp9b+EVt2boDh6c2DY=; b=d7BLIftlkBR4BukCSPg4bNCCO2MoClKyFuLx8QxGGAAiUEHcPKQkRwEOXvj+si1JPPvn6kN0V3FZblNsGMtDb4eh3uu7q1IkfwPXNATfLG/MkLlg3ViX5eu3fqtdLGMkkbVjQYWqU04DFvukveyPbDTsnTdZfGRWEAK/hO2jSIM= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=synaptics.com; Received: from BN7PR03MB4547.namprd03.prod.outlook.com (2603:10b6:408:9::22) by BN8PR03MB4738.namprd03.prod.outlook.com (2603:10b6:408:6d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.24; Thu, 20 Aug 2020 09:15:39 +0000 Received: from BN7PR03MB4547.namprd03.prod.outlook.com ([fe80::3cda:7634:5802:df5f]) by BN7PR03MB4547.namprd03.prod.outlook.com ([fe80::3cda:7634:5802:df5f%7]) with mapi id 15.20.3305.024; Thu, 20 Aug 2020 09:15:39 +0000 Date: Thu, 20 Aug 2020 17:11:51 +0800 From: Jisheng Zhang To: Liam Girdwood , Mark Brown , Rob Herring , Saravanan Sekar Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v3 3/4] regulator: mp886x: support setting switch freq Message-ID: <20200820171151.12b01534@xhacker.debian> In-Reply-To: <20200820171020.5df4683b@xhacker.debian> References: <20200820171020.5df4683b@xhacker.debian> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ClientProxiedBy: TYAPR03CA0015.apcprd03.prod.outlook.com (2603:1096:404:14::27) To BN7PR03MB4547.namprd03.prod.outlook.com (2603:10b6:408:9::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by TYAPR03CA0015.apcprd03.prod.outlook.com (2603:1096:404:14::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.10 via Frontend Transport; Thu, 20 Aug 2020 09:15:37 +0000 X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-Originating-IP: [124.74.246.114] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: edde4e3b-95b6-47cf-21d8-08d844e99b0a X-MS-TrafficTypeDiagnostic: BN8PR03MB4738: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:411; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7P1LqjuIbqv/1GsZgGAvRSM8zcydB2f36Io69uKaKCL9ChrTeWRFKSpvH2xqSJKyagmbfsesdiFMAqRggSFuGN+SmM4VMuKCYgB3ZrWdjHFmWQRWEF+WGBqDzaoJPpRVql+Fl20fGGseNyt1CP3OMalobdI4CK8WhkgwusLXfN1565RYS3vE+f3w/xm1tjCD37ovYJh4dX2xHOWF7zS2PUKdehZ5Sk5DijJIIn3x6QMR2Pjx2TEJZbHeQn+8kWd9sZhSU1yp3yb5KV9eEtOqsSV+cHspKIko2VfAETvt/ryvh9w2WfI5q3ihPA1oraRhQpcoGXcquzLTraw8qX8+yf/jNcdLYIsaLwxkcpLDdpVuyHAMhSVa6ZVIx0QDh37g X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN7PR03MB4547.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(396003)(346002)(366004)(376002)(136003)(316002)(2906002)(110136005)(66476007)(6486002)(66556008)(66946007)(110011004)(16576012)(4326008)(8676002)(478600001)(5660300002)(26005)(86362001)(9686003)(6666004)(52116002)(956004)(186003)(1076003)(83380400001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 9AhRj63J7YBqtkthLTaUFuI20K1/rHO+kV8oDVDVGbQmsVkVu/696d8ckwpsSEOimi/X5I+0c8bqf8eL8S3YWq+hRnqZrRT8Lr5uMZy6hfO4GJzA9ur3H3/WmME0d+3NAyGfeJQrjV5umcoSYE3BwaNb7RWl0Gz8TByH8UZ2BDWmdNcM+Qaot1c4dSNpyT60wvi07UdAf8fjhErso/0LwCMKf65G0fIYxd2AMuqqjY0u474id6zkHFs4AryDYLeB1YnDaoTdCHnqeBAX7RN2XE1w87Taovf9R8te7ULCL/jgYOnaZamwDgXvIrN2TlI8z6xxaEC7AvY6wphDVgLxHkFHVAIfweW0nZ2Wzc4ie7BG87UGZeFSPfKIS51G/aBVjFnwlDCBnzC00XzD6Hn9Dh8MgEiGS7hCwT69clsgk/vCTQx0pXBuLj3rLlMgvv+uSSsu6zX3BdmlFt67mmbL8bxPCsQrYBehL0yn1sa+1nq/533YfFUtwlLNiI4R8D7Iz+ucMhtuzMo0TMJbZE5iZjM/GCam1W2IoABfWy8i6wbEmguqmaEG8Y1HOjUPLRV4PfW6O7sPRBolkfepRxop8EXa7SeYAfK+719UGAUnHcLpXZqVgmQMGIds3EsLo9Y7Tf3Mr/K0b7ZbSEsAVfl8qA== X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: edde4e3b-95b6-47cf-21d8-08d844e99b0a X-MS-Exchange-CrossTenant-AuthSource: BN7PR03MB4547.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2020 09:15:39.5584 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FwnRSKneyLp26/oB1Izxrw25IMqHS1A6AmtTO90DhzWDCN3bwcJAzAdzSl3Gq8koiPseORcGECgt+bpi52rNVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR03MB4738 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both MP8867 and MP8869 support different switch frequency. Signed-off-by: Jisheng Zhang --- drivers/regulator/mp886x.c | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/regulator/mp886x.c b/drivers/regulator/mp886x.c index 1305bf217df1..a84fd74081de 100644 --- a/drivers/regulator/mp886x.c +++ b/drivers/regulator/mp886x.c @@ -22,10 +22,14 @@ #define MP886X_SLEW_MASK (0x7 << MP886X_SLEW_SHIFT) #define MP886X_GO (1 << 6) #define MP886X_EN (1 << 7) +#define MP8869_SYSCNTLREG2 0x02 struct mp886x_cfg_info { const struct regulator_ops *rops; const int slew_rates[8]; + const int switch_freq[4]; + const u8 fs_reg; + const u8 fs_shift; }; struct mp886x_device_info { @@ -60,6 +64,24 @@ static int mp886x_set_ramp(struct regulator_dev *rdev, int ramp) MP886X_SLEW_MASK, reg << MP886X_SLEW_SHIFT); } +static void mp886x_set_switch_freq(struct mp886x_device_info *di, + struct regmap *regmap, + u32 freq) +{ + const struct mp886x_cfg_info *ci = di->ci; + int i; + + for (i = 0; i < ARRAY_SIZE(ci->switch_freq); i++) { + if (freq == ci->switch_freq[i]) { + regmap_update_bits(regmap, ci->fs_reg, + 0x3 << ci->fs_shift, i << ci->fs_shift); + return; + } + } + + dev_err(di->dev, "invalid frequency %d\n", freq); +} + static int mp886x_set_mode(struct regulator_dev *rdev, unsigned int mode) { switch (mode) { @@ -162,6 +184,14 @@ static const struct mp886x_cfg_info mp8869_ci = { 1250, 625, }, + .switch_freq = { + 500000, + 750000, + 1000000, + 1250000, + }, + .fs_reg = MP8869_SYSCNTLREG2, + .fs_shift = 4, }; static int mp8867_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel) @@ -233,6 +263,14 @@ static const struct mp886x_cfg_info mp8867_ci = { 1000, 500, }, + .switch_freq = { + 500000, + 750000, + 1000000, + 1500000, + }, + .fs_reg = MP886X_SYSCNTLREG1, + .fs_shift = 1, }; static int mp886x_regulator_register(struct mp886x_device_info *di, @@ -273,6 +311,7 @@ static int mp886x_i2c_probe(struct i2c_client *client) struct mp886x_device_info *di; struct regulator_config config = { }; struct regmap *regmap; + u32 freq; int ret; di = devm_kzalloc(dev, sizeof(struct mp886x_device_info), GFP_KERNEL); @@ -310,6 +349,9 @@ static int mp886x_i2c_probe(struct i2c_client *client) config.driver_data = di; config.of_node = np; + if (!of_property_read_u32(np, "mps,switch-frequency-hz", &freq)) + mp886x_set_switch_freq(di, regmap, freq); + ret = mp886x_regulator_register(di, &config); if (ret < 0) dev_err(dev, "Failed to register regulator!\n"); -- 2.28.0