diff options
author | Chris Blair <chris.blair@stericsson.com> | 2011-11-07 14:34:38 +0000 |
---|---|---|
committer | Philippe Langlais <philippe.langlais@stericsson.com> | 2012-05-22 11:07:19 +0200 |
commit | 205a30eb9c473d8fdf2c4a3d484d2ab70ebd3790 (patch) | |
tree | 177a74c6eeacb13f35c409260b9c901ff04d87ef /include | |
parent | 64b767f38d9f08d78444b2d5c8cf47198aab132a (diff) |
modem: Add M6718 modem SPI IPC driver framework
Adds support for the M6718 modem IPC SPI driver. This patch adds the
spi driver under which the protocol will be added.
ST-Ericsson ID: 369397
ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-12224
ST-Ericsson Linux next: NA
Change-Id: Ifa60efa9cb6a9d30b02b88b563624a293bc0930c
Signed-off-by: Chris Blair <chris.blair@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/36433
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/modem/m6718_spi/modem_driver.h | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/include/linux/modem/m6718_spi/modem_driver.h b/include/linux/modem/m6718_spi/modem_driver.h new file mode 100644 index 00000000000..8c5209c228c --- /dev/null +++ b/include/linux/modem/m6718_spi/modem_driver.h @@ -0,0 +1,135 @@ +/* + * 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; +}; + +/* function exported for L1 to call with received frames */ +int modem_m6718_spi_receive(struct spi_device *sdev, u8 channel, + u32 len, void *data); + +#endif /* _MODEM_DRIVER_H_ */ |