Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753280AbbHCLQv (ORCPT ); Mon, 3 Aug 2015 07:16:51 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:45291 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752752AbbHCLQu (ORCPT ); Mon, 3 Aug 2015 07:16:50 -0400 Message-ID: <1438600598.3844.10.camel@pengutronix.de> Subject: Re: [PATCHv2 3/4] reset: socfpga: Update reset-socfpga to read the altr,modrst-offset property From: Philipp Zabel To: dinguyen@opensource.altera.com Cc: dinh.linux@gmail.com, robh+dt@kernel.org, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, mark.rutland@arm.com, pawel.moll@arm.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, s.trumtrar@pengutronix.de Date: Mon, 03 Aug 2015 13:16:38 +0200 In-Reply-To: <1438376591-22100-4-git-send-email-dinguyen@opensource.altera.com> References: <1438376591-22100-1-git-send-email-dinguyen@opensource.altera.com> <1438376591-22100-4-git-send-email-dinguyen@opensource.altera.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:100:96de:80ff:fec2:9969 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3675 Lines: 104 Hi Dinh, Am Freitag, den 31.07.2015, 16:03 -0500 schrieb dinguyen@opensource.altera.com: > From: Dinh Nguyen > > In order for the Arria10 to be able to re-use the reset driver for SoCFPGA > Cyclone5/Arria5, we need to read the 'altr,modrst-offset' property from the > device tree entry. The 'altr,modrst-offset' property is the first register > into the reset manager that is used for bringing peripherals out of reset. > > The driver assumes a modrst-offset of 0x10 in order to support legacy > Cyclone5/Arria5 hardware. > > Signed-off-by: Dinh Nguyen Applied, thanks. regards Philipp > --- > v2: assume a modrst-offset of 0x10 if the property is not specified in order > to support legacy boards that do not have the property. > --- > drivers/reset/reset-socfpga.c | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > > diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c > index 0a8def3..1a6c5d6 100644 > --- a/drivers/reset/reset-socfpga.c > +++ b/drivers/reset/reset-socfpga.c > @@ -24,11 +24,11 @@ > #include > > #define NR_BANKS 4 > -#define OFFSET_MODRST 0x10 > > struct socfpga_reset_data { > spinlock_t lock; > void __iomem *membase; > + u32 modrst_offset; > struct reset_controller_dev rcdev; > }; > > @@ -45,8 +45,8 @@ static int socfpga_reset_assert(struct reset_controller_dev *rcdev, > > spin_lock_irqsave(&data->lock, flags); > > - reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS)); > - writel(reg | BIT(offset), data->membase + OFFSET_MODRST + > + reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS)); > + writel(reg | BIT(offset), data->membase + data->modrst_offset + > (bank * NR_BANKS)); > spin_unlock_irqrestore(&data->lock, flags); > > @@ -67,8 +67,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev, > > spin_lock_irqsave(&data->lock, flags); > > - reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS)); > - writel(reg & ~BIT(offset), data->membase + OFFSET_MODRST + > + reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS)); > + writel(reg & ~BIT(offset), data->membase + data->modrst_offset + > (bank * NR_BANKS)); > > spin_unlock_irqrestore(&data->lock, flags); > @@ -85,7 +85,7 @@ static int socfpga_reset_status(struct reset_controller_dev *rcdev, > int offset = id % BITS_PER_LONG; > u32 reg; > > - reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS)); > + reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS)); > > return !(reg & BIT(offset)); > } > @@ -100,6 +100,8 @@ static int socfpga_reset_probe(struct platform_device *pdev) > { > struct socfpga_reset_data *data; > struct resource *res; > + struct device *dev = &pdev->dev; > + struct device_node *np = dev->of_node; > > /* > * The binding was mainlined without the required property. > @@ -120,6 +122,11 @@ static int socfpga_reset_probe(struct platform_device *pdev) > if (IS_ERR(data->membase)) > return PTR_ERR(data->membase); > > + if (of_property_read_u32(np, "altr,modrst-offset", &data->modrst_offset)) { > + dev_warn(dev, "missing altr,modrst-offset property, assuming 0x10!\n"); > + data->modrst_offset = 0x10; > + } > + > spin_lock_init(&data->lock); > > data->rcdev.owner = THIS_MODULE; -- 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/