Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 533cf6e5 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: soc: qcom: Port bam dmux driver"

parents 97b76bc3 bb74403b
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
Qualcomm Technologies, Inc. BAM Data Multiplexer Driver

Required properties:
- compatible : should be "qcom,bam_dmux"
- reg : the location and size of the BAM hardware
- interrupts : the BAM hardware to apps processor interrupt line

Optional properties:
-qcom,satellite-mode: the hardware needs to be configured in satellite mode
-qcom,rx-ring-size: the size of the receive ring buffer pool, default is 32
-qcom,max-rx-mtu: the maximum receive MTU that can be negotiated, in bytes.
	Default is 2048.  Other possible values are 4096, 8192, and 16384.
-qcom,no-cpu-affinity: boolean value indicating that workqueue CPU affinity
	is not required.
-qcom,fast-shutdown: boolean value to support fast shutdown time.

Example:

	qcom,bam_dmux@fc834000 {
		compatible = "qcom,bam_dmux";
		reg = <0xfc834000 0x7000>;
		interrupts = <0 29 1>;
		qcom,satellite-mode;
		qcom,rx-ring-size = <64>;
		qcom,max-rx-mtu = <8192>;
		qcom,no-cpu-affinity;
		qcom,fast-shutdown;
	};
+9 −0
Original line number Diff line number Diff line
@@ -914,6 +914,15 @@ config QCOM_ADSP_MANUAL_VOTE
	  This driver sends message over QMI to the service which is running on
	  ADSP.

config MSM_BAM_DMUX
	bool "BAM Data Mux Driver"
	depends on SPS
	help
	  Support Muxed Data Channels over BAM interface.
	  BAM has a limited number of pipes.  This driver
	  provides a means to support more logical channels
	  via muxing than BAM could without muxing.

endmenu

config QCOM_HYP_CORE_CTL
+1 −0
Original line number Diff line number Diff line
@@ -106,3 +106,4 @@ obj-$(CONFIG_QCOM_AOP_DDRSS_COMMANDS) += aop_ddrss_cmds.o
obj-$(CONFIG_RMNET_CTL) += rmnet_ctl/
obj-$(CONFIG_QCOM_ADSP_MANUAL_VOTE) += adsp_vote_qmi.o adsp_lpm_voting_v01.o
obj-$(CONFIG_CPU_V7) += idle-v7.o
obj-$(CONFIG_MSM_BAM_DMUX) += bam_dmux.o
+2895 −0

File added.

Preview size limit exceeded, changes collapsed.

+192 −0
Original line number Diff line number Diff line
/* Copyright (c) 2013-2014, 2019 The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _BAM_DMUX_PRIVATE_H
#define _BAM_DMUX_PRIVATE_H

#include <linux/types.h>
#include <linux/dma-mapping.h>

#include <linux/msm-sps.h>
#include <linux/soc/qcom/smem_state.h>

#define BAM_MUX_HDR_MAGIC_NO			0x33fc
#define BAM_MUX_HDR_CMD_DATA			0
#define BAM_MUX_HDR_CMD_OPEN			1
#define BAM_MUX_HDR_CMD_CLOSE			2
#define BAM_MUX_HDR_CMD_STATUS			3 /* unused */
#define BAM_MUX_HDR_CMD_OPEN_NO_A2_PC		4
#define DEFAULT_BUFFER_SIZE			SZ_2K

#define DYNAMIC_MTU_MASK			0x2
#define MTU_SIZE_MASK				0xc0
#define MTU_SIZE_SHIFT				0x6
#define DL_POOL_SIZE_SHIFT			0x4

/**
 * struct bam_ops_if - collection of function pointers to allow swappable
 * runtime functionality
 * @smsm_change_state_ptr: pointer to smsm_change_state function
 * @smsm_get_state_ptr: pointer to smsm_get_state function
 * @smsm_state_cb_register_ptr: pointer to smsm_state_cb_register function
 * @smsm_state_cb_deregister_ptr: pointer to smsm_state_cb_deregister function
 * @sps_connect_ptr: pointer to sps_connect function
 * @sps_disconnect_ptr: pointer to sps_disconnect function
 * @sps_register_bam_device_ptr: pointer to sps_register_bam_device
 * @sps_deregister_bam_device_ptr: pointer to sps_deregister_bam_device
 * function
 * @sps_alloc_endpoint_ptr: pointer to sps_alloc_endpoint function
 * @sps_free_endpoint_ptr: pointer to sps_free_endpoint function
 * @sps_set_config_ptr: pointer to sps_set_config function
 * @sps_get_config_ptr: pointer to sps_get_config function
 * @sps_device_reset_ptr: pointer to sps_device_reset function
 * @sps_register_event_ptr: pointer to sps_register_event function
 * @sps_transfer_one_ptr: pointer to sps_transfer_one function
 * @sps_get_iovec_ptr: pointer to sps_get_iovec function
 * @sps_get_unused_desc_num_ptr: pointer to sps_get_unused_desc_num function
 * @dma_to: enum for the direction of dma operations to device
 * @dma_from: enum for the direction of dma operations from device
 *
 * This struct contains the interface from bam_dmux to smsm and sps. The
 * pointers can be swapped out at run time to provide different functionality.
 */
