18c2ecf20Sopenharmony_ciOne-register-per-pin type device tree based pinctrl driver
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciRequired properties:
48c2ecf20Sopenharmony_ci- compatible : "pinctrl-single" or "pinconf-single".
58c2ecf20Sopenharmony_ci  "pinctrl-single" means that pinconf isn't supported.
68c2ecf20Sopenharmony_ci  "pinconf-single" means that generic pinconf is supported.
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci- reg : offset and length of the register set for the mux registers
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci- #pinctrl-cells : number of cells in addition to the index, set to 1
118c2ecf20Sopenharmony_ci  for pinctrl-single,pins and 2 for pinctrl-single,bits
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci- pinctrl-single,register-width : pinmux register access width in bits
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci- pinctrl-single,function-mask : mask of allowed pinmux function bits
168c2ecf20Sopenharmony_ci  in the pinmux register
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciOptional properties:
198c2ecf20Sopenharmony_ci- pinctrl-single,function-off : function off mode for disabled state if
208c2ecf20Sopenharmony_ci  available and same for all registers; if not specified, disabling of
218c2ecf20Sopenharmony_ci  pin functions is ignored
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci- pinctrl-single,bit-per-mux : boolean to indicate that one register controls
248c2ecf20Sopenharmony_ci  more than one pin, for which "pinctrl-single,function-mask" property specifies
258c2ecf20Sopenharmony_ci position mask of pin.
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci- pinctrl-single,drive-strength : array of value that are used to configure
288c2ecf20Sopenharmony_ci  drive strength in the pinmux register. They're value of drive strength
298c2ecf20Sopenharmony_ci  current and drive strength mask.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci		/* drive strength current, mask */
328c2ecf20Sopenharmony_ci		pinctrl-single,power-source = <0x30 0xf0>;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci- pinctrl-single,bias-pullup : array of value that are used to configure the
358c2ecf20Sopenharmony_ci  input bias pullup in the pinmux register.
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci		/* input, enabled pullup bits, disabled pullup bits, mask */
388c2ecf20Sopenharmony_ci		pinctrl-single,bias-pullup = <0 1 0 1>;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci- pinctrl-single,bias-pulldown : array of value that are used to configure the
418c2ecf20Sopenharmony_ci  input bias pulldown in the pinmux register.
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci		/* input, enabled pulldown bits, disabled pulldown bits, mask */
448c2ecf20Sopenharmony_ci		pinctrl-single,bias-pulldown = <2 2 0 2>;
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci  * Two bits to control input bias pullup and pulldown: User should use
478c2ecf20Sopenharmony_ci    pinctrl-single,bias-pullup & pinctrl-single,bias-pulldown. One bit means
488c2ecf20Sopenharmony_ci    pullup, and the other one bit means pulldown.
498c2ecf20Sopenharmony_ci  * Three bits to control input bias enable, pullup and pulldown. User should
508c2ecf20Sopenharmony_ci    use pinctrl-single,bias-pullup & pinctrl-single,bias-pulldown. Input bias
518c2ecf20Sopenharmony_ci    enable bit should be included in pullup or pulldown bits.
528c2ecf20Sopenharmony_ci  * Although driver could set PIN_CONFIG_BIAS_DISABLE, there's no property as
538c2ecf20Sopenharmony_ci    pinctrl-single,bias-disable. Because pinctrl single driver could implement
548c2ecf20Sopenharmony_ci    it by calling pulldown, pullup disabled.
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci- pinctrl-single,input-schmitt : array of value that are used to configure
578c2ecf20Sopenharmony_ci  input schmitt in the pinmux register. In some silicons, there're two input
588c2ecf20Sopenharmony_ci  schmitt value (rising-edge & falling-edge) in the pinmux register.
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci		/* input schmitt value, mask */
618c2ecf20Sopenharmony_ci		pinctrl-single,input-schmitt = <0x30 0x70>;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci- pinctrl-single,input-schmitt-enable : array of value that are used to
648c2ecf20Sopenharmony_ci  configure input schmitt enable or disable in the pinmux register.
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci		/* input, enable bits, disable bits, mask */
678c2ecf20Sopenharmony_ci		pinctrl-single,input-schmitt-enable = <0x30 0x40 0 0x70>;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci- pinctrl-single,low-power-mode : array of value that are used to configure
708c2ecf20Sopenharmony_ci  low power mode of this pin. For some silicons, the low power mode will
718c2ecf20Sopenharmony_ci  control the output of the pin when the pad including the pin enter low
728c2ecf20Sopenharmony_ci  power mode.
738c2ecf20Sopenharmony_ci		/* low power mode value, mask */
748c2ecf20Sopenharmony_ci		pinctrl-single,low-power-mode = <0x288 0x388>;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci- pinctrl-single,gpio-range : list of value that are used to configure a GPIO
778c2ecf20Sopenharmony_ci  range. They're value of subnode phandle, pin base in pinctrl device, pin
788c2ecf20Sopenharmony_ci  number in this range, GPIO function value of this GPIO range.
798c2ecf20Sopenharmony_ci  The number of parameters is depend on #pinctrl-single,gpio-range-cells
808c2ecf20Sopenharmony_ci  property.
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci		/* pin base, nr pins & gpio function */
838c2ecf20Sopenharmony_ci		pinctrl-single,gpio-range = <&range 0 3 0 &range 3 9 1>;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci- interrupt-controller : standard interrupt controller binding if using
868c2ecf20Sopenharmony_ci  interrupts for wake-up events for example. In this case pinctrl-single
878c2ecf20Sopenharmony_ci  is set up as a chained interrupt controller and the wake-up interrupts
888c2ecf20Sopenharmony_ci  can be requested by the drivers using request_irq().
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci- #interrupt-cells : standard interrupt binding if using interrupts
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ciThis driver assumes that there is only one register for each pin (unless the
938c2ecf20Sopenharmony_cipinctrl-single,bit-per-mux is set), and uses the common pinctrl bindings as
948c2ecf20Sopenharmony_cispecified in the pinctrl-bindings.txt document in this directory.
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciThe pin configuration nodes for pinctrl-single are specified as pinctrl
978c2ecf20Sopenharmony_ciregister offset and values using pinctrl-single,pins. Only the bits specified
988c2ecf20Sopenharmony_ciin pinctrl-single,function-mask are updated.
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ciWhen #pinctrl-cells = 1, then setting a pin for a device could be done with:
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci	pinctrl-single,pins = <0xdc 0x118>;
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciWhere 0xdc is the offset from the pinctrl register base address for the device
1058c2ecf20Sopenharmony_cipinctrl register, and 0x118 contains the desired value of the pinctrl register.
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ciWhen #pinctrl-cells = 2, then setting a pin for a device could be done with:
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci	pinctrl-single,pins = <0xdc 0x30 0x07>;
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ciWhere 0x30 is the pin configuration value and 0x07 is the pin mux mode value.
1128c2ecf20Sopenharmony_ciThese two values are OR'd together to produce the value stored at offset 0xdc.
1138c2ecf20Sopenharmony_ciSee the device example and static board pins example below for more information.
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciIn case when one register changes more than one pin's mux the
1168c2ecf20Sopenharmony_cipinctrl-single,bits need to be used which takes three parameters:
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	pinctrl-single,bits = <0xdc 0x18 0xff>;
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ciWhere 0xdc is the offset from the pinctrl register base address for the
1218c2ecf20Sopenharmony_cidevice pinctrl register, 0x18 is the desired value, and 0xff is the sub mask to
1228c2ecf20Sopenharmony_cibe used when applying this change to the register.
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ciOptional sub-node: In case some pins could be configured as GPIO in the pinmux
1268c2ecf20Sopenharmony_ciregister, those pins could be defined as a GPIO range. This sub-node is required
1278c2ecf20Sopenharmony_ciby pinctrl-single,gpio-range property.
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ciRequired properties in sub-node:
1308c2ecf20Sopenharmony_ci- #pinctrl-single,gpio-range-cells : the number of parameters after phandle in
1318c2ecf20Sopenharmony_ci  pinctrl-single,gpio-range property.
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci	range: gpio-range {
1348c2ecf20Sopenharmony_ci		#pinctrl-single,gpio-range-cells = <3>;
1358c2ecf20Sopenharmony_ci	};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ciExample:
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/* SoC common file */
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci/* first controller instance for pins in core domain */
1438c2ecf20Sopenharmony_cipmx_core: pinmux@4a100040 {
1448c2ecf20Sopenharmony_ci	compatible = "pinctrl-single";
1458c2ecf20Sopenharmony_ci	reg = <0x4a100040 0x0196>;
1468c2ecf20Sopenharmony_ci	#address-cells = <1>;
1478c2ecf20Sopenharmony_ci	#size-cells = <0>;
1488c2ecf20Sopenharmony_ci	#interrupt-cells = <1>;
1498c2ecf20Sopenharmony_ci	interrupt-controller;
1508c2ecf20Sopenharmony_ci	pinctrl-single,register-width = <16>;
1518c2ecf20Sopenharmony_ci	pinctrl-single,function-mask = <0xffff>;
1528c2ecf20Sopenharmony_ci};
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci/* second controller instance for pins in wkup domain */
1558c2ecf20Sopenharmony_cipmx_wkup: pinmux@4a31e040 {
1568c2ecf20Sopenharmony_ci	compatible = "pinctrl-single";
1578c2ecf20Sopenharmony_ci	reg = <0x4a31e040 0x0038>;
1588c2ecf20Sopenharmony_ci	#address-cells = <1>;
1598c2ecf20Sopenharmony_ci	#size-cells = <0>;
1608c2ecf20Sopenharmony_ci	#interrupt-cells = <1>;
1618c2ecf20Sopenharmony_ci	interrupt-controller;
1628c2ecf20Sopenharmony_ci	pinctrl-single,register-width = <16>;
1638c2ecf20Sopenharmony_ci	pinctrl-single,function-mask = <0xffff>;
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cicontrol_devconf0: pinmux@48002274 {
1678c2ecf20Sopenharmony_ci	compatible = "pinctrl-single";
1688c2ecf20Sopenharmony_ci	reg = <0x48002274 4>;	/* Single register */
1698c2ecf20Sopenharmony_ci	#address-cells = <1>;
1708c2ecf20Sopenharmony_ci	#size-cells = <0>;
1718c2ecf20Sopenharmony_ci	pinctrl-single,bit-per-mux;
1728c2ecf20Sopenharmony_ci	pinctrl-single,register-width = <32>;
1738c2ecf20Sopenharmony_ci	pinctrl-single,function-mask = <0x5F>;
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci/* third controller instance for pins in gpio domain */
1778c2ecf20Sopenharmony_cipmx_gpio: pinmux@d401e000 {
1788c2ecf20Sopenharmony_ci	compatible = "pinconf-single";
1798c2ecf20Sopenharmony_ci	reg = <0xd401e000 0x0330>;
1808c2ecf20Sopenharmony_ci	#address-cells = <1>;
1818c2ecf20Sopenharmony_ci	#size-cells = <1>;
1828c2ecf20Sopenharmony_ci	ranges;
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	pinctrl-single,register-width = <32>;
1858c2ecf20Sopenharmony_ci	pinctrl-single,function-mask = <7>;
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	/* sparse GPIO range could be supported */
1888c2ecf20Sopenharmony_ci	pinctrl-single,gpio-range = <&range 0 3 0 &range 3 9 1
1898c2ecf20Sopenharmony_ci				&range 12 1 0 &range 13 29 1
1908c2ecf20Sopenharmony_ci				&range 43 1 0 &range 44 49 1
1918c2ecf20Sopenharmony_ci				&range 94 1 1 &range 96 2 1>;
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	range: gpio-range {
1948c2ecf20Sopenharmony_ci		#pinctrl-single,gpio-range-cells = <3>;
1958c2ecf20Sopenharmony_ci	};
1968c2ecf20Sopenharmony_ci};
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* board specific .dts file */
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci&pmx_core {
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci	/*
2048c2ecf20Sopenharmony_ci	 * map all board specific static pins enabled by the pinctrl driver
2058c2ecf20Sopenharmony_ci	 * itself during the boot (or just set them up in the bootloader)
2068c2ecf20Sopenharmony_ci	 */
2078c2ecf20Sopenharmony_ci	pinctrl-names = "default";
2088c2ecf20Sopenharmony_ci	pinctrl-0 = <&board_pins>;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	board_pins: pinmux_board_pins {
2118c2ecf20Sopenharmony_ci		pinctrl-single,pins = <
2128c2ecf20Sopenharmony_ci			0x6c 0xf
2138c2ecf20Sopenharmony_ci			0x6e 0xf
2148c2ecf20Sopenharmony_ci			0x70 0xf
2158c2ecf20Sopenharmony_ci			0x72 0xf
2168c2ecf20Sopenharmony_ci		>;
2178c2ecf20Sopenharmony_ci	};
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	uart0_pins: pinmux_uart0_pins {
2208c2ecf20Sopenharmony_ci		pinctrl-single,pins = <
2218c2ecf20Sopenharmony_ci			0x208 0		/* UART0_RXD (IOCFG138) */
2228c2ecf20Sopenharmony_ci			0x20c 0		/* UART0_TXD (IOCFG139) */
2238c2ecf20Sopenharmony_ci		>;
2248c2ecf20Sopenharmony_ci		pinctrl-single,bias-pulldown = <0 2 2>;
2258c2ecf20Sopenharmony_ci		pinctrl-single,bias-pullup = <0 1 1>;
2268c2ecf20Sopenharmony_ci	};
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci	/* map uart2 pins */
2298c2ecf20Sopenharmony_ci	uart2_pins: pinmux_uart2_pins {
2308c2ecf20Sopenharmony_ci		pinctrl-single,pins = <
2318c2ecf20Sopenharmony_ci			0xd8 0x118
2328c2ecf20Sopenharmony_ci			0xda 0
2338c2ecf20Sopenharmony_ci			0xdc 0x118
2348c2ecf20Sopenharmony_ci			0xde 0
2358c2ecf20Sopenharmony_ci		>;
2368c2ecf20Sopenharmony_ci	};
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci&control_devconf0 {
2408c2ecf20Sopenharmony_ci	mcbsp1_pins: pinmux_mcbsp1_pins {
2418c2ecf20Sopenharmony_ci		pinctrl-single,bits = <
2428c2ecf20Sopenharmony_ci			0x00 0x18 0x18 /* FSR/CLKR signal from FSX/CLKX pin */
2438c2ecf20Sopenharmony_ci		>;
2448c2ecf20Sopenharmony_ci	};
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	mcbsp2_clks_pins: pinmux_mcbsp2_clks_pins {
2478c2ecf20Sopenharmony_ci		pinctrl-single,bits = <
2488c2ecf20Sopenharmony_ci			0x00 0x40 0x40 /* McBSP2 CLKS from McBSP_CLKS pin */
2498c2ecf20Sopenharmony_ci		>;
2508c2ecf20Sopenharmony_ci	};
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci};
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci&uart1 {
2558c2ecf20Sopenharmony_ci       pinctrl-names = "default";
2568c2ecf20Sopenharmony_ci       pinctrl-0 = <&uart0_pins>;
2578c2ecf20Sopenharmony_ci};
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci&uart2 {
2608c2ecf20Sopenharmony_ci       pinctrl-names = "default";
2618c2ecf20Sopenharmony_ci       pinctrl-0 = <&uart2_pins>;
2628c2ecf20Sopenharmony_ci};
263