Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp461893rdb; Fri, 26 Jan 2024 00:22:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7IwwbtzriJYkYZLmDkAGPPJoyqk34TfpjN/csLX0LNm1HVHb3nmD2PM9n8SQ7bb3IBnCc X-Received: by 2002:a05:620a:22cf:b0:783:5baf:a9b7 with SMTP id o15-20020a05620a22cf00b007835bafa9b7mr820477qki.148.1706257354532; Fri, 26 Jan 2024 00:22:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706257354; cv=pass; d=google.com; s=arc-20160816; b=mR4g4R9QcNTYYxQ2ILIH56haBLRkLxllHCjvV6qbfdSinjWr6aWZ5yqq1dY5akPeY3 TJvpzf1L3zvBkT16jJ5RVli8PHz/mvF0Gcw69ZAXt+S4fWOFbClkN/mrtVL81GiV+X2R DgwUFRk9wQtOnmbxrN7PxRjJCVbVglRp18/oXRz0fmQvlCLc2KKtHb2EE/bg64376n7j iQsFBNzvnRYidsWfSFIS0iNYmFXZUwMzhUBkajFTDDdcBfN+40qTw8imCnfbSk5FnPPy OsjnMAogm6+E2VFny8Z1+543CwfZSKEGdjCISbInDvrUT5mmft8nmKaQo29NlrSkQcyj B1rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=ZqBsqO9T2JlEoqQ8jk72n3yUEjY0ZoIwmU374g2YkEw=; fh=brGe74e6yjPX7mZjp29+1wvvnNPwuiU07NHKDRNKMgs=; b=krwJ3q8HU32OP+3sTlM9zzAQ9u5Yyr3NZshfG4t92Bzfulc1r7W4MRM10FULpClyqi +KaIi0iKttr/kChFlVZrv3lyxm3welm1QiQq/CzESCKo5Slt94b1eP4o1ejMzM7CAIvv UAM5DUZBsEP2zeNFvO7bWhuaahHXiOqvIj+SGaCcSfEGcZ/te8+Y6VA2DHncXzBZj+CQ FmNjqI6mHSBpcuev1uF8dBNtGITuKUD5iV7F8D/eKhqul2hWskqiUNArB9dPMzxxXMmB XGbGUkoTSQJGMhPUAkbe6iZzTO+4RXsAAxW+H52KK6jYPGM1ajkcQXFJezHbDZw5NOaG AFJg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-39694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39694-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v7-20020a05620a090700b00783c7178a9dsi794955qkv.772.2024.01.26.00.22.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 00:22:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-39694-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39694-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2A7F01C22246 for ; Fri, 26 Jan 2024 08:22:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F15421B596; Fri, 26 Jan 2024 07:20:22 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C60E31AAC4 for ; Fri, 26 Jan 2024 07:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706253622; cv=none; b=S8jfYabQdMJvl40Xq/Il8IrdmMtVkusKk1tJuTX+bkbhD6diPBzdB2+jnnhEbEb/dRGUBh56EX/ku0mea3iD40wNNU1/FIEv3LMKRM5mPs67/tBCIsN2WvE/FJqS6JpPAFS1yGFQwb7gqf/S0SXtmJQHN4YMhcQH2gRHIj/5QJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706253622; c=relaxed/simple; bh=2MlIvEb5ti15ByVLn0Sx8MbSa5UY7PBvuWGN5H1F15g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EdbQ3vOgsh+Z6TZB1FikpuHTZLGh7rN8k8+o87NRVz5/dUsBLfleEta5YIFgB5tUEnTF5BG196CsrVUedTwnQAXrxrQkAllhITT1Elusm7M1KboLfVt9QDF4rjTCdbP7NEJABlBEiqXS40tfRblAuwuUtIAA/bmYzmFlQokZPro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rTGVU-0000h3-J6; Fri, 26 Jan 2024 08:20:08 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rTGVJ-002SaA-Ok; Fri, 26 Jan 2024 08:19:57 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rTGVJ-008SOJ-2A; Fri, 26 Jan 2024 08:19:57 +0100 Date: Fri, 26 Jan 2024 08:19:51 +0100 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Wenhua Lin Cc: Orson Zhai , Baolin Wang , Chunyan Zhang , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, wenhua lin , Xiongpeng Wu , zhaochen su , Zhaochen Su , Xiaolong Wang Subject: Re: [PATCH 1/6] pwm: sprd: Add support for UMS9620 Message-ID: References: <20240122081754.17058-1-Wenhua.Lin@unisoc.com> <20240122081754.17058-2-Wenhua.Lin@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="6hmfj7udr3e3yp5w" Content-Disposition: inline In-Reply-To: <20240122081754.17058-2-Wenhua.Lin@unisoc.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org --6hmfj7udr3e3yp5w Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 22, 2024 at 04:17:49PM +0800, Wenhua Lin wrote: > The PMW unit on the current Unisoc's SoCs has 4 channels but has different > address offsets. On UMS512, they are 0x0, 0x20, 0x40, 0x60 respectively, > while are 0x0, 0x4000, 0x8000, 0xC000 on UMS9620. >=20 > Signed-off-by: Wenhua Lin > --- > drivers/pwm/pwm-sprd.c | 28 ++++++++++++++++++++++++---- > 1 file changed, 24 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c > index 77939e161006..bc1e3ed13528 100644 > --- a/drivers/pwm/pwm-sprd.c > +++ b/drivers/pwm/pwm-sprd.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > #include > #include > =20 > @@ -23,7 +24,6 @@ > #define SPRD_PWM_ENABLE_BIT BIT(0) > =20 > #define SPRD_PWM_CHN_NUM 4 > -#define SPRD_PWM_REGS_SHIFT 5 > #define SPRD_PWM_CHN_CLKS_NUM 2 > #define SPRD_PWM_CHN_OUTPUT_CLK 1 > =20 > @@ -32,14 +32,27 @@ struct sprd_pwm_chn { > u32 clk_rate; > }; > =20 > +struct sprd_pwm_data { > + int reg_shift; > +}; > + > struct sprd_pwm_chip { > void __iomem *base; > struct device *dev; > struct pwm_chip chip; > + const struct sprd_pwm_data *pdata; > int num_pwms; > struct sprd_pwm_chn chn[SPRD_PWM_CHN_NUM]; > }; > =20 > +static const struct sprd_pwm_data ums512_data =3D { > + .reg_shift =3D 5, > +}; > + > +static const struct sprd_pwm_data ums9620_data =3D { > + .reg_shift =3D 14, > +}; > + > static inline struct sprd_pwm_chip* sprd_pwm_from_chip(struct pwm_chip *= chip) > { > return container_of(chip, struct sprd_pwm_chip, chip); > @@ -58,7 +71,7 @@ static const char * const sprd_pwm_clks[] =3D { > =20 > static u32 sprd_pwm_read(struct sprd_pwm_chip *spc, u32 hwid, u32 reg) > { > - u32 offset =3D reg + (hwid << SPRD_PWM_REGS_SHIFT); > + u32 offset =3D reg + (hwid << spc->pdata->reg_shift); > =20 > return readl_relaxed(spc->base + offset); > } > @@ -66,7 +79,7 @@ static u32 sprd_pwm_read(struct sprd_pwm_chip *spc, u32= hwid, u32 reg) > static void sprd_pwm_write(struct sprd_pwm_chip *spc, u32 hwid, > u32 reg, u32 val) > { > - u32 offset =3D reg + (hwid << SPRD_PWM_REGS_SHIFT); > + u32 offset =3D reg + (hwid << spc->pdata->reg_shift); > =20 > writel_relaxed(val, spc->base + offset); > } > @@ -253,6 +266,7 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *sp= c) > static int sprd_pwm_probe(struct platform_device *pdev) > { > struct sprd_pwm_chip *spc; > + const void *priv; This can better be of type struct sprd_pwm_data *. Also pdata would be a better name. > int ret; > =20 > spc =3D devm_kzalloc(&pdev->dev, sizeof(*spc), GFP_KERNEL); > @@ -263,6 +277,11 @@ static int sprd_pwm_probe(struct platform_device *pd= ev) > if (IS_ERR(spc->base)) > return PTR_ERR(spc->base); > =20 > + priv =3D of_device_get_match_data(&pdev->dev); > + if (!priv) > + return dev_err_probe(&pdev->dev, -EINVAL, "get regs shift failed!\n"); > + spc->pdata =3D priv; > + > spc->dev =3D &pdev->dev; > =20 > ret =3D sprd_pwm_clk_init(spc); > @@ -281,7 +300,8 @@ static int sprd_pwm_probe(struct platform_device *pde= v) > } > =20 > static const struct of_device_id sprd_pwm_of_match[] =3D { > - { .compatible =3D "sprd,ums512-pwm", }, > + { .compatible =3D "sprd,ums512-pwm", .data =3D (void *)&ums512_data}, > + { .compatible =3D "sprd,ums9620-pwm", .data =3D (void *)&ums9620_data}, Please use one line per assignment. Do you really need the cast to void *? Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --6hmfj7udr3e3yp5w Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmWzXRYACgkQj4D7WH0S /k4JmwgAkLH4Y8EJskrxYs0xavniF70Hm1Dr48Cp50Of6D25lfLnkXou+9JXjJT1 OaJLTED1r8yDO4rPT58QOeEF1L58RpMtrqjG7FJfA3cBf/NX4cEDT9i81zVL1je+ c2sZj01cx8X1dkeuSZtkKNXcWRI/yQV1PH/r3XDzwxIwNxbpQEwt1PRpu0C1U2qm ONlTDLpZZSaEJV7HfH24WCnrco/jR6G8n4QImLzyvV8FAOGV6+GqYPvXu7fJ4Aop zxGGb0keN8BmuCDWP+NfnxrsRg7IReowVY2g1uQtTNAczmh/tqVmJv6RZmB/6kdR HjRy/yHKEM27bM6tQwnhc6gv/9ZgDw== =/S+R -----END PGP SIGNATURE----- --6hmfj7udr3e3yp5w--