public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dinh Nguyen <dinguyen@opensource.altera.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
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>,
	<s.trumtrar@pengutronix.de>, <linux-kernel@vger.kernel.org>,
	<devicetree@vger.kernel.org>
Subject: Re: [PATCH 3/4] reset: socfpga: Update reset-socfpga to read the altr,modrst-offset property
Date: Tue, 28 Jul 2015 08:46:59 -0500	[thread overview]
Message-ID: <55B787D3.5060509@opensource.altera.com> (raw)
In-Reply-To: <1438073190.3193.28.camel@pengutronix.de>



On 7/28/15 3:46 AM, Philipp Zabel wrote:
> Am Montag, den 27.07.2015, 13:57 -0500 schrieb
> dinguyen@opensource.altera.com:
>> From: Dinh Nguyen <dinguyen@opensource.altera.com>
>>
>> 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.
>>
>> Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
>> ---
>>  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..9074d41 100644
>> --- a/drivers/reset/reset-socfpga.c
>> +++ b/drivers/reset/reset-socfpga.c
>> @@ -24,11 +24,11 @@
>>  #include <linux/types.h>
>>  
>>  #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_err(dev, "no altr,modrst-offset specified in device tree\n");
>> +		return -ENODEV;
>> +	}
>> +
> 
> This should fall back to the old value of 0x10 in case the device tree
> property doesn't exist. Otherwise you are breaking Cyclone5/Arria5 with
> older device trees.
> 

Ah yes, you're right. Thanks for catching this!

Dinh

  reply	other threads:[~2015-07-28 13:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 18:57 [PATCH 0/4] reset: socfpga: Add reset driver support for Arria10 platform dinguyen
2015-07-27 18:57 ` [PATCH 1/4] dt-bindings: Add reset manager offsets for Arria10 dinguyen
2015-07-27 18:57 ` [PATCH 2/4] ARM: socfpga: dts: add "altr,modrst-offset" property dinguyen
2015-07-27 18:57 ` [PATCH 3/4] reset: socfpga: Update reset-socfpga to read the altr,modrst-offset property dinguyen
2015-07-28  8:46   ` Philipp Zabel
2015-07-28 13:46     ` Dinh Nguyen [this message]
2015-07-27 18:57 ` [PATCH 4/4] ARM: socfpga: dts: Add resets for EMACs on Arria10 dinguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55B787D3.5060509@opensource.altera.com \
    --to=dinguyen@opensource.altera.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinh.linux@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=p.zabel@pengutronix.de \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=s.trumtrar@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox