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

Commit 4c6aa4e0 authored by Manu Gautam's avatar Manu Gautam
Browse files

usb_bam: restructure and cleanup code to handle multi instances



Driver supports all the USB bam2bam connections that are
available for all USB cores -  DWC3, CI or HSIC. But, current
design requires single devicetree node to specify all the
information which affects readability and adds few DT attributes
with redundant information.
Cleanup all this mess by restructuring the driver to allow
each USB controller specify/register DT node corresponding to
its own BAM core only. Few DT related  modifications as part of
this patch include changing attribute e.g. bam_type, reset-on-connect
and reset-on-disconnect from per connection to per BAM instance,
and replacing src-bam-physical-address and dst-bam-physical-address
with peer-bam-physical-address as it is now straight forward to
pick USB BAM's physical address (src or dst depends on PIPE's DIR)
from the DT node's reg property.

Change-Id: I427f88c736fda3ae0a71f3641334cf4f2231756c
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent eaa23eb8
Loading
Loading
Loading
Loading
+28 −51
Original line number Diff line number Diff line
@@ -7,29 +7,36 @@ and is statically configured with a number of unidirectional pipes.

Required properties:
- compatible: should be "qcom,usb-bam-msm"
- reg  : pairs of physical base addresses and region sizes
            of all the memory mapped BAM devices present
- reg-names : Register region name(s), in 1-1 correspondence with the
	    registers in 'reg'. This list should contain at least as many names
            as the number of unique values given in both 'usb-active-bam' and
            all the subnodes' 'usb-bam-type' properties.

            If SSUSB_BAM is used, "ssusb" should be present.
            If HSUSB_BAM is used, "hsusb" should be present.
            If HSIC_BAM is used, "hsic" should be present.
- interrupts: IRQ lines for BAM devices
- interrupt-names: BAM interrupt name(s), in 1-1 correspondence with
            'interrupts' above.

            If SSUSB_BAM is used, "ssusb" should be present.
            If HSUSB_BAM is used, "hsusb" should be present.
            If HSIC_BAM is used, "hsic" should be present.
- reg  : pair of physical base addresses and region size of BAM device
- interrupts: IRQ line for BAM device
- qcom,usb-bam-num-pipes: max number of pipes that can be used
- qcom,bam-type: BAM type can be one of
	0 - SSUSB_BAM
	1 - HSUSB_BAM
	2 - HSIC_BAM

Optional properties:
- qcom,usb-bam-fifo-baseaddr: base address for bam pipe's data and descriptor
  fifos. This can be on chip memory (ocimem). This
  property is required if sub-node's mem-type is ocimem or usb private mem.
- qcom,ignore-core-reset-ack: If present then BAM ignores ACK from USB core
	    while performing PIPE RESET
- qcom,disable-clk-gating: If present then disable BAM clock gating.
- qcom,usb-bam-override-threshold: If present then the default 512 byte threshold
		is overridden. This threshold configures the threshold value for Read/Write
		event generation by the BAM towards another BAM.
- qcom,usb-bam-max-mbps-highspeed: max mbps in high speed connection
            for either rx or tx direction.
- qcom,usb-bam-max-mbps-superspeed: max mbps in super speed connection
            for either rx or tx direction.
- qcom,bam-mode: BAM mode can be one of.
	0 - BAM_MODE_DEVICE
	1 - BAM_MODE_HOST
	(If not set will be set by default to BAM_MODE_DEVICE)
- qcom,reset-bam-on-connect: If present then BAM is RESET before connecting
  pipe. This may be required if BAM peripheral is also reset before connect.
- qcom,reset-bam-on-disconnect: If present then BAM is RESET after disconnecting pipes.
- qcom,enable-hsusb-bam-on-boot: If present then BAM is enabled at bootup itself.

A number of USB BAM pipe parameters are represented as sub-nodes:

@@ -44,10 +51,6 @@ Subnode Required:
            0 - Uses SPS's dedicated pipe memory
            1 - System RAM allocated by driver
	    2 - OCI memory residing @ 'qcom,usb-bam-fifo-baseaddr'
- qcom,bam-type: BAM type can be one of
	0 - SSUSB_BAM
	1 - HSUSB_BAM
	2 - HSIC_BAM
- qcom,dir: pipe direction
	0 - from usb (out)
	1 - to usb (in)
