hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/can/rcar/rcar_can.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /* Renesas R-Car CAN device driver
23 *
34 * Copyright (C) 2013 Cogent Embedded, Inc. <source@cogentembedded.com>
45 * 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.
106 */
117
128 #include <linux/module.h>
....@@ -19,10 +15,16 @@
1915 #include <linux/can/led.h>
2016 #include <linux/can/dev.h>
2117 #include <linux/clk.h>
22
-#include <linux/can/platform/rcar_can.h>
2318 #include <linux/of.h>
2419
2520 #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
+};
2628
2729 #define RCAR_SUPPORTED_CLOCKS (BIT(CLKR_CLKP1) | BIT(CLKR_CLKP2) | \
2830 BIT(CLKR_CLKEXT))
....@@ -233,11 +235,8 @@
233235 if (eifr & (RCAR_CAN_EIFR_EWIF | RCAR_CAN_EIFR_EPIF)) {
234236 txerr = readb(&priv->regs->tecr);
235237 rxerr = readb(&priv->regs->recr);
236
- if (skb) {
238
+ if (skb)
237239 cf->can_id |= CAN_ERR_CRTL;
238
- cf->data[6] = txerr;
239
- cf->data[7] = rxerr;
240
- }
241240 }
242241 if (eifr & RCAR_CAN_EIFR_BEIF) {
243242 int rx_errors = 0, tx_errors = 0;
....@@ -337,6 +336,9 @@
337336 can_bus_off(ndev);
338337 if (skb)
339338 cf->can_id |= CAN_ERR_BUSOFF;
339
+ } else if (skb) {
340
+ cf->data[6] = txerr;
341
+ cf->data[7] = rxerr;
340342 }
341343 if (eifr & RCAR_CAN_EIFR_ORIF) {
342344 netdev_dbg(priv->ndev, "Receive overrun error interrupt\n");
....@@ -740,36 +742,23 @@
740742
741743 static int rcar_can_probe(struct platform_device *pdev)
742744 {
743
- struct rcar_can_platform_data *pdata;
744745 struct rcar_can_priv *priv;
745746 struct net_device *ndev;
746
- struct resource *mem;
747747 void __iomem *addr;
748748 u32 clock_select = CLKR_CLKP1;
749749 int err = -ENODEV;
750750 int irq;
751751
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);
763754
764755 irq = platform_get_irq(pdev, 0);
765756 if (irq < 0) {
766
- dev_err(&pdev->dev, "No IRQ resource\n");
767757 err = irq;
768758 goto fail;
769759 }
770760
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);
773762 if (IS_ERR(addr)) {
774763 err = PTR_ERR(addr);
775764 goto fail;