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

Commit 50e8326c authored by Manu Gautam's avatar Manu Gautam
Browse files

usb_bam: Get rid of usb_bam_set_qdss_core and usb_bam_get_qdss_idx



usb_bam_set_qdss_core API is currently used by QDSS function driver
to notify usb_bam about the USB core to which QDSS function is bound.
usb_bam can however determine this information from the connections
info passed via devicetree. Remove this API and rather let usb_bam
figure this out while parsing the BAM connections.
While at it also make coresight driver not bother about connection
index as this is not relevant for coresight. And change function
drivers to directly pass usb_bam_type (DWC3 or CI/HSIC) when
querying connection indexes which will allow to have separate
usb_bam_connections array for each BAM and eventually we can have
usb_bam platform driver as multi instance and pass connections
information for different USB BAMs using separate DT nodes.

Change-Id: I2f794751b102ab7200756245bce546dda41a1f90
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent 92407d6c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -522,8 +522,7 @@ static void tmc_etr_fill_usb_bam_data(struct tmc_drvdata *drvdata)
{
	struct tmc_etr_bam_data *bamdata = drvdata->bamdata;

	get_bam2bam_connection_info(usb_bam_get_qdss_idx(0),
				    &bamdata->dest,
	get_qdss_bam_connection_info(&bamdata->dest,
				    &bamdata->dest_pipe_idx,
				    &bamdata->src_pipe_idx,
				    &bamdata->desc_fifo,
+35 −28
Original line number Diff line number Diff line
@@ -100,8 +100,7 @@ struct usb_bam_sps_type {
*	case the usb bam uses its private memory for the pipes.
* @mem_iface_clk: Clock that controls the usb bam private memory in
*	case the usb bam uses its private memory for the pipes.
* @qdss_core_name: Stores the name of the core ("ssusb", "hsusb" or "hsic")
*	that it used as a peer of the qdss in bam2bam mode.
* @qdss_usb_bam_type: USB bam type used as a peer of the qdss in bam2bam mode.
* @h_bam: This array stores for each BAM ("ssusb", "hsusb" or "hsic") the
*	handle/device of the sps driver.
* @pipes_enabled_per_bam: This array stores for each BAM
@@ -120,7 +119,7 @@ struct usb_bam_ctx_type {
	u8 max_connections;
	struct clk *mem_clk;
	struct clk *mem_iface_clk;
	char qdss_core_name[USB_BAM_MAX_STR_LEN];
	enum usb_ctrl qdss_usb_bam_type;
	unsigned long h_bam[MAX_BAMS];
	u8 pipes_enabled_per_bam[MAX_BAMS];
	u32 inactivity_timer_ms[MAX_BAMS];
@@ -2968,6 +2967,10 @@ static struct msm_usb_bam_platform_data *usb_bam_dt_to_pdata(
				__func__);
			goto err;
		}
		/* Store USB bam_type to be used with QDSS */
		if (usb_bam_connections[i].peer_bam == QDSS_P_BAM)
			ctx.qdss_usb_bam_type = usb_bam_connections[i].bam_type;

		rc = of_property_read_u32(node, "qcom,dir",
			&usb_bam_connections[i].dir);
		if (rc) {
@@ -3355,13 +3358,6 @@ static int usb_bam_probe(struct platform_device *pdev)
	return ret;
}

int usb_bam_get_qdss_idx(u8 num)
{
	return usb_bam_get_connection_idx(ctx.qdss_core_name, QDSS_P_BAM,
		PEER_PERIPHERAL_TO_USB, USB_BAM_DEVICE, num);
}
EXPORT_SYMBOL(usb_bam_get_qdss_idx);

bool usb_bam_get_prod_granted(u8 idx)
{
	struct usb_bam_pipe_connect *pipe_connect = &usb_bam_connections[idx];
@@ -3371,12 +3367,6 @@ bool usb_bam_get_prod_granted(u8 idx)
}
EXPORT_SYMBOL(usb_bam_get_prod_granted);


void usb_bam_set_qdss_core(const char *qdss_core)
{
	strlcpy(ctx.qdss_core_name, qdss_core, USB_BAM_MAX_STR_LEN);
}

int get_bam2bam_connection_info(u8 idx, unsigned long *usb_bam_handle,
	u32 *usb_bam_pipe_idx, u32 *peer_pipe_idx,
	struct sps_mem_buffer *desc_fifo, struct sps_mem_buffer *data_fifo,
@@ -3409,19 +3399,28 @@ int get_bam2bam_connection_info(u8 idx, unsigned long *usb_bam_handle,
}
EXPORT_SYMBOL(get_bam2bam_connection_info);

int get_qdss_bam_connection_info(unsigned long *usb_bam_handle,
	u32 *usb_bam_pipe_idx, u32 *peer_pipe_idx,
	struct sps_mem_buffer *desc_fifo, struct sps_mem_buffer *data_fifo,
	enum usb_pipe_mem_type *mem_type)
{
	u8 idx;

	/* QDSS uses only one pipe */
	idx = usb_bam_get_connection_idx(ctx.qdss_usb_bam_type, QDSS_P_BAM,
		PEER_PERIPHERAL_TO_USB, USB_BAM_DEVICE, 0);

int usb_bam_get_connection_idx(const char *core_name, enum peer_bam client,
	get_bam2bam_connection_info(idx, usb_bam_handle, usb_bam_pipe_idx,
			peer_pipe_idx, desc_fifo, data_fifo, mem_type);

	return 0;
}
EXPORT_SYMBOL(get_qdss_bam_connection_info);

int usb_bam_get_connection_idx(enum usb_ctrl bam_type, enum peer_bam client,
	enum usb_bam_pipe_dir dir, enum usb_bam_mode bam_mode, u32 num)
{
	u8 i;
	int bam_type;

	bam_type = get_bam_type_from_core_name(core_name);
	if (bam_type < 0 || bam_type >= MAX_BAMS) {
		pr_err("%s: Invalid bam, type=%d, name=%s\n",
			__func__, bam_type, core_name);
		return -EINVAL;
	}

	for (i = 0; i < ctx.max_connections; i++)
		if (usb_bam_connections[i].bam_type == bam_type &&
@@ -3433,14 +3432,22 @@ int usb_bam_get_connection_idx(const char *core_name, enum peer_bam client,
			return i;
		}

	pr_err("%s: failed for %s\n", __func__, core_name);
	pr_err("%s: failed for %d\n", __func__, bam_type);
	return -ENODEV;
}
EXPORT_SYMBOL(usb_bam_get_connection_idx);

int usb_bam_get_bam_type(int connection_idx)
int usb_bam_get_bam_type(const char *core_name)
{
	return usb_bam_connections[connection_idx].bam_type;
	int bam_type = get_bam_type_from_core_name(core_name);

	if (bam_type < 0 || bam_type >= MAX_BAMS) {
		pr_err("%s: Invalid bam, type=%d, name=%s\n",
			__func__, bam_type, core_name);
		return -EINVAL;
	}

	return bam_type;
}
EXPORT_SYMBOL(usb_bam_get_bam_type);

+3 −2
Original line number Diff line number Diff line
@@ -621,7 +621,7 @@ static int qdss_dpl_ipa_connect(int port_num)
	struct gqdss *g_qdss;
	struct gadget_ipa_port *gp;
	struct usb_gadget *gadget;
	enum peer_bam bam_name = IPA_P_BAM;
	enum usb_ctrl usb_bam_type;
	unsigned long flags;

	ipa_data_port_select(port_num, USB_GADGET_DPL);
@@ -639,7 +639,8 @@ static int qdss_dpl_ipa_connect(int port_num)

	spin_unlock_irqrestore(&qdss->lock, flags);

	dst_connection_idx = usb_bam_get_connection_idx(gadget->name, bam_name,
	usb_bam_type = usb_bam_get_bam_type(gadget->name);
	dst_connection_idx = usb_bam_get_connection_idx(usb_bam_type, IPA_P_BAM,
				PEER_PERIPHERAL_TO_USB, USB_BAM_DEVICE, 1);
	if (dst_connection_idx < 0) {
		pr_err("usb_bam_get_connection_idx failed\n");
+5 −3
Original line number Diff line number Diff line
@@ -379,6 +379,7 @@ static int gport_rmnet_connect(struct f_rmnet *dev, unsigned intf)
	enum transport_type	dxport = rmnet_ports[dev->port_num].data_xport;
	int			src_connection_idx = 0, dst_connection_idx = 0;
	struct usb_gadget	*gadget = dev->cdev->gadget;
	enum usb_ctrl		usb_bam_type;
	void			*net;

	pr_debug("%s: ctrl xport: %s data xport: %s dev: %p portno: %d\n",
@@ -434,10 +435,11 @@ static int gport_rmnet_connect(struct f_rmnet *dev, unsigned intf)
		}
		break;
	case USB_GADGET_XPORT_BAM2BAM_IPA:
		src_connection_idx = usb_bam_get_connection_idx(gadget->name,
		usb_bam_type = usb_bam_get_bam_type(gadget->name);
		src_connection_idx = usb_bam_get_connection_idx(usb_bam_type,
			IPA_P_BAM, USB_TO_PEER_PERIPHERAL, USB_BAM_DEVICE,
			port_num);
		dst_connection_idx = usb_bam_get_connection_idx(gadget->name,
		dst_connection_idx = usb_bam_get_connection_idx(usb_bam_type,
			IPA_P_BAM, PEER_PERIPHERAL_TO_USB, USB_BAM_DEVICE,
			port_num);
		if (dst_connection_idx < 0 || src_connection_idx < 0) {
+6 −7
Original line number Diff line number Diff line
@@ -1422,6 +1422,7 @@ int bam_data_connect(struct data_port *gr, enum transport_type trans,
	int			ret, port_num;
	unsigned long		flags;
	u8			src_connection_idx, dst_connection_idx;
	enum usb_ctrl		usb_bam_type;

	if (!gr) {
		pr_err("data port is null\n");
@@ -1441,10 +1442,12 @@ int bam_data_connect(struct data_port *gr, enum transport_type trans,

	pr_debug("dev:%p port#%d\n", gr, port_num);

	src_connection_idx = usb_bam_get_connection_idx(gr->cdev->gadget->name,
	usb_bam_type = usb_bam_get_bam_type(gr->cdev->gadget->name);

	src_connection_idx = usb_bam_get_connection_idx(usb_bam_type,
			IPA_P_BAM, USB_TO_PEER_PERIPHERAL, USB_BAM_DEVICE,
			dev_port_num);
	dst_connection_idx = usb_bam_get_connection_idx(gr->cdev->gadget->name,
	dst_connection_idx = usb_bam_get_connection_idx(usb_bam_type,
			IPA_P_BAM, PEER_PERIPHERAL_TO_USB, USB_BAM_DEVICE,
			dev_port_num);
	if (src_connection_idx < 0 || dst_connection_idx < 0) {
@@ -1467,11 +1470,7 @@ int bam_data_connect(struct data_port *gr, enum transport_type trans,
	d->rx_buffer_size = (gr->rx_buffer_size ? gr->rx_buffer_size :
					bam_mux_rx_req_size);

	/*
	 * Both source (consumer) and destination (producer) use the same
	 * controller, so checking just one of them should suffice.
	 */
	if (usb_bam_get_bam_type(src_connection_idx) == HSIC_CTRL) {
	if (usb_bam_type == HSIC_CTRL) {
		d->ipa_params.src_client = IPA_CLIENT_HSIC1_PROD;
		d->ipa_params.dst_client = IPA_CLIENT_HSIC1_CONS;
	} else {
Loading