From patchwork Tue Jan 24 18:44:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 47814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2316524wrn; Tue, 24 Jan 2023 10:47:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGiH8JcRCJnv7cUc2ceW+E5JPFpKRWpFVBkygMUYdn/R7YfnCdA+qkQ3gAToGFfD42mnB/ X-Received: by 2002:a05:6402:380b:b0:499:e665:8683 with SMTP id es11-20020a056402380b00b00499e6658683mr34603091edb.2.1674586052398; Tue, 24 Jan 2023 10:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586052; cv=none; d=google.com; s=arc-20160816; b=hGDVrD3txQxWgeKTJVYRLH/PEDhdX2BeEfy3d8LCJZTl70ahQiMcb2JamEEyO6d1Um wzImlurJusdkNri5WT9BO3fkPwJ8loMxr2G4aI8p0JfOn9s1JI6JA9b9rhoqfWX7dhsF zodc+ih7qOWaXLZIfQqneY2isq+nwPodAQX+TFmwRXJUkzYi5YbBDeI7hD+2LUO5gI2t URht7ZB1NBk0qW7Pi3E6O6e5DrRgfase482cD74hg2KHmooPeDSGfCDQdjXkPdV2IHvc NqfwuHeS9+xZinQ04PldwVOiWOH6giIc5xEvHB0dmL9qvlC8vnzTr+26669jEyJbT134 +9Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FuvtUs6LbmxpmPar3UYKfQ2kkrS+koex54XbtKctYU0=; b=e22fdQQJ287J+VIm0VU/672ZQTqDiA+sjaKZnXSK/5JTvx8BVo7TQMqwYVUlznlhjZ 1uwVVaGcJedB2olb4fWkRxG3PikMm+qwT9cbzKRL10XXN2U+WjAa6zqqSsTGMsRUbOBI wPVsckTiIp5XHKoglwTib7teD2B8wuwbuA+XMFl/I5/TYYJJ2DteJy/4V/wmqFFTY/M6 CaYrIwt+TXiDDB6EZMT38fLXwj1s8LaiGrY9/exN1m/OElFijvfQBRhuulc9H/qqFO2V /NGJghrdvKZyI8gxNcAmCxckQFgQucLbC/dj7j0fDZgjFsqFRQIjSF2b7ZYLMJL08cI7 imLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lCHLGBsF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a05640202cd00b0049b935e07e4si4083013edx.207.2023.01.24.10.47.08; Tue, 24 Jan 2023 10:47:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lCHLGBsF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234094AbjAXSpL (ORCPT + 99 others); Tue, 24 Jan 2023 13:45:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbjAXSo4 (ORCPT ); Tue, 24 Jan 2023 13:44:56 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA6E36E97; Tue, 24 Jan 2023 10:44:51 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30OEH2lO013791; Tue, 24 Jan 2023 18:44:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=FuvtUs6LbmxpmPar3UYKfQ2kkrS+koex54XbtKctYU0=; b=lCHLGBsFS8JQ4PVCMnwubAN8A6qELOwwF7/2srp2TSaDlGuTk/l1b2Vl8OAvBfkApz9u FSNIWQ0Ca16Bpw8HBo/gSUagoYztyD3pTuuK33diXHN4Ro25gRF6aBDlrTiBQBocG+vH s3O3wHfrZn8h4x3zN7zCKiBgibCe+Djkk6on6WpT8qYOo58LCoZBUq7Qu4IErlVjSnkx F0JYJRlKAVhMNnycHcrKQqP1/uEqhrruJ/7dPHsbx4f3EH1oOghwBho7LZRUaS20Ip4R ga+F9QrRgCv0gEXnSnuum7nTbxJyT5wrcTnD8fzxA8ScaWZgxznUqzQ9Qb8r5dPikWYq pg== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nag308q49-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 18:44:47 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30OIik9o021002 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 18:44:46 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 24 Jan 2023 10:44:46 -0800 From: Bjorn Andersson To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski CC: Andy Gross , Bjorn Andersson , Konrad Dybcio , , , , Krzysztof Kozlowski Subject: [PATCH v2 1/3] regulator: dt-bindings: Describe Maxim MAX20411 Date: Tue, 24 Jan 2023 10:44:38 -0800 Message-ID: <20230124184440.1421074-2-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124184440.1421074-1-quic_bjorande@quicinc.com> References: <20230124184440.1421074-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: pv0YOyjOr76kWlKxBjjsodlLOSmCexcr X-Proofpoint-GUID: pv0YOyjOr76kWlKxBjjsodlLOSmCexcr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-24_13,2023-01-24_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 suspectscore=0 bulkscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 priorityscore=1501 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240170 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755930744612790836?= X-GMAIL-MSGID: =?utf-8?q?1755930744612790836?= Add binding for the Maxim MAX20411 step-down DC-DC converter. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Bjorn Andersson --- Changes since v1: - Swapped "dt-bindings" and "regulator" in $subject - Dropped maxItems from enable-gpios .../bindings/regulator/maxim,max20411.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/maxim,max20411.yaml diff --git a/Documentation/devicetree/bindings/regulator/maxim,max20411.yaml b/Documentation/devicetree/bindings/regulator/maxim,max20411.yaml new file mode 100644 index 000000000000..5b3a42d24e51 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/maxim,max20411.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/maxim,max20411.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated MAX20411 Step-Down DC-DC Converter + +maintainers: + - Bjorn Andersson + +description: + The MAX20411 is a high-efficiency, DC-DC step-down converter. It provides + configurable output voltage in the range of 0.5V to 1.275V, configurable over + I2C. + +allOf: + - $ref: regulator.yaml# + +properties: + compatible: + const: maxim,max20411 + + reg: + maxItems: 1 + + enable-gpios: + description: GPIO connected to the EN pin, active high + + vdd-supply: + description: Input supply for the device (VDD pin, 3.0V to 5.5V) + +required: + - compatible + - reg + - enable-gpios + +unevaluatedProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + regulator@39 { + compatible = "maxim,max20411"; + reg = <0x39>; + + enable-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; + + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <1000000>; + }; + }; +... From patchwork Tue Jan 24 18:44:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 47812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2315917wrn; Tue, 24 Jan 2023 10:46:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXtVUVOhiEGR/gS6Iy/Ihm67Op3NeFWDTAjf8+A+Zt5LxQmdiInhMcmgqnfJngb4b9aZ4X0o X-Received: by 2002:a17:907:8e86:b0:84d:43c3:a897 with SMTP id tx6-20020a1709078e8600b0084d43c3a897mr47166221ejc.2.1674585960233; Tue, 24 Jan 2023 10:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674585960; cv=none; d=google.com; s=arc-20160816; b=qoWdq2zLv/njHjXr9cZJXIY2ngraO0WXmrRYOGUKnwyuu3sk8/yCzaWYn+XBXdJy4Z e5LB7J9PgKvVa6b2E9gBWiXNd4/zLcxzpS8jHTvByGA1ege4W+kfOkwbBCta6XBJbfBw yghK8bGbMo96gqLGeiK1rqBnTs7RRZDw4i/QrhjbnJ2WmNrZsoKXnZ9XuVRoBIJmNHwy TnchEvVY3gHYOJgiCnBE6Qsm/AZo8NiCnrRWCXN29QnGsdJp+S16gjkewrB8gWjdUQ5R RnLIG4dACHJ46QHdc0Uj9kqeXhUP2kLorbFeVV78DvA6agUACl4O4Kh81A3DEsRHxoYw JuYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Cy4dl2dzisUj1FI+OxLrzKnUO73As++c7cPJPQQFh4I=; b=zEk+uwhGCu6J6gTX7VhgrSYZKwXfJz2pQYPeKMSaM+ilCe1Bd00G9T2AqzfVnjWz/f 7Pze7+jfCOPw1W8vp59thd52neE4RSHVZJ0HosnP2D+B1ibgLmuIL/gaxb1bNV18hSV8 vVpaRNA85cL5dsNS9op2wP/48cned9zqAYaguHqSnJvv1R2TIjcoI7FpTcXkhm1FOcAQ i7ZyEitgJ3Xs8p38Sc5mPr/wrXEriD5pdK1r8BNayID8BVPwL6csc0AFOxpvozJd8n3U wXweriOIMSqENm0uIqVNy/AVsXRb80m8EsAkOdJE1SmMednQqCdK8uwLQVOrC4erD1yH bPDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=U2f+e7HK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oh10-20020a17090784ca00b008776a7302easi3127696ejc.801.2023.01.24.10.45.36; Tue, 24 Jan 2023 10:46:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=U2f+e7HK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233925AbjAXSpH (ORCPT + 99 others); Tue, 24 Jan 2023 13:45:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234183AbjAXSoz (ORCPT ); Tue, 24 Jan 2023 13:44:55 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1DC023107; Tue, 24 Jan 2023 10:44:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1674585887; x=1706121887; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cy4dl2dzisUj1FI+OxLrzKnUO73As++c7cPJPQQFh4I=; b=U2f+e7HKcnBqUn3jLqkV/h6Xfij/5TEQJXsVMDDJjZE0DsmfZV5/w/QE xzv2fCvN0s6CADOYy2hNj0HJVaPJqePM9hm8yPrK8Iu9TClQQezA1/X6h KTwL2Lpm8oWjr0zH+ujEYkAGdZ9xWfHPdg2zPP3v9qVdigYEd+4cnJnz2 w=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 24 Jan 2023 10:44:47 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.45.79.139]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2023 10:44:47 -0800 Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 24 Jan 2023 10:44:46 -0800 From: Bjorn Andersson To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski CC: Andy Gross , Bjorn Andersson , Konrad Dybcio , , , Subject: [PATCH v2 2/3] regulator: Introduce Maxim MAX20411 Step-Down converter Date: Tue, 24 Jan 2023 10:44:39 -0800 Message-ID: <20230124184440.1421074-3-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124184440.1421074-1-quic_bjorande@quicinc.com> References: <20230124184440.1421074-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755930647835140256?= X-GMAIL-MSGID: =?utf-8?q?1755930647835140256?= From: Bjorn Andersson Introduce a driver to control the Maxim MAX20411 family of high-efficiency, syncrhonous step-down converters. Signed-off-by: Bjorn Andersson Signed-off-by: Bjorn Andersson --- Changes since v1: - Extracted regulator_desc initialization from max20411_probe() drivers/regulator/Kconfig | 8 ++ drivers/regulator/Makefile | 1 + drivers/regulator/max20411-regulator.c | 163 +++++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 drivers/regulator/max20411-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 820c9a0788e5..aae28d0a489c 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -655,6 +655,14 @@ config REGULATOR_MAX20086 protectorvia I2C bus. The regulator has 2 or 4 outputs depending on the device model. This driver is only capable to turn on/off them. +config REGULATOR_MAX20411 + tristate "Maxim MAX20411 High-Efficiency Single Step-Down Converter" + depends on I2C + select REGMAP_I2C + help + This driver controls the Maxim MAX20411 family of high-efficiency, + syncrhonous step-down converters. + config REGULATOR_MAX77686 tristate "Maxim 77686 regulator" depends on MFD_MAX77686 || COMPILE_TEST diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index b9f5eb35bf5f..ee383d8fc835 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -80,6 +80,7 @@ obj-$(CONFIG_REGULATOR_MAX8973) += max8973-regulator.o obj-$(CONFIG_REGULATOR_MAX8997) += max8997-regulator.o obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o obj-$(CONFIG_REGULATOR_MAX20086) += max20086-regulator.o +obj-$(CONFIG_REGULATOR_MAX20411) += max20411-regulator.o obj-$(CONFIG_REGULATOR_MAX77686) += max77686-regulator.o obj-$(CONFIG_REGULATOR_MAX77693) += max77693-regulator.o obj-$(CONFIG_REGULATOR_MAX77802) += max77802-regulator.o diff --git a/drivers/regulator/max20411-regulator.c b/drivers/regulator/max20411-regulator.c new file mode 100644 index 000000000000..69f04cbe69f1 --- /dev/null +++ b/drivers/regulator/max20411-regulator.c @@ -0,0 +1,163 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022, Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX20411_UV_STEP 6250 +#define MAX20411_BASE_UV 243750 +#define MAX20411_MIN_SEL 41 /* 0.5V */ +#define MAX20411_MAX_SEL 165 /* 1.275V */ +#define MAX20411_VID_OFFSET 0x7 +#define MAX20411_VID_MASK 0xff +#define MAX20411_SLEW_OFFSET 0x6 +#define MAX20411_SLEW_DVS_MASK 0xc +#define MAX20411_SLEW_SR_MASK 0x3 + +struct max20411 { + struct device *dev; + struct device_node *of_node; + struct regulator_desc desc; + struct regulator_dev *rdev; + struct regmap *regmap; +}; + +static const unsigned int max20411_slew_rates[] = { 13100, 6600, 3300, 1600 }; + +static int max20411_enable_time(struct regulator_dev *rdev) +{ + int voltage, rate, ret; + unsigned int val; + + /* get voltage */ + ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); + if (ret) + return ret; + + val &= rdev->desc->vsel_mask; + voltage = regulator_list_voltage_linear(rdev, val); + + /* get rate */ + ret = regmap_read(rdev->regmap, MAX20411_SLEW_OFFSET, &val); + if (ret) + return ret; + + val = FIELD_GET(MAX20411_SLEW_SR_MASK, val); + rate = max20411_slew_rates[val]; + + return DIV_ROUND_UP(voltage, rate); +} + +static const struct regmap_config max20411_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 0xe, +}; + +static const struct regulator_ops max20411_ops = { + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .list_voltage = regulator_list_voltage_linear, + .enable_time = max20411_enable_time, +}; + +static const struct regulator_desc max20411_desc = { + .ops = &max20411_ops, + .owner = THIS_MODULE, + .type = REGULATOR_VOLTAGE, + .supply_name = "vin", + .name = "max20411", + + /* + * voltage = 0.24375V + selector * 6.25mV + * with valid selector between 41 to 165 (0.5V to 1.275V) + */ + .min_uV = MAX20411_BASE_UV, + .uV_step = MAX20411_UV_STEP, + .linear_min_sel = MAX20411_MIN_SEL, + .n_voltages = MAX20411_MAX_SEL, + + .vsel_reg = MAX20411_VID_OFFSET, + .vsel_mask = MAX20411_VID_MASK, + + .ramp_reg = MAX20411_SLEW_OFFSET, + .ramp_mask = MAX20411_SLEW_DVS_MASK, + .ramp_delay_table = max20411_slew_rates, + .n_ramp_values = ARRAY_SIZE(max20411_slew_rates), +}; + +static int max20411_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct regulator_init_data *init_data; + struct device *dev = &client->dev; + struct regulator_config cfg = {}; + struct max20411 *max20411; + + max20411 = devm_kzalloc(dev, sizeof(*max20411), GFP_KERNEL); + if (!max20411) + return -ENOMEM; + + max20411->regmap = devm_regmap_init_i2c(client, &max20411_regmap_config); + if (IS_ERR(max20411->regmap)) { + dev_err(dev, "Failed to allocate regmap!\n"); + return PTR_ERR(max20411->regmap); + } + + max20411->dev = dev; + max20411->of_node = dev->of_node; + + max20411->desc = max20411_desc; + init_data = of_get_regulator_init_data(max20411->dev, max20411->of_node, &max20411->desc); + if (!init_data) + return -ENODATA; + + cfg.dev = max20411->dev; + cfg.init_data = init_data; + cfg.of_node = max20411->of_node; + cfg.driver_data = max20411; + + cfg.ena_gpiod = gpiod_get(max20411->dev, "enable", GPIOD_ASIS); + if (IS_ERR(cfg.ena_gpiod)) + return dev_err_probe(dev, PTR_ERR(cfg.ena_gpiod), + "unable to acquire enable gpio\n"); + + max20411->rdev = devm_regulator_register(max20411->dev, &max20411->desc, &cfg); + if (IS_ERR(max20411->rdev)) + dev_err(max20411->dev, "Failed to register regulator\n"); + + return PTR_ERR_OR_ZERO(max20411->rdev); +} + +static const struct of_device_id of_max20411_match_tbl[] = { + { .compatible = "maxim,max20411", }, + { }, +}; +MODULE_DEVICE_TABLE(of, of_max20411_match_tbl); + +static const struct i2c_device_id max20411_id[] = { + { "max20411", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, max20411_id); + +static struct i2c_driver max20411_i2c_driver = { + .driver = { + .name = "max20411", + .of_match_table = of_max20411_match_tbl, + }, + .probe = max20411_probe, + .id_table = max20411_id, +}; +module_i2c_driver(max20411_i2c_driver); + +MODULE_LICENSE("GPL"); From patchwork Tue Jan 24 18:44:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 47813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2316412wrn; Tue, 24 Jan 2023 10:47:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXsmX42au4K5r/CmYU3NLCF7VBCQ0OnFxRHellcWkno0Qz6+Et2ygEn32scbelFNJvzZHUFV X-Received: by 2002:a17:906:fb16:b0:7c1:6d65:4718 with SMTP id lz22-20020a170906fb1600b007c16d654718mr30730399ejb.33.1674586035485; Tue, 24 Jan 2023 10:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674586035; cv=none; d=google.com; s=arc-20160816; b=E/PB6nbn1xKGOAUIiwl5fQt/UXLv84Hs9A23q9/dmbGLXo7TlVQ4GveXKuYyTtKMPF 2DDAO+F43leLArU6CuTw0bDa2N9Tt+1FZGLm673pbh0K1Pl/T94Qjfk5GAm8xZIgrLto LgL+utkxkvMZjZ7NQqIU/6xhR1XLH4TLrb6qgB6podAhQJMxLx3++GbXLuNApG2ofrie nSExF/dZnSKzEz1XczMpngKiHPFiOnZ1s7LargncWLGIzTyUyl1slWGpo1ohN7Xbo9xs g6cxgWc/RjSRtF4emDWTz47nv1SE2A+tA//dUpDebkh02jiiLqp/trC6fIf2/T6zZSs1 gvqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=an6GQ7C4x8r1owOs4PWQW974MIIzzFEe9T+hV8d3vd0=; b=yDTORTk10hFvu+0mNLSaaEFRzQUI5KRbd3lM/xVY3qq+5HOS8lhSFRGjiF0vhzB6vC pLjMJQTatdiTpJ2Th4dx/54O29nCCbnvd5G1nNOEOoy2YunEdQxYiL1jw5blkrvuCN/s J1iXnWRMGWMg3xe+jtTgFsIggdeeBwiLS2HPHG24sAtSjK3kZTc9gu9PSwjiEKLnKKfL q8kaCSe7D9eOrRxzk7iZR4UTKymPAJnnk0nCyuwR2ZLeO0E4wJobeDwaUDTGmS8SoOAt vyOh8IygdekMzhXbxYzvjsadNdk+uuE//B5GefVg/k7q4n+o7ztmvQIf4opjmADNVeUy wipQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ftJrR9Mn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fv21-20020a170907509500b0083b6e04f33esi2975944ejc.280.2023.01.24.10.46.51; Tue, 24 Jan 2023 10:47:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ftJrR9Mn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234139AbjAXSpR (ORCPT + 99 others); Tue, 24 Jan 2023 13:45:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbjAXSo6 (ORCPT ); Tue, 24 Jan 2023 13:44:58 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 062AC3ABD; Tue, 24 Jan 2023 10:44:58 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30OFDxYl030407; Tue, 24 Jan 2023 18:44:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=an6GQ7C4x8r1owOs4PWQW974MIIzzFEe9T+hV8d3vd0=; b=ftJrR9MnAI3cjWYuXAvyz4iMIRVJiDhyCgLJqosP/WP3P/RsqaAIh38snMOLgkyqiWVp wb0dSRTXy/8ilQDAnfMoOKrQnXc/3TqblWZeFO0wWlG5fdpPM2vQYwLJyh9KqSB7cYrY z/lZUI/DA0vjyGCz/Hep3tbqubQNUc1FYiXN4tRnTsZPxt8kO7+rdoTvCRI8hXYbAFUR 38a6QszHqhJWKHMshrdZSRBrAowLMmWcMOi9WPwYDQd0MpX4ymMTgI0cnHh4fV3blv7c z1onsJshGA9t3r7gWvGlsO2Cv7phgprWWOYSo5Uwvw8hS9dWFammvJUrnuzbcu8z+Kmb Jw== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n89dr5n9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 18:44:48 +0000 Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30OIildc013441 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 18:44:47 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 24 Jan 2023 10:44:47 -0800 From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Konrad Dybcio CC: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , , , Subject: [PATCH v2 3/3] arm64: dts: qcom: sa8295p-adp: Add max20411 on i2c12 Date: Tue, 24 Jan 2023 10:44:40 -0800 Message-ID: <20230124184440.1421074-4-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230124184440.1421074-1-quic_bjorande@quicinc.com> References: <20230124184440.1421074-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 2IjXJ8kt_I3qudQasyWyp_hAF0BYR0Vw X-Proofpoint-ORIG-GUID: 2IjXJ8kt_I3qudQasyWyp_hAF0BYR0Vw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-24_13,2023-01-24_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 bulkscore=0 mlxlogscore=945 phishscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240171 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755930726959208506?= X-GMAIL-MSGID: =?utf-8?q?1755930726959208506?= From: Bjorn Andersson The SA8295P ADP has a Maxim max20411 step-down converter on i2c12. Signed-off-by: Bjorn Andersson Signed-off-by: Bjorn Andersson Reviewed-by: Andrew Halaney Tested-by: Andrew Halaney --- Changes since v1: - i2c node had changed name arch/arm64/boot/dts/qcom/sa8295p-adp.dts | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sa8295p-adp.dts b/arch/arm64/boot/dts/qcom/sa8295p-adp.dts index bb4270e8f551..642000d95812 100644 --- a/arch/arm64/boot/dts/qcom/sa8295p-adp.dts +++ b/arch/arm64/boot/dts/qcom/sa8295p-adp.dts @@ -266,6 +266,27 @@ &dispcc1 { status = "okay"; }; +&i2c12 { + pinctrl-names = "default"; + pinctrl-0 = <&i2c12_state>; + + status = "okay"; + + vdd_gfx: regulator@39 { + compatible = "maxim,max20411"; + reg = <0x39>; + + regulator-name = "vdd_gfx"; + regulator-min-microvolt = <800000>; + regulator-max-microvolt = <968750>; + + enable-gpios = <&pmm8540a_gpios 2 GPIO_ACTIVE_HIGH>; + + pinctrl-names = "default"; + pinctrl-0 = <&vdd_gfx_enable_state>; + }; +}; + &mdss0 { status = "okay"; }; @@ -476,6 +497,10 @@ &pcie4_phy { status = "okay"; }; +&qup1 { + status = "okay"; +}; + &qup2 { status = "okay"; }; @@ -636,7 +661,23 @@ &xo_board_clk { /* PINCTRL */ +&pmm8540a_gpios { + vdd_gfx_enable_state: vdd-gfx-enable-state { + pins = "gpio2"; + function = "normal"; + output-enable; + }; +}; + &tlmm { + i2c12_state: i2c12-state { + pins = "gpio0", "gpio1"; + function = "qup12"; + + drive-strength = <2>; + bias-pull-up; + }; + pcie2a_default: pcie2a-default-state { clkreq-n-pins { pins = "gpio142";