162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci * 362306a36Sopenharmony_ci * tcan4x5x - Texas Instruments TCAN4x5x Family CAN controller driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2020 Pengutronix, 662306a36Sopenharmony_ci * Marc Kleine-Budde <kernel@pengutronix.de> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef _TCAN4X5X_H 1062306a36Sopenharmony_ci#define _TCAN4X5X_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/gpio/consumer.h> 1362306a36Sopenharmony_ci#include <linux/regmap.h> 1462306a36Sopenharmony_ci#include <linux/regulator/consumer.h> 1562306a36Sopenharmony_ci#include <linux/spi/spi.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#include "m_can.h" 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define TCAN4X5X_SANITIZE_SPI 1 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_cistruct __packed tcan4x5x_buf_cmd { 2262306a36Sopenharmony_ci u8 cmd; 2362306a36Sopenharmony_ci __be16 addr; 2462306a36Sopenharmony_ci u8 len; 2562306a36Sopenharmony_ci}; 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_cistruct tcan4x5x_map_buf { 2862306a36Sopenharmony_ci struct tcan4x5x_buf_cmd cmd; 2962306a36Sopenharmony_ci u8 data[256 * sizeof(u32)]; 3062306a36Sopenharmony_ci} ____cacheline_aligned; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cistruct tcan4x5x_priv { 3362306a36Sopenharmony_ci struct m_can_classdev cdev; 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci struct regmap *regmap; 3662306a36Sopenharmony_ci struct spi_device *spi; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci struct gpio_desc *reset_gpio; 3962306a36Sopenharmony_ci struct gpio_desc *device_wake_gpio; 4062306a36Sopenharmony_ci struct gpio_desc *device_state_gpio; 4162306a36Sopenharmony_ci struct regulator *power; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci struct tcan4x5x_map_buf map_buf_rx; 4462306a36Sopenharmony_ci struct tcan4x5x_map_buf map_buf_tx; 4562306a36Sopenharmony_ci}; 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_cistatic inline void 4862306a36Sopenharmony_citcan4x5x_spi_cmd_set_len(struct tcan4x5x_buf_cmd *cmd, u8 len) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci /* number of u32 */ 5162306a36Sopenharmony_ci cmd->len = len >> 2; 5262306a36Sopenharmony_ci} 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ciint tcan4x5x_regmap_init(struct tcan4x5x_priv *priv); 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#endif 57