| 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 <[email protected]> |
| 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/regulator/consumer.h> |
| 15 |
#include <linux/spi/spi.h> |
| 16 |
|
| 17 |
#include "m_can.h" |
| 18 |
|
| 19 |
#define TCAN4X5X_SANITIZE_SPI 1 |
| 20 |
|
| 21 |
struct __packed tcan4x5x_buf_cmd { |
| 22 |
u8 cmd; |
| 23 |
__be16 addr; |
| 24 |
u8 len; |
| 25 |
}; |
| 26 |
|
| 27 |
struct tcan4x5x_map_buf { |
| 28 |
struct tcan4x5x_buf_cmd cmd; |
| 29 |
u8 data[256 * sizeof(u32)]; |
| 30 |
} ____cacheline_aligned; |
| 31 |
|
| 32 |
struct tcan4x5x_priv { |
| 33 |
struct m_can_classdev cdev; |
| 34 |
|
| 35 |
struct regmap *regmap; |
| 36 |
struct spi_device *spi; |
| 37 |
|
| 38 |
struct gpio_desc *reset_gpio; |
| 39 |
struct gpio_desc *device_wake_gpio; |
| 40 |
struct gpio_desc *device_state_gpio; |
| 41 |
struct regulator *power; |
| 42 |
|
| 43 |
struct tcan4x5x_map_buf map_buf_rx; |
| 44 |
struct tcan4x5x_map_buf map_buf_tx; |
| 45 |
|
| 46 |
bool nwkrq_voltage_vio; |
| 47 |
}; |
| 48 |
|
| 49 |
static inline void |
| 50 |
tcan4x5x_spi_cmd_set_len(struct tcan4x5x_buf_cmd *cmd, u8 len) |
| 51 |
{ |
| 52 |
/* number of u32 */ |
| 53 |
cmd->len = len >> 2; |
| 54 |
} |
| 55 |
|
| 56 |
int tcan4x5x_regmap_init(struct tcan4x5x_priv *priv); |
| 57 |
|
| 58 |
#endif |