summaryrefslogtreecommitdiff
path: root/include/linux/modem/m6718_spi/modem_driver.h
blob: f3aae4a71160da67da0494726db0cc3cf1b00b90 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
 * Copyright (C) ST-Ericsson SA 2011
 *
 * Author: Chris Blair <chris.blair@stericsson.com> for ST-Ericsson
 *   based on shrm_driver.h
 *
 * License terms: GNU General Public License (GPL) version 2
 *
 * Modem IPC driver interface header.
 */
#ifndef _MODEM_DRIVER_H_
#define _MODEM_DRIVER_H_

#include <linux/device.h>
#include <linux/modem/modem.h>
#include <linux/cdev.h>
#include <linux/spi/spi.h>


/* driver L2 mux channels */
#ifdef CONFIG_MODEM_M6718_SPI_ENABLE_FEATURE_LOOPBACK
#define MODEM_M6718_SPI_MAX_CHANNELS		(9)
#else
#define MODEM_M6718_SPI_MAX_CHANNELS		(3)
#endif

#define MODEM_M6718_SPI_CHN_ISI			(0)
/*#define MODEM_M6718_SPI_CHN_RPC		(1) not supported */
#define MODEM_M6718_SPI_CHN_AUDIO		(2)
/*#define MODEM_M6718_SPI_CHN_SECURITY		(3) not supported */
/*						(4) not supported */
#ifdef CONFIG_MODEM_M6718_SPI_ENABLE_FEATURE_LOOPBACK
#define MODEM_M6718_SPI_CHN_MASTER_LOOPBACK0	(5)
#define MODEM_M6718_SPI_CHN_SLAVE_LOOPBACK0	(6)
#define MODEM_M6718_SPI_CHN_MASTER_LOOPBACK1	(7)
#define MODEM_M6718_SPI_CHN_SLAVE_LOOPBACK1	(8)
#endif

/**
 * struct queue_element - information to add an element to queue
 * @entry:	list entry
 * @offset:	message offset
 * @size:	message size
 * @no:		total number of messages
 */
struct queue_element {
	struct list_head entry;
	u32 offset;
	u32 size;
	u32 no;
};

/**
 * struct message_queue - ISI, RPC, AUDIO, SECURITY message queue information
 * @channel:		L2 mux channel served by this queue
 * @fifo_base:		pointer to the respective fifo base
 * @size:		size of the data to be read
 * @free:		free space in the queue
 * @readptr:		fifo read pointer
 * @writeptr:		fifo write pointer
 * @no:			total number of messages
 * @update_lock:	spinlock for protecting the queue read operation
 * @q_rp:		queue read pointer is valid
 * @wq_readable:	wait queue head
 * @msg_list:		message list
 * @modem_spi_dev:	pointer to modem device information structure
 */
struct message_queue {
      u8 channel;
      u8 *fifo_base;
      u32 size;
      u32 free;
      u32 readptr;
      u32 writeptr;
      u32 no;
      spinlock_t update_lock;
      atomic_t q_rp;
      wait_queue_head_t wq_readable;
      struct list_head msg_list;
      struct modem_spi_dev *modem_spi_dev;
};

/**
 * struct isa_device_context - modem char interface device information
 * @dl_queue:	structre to store the queue related info
 * @device_id:	channel id (ISI, AUDIO, RPC, ...)
 * @addr:	device address
 */
struct isa_device_context {
	struct message_queue dl_queue;
	u8 device_id;
	void *addr;
};

/**
 * struct isa_driver_context - modem char interface driver information
 * @is_open:		flag to check the usage of queue
 * @isadev:		pointer to struct t_isadev_context
 * @common_tx_lock:	spinlock for protecting common channel
 * @audio_tx_mutex:	mutex for protecting audio channel
 * @cdev:		character device structre
 * @modem_class:	pointer to the class structure
 */
struct isa_driver_context {
	atomic_t is_open[MODEM_M6718_SPI_MAX_CHANNELS];
	struct isa_device_context *isadev;
	spinlock_t common_tx_lock;
	struct mutex audio_tx_mutex;
	struct cdev cdev;
	struct class *modem_class;
};

/**
 * struct modem_spi_dev - modem device information
 * @dev			pointer to device
 * @ndev		pointer to net_device interface
 * @modem		pointer to registered modem structure
 * @isa_context		pointer to char device interface
 * @netdev_flag_up:	flag to indicate up/down of network device
 * @msr_flag:		flag to indicate modem-silent-reset is in progress
 */
struct modem_spi_dev {
	struct device *dev;
	struct net_device *ndev;
	struct modem *modem;
	struct isa_driver_context *isa_context;
	int netdev_flag_up;
	bool msr_flag;
};

/**
 * struct modem_m6718_spi_link_gpio - gpio configuration for an IPC link
 * @ss_pin:	pins to use for slave-select
 * @ss_active:	active level for slave-select pin
 * @int_pin:	pin to use for slave-int (ready)
 * @int_active:	active level for slave-int
 */
struct modem_m6718_spi_link_gpio {
	int ss_pin;
	int ss_active;
	int int_pin;
	int int_active;
};

/**
 * struct modem_m6718_spi_link_platform_data - IPC link data
 * @id:		link id
 * @gpio:	link gpio configuration
 * @name:	link name (to appear in debugfs)
 */
struct modem_m6718_spi_link_platform_data {
	int id;
	struct modem_m6718_spi_link_gpio gpio;
#ifdef CONFIG_DEBUG_FS
	const char *name;
#endif
};

int modem_m6718_spi_receive(struct spi_device *sdev, u8 channel,
	u32 len, void *data);
int modem_m6718_spi_send(struct modem_spi_dev *modem_spi_dev, u8 channel,
	u32 len, void *data);
bool modem_m6718_spi_is_boot_done(void);

#endif /* _MODEM_DRIVER_H_ */