ctucanfd.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*******************************************************************************
  3. *
  4. * CTU CAN FD IP Core
  5. *
  6. * Copyright (C) 2015-2018 Ondrej Ille <[email protected]> FEE CTU
  7. * Copyright (C) 2018-2021 Ondrej Ille <[email protected]> self-funded
  8. * Copyright (C) 2018-2019 Martin Jerabek <[email protected]> FEE CTU
  9. * Copyright (C) 2018-2021 Pavel Pisa <[email protected]> FEE CTU/self-funded
  10. *
  11. * Project advisors:
  12. * Jiri Novak <[email protected]>
  13. * Pavel Pisa <[email protected]>
  14. *
  15. * Department of Measurement (http://meas.fel.cvut.cz/)
  16. * Faculty of Electrical Engineering (http://www.fel.cvut.cz)
  17. * Czech Technical University (http://www.cvut.cz/)
  18. ******************************************************************************/
  19. #ifndef __CTUCANFD__
  20. #define __CTUCANFD__
  21. #include <linux/netdevice.h>
  22. #include <linux/can/dev.h>
  23. #include <linux/list.h>
  24. enum ctu_can_fd_can_registers;
  25. struct ctucan_priv {
  26. struct can_priv can; /* must be first member! */
  27. void __iomem *mem_base;
  28. u32 (*read_reg)(struct ctucan_priv *priv,
  29. enum ctu_can_fd_can_registers reg);
  30. void (*write_reg)(struct ctucan_priv *priv,
  31. enum ctu_can_fd_can_registers reg, u32 val);
  32. unsigned int txb_head;
  33. unsigned int txb_tail;
  34. u32 txb_prio;
  35. unsigned int ntxbufs;
  36. spinlock_t tx_lock; /* spinlock to serialize allocation and processing of TX buffers */
  37. struct napi_struct napi;
  38. struct device *dev;
  39. struct clk *can_clk;
  40. int irq_flags;
  41. unsigned long drv_flags;
  42. u32 rxfrm_first_word;
  43. struct list_head peers_on_pdev;
  44. };
  45. /**
  46. * ctucan_probe_common - Device type independent registration call
  47. *
  48. * This function does all the memory allocation and registration for the CAN
  49. * device.
  50. *
  51. * @dev: Handle to the generic device structure
  52. * @addr: Base address of CTU CAN FD core address
  53. * @irq: Interrupt number
  54. * @ntxbufs: Number of implemented Tx buffers
  55. * @can_clk_rate: Clock rate, if 0 then clock are taken from device node
  56. * @pm_enable_call: Whether pm_runtime_enable should be called
  57. * @set_drvdata_fnc: Function to set network driver data for physical device
  58. *
  59. * Return: 0 on success and failure value on error
  60. */
  61. int ctucan_probe_common(struct device *dev, void __iomem *addr,
  62. int irq, unsigned int ntxbufs,
  63. unsigned long can_clk_rate,
  64. int pm_enable_call,
  65. void (*set_drvdata_fnc)(struct device *dev,
  66. struct net_device *ndev));
  67. int ctucan_suspend(struct device *dev) __maybe_unused;
  68. int ctucan_resume(struct device *dev) __maybe_unused;
  69. #endif /*__CTUCANFD__*/