18c2ecf20Sopenharmony_ciRenesas R-Car Gen3 Digital Radio Interface controller (DRIF)
28c2ecf20Sopenharmony_ci------------------------------------------------------------
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciR-Car Gen3 DRIF is a SPI like receive only slave device. A general
58c2ecf20Sopenharmony_cirepresentation of DRIF interfacing with a master device is shown below.
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci+---------------------+                +---------------------+
88c2ecf20Sopenharmony_ci|                     |-----SCK------->|CLK                  |
98c2ecf20Sopenharmony_ci|       Master        |-----SS-------->|SYNC  DRIFn (slave)  |
108c2ecf20Sopenharmony_ci|                     |-----SD0------->|D0                   |
118c2ecf20Sopenharmony_ci|                     |-----SD1------->|D1                   |
128c2ecf20Sopenharmony_ci+---------------------+                +---------------------+
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciAs per datasheet, each DRIF channel (drifn) is made up of two internal
158c2ecf20Sopenharmony_cichannels (drifn0 & drifn1). These two internal channels share the common
168c2ecf20Sopenharmony_ciCLK & SYNC. Each internal channel has its own dedicated resources like
178c2ecf20Sopenharmony_ciirq, dma channels, address space & clock. This internal split is not
188c2ecf20Sopenharmony_civisible to the external master device.
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciThe device tree model represents each internal channel as a separate node.
218c2ecf20Sopenharmony_ciThe internal channels sharing the CLK & SYNC are tied together by their
228c2ecf20Sopenharmony_ciphandles using a property called "renesas,bonding". For the rest of
238c2ecf20Sopenharmony_cithe documentation, unless explicitly stated, the word channel implies an
248c2ecf20Sopenharmony_ciinternal channel.
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciWhen both internal channels are enabled they need to be managed together
278c2ecf20Sopenharmony_cias one (i.e.) they cannot operate alone as independent devices. Out of the
288c2ecf20Sopenharmony_citwo, one of them needs to act as a primary device that accepts common
298c2ecf20Sopenharmony_ciproperties of both the internal channels. This channel is identified by a
308c2ecf20Sopenharmony_ciproperty called "renesas,primary-bond".
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciTo summarize,
338c2ecf20Sopenharmony_ci   - When both the internal channels that are bonded together are enabled,
348c2ecf20Sopenharmony_ci     the zeroth channel is selected as primary-bond. This channels accepts
358c2ecf20Sopenharmony_ci     properties common to all the members of the bond.
368c2ecf20Sopenharmony_ci   - When only one of the bonded channels need to be enabled, the property
378c2ecf20Sopenharmony_ci     "renesas,bonding" or "renesas,primary-bond" will have no effect. That
388c2ecf20Sopenharmony_ci     enabled channel can act alone as any other independent device.
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciRequired properties of an internal channel:
418c2ecf20Sopenharmony_ci-------------------------------------------
428c2ecf20Sopenharmony_ci- compatible:	"renesas,r8a7795-drif" if DRIF controller is a part of R8A7795 SoC.
438c2ecf20Sopenharmony_ci		"renesas,r8a7796-drif" if DRIF controller is a part of R8A7796 SoC.
448c2ecf20Sopenharmony_ci		"renesas,rcar-gen3-drif" for a generic R-Car Gen3 compatible device.
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci		When compatible with the generic version, nodes must list the
478c2ecf20Sopenharmony_ci		SoC-specific version corresponding to the platform first
488c2ecf20Sopenharmony_ci		followed by the generic version.
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci- reg: offset and length of that channel.
518c2ecf20Sopenharmony_ci- interrupts: associated with that channel.
528c2ecf20Sopenharmony_ci- clocks: phandle and clock specifier of that channel.
538c2ecf20Sopenharmony_ci- clock-names: clock input name string: "fck".
548c2ecf20Sopenharmony_ci- dmas: phandles to the DMA channels.
558c2ecf20Sopenharmony_ci- dma-names: names of the DMA channel: "rx".
568c2ecf20Sopenharmony_ci- renesas,bonding: phandle to the other channel.
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ciOptional properties of an internal channel:
598c2ecf20Sopenharmony_ci-------------------------------------------
608c2ecf20Sopenharmony_ci- power-domains: phandle to the respective power domain.
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ciRequired properties of an internal channel when:
638c2ecf20Sopenharmony_ci	- It is the only enabled channel of the bond (or)
648c2ecf20Sopenharmony_ci	- If it acts as primary among enabled bonds
658c2ecf20Sopenharmony_ci--------------------------------------------------------
668c2ecf20Sopenharmony_ci- pinctrl-0: pin control group to be used for this channel.
678c2ecf20Sopenharmony_ci- pinctrl-names: must be "default".
688c2ecf20Sopenharmony_ci- renesas,primary-bond: empty property indicating the channel acts as primary
698c2ecf20Sopenharmony_ci			among the bonded channels.
708c2ecf20Sopenharmony_ci- port: child port node corresponding to the data input, in accordance with
718c2ecf20Sopenharmony_ci	the video interface bindings defined in
728c2ecf20Sopenharmony_ci	Documentation/devicetree/bindings/media/video-interfaces.txt. The port
738c2ecf20Sopenharmony_ci	node must contain at least one endpoint.
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ciOptional endpoint property:
768c2ecf20Sopenharmony_ci---------------------------
778c2ecf20Sopenharmony_ci- sync-active: Indicates sync signal polarity, 0/1 for low/high respectively.
788c2ecf20Sopenharmony_ci	       This property maps to SYNCAC bit in the hardware manual. The
798c2ecf20Sopenharmony_ci	       default is 1 (active high).
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciExample:
828c2ecf20Sopenharmony_ci--------
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci(1) Both internal channels enabled:
858c2ecf20Sopenharmony_ci-----------------------------------
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ciWhen interfacing with a third party tuner device with two data pins as shown
888c2ecf20Sopenharmony_cibelow.
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci+---------------------+                +---------------------+
918c2ecf20Sopenharmony_ci|                     |-----SCK------->|CLK                  |
928c2ecf20Sopenharmony_ci|       Master        |-----SS-------->|SYNC  DRIFn (slave)  |
938c2ecf20Sopenharmony_ci|                     |-----SD0------->|D0                   |
948c2ecf20Sopenharmony_ci|                     |-----SD1------->|D1                   |
958c2ecf20Sopenharmony_ci+---------------------+                +---------------------+
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	drif00: rif@e6f40000 {
988c2ecf20Sopenharmony_ci		compatible = "renesas,r8a7795-drif",
998c2ecf20Sopenharmony_ci			     "renesas,rcar-gen3-drif";
1008c2ecf20Sopenharmony_ci		reg = <0 0xe6f40000 0 0x64>;
1018c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
1028c2ecf20Sopenharmony_ci		clocks = <&cpg CPG_MOD 515>;
1038c2ecf20Sopenharmony_ci		clock-names = "fck";
1048c2ecf20Sopenharmony_ci		dmas = <&dmac1 0x20>, <&dmac2 0x20>;
1058c2ecf20Sopenharmony_ci		dma-names = "rx", "rx";
1068c2ecf20Sopenharmony_ci		power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
1078c2ecf20Sopenharmony_ci		renesas,bonding = <&drif01>;
1088c2ecf20Sopenharmony_ci		renesas,primary-bond;
1098c2ecf20Sopenharmony_ci		pinctrl-0 = <&drif0_pins>;
1108c2ecf20Sopenharmony_ci		pinctrl-names = "default";
1118c2ecf20Sopenharmony_ci		port {
1128c2ecf20Sopenharmony_ci			drif0_ep: endpoint {
1138c2ecf20Sopenharmony_ci			     remote-endpoint = <&tuner_ep>;
1148c2ecf20Sopenharmony_ci			};
1158c2ecf20Sopenharmony_ci		};
1168c2ecf20Sopenharmony_ci	};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	drif01: rif@e6f50000 {
1198c2ecf20Sopenharmony_ci		compatible = "renesas,r8a7795-drif",
1208c2ecf20Sopenharmony_ci			     "renesas,rcar-gen3-drif";
1218c2ecf20Sopenharmony_ci		reg = <0 0xe6f50000 0 0x64>;
1228c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
1238c2ecf20Sopenharmony_ci		clocks = <&cpg CPG_MOD 514>;
1248c2ecf20Sopenharmony_ci		clock-names = "fck";
1258c2ecf20Sopenharmony_ci		dmas = <&dmac1 0x22>, <&dmac2 0x22>;
1268c2ecf20Sopenharmony_ci		dma-names = "rx", "rx";
1278c2ecf20Sopenharmony_ci		power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
1288c2ecf20Sopenharmony_ci		renesas,bonding = <&drif00>;
1298c2ecf20Sopenharmony_ci	};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci(2) Internal channel 1 alone is enabled:
1338c2ecf20Sopenharmony_ci----------------------------------------
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ciWhen interfacing with a third party tuner device with one data pin as shown
1368c2ecf20Sopenharmony_cibelow.
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci+---------------------+                +---------------------+
1398c2ecf20Sopenharmony_ci|                     |-----SCK------->|CLK                  |
1408c2ecf20Sopenharmony_ci|       Master        |-----SS-------->|SYNC  DRIFn (slave)  |
1418c2ecf20Sopenharmony_ci|                     |                |D0 (unused)          |
1428c2ecf20Sopenharmony_ci|                     |-----SD-------->|D1                   |
1438c2ecf20Sopenharmony_ci+---------------------+                +---------------------+
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	drif00: rif@e6f40000 {
1468c2ecf20Sopenharmony_ci		compatible = "renesas,r8a7795-drif",
1478c2ecf20Sopenharmony_ci			     "renesas,rcar-gen3-drif";
1488c2ecf20Sopenharmony_ci		reg = <0 0xe6f40000 0 0x64>;
1498c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
1508c2ecf20Sopenharmony_ci		clocks = <&cpg CPG_MOD 515>;
1518c2ecf20Sopenharmony_ci		clock-names = "fck";
1528c2ecf20Sopenharmony_ci		dmas = <&dmac1 0x20>, <&dmac2 0x20>;
1538c2ecf20Sopenharmony_ci		dma-names = "rx", "rx";
1548c2ecf20Sopenharmony_ci		power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
1558c2ecf20Sopenharmony_ci		renesas,bonding = <&drif01>;
1568c2ecf20Sopenharmony_ci	};
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	drif01: rif@e6f50000 {
1598c2ecf20Sopenharmony_ci		compatible = "renesas,r8a7795-drif",
1608c2ecf20Sopenharmony_ci			     "renesas,rcar-gen3-drif";
1618c2ecf20Sopenharmony_ci		reg = <0 0xe6f50000 0 0x64>;
1628c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
1638c2ecf20Sopenharmony_ci		clocks = <&cpg CPG_MOD 514>;
1648c2ecf20Sopenharmony_ci		clock-names = "fck";
1658c2ecf20Sopenharmony_ci		dmas = <&dmac1 0x22>, <&dmac2 0x22>;
1668c2ecf20Sopenharmony_ci		dma-names = "rx", "rx";
1678c2ecf20Sopenharmony_ci		power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
1688c2ecf20Sopenharmony_ci		renesas,bonding = <&drif00>;
1698c2ecf20Sopenharmony_ci		pinctrl-0 = <&drif0_pins>;
1708c2ecf20Sopenharmony_ci		pinctrl-names = "default";
1718c2ecf20Sopenharmony_ci		port {
1728c2ecf20Sopenharmony_ci			drif0_ep: endpoint {
1738c2ecf20Sopenharmony_ci			     remote-endpoint = <&tuner_ep>;
1748c2ecf20Sopenharmony_ci			     sync-active = <0>;
1758c2ecf20Sopenharmony_ci			};
1768c2ecf20Sopenharmony_ci		};
1778c2ecf20Sopenharmony_ci	};
178