From patchwork Thu Oct 5 04:31:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp410912vqb; Thu, 5 Oct 2023 09:17:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQeeLxD0xASEjmIe58NNjw1obLhBBpyMrPbBKegUHrhGbwkJoH/5wdkfzjO8JjXcGjEamo X-Received: by 2002:a05:6a00:894:b0:68a:586a:f62 with SMTP id q20-20020a056a00089400b0068a586a0f62mr6620599pfj.4.1696522648288; Thu, 05 Oct 2023 09:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696522648; cv=none; d=google.com; s=arc-20160816; b=uJy8ycn4+WCHHU1KKd5iQUnTlCshKNn6+buB+W1GnXOt8lFpDaJMPGn7L/ZIvaGhXd it7c7cIaePM9R9ttb1LOeIoq88YKbp1DWBiJO61tGChERIfwOwYhSX7ypImNeQ4ZffET 5EQCij0/JPBmaplv+EAcogps3GRzQDV574iKk59G6oWzpeTOqn1leNwZvOcWrv9zHipI 39yNbW5Chp9U4bcWFOHvrkj63UesGzkJljkxj3ALcQQ5oxAMfUxXXtpjG4Msh1LJfWDX p6DiqaL0KpB/6gj1ohne27VhlthocYMqtYDpeViY15qNZY7wfD0Hpu6pN1t+7zmq36Sm ioig== 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=Oz6TiyhdzwlYmjT2exBOzK4LQ/ahqYyF2RP1DeeR2Zk=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=EecM0ipLiLRa2gV1KArCJlZHw74CTsSA0Vt/82r8Z9ro4V6WY6XDXd9oDdyQxgrqOt uNDc1tThQOjk4Ttv2L4ozwAT4zwxfxbdPer7IjcBUDF7lisRw3NgRjOYEjtxtzbSUjWi q+jHv0TS53ssUJxKh9RL8n5QsTQ+MDB1/R+CXyeQhIXnQsmqTgSpW3YmFGjPXellajB5 K0qMgt5N2gvedp5deRu3uJ6hy3hn90Vy5RQlWfaaUNV1cemMMeKa9xcHoXMjIHE3KtxO W/Y0G+iwP1+O5OBdPtx6nT6mb5mO475pw5JAq7AAQdVEkkS8vbv74EBZTKenCAPj8g1p RUXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Fg9sH5Rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id cl11-20020a056a0032cb00b0068e3f550763si1646934pfb.101.2023.10.05.09.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Fg9sH5Rs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C962C80B1899; Thu, 5 Oct 2023 09:15:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241668AbjJEQOi (ORCPT + 19 others); Thu, 5 Oct 2023 12:14:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237054AbjJEQM0 (ORCPT ); Thu, 5 Oct 2023 12:12:26 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17EDC287CA; Thu, 5 Oct 2023 06:46:54 -0700 (PDT) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3950e6hY025800; Thu, 5 Oct 2023 04:31:52 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-type : content-transfer-encoding; s=qcppdkim1; bh=Oz6TiyhdzwlYmjT2exBOzK4LQ/ahqYyF2RP1DeeR2Zk=; b=Fg9sH5Rszh5rn3A5jkBN/RfxFZBr2C6W+uI1d1XHLkir8R/8ldRnt3j4yC44Pqd5xeoP FfZ981HhhF8/Ousu6ouzzEKOUPr7Vg6wc1nNp9Rb0WWMK0KrqgGZ32J93hW8MAYmL2fM gt01ePcKckQY5b7VDN+4ARjH5zgI/JxZGEx26NzZCHhYntf6TCspZAVQfu0vIbtP5AkB 50E8daM9N1AITOqxC1jCVTaD6fToibjjXNdnxY21XvzTw+hBtcqAOFQU/qg/t4xhEJuL l87aH1C9o2qQ3mZ8b6koIMYlMKowNDgEvVsNaO60uTmUm5moMJjZ6zbgBadnr9w0+hEb Kw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3thfkh0qqx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 04:31:52 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3954VpM2011650 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 04:31:51 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Wed, 4 Oct 2023 21:31:45 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V14 1/4] pwm: driver for qualcomm ipq6018 pwm block Date: Thu, 5 Oct 2023 10:01:24 +0530 Message-ID: <20231005043127.2690639-2-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005043127.2690639-1-quic_devipriy@quicinc.com> References: <20231005043127.2690639-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: BJrDwmTO6t9WvaWMFrtRgHWwTG5FOmqI X-Proofpoint-ORIG-GUID: BJrDwmTO6t9WvaWMFrtRgHWwTG5FOmqI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_01,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 spamscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050037 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,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:15:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778932932336640874 X-GMAIL-MSGID: 1778932932336640874 Driver for the PWM block in Qualcomm IPQ6018 line of SoCs. Based on driver from downstream Codeaurora kernel tree. Removed support for older (V1) variants because I have no access to that hardware. Tested on IPQ6010 based hardware. Co-developed-by: Baruch Siach Signed-off-by: Baruch Siach Signed-off-by: Devi Priya --- V14: No change V13: No change V12: Fix the below clang warning for overflow check reported by kernel test robot drivers/pwm/pwm-ipq.c:122:11: warning: result of comparison of constant 16000000000 with expression of type 'unsigned long' is always false [-Wtautological-constant-out-of-range-compare] >> if (rate > 16ULL * GIGA) v11: Address comment from Uwe Kleine-König: Drop redundant registers field comments Fix period limit check in .apply Clarify the comment explaining skip of pre_div > pwm_div values Add explicit check for clock rate within limit Add comment explaining the selection of initial pre_div Use pwm_div division with remainder instead of separate diff calculation Round up duty_cycle calculation in .get_state v10: Restore round up in pwm_div calculation; otherwise diff is always <= 0, so only bingo match works Don't overwrite min_diff on every loop iteration v9: Address comment from Uwe Kleine-König: Use period_ns*rate in dividers calculation for better accuracy Round down pre_div and pwm_div Add a comment explaining why pwm_div can't underflow Add a comment explaining why pre_div > pwm_div end the search loop Drop 'CFG_' from register macros Rename to_ipq_pwm_chip() to ipq_pwm_from_chip() Change bare 'unsigned' to 'unsigned int' Clarify the comment on separate REG1 write for enable/disable Round up the period value in .get_state Use direct readl/writel so no need to check for regmap errors v7: Change 'offset' to 'reg' for the tcsr offset (Rob) Drop clock name; there is only one clock (Bjorn) Simplify probe failure code path (Bjorn) v6: Address Uwe Kleine-König review comments: Drop IPQ_PWM_MAX_DEVICES Rely on assigned-clock-rates; drop IPQ_PWM_CLK_SRC_FREQ Simplify register offset calculation Calculate duty cycle more precisely Refuse to set inverted polarity Drop redundant IPQ_PWM_REG1_ENABLE bit clear Remove x1000 factor in pwm_div calculation, use rate directly, and round up Choose initial pre_div such that pwm_div < IPQ_PWM_MAX_DIV Ensure pre_div <= pwm_div Rename close_ to best_ Explain in comment why effective_div doesn't overflow Limit pwm_div to IPQ_PWM_MAX_DIV - 1 to allow 100% duty cycle Disable clock only after pwmchip_remove() const pwm_ops Other changes: Add missing linux/bitfield.h header include (kernel test robot) Adjust code for PWM device node under TCSR (Rob Herring) v5: Use &tcsr_q6 syscon to access registers (Bjorn Andersson) Address Uwe Kleine-König review comments: Implement .get_state() Add IPQ_PWM_ prefix to local macros Use GENMASK/BIT/FIELD_PREP for register fields access Make type of config_div_and_duty() parameters consistent Derive IPQ_PWM_MIN_PERIOD_NS from IPQ_PWM_CLK_SRC_FREQ Integrate enable/disable into config_div_and_duty() to save register read, and reduce frequency glitch on update Use min() instead of min_t() Fix comment format Use dev_err_probe() to indicate probe step failure Add missing clk_disable_unprepare() in .remove Don't set .owner v4: Use div64_u64() to fix link for 32-bit targets ((kernel test robot , Uwe Kleine-König) v3: s/qcom,pwm-ipq6018/qcom,ipq6018-pwm/ (Rob Herring) Fix integer overflow on 32-bit targets (kernel test robot ) v2: Address Uwe Kleine-König review comments: Fix period calculation when out of range Don't set period larger than requested Remove PWM disable on configuration change Implement .apply instead of non-atomic .config/.enable/.disable Don't modify PWM on .request/.free Check pwm_div underflow Fix various code and comment formatting issues Other changes: Use u64 divisor safe division Remove now empty .request/.free drivers/pwm/Kconfig | 12 ++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-ipq.c | 282 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 295 insertions(+) create mode 100644 drivers/pwm/pwm-ipq.c diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 8ebcddf91f7b..c2d51680823a 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -282,6 +282,18 @@ config PWM_INTEL_LGM To compile this driver as a module, choose M here: the module will be called pwm-intel-lgm. +config PWM_IPQ + tristate "IPQ PWM support" + depends on ARCH_QCOM || COMPILE_TEST + depends on HAVE_CLK && HAS_IOMEM + help + Generic PWM framework driver for IPQ PWM block which supports + 4 pwm channels. Each of the these channels can be configured + independent of each other. + + To compile this driver as a module, choose M here: the module + will be called pwm-ipq. + config PWM_IQS620A tristate "Azoteq IQS620A PWM support" depends on MFD_IQS62X || COMPILE_TEST diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile index c822389c2a24..1b69e8cb2b91 100644 --- a/drivers/pwm/Makefile +++ b/drivers/pwm/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_PWM_IMX1) += pwm-imx1.o obj-$(CONFIG_PWM_IMX27) += pwm-imx27.o obj-$(CONFIG_PWM_IMX_TPM) += pwm-imx-tpm.o obj-$(CONFIG_PWM_INTEL_LGM) += pwm-intel-lgm.o +obj-$(CONFIG_PWM_IPQ) += pwm-ipq.o obj-$(CONFIG_PWM_IQS620A) += pwm-iqs620a.o obj-$(CONFIG_PWM_JZ4740) += pwm-jz4740.o obj-$(CONFIG_PWM_KEEMBAY) += pwm-keembay.o diff --git a/drivers/pwm/pwm-ipq.c b/drivers/pwm/pwm-ipq.c new file mode 100644 index 000000000000..5dbe46bb56d6 --- /dev/null +++ b/drivers/pwm/pwm-ipq.c @@ -0,0 +1,282 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 +/* + * Copyright (c) 2016-2017, 2020 The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* The frequency range supported is 1 Hz to clock rate */ +#define IPQ_PWM_MAX_PERIOD_NS ((u64)NSEC_PER_SEC) + +/* + * The max value specified for each field is based on the number of bits + * in the pwm control register for that field + */ +#define IPQ_PWM_MAX_DIV 0xFFFF + +/* + * Two 32-bit registers for each PWM: REG0, and REG1. + * Base offset for PWM #i is at 8 * #i. + */ +#define IPQ_PWM_REG0 0 +#define IPQ_PWM_REG0_PWM_DIV GENMASK(15, 0) +#define IPQ_PWM_REG0_HI_DURATION GENMASK(31, 16) + +#define IPQ_PWM_REG1 4 +#define IPQ_PWM_REG1_PRE_DIV GENMASK(15, 0) +/* + * Enable bit is set to enable output toggling in pwm device. + * Update bit is set to reflect the changed divider and high duration + * values in register. + */ +#define IPQ_PWM_REG1_UPDATE BIT(30) +#define IPQ_PWM_REG1_ENABLE BIT(31) + +struct ipq_pwm_chip { + struct pwm_chip chip; + struct clk *clk; + void __iomem *mem; +}; + +static struct ipq_pwm_chip *ipq_pwm_from_chip(struct pwm_chip *chip) +{ + return container_of(chip, struct ipq_pwm_chip, chip); +} + +static unsigned int ipq_pwm_reg_read(struct pwm_device *pwm, unsigned int reg) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(pwm->chip); + unsigned int off = 8 * pwm->hwpwm + reg; + + return readl(ipq_chip->mem + off); +} + +static void ipq_pwm_reg_write(struct pwm_device *pwm, unsigned int reg, + unsigned int val) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(pwm->chip); + unsigned int off = 8 * pwm->hwpwm + reg; + + writel(val, ipq_chip->mem + off); +} + +static void config_div_and_duty(struct pwm_device *pwm, unsigned int pre_div, + unsigned int pwm_div, unsigned long rate, u64 duty_ns, + bool enable) +{ + unsigned long hi_dur; + unsigned long val = 0; + + /* + * high duration = pwm duty * (pwm div + 1) + * pwm duty = duty_ns / period_ns + */ + hi_dur = div64_u64(duty_ns * rate, (pre_div + 1) * NSEC_PER_SEC); + + val = FIELD_PREP(IPQ_PWM_REG0_HI_DURATION, hi_dur) | + FIELD_PREP(IPQ_PWM_REG0_PWM_DIV, pwm_div); + ipq_pwm_reg_write(pwm, IPQ_PWM_REG0, val); + + val = FIELD_PREP(IPQ_PWM_REG1_PRE_DIV, pre_div); + ipq_pwm_reg_write(pwm, IPQ_PWM_REG1, val); + + /* PWM enable toggle needs a separate write to REG1 */ + val |= IPQ_PWM_REG1_UPDATE; + if (enable) + val |= IPQ_PWM_REG1_ENABLE; + ipq_pwm_reg_write(pwm, IPQ_PWM_REG1, val); +} + +static int ipq_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, + const struct pwm_state *state) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(chip); + unsigned int pre_div, pwm_div, best_pre_div, best_pwm_div; + unsigned long rate = clk_get_rate(ipq_chip->clk); + u64 period_ns, duty_ns, period_rate; + u64 min_diff; + + if (state->polarity != PWM_POLARITY_NORMAL) + return -EINVAL; + + if (state->period < DIV64_U64_ROUND_UP(NSEC_PER_SEC, rate)) + return -ERANGE; + + period_ns = min(state->period, IPQ_PWM_MAX_PERIOD_NS); + duty_ns = min(state->duty_cycle, period_ns); + + /* + * period_ns is 1G or less. As long as rate is less than 16 GHz, + * period_rate does not overflow. Make that explicit. + */ + if ((unsigned long long)rate > 16ULL * GIGA) + return -EINVAL; + period_rate = period_ns * rate; + best_pre_div = IPQ_PWM_MAX_DIV; + best_pwm_div = IPQ_PWM_MAX_DIV; + /* + * We don't need to consider pre_div values smaller than + * + * period_rate + * pre_div_min := ------------------------------------ + * NSEC_PER_SEC * (IPQ_PWM_MAX_DIV + 1) + * + * because pre_div = pre_div_min results in a better + * approximation. + */ + pre_div = div64_u64(period_rate, + (u64)NSEC_PER_SEC * (IPQ_PWM_MAX_DIV + 1)); + min_diff = period_rate; + + for (; pre_div <= IPQ_PWM_MAX_DIV; pre_div++) { + u64 remainder; + + pwm_div = div64_u64_rem(period_rate, + (u64)NSEC_PER_SEC * (pre_div + 1), &remainder); + /* pwm_div is unsigned; the check below catches underflow */ + pwm_div--; + + /* + * Swapping values for pre_div and pwm_div produces the same + * period length. So we can skip all settings with pre_div > + * pwm_div which results in bigger constraints for selecting + * the duty_cycle than with the two values swapped. + */ + if (pre_div > pwm_div) + break; + + /* + * Make sure we can do 100% duty cycle where + * hi_dur == pwm_div + 1 + */ + if (pwm_div > IPQ_PWM_MAX_DIV - 1) + continue; + + if (remainder < min_diff) { + best_pre_div = pre_div; + best_pwm_div = pwm_div; + min_diff = remainder; + + if (min_diff == 0) /* bingo */ + break; + } + } + + /* config divider values for the closest possible frequency */ + config_div_and_duty(pwm, best_pre_div, best_pwm_div, + rate, duty_ns, state->enabled); + + return 0; +} + +static int ipq_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, + struct pwm_state *state) +{ + struct ipq_pwm_chip *ipq_chip = ipq_pwm_from_chip(chip); + unsigned long rate = clk_get_rate(ipq_chip->clk); + unsigned int pre_div, pwm_div, hi_dur; + u64 effective_div, hi_div; + u32 reg0, reg1; + + reg0 = ipq_pwm_reg_read(pwm, IPQ_PWM_REG0); + reg1 = ipq_pwm_reg_read(pwm, IPQ_PWM_REG1); + + state->polarity = PWM_POLARITY_NORMAL; + state->enabled = reg1 & IPQ_PWM_REG1_ENABLE; + + pwm_div = FIELD_GET(IPQ_PWM_REG0_PWM_DIV, reg0); + hi_dur = FIELD_GET(IPQ_PWM_REG0_HI_DURATION, reg0); + pre_div = FIELD_GET(IPQ_PWM_REG1_PRE_DIV, reg1); + + /* No overflow here, both pre_div and pwm_div <= 0xffff */ + effective_div = (u64)(pre_div + 1) * (pwm_div + 1); + state->period = DIV64_U64_ROUND_UP(effective_div * NSEC_PER_SEC, rate); + + hi_div = hi_dur * (pre_div + 1); + state->duty_cycle = DIV64_U64_ROUND_UP(hi_div * NSEC_PER_SEC, rate); + + return 0; +} + +static const struct pwm_ops ipq_pwm_ops = { + .apply = ipq_pwm_apply, + .get_state = ipq_pwm_get_state, + .owner = THIS_MODULE, +}; + +static int ipq_pwm_probe(struct platform_device *pdev) +{ + struct ipq_pwm_chip *pwm; + struct device *dev = &pdev->dev; + int ret; + + pwm = devm_kzalloc(dev, sizeof(*pwm), GFP_KERNEL); + if (!pwm) + return -ENOMEM; + + platform_set_drvdata(pdev, pwm); + + pwm->mem = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(pwm->mem)) + return dev_err_probe(dev, PTR_ERR(pwm->mem), + "regs map failed"); + + pwm->clk = devm_clk_get(dev, NULL); + if (IS_ERR(pwm->clk)) + return dev_err_probe(dev, PTR_ERR(pwm->clk), + "failed to get clock"); + + ret = clk_prepare_enable(pwm->clk); + if (ret) + return dev_err_probe(dev, ret, "clock enable failed"); + + pwm->chip.dev = dev; + pwm->chip.ops = &ipq_pwm_ops; + pwm->chip.npwm = 4; + + ret = pwmchip_add(&pwm->chip); + if (ret < 0) { + dev_err_probe(dev, ret, "pwmchip_add() failed\n"); + clk_disable_unprepare(pwm->clk); + } + + return ret; +} + +static int ipq_pwm_remove(struct platform_device *pdev) +{ + struct ipq_pwm_chip *pwm = platform_get_drvdata(pdev); + + pwmchip_remove(&pwm->chip); + clk_disable_unprepare(pwm->clk); + + return 0; +} + +static const struct of_device_id pwm_ipq_dt_match[] = { + { .compatible = "qcom,ipq6018-pwm", }, + {} +}; +MODULE_DEVICE_TABLE(of, pwm_ipq_dt_match); + +static struct platform_driver ipq_pwm_driver = { + .driver = { + .name = "ipq-pwm", + .of_match_table = pwm_ipq_dt_match, + }, + .probe = ipq_pwm_probe, + .remove = ipq_pwm_remove, +}; + +module_platform_driver(ipq_pwm_driver); + +MODULE_LICENSE("Dual BSD/GPL"); From patchwork Thu Oct 5 04:31:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp315002vqb; Thu, 5 Oct 2023 06:59:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHX6m7OM88W4z/7ZxZ6kUh/VQZAEpjQdS0YgGbM7a/+3nxh23Dj/ZWUV27+gGXUmr94450t X-Received: by 2002:a05:6a20:914b:b0:158:7fdf:66df with SMTP id x11-20020a056a20914b00b001587fdf66dfmr6421672pzc.18.1696514359720; Thu, 05 Oct 2023 06:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696514359; cv=none; d=google.com; s=arc-20160816; b=bIHsrWHgQRvcr0u4ExHD748i2Vghaq9fsX1tcpgzMYeeYy6k6dBvVubHzG0RNbeQ/9 Ty94lWhbJdhIeNeFneXYY7/Vx2+FwUcSoPHa79Lk2Qq5Ap92O+Q4CWRwia/3NBRNKfjV 0LtdOMs2KvMyoCx1Bux/1FcC+3PdpBIpJVVIB5Ffv08QxAwT0pRStuhK4mNWbu5Zdnzy naAEyNl7B4nAJ1jFlSwQ5IkTwZE5ELZ3FOXDO3DtYH7HpFrXoUhxgh2IPrR8UKgM/9ha R6w5dqrFQMlj4HOPq1QaWVoubf7xswyRg8664pF2PZfQClhNBvobaxXTwLRxNGB3IJc6 s6/g== 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=aNc/qQqVLrd5xCqMkKsIbyqjupUyO0PkNQXzy7ahMHA=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=AUr5UON8FwOIQim8llwo3iEuf5Zg4ebPq1khdFV0jFcYCmBki85kJ+50C5GuaaoGTd arGPfFaWOIZOilZ279QfK1oUZzD/M3racUJFgRzAYLzXaJZIxeKFQIQCxCpai+DZEAL+ mCksn5d1Ook0OzMhZiPmIWMCor59aCJI0rYOiVK8XYIGveDxXXYsrwLr5vsOWb8vcDwq 8WQptRQ09wVnHLxm/wzMcLTiFw5ANZPyGjb9r7o8UzuiplFL2VOZzgtYoQPVkaVWtsmt fye82NYssZs+cGiNk3X56lDef+Hom1GwGjRfjGw3hiPJj7qFv4wqOC709AE1FH2hepUV Zhhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=T2bMfJeS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id l9-20020a170903244900b001c77a0c5a61si1575170pls.551.2023.10.05.06.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 06:59:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=T2bMfJeS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C3B4B8091C43; Thu, 5 Oct 2023 06:59:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231940AbjJEN7A (ORCPT + 19 others); Thu, 5 Oct 2023 09:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231882AbjJEN5J (ORCPT ); Thu, 5 Oct 2023 09:57:09 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F49628126; Thu, 5 Oct 2023 06:45:51 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3952Wv5l000725; Thu, 5 Oct 2023 04:31:59 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-type : content-transfer-encoding; s=qcppdkim1; bh=aNc/qQqVLrd5xCqMkKsIbyqjupUyO0PkNQXzy7ahMHA=; b=T2bMfJeSlP+bWY+aPttMPiUF7rC/gMuqJ42qsO0bYvxjWrEz+mLZyWkEEY+cX+wi1cP/ 0C4YVlBpN1JId0nBVc8wW7tU8X4BBpcppHnrZUVX7TPT3ppG6ORaX4ST64kDVuSLRqT9 GzH3d0/5gJw4i9e4GOO818F6POEqb4X6xIfbIr1M/8E3Xu6688pY94DeRR3vtOJNv5ZB ql+6RpO77DOOcHgpgtvr/PLhM39tCzSab2M9OpFhb9mnfM9sSSDTsC+NQSWyGur98gNu 1LD38eK/P5fhD4JCtSAQoK1gJLgsgnQYvR3QDZzbc8k17U9BnYwz71Jmy+GSQ9++hgdi CA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tgqth3th1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 04:31:58 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3954VvpI011499 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 04:31:57 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Wed, 4 Oct 2023 21:31:51 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V14 2/4] dt-bindings: pwm: add IPQ6018 binding Date: Thu, 5 Oct 2023 10:01:25 +0530 Message-ID: <20231005043127.2690639-3-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005043127.2690639-1-quic_devipriy@quicinc.com> References: <20231005043127.2690639-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: lhP7K0QSAbvAMaOZtoyHr8rw6AgOtNox X-Proofpoint-GUID: lhP7K0QSAbvAMaOZtoyHr8rw6AgOtNox X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_01,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050037 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 06:59:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778924241039530109 X-GMAIL-MSGID: 1778924241039530109 DT binding for the PWM block in Qualcomm IPQ6018 SoC. Reviewed-by: Bjorn Andersson Reviewed-by: Krzysztof Kozlowski Co-developed-by: Baruch Siach Signed-off-by: Baruch Siach Signed-off-by: Devi Priya --- v14: Picked up the R-b tag v13: Updated the file name to match the compatible Sorted the properties and updated the order in the required field Dropped the syscon node from examples v12: Picked up the R-b tag v11: No change v10: No change v9: Add 'ranges' property to example (Rob) Drop label in example (Rob) v8: Add size cell to 'reg' (Rob) v7: Use 'reg' instead of 'offset' (Rob) Drop 'clock-names' and 'assigned-clock*' (Bjorn) Use single cell address/size in example node (Bjorn) Move '#pwm-cells' lower in example node (Bjorn) List 'reg' as required v6: Device node is child of TCSR; remove phandle (Rob Herring) Add assigned-clocks/assigned-clock-rates (Uwe Kleine-König) v5: Use qcom,pwm-regs for phandle instead of direct regs (Bjorn Andersson, Kathiravan T) v4: Update the binding example node as well (Rob Herring's bot) v3: s/qcom,pwm-ipq6018/qcom,ipq6018-pwm/ (Rob Herring) v2: Make #pwm-cells const (Rob Herring) .../bindings/pwm/qcom,ipq6018-pwm.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml diff --git a/Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml b/Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml new file mode 100644 index 000000000000..6d0d7ed271f7 --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/qcom,ipq6018-pwm.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pwm/qcom,ipq6018-pwm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm IPQ6018 PWM controller + +maintainers: + - Baruch Siach + +properties: + compatible: + const: qcom,ipq6018-pwm + + reg: + description: Offset of PWM register in the TCSR block. + maxItems: 1 + + clocks: + maxItems: 1 + + "#pwm-cells": + const: 2 + +required: + - compatible + - reg + - clocks + - "#pwm-cells" + +additionalProperties: false + +examples: + - | + #include + + pwm: pwm@a010 { + compatible = "qcom,ipq6018-pwm"; + reg = <0xa010 0x20>; + clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clock-rates = <100000000>; + #pwm-cells = <2>; + }; From patchwork Thu Oct 5 04:31:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp350093vqb; Thu, 5 Oct 2023 07:49:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLzE9Uomwory/7oxmkn+vN57nnCUXW+j6Qeig7Xsm4WLIbgGpsWkOmMAkSaqHvvfrATgmG X-Received: by 2002:a05:6358:924:b0:143:96e0:5bef with SMTP id r36-20020a056358092400b0014396e05befmr6078207rwi.4.1696517347211; Thu, 05 Oct 2023 07:49:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517347; cv=none; d=google.com; s=arc-20160816; b=fCDJTARtKzsfCeW2kt15m1uB5Dkq5A/Km/h1+jUZAALD+wrfNIc5XJHnjznWB3eoT7 3JRgS/2U8swFEhR8sFbrAJ1ZoCeo7F2rewfUSwaInoKyrYw68GGcl/SBPARf62gvLkz/ 8RVWs1XRHVlnKjQLkjymNYlEYhnrP/VYmpe5l1mwJcZAVqbCFClefzzuTmLFZcC7P/Sx 0y6hj3t1LTytSlo1TgHBTlPAtySsFlKPo4ZCLYnxpz5DByd5Gq1sD+I23kU+xVqtHt2D HpAnlF6e/6bhfq4/KkZfIkY+vVBlrPiHFRFx9bEKjYXPAyLrAeJzlGuqndR6InaNyri6 LaUQ== 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=S9rgb+e8uszfY9Myolwr2rBmO4pkfp4MhrN2vBXD/Zg=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=QiZ9uQLwNSXSX3xYFvxQh6+KgnKm6dJkM87cl63c3fdffnsO7QDQzIZb8XdkCbCQ/z ScomSgMrgtDg+52BB4R/+sVdv9pOBhjSkk4cr28xhZQ0vG0Lmp63WbYSBqdMtlikx4JJ JkEMjSqvva1vT1rSE76fNmjDAYTllwOYh4REoIweaeFyduK5RoLXIaIRZooJ4J2+AwXe BrWwM5ZxS7oAGLfu52LeNVKvgh4Na/YUsOStNSBfANe9O0Snm+VQuzWDDMCAqk46wwjy +6A2sD53ftGOWnHfcjrCi69/Hl4OhVcx8lWByo0E2LNVPOG+S8xJAcXbGDknUKip6O+Y Ekwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ajB3IibC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v62-20020a638941000000b0057884435a71si1502839pgd.396.2023.10.05.07.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:49:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=ajB3IibC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6BEB28374D92; Thu, 5 Oct 2023 07:48:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239810AbjJEOom (ORCPT + 19 others); Thu, 5 Oct 2023 10:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238069AbjJEOjv (ORCPT ); Thu, 5 Oct 2023 10:39:51 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D50C76B29E; Thu, 5 Oct 2023 07:10:35 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3953KRmB005460; Thu, 5 Oct 2023 04:32:04 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=S9rgb+e8uszfY9Myolwr2rBmO4pkfp4MhrN2vBXD/Zg=; b=ajB3IibCedjxVKiVSXM53LItuNsMDlsUUT+wN7Uxe3BaZBx6eaDFI3Qm//r5aTrqDehK jqvIMDGuvSWTRp5jDUqa0gkNADnePrWzaeQ2eqpwO51j18p/+8ApXLEG0AXl6jeaSIoH hwT7GkNfcDaD+n07N+S4cE2H/wdeGP7b/jz3XvrHTGeDfnUpqmX3rpfyxfAXnefeOLZB TYx49phW3NLSwQvdwZiprsZswXV69bp0zw6gM6adRk3QnuuTDs1O18jJSbC7osyQ2NOW r+HmKWnsDGG6oe9C9+AMoajjgCEEH/9xcIfZ8YcgNPq8Oeqd6BQ3kqLtwAtid5QEqYAP xA== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3thn0583wd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 04:32:04 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3954W3c3032057 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 04:32:03 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Wed, 4 Oct 2023 21:31:57 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V14 3/4] dt-bindings: mfd: qcom,tcsr: Add simple-mfd support for IPQ6018 Date: Thu, 5 Oct 2023 10:01:26 +0530 Message-ID: <20231005043127.2690639-4-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005043127.2690639-1-quic_devipriy@quicinc.com> References: <20231005043127.2690639-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: bL2np5mn-KkMFhtnpKsVgQ9UhaaRbuPc X-Proofpoint-GUID: bL2np5mn-KkMFhtnpKsVgQ9UhaaRbuPc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_01,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050037 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:48:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778925486184701675 X-GMAIL-MSGID: 1778927373881833700 Update the binding to include pwm as the child node to TCSR block and add simple-mfd support for IPQ6018. Signed-off-by: Devi Priya --- v14: Addressed comments suggested by krzysztof Added type: object to patternProperties and added the complete path to pwm.yaml in the reference Disallow pwm for targets other than ipq6018 Moved ranges property just after reg in the examples v13: Added simple-mfd support for IPQ6018 based devices Added support to include pwm as the child node to TCSR Included syscon node found on IPQ6018 to the examples .../devicetree/bindings/mfd/qcom,tcsr.yaml | 112 +++++++++++++----- 1 file changed, 81 insertions(+), 31 deletions(-) diff --git a/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml b/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml index 33c3d023a106..f836b973e382 100644 --- a/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml +++ b/Documentation/devicetree/bindings/mfd/qcom,tcsr.yaml @@ -15,50 +15,100 @@ description: properties: compatible: - items: - - enum: - - qcom,msm8976-tcsr - - qcom,msm8998-tcsr - - qcom,qcs404-tcsr - - qcom,sc7180-tcsr - - qcom,sc7280-tcsr - - qcom,sc8280xp-tcsr - - qcom,sdm630-tcsr - - qcom,sdm845-tcsr - - qcom,sdx55-tcsr - - qcom,sdx65-tcsr - - qcom,sm4450-tcsr - - qcom,sm8150-tcsr - - qcom,sm8450-tcsr - - qcom,tcsr-apq8064 - - qcom,tcsr-apq8084 - - qcom,tcsr-ipq5332 - - qcom,tcsr-ipq6018 - - qcom,tcsr-ipq8064 - - qcom,tcsr-ipq8074 - - qcom,tcsr-ipq9574 - - qcom,tcsr-mdm9615 - - qcom,tcsr-msm8226 - - qcom,tcsr-msm8660 - - qcom,tcsr-msm8916 - - qcom,tcsr-msm8953 - - qcom,tcsr-msm8960 - - qcom,tcsr-msm8974 - - qcom,tcsr-msm8996 - - const: syscon + oneOf: + - items: + - enum: + - qcom,msm8976-tcsr + - qcom,msm8998-tcsr + - qcom,qcs404-tcsr + - qcom,sc7180-tcsr + - qcom,sc7280-tcsr + - qcom,sc8280xp-tcsr + - qcom,sdm630-tcsr + - qcom,sdm845-tcsr + - qcom,sdx55-tcsr + - qcom,sdx65-tcsr + - qcom,sm4450-tcsr + - qcom,sm8150-tcsr + - qcom,sm8450-tcsr + - qcom,tcsr-apq8064 + - qcom,tcsr-apq8084 + - qcom,tcsr-ipq5332 + - qcom,tcsr-ipq8064 + - qcom,tcsr-ipq8074 + - qcom,tcsr-ipq9574 + - qcom,tcsr-mdm9615 + - qcom,tcsr-msm8226 + - qcom,tcsr-msm8660 + - qcom,tcsr-msm8916 + - qcom,tcsr-msm8953 + - qcom,tcsr-msm8960 + - qcom,tcsr-msm8974 + - qcom,tcsr-msm8996 + - const: syscon + - items: + - const: qcom,tcsr-ipq6018 + - const: syscon + - const: simple-mfd reg: maxItems: 1 + ranges: true + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + +patternProperties: + "pwm@[a-f0-9]+$": + type: object + $ref: /schemas/pwm/qcom,ipq6018-pwm.yaml + required: - compatible - reg +allOf: + - if: + not: + properties: + compatible: + contains: + enum: + - qcom,tcsr-ipq6018 + then: + patternProperties: + "pwm@[a-f0-9]+$": false + additionalProperties: false examples: + # Example 1 - Syscon node found on MSM8960 - | syscon@1a400000 { compatible = "qcom,tcsr-msm8960", "syscon"; reg = <0x1a400000 0x100>; }; + # Example 2 - Syscon node found on IPQ6018 + - | + #include + + syscon@1937000 { + compatible = "qcom,tcsr-ipq6018", "syscon", "simple-mfd"; + reg = <0x01937000 0x21000>; + ranges = <0 0x1937000 0x21000>; + #address-cells = <1>; + #size-cells = <1>; + + pwm: pwm@a010 { + compatible = "qcom,ipq6018-pwm"; + reg = <0xa010 0x20>; + clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clock-rates = <100000000>; + #pwm-cells = <2>; + }; + }; From patchwork Thu Oct 5 04:31:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Devi Priya X-Patchwork-Id: 148812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp386382vqb; Thu, 5 Oct 2023 08:42:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxJf2vS5s8VvEmDP2LCvAp0kNETiTng21sA6f/z+C6slolxqP9cKg4pvweBu5tKVPV4p9N X-Received: by 2002:a17:90b:3c2:b0:259:466:940f with SMTP id go2-20020a17090b03c200b002590466940fmr5168822pjb.22.1696520536620; Thu, 05 Oct 2023 08:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696520536; cv=none; d=google.com; s=arc-20160816; b=UdFNARK8/fxZ03x+ZjGCyp3XrrAP0s6/DyikqyfGa9sM8A5QTbeOQ75OawCUaTo4x4 QTovjiXtky6zcK+0O1Cn8iYRV8gmQakzcQ5Yy/lNhWEU3tl+3TQ7UnYg0H+pbSA6Nb4/ bm50HDS+A7iQA5VgYGHOSSXvb0jYqCKToK6D0zvvC1Q00m2DkiD++76sGPDsawOrS3CC k6aT6Gy50fv2tmFy8QUTsQnu3WQBpy9l33b+2flGsj/3uHtqFq6TR1KvDcebUB/Ri5QT ffHBjXsZ24pleuQCaQZZTiOblAKGfJCoE+xA8TeWzhYkOFMLCgSnAY8LpHGlIG837hzX VOsQ== 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=O9G6aJwwwtzXKgwKWSw8c7oRidhefF3dxtbgZvE+dvY=; fh=6AwcISBGklEC0U2b8ZFmhdtzZmcvKnccaXqP9iERvtc=; b=YCpF0Bgq2+XVJGSQGsNSba2NPQcCVOKVaWgFMJdxsGIcesMNU9YAQaaP5MPsSeub3C W/i8aa0jtGptHPpu0xGTmaHI0ffFYQux7mi1PIvLTQBCfkyn0HEQ7dgLzcC1zbjsvU7e LFCdvDxlOXngGko4F1fTQFwLI7CL1AHgW3v/E05TSs+zIlfc7Fzcd0UhtkDGff+aVjgu TO6Jz+X+uJs/av3FutW+/NbKF9ehKEM8UNEAimtqfCcOicrGzIbyS3gXYTX8VPmtJ/gK rMNdVx2Ve3wHk3zK1l63af54dj7s7Om9x4us8ybC/1tpvhHkY4QsJPopFuehX1aYV92+ CeXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mdxUiPnh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id z6-20020a17090ab10600b0027995cf4342si1782201pjq.55.2023.10.05.08.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:42:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mdxUiPnh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C7F4684049C5; Thu, 5 Oct 2023 08:42:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233976AbjJEPlw (ORCPT + 19 others); Thu, 5 Oct 2023 11:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233532AbjJEPl1 (ORCPT ); Thu, 5 Oct 2023 11:41:27 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D40677FF; Thu, 5 Oct 2023 07:55:59 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3954WAN5022298; Thu, 5 Oct 2023 04:32:10 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-type : content-transfer-encoding; s=qcppdkim1; bh=O9G6aJwwwtzXKgwKWSw8c7oRidhefF3dxtbgZvE+dvY=; b=mdxUiPnhC/PoFlL6za8Cxtmm9oBNXVNA0udE0UepR1J4pq9py1TlVKyTnQZbpDVtwNwE qnPK220gn4YYpXcZvxawaVDM9NrY+Y7T4z2rnwAonQt+lZFzWFaTkmC84xymVZ8U+6uI 6Ff0BDDv/CjYUUz67doT7/Bp/OwSzPTXo2jkzOmonHo0Q2R7QYLU8WSgG9ZPy6Dro1kG xlcDjgJB/epDZoM/rx7bXqC8n7+cUWWyOxr6zXgggT9d18yWdpOd+5G0IGB+cZwQ0lJB jMcKfb+O3C0On+1uugyVeS2mwfErKai9sletqFnx4DsFUG78AUJDuRcCp06+bXwXCbTz cg== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tgqth3thd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 Oct 2023 04:32:10 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3954W9s7012196 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 5 Oct 2023 04:32:09 GMT Received: from hu-devipriy-blr.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Wed, 4 Oct 2023 21:32:03 -0700 From: Devi Priya To: , , , , , , , , , , , , , , CC: , , Subject: [PATCH V14 4/4] arm64: dts: qcom: ipq6018: add pwm node Date: Thu, 5 Oct 2023 10:01:27 +0530 Message-ID: <20231005043127.2690639-5-quic_devipriy@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005043127.2690639-1-quic_devipriy@quicinc.com> References: <20231005043127.2690639-1-quic_devipriy@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: YZOByDK8Xz85dZZbV5JolnEdYeqlHHcB X-Proofpoint-GUID: YZOByDK8Xz85dZZbV5JolnEdYeqlHHcB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_01,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 clxscore=1015 malwarescore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310050037 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:42:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778925993004512204 X-GMAIL-MSGID: 1778930718341003331 Describe the PWM block on IPQ6018. The PWM is in the TCSR area. Make &tcsr "simple-mfd" compatible, and add &pwm as child of &tcsr. Add also ipq6018 specific compatible string. Reviewed-by: Krzysztof Kozlowski Co-developed-by: Baruch Siach Signed-off-by: Baruch Siach Signed-off-by: Devi Priya --- v14: Moved ranges just after reg as suggested by Krzysztof Picked up the R-b tag v13: No change v12: No change v11: No change v10: No change v9: Add 'ranges' property (Rob) v8: Add size cell to 'reg' (Rob) v7: Use 'reg' instead of 'offset' (Rob) Add qcom,tcsr-ipq6018 (Rob) Drop clock-names (Bjorn) v6: Make the PWM node child of TCSR (Rob Herring) Add assigned-clocks/assigned-clock-rates (Uwe Kleine-König) v5: Use qcom,pwm-regs for TCSR phandle instead of direct regs v3: s/qcom,pwm-ipq6018/qcom,ipq6018-pwm/ (Rob Herring) arch/arm64/boot/dts/qcom/ipq6018.dtsi | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/ipq6018.dtsi b/arch/arm64/boot/dts/qcom/ipq6018.dtsi index e59b9df96c7e..565e61ce382f 100644 --- a/arch/arm64/boot/dts/qcom/ipq6018.dtsi +++ b/arch/arm64/boot/dts/qcom/ipq6018.dtsi @@ -390,8 +390,21 @@ tcsr_mutex: hwlock@1905000 { }; tcsr: syscon@1937000 { - compatible = "qcom,tcsr-ipq6018", "syscon"; + compatible = "qcom,tcsr-ipq6018", "syscon", "simple-mfd"; reg = <0x0 0x01937000 0x0 0x21000>; + ranges = <0x0 0x0 0x01937000 0x21000>; + #address-cells = <1>; + #size-cells = <1>; + + pwm: pwm@a010 { + compatible = "qcom,ipq6018-pwm"; + reg = <0xa010 0x20>; + clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clocks = <&gcc GCC_ADSS_PWM_CLK>; + assigned-clock-rates = <100000000>; + #pwm-cells = <2>; + status = "disabled"; + }; }; usb2: usb@70f8800 {