Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*******************************************************************************
0003  *
0004  * CTU CAN FD IP Core
0005  *
0006  * Copyright (C) 2015-2018 Ondrej Ille <ondrej.ille@gmail.com> FEE CTU
0007  * Copyright (C) 2018-2021 Ondrej Ille <ondrej.ille@gmail.com> self-funded
0008  * Copyright (C) 2018-2019 Martin Jerabek <martin.jerabek01@gmail.com> FEE CTU
0009  * Copyright (C) 2018-2021 Pavel Pisa <pisa@cmp.felk.cvut.cz> FEE CTU/self-funded
0010  *
0011  * Project advisors:
0012  *     Jiri Novak <jnovak@fel.cvut.cz>
0013  *     Pavel Pisa <pisa@cmp.felk.cvut.cz>
0014  *
0015  * Department of Measurement         (http://meas.fel.cvut.cz/)
0016  * Faculty of Electrical Engineering (http://www.fel.cvut.cz)
0017  * Czech Technical University        (http://www.cvut.cz/)
0018  ******************************************************************************/
0019 
0020 #ifndef __CTUCANFD__
0021 #define __CTUCANFD__
0022 
0023 #include <linux/netdevice.h>
0024 #include <linux/can/dev.h>
0025 #include <linux/list.h>
0026 
0027 enum ctu_can_fd_can_registers;
0028 
0029 struct ctucan_priv {
0030     struct can_priv can; /* must be first member! */
0031 
0032     void __iomem *mem_base;
0033     u32 (*read_reg)(struct ctucan_priv *priv,
0034             enum ctu_can_fd_can_registers reg);
0035     void (*write_reg)(struct ctucan_priv *priv,
0036               enum ctu_can_fd_can_registers reg, u32 val);
0037 
0038     unsigned int txb_head;
0039     unsigned int txb_tail;
0040     u32 txb_prio;
0041     unsigned int ntxbufs;
0042     spinlock_t tx_lock; /* spinlock to serialize allocation and processing of TX buffers */
0043 
0044     struct napi_struct napi;
0045     struct device *dev;
0046     struct clk *can_clk;
0047 
0048     int irq_flags;
0049     unsigned long drv_flags;
0050 
0051     u32 rxfrm_first_word;
0052 
0053     struct list_head peers_on_pdev;
0054 };
0055 
0056 /**
0057  * ctucan_probe_common - Device type independent registration call
0058  *
0059  * This function does all the memory allocation and registration for the CAN
0060  * device.
0061  *
0062  * @dev:    Handle to the generic device structure
0063  * @addr:   Base address of CTU CAN FD core address
0064  * @irq:    Interrupt number
0065  * @ntxbufs:    Number of implemented Tx buffers
0066  * @can_clk_rate: Clock rate, if 0 then clock are taken from device node
0067  * @pm_enable_call: Whether pm_runtime_enable should be called
0068  * @set_drvdata_fnc: Function to set network driver data for physical device
0069  *
0070  * Return: 0 on success and failure value on error
0071  */
0072 int ctucan_probe_common(struct device *dev, void __iomem *addr,
0073             int irq, unsigned int ntxbufs,
0074             unsigned long can_clk_rate,
0075             int pm_enable_call,
0076             void (*set_drvdata_fnc)(struct device *dev,
0077                         struct net_device *ndev));
0078 
0079 int ctucan_suspend(struct device *dev) __maybe_unused;
0080 int ctucan_resume(struct device *dev) __maybe_unused;
0081 
0082 #endif /*__CTUCANFD__*/