linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] fpga fr br: update supported version numbers
@ 2017-04-07 19:26 matthew.gerlach
  2017-04-08  0:52 ` Moritz Fischer
  0 siblings, 1 reply; 2+ messages in thread
From: matthew.gerlach @ 2017-04-07 19:26 UTC (permalink / raw)
  To: atull, moritz.fischer, linux-fpga, linux-kernel; +Cc: Matthew Gerlach

From: Matthew Gerlach <matthew.gerlach@linux.intel.com>

The value in the version register of the altera freeze bridge
controller changed from the beta value of 2 to the
value of 0xad000003 in the official release of the IP.
This patch supports the old and new version numbers, and the
driver's probe function will fail if neither of the supported
versions is found.

Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
---
v2: change warning to fail as per Moritz Fischer <mdf@kernel.org>
---
 drivers/fpga/altera-freeze-bridge.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/fpga/altera-freeze-bridge.c b/drivers/fpga/altera-freeze-bridge.c
index 8dcd9fb..114d3cb 100644
--- a/drivers/fpga/altera-freeze-bridge.c
+++ b/drivers/fpga/altera-freeze-bridge.c
@@ -28,6 +28,7 @@
 #define FREEZE_CSR_REG_VERSION			12
 
 #define FREEZE_CSR_SUPPORTED_VERSION		2
+#define FREEZE_CSR_OFFICIAL_VERSION		0xad000003
 
 #define FREEZE_CSR_STATUS_FREEZE_REQ_DONE	BIT(0)
 #define FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE	BIT(1)
@@ -218,6 +219,7 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = pdev->dev.of_node;
+	void __iomem *base_addr;
 	struct altera_freeze_br_data *priv;
 	struct resource *res;
 	u32 status, revision;
@@ -225,26 +227,32 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 	if (!np)
 		return -ENODEV;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base_addr = devm_ioremap_resource(dev, res);
+	if (IS_ERR(base_addr))
+		return PTR_ERR(base_addr);
+
+	revision = readl(base_addr + FREEZE_CSR_REG_VERSION);
+	if ((revision != FREEZE_CSR_SUPPORTED_VERSION) &&
+	    (revision != FREEZE_CSR_OFFICIAL_VERSION)) {
+		dev_err(dev,
+			"%s unexpected revision 0x%x != 0x%x != 0x%x\n",
+			__func__, revision, FREEZE_CSR_SUPPORTED_VERSION,
+			FREEZE_CSR_OFFICIAL_VERSION);
+		return -EINVAL;
+	}
+
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
 	priv->dev = dev;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->base_addr = devm_ioremap_resource(dev, res);
-	if (IS_ERR(priv->base_addr))
-		return PTR_ERR(priv->base_addr);
-
-	status = readl(priv->base_addr + FREEZE_CSR_STATUS_OFFSET);
+	status = readl(base_addr + FREEZE_CSR_STATUS_OFFSET);
 	if (status & FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE)
 		priv->enable = 1;
 
-	revision = readl(priv->base_addr + FREEZE_CSR_REG_VERSION);
-	if (revision != FREEZE_CSR_SUPPORTED_VERSION)
-		dev_warn(dev,
-			 "%s Freeze Controller unexpected revision %d != %d\n",
-			 __func__, revision, FREEZE_CSR_SUPPORTED_VERSION);
+	priv->base_addr = base_addr;
 
 	return fpga_bridge_register(dev, FREEZE_BRIDGE_NAME,
 				    &altera_freeze_br_br_ops, priv);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] fpga fr br: update supported version numbers
  2017-04-07 19:26 [PATCH v2] fpga fr br: update supported version numbers matthew.gerlach
@ 2017-04-08  0:52 ` Moritz Fischer
  0 siblings, 0 replies; 2+ messages in thread
From: Moritz Fischer @ 2017-04-08  0:52 UTC (permalink / raw)
  To: matthew.gerlach; +Cc: atull, linux-fpga, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3245 bytes --]

On Fri, Apr 07, 2017 at 12:26:36PM -0700, matthew.gerlach@linux.intel.com wrote:
> From: Matthew Gerlach <matthew.gerlach@linux.intel.com>
> 
> The value in the version register of the altera freeze bridge
> controller changed from the beta value of 2 to the
> value of 0xad000003 in the official release of the IP.
> This patch supports the old and new version numbers, and the
> driver's probe function will fail if neither of the supported
> versions is found.
> 
> Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Reviewed-by: Moritz Fischer <mdf@kernel.org>
> ---
> v2: change warning to fail as per Moritz Fischer <mdf@kernel.org>
> ---
>  drivers/fpga/altera-freeze-bridge.c | 30 +++++++++++++++++++-----------
>  1 file changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/fpga/altera-freeze-bridge.c b/drivers/fpga/altera-freeze-bridge.c
> index 8dcd9fb..114d3cb 100644
> --- a/drivers/fpga/altera-freeze-bridge.c
> +++ b/drivers/fpga/altera-freeze-bridge.c
> @@ -28,6 +28,7 @@
>  #define FREEZE_CSR_REG_VERSION			12
>  
>  #define FREEZE_CSR_SUPPORTED_VERSION		2
> +#define FREEZE_CSR_OFFICIAL_VERSION		0xad000003
>  
>  #define FREEZE_CSR_STATUS_FREEZE_REQ_DONE	BIT(0)
>  #define FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE	BIT(1)
> @@ -218,6 +219,7 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct device_node *np = pdev->dev.of_node;
> +	void __iomem *base_addr;
>  	struct altera_freeze_br_data *priv;
>  	struct resource *res;
>  	u32 status, revision;
> @@ -225,26 +227,32 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
>  	if (!np)
>  		return -ENODEV;
>  
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	base_addr = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(base_addr))
> +		return PTR_ERR(base_addr);
> +
> +	revision = readl(base_addr + FREEZE_CSR_REG_VERSION);
> +	if ((revision != FREEZE_CSR_SUPPORTED_VERSION) &&
> +	    (revision != FREEZE_CSR_OFFICIAL_VERSION)) {
> +		dev_err(dev,
> +			"%s unexpected revision 0x%x != 0x%x != 0x%x\n",
> +			__func__, revision, FREEZE_CSR_SUPPORTED_VERSION,
> +			FREEZE_CSR_OFFICIAL_VERSION);
> +		return -EINVAL;
> +	}
> +
>  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
>  		return -ENOMEM;
>  
>  	priv->dev = dev;
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	priv->base_addr = devm_ioremap_resource(dev, res);
> -	if (IS_ERR(priv->base_addr))
> -		return PTR_ERR(priv->base_addr);
> -
> -	status = readl(priv->base_addr + FREEZE_CSR_STATUS_OFFSET);
> +	status = readl(base_addr + FREEZE_CSR_STATUS_OFFSET);
>  	if (status & FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE)
>  		priv->enable = 1;
>  
> -	revision = readl(priv->base_addr + FREEZE_CSR_REG_VERSION);
> -	if (revision != FREEZE_CSR_SUPPORTED_VERSION)
> -		dev_warn(dev,
> -			 "%s Freeze Controller unexpected revision %d != %d\n",
> -			 __func__, revision, FREEZE_CSR_SUPPORTED_VERSION);
> +	priv->base_addr = base_addr;
>  
>  	return fpga_bridge_register(dev, FREEZE_BRIDGE_NAME,
>  				    &altera_freeze_br_br_ops, priv);
> -- 
> 2.7.4
> 

Thanks,
Moritz

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-08  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-07 19:26 [PATCH v2] fpga fr br: update supported version numbers matthew.gerlach
2017-04-08  0:52 ` Moritz Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).