Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754504AbbGXQeh (ORCPT ); Fri, 24 Jul 2015 12:34:37 -0400 Received: from mail-by2on0080.outbound.protection.outlook.com ([207.46.100.80]:41856 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754470AbbGXQed (ORCPT ); Fri, 24 Jul 2015 12:34:33 -0400 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Fri, 24 Jul 2015 09:19:27 -0700 From: =?utf-8?B?U8O2cmVu?= Brinkmann To: Moritz Fischer CC: , , , Subject: Re: [RFC 3/3] reset: reset-zynq-pl: Adding support for Xilinx Zynq PL reset. Message-ID: <20150724161927.GB2531@xsjsorenbubuntu> References: <1437691862-21312-1-git-send-email-moritz.fischer@ettus.com> <1437691862-21312-4-git-send-email-moritz.fischer@ettus.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1437691862-21312-4-git-send-email-moritz.fischer@ettus.com> 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-21700.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD001;1:g8eSxFD5t91d5hyHcmNAbirprrjExnZ2L4gBD/dT18R116IayydyQ/F79pkWhhqgmSwAohB5+VFAYbunQ0RetmGK9ezFieMEvWAMdERcTcs38gGv1wBT5VS/+1Ly9TFnL8oEhlcwTE9kYbc+B952T7pqErb3Lt2Miur6gpl6YrofguoM+8ifn/LtlWnp/8xW8843wdbgZEQi+oli0ehQgYX7LyToy0JhscQ/OKpvyWPoInfD7wm3pOnJbfjd5EsJJU3dmK3Lty3a36ObXkDao7XAmwO2OclicPi5DIe/3pI1BPaeLrYpzTT6SsK+VRXo X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(377424004)(24454002)(199003)(189002)(164054003)(33716001)(23676002)(4001350100001)(189998001)(46102003)(92566002)(47776003)(33656002)(2950100001)(50986999)(77096005)(62966003)(54356999)(76176999)(77156002)(85182001)(19580405001)(50466002)(87936001)(83506001)(85202003)(19580395003)(6806004)(230783001)(63266004)(110136002)(5001960100002)(106466001)(76506005)(57986006)(86362001)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2FFO11HUB041;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB041;2:FnoIsp475iItEAxefl6Aa6iaOcgkvMAcwgCU95uAQ/y1u1X/2aeXUhHdwqHqMyze;3:EmNV3+n/a6DfgyVDzamNu4nA8EPuQiFJXAoU28iNCUIpDbo5QL2lyIeRQOJRS/c6u/iukhCUI9ucXrVCJgNC8M9ZJIGM3JGOTdMv/Mwcoo42R2hQKUG6lAuD/gLfg0F3BVHsVEVBglJ0JU7KWIOS12wIExKEsUCg/ylzfhJOPVas5aTBGlVmRpjcH12ZgLqm8Q5h5WtgEqvEP+tqnvfi3938A2V9BjZxoGy2J06l6YU=;25:Km5Y0cYBbbsnuKnnKc7/6JcEMX/W62TOvlEdfLoGr3lp3JOFPI9yiazCwIviZEPxO/c/LHbt7MbmLlbb4AFYits+fbVreE3zC1GQhHmv9fBVYJD1v4C/J1YD+UZT/6uu/tW8mND3IitOT2XA67ic8nET31pHyo9GbmV7rd8/tJ7j5dpr8CdJ9OV67Vs8Lcn/tRTTekI9v/yCplJGCxaSr9EZ7y0VgRWZPitp8pHDzfUil1V5pafiFrrvLGHo1wnjoXsuIgu3GTot2r5ckdkm+A== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2FFO11HUB041; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB041;20:zBMvfbCeCsz9j9SSe6taEGX3vihFfcS7wPEz46mYeICQM2UMf42NrV+ZzS/kFDm60DlSBNhZ0dtFyXorITuzrQdmsB4OAR/VX0i+jOSpO+vBlBHOVLVuECnhSnEk0NjZwujb42VaCsJgWD7PYhgePMkxkQVShhB+UtngbR441rZkYsiqeacxHBuaolPDPWiSUZrLuWksQ5X+3MTgjpc7m/eoFmicAc5pM5emNogScN14VYDRTS7trx766GAvehjWMFglRLizN3KA7XOqpi5oxxwk4A6RJisA48w0f2b0TgOl7JVIstnN89B7gtsaq2oU6nxW2QT2fhfhss2EvT4Lv+agcwz6LaE57JrgFDbbj/IWKFbr4FpVrtqAhWGV05FB9QatgpUii4D9XRR5wXSjD3hGCjlM1r5PSU/OV4rS4iXMpOspynB6c5xILVZSGyactlG5MN+LzmETvixVepb4V1zG/o9DI7yLronRlb2EmL52dGxYKm4whNThmk3c2q/D;4:ZSR8DEvbEVKX3a0Pcvr/osXZc6rW0MLiMvrnzNlBrczKkhOkkYXcQenkj0gB8/xq8ipseZ3a6Xo5iht+u+lHTkszKA7PkBZw98EKHl9XLbL5glAUFavUPciTRaErvm9SwvqW/UMSEU1pgiNXU42OP0W/mvu/fQkGeTy5YfhDnOTLbVVVUTrDqgF2RtxJ17i4mQ2N/rIEtJIxaTorEZ/AS5l8S0uCXYs6/X8TxeqR2wgh3L5Ji+mWMAbBv+U3E3ZgOGHMNoGeSqezf8+FmXfydMaDm9bSsUF48H5DiKlgP/o= BY2FFO11HUB041: 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:BY2FFO11HUB041;BCL:0;PCL:0;RULEID:;SRVR:BY2FFO11HUB041; X-Forefront-PRVS: 0647963F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U1DTHNtZHhnZmxGVzR3MFk0T0RXQVo4UTdMTFkv?= =?utf-8?B?b2pVdm5zRnVPSlRoWnN2SVhKVURVY244SkJuaVBLZWdURzZPNDhQaEhxVnZj?= =?utf-8?B?Z1p2Tmg2NVFkWnVwR2xYQzBhUTgxQk1ha1dhOElNYzZ4c3k3Zk5FRzB5RWRy?= =?utf-8?B?RFZqcDZwcW5RTWYxT2QvVWxBV292cGpvaUFEUXlldmlLZ1E2bVR3VWRFZWM4?= =?utf-8?B?alJaVlptcGE1YWdKY1I5eCtEeG9WWnVnQ2FLVy9PQWlySkNISlNlamlEMmV2?= =?utf-8?B?czZZWkNlWVFPNkMrdzJCSG1CanZrM1dHcERQRE9BOHVzWUhqVy9aMEF6V3dD?= =?utf-8?B?L2RCcVlsd0NVU3dJZ0M4MldMWEpRY290bUN1TFFNSXpQYXNmTlh6N1hVQVA1?= =?utf-8?B?aVVSbVR3ZEZHcWRSTDlCK0FlM21KYkZ2N2htM09YQjNadWdiaHF5clBOY0Mx?= =?utf-8?B?VS9qRTduSTJpYzZqODlIL3JoSytCRHFZQTNCZmlJellyNkxBOE1BU1RJQmVO?= =?utf-8?B?bCttV0haeUViQStXOWRVbGpxekJjc0lra096TVZ2UT09?= X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11HUB041;5:pqC5Mge9tXjgvqfSyoQ6zRRgEmBKH8zKYS37TOqzUq7RDSd/KKKuQY5Y1v/lB5F77zyUQauvddBpbPAziWarSYsFrg2yQ6aNveeUsschay8vClQkMiPbAGchD4GXNoSZEEI/Gc9T+3HJ/pKqh21tFg==;24:MpdCjca0mFz/0BG1XtuiIU8RkZ4gHy+QCVPsDPBcDAd1jEEj+8Cccup2jV+L/WsWN9t6fj301aNh8l7rsxC9viSuIpwZSNeBck6dtO/0DxU= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2015 16:19:42.8540 (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.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2FFO11HUB041 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5902 Lines: 194 Hi Moritz, On Thu, 2015-07-23 at 03:51PM -0700, Moritz Fischer wrote: > The Zynq PL reset controller allows to control the 4 > FCLK{0..3}_RESETN signals that can be used to reset custom IP in > the PL. > > Signed-off-by: Moritz Fischer > --- > drivers/reset/Makefile | 1 + > drivers/reset/reset-zynq-pl.c | 142 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 143 insertions(+) > create mode 100644 drivers/reset/reset-zynq-pl.c > > diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile > index 157d421..5c86f92 100644 > --- a/drivers/reset/Makefile > +++ b/drivers/reset/Makefile > @@ -3,3 +3,4 @@ obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o > obj-$(CONFIG_ARCH_BERLIN) += reset-berlin.o > obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o > obj-$(CONFIG_ARCH_STI) += sti/ > +obj-$(CONFIG_ARCH_ZYNQ) += reset-zynq-pl.o > diff --git a/drivers/reset/reset-zynq-pl.c b/drivers/reset/reset-zynq-pl.c > new file mode 100644 > index 0000000..3e04ab0 > --- /dev/null > +++ b/drivers/reset/reset-zynq-pl.c > @@ -0,0 +1,142 @@ > +/* > + * Xilinx Zynq PL Reset Controller > + * > + * Copyright (c) 2015, National Instruments Corp. > + * Author: Moritz Fischer > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License as > + * published by the Free Software Foundation; either version 2 of > + * the License, or (at your option) any later version. Here you allow GPLv2 and later, whereas in the LICENSE macro you only allow GPLv2. That should be in sync. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* Offsets into SLCR regmap */ > +#define SLCR_FPGA_RST_CTRL_OFFSET 0x240 /* FPGA Software Reset Control */ > + > +struct zynq_pl_reset_data { > + struct regmap *slcr; > + struct reset_controller_dev rcdev; > +}; > + > +static int zynq_pl_reset_assert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zynq_pl_reset_data *priv = container_of(rcdev, > + struct zynq_pl_reset_data, > + rcdev); > + > + int offset = id % BITS_PER_LONG; > + > + regmap_update_bits(priv->slcr, > + SLCR_FPGA_RST_CTRL_OFFSET, > + BIT(offset), > + BIT(offset)); > + > + return 0; > +} > + > +static int zynq_pl_reset_deassert(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zynq_pl_reset_data *priv = container_of(rcdev, > + struct zynq_pl_reset_data, > + rcdev); > + > + int offset = id % BITS_PER_LONG; > + > + regmap_update_bits(priv->slcr, > + SLCR_FPGA_RST_CTRL_OFFSET, > + BIT(offset), > + ~BIT(offset)); > + > + return 0; > +} > + > +static int zynq_pl_reset_status(struct reset_controller_dev *rcdev, > + unsigned long id) > +{ > + struct zynq_pl_reset_data *priv = container_of(rcdev, > + struct zynq_pl_reset_data, > + rcdev); > + int offset = id % BITS_PER_LONG; > + u32 reg; > + > + regmap_read(priv->slcr, SLCR_FPGA_RST_CTRL_OFFSET, ®); > + > + return !(reg & BIT(offset)); > +} > + > +static const struct reset_control_ops zynq_pl_reset_ops = { > + .assert = zynq_pl_reset_assert, > + .deassert = zynq_pl_reset_deassert, > + .status = zynq_pl_reset_status, > +}; > + > +static int zynq_pl_reset_probe(struct platform_device *pdev) > +{ > + struct zynq_pl_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"); > + if (IS_ERR(priv->slcr)) { > + dev_err(&pdev->dev, "unable to get zynq-slcr regmap"); > + return PTR_ERR(priv->slcr); > + } > + > + priv->rcdev.owner = THIS_MODULE; > + priv->rcdev.nr_resets = BITS_PER_LONG; > + priv->rcdev.ops = &zynq_pl_reset_ops; > + priv->rcdev.of_node = pdev->dev.of_node; > + reset_controller_register(&priv->rcdev); > + > + return 0; > +} > + > +static int zynq_pl_reset_remove(struct platform_device *pdev) > +{ > + struct zynq_pl_reset_data *priv = platform_get_drvdata(pdev); > + > + reset_controller_unregister(&priv->rcdev); > + > + return 0; > +} > + > +static const struct of_device_id zynq_pl_reset_dt_ids[] = { > + { .compatible = "xlnx,zynq-reset-pl", }, > + { /* sentinel */ }, > +}; > + > +static struct platform_driver zynq_pl_reset_driver = { > + .probe = zynq_pl_reset_probe, > + .remove = zynq_pl_reset_remove, > + .driver = { > + .name = "zynq-pl-reset", > + .of_match_table = zynq_pl_reset_dt_ids, > + }, > +}; > +module_platform_driver(zynq_pl_reset_driver); > + > +MODULE_LICENSE("GPL v2"); GPLv2 or GPL? > +MODULE_AUTHOR("Moritz Fischer "); > +MODULE_DESCRIPTION("Zynq PL Reset Controller Driver"); > +MODULE_ALIAS("reset:zynq-pl"); There has been some discussion around the alias. I think in most cases it turned out to not be necessary to have. I think overall having a reset-manager is a good thing. But as already mentioned in the other emails, why stop at the PL? I think this should just become the Zynq reset controller and handle all the resets in the SLCR. Thanks, 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/