Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932157AbbG1O1k (ORCPT ); Tue, 28 Jul 2015 10:27:40 -0400 Received: from mail-bn1on0063.outbound.protection.outlook.com ([157.56.110.63]:43102 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752762AbbG1O1h (ORCPT ); Tue, 28 Jul 2015 10:27:37 -0400 Authentication-Results: spf=temperror (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Tue, 28 Jul 2015 07:27:24 -0700 From: =?utf-8?B?U8O2cmVu?= Brinkmann To: Moritz Fischer CC: Philipp Zabel , , , , , Kumar Gala , "Michal Simek" , , , linux-arm-kernel , Subject: Re: [RFCv2 3/3] reset: reset-zynq: Adding support for Xilinx Zynq reset controller. Message-ID: <20150728142723.GS2650@xsjsorenbubuntu> References: <1437783682-13632-1-git-send-email-moritz.fischer@ettus.com> <1437783682-13632-4-git-send-email-moritz.fischer@ettus.com> <1438072680.3193.24.camel@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-21708.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11OLC002;1:/RxGlOwZD665wp80JuXQ8jjVNDU+aNw7kJ/c9sc/lVrwmmBlHKxeOe5YwzIlSTeeLLF9aKFwrq/dusOVrYaihNxrCRhM9z4tY4hmbaCsOUv2SzLNTtxQ+jhrTgfluJTwDjDx5yKZf7LRsBdkESygqMhpwXCH6Ikt8zc8fQm7hxPia6m99iIZ0vmd+J/MB9Lz2Unk+DsOOm+WfK0z2VIf6ULqlGkqoMEy6+GGkjmv6NH6qSBYl18MqQW4VF04wmd/WtrMvynmw6/al5Ns60I2LQcKzSSJSCBuRkWXt2aWhEVGl47mqcAoC9RbFdFhMlqY X-Forefront-Antispam-Report: CIP:149.199.60.100;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(377454003)(189002)(377424004)(24454002)(199003)(189998001)(33716001)(33656002)(54356999)(50986999)(76176999)(23676002)(92566002)(5001960100002)(110136002)(86362001)(87936001)(561944003)(47776003)(2950100001)(4001350100001)(77096005)(83506001)(36386004)(46102003)(93886004)(77156002)(62966003)(106466001)(85202003)(57986006)(76506005)(63266004)(19580405001)(19580395003)(6806004)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN1AFFO11HUB013;H:xsj-pvapsmtpgw02;FPR:;SPF:TempError;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11HUB013;2:gpW1TJJgLWl5aKA3D7aaJwQnM9X/BObceuy11vj3I0H/n5rSAp7RANu+aQraEye7x+ISS8hvdYdZRajZmWu8OJrb/ccwEEGkierXDFk4j3A5E8vPfzFeOrlal+QdGWOdsbMVHPebEBRF4nq+qyPbW6u4B2Qgf8YvdcwGqLeEjPw=;3:YrHW27G7TTyTqn50cQSnSytiVyW4d44yb9RAW/T0Iza/6RcE21vskTUx4gKlt+LW+YzFlHnkills8SX4SPDtaTyFjAySj2vSfHyAINts1zXLR70ztE76zJwnozVDEPJbUK5wBHUV6iiscDeM9xIPzSyNFWm2CpnwAx3DqU81AGjX4l7qmqm4HN3K4u5ywgE8uGwwquteexJvxQ9Pwe6pUyx9v5HF859lWrJNthZq7HCODkisWNhhYhc7fFbU4pon;25:89XXNqNuN6iPdDUMdUy3Ngcz2MB3EzkH7/G7vXWb+WwHWEAjRrgKmvlh9pAZcOfJxv7dyieWDqnHCMA5NIJSEvAI4XjUcIQVBqCC6YVnp71rsSXasD+owbYSND1Dgzsz2L0kEvEXJzmtOWEj07dFUkW4es5vSH9XEItxS5SNXycogqMUCKYhB8Z1nwJ320frgGmODjhJvSUeNzrM65i9KSSYseYPAOsZF2nawaYK2zPOsufYEGhpGhZBLTH539M2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1AFFO11HUB013; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11HUB013;20:LKl6vorb4UIPbp8fgs55sMZPzdYTXIrYmXhtXprBWuhZqXqQclLtaRhd33x7GkRolY6fYlp0W/PCA8GQSQWpvS9yd1eZyFQPURkRY5HaY4M9XwFRVRh3+qRt55ak2+044D0wUGCMmZ/QUUDhgLlS85I741sG14pGGEi+AroUwib1UqbhQGYsZcW0vSGTjGGbnahRz+l/HOZsNyS3RpQIRsPUkBLLXSoCzrDBDyG7hel1Wlh/Bo9xRQr8K/HaD1E5+HlXX2ubUVeAxSX4TwPJwCfuxVlWhqzlmao/g95YuCHPuFrlZK0+FXY6iiBw+Dn4unfbXCmwZIs6knbncMbNrHYYFC+azeJs/SIyAICjwdP5YeOJYEpuIIlxtB39h7TsxkhEdUX3ObQZtIJsXNJbBt82trsJHdkxAqYL2BD9qBCKDwO0yAMBhEY/4AQpKpJ00doi64KMR0J+7FxAeMfnPtqH0DO4kiCkrF1eDcicerOLAn6/gGARMDvmyq5NQqgS;4:vj0SDNL9o96EbOYpbdRvUPgwFGRuJUkCbaKhZnoG0ikgBrBMGB3fYXtQ+hsv9q5/L/edPbMXsv/9/t15J4yIVM2JR1D/E6w4OcFa/j+T9CIdii9lrKer40Mkx5mfzD2OVp2CYXy9O7bed1K1+xNFsvBLHrgoDKNL/IDsH8j8daVKYz0atQES+d0uFSr/fggFKh8gdizDz2vwAWAdMPZqyFqVljAE0xQzzTQL5Ldy2VyHAHWvRyXqdcVBZmkZgj7wpGPAXpCT27yhdj8NKjT1iwNRysxISbrb8mlt9tNzc7w= BN1AFFO11HUB013: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BN1AFFO11HUB013;BCL:0;PCL:0;RULEID:;SRVR:BN1AFFO11HUB013; X-Forefront-PRVS: 06515DA04B X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjFBRkZPMTFIVUIwMTM7MjM6Y2ZTMHhTRURQeUdTSGFzNzQrMUtnTTMz?= =?utf-8?B?aVVuZGhPR1g2QnZsNzdtYm9tUHQrQ3dNSFBjRXBUZXVtY2o1eWdjVG1hLzdV?= =?utf-8?B?bFRBdmoxb3kwNk85bWVGVCtKM3J1aWZRWlRiRmVxOGl0WHYxcWMxaHZsS2pE?= =?utf-8?B?bGliOUcreHFVLzJ0ZjVXdWFEY1YzeEw4Y1J0QkJORlJaZkhCMk5yN1FsRTM0?= =?utf-8?B?K2hWdEJzcTlHLzlSQVVydlJHSTJmREg5R3YxNWtRNGlsWU9SN1dBM0V6UUMy?= =?utf-8?B?c1Bzakl0RWdZSjlraTQ1TmxXOUhRMzg0OWJBNWliRElaVGFzRjE2YXZQemJK?= =?utf-8?B?Njd5WHUycDFIL2xOd1Z4WktzdzNZaWV1L1ZaZ2N5UnViOGI0OVZiSEhNeEV4?= =?utf-8?B?eXpZdUVkZThUUE5vNVJRUVFROURDR3BGL21aQ083Q1R1OCtZRXkwSThvSnNQ?= =?utf-8?B?ZzRtZFdaa0Y0N3B3STF4RUFqS3VnOUtyTkJINGRYdk9scHVoUkpNQmNqbDV6?= =?utf-8?B?d1V1YURxQVE5OW5XS0dQMGtVMHJjN0ZRdUdhYUVOZzRieGRHUk1yZTR4N21x?= =?utf-8?B?bTZjWTNhMFdRM0UvNFZUVHlDSWZZUldHQmRHdnArdDhhQ21qaThRVjRmc2hq?= =?utf-8?B?NGVGejFDVTZaazloZFNDVVdiUXFOL2dpeXY3L2tDdEpOVTF3SWY2QktvaHZT?= =?utf-8?B?Q09zOGRjM1REO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4TMEmfWuag5uV7q8by97H+X/VwMltwaZPMxebiTHLFStoLf2GWADHt2Smc3JEXDVOQ8iggk= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2015 14:27:34.4730 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1AFFO11HUB013 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3793 Lines: 107 On Tue, 2015-07-28 at 07:05AM -0700, Moritz Fischer wrote: > Philip, > > thanks for your review :) > > On Tue, Jul 28, 2015 at 1:38 AM, Philipp Zabel wrote: > > Hi Moritz, > > > > Am Freitag, den 24.07.2015, 17:21 -0700 schrieb Moritz Fischer: > >> This adds a reset controller driver to control the Xilinx Zynq > >> SoC's various resets. > >> > >> Signed-off-by: Moritz Fischer [...] > >> + > >> +/* Offsets into SLCR regmap */ > >> +#define SLCR_RST_CTRL_OFFSET 0x200 /* FPGA Software Reset Control */ > > > > Maybe get this value from the reg property? I'm not sure if this is ever > > expected to change. > I don't think it's going to change. Is there a reason to only expose > part of the resets? I think all other users of the syscon (in the Zynq DT) use the 'reg' property to retrieve an offset into the SLCR. We should probably do that here too and remove the #define. Who knows, maybe this driver is reusable with some modifications for the Zynq MPSoC. > > > >> +#define NBANKS 18 > > > > reg = <0x200 0x50> says there are two more registers, are those not used? > > Should be 0x48, you're right. Michal had suggested 0x50, but the last > two regs are not really resets. > > [...] > >> +static int zynq_reset_status(struct reset_controller_dev *rcdev, > >> + unsigned long id) > >> +{ > >> + struct zynq_reset_data *priv = to_zynq_reset_data(rcdev); > >> + > >> + int bank = id / BITS_PER_LONG; > >> + int offset = id % BITS_PER_LONG; > >> + u32 reg; > >> + > >> + regmap_read(priv->slcr, SLCR_RST_CTRL_OFFSET + (bank * 4), ®); > >> + > >> + return !(reg & BIT(offset)); > >> +} > > Will change to: > ret = regmap_read(priv->slcr, SLCR_RST_CTRL_OFFSET + (bank * 4), ®); > if (ret) > return ret; > else > return !!(reg & BIT(offset)); > > the single '!' was a typo ... You have an early return on error in the if-branch. No need for the else. > > > > > Do I understand this correctly, you write 1 to assert the reset, but the > > register reads 0 while the reset is asserted and 1 otherwise? > > Also note that reset_status may return negative ERRNO, so for offset == > > 31 you should not return (1<<31). > > > >> +static const struct reset_control_ops zynq_reset_ops = { > >> + .assert = zynq_reset_assert, > >> + .deassert = zynq_reset_deassert, > >> + .status = zynq_reset_status, > >> +}; > >> + > >> +static int zynq_reset_probe(struct platform_device *pdev) > >> +{ > >> + struct zynq_reset_data *priv; > >> + > >> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); > >> + if (!priv) > >> + return -ENOMEM; > >> + platform_set_drvdata(pdev, priv); > >> + > >> + priv->slcr = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, > >> + "syscon"); > > > > I'd just use syscon_node_to_regmap(pdev->dev.of_node->parent) here, > > which removes the need for the syscon phandle binding. > > See binding doc discussion. I don't have a strong preference either way, > just tried to be consistent with the pinctrl node. > We just need a decision one way or the other :) I personally like the syscon handle better since it would make placing the node more flexible, while this proposal forces some topology on the DT. In both cases though, the syscon and this user are tightly coupled and this driver depends on the syscon. I don't really mind either way - I think. Sören -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/