tcan4x5x.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef _TCAN4X5X_H
  9. #define _TCAN4X5X_H
  10. #include <linux/gpio/consumer.h>
  11. #include <linux/regmap.h>
  12. #include <linux/regulator/consumer.h>
  13. #include <linux/spi/spi.h>
  14. #include "m_can.h"
  15. #define TCAN4X5X_SANITIZE_SPI 1
  16. struct __packed tcan4x5x_buf_cmd {
  17. u8 cmd;
  18. __be16 addr;
  19. u8 len;
  20. };
  21. struct tcan4x5x_map_buf {
  22. struct tcan4x5x_buf_cmd cmd;
  23. u8 data[256 * sizeof(u32)];
  24. } ____cacheline_aligned;
  25. struct tcan4x5x_priv {
  26. struct m_can_classdev cdev;
  27. struct regmap *regmap;
  28. struct spi_device *spi;
  29. struct gpio_desc *reset_gpio;
  30. struct gpio_desc *device_wake_gpio;
  31. struct gpio_desc *device_state_gpio;
  32. struct regulator *power;
  33. struct tcan4x5x_map_buf map_buf_rx;
  34. struct tcan4x5x_map_buf map_buf_tx;
  35. };
  36. static inline void
  37. tcan4x5x_spi_cmd_set_len(struct tcan4x5x_buf_cmd *cmd, u8 len)
  38. {
  39. /* number of u32 */
  40. cmd->len = len >> 2;
  41. }
  42. int tcan4x5x_regmap_init(struct tcan4x5x_priv *priv);
  43. #endif