@@ -59,11 +62,9 @@ Subnode Required:
- qcom,descriptor-fifo-size: descriptor fifo size

Optional Properties for Subnode:
- qcom,reset-bam-on-connect: If present then BAM is RESET before connecting
  pipe. This may be required if BAM peripheral is also reset before connect.
- qcom,dst-bam-physical-address: destination BAM physical address
- qcom,peer-bam-physical-address: peer BAM's physical address.
	Not specified for IPA and used only for qdss connection
- qcom,dst-bam-pipe-index: destination BAM pipe index
- qcom,src-bam-physical-address: source BAM physical address
- qcom,src-bam-pipe-index: source BAM pipe index
- qcom,data-fifo-offset: data fifo offset address
- qcom,descriptor-fifo-offset: descriptor fifo offset address
@@ -71,47 +72,26 @@ Optional Properties for Subnode:
	0 - BAM2BAM (default if not specified)
	1 - SYS2BAM (only supported on UL)

Optional properties :
- qcom,bam-mode: BAM mode can be one of.
	0 - BAM_MODE_DEVICE
	1 - BAM_MODE_HOST
	(If not set will be set by default to BAM_MODE_DEVICE)
- qcom,ignore-core-reset-ack: If present then BAM ignores ACK from USB core
	    while performing PIPE RESET
- qcom,disable-clk-gating: If present then disable BAM clock gating.
- qcom,usb-bam-override-threshold: If present then the default 512 byte threshold
		is overridden. This threshold configures the threshold value for Read/Write
		event generation by the BAM towards another BAM.
- qcom,usb-bam-max-mbps-highspeed: max mbps in high speed connection
            for either rx or tx direction.
- qcom,usb-bam-max-mbps-superspeed: max mbps in super speed connection
            for either rx or tx direction.
- qcom,reset-bam-on-disconnect: If present then BAM is RESET after disconnecting pipes.
- qcom,enable-hsusb-bam-on-boot: If present then BAM is enabled at bootup itself.

