.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
---|
1 | 2 | /* Renesas R-Car CAN device driver |
---|
2 | 3 | * |
---|
3 | 4 | * Copyright (C) 2013 Cogent Embedded, Inc. <source@cogentembedded.com> |
---|
4 | 5 | * Copyright (C) 2013 Renesas Solutions Corp. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms of the GNU General Public License as published by the |
---|
8 | | - * Free Software Foundation; either version 2 of the License, or (at your |
---|
9 | | - * option) any later version. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/module.h> |
---|
.. | .. |
---|
19 | 15 | #include <linux/can/led.h> |
---|
20 | 16 | #include <linux/can/dev.h> |
---|
21 | 17 | #include <linux/clk.h> |
---|
22 | | -#include <linux/can/platform/rcar_can.h> |
---|
23 | 18 | #include <linux/of.h> |
---|
24 | 19 | |
---|
25 | 20 | #define RCAR_CAN_DRV_NAME "rcar_can" |
---|
| 21 | + |
---|
| 22 | +/* Clock Select Register settings */ |
---|
| 23 | +enum CLKR { |
---|
| 24 | + CLKR_CLKP1 = 0, /* Peripheral clock (clkp1) */ |
---|
| 25 | + CLKR_CLKP2 = 1, /* Peripheral clock (clkp2) */ |
---|
| 26 | + CLKR_CLKEXT = 3, /* Externally input clock */ |
---|
| 27 | +}; |
---|
26 | 28 | |
---|
27 | 29 | #define RCAR_SUPPORTED_CLOCKS (BIT(CLKR_CLKP1) | BIT(CLKR_CLKP2) | \ |
---|
28 | 30 | BIT(CLKR_CLKEXT)) |
---|
.. | .. |
---|
233 | 235 | if (eifr & (RCAR_CAN_EIFR_EWIF | RCAR_CAN_EIFR_EPIF)) { |
---|
234 | 236 | txerr = readb(&priv->regs->tecr); |
---|
235 | 237 | rxerr = readb(&priv->regs->recr); |
---|
236 | | - if (skb) { |
---|
| 238 | + if (skb) |
---|
237 | 239 | cf->can_id |= CAN_ERR_CRTL; |
---|
238 | | - cf->data[6] = txerr; |
---|
239 | | - cf->data[7] = rxerr; |
---|
240 | | - } |
---|
241 | 240 | } |
---|
242 | 241 | if (eifr & RCAR_CAN_EIFR_BEIF) { |
---|
243 | 242 | int rx_errors = 0, tx_errors = 0; |
---|
.. | .. |
---|
337 | 336 | can_bus_off(ndev); |
---|
338 | 337 | if (skb) |
---|
339 | 338 | cf->can_id |= CAN_ERR_BUSOFF; |
---|
| 339 | + } else if (skb) { |
---|
| 340 | + cf->data[6] = txerr; |
---|
| 341 | + cf->data[7] = rxerr; |
---|
340 | 342 | } |
---|
341 | 343 | if (eifr & RCAR_CAN_EIFR_ORIF) { |
---|
342 | 344 | netdev_dbg(priv->ndev, "Receive overrun error interrupt\n"); |
---|
.. | .. |
---|
740 | 742 | |
---|
741 | 743 | static int rcar_can_probe(struct platform_device *pdev) |
---|
742 | 744 | { |
---|
743 | | - struct rcar_can_platform_data *pdata; |
---|
744 | 745 | struct rcar_can_priv *priv; |
---|
745 | 746 | struct net_device *ndev; |
---|
746 | | - struct resource *mem; |
---|
747 | 747 | void __iomem *addr; |
---|
748 | 748 | u32 clock_select = CLKR_CLKP1; |
---|
749 | 749 | int err = -ENODEV; |
---|
750 | 750 | int irq; |
---|
751 | 751 | |
---|
752 | | - if (pdev->dev.of_node) { |
---|
753 | | - of_property_read_u32(pdev->dev.of_node, |
---|
754 | | - "renesas,can-clock-select", &clock_select); |
---|
755 | | - } else { |
---|
756 | | - pdata = dev_get_platdata(&pdev->dev); |
---|
757 | | - if (!pdata) { |
---|
758 | | - dev_err(&pdev->dev, "No platform data provided!\n"); |
---|
759 | | - goto fail; |
---|
760 | | - } |
---|
761 | | - clock_select = pdata->clock_select; |
---|
762 | | - } |
---|
| 752 | + of_property_read_u32(pdev->dev.of_node, "renesas,can-clock-select", |
---|
| 753 | + &clock_select); |
---|
763 | 754 | |
---|
764 | 755 | irq = platform_get_irq(pdev, 0); |
---|
765 | 756 | if (irq < 0) { |
---|
766 | | - dev_err(&pdev->dev, "No IRQ resource\n"); |
---|
767 | 757 | err = irq; |
---|
768 | 758 | goto fail; |
---|
769 | 759 | } |
---|
770 | 760 | |
---|
771 | | - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
772 | | - addr = devm_ioremap_resource(&pdev->dev, mem); |
---|
| 761 | + addr = devm_platform_ioremap_resource(pdev, 0); |
---|
773 | 762 | if (IS_ERR(addr)) { |
---|
774 | 763 | err = PTR_ERR(addr); |
---|
775 | 764 | goto fail; |
---|