Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0
0002  *
0003  * tcan4x5x - Texas Instruments TCAN4x5x Family CAN controller driver
0004  *
0005  * Copyright (c) 2020 Pengutronix,
0006  *                    Marc Kleine-Budde <kernel@pengutronix.de>
0007  */
0008 
0009 #ifndef _TCAN4X5X_H
0010 #define _TCAN4X5X_H
0011 
0012 #include <linux/gpio/consumer.h>
0013 #include <linux/regmap.h>
0014 #include <linux/regulator/consumer.h>
0015 #include <linux/spi/spi.h>
0016 
0017 #include "m_can.h"
0018 
0019 #define TCAN4X5X_SANITIZE_SPI 1
0020 
0021 struct __packed tcan4x5x_buf_cmd {
0022     u8 cmd;
0023     __be16 addr;
0024     u8 len;
0025 };
0026 
0027 struct tcan4x5x_map_buf {
0028     struct tcan4x5x_buf_cmd cmd;
0029     u8 data[256 * sizeof(u32)];
0030 } ____cacheline_aligned;
0031 
0032 struct tcan4x5x_priv {
0033     struct m_can_classdev cdev;
0034 
0035     struct regmap *regmap;
0036     struct spi_device *spi;
0037 
0038     struct gpio_desc *reset_gpio;
0039     struct gpio_desc *device_wake_gpio;
0040     struct gpio_desc *device_state_gpio;
0041     struct regulator *power;
0042 
0043     struct tcan4x5x_map_buf map_buf_rx;
0044     struct tcan4x5x_map_buf map_buf_tx;
0045 };
0046 
0047 static inline void
0048 tcan4x5x_spi_cmd_set_len(struct tcan4x5x_buf_cmd *cmd, u8 len)
0049 {
0050     /* number of u32 */
0051     cmd->len = len >> 2;
0052 }
0053 
0054 int tcan4x5x_regmap_init(struct tcan4x5x_priv *priv);
0055 
0056 #endif