Example USB BAM controller device node:

	qcom,usbbam@f9a44000 {
		compatible = "qcom,usb-bam-msm";
		reg = <0xf9a44000 0x11000>;
		reg-names = "hsusb";
		interrupts = <0 135 0>;
		interrupt-names = "hsusb";
		qcom,usb-bam-num-pipes = <16>;
		qcom,ignore-core-reset-ack;
		qcom,disable-clk-gating;
		qcom,usb-bam-max-mbps-highspeed = <400>;
		qcom,usb-bam-max-mbps-superspeed = <3600>;
		qcom,bam-type = <1>;
		qcom,bam-mode = <0>;

		qcom,pipe0 {
			label = "hsusb-ipa-out-0";
			qcom,usb-bam-mem-type = <0>;
			qcom,bam-type = <1>;
			qcom,bam-mode = <0>;
			qcom,dir = <0>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <2>;
			qcom,src-bam-physical-address = <0xf9a44000>;
			qcom,src-bam-pipe-index = <1>;
			qcom,data-fifo-offset = <0x2200>;
			qcom,data-fifo-size = <0x1e00>;
@@ -121,12 +101,9 @@ Example USB BAM controller device node:
		qcom,pipe1 {
			label = "hsusb-ipa-in-0";
			qcom,usb-bam-mem-type = <0>;
			qcom,bam-type = <1>;
			qcom,bam-mode = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <2>;
			qcom,dst-bam-physical-address = <0xf9a44000>;
			qcom,dst-bam-pipe-index = <0>;
			qcom,data-fifo-offset = <0x300>;
			qcom,data-fifo-size = <0x1e00>;
+4 −30
Original line number Diff line number Diff line
@@ -977,9 +977,9 @@
	qcom,usbbam@8b04000 {
		compatible = "qcom,usb-bam-msm";
		reg = <0x08b04000 0x1b000>;
		reg-names = "ssusb";
		interrupts = <0 132 0>;
		interrupt-names = "ssusb";

		qcom,bam-type = <0>;
		qcom,usb-bam-fifo-baseaddr = <0x08601000>;
		qcom,usb-bam-num-pipes = <16>;
		qcom,ignore-core-reset-ack;
@@ -987,127 +987,101 @@
		qcom,usb-bam-override-threshold = <0x4001>;
		qcom,usb-bam-max-mbps-highspeed = <400>;
		qcom,usb-bam-max-mbps-superspeed = <3600>;
		qcom,reset-bam-on-connect;

		qcom,pipe0 {
			label = "ssusb-ipa-out-0";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <0>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <1>;
			qcom,src-bam-physical-address = <0x08b04000>;
			qcom,src-bam-pipe-index = <1>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe1 {
			label = "ssusb-ipa-in-0";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x08b04000>;
			qcom,dst-bam-pipe-index = <0>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe2 {
			label = "ssusb-qdss-in-0";
			qcom,usb-bam-mem-type = <2>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <0>;
			qcom,src-bam-physical-address = <0x00884000>;
			qcom,peer-bam-physical-address = <0x00884000>;
			qcom,src-bam-pipe-index = <0>;
			qcom,dst-bam-physical-address = <0x08b04000>;
			qcom,dst-bam-pipe-index = <2>;
			qcom,data-fifo-offset = <0x0>;
			qcom,data-fifo-size = <0xC00>;
			qcom,descriptor-fifo-offset = <0xC00>;
			qcom,descriptor-fifo-size = <0x400>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe3 {
			label = "ssusb-ipa-out-1";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <0>;
			qcom,pipe-num = <1>;
			qcom,peer-bam = <1>;
			qcom,src-bam-physical-address = <0x08b04000>;
			qcom,src-bam-pipe-index = <3>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe4 {
			label = "ssusb-ipa-in-1";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <1>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x08b04000>;
			qcom,dst-bam-pipe-index = <2>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe5 {
			label = "ssusb-ipa-out-2";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <0>;
			qcom,pipe-num = <2>;
			qcom,peer-bam = <1>;
			qcom,src-bam-physical-address = <0x08b04000>;
			qcom,src-bam-pipe-index = <5>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe6 {
			label = "ssusb-ipa-in-2";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <2>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x08b04000>;
			qcom,dst-bam-pipe-index = <4>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe7  {
			label = "ssusb-ipa-out-3";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <0>;
			qcom,pipe-num = <3>;
			qcom,peer-bam = <1>;
			qcom,src-bam-physical-address = <0x08b04000>;
			qcom,src-bam-pipe-index = <6>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe8  {
			label = "ssusb-ipa-in-3";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <3>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x08b04000>;
			qcom,dst-bam-pipe-index = <7>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
	};

+3 −6
Original line number Diff line number Diff line
@@ -749,30 +749,27 @@
	qcom,usbbam@78c4000 {
		compatible = "qcom,usb-bam-msm";
		reg = <0x78c4000 0x15000>;
		reg-names = "hsusb";
		interrupts = <0 135 0>;
		interrupt-names = "hsusb";
		qcom,bam-type = <1>;
		qcom,usb-bam-num-pipes = <2>;
		qcom,usb-bam-fifo-baseaddr = <0x08603800>;
		qcom,ignore-core-reset-ack;
		qcom,disable-clk-gating;
		qcom,reset-bam-on-connect;

		qcom,pipe0 {
			label = "hsusb-qdss-in-0";
			qcom,usb-bam-mem-type = <2>;
			qcom,bam-type = <1>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <0>;
			qcom,src-bam-physical-address = <0x884000>;
			qcom,peer-bam-physical-address = <0x884000>;
			qcom,src-bam-pipe-index = <0>;
			qcom,dst-bam-physical-address = <0x78c4000>;
			qcom,dst-bam-pipe-index = <0>;
			qcom,data-fifo-offset = <0x0>;
			qcom,data-fifo-size = <0x600>;
			qcom,descriptor-fifo-offset = <0x600>;
			qcom,descriptor-fifo-size = <0x200>;
			qcom,reset-bam-on-connect;
		};
	};

+4 −15
Original line number Diff line number Diff line
@@ -949,73 +949,62 @@
	qcom,usbbam@78c4000 {
		compatible = "qcom,usb-bam-msm";
		reg = <0x78c4000 0x17000>;
		reg-names = "hsusb";
		interrupts = <0 135 0>;
		interrupt-names = "hsusb";

		qcom,bam-type = <1>;
		qcom,usb-bam-num-pipes = <4>;
		qcom,usb-bam-fifo-baseaddr = <0x08605000>;
		qcom,ignore-core-reset-ack;
		qcom,disable-clk-gating;
		qcom,usb-bam-max-mbps-highspeed = <400>;
		qcom,reset-bam-on-disconnect;

		qcom,pipe0 {
			label = "hsusb-ipa-out-0";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <1>;
			qcom,dir = <0>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <1>;
			qcom,src-bam-physical-address = <0x78c4000>;
			qcom,src-bam-pipe-index = <1>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-disconnect;
		};
		qcom,pipe1 {
			label = "hsusb-ipa-in-0";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <1>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x78c4000>;
			qcom,dst-bam-pipe-index = <0>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-disconnect;
		};

		qcom,pipe2 {
			label = "hsusb-qdss-in-0";
			qcom,usb-bam-mem-type = <2>;
			qcom,bam-type = <1>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <0>;
			qcom,src-bam-physical-address = <0x884000>;
			qcom,peer-bam-physical-address = <0x884000>;
			qcom,src-bam-pipe-index = <0>;
			qcom,dst-bam-physical-address = <0x78c4000>;
			qcom,dst-bam-pipe-index = <2>;
			qcom,data-fifo-offset = <0x0>;
			qcom,data-fifo-size = <0xe00>;
			qcom,descriptor-fifo-offset = <0xe00>;
			qcom,descriptor-fifo-size = <0x200>;
			qcom,reset-bam-on-disconnect;
		};

		/* USB BAM pipe (consumer) configuration for accelerated DPL */
		qcom,pipe3 {
			label = "hsusb-dpl-ipa-in-1";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <1>;
			qcom,dir = <1>;
			qcom,pipe-num = <1>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x78c4000>;
			qcom,dst-bam-pipe-index = <3>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-disconnect;
		};
	};

+3 −15
Original line number Diff line number Diff line
@@ -2216,10 +2216,9 @@
	qcom,usbbam@6b04000 {
		compatible = "qcom,usb-bam-msm";
		reg = <0x06b04000 0x1a934>;
		reg-names = "ssusb";
		interrupts = <0 132 0>;
		interrupt-names = "ssusb";

		qcom,bam-type = <0>;
		qcom,usb-bam-fifo-baseaddr = <0x066bb000>;
		qcom,usb-bam-num-pipes = <8>;
		qcom,ignore-core-reset-ack;
@@ -2227,62 +2226,51 @@
		qcom,usb-bam-override-threshold = <0x4001>;
		qcom,usb-bam-max-mbps-highspeed = <400>;
		qcom,usb-bam-max-mbps-superspeed = <3600>;
		qcom,reset-bam-on-connect;

		qcom,pipe0 {
			label = "ssusb-ipa-out-0";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <0>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <1>;
			qcom,src-bam-physical-address = <0x06b04000>;
			qcom,src-bam-pipe-index = <1>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe1 {
			label = "ssusb-ipa-in-0";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x06b04000>;
			qcom,dst-bam-pipe-index = <0>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe2 {
			label = "ssusb-qdss-in-0";
			qcom,usb-bam-mem-type = <2>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <0>;
			qcom,peer-bam = <0>;
			qcom,src-bam-physical-address = <0x03084000>;
			qcom,peer-bam-physical-address = <0x03084000>;
			qcom,src-bam-pipe-index = <0>;
			qcom,dst-bam-physical-address = <0x06b04000>;
			qcom,dst-bam-pipe-index = <2>;
			qcom,data-fifo-offset = <0x0>;
			qcom,data-fifo-size = <0x1800>;
			qcom,descriptor-fifo-offset = <0x1800>;
			qcom,descriptor-fifo-size = <0x800>;
			qcom,reset-bam-on-connect;
		};
		qcom,pipe3 {
			label = "ssusb-dpl-ipa-in-1";
			qcom,usb-bam-mem-type = <1>;
			qcom,bam-type = <0>;
			qcom,dir = <1>;
			qcom,pipe-num = <1>;
			qcom,peer-bam = <1>;
			qcom,dst-bam-physical-address = <0x06b04000>;
			qcom,dst-bam-pipe-index = <2>;
			qcom,data-fifo-size = <0x8000>;
			qcom,descriptor-fifo-size = <0x2000>;
			qcom,reset-bam-on-connect;
		};
	};

Loading