18c2ecf20Sopenharmony_ci* Rockchip Pinmux Controller
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThe Rockchip Pinmux Controller, enables the IC
48c2ecf20Sopenharmony_cito share one PAD to several functional blocks. The sharing is done by
58c2ecf20Sopenharmony_cimultiplexing the PAD input/output signals. For each PAD there are several
68c2ecf20Sopenharmony_cimuxing options with option 0 being the use as a GPIO.
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ciPlease refer to pinctrl-bindings.txt in this directory for details of the
98c2ecf20Sopenharmony_cicommon pinctrl bindings used by client devices, including the meaning of the
108c2ecf20Sopenharmony_ciphrase "pin configuration node".
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciThe Rockchip pin configuration node is a node of a group of pins which can be
138c2ecf20Sopenharmony_ciused for a specific device or function. This node represents both mux and
148c2ecf20Sopenharmony_ciconfig of the pins in that group. The 'pins' selects the function mode(also
158c2ecf20Sopenharmony_cinamed pin mode) this pin can work on and the 'config' configures various pad
168c2ecf20Sopenharmony_cisettings such as pull-up, etc.
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciThe pins are grouped into up to 5 individual pin banks which need to be
198c2ecf20Sopenharmony_cidefined as gpio sub-nodes of the pinmux controller.
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ciRequired properties for iomux controller:
228c2ecf20Sopenharmony_ci  - compatible: should be
238c2ecf20Sopenharmony_ci		"rockchip,px30-pinctrl":    for Rockchip PX30
248c2ecf20Sopenharmony_ci		"rockchip,rv1108-pinctrl":  for Rockchip RV1108
258c2ecf20Sopenharmony_ci		"rockchip,rk2928-pinctrl":  for Rockchip RK2928
268c2ecf20Sopenharmony_ci		"rockchip,rk3066a-pinctrl": for Rockchip RK3066a
278c2ecf20Sopenharmony_ci		"rockchip,rk3066b-pinctrl": for Rockchip RK3066b
288c2ecf20Sopenharmony_ci		"rockchip,rk3128-pinctrl":  for Rockchip RK3128
298c2ecf20Sopenharmony_ci		"rockchip,rk3188-pinctrl":  for Rockchip RK3188
308c2ecf20Sopenharmony_ci		"rockchip,rk3228-pinctrl":  for Rockchip RK3228
318c2ecf20Sopenharmony_ci		"rockchip,rk3288-pinctrl":  for Rockchip RK3288
328c2ecf20Sopenharmony_ci		"rockchip,rk3308-pinctrl":  for Rockchip RK3308
338c2ecf20Sopenharmony_ci		"rockchip,rk3328-pinctrl":  for Rockchip RK3328
348c2ecf20Sopenharmony_ci		"rockchip,rk3368-pinctrl":  for Rockchip RK3368
358c2ecf20Sopenharmony_ci		"rockchip,rk3399-pinctrl":  for Rockchip RK3399
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci  - rockchip,grf: phandle referencing a syscon providing the
388c2ecf20Sopenharmony_ci	 "general register files"
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciOptional properties for iomux controller:
418c2ecf20Sopenharmony_ci  - rockchip,pmu: phandle referencing a syscon providing the pmu registers
428c2ecf20Sopenharmony_ci	 as some SoCs carry parts of the iomux controller registers there.
438c2ecf20Sopenharmony_ci	 Required for at least rk3188 and rk3288. On the rk3368 this should
448c2ecf20Sopenharmony_ci	 point to the PMUGRF syscon.
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ciDeprecated properties for iomux controller:
478c2ecf20Sopenharmony_ci  - reg: first element is the general register space of the iomux controller
488c2ecf20Sopenharmony_ci	 It should be large enough to contain also separate pull registers.
498c2ecf20Sopenharmony_ci	 second element is the separate pull register space of the rk3188.
508c2ecf20Sopenharmony_ci	 Use rockchip,grf and rockchip,pmu described above instead.
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciRequired properties for gpio sub nodes:
538c2ecf20Sopenharmony_ci  - compatible: "rockchip,gpio-bank"
548c2ecf20Sopenharmony_ci  - reg: register of the gpio bank (different than the iomux registerset)
558c2ecf20Sopenharmony_ci  - interrupts: base interrupt of the gpio bank in the interrupt controller
568c2ecf20Sopenharmony_ci  - clocks: clock that drives this bank
578c2ecf20Sopenharmony_ci  - gpio-controller: identifies the node as a gpio controller and pin bank.
588c2ecf20Sopenharmony_ci  - #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
598c2ecf20Sopenharmony_ci    binding is used, the amount of cells must be specified as 2. See generic
608c2ecf20Sopenharmony_ci    GPIO binding documentation for description of particular cells.
618c2ecf20Sopenharmony_ci  - interrupt-controller: identifies the controller node as interrupt-parent.
628c2ecf20Sopenharmony_ci  - #interrupt-cells: the value of this property should be 2 and the interrupt
638c2ecf20Sopenharmony_ci    cells should use the standard two-cell scheme described in
648c2ecf20Sopenharmony_ci    bindings/interrupt-controller/interrupts.txt
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciDeprecated properties for gpio sub nodes:
678c2ecf20Sopenharmony_ci  - compatible: "rockchip,rk3188-gpio-bank0"
688c2ecf20Sopenharmony_ci  - reg: second element: separate pull register for rk3188 bank0, use
698c2ecf20Sopenharmony_ci	 rockchip,pmu described above instead
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ciRequired properties for pin configuration node:
728c2ecf20Sopenharmony_ci  - rockchip,pins: 3 integers array, represents a group of pins mux and config
738c2ecf20Sopenharmony_ci    setting. The format is rockchip,pins = <PIN_BANK PIN_BANK_IDX MUX &phandle>.
748c2ecf20Sopenharmony_ci    The MUX 0 means gpio and MUX 1 to N mean the specific device function.
758c2ecf20Sopenharmony_ci    The phandle of a node containing the generic pinconfig options
768c2ecf20Sopenharmony_ci    to use, as described in pinctrl-bindings.txt in this directory.
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ciExamples:
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#include <dt-bindings/pinctrl/rockchip.h>
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci...
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_cipinctrl@20008000 {
858c2ecf20Sopenharmony_ci	compatible = "rockchip,rk3066a-pinctrl";
868c2ecf20Sopenharmony_ci	rockchip,grf = <&grf>;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	#address-cells = <1>;
898c2ecf20Sopenharmony_ci	#size-cells = <1>;
908c2ecf20Sopenharmony_ci	ranges;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	gpio0: gpio0@20034000 {
938c2ecf20Sopenharmony_ci		compatible = "rockchip,gpio-bank";
948c2ecf20Sopenharmony_ci		reg = <0x20034000 0x100>;
958c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>;
968c2ecf20Sopenharmony_ci		clocks = <&clk_gates8 9>;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci		gpio-controller;
998c2ecf20Sopenharmony_ci		#gpio-cells = <2>;
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci		interrupt-controller;
1028c2ecf20Sopenharmony_ci		#interrupt-cells = <2>;
1038c2ecf20Sopenharmony_ci	};
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci	...
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci	pcfg_pull_default: pcfg_pull_default {
1088c2ecf20Sopenharmony_ci		bias-pull-pin-default
1098c2ecf20Sopenharmony_ci	};
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	uart2 {
1128c2ecf20Sopenharmony_ci		uart2_xfer: uart2-xfer {
1138c2ecf20Sopenharmony_ci			rockchip,pins = <1 RK_PB0 1 &pcfg_pull_default>,
1148c2ecf20Sopenharmony_ci					<1 RK_PB1 1 &pcfg_pull_default>;
1158c2ecf20Sopenharmony_ci		};
1168c2ecf20Sopenharmony_ci	};
1178c2ecf20Sopenharmony_ci};
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ciuart2: serial@20064000 {
1208c2ecf20Sopenharmony_ci	compatible = "snps,dw-apb-uart";
1218c2ecf20Sopenharmony_ci	reg = <0x20064000 0x400>;
1228c2ecf20Sopenharmony_ci	interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
1238c2ecf20Sopenharmony_ci	reg-shift = <2>;
1248c2ecf20Sopenharmony_ci	reg-io-width = <1>;
1258c2ecf20Sopenharmony_ci	clocks = <&mux_uart2>;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	pinctrl-names = "default";
1288c2ecf20Sopenharmony_ci	pinctrl-0 = <&uart2_xfer>;
1298c2ecf20Sopenharmony_ci};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ciExample for rk3188:
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci	pinctrl@20008000 {
1348c2ecf20Sopenharmony_ci		compatible = "rockchip,rk3188-pinctrl";
1358c2ecf20Sopenharmony_ci		rockchip,grf = <&grf>;
1368c2ecf20Sopenharmony_ci		rockchip,pmu = <&pmu>;
1378c2ecf20Sopenharmony_ci		#address-cells = <1>;
1388c2ecf20Sopenharmony_ci		#size-cells = <1>;
1398c2ecf20Sopenharmony_ci		ranges;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci		gpio0: gpio0@2000a000 {
1428c2ecf20Sopenharmony_ci			compatible = "rockchip,rk3188-gpio-bank0";
1438c2ecf20Sopenharmony_ci			reg = <0x2000a000 0x100>;
1448c2ecf20Sopenharmony_ci			interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>;
1458c2ecf20Sopenharmony_ci			clocks = <&clk_gates8 9>;
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci			gpio-controller;
1488c2ecf20Sopenharmony_ci			#gpio-cells = <2>;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci			interrupt-controller;
1518c2ecf20Sopenharmony_ci			#interrupt-cells = <2>;
1528c2ecf20Sopenharmony_ci		};
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci		gpio1: gpio1@2003c000 {
1558c2ecf20Sopenharmony_ci			compatible = "rockchip,gpio-bank";
1568c2ecf20Sopenharmony_ci			reg = <0x2003c000 0x100>;
1578c2ecf20Sopenharmony_ci			interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
1588c2ecf20Sopenharmony_ci			clocks = <&clk_gates8 10>;
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci			gpio-controller;
1618c2ecf20Sopenharmony_ci			#gpio-cells = <2>;
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci			interrupt-controller;
1648c2ecf20Sopenharmony_ci			#interrupt-cells = <2>;
1658c2ecf20Sopenharmony_ci		};
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci		...
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	};
170