|
28 | 28 | #define FREEZE_CSR_REG_VERSION 12
|
29 | 29 |
|
30 | 30 | #define FREEZE_CSR_SUPPORTED_VERSION 2
|
| 31 | +#define FREEZE_CSR_OFFICIAL_VERSION 0xad000003 |
31 | 32 |
|
32 | 33 | #define FREEZE_CSR_STATUS_FREEZE_REQ_DONE BIT(0)
|
33 | 34 | #define FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE BIT(1)
|
@@ -218,33 +219,40 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
|
218 | 219 | {
|
219 | 220 | struct device *dev = &pdev->dev;
|
220 | 221 | struct device_node *np = pdev->dev.of_node;
|
| 222 | + void __iomem *base_addr; |
221 | 223 | struct altera_freeze_br_data *priv;
|
222 | 224 | struct resource *res;
|
223 | 225 | u32 status, revision;
|
224 | 226 |
|
225 | 227 | if (!np)
|
226 | 228 | return -ENODEV;
|
227 | 229 |
|
| 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 | + |
228 | 245 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
229 | 246 | if (!priv)
|
230 | 247 | return -ENOMEM;
|
231 | 248 |
|
232 | 249 | priv->dev = dev;
|
233 | 250 |
|
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); |
240 | 252 | if (status & FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE)
|
241 | 253 | priv->enable = 1;
|
242 | 254 |
|
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; |
248 | 256 |
|
249 | 257 | return fpga_bridge_register(dev, FREEZE_BRIDGE_NAME,
|
250 | 258 | &altera_freeze_br_br_ops, priv);
|
|
0 commit comments