18c2ecf20Sopenharmony_ciQualcomm External Bus Interface 2 (EBI2)
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThe EBI2 contains two peripheral blocks: XMEM and LCDC. The XMEM handles any
48c2ecf20Sopenharmony_ciexternal memory (such as NAND or other memory-mapped peripherals) whereas
58c2ecf20Sopenharmony_ciLCDC handles LCD displays.
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciAs it says it connects devices to an external bus interface, meaning address
88c2ecf20Sopenharmony_cilines (up to 9 address lines so can only address 1KiB external memory space),
98c2ecf20Sopenharmony_cidata lines (16 bits), OE (output enable), ADV (address valid, used on some
108c2ecf20Sopenharmony_ciNOR flash memories), WE (write enable). This on top of 6 different chip selects
118c2ecf20Sopenharmony_ci(CS0 thru CS5) so that in theory 6 different devices can be connected.
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciApparently this bus is clocked at 64MHz. It has dedicated pins on the package
148c2ecf20Sopenharmony_ciand the bus can only come out on these pins, however if some of the pins are
158c2ecf20Sopenharmony_ciunused they can be left unconnected or remuxed to be used as GPIO or in some
168c2ecf20Sopenharmony_cicases other orthogonal functions as well.
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciAlso CS1 and CS2 has -A and -B signals. Why they have that is unclear to me.
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciThe chip selects have the following memory range assignments. This region of
218c2ecf20Sopenharmony_cimemory is referred to as "Chip Peripheral SS FPB0" and is 168MB big.
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciChip Select                     Physical address base
248c2ecf20Sopenharmony_ciCS0 GPIO134                     0x1a800000-0x1b000000 (8MB)
258c2ecf20Sopenharmony_ciCS1 GPIO39 (A) / GPIO123 (B)    0x1b000000-0x1b800000 (8MB)
268c2ecf20Sopenharmony_ciCS2 GPIO40 (A) / GPIO124 (B)    0x1b800000-0x1c000000 (8MB)
278c2ecf20Sopenharmony_ciCS3 GPIO133                     0x1d000000-0x25000000 (128 MB)
288c2ecf20Sopenharmony_ciCS4 GPIO132                     0x1c800000-0x1d000000 (8MB)
298c2ecf20Sopenharmony_ciCS5 GPIO131                     0x1c000000-0x1c800000 (8MB)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciThe APQ8060 Qualcomm Application Processor User Guide, 80-N7150-14 Rev. A,
328c2ecf20Sopenharmony_ciAugust 6, 2012 contains some incomplete documentation of the EBI2.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciFIXME: the manual mentions "write precharge cycles" and "precharge cycles".
358c2ecf20Sopenharmony_ciWe have not been able to figure out which bit fields these correspond to
368c2ecf20Sopenharmony_ciin the hardware, or what valid values exist. The current hypothesis is that
378c2ecf20Sopenharmony_cithis is something just used on the FAST chip selects and that the SLOW
388c2ecf20Sopenharmony_cichip selects are understood fully. There is also a "byte device enable"
398c2ecf20Sopenharmony_ciflag somewhere for 8bit memories.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciFIXME: The chipselects have SLOW and FAST configuration registers. It's a bit
428c2ecf20Sopenharmony_ciunclear what this means, if they are mutually exclusive or can be used
438c2ecf20Sopenharmony_citogether, or if some chip selects are hardwired to be FAST and others are SLOW
448c2ecf20Sopenharmony_ciby design.
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciThe XMEM registers are totally undocumented but could be partially decoded
478c2ecf20Sopenharmony_cibecause the Cypress AN49576 Antioch Westbridge apparently has suspiciously
488c2ecf20Sopenharmony_cisimilar register layout, see: http://www.cypress.com/file/105771/download
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciRequired properties:
518c2ecf20Sopenharmony_ci- compatible: should be one of:
528c2ecf20Sopenharmony_ci  "qcom,msm8660-ebi2"
538c2ecf20Sopenharmony_ci  "qcom,apq8060-ebi2"
548c2ecf20Sopenharmony_ci- #address-cells: should be <2>: the first cell is the chipselect,
558c2ecf20Sopenharmony_ci  the second cell is the offset inside the memory range
568c2ecf20Sopenharmony_ci- #size-cells: should be <1>
578c2ecf20Sopenharmony_ci- ranges: should be set to:
588c2ecf20Sopenharmony_ci  ranges = <0 0x0 0x1a800000 0x00800000>,
598c2ecf20Sopenharmony_ci           <1 0x0 0x1b000000 0x00800000>,
608c2ecf20Sopenharmony_ci           <2 0x0 0x1b800000 0x00800000>,
618c2ecf20Sopenharmony_ci           <3 0x0 0x1d000000 0x08000000>,
628c2ecf20Sopenharmony_ci           <4 0x0 0x1c800000 0x00800000>,
638c2ecf20Sopenharmony_ci           <5 0x0 0x1c000000 0x00800000>;
648c2ecf20Sopenharmony_ci- reg: two ranges of registers: EBI2 config and XMEM config areas
658c2ecf20Sopenharmony_ci- reg-names: should be "ebi2", "xmem"
668c2ecf20Sopenharmony_ci- clocks: two clocks, EBI_2X and EBI
678c2ecf20Sopenharmony_ci- clock-names: should be "ebi2x", "ebi2"
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciOptional subnodes:
708c2ecf20Sopenharmony_ci- Nodes inside the EBI2 will be considered device nodes.
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciThe following optional properties are properties that can be tagged onto
738c2ecf20Sopenharmony_ciany device subnode. We are assuming that there can be only ONE device per
748c2ecf20Sopenharmony_cichipselect subnode, else the properties will become ambiguous.
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ciOptional properties arrays for SLOW chip selects:
778c2ecf20Sopenharmony_ci- qcom,xmem-recovery-cycles: recovery cycles is the time the memory continues to
788c2ecf20Sopenharmony_ci  drive the data bus after OE is de-asserted, in order to avoid contention on
798c2ecf20Sopenharmony_ci  the data bus. They are inserted when reading one CS and switching to another
808c2ecf20Sopenharmony_ci  CS or read followed by write on the same CS. Valid values 0 thru 15. Minimum
818c2ecf20Sopenharmony_ci  value is actually 1, so a value of 0 will still yield 1 recovery cycle.
828c2ecf20Sopenharmony_ci- qcom,xmem-write-hold-cycles: write hold cycles, these are extra cycles
838c2ecf20Sopenharmony_ci  inserted after every write minimum 1. The data out is driven from the time
848c2ecf20Sopenharmony_ci  WE is asserted until CS is asserted. With a hold of 1 (value = 0), the CS
858c2ecf20Sopenharmony_ci  stays active for 1 extra cycle etc. Valid values 0 thru 15.
868c2ecf20Sopenharmony_ci- qcom,xmem-write-delta-cycles: initial latency for write cycles inserted for
878c2ecf20Sopenharmony_ci  the first write to a page or burst memory. Valid values 0 thru 255.
888c2ecf20Sopenharmony_ci- qcom,xmem-read-delta-cycles: initial latency for read cycles inserted for the
898c2ecf20Sopenharmony_ci  first read to a page or burst memory. Valid values 0 thru 255.
908c2ecf20Sopenharmony_ci- qcom,xmem-write-wait-cycles: number of wait cycles for every write access, 0=1
918c2ecf20Sopenharmony_ci  cycle. Valid values 0 thru 15.
928c2ecf20Sopenharmony_ci- qcom,xmem-read-wait-cycles: number of wait cycles for every read access, 0=1
938c2ecf20Sopenharmony_ci  cycle. Valid values 0 thru 15.
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ciOptional properties arrays for FAST chip selects:
968c2ecf20Sopenharmony_ci- qcom,xmem-address-hold-enable: this is a boolean property stating that we
978c2ecf20Sopenharmony_ci  shall hold the address for an extra cycle to meet hold time requirements
988c2ecf20Sopenharmony_ci  with ADV assertion.
998c2ecf20Sopenharmony_ci- qcom,xmem-adv-to-oe-recovery-cycles: the number of cycles elapsed before an OE
1008c2ecf20Sopenharmony_ci  assertion, with respect to the cycle where ADV (address valid) is asserted.
1018c2ecf20Sopenharmony_ci  2 means 2 cycles between ADV and OE. Valid values 0, 1, 2 or 3.
1028c2ecf20Sopenharmony_ci- qcom,xmem-read-hold-cycles: the length in cycles of the first segment of a
1038c2ecf20Sopenharmony_ci  read transfer. For a single read transfer this will be the time from CS
1048c2ecf20Sopenharmony_ci  assertion to OE assertion. Valid values 0 thru 15.
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ciExample:
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciebi2@1a100000 {
1108c2ecf20Sopenharmony_ci	compatible = "qcom,apq8060-ebi2";
1118c2ecf20Sopenharmony_ci	#address-cells = <2>;
1128c2ecf20Sopenharmony_ci	#size-cells = <1>;
1138c2ecf20Sopenharmony_ci	ranges = <0 0x0 0x1a800000 0x00800000>,
1148c2ecf20Sopenharmony_ci		 <1 0x0 0x1b000000 0x00800000>,
1158c2ecf20Sopenharmony_ci		 <2 0x0 0x1b800000 0x00800000>,
1168c2ecf20Sopenharmony_ci		 <3 0x0 0x1d000000 0x08000000>,
1178c2ecf20Sopenharmony_ci		 <4 0x0 0x1c800000 0x00800000>,
1188c2ecf20Sopenharmony_ci		 <5 0x0 0x1c000000 0x00800000>;
1198c2ecf20Sopenharmony_ci	reg = <0x1a100000 0x1000>, <0x1a110000 0x1000>;
1208c2ecf20Sopenharmony_ci	reg-names = "ebi2", "xmem";
1218c2ecf20Sopenharmony_ci	clocks = <&gcc EBI2_2X_CLK>, <&gcc EBI2_CLK>;
1228c2ecf20Sopenharmony_ci	clock-names = "ebi2x", "ebi2";
1238c2ecf20Sopenharmony_ci	/* Make sure to set up the pin control for the EBI2 */
1248c2ecf20Sopenharmony_ci	pinctrl-names = "default";
1258c2ecf20Sopenharmony_ci	pinctrl-0 = <&foo_ebi2_pins>;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	foo-ebi2@2,0 {
1288c2ecf20Sopenharmony_ci		compatible = "foo";
1298c2ecf20Sopenharmony_ci		reg = <2 0x0 0x100>;
1308c2ecf20Sopenharmony_ci		(...)
1318c2ecf20Sopenharmony_ci		qcom,xmem-recovery-cycles = <0>;
1328c2ecf20Sopenharmony_ci		qcom,xmem-write-hold-cycles = <3>;
1338c2ecf20Sopenharmony_ci		qcom,xmem-write-delta-cycles = <31>;
1348c2ecf20Sopenharmony_ci		qcom,xmem-read-delta-cycles = <28>;
1358c2ecf20Sopenharmony_ci		qcom,xmem-write-wait-cycles = <9>;
1368c2ecf20Sopenharmony_ci		qcom,xmem-read-wait-cycles = <9>;
1378c2ecf20Sopenharmony_ci	};
1388c2ecf20Sopenharmony_ci};
139