struct bam_ops_if {
	/* smsm */
	int (*smsm_change_state_ptr)(struct qcom_smem_state *state, u32 mask,
		u32 value);

	struct qcom_smem_state *(*smsm_get_state_ptr)(struct device *dev,
		const char *con_id, unsigned int *bit);

	struct qcom_smem_state *(*smsm_state_cb_register_ptr)(
		struct device_node *of_node,
		const struct qcom_smem_state_ops *ops, void *priv);

	void (*smsm_state_cb_deregister_ptr)(struct qcom_smem_state *state);

	/* sps */
	int (*sps_connect_ptr)(struct sps_pipe *h, struct sps_connect *connect);

	int (*sps_disconnect_ptr)(struct sps_pipe *h);

	int (*sps_register_bam_device_ptr)(
		const struct sps_bam_props *bam_props,
		unsigned long *dev_handle);

	int (*sps_deregister_bam_device_ptr)(unsigned long dev_handle);

	struct sps_pipe *(*sps_alloc_endpoint_ptr)(void);

	int (*sps_free_endpoint_ptr)(struct sps_pipe *h);

	int (*sps_set_config_ptr)(struct sps_pipe *h,
		struct sps_connect *config);

	int (*sps_get_config_ptr)(struct sps_pipe *h,
		struct sps_connect *config);

	int (*sps_device_reset_ptr)(unsigned long dev);

	int (*sps_register_event_ptr)(struct sps_pipe *h,
		struct sps_register_event *reg);

	int (*sps_transfer_one_ptr)(struct sps_pipe *h,
		phys_addr_t addr, u32 size,
		void *user, u32 flags);

	int (*sps_get_iovec_ptr)(struct sps_pipe *h,
		struct sps_iovec *iovec);

	int (*sps_get_unused_desc_num_ptr)(struct sps_pipe *h,
		u32 *desc_num);

	enum dma_data_direction dma_to;

	enum dma_data_direction dma_from;


	struct device_node *node;

	u32 *smem_state;

	void *pwr_state;

	void *pwr_ack_state;
};

/**
 * struct bam_mux_hdr - struct which contains bam dmux header info
 * @magic_num: magic number placed at start to ensure that it is actually a
 * valid bam dmux header
 * @signal: optional signaling bits with commmand type specific definitions
 * @cmd: the command
 * @pad_len: the length of padding
 * @ch_id: the id of the bam dmux channel that this is sent on
 * @pkt_len: the length of the packet that this is the header of
 */
struct bam_mux_hdr {
	uint16_t magic_num;
	uint8_t signal;
	uint8_t cmd;
	uint8_t pad_len;
	uint8_t ch_id;
	uint16_t pkt_len;
};

/**
 * struct rx_pkt_info - struct describing an rx packet
 * @skb: socket buffer containing the packet
 * @dma_address: dma mapped address of the packet
 * @work: work_struct for processing the packet
 * @list_node: list_head for placing this on a list
 * @sps_size: size of the sps_iovec for this packet
 * @len: total length of the buffer containing this packet
 */
struct rx_pkt_info {
	struct sk_buff *skb;
	dma_addr_t dma_address;
	struct work_struct work;
	struct list_head list_node;
	uint16_t sps_size;
	uint16_t len;
};

/**
 * struct tx_pkt_info - struct describing a tx packet
 * @skb: socket buffer containing the packet
 * @dma_address: dma mapped address of the packet
 * @is_cmd: signifies whether this is a command or data packet
 * @len: length og the packet
 * @work: work_struct for processing this packet
 * @list_node: list_head for placing this on a list
 * @ts_sec: seconds portion of the timestamp
 * @ts_nsec: nanoseconds portion of the timestamp
 *
 */
struct tx_pkt_info {
	struct sk_buff *skb;
	dma_addr_t dma_address;
	char is_cmd;
	uint32_t len;
	struct work_struct work;
	struct list_head list_node;
	unsigned int ts_sec;
	unsigned long ts_nsec;
};

void msm_bam_dmux_set_bam_ops(struct bam_ops_if *ops);

void msm_bam_dmux_deinit(void);

void msm_bam_dmux_reinit(void);

#endif /* _BAM_DMUX_PRIVATE_H */
Loading