Commit 591d65d5 authored by Marek Vasut's avatar Marek Vasut Committed by Marc Kleine-Budde

can: ifi: Check core revision upon probe

Older versions of the core are not compatible with the driver due
to various intrusive fixes of the core. Read out the VER register,
check the core revision bitfield and verify if the core in use is
new enough (rev 2.1 or newer) to work correctly with this driver.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Markus Marb <markus@marb.org>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent b7db978a
...@@ -136,6 +136,8 @@ ...@@ -136,6 +136,8 @@
#define IFI_CANFD_SYSCLOCK 0x50 #define IFI_CANFD_SYSCLOCK 0x50
#define IFI_CANFD_VER 0x54 #define IFI_CANFD_VER 0x54
#define IFI_CANFD_VER_REV_MASK 0xff
#define IFI_CANFD_VER_REV_MIN_SUPPORTED 0x15
#define IFI_CANFD_IP_ID 0x58 #define IFI_CANFD_IP_ID 0x58
#define IFI_CANFD_IP_ID_VALUE 0xD073CAFD #define IFI_CANFD_IP_ID_VALUE 0xD073CAFD
...@@ -933,7 +935,7 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev) ...@@ -933,7 +935,7 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
void __iomem *addr; void __iomem *addr;
int irq, ret; int irq, ret;
u32 id; u32 id, rev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
addr = devm_ioremap_resource(dev, res); addr = devm_ioremap_resource(dev, res);
...@@ -947,6 +949,13 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev) ...@@ -947,6 +949,13 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
rev = readl(addr + IFI_CANFD_VER) & IFI_CANFD_VER_REV_MASK;
if (rev < IFI_CANFD_VER_REV_MIN_SUPPORTED) {
dev_err(dev, "This block is too old (rev %i), minimum supported is rev %i\n",
rev, IFI_CANFD_VER_REV_MIN_SUPPORTED);
return -EINVAL;
}
ndev = alloc_candev(sizeof(*priv), 1); ndev = alloc_candev(sizeof(*priv), 1);
if (!ndev) if (!ndev)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment