Skip to contentSkip to conversation

reset: add socfpga_reset_status

PATCH Superseded [email protected] 2 participants 3 messages Oct 24, 2014 – Nov 3, 2014 Reset controller framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reset: add socfpga_reset_status

From: Dinh Nguyen <[email protected]>

Populate the reset_status callback for SOCFPGA.

---
 drivers/reset/reset-socfpga.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/reset/reset-socfpga.c +18 -0
index 79c32ca..cd37849 100644
@@ -76,9 +76,27 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
 	return 0;
 }
 
+static int socfpga_reset_status(struct reset_controller_dev *rcdev,
+				unsigned long id)
+{
+	struct socfpga_reset_data *data = container_of(rcdev,
+						struct socfpga_reset_data, rcdev);
+	int bank = id / BITS_PER_LONG;
+	int offset = id % BITS_PER_LONG;
+	unsigned long flags;
+	u32 reg;
+
+	spin_lock_irqsave(&data->lock, flags);
+	reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
+	spin_unlock_irqrestore(&data->lock, flags);
+
+	return !(reg & BIT(offset));
+}
+
 static struct reset_control_ops socfpga_reset_ops = {
 	.assert		= socfpga_reset_assert,
 	.deassert	= socfpga_reset_deassert,
+	.status		= socfpga_reset_status,
 };
 
 static int socfpga_reset_probe(struct platform_device *pdev)
Signature · 1 line
2.0.3
#1 lore raw

Hi Philipp,

Quoted 33 lines · On 10/24/2014 10:53 AM, [email protected] wrote:

From: Dinh Nguyen <[email protected]>

Populate the reset_status callback for SOCFPGA.

---
 drivers/reset/reset-socfpga.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/reset/reset-socfpga.c +14 -0
index 79c32ca..cd37849 100644
@@ -76,9 +76,27 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
 	return 0;
 }
 
+static int socfpga_reset_status(struct reset_controller_dev *rcdev,
+				unsigned long id)
+{
+	struct socfpga_reset_data *data = container_of(rcdev,
+						struct socfpga_reset_data, rcdev);
+	int bank = id / BITS_PER_LONG;
+	int offset = id % BITS_PER_LONG;
+	unsigned long flags;
+	u32 reg;
+
+	spin_lock_irqsave(&data->lock, flags);
+	reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
+	spin_unlock_irqrestore(&data->lock, flags);
+

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_controller_dev *rcdev, · line 102

Quoted 10 lines
drivers/reset/reset-socfpga.c +4 -0
+	return !(reg & BIT(offset));
+}
+
 static struct reset_control_ops socfpga_reset_ops = {
 	.assert		= socfpga_reset_assert,
 	.deassert	= socfpga_reset_deassert,
+	.status		= socfpga_reset_status,
 };
 
 static int socfpga_reset_probe(struct platform_device *pdev)

Just wondering if you had a chance to review this patch?

Thanks,
Dinh

maintainer
#2 lore raw
In reply to [email protected]

Hi Dinh,

Am Freitag, den 24.10.2014, 10:53 -0500 schrieb
[email protected]:

Quoted 21 lines

From: Dinh Nguyen <[email protected]>

Populate the reset_status callback for SOCFPGA.

---
 drivers/reset/reset-socfpga.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/reset/reset-socfpga.c +3 -0
index 79c32ca..cd37849 100644
@@ -76,9 +76,27 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
 	return 0;
 }
 
+static int socfpga_reset_status(struct reset_controller_dev *rcdev,
+				unsigned long id)
+{

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_controller_dev *rcdev, · line 91

Quoted 10 lines
drivers/reset/reset-socfpga.c +10 -0
+	struct socfpga_reset_data *data = container_of(rcdev,
+						struct socfpga_reset_data, rcdev);
+	int bank = id / BITS_PER_LONG;
+	int offset = id % BITS_PER_LONG;
+	unsigned long flags;
+	u32 reg;
+
+	spin_lock_irqsave(&data->lock, flags);
+	reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
+	spin_unlock_irqrestore(&data->lock, flags);

For the register read access, you don't need the lock.

drivers/reset/reset-socfpga.c static int socfpga_reset_deassert(struct reset_controller_dev *rcdev, · line 102

Quoted 10 lines
drivers/reset/reset-socfpga.c +4 -0
+	return !(reg & BIT(offset));
+}
+
 static struct reset_control_ops socfpga_reset_ops = {
 	.assert		= socfpga_reset_assert,
 	.deassert	= socfpga_reset_deassert,
+	.status		= socfpga_reset_status,
 };
 
 static int socfpga_reset_probe(struct platform_device *pdev)

regards
Philipp