22 #include <linux/kernel.h>
23 #include <linux/module.h>
26 #include <linux/netdevice.h>
27 #include <linux/if_arp.h>
28 #include <linux/if_ether.h>
29 #include <linux/list.h>
53 static void c_can_plat_write_reg_aligned_to_16bit(
struct c_can_priv *
priv,
65 static void c_can_plat_write_reg_aligned_to_32bit(
struct c_can_priv *
priv,
73 .name = KBUILD_MODNAME,
88 { .compatible =
"bosch,c_can", .data = &c_can_id_table[
BOSCH_C_CAN] },
89 { .compatible =
"bosch,d_can", .data = &c_can_id_table[
BOSCH_D_CAN] },
106 if (pdev->
dev.of_node) {
109 dev_err(&pdev->
dev,
"Failed to find matching dt id\n");
118 pinctrl = devm_pinctrl_get_select_default(&pdev->
dev);
121 "failed to configure pins from driver\n");
134 if (!mem || irq <= 0) {
141 dev_err(&pdev->
dev,
"resource unavailable\n");
148 dev_err(&pdev->
dev,
"failed to map can port\n");
150 goto exit_release_mem;
160 priv = netdev_priv(dev);
161 switch (id->driver_data) {
163 priv->
regs = reg_map_c_can;
166 priv->
read_reg = c_can_plat_read_reg_aligned_to_32bit;
167 priv->
write_reg = c_can_plat_write_reg_aligned_to_32bit;
171 priv->
read_reg = c_can_plat_read_reg_aligned_to_16bit;
172 priv->
write_reg = c_can_plat_write_reg_aligned_to_16bit;
177 priv->
regs = reg_map_d_can;
179 priv->
read_reg = c_can_plat_read_reg_aligned_to_16bit;
180 priv->
write_reg = c_can_plat_write_reg_aligned_to_16bit;
184 goto exit_free_device;
192 priv->
type =
id->driver_data;
194 platform_set_drvdata(pdev, dev);
199 dev_err(&pdev->
dev,
"registering %s failed (err=%d)\n",
200 KBUILD_MODNAME, ret);
201 goto exit_free_device;
204 dev_info(&pdev->
dev,
"%s device registered (regs=%p, irq=%d)\n",
205 KBUILD_MODNAME, priv->
base, dev->
irq);
209 platform_set_drvdata(pdev,
NULL);
225 struct net_device *dev = platform_get_drvdata(pdev);
230 platform_set_drvdata(pdev,
NULL);
255 if (netif_running(ndev)) {
256 netif_stop_queue(ndev);
260 ret = c_can_power_down(ndev);
262 netdev_err(ndev,
"failed to enter power down mode\n");
274 struct net_device *ndev = platform_get_drvdata(pdev);
282 ret = c_can_power_up(ndev);
284 netdev_err(ndev,
"Still in power down mode\n");
290 if (netif_running(ndev)) {
292 netif_start_queue(ndev);
298 #define c_can_suspend NULL
299 #define c_can_resume NULL
304 .name = KBUILD_MODNAME,
308 .probe = c_can_plat_probe,
312 .id_table = c_can_id_table,