162306a36Sopenharmony_ci* Atmel AT91 Pinmux Controller
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciThe AT91 Pinmux Controller, enables the IC
462306a36Sopenharmony_cito share one PAD to several functional blocks. The sharing is done by
562306a36Sopenharmony_cimultiplexing the PAD input/output signals. For each PAD there are up to
662306a36Sopenharmony_ci8 muxing options (called periph modes). Since different modules require
762306a36Sopenharmony_cidifferent PAD settings (like pull up, keeper, etc) the controller controls
862306a36Sopenharmony_cialso the PAD settings parameters.
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciPlease refer to pinctrl-bindings.txt in this directory for details of the
1162306a36Sopenharmony_cicommon pinctrl bindings used by client devices, including the meaning of the
1262306a36Sopenharmony_ciphrase "pin configuration node".
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciAtmel AT91 pin configuration node is a node of a group of pins which can be
1562306a36Sopenharmony_ciused for a specific device or function. This node represents both mux and config
1662306a36Sopenharmony_ciof the pins in that group. The 'pins' selects the function mode(also named pin
1762306a36Sopenharmony_cimode) this pin can work on and the 'config' configures various pad settings
1862306a36Sopenharmony_cisuch as pull-up, multi drive, etc.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciRequired properties for iomux controller:
2162306a36Sopenharmony_ci- compatible: "atmel,at91rm9200-pinctrl" or "atmel,at91sam9x5-pinctrl"
2262306a36Sopenharmony_ci		or "atmel,sama5d3-pinctrl" or "microchip,sam9x60-pinctrl"
2362306a36Sopenharmony_ci- atmel,mux-mask: array of mask (periph per bank) to describe if a pin can be
2462306a36Sopenharmony_ci  configured in this periph mode. All the periph and bank need to be describe.
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciHow to create such array:
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciEach column will represent the possible peripheral of the pinctrl
2962306a36Sopenharmony_ciEach line will represent a pio bank
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ciTake an example on the 9260
3262306a36Sopenharmony_ciPeripheral: 2 ( A and B)
3362306a36Sopenharmony_ciBank: 3 (A, B and C)
3462306a36Sopenharmony_ci=>
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci  /*    A         B     */
3762306a36Sopenharmony_ci  0xffffffff 0xffc00c3b  /* pioA */
3862306a36Sopenharmony_ci  0xffffffff 0x7fff3ccf  /* pioB */
3962306a36Sopenharmony_ci  0xffffffff 0x007fffff  /* pioC */
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ciFor each peripheral/bank we will describe in a u32 if a pin can be
4262306a36Sopenharmony_ciconfigured in it by putting 1 to the pin bit (1 << pin)
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciLet's take the pioA on peripheral B
4562306a36Sopenharmony_ciFrom the datasheet Table 10-2.
4662306a36Sopenharmony_ciPeripheral B
4762306a36Sopenharmony_ciPA0	MCDB0
4862306a36Sopenharmony_ciPA1	MCCDB
4962306a36Sopenharmony_ciPA2
5062306a36Sopenharmony_ciPA3	MCDB3
5162306a36Sopenharmony_ciPA4	MCDB2
5262306a36Sopenharmony_ciPA5	MCDB1
5362306a36Sopenharmony_ciPA6
5462306a36Sopenharmony_ciPA7
5562306a36Sopenharmony_ciPA8
5662306a36Sopenharmony_ciPA9
5762306a36Sopenharmony_ciPA10	ETX2
5862306a36Sopenharmony_ciPA11	ETX3
5962306a36Sopenharmony_ciPA12
6062306a36Sopenharmony_ciPA13
6162306a36Sopenharmony_ciPA14
6262306a36Sopenharmony_ciPA15
6362306a36Sopenharmony_ciPA16
6462306a36Sopenharmony_ciPA17
6562306a36Sopenharmony_ciPA18
6662306a36Sopenharmony_ciPA19
6762306a36Sopenharmony_ciPA20
6862306a36Sopenharmony_ciPA21
6962306a36Sopenharmony_ciPA22	ETXER
7062306a36Sopenharmony_ciPA23	ETX2
7162306a36Sopenharmony_ciPA24	ETX3
7262306a36Sopenharmony_ciPA25	ERX2
7362306a36Sopenharmony_ciPA26	ERX3
7462306a36Sopenharmony_ciPA27	ERXCK
7562306a36Sopenharmony_ciPA28	ECRS
7662306a36Sopenharmony_ciPA29	ECOL
7762306a36Sopenharmony_ciPA30	RXD4
7862306a36Sopenharmony_ciPA31	TXD4
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci=> 0xffc00c3b
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciRequired properties for pin configuration node:
8362306a36Sopenharmony_ci- atmel,pins: 4 integers array, represents a group of pins mux and config
8462306a36Sopenharmony_ci  setting. The format is atmel,pins = <PIN_BANK PIN_BANK_NUM PERIPH CONFIG>.
8562306a36Sopenharmony_ci  The PERIPH 0 means gpio, PERIPH 1 is periph A, PERIPH 2 is periph B...
8662306a36Sopenharmony_ci  PIN_BANK 0 is pioA, PIN_BANK 1 is pioB...
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ciBits used for CONFIG:
8962306a36Sopenharmony_ciPULL_UP		(1 << 0): indicate this pin needs a pull up.
9062306a36Sopenharmony_ciMULTIDRIVE	(1 << 1): indicate this pin needs to be configured as multi-drive.
9162306a36Sopenharmony_ci			Multi-drive is equivalent to open-drain type output.
9262306a36Sopenharmony_ciDEGLITCH	(1 << 2): indicate this pin needs deglitch.
9362306a36Sopenharmony_ciPULL_DOWN	(1 << 3): indicate this pin needs a pull down.
9462306a36Sopenharmony_ciDIS_SCHMIT	(1 << 4): indicate this pin needs to the disable schmitt trigger.
9562306a36Sopenharmony_ciDRIVE_STRENGTH (3 << 5): indicate the drive strength of the pin using the
9662306a36Sopenharmony_ci			following values:
9762306a36Sopenharmony_ci				00 - No change (reset state value kept)
9862306a36Sopenharmony_ci				01 - Low
9962306a36Sopenharmony_ci				10 - Medium
10062306a36Sopenharmony_ci				11 - High
10162306a36Sopenharmony_ciOUTPUT		(1 << 7): indicate this pin need to be configured as an output.
10262306a36Sopenharmony_ciOUTPUT_VAL	(1 << 8): output val (1 = high, 0 = low)
10362306a36Sopenharmony_ciSLEWRATE	(1 << 9): slew rate of the pin: 0 = disable, 1 = enable
10462306a36Sopenharmony_ciDEBOUNCE	(1 << 16): indicate this pin needs debounce.
10562306a36Sopenharmony_ciDEBOUNCE_VAL	(0x3fff << 17): debounce value.
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ciNOTE:
10862306a36Sopenharmony_ciSome requirements for using atmel,at91rm9200-pinctrl binding:
10962306a36Sopenharmony_ci1. We have pin function node defined under at91 controller node to represent
11062306a36Sopenharmony_ci   what pinmux functions this SoC supports.
11162306a36Sopenharmony_ci2. The driver can use the function node's name and pin configuration node's
11262306a36Sopenharmony_ci   name describe the pin function and group hierarchy.
11362306a36Sopenharmony_ci   For example, Linux at91 pinctrl driver takes the function node's name
11462306a36Sopenharmony_ci   as the function name and pin configuration node's name as group name to
11562306a36Sopenharmony_ci   create the map table.
11662306a36Sopenharmony_ci3. Each pin configuration node should have a phandle, devices can set pins
11762306a36Sopenharmony_ci   configurations by referring to the phandle of that pin configuration node.
11862306a36Sopenharmony_ci4. The gpio controller must be describe in the pinctrl simple-bus.
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ciFor each bank the required properties are:
12162306a36Sopenharmony_ci- compatible: "atmel,at91sam9x5-gpio" or "atmel,at91rm9200-gpio" or
12262306a36Sopenharmony_ci  "microchip,sam9x60-gpio"
12362306a36Sopenharmony_ci- reg: physical base address and length of the controller's registers
12462306a36Sopenharmony_ci- interrupts: interrupt outputs from the controller
12562306a36Sopenharmony_ci- interrupt-controller: marks the device node as an interrupt controller
12662306a36Sopenharmony_ci- #interrupt-cells: should be 2; refer to ../interrupt-controller/interrupts.txt
12762306a36Sopenharmony_ci  for more details.
12862306a36Sopenharmony_ci- gpio-controller
12962306a36Sopenharmony_ci- #gpio-cells: should be 2; the first cell is the GPIO number and the second
13062306a36Sopenharmony_ci  cell specifies GPIO flags as defined in <dt-bindings/gpio/gpio.h>.
13162306a36Sopenharmony_ci- clocks: bank clock
13262306a36Sopenharmony_ci
13362306a36Sopenharmony_ciExamples:
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_cipinctrl@fffff400 {
13662306a36Sopenharmony_ci	#address-cells = <1>;
13762306a36Sopenharmony_ci	#size-cells = <1>;
13862306a36Sopenharmony_ci	ranges;
13962306a36Sopenharmony_ci	compatible = "atmel,at91rm9200-pinctrl", "simple-bus";
14062306a36Sopenharmony_ci	reg = <0xfffff400 0x600>;
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci	pioA: gpio@fffff400 {
14362306a36Sopenharmony_ci		compatible = "atmel,at91sam9x5-gpio";
14462306a36Sopenharmony_ci		reg = <0xfffff400 0x200>;
14562306a36Sopenharmony_ci		interrupts = <2 IRQ_TYPE_LEVEL_HIGH 1>;
14662306a36Sopenharmony_ci		#gpio-cells = <2>;
14762306a36Sopenharmony_ci		gpio-controller;
14862306a36Sopenharmony_ci		interrupt-controller;
14962306a36Sopenharmony_ci		#interrupt-cells = <2>;
15062306a36Sopenharmony_ci		clocks = <&pmc PMC_TYPE_PERIPHERAL 2>;
15162306a36Sopenharmony_ci	};
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci	atmel,mux-mask = <
15462306a36Sopenharmony_ci	      /*    A         B     */
15562306a36Sopenharmony_ci	       0xffffffff 0xffc00c3b  /* pioA */
15662306a36Sopenharmony_ci	       0xffffffff 0x7fff3ccf  /* pioB */
15762306a36Sopenharmony_ci	       0xffffffff 0x007fffff  /* pioC */
15862306a36Sopenharmony_ci	      >;
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci	/* shared pinctrl settings */
16162306a36Sopenharmony_ci	dbgu {
16262306a36Sopenharmony_ci		pinctrl_dbgu: dbgu-0 {
16362306a36Sopenharmony_ci			atmel,pins =
16462306a36Sopenharmony_ci				<1 14 0x1 0x0	/* PB14 periph A */
16562306a36Sopenharmony_ci				 1 15 0x1 0x1>;	/* PB15 periph A with pullup */
16662306a36Sopenharmony_ci		};
16762306a36Sopenharmony_ci	};
16862306a36Sopenharmony_ci};
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_cidbgu: serial@fffff200 {
17162306a36Sopenharmony_ci	compatible = "atmel,at91sam9260-usart";
17262306a36Sopenharmony_ci	reg = <0xfffff200 0x200>;
17362306a36Sopenharmony_ci	interrupts = <1 4 7>;
17462306a36Sopenharmony_ci	pinctrl-names = "default";
17562306a36Sopenharmony_ci	pinctrl-0 = <&pinctrl_dbgu>;
17662306a36Sopenharmony_ci};
177