Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3592238imw; Thu, 7 Jul 2022 04:32:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uAvQFhLHL7ZAkVygHnqFWxWqu2JubS6vI+EiOzw6MNwFZ3bEdu8GCGFnXnOZdMKmcORhT7 X-Received: by 2002:a17:906:794f:b0:72b:1346:85a3 with SMTP id l15-20020a170906794f00b0072b134685a3mr1718990ejo.259.1657193578291; Thu, 07 Jul 2022 04:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657193578; cv=none; d=google.com; s=arc-20160816; b=GAX93e9syGJKIx1QnyXfzWIFH+aQxy1GbqeQTA2gu7xZ1S3pK7tIKY29hzX6qz7PDu wgYN3wanKKNDKwC3zd4vZN1rUQ4fiTyXBOmdvzQdH+SiCypJyekxkAUkCiZ5LFaOU1SL SKDWXwEGF7XJKIy2Jjouu4PiH/B5FZ1a1Dqsshk7RvrM34US7D5NXqh7idhtuJ82GQPL wBYuEFlVHu+/nq85ESHyJP3pEVnLXadjGOMyFUmKo1tJ9wlLFtdVVwpEn7N1M91lX3uX FJitBVVnqSj7qJD74SsirhVDbmEAY93EciwX6BflPpb4WwzyqA97nkig3LN62y5/nyIl sM/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:subject:cc:to:from:date:message-id:dkim-signature; bh=6ocG0Xck6UFoBCXVcbGriBvJ4wwbkS8brBEBVvGMITw=; b=R7yYR5lWMytjJujNoIHls9o58ZGN1cpw8SaZKHSh/JHBGxzSQboh4YqZS0nDTxMxNx JRFWxKnz2IKD/uz8z2QYj6mR6J7whHwz6M2T+ax0Mv8muMXkLblsUE9JmXYYRh9O8su4 WAMvjkJCwNvxikPsHw/oaxFhnx7L1DUb4DCY39PEJdF019QQfvt2Yk2L0wb/pK3foph7 eoQpX37EYTVOMB3rFv6EuEidPqBW6OMpLSmC0Vyd1Ri4LXUUJyJU5Bux+ZuGjDrY45e4 DxFDreXl3Oh2io1IK7GhSNiqoTMXmbPeVpy3o8hb626Ljq4yss7DvjhNV+vygIeC0eyl dmFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Q2yYlLuj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k15-20020aa7d8cf000000b0043a29c3e01bsi7962709eds.118.2022.07.07.04.32.32; Thu, 07 Jul 2022 04:32:58 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=Q2yYlLuj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235235AbiGGLHP (ORCPT + 99 others); Thu, 7 Jul 2022 07:07:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235339AbiGGLHN (ORCPT ); Thu, 7 Jul 2022 07:07:13 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B73857261; Thu, 7 Jul 2022 04:07:12 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id n4so12506373ejz.10; Thu, 07 Jul 2022 04:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:from:to:cc:subject:references:mime-version :content-disposition:in-reply-to; bh=6ocG0Xck6UFoBCXVcbGriBvJ4wwbkS8brBEBVvGMITw=; b=Q2yYlLuje44TpclVgSV40km5glpOaMJdyo/383PQm3a9IBFllScYiQtCL7SSXU8Kyd SoonSUjN2nsr6pvWv5sR9dTISXyt8c5wrUDfXV9TVI/94QUYjDPsYkZQVuPqBiXLjQlA b3pxn0ZDOh86lp5bLj5AhZsZwDX74rqrij/V7ya5pc8i+s6Em0y5VoZ4i/GAskJ9o5ag ITAcZl+T/8N6Cojoh0l27LwY3A8S6IFRkUGkR5JvvTLhBJjPCt1vTFxoxbBN86jMejWy CQAvKG7J3Nps+X5HoYUVdDrhjU7/zocopakCohb7EaCJkNPeabxr51dUMII7PR3FeJsW w9Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:from:to:cc:subject:references :mime-version:content-disposition:in-reply-to; bh=6ocG0Xck6UFoBCXVcbGriBvJ4wwbkS8brBEBVvGMITw=; b=V1fQ3CtP/e9cPQmYWoPibOzUhJC9DMxmJ6e4hV8ZQmZRGj7mrTNSZWLbRrR7n1LmPr vcf94+y5UfjFDA2niRCQPlWpIKramudbE4llCePkrvy/YfyfApAOXacxWKFFKk79h3Vp uzQoXvkChW0F66hLaNLrNP1VWRnqMXFjA1kCZmoFUN+IqOcZIvlHxgS4tOlP3tQMLu9E KJT4H7iYdv8PGwxepcjgzNb+6yklUpv50bgYo0ukZ25IXurB2nw1GMgd8sNXg7DnmY+v EBZRgI6Zoj85lt2CxEejAf0JEP4sUiJNf0cHHRegr0fI4JF8LruE0wgw2UIeeF7VFpuH uoSg== X-Gm-Message-State: AJIora+xwGA5ddNFhGDizYSq0cHDC7XQhEnmxlRYroI0TmJSxSuly+5i ogJN7WA0v40Bos5UMePD9gKJKOCZi9A= X-Received: by 2002:a17:907:75e1:b0:72a:ebee:5f61 with SMTP id jz1-20020a17090775e100b0072aebee5f61mr12017592ejc.171.1657192030969; Thu, 07 Jul 2022 04:07:10 -0700 (PDT) Received: from Ansuel-xps. (93-42-70-190.ip85.fastwebnet.it. [93.42.70.190]) by smtp.gmail.com with ESMTPSA id g18-20020a17090604d200b006ff0b457cdasm647905eja.53.2022.07.07.04.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 04:07:10 -0700 (PDT) Message-ID: <62c6be5e.1c69fb81.d194f.1258@mx.google.com> X-Google-Original-Message-ID: Date: Thu, 7 Jul 2022 13:07:09 +0200 From: Christian Marangi To: Baolin Wang Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Ohad Ben-Cohen , linux-arm-msm@vger.kernel.org, Devicetree List , LKML , linux-remoteproc@vger.kernel.org Subject: Re: [PATCH 1/3] hwspinlock: qcom: Add support for mmio usage to sfpb-mutex References: <20220707013017.26654-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Thu, Jul 07, 2022 at 07:00:15PM +0800, Baolin Wang wrote: > On Thu, Jul 7, 2022 at 9:30 AM Christian Marangi wrote: > > > > Allow sfpb-mutex to use mmio in addition to syscon. > > > > Signed-off-by: Christian Marangi > > --- > > drivers/hwspinlock/qcom_hwspinlock.c | 32 ++++++++++++++++++++++------ > > 1 file changed, 25 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c > > index 364710966665..23c913095bd0 100644 > > --- a/drivers/hwspinlock/qcom_hwspinlock.c > > +++ b/drivers/hwspinlock/qcom_hwspinlock.c > > @@ -19,6 +19,11 @@ > > #define QCOM_MUTEX_APPS_PROC_ID 1 > > #define QCOM_MUTEX_NUM_LOCKS 32 > > > > +struct qcom_hwspinlock_of_data { > > + u32 offset; > > + u32 stride; > > +}; > > + > > static int qcom_hwspinlock_trylock(struct hwspinlock *lock) > > { > > struct regmap_field *field = lock->priv; > > @@ -63,9 +68,20 @@ static const struct hwspinlock_ops qcom_hwspinlock_ops = { > > .unlock = qcom_hwspinlock_unlock, > > }; > > > > +static const struct qcom_hwspinlock_of_data of_sfpb_mutex = { > > + .offset = 0x4, > > + .stride = 0x4, > > +}; > > + > > +/* All modern platform has offset 0 and stride of 4k */ > > +static const struct qcom_hwspinlock_of_data of_tcsr_mutex = { > > + .offset = 0, > > + .stride = 0x1000, > > +}; > > + > > static const struct of_device_id qcom_hwspinlock_of_match[] = { > > - { .compatible = "qcom,sfpb-mutex" }, > > - { .compatible = "qcom,tcsr-mutex" }, > > + { .compatible = "qcom,sfpb-mutex", .data = &of_sfpb_mutex }, > > + { .compatible = "qcom,tcsr-mutex", .data = &of_tcsr_mutex }, > > { } > > }; > > MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match); > > @@ -101,7 +117,7 @@ static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev, > > return regmap; > > } > > > > -static const struct regmap_config tcsr_mutex_config = { > > +static const struct regmap_config qcom_hwspinlock_mmio_config = { > > .reg_bits = 32, > > .reg_stride = 4, > > .val_bits = 32, > > @@ -112,18 +128,20 @@ static const struct regmap_config tcsr_mutex_config = { > > static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev, > > u32 *offset, u32 *stride) > > { > > + const struct qcom_hwspinlock_of_data *data; > > struct device *dev = &pdev->dev; > > void __iomem *base; > > > > - /* All modern platform has offset 0 and stride of 4k */ > > - *offset = 0; > > - *stride = 0x1000; > > + data = of_device_get_match_data(dev); > > Nit: better to validate the return value though this is a rare case. > > if (!data) > return -ENODEV; > Wonder if that can actually happen? Looking at of_device_get_match_data() it can only return the data or NULL if the match data is not defined but considering it should ALWAYS be defined (or the driver can't work). But yhea should be a value to check. -- Ansuel