18c2ecf20Sopenharmony_ci* Atmel AT91 Pinmux Controller
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThe AT91 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 up to
68c2ecf20Sopenharmony_ci8 muxing options (called periph modes). Since different modules require
78c2ecf20Sopenharmony_cidifferent PAD settings (like pull up, keeper, etc) the controller controls
88c2ecf20Sopenharmony_cialso the PAD settings parameters.
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciPlease refer to pinctrl-bindings.txt in this directory for details of the
118c2ecf20Sopenharmony_cicommon pinctrl bindings used by client devices, including the meaning of the
128c2ecf20Sopenharmony_ciphrase "pin configuration node".
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciAtmel AT91 pin configuration node is a node of a group of pins which can be
158c2ecf20Sopenharmony_ciused for a specific device or function. This node represents both mux and config
168c2ecf20Sopenharmony_ciof the pins in that group. The 'pins' selects the function mode(also named pin
178c2ecf20Sopenharmony_cimode) this pin can work on and the 'config' configures various pad settings
188c2ecf20Sopenharmony_cisuch as pull-up, multi drive, etc.
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciRequired properties for iomux controller:
218c2ecf20Sopenharmony_ci- compatible: "atmel,at91rm9200-pinctrl" or "atmel,at91sam9x5-pinctrl"
228c2ecf20Sopenharmony_ci		or "atmel,sama5d3-pinctrl" or "microchip,sam9x60-pinctrl"
238c2ecf20Sopenharmony_ci- atmel,mux-mask: array of mask (periph per bank) to describe if a pin can be
248c2ecf20Sopenharmony_ci  configured in this periph mode. All the periph and bank need to be describe.
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciHow to create such array:
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciEach column will represent the possible peripheral of the pinctrl
298c2ecf20Sopenharmony_ciEach line will represent a pio bank
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciTake an example on the 9260
328c2ecf20Sopenharmony_ciPeripheral: 2 ( A and B)
338c2ecf20Sopenharmony_ciBank: 3 (A, B and C)
348c2ecf20Sopenharmony_ci=>
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci  /*    A         B     */
378c2ecf20Sopenharmony_ci  0xffffffff 0xffc00c3b  /* pioA */
388c2ecf20Sopenharmony_ci  0xffffffff 0x7fff3ccf  /* pioB */
398c2ecf20Sopenharmony_ci  0xffffffff 0x007fffff  /* pioC */
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciFor each peripheral/bank we will describe in a u32 if a pin can be
428c2ecf20Sopenharmony_ciconfigured in it by putting 1 to the pin bit (1 << pin)
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ciLet's take the pioA on peripheral B
458c2ecf20Sopenharmony_ciFrom the datasheet Table 10-2.
468c2ecf20Sopenharmony_ciPeripheral B
478c2ecf20Sopenharmony_ciPA0	MCDB0
488c2ecf20Sopenharmony_ciPA1	MCCDB
498c2ecf20Sopenharmony_ciPA2
508c2ecf20Sopenharmony_ciPA3	MCDB3
518c2ecf20Sopenharmony_ciPA4	MCDB2
528c2ecf20Sopenharmony_ciPA5	MCDB1
538c2ecf20Sopenharmony_ciPA6
548c2ecf20Sopenharmony_ciPA7
558c2ecf20Sopenharmony_ciPA8
568c2ecf20Sopenharmony_ciPA9
578c2ecf20Sopenharmony_ciPA10	ETX2
588c2ecf20Sopenharmony_ciPA11	ETX3
598c2ecf20Sopenharmony_ciPA12
608c2ecf20Sopenharmony_ciPA13
618c2ecf20Sopenharmony_ciPA14
628c2ecf20Sopenharmony_ciPA15
638c2ecf20Sopenharmony_ciPA16
648c2ecf20Sopenharmony_ciPA17
658c2ecf20Sopenharmony_ciPA18
668c2ecf20Sopenharmony_ciPA19
678c2ecf20Sopenharmony_ciPA20
688c2ecf20Sopenharmony_ciPA21
698c2ecf20Sopenharmony_ciPA22	ETXER
708c2ecf20Sopenharmony_ciPA23	ETX2
718c2ecf20Sopenharmony_ciPA24	ETX3
728c2ecf20Sopenharmony_ciPA25	ERX2
738c2ecf20Sopenharmony_ciPA26	ERX3
748c2ecf20Sopenharmony_ciPA27	ERXCK
758c2ecf20Sopenharmony_ciPA28	ECRS
768c2ecf20Sopenharmony_ciPA29	ECOL
778c2ecf20Sopenharmony_ciPA30	RXD4
788c2ecf20Sopenharmony_ciPA31	TXD4
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci=> 0xffc00c3b
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ciRequired properties for pin configuration node:
838c2ecf20Sopenharmony_ci- atmel,pins: 4 integers array, represents a group of pins mux and config
848c2ecf20Sopenharmony_ci  setting. The format is atmel,pins = <PIN_BANK PIN_BANK_NUM PERIPH CONFIG>.
858c2ecf20Sopenharmony_ci  The PERIPH 0 means gpio, PERIPH 1 is periph A, PERIPH 2 is periph B...
868c2ecf20Sopenharmony_ci  PIN_BANK 0 is pioA, PIN_BANK 1 is pioB...
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciBits used for CONFIG:
898c2ecf20Sopenharmony_ciPULL_UP		(1 << 0): indicate this pin needs a pull up.
908c2ecf20Sopenharmony_ciMULTIDRIVE	(1 << 1): indicate this pin needs to be configured as multi-drive.
918c2ecf20Sopenharmony_ci			Multi-drive is equivalent to open-drain type output.
928c2ecf20Sopenharmony_ciDEGLITCH	(1 << 2): indicate this pin needs deglitch.
938c2ecf20Sopenharmony_ciPULL_DOWN	(1 << 3): indicate this pin needs a pull down.
948c2ecf20Sopenharmony_ciDIS_SCHMIT	(1 << 4): indicate this pin needs to the disable schmitt trigger.
958c2ecf20Sopenharmony_ciDRIVE_STRENGTH (3 << 5): indicate the drive strength of the pin using the
968c2ecf20Sopenharmony_ci			following values:
978c2ecf20Sopenharmony_ci				00 - No change (reset state value kept)
988c2ecf20Sopenharmony_ci				01 - Low
998c2ecf20Sopenharmony_ci				10 - Medium
1008c2ecf20Sopenharmony_ci				11 - High
1018c2ecf20Sopenharmony_ciOUTPUT		(1 << 7): indicate this pin need to be configured as an output.
1028c2ecf20Sopenharmony_ciOUTPUT_VAL	(1 << 8): output val (1 = high, 0 = low)
1038c2ecf20Sopenharmony_ciSLEWRATE	(1 << 9): slew rate of the pin: 0 = disable, 1 = enable
1048c2ecf20Sopenharmony_ciDEBOUNCE	(1 << 16): indicate this pin needs debounce.
1058c2ecf20Sopenharmony_ciDEBOUNCE_VAL	(0x3fff << 17): debounce value.
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ciNOTE:
1088c2ecf20Sopenharmony_ciSome requirements for using atmel,at91rm9200-pinctrl binding:
1098c2ecf20Sopenharmony_ci1. We have pin function node defined under at91 controller node to represent
1108c2ecf20Sopenharmony_ci   what pinmux functions this SoC supports.
1118c2ecf20Sopenharmony_ci2. The driver can use the function node's name and pin configuration node's
1128c2ecf20Sopenharmony_ci   name describe the pin function and group hierarchy.
1138c2ecf20Sopenharmony_ci   For example, Linux at91 pinctrl driver takes the function node's name
1148c2ecf20Sopenharmony_ci   as the function name and pin configuration node's name as group name to
1158c2ecf20Sopenharmony_ci   create the map table.
1168c2ecf20Sopenharmony_ci3. Each pin configuration node should have a phandle, devices can set pins
1178c2ecf20Sopenharmony_ci   configurations by referring to the phandle of that pin configuration node.
1188c2ecf20Sopenharmony_ci4. The gpio controller must be describe in the pinctrl simple-bus.
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ciFor each bank the required properties are:
1218c2ecf20Sopenharmony_ci- compatible: "atmel,at91sam9x5-gpio" or "atmel,at91rm9200-gpio" or
1228c2ecf20Sopenharmony_ci  "microchip,sam9x60-gpio"
1238c2ecf20Sopenharmony_ci- reg: physical base address and length of the controller's registers
1248c2ecf20Sopenharmony_ci- interrupts: interrupt outputs from the controller
1258c2ecf20Sopenharmony_ci- interrupt-controller: marks the device node as an interrupt controller
1268c2ecf20Sopenharmony_ci- #interrupt-cells: should be 2; refer to ../interrupt-controller/interrupts.txt
1278c2ecf20Sopenharmony_ci  for more details.
1288c2ecf20Sopenharmony_ci- gpio-controller
1298c2ecf20Sopenharmony_ci- #gpio-cells: should be 2; the first cell is the GPIO number and the second
1308c2ecf20Sopenharmony_ci  cell specifies GPIO flags as defined in <dt-bindings/gpio/gpio.h>.
1318c2ecf20Sopenharmony_ci- clocks: bank clock
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ciExamples:
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_cipinctrl@fffff400 {
1368c2ecf20Sopenharmony_ci	#address-cells = <1>;
1378c2ecf20Sopenharmony_ci	#size-cells = <1>;
1388c2ecf20Sopenharmony_ci	ranges;
1398c2ecf20Sopenharmony_ci	compatible = "atmel,at91rm9200-pinctrl", "simple-bus";
1408c2ecf20Sopenharmony_ci	reg = <0xfffff400 0x600>;
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci	pioA: gpio@fffff400 {
1438c2ecf20Sopenharmony_ci		compatible = "atmel,at91sam9x5-gpio";
1448c2ecf20Sopenharmony_ci		reg = <0xfffff400 0x200>;
1458c2ecf20Sopenharmony_ci		interrupts = <2 IRQ_TYPE_LEVEL_HIGH 1>;
1468c2ecf20Sopenharmony_ci		#gpio-cells = <2>;
1478c2ecf20Sopenharmony_ci		gpio-controller;
1488c2ecf20Sopenharmony_ci		interrupt-controller;
1498c2ecf20Sopenharmony_ci		#interrupt-cells = <2>;
1508c2ecf20Sopenharmony_ci		clocks = <&pmc PMC_TYPE_PERIPHERAL 2>;
1518c2ecf20Sopenharmony_ci	};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	atmel,mux-mask = <
1548c2ecf20Sopenharmony_ci	      /*    A         B     */
1558c2ecf20Sopenharmony_ci	       0xffffffff 0xffc00c3b  /* pioA */
1568c2ecf20Sopenharmony_ci	       0xffffffff 0x7fff3ccf  /* pioB */
1578c2ecf20Sopenharmony_ci	       0xffffffff 0x007fffff  /* pioC */
1588c2ecf20Sopenharmony_ci	      >;
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	/* shared pinctrl settings */
1618c2ecf20Sopenharmony_ci	dbgu {
1628c2ecf20Sopenharmony_ci		pinctrl_dbgu: dbgu-0 {
1638c2ecf20Sopenharmony_ci			atmel,pins =
1648c2ecf20Sopenharmony_ci				<1 14 0x1 0x0	/* PB14 periph A */
1658c2ecf20Sopenharmony_ci				 1 15 0x1 0x1>;	/* PB15 periph A with pullup */
1668c2ecf20Sopenharmony_ci		};
1678c2ecf20Sopenharmony_ci	};
1688c2ecf20Sopenharmony_ci};
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_cidbgu: serial@fffff200 {
1718c2ecf20Sopenharmony_ci	compatible = "atmel,at91sam9260-usart";
1728c2ecf20Sopenharmony_ci	reg = <0xfffff200 0x200>;
1738c2ecf20Sopenharmony_ci	interrupts = <1 4 7>;
1748c2ecf20Sopenharmony_ci	pinctrl-names = "default";
1758c2ecf20Sopenharmony_ci	pinctrl-0 = <&pinctrl_dbgu>;
1768c2ecf20Sopenharmony_ci};
177