File: tcan4x5x.h

package info (click to toggle)
linux 6.16.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,724,576 kB
  • sloc: ansic: 26,558,545; asm: 271,315; sh: 143,998; python: 72,469; makefile: 57,126; perl: 36,821; xml: 19,553; cpp: 5,820; yacc: 4,915; lex: 2,955; awk: 1,667; sed: 28; ruby: 25
file content (58 lines) | stat: -rw-r--r-- 1,149 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: GPL-2.0
 *
 * tcan4x5x - Texas Instruments TCAN4x5x Family CAN controller driver
 *
 * Copyright (c) 2020 Pengutronix,
 *                    Marc Kleine-Budde <kernel@pengutronix.de>
 */

#ifndef _TCAN4X5X_H
#define _TCAN4X5X_H

#include <linux/gpio/consumer.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>

#include "m_can.h"

#define TCAN4X5X_SANITIZE_SPI 1

struct __packed tcan4x5x_buf_cmd {
	u8 cmd;
	__be16 addr;
	u8 len;
};

struct tcan4x5x_map_buf {
	struct tcan4x5x_buf_cmd cmd;
	u8 data[256 * sizeof(u32)];
} ____cacheline_aligned;

struct tcan4x5x_priv {
	struct m_can_classdev cdev;

	struct regmap *regmap;
	struct spi_device *spi;

	struct gpio_desc *reset_gpio;
	struct gpio_desc *device_wake_gpio;
	struct gpio_desc *device_state_gpio;
	struct regulator *power;

	struct tcan4x5x_map_buf map_buf_rx;
	struct tcan4x5x_map_buf map_buf_tx;

	bool nwkrq_voltage_vio;
};

static inline void
tcan4x5x_spi_cmd_set_len(struct tcan4x5x_buf_cmd *cmd, u8 len)
{
	/* number of u32 */
	cmd->len = len >> 2;
}

int tcan4x5x_regmap_init(struct tcan4x5x_priv *priv);

#endif