18c2ecf20Sopenharmony_ci* Mediatek MT8183 Pin Controller
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciThe Mediatek's Pin controller is used to control SoC pins.
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ciRequired properties:
68c2ecf20Sopenharmony_ci- compatible: value should be one of the following.
78c2ecf20Sopenharmony_ci	"mediatek,mt8183-pinctrl", compatible with mt8183 pinctrl.
88c2ecf20Sopenharmony_ci- gpio-controller : Marks the device node as a gpio controller.
98c2ecf20Sopenharmony_ci- #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
108c2ecf20Sopenharmony_ci  binding is used, the amount of cells must be specified as 2. See the below
118c2ecf20Sopenharmony_ci  mentioned gpio binding representation for description of particular cells.
128c2ecf20Sopenharmony_ci- gpio-ranges : gpio valid number range.
138c2ecf20Sopenharmony_ci- reg: physical address base for gpio base registers. There are 10 GPIO
148c2ecf20Sopenharmony_ci  physical address base in mt8183.
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ciOptional properties:
178c2ecf20Sopenharmony_ci- reg-names: gpio base register names. There are 10 gpio base register
188c2ecf20Sopenharmony_ci  names in mt8183. They are "iocfg0", "iocfg1", "iocfg2", "iocfg3", "iocfg4",
198c2ecf20Sopenharmony_ci  "iocfg5", "iocfg6", "iocfg7", "iocfg8", "eint".
208c2ecf20Sopenharmony_ci- interrupt-controller: Marks the device node as an interrupt controller
218c2ecf20Sopenharmony_ci- #interrupt-cells: Should be two.
228c2ecf20Sopenharmony_ci- interrupts : The interrupt outputs to sysirq.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciPlease refer to pinctrl-bindings.txt in this directory for details of the
258c2ecf20Sopenharmony_cicommon pinctrl bindings used by client devices.
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciSubnode format
288c2ecf20Sopenharmony_ciA pinctrl node should contain at least one subnodes representing the
298c2ecf20Sopenharmony_cipinctrl groups available on the machine. Each subnode will list the
308c2ecf20Sopenharmony_cipins it needs, and how they should be configured, with regard to muxer
318c2ecf20Sopenharmony_ciconfiguration, pullups, drive strength, input enable/disable and input schmitt.
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci    node {
348c2ecf20Sopenharmony_ci	pinmux = <PIN_NUMBER_PINMUX>;
358c2ecf20Sopenharmony_ci	GENERIC_PINCONFIG;
368c2ecf20Sopenharmony_ci    };
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ciRequired properties:
398c2ecf20Sopenharmony_ci- pinmux: integer array, represents gpio pin number and mux setting.
408c2ecf20Sopenharmony_ci    Supported pin number and mux varies for different SoCs, and are defined
418c2ecf20Sopenharmony_ci    as macros in boot/dts/<soc>-pinfunc.h directly.
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciOptional properties:
448c2ecf20Sopenharmony_ci- GENERIC_PINCONFIG: is the generic pinconfig options to use, bias-disable,
458c2ecf20Sopenharmony_ci    bias-pull-down, bias-pull-up, input-enable, input-disable, output-low,
468c2ecf20Sopenharmony_ci    output-high, input-schmitt-enable, input-schmitt-disable
478c2ecf20Sopenharmony_ci    and drive-strength are valid.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci    Some special pins have extra pull up strength, there are R0 and R1 pull-up
508c2ecf20Sopenharmony_ci    resistors available, but for user, it's only need to set R1R0 as 00, 01,
518c2ecf20Sopenharmony_ci    10 or 11. So It needs config "mediatek,pull-up-adv" or
528c2ecf20Sopenharmony_ci    "mediatek,pull-down-adv" to support arguments for those special pins.
538c2ecf20Sopenharmony_ci    Valid arguments are from 0 to 3.
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci    mediatek,tdsel: An integer describing the steps for output level shifter
568c2ecf20Sopenharmony_ci      duty cycle when asserted (high pulse width adjustment). Valid arguments
578c2ecf20Sopenharmony_ci      are from 0 to 15.
588c2ecf20Sopenharmony_ci    mediatek,rdsel: An integer describing the steps for input level shifter
598c2ecf20Sopenharmony_ci      duty cycle when asserted (high pulse width adjustment). Valid arguments
608c2ecf20Sopenharmony_ci      are from 0 to 63.
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci    When config drive-strength, it can support some arguments, such as
638c2ecf20Sopenharmony_ci    MTK_DRIVE_4mA, MTK_DRIVE_6mA, etc. See dt-bindings/pinctrl/mt65xx.h.
648c2ecf20Sopenharmony_ci    It can only support 2/4/6/8/10/12/14/16mA in mt8183.
658c2ecf20Sopenharmony_ci    For I2C pins, there are existing generic driving setup and the specific
668c2ecf20Sopenharmony_ci    driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA driving
678c2ecf20Sopenharmony_ci    adjustment in generic driving setup. But in specific driving setup,
688c2ecf20Sopenharmony_ci    they can support 0.125/0.25/0.5/1mA adjustment. If we enable specific
698c2ecf20Sopenharmony_ci    driving setup for I2C pins, the existing generic driving setup will be
708c2ecf20Sopenharmony_ci    disabled. For some special features, we need the I2C pins specific
718c2ecf20Sopenharmony_ci    driving setup. The specific driving setup is controlled by E1E0EN.
728c2ecf20Sopenharmony_ci    So we need add extra vendor driving preperty instead of
738c2ecf20Sopenharmony_ci    the generic driving property.
748c2ecf20Sopenharmony_ci    We can add "mediatek,drive-strength-adv = <XXX>;" to describe the specific
758c2ecf20Sopenharmony_ci    driving setup property. "XXX" means the value of E1E0EN. EN is 0 or 1.
768c2ecf20Sopenharmony_ci    It is used to enable or disable the specific driving setup.
778c2ecf20Sopenharmony_ci    E1E0 is used to describe the detail strength specification of the I2C pin.
788c2ecf20Sopenharmony_ci    When E1=0/E0=0, the strength is 0.125mA.
798c2ecf20Sopenharmony_ci    When E1=0/E0=1, the strength is 0.25mA.
808c2ecf20Sopenharmony_ci    When E1=1/E0=0, the strength is 0.5mA.
818c2ecf20Sopenharmony_ci    When E1=1/E0=1, the strength is 1mA.
828c2ecf20Sopenharmony_ci    So the valid arguments of "mediatek,drive-strength-adv" are from 0 to 7.
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ciExamples:
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#include "mt8183-pinfunc.h"
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci...
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	pio: pinctrl@10005000 {
918c2ecf20Sopenharmony_ci		compatible = "mediatek,mt8183-pinctrl";
928c2ecf20Sopenharmony_ci		reg = <0 0x10005000 0 0x1000>,
938c2ecf20Sopenharmony_ci		      <0 0x11f20000 0 0x1000>,
948c2ecf20Sopenharmony_ci		      <0 0x11e80000 0 0x1000>,
958c2ecf20Sopenharmony_ci		      <0 0x11e70000 0 0x1000>,
968c2ecf20Sopenharmony_ci		      <0 0x11e90000 0 0x1000>,
978c2ecf20Sopenharmony_ci		      <0 0x11d30000 0 0x1000>,
988c2ecf20Sopenharmony_ci		      <0 0x11d20000 0 0x1000>,
998c2ecf20Sopenharmony_ci		      <0 0x11c50000 0 0x1000>,
1008c2ecf20Sopenharmony_ci		      <0 0x11f30000 0 0x1000>,
1018c2ecf20Sopenharmony_ci		      <0 0x1000b000 0 0x1000>;
1028c2ecf20Sopenharmony_ci		reg-names = "iocfg0", "iocfg1", "iocfg2",
1038c2ecf20Sopenharmony_ci			    "iocfg3", "iocfg4", "iocfg5",
1048c2ecf20Sopenharmony_ci			    "iocfg6", "iocfg7", "iocfg8",
1058c2ecf20Sopenharmony_ci			    "eint";
1068c2ecf20Sopenharmony_ci		gpio-controller;
1078c2ecf20Sopenharmony_ci		#gpio-cells = <2>;
1088c2ecf20Sopenharmony_ci		gpio-ranges = <&pio 0 0 192>;
1098c2ecf20Sopenharmony_ci		interrupt-controller;
1108c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>;
1118c2ecf20Sopenharmony_ci		#interrupt-cells = <2>;
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci		i2c0_pins_a: i2c0 {
1148c2ecf20Sopenharmony_ci			pins1 {
1158c2ecf20Sopenharmony_ci				pinmux = <PINMUX_GPIO48__FUNC_SCL5>,
1168c2ecf20Sopenharmony_ci					 <PINMUX_GPIO49__FUNC_SDA5>;
1178c2ecf20Sopenharmony_ci				mediatek,pull-up-adv = <3>;
1188c2ecf20Sopenharmony_ci				mediatek,drive-strength-adv = <7>;
1198c2ecf20Sopenharmony_ci			};
1208c2ecf20Sopenharmony_ci		};
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci		i2c1_pins_a: i2c1 {
1238c2ecf20Sopenharmony_ci			pins {
1248c2ecf20Sopenharmony_ci				pinmux = <PINMUX_GPIO50__FUNC_SCL3>,
1258c2ecf20Sopenharmony_ci					 <PINMUX_GPIO51__FUNC_SDA3>;
1268c2ecf20Sopenharmony_ci				mediatek,pull-down-adv = <2>;
1278c2ecf20Sopenharmony_ci				mediatek,drive-strength-adv = <4>;
1288c2ecf20Sopenharmony_ci			};
1298c2ecf20Sopenharmony_ci		};
1308c2ecf20Sopenharmony_ci		...
1318c2ecf20Sopenharmony_ci	};
1328c2ecf20Sopenharmony_ci};
133