Skip to content

Commit dd17cc7

Browse files
matthew-gerlachgregkh
authored andcommitted
fpga fr br: update supported version numbers
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 <[email protected]> Reviewed-by: Moritz Fischer <[email protected]> Signed-off-by: Alan Tull <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e73bbf6 commit dd17cc7

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

drivers/fpga/altera-freeze-bridge.c

+19-11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define FREEZE_CSR_REG_VERSION 12
2929

3030
#define FREEZE_CSR_SUPPORTED_VERSION 2
31+
#define FREEZE_CSR_OFFICIAL_VERSION 0xad000003
3132

3233
#define FREEZE_CSR_STATUS_FREEZE_REQ_DONE BIT(0)
3334
#define FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE BIT(1)
@@ -218,33 +219,40 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
218219
{
219220
struct device *dev = &pdev->dev;
220221
struct device_node *np = pdev->dev.of_node;
222+
void __iomem *base_addr;
221223
struct altera_freeze_br_data *priv;
222224
struct resource *res;
223225
u32 status, revision;
224226

225227
if (!np)
226228
return -ENODEV;
227229

230+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
231+
base_addr = devm_ioremap_resource(dev, res);
232+
if (IS_ERR(base_addr))
233+
return PTR_ERR(base_addr);
234+
235+
revision = readl(base_addr + FREEZE_CSR_REG_VERSION);
236+
if ((revision != FREEZE_CSR_SUPPORTED_VERSION) &&
237+
(revision != FREEZE_CSR_OFFICIAL_VERSION)) {
238+
dev_err(dev,
239+
"%s unexpected revision 0x%x != 0x%x != 0x%x\n",
240+
__func__, revision, FREEZE_CSR_SUPPORTED_VERSION,
241+
FREEZE_CSR_OFFICIAL_VERSION);
242+
return -EINVAL;
243+
}
244+
228245
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
229246
if (!priv)
230247
return -ENOMEM;
231248

232249
priv->dev = dev;
233250

234-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
235-
priv->base_addr = devm_ioremap_resource(dev, res);
236-
if (IS_ERR(priv->base_addr))
237-
return PTR_ERR(priv->base_addr);
238-
239-
status = readl(priv->base_addr + FREEZE_CSR_STATUS_OFFSET);
251+
status = readl(base_addr + FREEZE_CSR_STATUS_OFFSET);
240252
if (status & FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE)
241253
priv->enable = 1;
242254

243-
revision = readl(priv->base_addr + FREEZE_CSR_REG_VERSION);
244-
if (revision != FREEZE_CSR_SUPPORTED_VERSION)
245-
dev_warn(dev,
246-
"%s Freeze Controller unexpected revision %d != %d\n",
247-
__func__, revision, FREEZE_CSR_SUPPORTED_VERSION);
255+
priv->base_addr = base_addr;
248256

249257
return fpga_bridge_register(dev, FREEZE_BRIDGE_NAME,
250258
&altera_freeze_br_br_ops, priv);

0 commit comments

Comments
 (0)