xref: /openbmc/linux/drivers/net/can/m_can/tcan4x5x.h (revision 79f382b9)
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * tcan4x5x - Texas Instruments TCAN4x5x Family CAN controller driver
4  *
5  * Copyright (c) 2020 Pengutronix,
6  *                    Marc Kleine-Budde <kernel@pengutronix.de>
7  */
8 
9 #ifndef _TCAN4X5X_H
10 #define _TCAN4X5X_H
11 
12 #include <linux/gpio/consumer.h>
13 #include <linux/regmap.h>
14 #include <linux/regmap.h>
15 #include <linux/regulator/consumer.h>
16 #include <linux/spi/spi.h>
17 
18 #include "m_can.h"
19 
20 #define TCAN4X5X_SANITIZE_SPI 1
21 
22 struct __packed tcan4x5x_buf_cmd {
23 	u8 cmd;
24 	__be16 addr;
25 	u8 len;
26 };
27 
28 struct tcan4x5x_map_buf {
29 	struct tcan4x5x_buf_cmd cmd;
30 	u8 data[256 * sizeof(u32)];
31 } ____cacheline_aligned;
32 
33 struct tcan4x5x_priv {
34 	struct m_can_classdev cdev;
35 
36 	struct regmap *regmap;
37 	struct spi_device *spi;
38 
39 	struct gpio_desc *reset_gpio;
40 	struct gpio_desc *device_wake_gpio;
41 	struct gpio_desc *device_state_gpio;
42 	struct regulator *power;
43 
44 	struct tcan4x5x_map_buf map_buf_rx;
45 	struct tcan4x5x_map_buf map_buf_tx;
46 };
47 
48 static inline void
49 tcan4x5x_spi_cmd_set_len(struct tcan4x5x_buf_cmd *cmd, u8 len)
50 {
51 	/* number of u32 */
52 	cmd->len = len >> 2;
53 }
54 
55 int tcan4x5x_regmap_init(struct tcan4x5x_priv *priv);
56 
57 #endif
58