code:
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright 2011 ST-Ericsson AB
 */

/dts-v1/;
#include "ste-db9500.dtsi"
#include "ste-href-ab8500.dtsi"
#include "ste-href-family-pinctrl.dtsi"

/ {
	model = "Calao Systems Snowball platform with device tree";
	compatible = "calaosystems,snowball-a9500", "st-ericsson,u9500";

	memory {
		device_type = "memory";
		reg = <0x00000000 0x20000000>;
	};

	battery: battery {
		compatible = "simple-battery";
		battery-type = "lithium-ion-polymer";
	};

	thermal-zones {
		battery-thermal {
			/* This zone will be polled by the battery temperature code */
			polling-delay = <0>;
			polling-delay-passive = <0>;
			thermal-sensors = <&bat_therm>;

			trips {
				battery-crit-hi {
					temperature = <70000>;
					hysteresis = <2000>;
					type = "critical";
				};
			};
		};
	};

	bat_therm: thermistor {
		compatible = "murata,ncp18wb473";
		io-channels = <&gpadc 0x02>; /* BatTemp */
		pullup-uv = <1800000>;
		pullup-ohm = <230000>;
		pulldown-ohm = <0>;
		#thermal-sensor-cells = <0>;
	};

	en_3v3_reg: en_3v3 {
		compatible = "regulator-fixed";
		regulator-name = "en-3v3-fixed-supply";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		/* AB8500 GPIOs start from 1 - offset 25 is GPIO26. */
		gpio = <&ab8500_gpio 25 0x4>;
		startup-delay-us = <5000>;
		enable-active-high;
	};

	gpio_keys {
		compatible = "gpio-keys";
		#address-cells = <1>;
		#size-cells = <0>;

		button@1 {
			debounce-interval = <50>;
			wakeup-source;
			linux,code = <2>;
			label = "userpb";
			gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
		};
		button@2 {
			debounce-interval = <50>;
			wakeup-source;
			linux,code = <3>;
			label = "extkb1";
			gpios = <&gpio4 23 GPIO_ACTIVE_HIGH>;
		};
		button@3 {
			debounce-interval = <50>;
			wakeup-source;
			linux,code = <4>;
			label = "extkb2";
			gpios = <&gpio4 24 GPIO_ACTIVE_HIGH>;
		};
		button@4 {
			debounce-interval = <50>;
			wakeup-source;
			linux,code = <5>;
			label = "extkb3";
			gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
		};
		button@5 {
			debounce-interval = <50>;
			wakeup-source;
			linux,code = <6>;
			label = "extkb4";
			gpios = <&gpio5 2 GPIO_ACTIVE_HIGH>;
		};
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&gpioled_snowball_mode>;
		used-led {
			label = "user_led";
			gpios = <&gpio4 14 GPIO_ACTIVE_HIGH>;
			default-state = "on";
			linux,default-trigger = "heartbeat";
		};
	};

	soc {
		/* Name the GPIO muxed rails on the Snowball board */
		gpio@8012e000 {
			/* GPIOs 0 - 31 */
			gpio-line-names = "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "",
				     "AP_GPIO31";
		};

		gpio@8012e080 {
			/* GPIOs 32 - 63 */
			gpio-line-names = "USR PB", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "";
		};

		gpio@8000e000 {
			/* GPIOs 64 - 95 */
			gpio-line-names = "", "", "", "", "AP_GPIO68", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "";
		};

		gpio@8000e100 {
			/* GPIOs 128 - 159 */
			gpio-line-names = "", "", "", "", "", "", "", "",
				     "", "", "", "", "IRQ_LAN", "RSTn_LAN",
				     "USR_LED", "", "", "", "", "", "",
				     "", "", "AP_GPIO151", "AP_GPIO152",
				     "", "", "", "", "", "", "";
		};

		gpio@8000e180 {
			/* GPIOs 160 - 191 */
			gpio-line-names = "", "AP_GPIO161", "AP_GPIO162",
				     "ACCELEROMETER_INT1_RDY",
				     "ACCELEROMETER_INT2", "MAG_DRDY",
				     "GYRO_DRDY", "RSTn_MLC", "RSTn_SLC",
				     "GYRO_INT", "UART_WAKE", "GBF_RESET",
				     "", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "";
		};

		gpio@8011e000 {
			/* GPIOs 192 - 223 */
			gpio-line-names = "HDTV_INTn", "", "", "", "HDTV_RST",
				     "", "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "", "",
				     "WLAN_RESETN", "WLAN_IRQ", "MMC_EN",
				     "MMC_CD", "", "", "", "", "";
		};

		gpio@8011e080 {
			/* GPIOs 224 - 255 */
			gpio-line-names = "", "", "", "", "SD_SEL", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "",
				     "", "", "", "", "", "", "", "";
		};

		msp0: msp@80123000 {
			pinctrl-names = "default";
			pinctrl-0 = <&msp0txrxtfstck_a_1_default>;
			status = "okay";
		};

		msp1: msp@80124000 {
			pinctrl-names = "default";
			pinctrl-0 = <&msp1txrx_a_1_default>;
			status = "okay";
		};

		msp2: msp@80117000 {
			pinctrl-names = "default";
			pinctrl-0 = <&msp2_a_1_default>;
		};

		msp3: msp@80125000 {
			status = "okay";
		};

		external-bus@50000000 {
			status = "okay";

			ethernet@0 {
				compatible = "smsc,lan9115";
				reg = <0 0x10000>;
				interrupts = <12 IRQ_TYPE_EDGE_RISING>;
				interrupt-parent = <&gpio4>;
				vdd33a-supply = <&en_3v3_reg>;
				vddvario-supply = <&db8500_vape_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&eth_snowball_mode>;

				reg-shift = <1>;
				reg-io-width = <2>;
				smsc,force-internal-phy;
				smsc,irq-active-high;
				smsc,irq-push-pull;

				clocks = <&prcc_pclk 3 0>;
			};
		};

		/* ST6G3244ME level translator for 1.8/2.9 V */
		vmmci: regulator-gpio {
			compatible = "regulator-gpio";

			/* GPIO228 SD_SEL */
			gpios = <&gpio7 4 GPIO_ACTIVE_HIGH>;
			/* GPIO217 MMC_EN */
			enable-gpio = <&gpio6 25 GPIO_ACTIVE_HIGH>;
			enable-active-high;

			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2900000>;
			regulator-name = "mmci-reg";
			regulator-type = "voltage";

			startup-delay-us = <100>;

			states = <1800000 0x1
				  2900000 0x0>;
		};

		// External Micro SD slot
		mmc@80126000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <4>;
			cap-sd-highspeed;
			cap-mmc-highspeed;
			sd-uhs-sdr12;
			sd-uhs-sdr25;
			/* All direction control is used */
			st,sig-dir-cmd;
			st,sig-dir-dat0;
			st,sig-dir-dat2;
			st,sig-dir-dat31;
			st,sig-pin-fbclk;
			full-pwr-cycle;
			vmmc-supply = <&ab8500_ldo_aux3_reg>;
			vqmmc-supply = <&vmmci>;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc0_a_1_default &sdi0_default_mode>;
			pinctrl-1 = <&mc0_a_1_sleep>;

			/* GPIO218 MMC_CD */
			cd-gpios  = <&gpio6 26 GPIO_ACTIVE_LOW>;

			status = "okay";
		};

		// WLAN SDIO channel
		mmc@80118000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <4>;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc1_a_1_default>;
			pinctrl-1 = <&mc1_a_1_sleep>;

			status = "okay";
		};

		// Unused PoP eMMC - register and put it to sleep by default */
		mmc@80005000 {
			arm,primecell-periphid = <0x10480180>;
			pinctrl-names = "default";
			pinctrl-0 = <&mc2_a_1_sleep>;

			status = "okay";
		};

		// On-board eMMC
		mmc@80114000 {
			arm,primecell-periphid = <0x10480180>;
		        max-frequency = <100000000>;
			bus-width = <8>;
			cap-mmc-highspeed;
			no-sdio;
			no-sd;
			vmmc-supply = <&ab8500_ldo_aux2_reg>;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc4_a_1_default>;
			pinctrl-1 = <&mc4_a_1_sleep>;

			status = "okay";
		};

		uart@80120000 {
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u0_a_1_default>;
			pinctrl-1 = <&u0_a_1_sleep>;
			status = "okay";
		};

		/* This UART is unused and thus left disabled */
		uart@80121000 {
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u1rxtx_a_1_default>;
			pinctrl-1 = <&u1rxtx_a_1_sleep>;
		};

		uart@80007000 {
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u2rxtx_c_1_default>;
			pinctrl-1 = <&u2rxtx_c_1_sleep>;
			status = "okay";
		};

		i2c@80004000 {
			pinctrl-names = "default","sleep";
			pinctrl-0 = <&i2c0_a_1_default>;
			pinctrl-1 = <&i2c0_a_1_sleep>;
			status = "okay";
		};

		i2c@80122000 {
			pinctrl-names = "default","sleep";
			pinctrl-0 = <&i2c1_b_2_default>;
			pinctrl-1 = <&i2c1_b_2_sleep>;
			status = "okay";
		};

		i2c@80128000 {
			pinctrl-names = "default","sleep";
			pinctrl-0 = <&i2c2_b_2_default>;
			pinctrl-1 = <&i2c2_b_2_sleep>;
			status = "okay";
			lsm303dlh@18 {
				/* Accelerometer */
				compatible = "st,lsm303dlh-accel";
				st,drdy-int-pin = <1>;
				reg = <0x18>;
				vdd-supply = <&ab8500_ldo_aux1_reg>;
				vddio-supply = <&db8500_vsmps2_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&accel_snowball_mode>;
				interrupt-parent = <&gpio5>;
				interrupts = <3 IRQ_TYPE_EDGE_RISING>, /* INT1 */
					     <4 IRQ_TYPE_EDGE_RISING>; /* INT2 */
			};
			lsm303dlh@1e {
				/* Magnetometer */
				compatible = "st,lsm303dlh-magn";
				reg = <0x1e>;
				vdd-supply = <&ab8500_ldo_aux1_reg>;
				vddio-supply = <&db8500_vsmps2_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&magneto_snowball_mode>;
				interrupt-parent = <&gpio5>;
				interrupts = <5 IRQ_TYPE_EDGE_RISING>; /* DRDY line */
			};
			l3g4200d@68 {
				/* Gyroscope */
				compatible = "st,l3g4200d-gyro";
				st,drdy-int-pin = <2>;
				reg = <0x68>;
				vdd-supply = <&ab8500_ldo_aux1_reg>;
				vddio-supply = <&db8500_vsmps2_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&gyro_snowball_mode>;
				interrupt-parent = <&gpio5>;
				interrupts = <6 IRQ_TYPE_EDGE_RISING>, /* DRDY line */
					     <9 IRQ_TYPE_EDGE_RISING>; /* INT1 */
			};
			lsp001wm@5c {
				/* Barometer/pressure sensor */
				compatible = "st,lps001wp-press";
				reg = <0x5c>;
				vdd-supply = <&ab8500_ldo_aux1_reg>;
				vddio-supply = <&db8500_vsmps2_reg>;
			};
		};

		i2c@80110000 {
			pinctrl-names = "default","sleep";
			pinctrl-0 = <&i2c3_c_2_default>;
			pinctrl-1 = <&i2c3_c_2_sleep>;
			status = "okay";
		};

		spi@80002000 {
			pinctrl-names = "default";
			pinctrl-0 = <&ssp0_snowball_mode>;
			status = "okay";
		};

		prcmu@80157000 {
			ab8500 {
				gpio {
					/*
					 * AB8500 GPIOs are numbered starting from 1, so the first
					 * index 0 is what in the datasheet is called "GPIO1", and
					 * the second is "GPIO2" and so forth. Confusingly, the
					 * Snowball schematic then names the "GPIO2" line "PM_GPIO1".
					 * while later naming "GPIO4" as "PM_GPIO4".
					 */
					gpio-line-names = "", /* AB8500 GPIO1 */
						     "PM_GPIO1", /* AB8500 GPIO2 */
						     "WLAN_CLK_REQ", /* AB8500 GPIO3 */
						     "PM_GPIO4", /* AB8500 GPIO4 */
						     "", "", "", "", "", "", "", "", "", "", "",
						     "EN_3V6", /* AB8500 GPIO16 */
						     "", "", "", "" ,"", "", "", "", "",
						     "EN_3V3", /* AB8500 GPIO26 */
						     "", "", "", "", "", "", "", "", "", "", "", "", "",
						     "PM_GPIO40", /* AB8500 GPIO40 */
						     "PM_GPIO41", /* AB8500 GPIO41 */
						     "PM_GPIO42"; /* AB8500 GPIO42 */
				};

				phy {
					pinctrl-names = "default", "sleep";
					pinctrl-0 = <&usb_a_1_default>;
					pinctrl-1 = <&usb_a_1_sleep>;
				};

				ext_regulators: regulator-external {
					ab8500_ext1_reg: ab8500_ext1 {
						regulator-name = "ab8500-ext-supply1";
					};

					ab8500_ext2_reg_reg: ab8500_ext2 {
						regulator-name = "ab8500-ext-supply2";
					};

					ab8500_ext3_reg_reg: ab8500_ext3 {
						regulator-name = "ab8500-ext-supply3";
					};
				};

				regulator {
					ab8500_ldo_aux1_reg: ab8500_ldo_aux1 {
						regulator-name = "V-DISPLAY";
					};

					ab8500_ldo_aux2_reg: ab8500_ldo_aux2 {
						regulator-name = "V-eMMC1";
					};

					ab8500_ldo_aux3_reg: ab8500_ldo_aux3 {
						regulator-name = "V-MMC-SD";
					};

					ab8500_ldo_intcore_reg: ab8500_ldo_intcore {
						regulator-name = "V-INTCORE";
					};

					ab8500_ldo_tvout_reg: ab8500_ldo_tvout {
						regulator-name = "V-TVOUT";
					};

					ab8500_ldo_audio_reg: ab8500_ldo_audio {
						regulator-name = "V-AUD";
					};

					ab8500_ldo_anamic1_reg: ab8500_ldo_anamic1 {
						regulator-name = "V-AMIC1";
					};

					ab8500_ldo_anamic2_reg: ab8500_ldo_anamic2 {
						regulator-name = "V-AMIC2";
					};

					ab8500_ldo_dmic_reg: ab8500_ldo_dmic {
						regulator-name = "V-DMIC";
					};

					ab8500_ldo_ana_reg: ab8500_ldo_ana {
						regulator-name = "V-CSI/DSI";
					};
				};
			};
		};

		pinctrl {
			/*
			 * Set this up using hogs, as time goes by and as seems fit, these
			 * can be moved over to being controlled by respective device.
			 */
			pinctrl-names = "default";
			pinctrl-0 = <&gbf_snowball_mode>,
				  <&wlan_snowball_mode>;

			ethernet {
				/*
				 * Mux in "SM" which is used for the
				 * SMSC911x Ethernet adapter
				 */
				eth_snowball_mode: eth_snowball {
					snowball_mux {
						function = "sm";
						groups = "sm_b_1";
					};
					/* LAN IRQ pin */
					snowball_cfg1 {
						pins = "GPIO140_B11";
						ste,config = <&in_nopull>;
					};
					/* LAN reset pin */
					snowball_cfg2 {
						pins = "GPIO141_C12";
						ste,config = <&gpio_out_hi>;
					};

				};
			};
			sdi0 {
				sdi0_default_mode: sdi0_default {
					snowball_mux {
						function = "mc0";
						/* Add the DAT31 pin even if it is not really used */
						groups = "mc0dat31dir_a_1";
					};
					snowball_cfg1 {
						pins = "GPIO21_AB3"; /* DAT31DIR */
						ste,config = <&out_hi>;
					};
					/* SD card detect GPIO pin, extend default state */
					snowball_cfg2 {
						pins = "GPIO218_AH11";
						ste,config = <&gpio_in_pu>;
					};
					/* VMMCI level-shifter enable */
					snowball_cfg3 {
						pins = "GPIO217_AH12";
						ste,config = <&gpio_out_hi>;
					};
					/* VMMCI level-shifter voltage select */
					snowball_cfg4 {
						pins = "GPIO228_AJ6";
						ste,config = <&gpio_out_hi>;
					};
				};
			};
			ssp0 {
				ssp0_snowball_mode: ssp0_snowball_default {
					snowball_mux {
						function = "ssp0";
						groups = "ssp0_a_1";
					};
					snowball_cfg1 {
						pins = "GPIO144_B13"; /* FRM */
						ste,config = <&gpio_out_hi>;
					};
					snowball_cfg2 {
						pins = "GPIO145_C13"; /* RXD */
						ste,config = <&in_pd>;
					};
					snowball_cfg3 {
						pins =
						"GPIO146_D13", /* TXD */
						"GPIO143_D12"; /* CLK */
						ste,config = <&out_lo>;
					};

				};
			};
			gpio_led {
				gpioled_snowball_mode: gpioled_default {
					snowball_cfg1 {
						pins = "GPIO142_C11";
						ste,config = <&gpio_out_hi>;
					};

				};
			};
			accelerometer {
				accel_snowball_mode: accel_snowball {
					/* Accelerometer lines */
					snowball_cfg1 {
						pins =
						"GPIO163_C20", /* ACCEL_IRQ1 */
						"GPIO164_B21"; /* ACCEL_IRQ2 */
						ste,config = <&gpio_in_pu>;
					};
				};
			};
			gyro {
				gyro_snowball_mode: gyro_snowball {
					snowball_cfg1 {
						pins =
						"GPIO166_A22", /* DRDY */
						"GPIO169_D22"; /* INT */
						ste,config = <&gpio_in_pu>;
					};
				};
			};
			magnetometer {
				magneto_snowball_mode: magneto_snowball {
					snowball_cfg1 {
						pins = "GPIO165_C21"; /* MAG_DRDY */
						ste,config = <&gpio_in_pu>;
					};
				};
			};
			gbf {
				gbf_snowball_mode: gbf_snowball {
					/*
					 * GBF (GPS, Bluetooth, FM-radio) interface,
					 * pull low to reset state
					 */
					snowball_cfg1 {
						pins = "GPIO171_D23"; /* GBF_ENA_RESET */
						ste,config = <&gpio_out_lo>;
					};
				 };
			};
			wlan {
				wlan_snowball_mode: wlan_snowball {
					/*
					 * Activate this mode with the WLAN chip.
					 * These are plain GPIO pins used by WLAN
					 */
					snowball_cfg1 {
						pins =
						"GPIO161_D21", /* WLAN_PMU_EN */
						"GPIO215_AH13"; /* WLAN_ENA */
						ste,config = <&gpio_out_lo>;
					};
					snowball_cfg2 {
						pins = "GPIO216_AG12"; /* WLAN_IRQ */
						ste,config = <&gpio_in_pu>;
					};
				};
			};
		};

		mcde@a0350000 {
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&lcd_default_mode>;
			pinctrl-1 = <&lcd_sleep_mode>;
		};
	};
};


code:
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Devicetree for the Samsung Galaxy Exhibit SGH-T599 also known as Codina-TMO,
 * the "TMO" shall be read "T-Mobile" as this phone was produced exlusively
 * for T-Mobile in the United States.
 *
 * This phone is closely related to the Codina, but has:
 * - No CPU speed cap, full ~1GHz rate
 * - Different power management IC, AB8505
 * - As AB8505 has a micro USB phy, no TI TSU6111
 * - Different power routing such as the removal of the external LDO for the
 *   touchscreen in favor of using the AB8505
 * - Using a regulator for the key backlight LED
 * - Using the Samsung S6D27A1 panel by default
 * - The panel is using one of the ordinary AB8505 regulators for 1.8V
 * - WiFi/Bluetooth combi chip upgraded to BCM4334
 * - GPIO for backlight control moved from 68 to 69
 */

/dts-v1/;
#include "ste-db8500.dtsi"
#include "ste-ab8505.dtsi"
#include "ste-dbx5x0-pinctrl.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
	model = "Samsung Galaxy Exhibit (SGH-T599)";
	compatible = "samsung,codina-tmo", "st-ericsson,u8500";

	chosen {
		stdout-path = &serial2;
	};

	battery: battery {
		compatible = "samsung,eb425161lu";
	};

	thermal-zones {
		battery-thermal {
			/* This zone will be polled by the battery temperature code */
			polling-delay = <0>;
			polling-delay-passive = <0>;
			thermal-sensors = <&bat_therm>;

			trips {
				battery-crit-hi {
					temperature = <70000>;
					hysteresis = <2000>;
					type = "critical";
				};
			};
		};
	};

	bat_therm: thermistor {
		compatible = "samsung,1404-001221";
		io-channels = <&gpadc 0x02>; /* BatTemp */
		pullup-uv = <1800000>;
		pullup-ohm = <230000>;
		pulldown-ohm = <0>;
		#thermal-sensor-cells = <0>;
	};

	/* TI TXS0206 level translator for 2.9 V */
	sd_level_translator: regulator-gpio {
		compatible = "regulator-fixed";

		/* GPIO87 EN */
		gpios = <&gpio2 23 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		regulator-name = "sd-level-translator";
		regulator-min-microvolt = <2900000>;
		regulator-max-microvolt = <2900000>;
		regulator-type = "voltage";

		startup-delay-us = <200>;

		pinctrl-names = "default";
		pinctrl-0 = <&sd_level_translator_default>;
	};

	/* External LDO MIC5366-3.3YMT for eMMC */
	ldo_3v3_reg: regulator-gpio-ldo-3v3 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VMEM_3V3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		gpios = <&gpio6 31 GPIO_ACTIVE_HIGH>;
		startup-delay-us = <5000>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&emmc_ldo_en_default_mode>;
	};

	/*
	 * External Ricoh RP152L010B-TR LCD LDO regulator for the display.
	 * LCD_PWR_EN controls both the 3.0V output.
	 */
	lcd_3v0_reg: regulator-gpio-lcd-3v0 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VREG_LCD_3.0V";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		/* GPIO219 controls this regulator */
		gpio = <&gpio6 27 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&lcd_pwr_en_default_mode>;
	};

	/*
	 * This regulator is a GPIO line that drives the Broadcom WLAN
	 * line WL_REG_ON high and enables the internal regulators
	 * inside the chip. Unfortunatley it is erroneously named
	 * WLAN_RST_N on the schematic but it is not a reset line.
	 *
	 * The voltage specified here is only used to determine the OCR mask,
	 * the for the SDIO connector, the chip is actually connected
	 * directly to VBAT.
	 */
	wl_reg: regulator-gpio-wlan {
		compatible = "regulator-fixed";
		regulator-name = "WL_REG_ON";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		startup-delay-us = <100000>;
		/* GPIO215 (WLAN_RST_N to WL_REG_ON) */
		gpio = <&gpio6 23 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&wlan_ldo_en_default>;
	};

	vibrator {
		compatible = "gpio-vibrator";
		/* GPIO195 "MOT_EN" */
		enable-gpios = <&gpio6 3 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&vibrator_default>;
	};

	gpio-keys {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_keys_default_mode>;

		button-home {
			linux,code = <KEY_HOME>;
			label = "HOME";
			/* GPIO91 */
			gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
		};
		button-volup {
			linux,code = <KEY_VOLUMEUP>;
			label = "VOL+";
			/* GPIO67 */
			gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
		};
		button-voldown {
			linux,code = <KEY_VOLUMEDOWN>;
			label = "VOL-";
			/* GPIO92 */
			gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
		};
	};

	led-touchkeys {
		compatible = "regulator-led";
		vled-supply = <&ab8500_ldo_aux4_reg>; // 3.3V
		default-state = "on";
		function = LED_FUNCTION_KBD_BACKLIGHT;
		color = <LED_COLOR_ID_WHITE>;
	};

	ktd253: backlight {
		compatible = "kinetic,ktd253";
		/* GPIO69 is used on Codina R0.4 and Codina TMO */
		enable-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
		/* Default to 13/32 brightness */
		default-brightness = <13>;
		pinctrl-names = "default";
		pinctrl-0 = <&ktd253_backlight_default_mode>;
	};

	/* Richtek RT8515GQW Flash LED Driver IC */
	flash {
		compatible = "richtek,rt8515";
		/* GPIO 140 */
		enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
		/* GPIO 141 */
		ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
		/*
		 * RFS is 16 kOhm and RTS is 100 kOhm giving
		 * the flash max current 343mA and torch max
		 * current 55 mA.
		 */
		richtek,rfs-ohms = <16000>;
		richtek,rts-ohms = <100000>;
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_flash_default_mode>;

		led {
			function = LED_FUNCTION_FLASH;
			color = <LED_COLOR_ID_WHITE>;
			flash-max-timeout-us = <250000>;
			flash-max-microamp = <343750>;
			led-max-microamp = <55000>;
		};
	};

	/* Bit-banged I2C on GPIO143 and GPIO144 also called "SUBPMU I2C" */
	i2c-gpio-0 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio4 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio4 15 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_0_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		/* TODO: this should also be used by the SM5103 Camera power management unit */
	};

	/* Bit-banged I2C on GPIO151 and GPIO152 also called "COMP I2C" */
	i2c-gpio-1 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio4 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio4 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_1_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		magnetometer@c {
			compatible = "alps,hscdtd008a";
			reg = <0x0c>;
			clock-frequency = <400000>;

			avdd-supply = <&ab8500_ldo_aux1_reg>; // 3V
			dvdd-supply = <&ab8500_ldo_aux8_reg>; // 1.8V
		};
	};

	spi {
		compatible = "spi-gpio";
		/* Clock on GPIO220, pin SCL */
		sck-gpios = <&gpio6 28 GPIO_ACTIVE_HIGH>;
		/* MOSI on GPIO224, pin SDI "slave data in" */
		mosi-gpios = <&gpio7 0 GPIO_ACTIVE_HIGH>;
		/* MISO on GPIO225, pin SDO "slave data out" */
		miso-gpios = <&gpio7 1 GPIO_ACTIVE_HIGH>;
		/* Chip select on GPIO201 */
		cs-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>;
		num-chipselects = <1>;

		pinctrl-names = "default";
		pinctrl-0 = <&spi_gpio_0_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		panel@0 {
			compatible = "samsung,s6d27a1";
			spi-max-frequency = <1200000>;
			/* TYPE 3: inverse clock polarity and phase */
			spi-cpha;
			spi-cpol;

			reg = <0>;
			vci-supply = <&lcd_3v0_reg>;
			vccio-supply = <&ab8500_ldo_aux6_reg>;

			/* Reset on GPIO139 */
			reset-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
			/* LCD_VGH/LCD_DETECT, ESD IRQ on GPIO93 */
			interrupt-parent = <&gpio2>;
			interrupts = <29 IRQ_TYPE_EDGE_RISING>;

			pinctrl-names = "default";
			pinctrl-0 = <&panel_default_mode>;
			backlight = <&ktd253>;

			port {
				panel_in: endpoint {
					remote-endpoint = <&display_out>;
				};
			};
		};
	};

	soc {
		/* External Micro SD slot */
		mmc@80126000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <4>;
			cap-sd-highspeed;
			cap-mmc-highspeed;
			st,sig-pin-fbclk;
			full-pwr-cycle;
			/* MMC is powered by AUX3 1.2V .. 2.91V */
			vmmc-supply = <&ab8500_ldo_aux3_reg>;
			/* 2.9 V level translator is using AUX3 at 2.9 V as well */
			vqmmc-supply = <&sd_level_translator>;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc0_a_2_default>;
			pinctrl-1 = <&mc0_a_2_sleep>;
			cd-gpios  = <&gpio6 25 GPIO_ACTIVE_LOW>; // GPIO217
			status = "okay";
		};

		/* WLAN SDIO channel */
		mmc@80118000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <50000000>;
			bus-width = <4>;
			non-removable;
			cap-sd-highspeed;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc1_a_2_default>;
			pinctrl-1 = <&mc1_a_2_sleep>;
			/*
			 * GPIO-controlled voltage enablement: this drives
			 * the WL_REG_ON line high when we use this device.
			 * Represented as regulator to fill OCR mask.
			 */
			vmmc-supply = <&wl_reg>;

			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			wifi@1 {
				compatible = "brcm,bcm4334-fmac", "brcm,bcm4329-fmac";
				reg = <1>;
				/* GPIO216 WL_HOST_WAKE */
				interrupt-parent = <&gpio6>;
				interrupts = <24 IRQ_TYPE_EDGE_FALLING>;
				interrupt-names = "host-wake";
				pinctrl-names = "default";
				pinctrl-0 = <&wlan_default_mode>;
			};
		};

		/* eMMC */
		mmc@80005000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <8>;
			non-removable;
			cap-mmc-highspeed;
			mmc-ddr-1_8v;
			no-sdio;
			no-sd;
			vmmc-supply = <&ldo_3v3_reg>;
			pinctrl-names = "default", "sleep";
			/*
			 * GPIO130 will be set to input no pull-up resulting in a resistor
			 * pulling the reset high and taking the memory out of reset.
			 */
			pinctrl-0 = <&mc2_a_1_default>;
			pinctrl-1 = <&mc2_a_1_sleep>;
			status = "okay";
		};

		/* GBF (Bluetooth) UART */
		uart@80120000 {
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u0_a_1_default>;
			pinctrl-1 = <&u0_a_1_sleep>;
			status = "okay";

			bluetooth {
				/* BCM4334B0 actually */
				compatible = "brcm,bcm4330-bt";
				/* GPIO222 rail BT_VREG_EN to BT_REG_ON */
				shutdown-gpios = <&gpio6 30 GPIO_ACTIVE_HIGH>;
				/* BT_WAKE on GPIO199 */
				device-wakeup-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
				/* BT_HOST_WAKE on GPIO97 */
				/* FIXME: convert to interrupt */
				host-wakeup-gpios = <&gpio3 1 GPIO_ACTIVE_HIGH>;
				/* BT_RST_N on GPIO209 */
				reset-gpios = <&gpio6 17 GPIO_ACTIVE_LOW>;
				pinctrl-names = "default";
				pinctrl-0 = <&bluetooth_default_mode>;
			};
		};

		/* GPS UART */
		uart@80121000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			/* CTS/RTS is not used, CTS is repurposed as GPIO */
			pinctrl-0 = <&u1rxtx_a_1_default>;
			pinctrl-1 = <&u1rxtx_a_1_sleep>;
			/* FIXME: add a device for the GPS here */
		};

		/* Debugging console UART connected to AB8505 */
		uart@80007000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u2rxtx_c_1_default>;
			pinctrl-1 = <&u2rxtx_c_1_sleep>;
		};

		prcmu@80157000 {
			ab8505 {
				phy {
					pinctrl-names = "default", "sleep";
					pinctrl-0 = <&usb_a_1_default>;
					pinctrl-1 = <&usb_a_1_sleep>;
				};

				ab8500_fg {
					line-impedance-micro-ohms = <36000>;
				};

				/* This is mostly identical to the Codina v0.4 regulators */
				regulator {
					ab8500_ldo_aux1 {
						regulator-name = "v-sensors-vdd";
						regulator-min-microvolt = <3000000>;
						regulator-max-microvolt = <3300000>;
					};

					ab8500_ldo_aux2 {
						regulator-name = "v-aux2";
						regulator-min-microvolt = <3300000>;
						regulator-max-microvolt = <3300000>;
					};

					ab8500_ldo_aux3 {
						regulator-name = "v-mmc-sd";
					};

					ab8500_ldo_aux4 {
						regulator-name = "v-aux4";
						/*
						 * Providing some span here makes the touchkey
						 * LEDs actually dimmable.
						 */
						regulator-min-microvolt = <1100000>;
						regulator-max-microvolt = <3300000>;
					};

					ab8500_ldo_aux5 {
						regulator-name = "v-aux5";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
					};

					ab8500_ldo_aux6 {
						/* 1.8 V to the display */
						regulator-name = "v-aux6";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
					};

					ab8500_ldo_aux8 {
						regulator-name = "v-sensors-vio";
					};
				};
			};
		};

		/* I2C0 also known as "AGC I2C" */
		i2c@80004000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c0_a_1_default>;
			pinctrl-1 = <&i2c0_a_1_sleep>;

			proximity@39 {
				/* Codina has the Amstaos TMD2672 */
				compatible = "amstaos,tmd2672";
				clock-frequency = <400000>;
				reg = <0x39>;

				/* IRQ on GPIO146 "PS_INT" */
				interrupt-parent = <&gpio4>;
				interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
				vdd-supply = <&ab8500_ldo_aux1_reg>;
				vddio-supply = <&ab8500_ldo_aux8_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&tmd2672_codina_default>;
			};
		};

		/* I2C2 on GPIO10 and GPIO11 also called "SENSORS I2C" */
		i2c@80128000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c2_b_2_default>;
			pinctrl-1 = <&i2c2_b_2_sleep>;

			/* Bosch BMA254 accelerometer */
			accelerometer@18 {
				compatible = "bosch,bma254";
				reg = <0x18>;
				mount-matrix = "0", "1", "0",
					       "-1", "0", "0",
					       "0", "0", "1";
				vddio-supply = <&ab8500_ldo_aux8_reg>; // 1.8V
				vdd-supply = <&ab8500_ldo_aux1_reg>; // 3V
			};
		};

		/* I2C3 */
		i2c@80110000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c3_c_2_default>;
			pinctrl-1 = <&i2c3_c_2_sleep>;

			/* TODO: write bindings and driver for this touchscreen */

			/* Zinitix BT404 ISP part */
			isp@50 {
				compatible = "zinitix,bt404-isp";
				reg = <0x50>;
				pinctrl-names = "default";
				pinctrl-0 = <&tsp_default>;
			};

			/* Zinitix BT404 touchscreen, also has the touchkeys for menu and back */
			touchscreen@20 {
				compatible = "zinitix,bt404";
				reg = <0x20>;
				/* GPIO218 (TSP_INT_1V8) */
				interrupt-parent = <&gpio6>;
				interrupts = <26 IRQ_TYPE_EDGE_FALLING>;
				vcca-supply = <&ab8500_ldo_aux2_reg>; // 3.3V
				vdd-supply = <&ab8500_ldo_aux5_reg>; // 1.8V
				zinitix,mode = <2>;
				touchscreen-size-x = <480>;
				touchscreen-size-y = <800>;
				pinctrl-names = "default";
				pinctrl-0 = <&tsp_default>;
			};
		};

		mcde@a0350000 {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&dpi_default_mode>;

			port {
				display_out: endpoint {
					remote-endpoint = <&panel_in>;
				};
			};
		};
	};
};

&pinctrl {
	/*
	 * This extends the MC0_A_2 default config to include
	 * the card detect GPIO217 line.
	 */
	sdi0 {
		mc0_a_2_default {
			default_cfg4 {
				pins = "GPIO217_AH12"; /* card detect */
				ste,config = <&gpio_in_pd>;
			};
		};
	};
	sdi2 {
		/*
		 * GPIO130 should be set in GPIO mode and
		 * pulled down. (Not connected.)
		 */
		mc2_a_1_default {
			default_cfg2 {
				pins = "GPIO130_C8"; /* FBCLK */
				ste,config = <&gpio_in_pd>;
			};
		};
	};
	/* GPIO that enables the 2.9V SD card level translator */
	sd-level-translator {
		sd_level_translator_default: sd_level_translator_default {
			/* level shifter on GPIO87 */
			codina_cfg1 {
				pins = "GPIO87_B3";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the eMMC */
	emmc-ldo {
		emmc_ldo_en_default_mode: emmc_ldo_default {
			/* LDO enable on GPIO223 */
			codina_cfg1 {
				pins = "GPIO223_AH9";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIOs for panel control */
	panel {
		panel_default_mode: panel_default {
			codina_cfg1 {
				/* Reset line */
				pins = "GPIO139_C9";
				ste,config = <&gpio_out_lo>;
			};
			codina_cfg2 {
				/* ESD IRQ line "LCD detect" */
				pins = "GPIO93_B7";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the LCD display */
	lcd-ldo {
		lcd_pwr_en_default_mode: lcd_pwr_en_default {
			/* LCD_PWR_EN on GPIO219 */
			codina_cfg1 {
				pins = "GPIO219_AG10";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the WLAN internal LDO regulators */
	wlan-ldo {
		wlan_ldo_en_default: wlan_ldo_default {
			/* GPIO215 named WLAN_RST_N */
			codina_cfg1 {
				pins = "GPIO215_AH13";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* Backlight GPIO */
	backlight {
		ktd253_backlight_default_mode: backlight_default {
			skomer_cfg1 {
				pins = "GPIO69_E2"; /* LCD_BL_CTRL */
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* Flash and torch */
	flash {
		gpio_flash_default_mode: flash_default {
			codina_cfg1 {
				pins = "GPIO140_B11", "GPIO141_C12";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* GPIO keys */
	gpio-keys {
		gpio_keys_default_mode: gpio_keys_default {
			skomer_cfg1 {
				pins = "GPIO67_G2", /* VOL UP */
				       "GPIO91_B6", /* HOME */
				       "GPIO92_D6"; /* VOL DOWN */
				ste,config = <&gpio_in_pu>;
			};
		};
	};
	/* Interrupt line for the Zinitix BT404 touchscreen */
	tsp {
		tsp_default: tsp_default {
			codina_cfg1 {
				pins = "GPIO218_AH11";	/* TSP_INT_1V8 */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* Interrupt line for light/proximity sensor TMD2672 */
	tmd2672 {
		tmd2672_codina_default: tmd2672_codina {
			codina_cfg1 {
				pins = "GPIO146_D13";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based I2C bus for subpmu */
	i2c-gpio-0 {
		i2c_gpio_0_default: i2c_gpio_0 {
			codina_cfg1 {
				pins = "GPIO143_D12", "GPIO144_B13";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based I2C bus for the NFC */
	i2c-gpio-1 {
		i2c_gpio_1_default: i2c_gpio_1 {
			codina_cfg1 {
				pins = "GPIO151_D17", "GPIO152_D16";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based SPI bus for the display */
	spi-gpio-0 {
		spi_gpio_0_default: spi_gpio_0_d {
			codina_cfg1 {
				pins = "GPIO220_AH10", "GPIO201_AF24", "GPIO224_AG9";
				ste,config = <&gpio_out_hi>;
			};
			codina_cfg2 {
				pins = "GPIO225_AG8";
				/* Needs pull down, no pull down resistor on board */
				ste,config = <&gpio_in_pd>;
			};
		};
		spi_gpio_0_sleep: spi_gpio_0_s {
			codina_cfg1 {
				pins = "GPIO220_AH10", "GPIO201_AF24",
				       "GPIO224_AG9", "GPIO225_AG8";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	wlan {
		wlan_default_mode: wlan_default {
			/* GPIO216 for WL_HOST_WAKE */
			codina_cfg2 {
				pins = "GPIO216_AG12";
				ste,config = <&gpio_in_pd>;
			};
		};
	};
	bluetooth {
		bluetooth_default_mode: bluetooth_default {
			/* GPIO199 BT_WAKE and GPIO222 BT_VREG_ON */
			codina_cfg1 {
				pins = "GPIO199_AH23", "GPIO222_AJ9";
				ste,config = <&gpio_out_lo>;
			};
			/* GPIO97 BT_HOST_WAKE */
			codina_cfg2 {
				pins = "GPIO97_D9";
				ste,config = <&gpio_in_nopull>;
			};
			/* GPIO209 BT_RST_N */
			codina_cfg3 {
				pins = "GPIO209_AG15";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	vibrator {
		vibrator_default: vibrator_default {
			codina_cfg1 {
				pins = "GPIO195_AG28";	/* MOT_EN */
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	mcde {
		dpi_default_mode: dpi_default {
			default_mux1 {
				/* Mux in all the data lines */
				function = "lcd";
				groups =
					/* Data lines D0-D7 GPIO70..GPIO77 */
					"lcd_d0_d7_a_1",
					/* Data lines D8-D11 GPIO78..GPIO81 */
					"lcd_d8_d11_a_1",
					/* Data lines D12-D15 GPIO82..GPIO85 */
					"lcd_d12_d15_a_1",
					/* Data lines D16-D23 GPIO161..GPIO168 */
					"lcd_d16_d23_b_1";
			};
			default_mux2 {
				function = "lcda";
				/* Clock line on GPIO150, DE, VSO, HSO on GPIO169..GPIO171 */
				groups = "lcdaclk_b_1", "lcda_b_1";
			};
			/* Input, no pull-up is the default state for pins used for an alt function */
			default_cfg1 {
				pins = "GPIO150_C14", "GPIO169_D22", "GPIO170_C23", "GPIO171_D23";
				ste,config = <&in_nopull>;
			};
		};
	};
};

repo_name: angery/linux


code:
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Devicetree for the Samsung Galaxy Ace 2 GT-I8160 also known as Codina.
 *
 * NOTE: this is the most common variant according to the vendor tree, known
 * as "R0.0". There appears to be a "R0.4" variant with backlight on GPIO69,
 * AB8505 and other changes. There is also talk about some variants having a
 * Samsung S6D27A1 display, indicated by passing a different command line from
 * the boot loader.
 *
 * The Samsung tree further talks about GT-I8160P and GT-I8160chn (China).
 * The GT-I8160 plain is known as the "europe" variant.
 * The GT-I8160P is the CDMA version and it appears to not use the ST
 * Microelectronics accelerometer and reportedly has NFC mounted.
 * The GT-I8160chn appears to be the same as the europe variant.
 *
 * There is also the Codina-TMO, Samsung SGH-T599, which has its own device
 * tree.
 */

/dts-v1/;
#include "ste-db8500.dtsi"
#include "ste-ab8500.dtsi"
#include "ste-dbx5x0-pinctrl.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
	model = "Samsung Galaxy Ace 2 (GT-I8160)";
	compatible = "samsung,codina", "st-ericsson,u8500";

	cpus {
		cpu@300 {
			/*
			 * This has a frequency cap at ~800 MHz in the firmware.
			 * (Changing this number here will not overclock it.)
			 */
			operating-points = <798720 0
					    399360 0
					    199680 0>;
		};
	};

	chosen {
		stdout-path = &serial2;
	};

	battery: battery {
		compatible = "samsung,eb425161lu";
	};

	thermal-zones {
		battery-thermal {
			/* This zone will be polled by the battery temperature code */
			polling-delay = <0>;
			polling-delay-passive = <0>;
			thermal-sensors = <&bat_therm>;

			trips {
				battery-crit-hi {
					temperature = <70000>;
					hysteresis = <2000>;
					type = "critical";
				};
			};
		};
	};

	bat_therm: thermistor {
		compatible = "samsung,1404-001221";
		io-channels = <&gpadc 0x02>; /* BatTemp */
		pullup-uv = <1800000>;
		pullup-ohm = <230000>;
		pulldown-ohm = <0>;
		#thermal-sensor-cells = <0>;
	};

	/* TI TXS0206 level translator for 2.9 V */
	sd_level_translator: regulator-gpio {
		compatible = "regulator-fixed";

		/* GPIO87 EN */
		gpios = <&gpio2 23 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		regulator-name = "sd-level-translator";
		regulator-min-microvolt = <2900000>;
		regulator-max-microvolt = <2900000>;
		regulator-type = "voltage";

		startup-delay-us = <200>;

		pinctrl-names = "default";
		pinctrl-0 = <&sd_level_translator_default>;
	};

	/* External LDO MIC5366-3.3YMT for eMMC */
	ldo_3v3_reg: regulator-gpio-ldo-3v3 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VMEM_3V3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		gpios = <&gpio6 31 GPIO_ACTIVE_HIGH>;
		startup-delay-us = <5000>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&emmc_ldo_en_default_mode>;
	};

	/*
	 * External Ricoh "TSP" regulator for the touchscreen.
	 * One GPIO line controls two voltages of 3.3V and 1.8V
	 * this line is known as "TSP_LDO_ON1" in the schematics.
	 */
	ldo_tsp_3v3_reg: regulator-gpio-tsp-ldo-3v3 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "LDO_TSP_A3V3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		/* GPIO94 controls this regulator */
		gpio = <&gpio2 30 GPIO_ACTIVE_HIGH>;
		/* 70 ms power-on delay */
		startup-delay-us = <70000>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&tsp_ldo_en_default_mode>;
	};
	ldo_tsp_1v8_reg: regulator-gpio-tsp-ldo-1v8 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VREG_TSP_1V8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		/* GPIO94 controls this regulator */
		gpio = <&gpio2 30 GPIO_ACTIVE_HIGH>;
		/* 70 ms power-on delay */
		startup-delay-us = <70000>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&tsp_ldo_en_default_mode>;
	};

	/*
	 * External Ricoh RP152L010B-TR LCD LDO regulator for the display.
	 * LCD_PWR_EN controls both a 3.0V and 1.8V output.
	 */
	lcd_3v0_reg: regulator-gpio-lcd-3v0 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VREG_LCD_3.0V";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		/* GPIO219 controls this regulator */
		gpio = <&gpio6 27 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&lcd_pwr_en_default_mode>;
	};
	lcd_1v8_reg: regulator-gpio-lcd-1v8 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VREG_LCD_1.8V";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		/* GPIO219 controls this regulator too */
		gpio = <&gpio6 27 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&lcd_pwr_en_default_mode>;
	};

	/*
	 * This regulator is a GPIO line that drives the Broadcom WLAN
	 * line WL_REG_ON high and enables the internal regulators
	 * inside the chip. Unfortunatley it is erroneously named
	 * WLAN_RST_N on the schematic but it is not a reset line.
	 *
	 * The voltage specified here is only used to determine the OCR mask,
	 * the for the SDIO connector, the chip is actually connected
	 * directly to VBAT.
	 */
	wl_reg: regulator-gpio-wlan {
		compatible = "regulator-fixed";
		regulator-name = "WL_REG_ON";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		startup-delay-us = <100000>;
		/* GPIO215 (WLAN_RST_N to WL_REG_ON) */
		gpio = <&gpio6 23 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&wlan_ldo_en_default>;
	};

	vibrator {
		compatible = "gpio-vibrator";
		/* GPIO195 "MOT_EN" */
		enable-gpios = <&gpio6 3 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&vibrator_default>;
	};

	gpio-keys {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_keys_default_mode>;

		button-home {
			linux,code = <KEY_HOME>;
			label = "HOME";
			/* GPIO91 */
			gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
		};
		button-volup {
			linux,code = <KEY_VOLUMEUP>;
			label = "VOL+";
			/* GPIO67 */
			gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
		};
		button-voldown {
			linux,code = <KEY_VOLUMEDOWN>;
			label = "VOL-";
			/* GPIO92 */
			gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
		};
	};

	gpio-leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_leds_default_mode>;
		touchkey-led {
			label = "touchkeys";
			/*
			 * GPIO194 on R0.0, R0.4 does not use this at all, it
			 * will instead turn LDO AUX4 on/off for key led backlighy.
			 * (Line is pulled down on R0.4)
			 */
			gpios = <&gpio6 2 GPIO_ACTIVE_HIGH>;
			default-state = "on";
		};
	};

	ktd253: backlight {
		compatible = "kinetic,ktd253";
		/*
		 * GPIO68 is for R0.0, the board file talks about a TMO variant
		 * (R0.4) using GPIO69.
		 */
		enable-gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>;
		/* Default to 13/32 brightness */
		default-brightness = <13>;
		pinctrl-names = "default";
		pinctrl-0 = <&ktd253_backlight_default_mode>;
	};

	/* Richtek RT8515GQW Flash LED Driver IC */
	flash {
		compatible = "richtek,rt8515";
		/* GPIO 140 */
		enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
		/* GPIO 141 */
		ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
		/*
		 * RFS is 16 kOhm and RTS is 100 kOhm giving
		 * the flash max current 343mA and torch max
		 * current 55 mA.
		 */
		richtek,rfs-ohms = <16000>;
		richtek,rts-ohms = <100000>;
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_flash_default_mode>;

		led {
			function = LED_FUNCTION_FLASH;
			color = <LED_COLOR_ID_WHITE>;
			flash-max-timeout-us = <250000>;
			flash-max-microamp = <343750>;
			led-max-microamp = <55000>;
		};
	};

	/* Bit-banged I2C on GPIO143 and GPIO144 also called "SUBPMU I2C" */
	i2c-gpio-0 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio4 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio4 15 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_0_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		magnetometer@c {
			compatible = "alps,hscdtd008a";
			reg = <0x0c>;
			clock-frequency = <400000>;

			avdd-supply = <&ab8500_ldo_aux1_reg>; // 3V
			dvdd-supply = <&ab8500_ldo_aux2_reg>; // 1.8V
		};
		/* TODO: this should also be used by the SM5103 Camera power management unit */
	};

	/* Bit-banged I2C on GPIO151 and GPIO152 also called "NFC I2C" */
	i2c-gpio-1 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio4 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio4 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_1_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		nfc@2b {
			/* NXP NFC circuit PN544 C1 marked NXP 44501  */
			compatible = "nxp,pn544-i2c";
			/* IF0, IF1 high, gives I2C address 0x2B */
			reg = <0x2b>;
			clock-frequency = <400000>;
			/* NFC IRQ on GPIO32 */
			interrupt-parent = <&gpio1>;
			interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
			/* GPIO 31 */
			firmware-gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
			/* GPIO88 */
			enable-gpios = <&gpio2 24 GPIO_ACTIVE_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&pn544_codina_default>;
		};
	};

	spi {
		compatible = "spi-gpio";
		/* Clock on GPIO220, pin SCL */
		sck-gpios = <&gpio6 28 GPIO_ACTIVE_HIGH>;
		/* MOSI on GPIO224, pin SDI "slave data in" */
		mosi-gpios = <&gpio7 0 GPIO_ACTIVE_HIGH>;
		/* MISO on GPIO225, pin SDO "slave data out" */
		miso-gpios = <&gpio7 1 GPIO_ACTIVE_HIGH>;
		/* Chip select on GPIO201 */
		cs-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>;
		num-chipselects = <1>;

		pinctrl-names = "default";
		pinctrl-0 = <&spi_gpio_0_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		/*
		 * Some Codinas (90%) have a WideChips WS2401-based LMS380KF01
		 * display mounted and some 10% has a Samsung S6D27A1 instead.
		 * The boot loader needs to modify this compatible to
		 * correspond to whatever is passed from the early Samsung boot.
		 */
		panel@0 {
			compatible = "samsung,lms380kf01";
			spi-max-frequency = <1200000>;
			/* TYPE 3: inverse clock polarity and phase */
			spi-cpha;
			spi-cpol;

			reg = <0>;
			vci-supply = <&lcd_3v0_reg>;
			vccio-supply = <&lcd_1v8_reg>;

			/* Reset on GPIO139 */
			reset-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
			/* LCD_VGH/LCD_DETECT, ESD IRQ on GPIO93 */
			interrupt-parent = <&gpio2>;
			interrupts = <29 IRQ_TYPE_EDGE_RISING>;

			pinctrl-names = "default";
			pinctrl-0 = <&panel_default_mode>;
			backlight = <&ktd253>;

			port {
				panel_in: endpoint {
					remote-endpoint = <&display_out>;
				};
			};
		};
	};

	soc {
		/* External Micro SD slot */
		mmc@80126000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <4>;
			cap-sd-highspeed;
			cap-mmc-highspeed;
			st,sig-pin-fbclk;
			full-pwr-cycle;
			/* MMC is powered by AUX3 1.2V .. 2.91V */
			vmmc-supply = <&ab8500_ldo_aux3_reg>;
			/* 2.9 V level translator is using AUX3 at 2.9 V as well */
			vqmmc-supply = <&sd_level_translator>;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc0_a_2_default>;
			pinctrl-1 = <&mc0_a_2_sleep>;
			cd-gpios  = <&gpio6 25 GPIO_ACTIVE_LOW>; // GPIO217
			status = "okay";
		};

		/* WLAN SDIO channel */
		mmc@80118000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <50000000>;
			bus-width = <4>;
			non-removable;
			cap-sd-highspeed;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc1_a_2_default>;
			pinctrl-1 = <&mc1_a_2_sleep>;
			/*
			 * GPIO-controlled voltage enablement: this drives
			 * the WL_REG_ON line high when we use this device.
			 * Represented as regulator to fill OCR mask.
			 */
			vmmc-supply = <&wl_reg>;

			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			wifi@1 {
				/* Actually BRCM4330 */
				compatible = "brcm,bcm4330-fmac", "brcm,bcm4329-fmac";
				reg = <1>;
				/* GPIO216 WL_HOST_WAKE */
				interrupt-parent = <&gpio6>;
				interrupts = <24 IRQ_TYPE_EDGE_FALLING>;
				interrupt-names = "host-wake";
				pinctrl-names = "default";
				pinctrl-0 = <&wlan_default_mode>;
			};
		};

		/* eMMC */
		mmc@80005000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <8>;
			non-removable;
			cap-mmc-highspeed;
			mmc-ddr-1_8v;
			no-sdio;
			no-sd;
			vmmc-supply = <&ldo_3v3_reg>;
			pinctrl-names = "default", "sleep";
			/*
			 * GPIO130 will be set to input no pull-up resulting in a resistor
			 * pulling the reset high and taking the memory out of reset.
			 */
			pinctrl-0 = <&mc2_a_1_default>;
			pinctrl-1 = <&mc2_a_1_sleep>;
			status = "okay";
		};

		/* GBF (Bluetooth) UART */
		uart@80120000 {
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u0_a_1_default>;
			pinctrl-1 = <&u0_a_1_sleep>;
			status = "okay";

			bluetooth {
				compatible = "brcm,bcm4330-bt";
				/* GPIO222 rail BT_VREG_EN to BT_REG_ON */
				shutdown-gpios = <&gpio6 30 GPIO_ACTIVE_HIGH>;
				/* BT_WAKE on GPIO199 */
				device-wakeup-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
				/* BT_HOST_WAKE on GPIO97 */
				/* FIXME: convert to interrupt */
				host-wakeup-gpios = <&gpio3 1 GPIO_ACTIVE_HIGH>;
				/* BT_RST_N on GPIO209 */
				reset-gpios = <&gpio6 17 GPIO_ACTIVE_LOW>;
				pinctrl-names = "default";
				pinctrl-0 = <&bluetooth_default_mode>;
			};
		};

		/* GPS UART */
		uart@80121000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u1rxtx_a_1_default &u1ctsrts_a_1_default>;
			pinctrl-1 = <&u1rxtx_a_1_sleep &u1ctsrts_a_1_sleep>;

			gnss {
				compatible = "brcm,bcm4751";
				/* GPS_RSTN on GPIO21 */
				reset-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>;
				/* GPS_ON_OFF on GPIO86 */
				enable-gpios = <&gpio2 22 GPIO_ACTIVE_HIGH>;
				/* GPS_1V8 (VSMPS2) */
				vddio-supply = <&db8500_vsmps2_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&bcm4751_codina_default>;
			};
		};

		/* Debugging console UART connected to TSU6111RSVR (FSA880) */
		uart@80007000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u2rxtx_c_1_default>;
			pinctrl-1 = <&u2rxtx_c_1_sleep>;
		};

		prcmu@80157000 {
			ab8500 {
				phy {
					pinctrl-names = "default", "sleep";
					pinctrl-0 = <&usb_a_1_default>;
					pinctrl-1 = <&usb_a_1_sleep>;
				};

				ab8500_fg {
					line-impedance-micro-ohms = <36000>;
				};

				regulator {
					ab8500_ldo_aux1 {
						/* Used for VDD for sensors */
						regulator-name = "V-SENSORS-VDD";
						regulator-min-microvolt = <3000000>;
						regulator-max-microvolt = <3000000>;
					};

					ab8500_ldo_aux2 {
						/* Used for VIO for sensors */
						regulator-name = "V-SENSORS-VIO";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
					};

					ab8500_ldo_aux3 {
						/* Used for voltage for external MMC/SD card */
						regulator-name = "V-MMC-SD";
						regulator-min-microvolt = <1200000>;
						regulator-max-microvolt = <2910000>;
					};
				};
			};
		};

		/* I2C0 also known as "AGC I2C" */
		i2c@80004000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c0_a_1_default>;
			pinctrl-1 = <&i2c0_a_1_sleep>;

			proximity@39 {
				/* Codina has the Amstaos TMD2672 */
				compatible = "amstaos,tmd2672";
				clock-frequency = <400000>;
				reg = <0x39>;

				/* IRQ on GPIO146 "PS_INT" */
				interrupt-parent = <&gpio4>;
				interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
				/* FIXME: needs a VDDIO supply that is connected to a pull-up resistor */
				vdd-supply = <&ab8500_ldo_aux1_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&tms2672_codina_default>;
			};
		};

		/* I2C1 on GPIO16 and GPIO17 also called "MUS I2C" */
		i2c@80122000 {
			status = "okay";
			pinctrl-names = "default","sleep";
			/* FIXME: If it doesn't work try what we use on Gavini */
			pinctrl-0 = <&i2c1_b_2_default>;
			pinctrl-1 = <&i2c1_b_2_sleep>;

			/* Texas Instruments TSU6111 micro USB switch */
			usb-switch@25 {
				compatible = "ti,tsu6111";
				reg = <0x25>;
				/* Interrupt JACK_INT_N on GPIO95 */
				interrupt-parent = <&gpio2>;
				interrupts = <31 IRQ_TYPE_EDGE_FALLING>;
				pinctrl-names = "default";
				pinctrl-0 = <&tsu6111_codina_default>;
			};
		};

		/* I2C2 on GPIO10 and GPIO11 also called "SENSORS I2C" */
		i2c@80128000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c2_b_2_default>;
			pinctrl-1 = <&i2c2_b_2_sleep>;

			lisd3dh@19 {
				/* ST Microelectronics Accelerometer */
				compatible = "st,lis3dh-accel";
				st,drdy-int-pin = <1>;
				reg = <0x19>;
				vdd-supply = <&ab8500_ldo_aux1_reg>; // 3V
				vddio-supply = <&ab8500_ldo_aux2_reg>; // 1.8V
				mount-matrix = "0", "1", "0",
					       "-1", "0", "0",
					       "0", "0", "1";
			};
		};

		/* I2C3 */
		i2c@80110000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c3_c_2_default>;
			pinctrl-1 = <&i2c3_c_2_sleep>;

			/* TODO: write bindings and driver for this touchscreen */

			/* Zinitix BT404 ISP part */
			isp@50 {
				compatible = "zinitix,bt404-isp";
				reg = <0x50>;
				pinctrl-names = "default";
				pinctrl-0 = <&tsp_default>;
			};

			/* Zinitix BT404 touchscreen, also has the touchkeys for menu and back */
			touchscreen@20 {
				compatible = "zinitix,bt404";
				reg = <0x20>;
				/* GPIO218 (TSP_INT_1V8) */
				interrupt-parent = <&gpio6>;
				interrupts = <26 IRQ_TYPE_EDGE_FALLING>;
				vcca-supply = <&ldo_tsp_3v3_reg>;
				vdd-supply = <&ldo_tsp_1v8_reg>;
				zinitix,mode = <2>;
				touchscreen-size-x = <480>;
				touchscreen-size-y = <800>;
				pinctrl-names = "default";
				pinctrl-0 = <&tsp_default>;
			};
		};

		mcde@a0350000 {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&dpi_default_mode>;

			port {
				display_out: endpoint {
					remote-endpoint = <&panel_in>;
				};
			};
		};
	};
};

&pinctrl {
	/*
	 * This extends the MC0_A_2 default config to include
	 * the card detect GPIO217 line.
	 */
	sdi0 {
		mc0_a_2_default {
			default_cfg4 {
				pins = "GPIO217_AH12"; /* card detect */
				ste,config = <&gpio_in_pd>;
			};
		};
	};
	sdi2 {
		/*
		 * This will make the resistor mounted in R0.0 pull up
		 * the reset line and take the eMMC out of reset. On
		 * R0.4 variants, GPIO130 should be set in GPIO mode and
		 * pulled down. (Not connected.)
		 */
		mc2_a_1_default {
			default_cfg2 {
				pins = "GPIO130_C8"; /* FBCLK */
				ste,config = <&in_nopull>;
			};
		};
	};
	/* GPIO that enables the 2.9V SD card level translator */
	sd-level-translator {
		sd_level_translator_default: sd_level_translator_default {
			/* level shifter on GPIO87 */
			codina_cfg1 {
				pins = "GPIO87_B3";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the eMMC */
	emmc-ldo {
		emmc_ldo_en_default_mode: emmc_ldo_default {
			/* LDO enable on GPIO223 */
			codina_cfg1 {
				pins = "GPIO223_AH9";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIOs for panel control */
	panel {
		panel_default_mode: panel_default {
			codina_cfg1 {
				/* Reset line */
				pins = "GPIO139_C9";
				ste,config = <&gpio_out_lo>;
			};
			codina_cfg2 {
				/* ESD IRQ line "LCD detect" */
				pins = "GPIO93_B7";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the touchscreen */
	tsp-ldo {
		tsp_ldo_en_default_mode: tsp_ldo_default {
			/* LDO enable on GPIO94 */
			gavini_cfg1 {
				pins = "GPIO94_D7";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the LCD display */
	lcd-ldo {
		lcd_pwr_en_default_mode: lcd_pwr_en_default {
			/* LCD_PWR_EN on GPIO219 */
			codina_cfg1 {
				pins = "GPIO219_AG10";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the key LED */
	key-led {
		gpio_leds_default_mode: en_led_ldo_default {
			/* EN_LED_LDO on GPIO194 */
			codina_cfg1 {
				pins = "GPIO194_AF27";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the WLAN internal LDO regulators */
	wlan-ldo {
		wlan_ldo_en_default: wlan_ldo_default {
			/* GPIO215 named WLAN_RST_N */
			codina_cfg1 {
				pins = "GPIO215_AH13";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* Backlight GPIO */
	backlight {
		ktd253_backlight_default_mode: backlight_default {
			skomer_cfg1 {
				pins = "GPIO68_E1"; /* LCD_BL_CTRL */
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* Flash and torch */
	flash {
		gpio_flash_default_mode: flash_default {
			codina_cfg1 {
				pins = "GPIO140_B11", "GPIO141_C12";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* GPIO keys */
	gpio-keys {
		gpio_keys_default_mode: gpio_keys_default {
			skomer_cfg1 {
				pins = "GPIO67_G2", /* VOL UP */
				       "GPIO91_B6", /* HOME */
				       "GPIO92_D6"; /* VOL DOWN */
				ste,config = <&gpio_in_pu>;
			};
		};
	};
	/* Interrupt line for the Zinitix BT404 touchscreen */
	tsp {
		tsp_default: tsp_default {
			codina_cfg1 {
				pins = "GPIO218_AH11";	/* TSP_INT_1V8 */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* Interrupt line for light/proximity sensor TMS2672 */
	tms2672 {
		tms2672_codina_default: tms2672_codina {
			codina_cfg1 {
				pins = "GPIO146_D13";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based I2C bus for subpmu */
	i2c-gpio-0 {
		i2c_gpio_0_default: i2c_gpio_0 {
			codina_cfg1 {
				pins = "GPIO143_D12", "GPIO144_B13";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based I2C bus for the NFC */
	i2c-gpio-1 {
		i2c_gpio_1_default: i2c_gpio_1 {
			codina_cfg1 {
				pins = "GPIO151_D17", "GPIO152_D16";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based SPI bus for the display */
	spi-gpio-0 {
		spi_gpio_0_default: spi_gpio_0_d {
			codina_cfg1 {
				pins = "GPIO220_AH10", "GPIO201_AF24", "GPIO224_AG9";
				ste,config = <&gpio_out_hi>;
			};
			codina_cfg2 {
				pins = "GPIO225_AG8";
				/* Needs pull down, no pull down resistor on board */
				ste,config = <&gpio_in_pd>;
			};
		};
		spi_gpio_0_sleep: spi_gpio_0_s {
			codina_cfg1 {
				pins = "GPIO220_AH10", "GPIO201_AF24",
				       "GPIO224_AG9", "GPIO225_AG8";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	wlan {
		wlan_default_mode: wlan_default {
			/* GPIO216 for WL_HOST_WAKE */
			codina_cfg2 {
				pins = "GPIO216_AG12";
				ste,config = <&gpio_in_pd>;
			};
		};
	};
	bluetooth {
		bluetooth_default_mode: bluetooth_default {
			/* GPIO199 BT_WAKE and GPIO222 BT_VREG_ON */
			codina_cfg1 {
				pins = "GPIO199_AH23", "GPIO222_AJ9";
				ste,config = <&gpio_out_lo>;
			};
			/* GPIO97 BT_HOST_WAKE */
			codina_cfg2 {
				pins = "GPIO97_D9";
				ste,config = <&gpio_in_nopull>;
			};
			/* GPIO209 BT_RST_N */
			codina_cfg3 {
				pins = "GPIO209_AG15";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* Interrupt line for TI TSU6111 Micro USB switch */
	tsu6111 {
		tsu6111_codina_default: tsu6111_codina {
			codina_cfg1 {
				/* GPIO95 used for IRQ */
				pins = "GPIO95_E8";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	nfc {
		pn544_codina_default: pn544_codina {
			/* Interrupt line */
			codina_cfg1 {
				pins = "GPIO32_V2";
				ste,config = <&gpio_in_nopull>;
			};
			/* Enable and firmware GPIOs */
			codina_cfg2 {
				pins = "GPIO31_V3", "GPIO88_C4";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	bcm4751 {
		bcm4751_codina_default: bcm4751_codina {
			/* Reset line, start out asserted */
			codina_cfg1 {
				pins = "GPIO21_AB3";
				ste,config = <&gpio_out_lo>;
			};
			/* GPS_ON_OFF, start out deasserted (off) */
			codina_cfg2 {
				pins = "GPIO86_C6";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	vibrator {
		vibrator_default: vibrator_default {
			codina_cfg1 {
				pins = "GPIO195_AG28";	/* MOT_EN */
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	mcde {
		dpi_default_mode: dpi_default {
			default_mux1 {
				/* Mux in all the data lines */
				function = "lcd";
				groups =
					/* Data lines D0-D7 GPIO70..GPIO77 */
					"lcd_d0_d7_a_1",
					/* Data lines D8-D11 GPIO78..GPIO81 */
					"lcd_d8_d11_a_1",
					/* Data lines D12-D15 GPIO82..GPIO85 */
					"lcd_d12_d15_a_1",
					/* Data lines D16-D23 GPIO161..GPIO168 */
					"lcd_d16_d23_b_1";
			};
			default_mux2 {
				function = "lcda";
				/* Clock line on GPIO150, DE, VSO, HSO on GPIO169..GPIO171 */
				groups = "lcdaclk_b_1", "lcda_b_1";
			};
			/* Input, no pull-up is the default state for pins used for an alt function */
			default_cfg1 {
				pins = "GPIO150_C14", "GPIO169_D22", "GPIO170_C23", "GPIO171_D23";
				ste,config = <&in_nopull>;
			};
		};
	};
};


code:
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Devicetree for the Samsung Galaxy Beam GT-I8530 also known as Gavini.
 */

/dts-v1/;
#include "ste-db8500.dtsi"
#include "ste-ab8500.dtsi"
#include "ste-dbx5x0-pinctrl.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
	model = "Samsung Galaxy Beam (GT-I8530)";
	compatible = "samsung,gavini", "st-ericsson,u8500";

	chosen {
		stdout-path = &serial2;
	};

	battery: battery {
		compatible = "samsung,eb585157lu";
	};

	thermal-zones {
		battery-thermal {
			/* This zone will be polled by the battery temperature code */
			polling-delay = <0>;
			polling-delay-passive = <0>;
			thermal-sensors = <&bat_therm>;

			trips {
				battery-crit-hi {
					temperature = <70000>;
					hysteresis = <2000>;
					type = "critical";
				};
			};
		};
	};

	bat_therm: thermistor {
		compatible = "samsung,1404-001221";
		io-channels = <&gpadc 0x02>; /* BatTemp */
		pullup-uv = <1800000>;
		pullup-ohm = <230000>;
		pulldown-ohm = <0>;
		#thermal-sensor-cells = <0>;
	};

	/* TI TXS0206 level translator for 2.9 V */
	sd_level_translator: regulator-gpio {
		compatible = "regulator-fixed";

		/* GPIO193 EN */
		gpios = <&gpio6 1 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		regulator-name = "sd-level-translator";
		regulator-min-microvolt = <2900000>;
		regulator-max-microvolt = <2900000>;
		regulator-type = "voltage";

		startup-delay-us = <200>;

		pinctrl-names = "default";
		pinctrl-0 = <&sd_level_translator_default>;
	};

	/* External LDO for eMMC LDO VMEM_3V3 controlled by GPIO6 */
	ldo_3v3_reg: regulator-gpio-ldo-3v3 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VMEM_3V3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		gpio = <&gpio0 6 GPIO_ACTIVE_HIGH>;
		startup-delay-us = <5000>; // FIXME
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&emmc_ldo_en_default_mode>;
	};

	/*
	 * External Ricoh "TSP" regulator for the touchscreen.
	 * One GPIO line controls two voltages of 3.3V and 1.8V
	 * this line is known as "TSP_LDO_ON1" in the schematics.
	 */
	ldo_tsp_3v3_reg: regulator-gpio-tsp-ldo-3v3 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "LDO_TSP_A3V3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		/* GPIO94 controls this regulator */
		gpio = <&gpio2 30 GPIO_ACTIVE_HIGH>;
		/* 70 ms power-on delay */
		startup-delay-us = <70000>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&tsp_ldo_en_default_mode>;
	};
	ldo_tsp_1v8_reg: regulator-gpio-tsp-ldo-1v8 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VREG_TSP_1V8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		/* GPIO94 controls this regulator */
		gpio = <&gpio2 30 GPIO_ACTIVE_HIGH>;
		/* 70 ms power-on delay */
		startup-delay-us = <70000>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&tsp_ldo_en_default_mode>;
	};

	/*
	 * External Ricoh RP152L010B-TR LCD LDO regulator for the display.
	 * LCD_PWR_EN controls both a 3.0V and 1.8V output.
	 */
	lcd_3v0_reg: regulator-gpio-lcd-3v0 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VREG_LCD_3V0";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		/* GPIO219 controls this regulator */
		gpio = <&gpio6 27 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&lcd_pwr_en_default_mode>;
	};
	lcd_1v8_reg: regulator-gpio-lcd-1v8 {
		compatible = "regulator-fixed";
		/* Supplied in turn by VBAT */
		regulator-name = "VREG_LCD_1V8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		/* GPIO219 controls this regulator too */
		gpio = <&gpio6 27 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&lcd_pwr_en_default_mode>;
	};

	/*
	 * This regulator is a GPIO line that drives the Broadcom WLAN
	 * line WL_REG_ON high and enables the internal regulators
	 * inside the chip. Unfortunatley it is erroneously named
	 * WLAN_RST_N on the schematic but it is not a reset line.
	 *
	 * The voltage specified here is only used to determine the OCR mask,
	 * the for the SDIO connector, the chip is actually connected
	 * directly to VBAT.
	 */
	wl_reg: regulator-gpio-wlan {
		compatible = "regulator-fixed";
		regulator-name = "WL_REG_ON";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		startup-delay-us = <100000>;
		/* GPIO215 (WLAN_RST_N to WL_REG_ON) */
		gpio = <&gpio6 23 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&wlan_ldo_en_default>;
	};

	gpio-keys {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_keys_default_mode>;

		button-projector {
			linux,code = <KEY_SWITCHVIDEOMODE>;
			label = "Projector";
			/* GPIO32 "Projector On HotKey" */
			gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
		};
		button-home {
			linux,code = <KEY_HOME>;
			label = "HOME";
			/* GPIO91 */
			gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
		};
		button-volup {
			linux,code = <KEY_VOLUMEUP>;
			label = "VOL+";
			/* GPIO67 */
			gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
		};
		button-voldown {
			linux,code = <KEY_VOLUMEDOWN>;
			label = "VOL-";
			/* GPIO92 */
			gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
		};
	};

	/* Richtek RT8515GQW Flash LED Driver IC */
	flash {
		compatible = "richtek,rt8515";
		/* GPIO 140 */
		enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
		/* GPIO 141 */
		ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
		/*
		 * RFS is 16 kOhm and RTS is 100 kOhm giving
		 * the flash max current 343mA and torch max
		 * current 55 mA.
		 */
		richtek,rfs-ohms = <16000>;
		richtek,rts-ohms = <100000>;
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_flash_default_mode>;

		led {
			function = LED_FUNCTION_FLASH;
			color = <LED_COLOR_ID_WHITE>;
			flash-max-timeout-us = <250000>;
			flash-max-microamp = <343750>;
			led-max-microamp = <55000>;
		};
	};

	gpio-leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_leds_default_mode>;
		used-led {
			label = "touchkeys";
			/* GPIO68 */
			gpios = <&gpio2 4 GPIO_ACTIVE_HIGH>;
			default-state = "on";
		};
	};

	ktd259: backlight {
		compatible = "kinetic,ktd259";
		/* GPIO20 */
		enable-gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
		/* Default to 13/32 brightness */
		default-brightness = <13>;
		pinctrl-names = "default";
		pinctrl-0 = <&ktd259_backlight_default_mode>;
	};

	/* Bit-banged I2C on GPIO143 and GPIO144 also called "SUBPMU I2C" */
	i2c-gpio-0 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio4 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio4 15 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_0_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		/* Yamaha YAS530 magnetometer */
		magnetometer@2e {
			compatible = "yamaha,yas530";
			reg = <0x2e>;
			/* VDD 3V */
			vdd-supply = <&ab8500_ldo_aux1_reg>;
			/* IOVDD 1.8V */
			iovdd-supply = <&ab8500_ldo_aux2_reg>;
			/* GPIO204 COMPASS_RST_N */
			reset-gpios = <&gpio6 12 GPIO_ACTIVE_LOW>;
			pinctrl-names = "default";
			pinctrl-0 = <&yas530_default>;
		};
		/* TODO: this should also be used by the NCP6914 Camera power management unit */
	};

	/*
	 * TODO: See if we can use the PL023 for this instead.
	 */
	spi {
		compatible = "spi-gpio";
		/* Clock on GPIO220, pin SCL */
		sck-gpios = <&gpio6 28 GPIO_ACTIVE_HIGH>;
		/* MOSI on GPIO224, pin SDI "slave data in" */
		mosi-gpios = <&gpio7 0 GPIO_ACTIVE_HIGH>;
		/* MISO on GPIO225, pin SDO "slave data out" */
		miso-gpios = <&gpio7 1 GPIO_ACTIVE_HIGH>;
		/* Chip select on GPIO223 */
		cs-gpios = <&gpio6 31 GPIO_ACTIVE_LOW>;
		num-chipselects = <1>;

		pinctrl-names = "default";
		pinctrl-0 = <&spi_gpio_0_default>;
		#address-cells = <1>;
		#size-cells = <0>;

		panel@0 {
			compatible = "samsung,lms397kf04";
			/* 300 ns at read cycle -> 3 MHz max speed */
			//spi-max-frequency = <3000000>;
			spi-max-frequency = <1200000>;
			/* TYPE 3: inverse clock polarity and phase */
			spi-cpha;
			spi-cpol;

			reg = <0>;
			vci-supply = <&lcd_3v0_reg>;
			vccio-supply = <&lcd_1v8_reg>;
			/* Reset on GPIO139 */
			reset-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
			pinctrl-names = "default";
			pinctrl-0 = <&panel_default_mode>;
			backlight = <&ktd259>;

			port {
				panel_in: endpoint {
					remote-endpoint = <&display_out>;
				};
			};
		};
	};

	/* Bit-banged I2C on GPIO201 and GPIO202 also called "MOT_I2C" */
	i2c-gpio-2 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio6 10 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio6 9 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_2_default>;
		#address-cells = <1>;
		#size-cells = <0>;
		/* TODO: add the Immersion ISA1200 I2C device here */
	};

	/* Bit-banged I2C on GPIO196 and GPIO197 also called "MPR_I2C" */
	i2c-gpio-3 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio6 5 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio6 4 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_3_default>;
		#address-cells = <1>;
		#size-cells = <0>;
		/* TODO: add the DPP2601 projector I2C device 0x1b here */
	};

	soc {
		/* External Micro SD slot */
		mmc@80126000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <50000000>;
			bus-width = <4>;
			cap-sd-highspeed;
			cap-mmc-highspeed;
			st,sig-pin-fbclk;
			full-pwr-cycle;
			/* MMC is powered by AUX3 1.2V .. 2.91V */
			vmmc-supply = <&ab8500_ldo_aux3_reg>;
			/* 2.9 V level translator */
			vqmmc-supply = <&sd_level_translator>;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc0_a_2_default>;
			pinctrl-1 = <&mc0_a_2_sleep>;
			/* "flash detect" actually card detect */
			cd-gpios  = <&gpio6 25 GPIO_ACTIVE_LOW>;
			status = "okay";
		};

		/* WLAN SDIO channel */
		mmc@80118000 {
			arm,primecell-periphid = <0x10480180>;
			max-frequency = <50000000>;
			bus-width = <4>;
			non-removable;
			cap-sd-highspeed;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc1_a_2_default>;
			pinctrl-1 = <&mc1_a_2_sleep>;
			/*
			 * GPIO-controlled voltage enablement: this drives
			 * the WL_REG_ON line high when we use this device.
			 * Represented as regulator to fill OCR mask.
			 */
			vmmc-supply = <&wl_reg>;

			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";

			wifi@1 {
				compatible = "brcm,bcm4330-fmac", "brcm,bcm4329-fmac";
				reg = <1>;
				/* GPIO216 WL_HOST_WAKE */
				interrupt-parent = <&gpio6>;
				interrupts = <24 IRQ_TYPE_EDGE_FALLING>;
				interrupt-names = "host-wake";
				pinctrl-names = "default";
				pinctrl-0 = <&wlan_default_mode>;
			};
		};

		/* eMMC */
		mmc@80005000 {
			arm,primecell-periphid = <0x10480180>;
		        max-frequency = <50000000>;
			bus-width = <8>;
			non-removable;
			cap-mmc-highspeed;
			mmc-ddr-1_8v;
			no-sdio;
			no-sd;
			vmmc-supply = <&ldo_3v3_reg>;
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc2_a_1_default>;
			pinctrl-1 = <&mc2_a_1_sleep>;
			status = "okay";
		};

		/* GBF (Bluetooth) UART */
		uart@80120000 {
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u0_a_1_default>;
			pinctrl-1 = <&u0_a_1_sleep>;
			status = "okay";

			bluetooth {
				compatible = "brcm,bcm4330-bt";
				/* GPIO222 rail BT_VREG_EN to BT_REG_ON */
				shutdown-gpios = <&gpio6 30 GPIO_ACTIVE_HIGH>;
				/* BT_WAKE on GPIO199 */
				device-wakeup-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
				/* BT_HOST_WAKE on GPIO97 */
				host-wakeup-gpios = <&gpio3 1 GPIO_ACTIVE_HIGH>;
				/* BT_RST_N on GPIO209 */
				reset-gpios = <&gpio6 17 GPIO_ACTIVE_LOW>;
				pinctrl-names = "default";
				pinctrl-0 = <&bluetooth_default_mode>;
			};
		};

		/* GPS UART */
		uart@80121000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			/* CTS/RTS is not used, CTS is repurposed as GPIO */
			pinctrl-0 = <&u1rxtx_a_1_default>;
			pinctrl-1 = <&u1rxtx_a_1_sleep>;
			/* FIXME: add a device for the GPS here */
		};

		/* Debugging console UART connected to TSU6111RSVR (FSA880) */
		uart@80007000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u2rxtx_c_1_default>;
			pinctrl-1 = <&u2rxtx_c_1_sleep>;
		};

		prcmu@80157000 {
			ab8500 {
				phy {
					pinctrl-names = "default", "sleep";
					pinctrl-0 = <&usb_a_1_default>;
					pinctrl-1 = <&usb_a_1_sleep>;
				};

				ab8500_fg {
					line-impedance-micro-ohms = <43000>;
				};

				regulator {
					ab8500_ldo_aux1 {
						/* Used for VDD for sensors */
						regulator-name = "V-SENSORS-VDD";
						regulator-min-microvolt = <3000000>;
						regulator-max-microvolt = <3000000>;
					};

					ab8500_ldo_aux2 {
						/* Used for VIO for sensors */
						regulator-name = "V-SENSORS-VIO";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
					};

					ab8500_ldo_aux3 {
						/* Used for voltage for external MMC/SD card */
						regulator-name = "V-MMC-SD";
						regulator-min-microvolt = <1200000>;
						regulator-max-microvolt = <2910000>;
					};
				};
			};
		};

		/* I2C0 */
		i2c@80004000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c0_a_1_default>;
			pinctrl-1 = <&i2c0_a_1_sleep>;

			/* FIXME: fix the proximity sensor bindings and driver */
			proximity@39 {
				/* Gavini has the GP2A030S00F proximity sensor */
				compatible = "sharp,gp2a030s00f";
				clock-frequency = <400000>;
				reg = <0x39>;
				/* FIXME: GPIO146 provides power on, IR LED? */
			};

			gyroscope@68 {
				compatible = "invensense,mpu3050";
				reg = <0x68>;
				/* GPIO226 interrupt */
				interrupt-parent = <&gpio7>;
				interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
				mount-matrix = "0", "1", "0",
					       "1", "0", "0",
					       "0", "0", "1";
				vlogic-supply = <&ab8500_ldo_aux2_reg>; // 1.8V
				vdd-supply = <&ab8500_ldo_aux1_reg>; // 3V
				pinctrl-names = "default";
				pinctrl-0 = <&mpu3050_default>;

				/*
				 * The MPU-3050 acts as a hub for the
				 * accelerometer.
				 */
				i2c-gate {
					#address-cells = <1>;
					#size-cells = <0>;

					/* Bosch BMA222E accelerometer */
					accelerometer@18 {
						compatible = "bosch,bma222e";
						reg = <0x18>;
						mount-matrix = "0", "-1", "0",
							       "1", "0", "0",
							       "0", "0", "1";
						vddio-supply = <&ab8500_ldo_aux2_reg>; // 1.8V
						vdd-supply = <&ab8500_ldo_aux1_reg>; // 3V
					};
				};
			};
		};

		/* I2C2 "AGC I2C" */
		i2c@80128000 {
			status = "okay";
			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c2_b_1_default>;
			pinctrl-1 = <&i2c2_b_1_sleep>;

			/* Texas Instruments TSU6111 micro USB switch */
			usb-switch@25 {
				compatible = "ti,tsu6111";
				reg = <0x25>;
				/* Interrupt JACK_INT_N on GPIO95 */
				interrupt-parent = <&gpio2>;
				interrupts = <31 IRQ_TYPE_EDGE_FALLING>;
				pinctrl-names = "default";
				pinctrl-0 = <&tsu6111_default>;
			};
		};

		/* I2C3 */
		i2c@80110000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c3_c_2_default>;
			pinctrl-1 = <&i2c3_c_2_sleep>;

			/* Melfas MMS136 touchscreen */
			touchscreen@48 {
				compatible = "melfas,mms136";
				reg = <0x48>;
				/* GPIO218 (TSP_INT_1V8) */
				interrupt-parent = <&gpio6>;
				interrupts = <26 IRQ_TYPE_EDGE_FALLING>;
				/* AVDD is "analog supply", 2.57-3.47 V */
				avdd-supply = <&ldo_tsp_3v3_reg>;
				/* VDD is "digital supply" 1.71-3.47V */
				vdd-supply = <&ldo_tsp_1v8_reg>;
				pinctrl-names = "default";
				pinctrl-0 = <&tsp_default>;
				touchscreen-size-x = <480>;
				touchscreen-size-y = <800>;
			};
		};

		mcde@a0350000 {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&dpi_default_mode>;

			port {
				display_out: endpoint {
					remote-endpoint = <&panel_in>;
				};
			};
		};
	};
};

&pinctrl {
	/*
	 * This extends the MC0_A_2 default config to include
	 * the card detect GPIO217 line.
	 */
	sdi0 {
		mc0_a_2_default {
			default_cfg4 {
				pins = "GPIO217_AH12"; /* card detect */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	mcde {
		dpi_default_mode: dpi_default {
			default_mux1 {
				/* Mux in all the data lines */
				function = "lcd";
				groups =
					/* Data lines D0-D7 GPIO70..GPIO77 */
					"lcd_d0_d7_a_1",
					/* Data lines D8-D11 GPIO78..GPIO81 */
					"lcd_d8_d11_a_1",
					/* Data lines D12-D15 GPIO82..GPIO85 */
					"lcd_d12_d15_a_1",
					/* Data lines D16-D23 GPIO161..GPIO168 */
					"lcd_d16_d23_b_1";
			};
			default_mux2 {
				function = "lcda";
				/* Clock line on GPIO150, DE, VSO, HSO on GPIO169..GPIO171 */
				groups = "lcdaclk_b_1", "lcda_b_1";
			};
			/* Input, no pull-up is the default state for pins used for an alt function */
			default_cfg1 {
				pins = "GPIO150_C14", "GPIO169_D22", "GPIO170_C23", "GPIO171_D23";
				ste,config = <&in_nopull>;
			};
		};
	};
	/* GPIO for panel reset control */
	panel {
		panel_default_mode: panel_default {
			gavini_cfg1 {
				/* Reset line */
				pins = "GPIO139_C9";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the eMMC */
	emmc-ldo {
		emmc_ldo_en_default_mode: emmc_ldo_default {
			/* LDO enable on GPIO6 */
			gavini_cfg1 {
				pins = "GPIO6_AF6";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the touchscreen */
	tsp-ldo {
		tsp_ldo_en_default_mode: tsp_ldo_default {
			/* LDO enable on GPIO94 */
			gavini_cfg1 {
				pins = "GPIO94_D7";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* Reset line for the Yamaha YAS530 magnetometer */
	yas530 {
		yas530_default: yas530_janice {
			janice_cfg1 {
				pins = "GPIO204_AF23";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* Flash and torch */
	flash {
		gpio_flash_default_mode: flash_default {
			janice_cfg1 {
				pins = "GPIO140_B11", "GPIO141_C12";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the key LED */
	gpio-leds {
		gpio_leds_default_mode: gpio_leds_default {
			/* EN_LED_LDO on GPIO68 */
			gavini_cfg1 {
				pins = "GPIO68_E1";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	backlight {
		ktd259_backlight_default_mode: backlight_default {
			skomer_cfg1 {
				pins = "GPIO20_AB4"; /* LCD_BL_EN */
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the touchkeys */
	touchkey-ldo {
		tsp_ldo_on2_default_mode: tsp_ldo_on2_default {
			/* TSP_LDO_ON2 on GPIO89 */
			gavini_cfg1 {
				pins = "GPIO89_E6";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	touchkey {
		touchkey_default_mode: touchkey_default {
			gavini_cfg1 {
				/* Interrupt */
				pins = "GPIO198_AG25";
				ste,config = <&gpio_in_nopull>;
			};
			gavini_cfg2 {
				/* Reset, actually completely unused (not routed) */
				pins = "GPIO205_AG23";
				ste,config = <&gpio_in_pd>;
			};
		};
	};
	/* GPIO that enables the LDO regulator for the LCD display */
	lcd-ldo {
		lcd_pwr_en_default_mode: lcd_pwr_en_default {
			/* LCD_PWR_EN on GPIO219 */
			gavini_cfg1 {
				pins = "GPIO219_AG10";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO that enables the WLAN internal LDO regulators */
	wlan-ldo {
		wlan_ldo_en_default: wlan_ldo_default {
			/* GPIO215 named WLAN_RST_N */
			gavini_cfg1 {
				pins = "GPIO215_AH13";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	/* GPIO that enables the 2.9V SD card level translator */
	sd-level-translator {
		sd_level_translator_default: sd_level_translator_default {
			/* level shifter on GPIO193 */
			skomer_cfg1 {
				pins = "GPIO193_AH27";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* GPIO keys */
	gpio-keys {
		gpio_keys_default_mode: gpio_keys_default {
			skomer_cfg1 {
				pins = "GPIO32_V2", /* Projector On HotKey */
				       "GPIO67_G2", /* VOL UP */
				       "GPIO91_B6", /* HOME */
				       "GPIO92_D6"; /* VOL DOWN */
				ste,config = <&gpio_in_pu>;
			};
		};
	};
	/* Interrupt line for the Atmel MXT228 touchscreen */
	tsp {
		tsp_default: tsp_default {
			gavini_cfg1 {
				pins = "GPIO218_AH11";	/* TSP_INT_1V8 */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* Interrupt line for Invensense MPU3050 gyroscope */
	mpu3050 {
		mpu3050_default: mpu3050 {
			gavini_cfg1 {
				/* GPIO226 used for IRQ */
				pins = "GPIO226_AF8";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based I2C bus for magnetometer and NCP6914 */
	i2c-gpio-0 {
		i2c_gpio_0_default: i2c_gpio_0 {
			gavini_cfg1 {
				pins = "GPIO143_D12", "GPIO144_B13";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based I2C bus for the Immersion ISA1200 */
	i2c-gpio-2 {
		i2c_gpio_2_default: i2c_gpio_2 {
			gavini_cfg1 {
				pins = "GPIO201_AF24", "GPIO202_AF25";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based I2C bus for the TI DPP2601 */
	i2c-gpio-3 {
		i2c_gpio_3_default: i2c_gpio_3 {
			gavini_cfg1 {
				pins = "GPIO196_AG26", "GPIO197_AH24";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
	/* GPIO-based SPI bus for the display */
	spi-gpio-0 {
		spi_gpio_0_default: spi_gpio_0_d {
			gavini_cfg1 {
				pins = "GPIO220_AH10", "GPIO223_AH9", "GPIO224_AG9";
				ste,config = <&gpio_out_hi>;
			};
			gavini_cfg2 {
				pins = "GPIO225_AG8";
				ste,config = <&gpio_in_nopull>;
			};
		};
		spi_gpio_0_sleep: spi_gpio_0_s {
			gavini_cfg1 {
				pins = "GPIO220_AH10", "GPIO223_AH9",
				     "GPIO224_AG9", "GPIO225_AG8";
				ste,config = <&gpio_out_hi>;
			};
			gavini_cfg2 {
				pins = "GPIO225_AG8";
				ste,config = <&gpio_out_lo>;
			};
		};
	};
	wlan {
		wlan_default_mode: wlan_default {
			/* GPIO216 for WL_HOST_WAKE */
			gavini_cfg2 {
				pins = "GPIO216_AG12";
				ste,config = <&gpio_in_pd>;
			};
		};
	};
	bluetooth {
		bluetooth_default_mode: bluetooth_default {
			/* GPIO199 BT_WAKE and GPIO222 BT_VREG_ON */
			gavini_cfg1 {
				pins = "GPIO199_AH23", "GPIO222_AJ9";
				ste,config = <&gpio_out_lo>;
			};
			/* GPIO97 BT_HOST_WAKE */
			gavini_cfg2 {
				pins = "GPIO97_D9";
				ste,config = <&gpio_in_nopull>;
			};
			/* GPIO209 BT_RST_N */
			gavini_cfg3 {
				pins = "GPIO209_AG15";
				ste,config = <&gpio_out_hi>;
			};
		};
	};
	/* Interrupt line for TI TSU6111 Micro USB switch */
	tsu6111 {
		tsu6111_default: tsu6111 {
			gavini_cfg1 {
				/* GPIO95 used for IRQ */
				pins = "GPIO95_E8";
				ste,config = <&gpio_in_nopull>;
			};
		};
	};
};


code:
// SPDX-License-Identifier: GPL-2.0-only
/dts-v1/;

#include "ste-db8500.dtsi"
#include "ste-ab8505.dtsi"
#include "ste-dbx5x0-pinctrl.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>

/*
 * Note: This device tree cannot be booted directly with the Samsung bootloader.
 * You need an intermediate, device-tree compatible bootloader
 * that locks the L2 cache. Otherwise the kernel will crash after decompression.
 *
 * There is a port of (mainline) U-Boot, see
 * https://wiki.postmarketos.org/wiki/ST-Ericsson_NovaThor_U8500#U-Boot
 */
/ {
	model = "Samsung Galaxy S III mini (GT-I8190)";
	compatible = "samsung,golden", "st-ericsson,u8500";

	chosen {
		stdout-path = &serial2;
	};

	battery: battery {
		compatible = "samsung,eb-l1m7flu";
	};

	thermal-zones {
		battery-thermal {
			/* This zone will be polled by the battery temperature code */
			polling-delay = <0>;
			polling-delay-passive = <0>;
			thermal-sensors = <&bat_therm>;

			trips {
				battery-crit-hi {
					temperature = <70000>;
					hysteresis = <2000>;
					type = "critical";
				};
			};
		};
	};

	bat_therm: thermistor {
		compatible = "samsung,1404-001221";
		io-channels = <&gpadc 0x02>; /* BatTemp */
		pullup-uv = <1800000>;
		pullup-ohm = <230000>;
		pulldown-ohm = <0>;
		#thermal-sensor-cells = <0>;
	};

	i2c-gpio-0 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio2 14 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio2 13 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_0_default>;

		#address-cells = <1>;
		#size-cells = <0>;

		touchkey@20 {
			compatible = "coreriver,tc360-touchkey";
			reg = <0x20>;
			vdd-supply = <&ab8500_ldo_aux4_reg>;
			vcc-supply = <&ab8500_ldo_aux6_reg>;

			interrupt-parent = <&gpio2>;
			interrupts = <15 IRQ_TYPE_EDGE_FALLING>;

			pinctrl-names = "default";
			pinctrl-0 = <&touchkey_default>;
			linux,keycodes = <KEY_MENU KEY_BACK>;
		};
	};

	i2c-gpio-1 {
		compatible = "i2c-gpio";
		sda-gpios = <&gpio4 24 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio4 23 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

		pinctrl-names = "default";
		pinctrl-0 = <&i2c_gpio_1_default>;

		#address-cells = <1>;
		#size-cells = <0>;

		magnetometer@c {
			compatible = "alps,hscdtd008a";
			reg = <0x0c>;

			avdd-supply = <&ab8500_ldo_aux1_reg>;
			dvdd-supply = <&ab8500_ldo_aux8_reg>;
		};
	};

	soc {
		/* External Micro SD card slot */
		mmc@80126000 {
			status = "okay";

			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <4>;

			non-removable;
			/*
			 * Unfortunately, there is no way to enable the UHS
			 * modes due to a limitation of the SD level translator:
			 * It will either translate to 2.9V or disconnect the
			 * DATA lines, so switching to 1.8V signal voltage fails.
			 */
			cap-sd-highspeed;
			cap-mmc-highspeed;
			st,sig-pin-fbclk;
			full-pwr-cycle;

			vmmc-supply = <&ab8500_ldo_aux3_reg>;
			vqmmc-supply = <&sd_level_translator>;

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc0_a_2_default>;
			pinctrl-1 = <&mc0_a_2_sleep>;
		};

		/* WLAN SDIO */
		mmc@80118000 {
			status = "okay";

			arm,primecell-periphid = <0x10480180>;
			max-frequency = <50000000>;
			bus-width = <4>;

			non-removable;
			cap-sd-highspeed;

			vmmc-supply = <&wl_reg_on>;

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc1_a_2_default>;
			pinctrl-1 = <&mc1_a_2_sleep>;

			#address-cells = <1>;
			#size-cells = <0>;

			wifi@1 {
				compatible = "brcm,bcm4334-fmac", "brcm,bcm4329-fmac";
				reg = <1>;

				/* GPIO216 (WLAN_HOST_WAKE) */
				interrupt-parent = <&gpio6>;
				interrupts = <24 IRQ_TYPE_EDGE_FALLING>;
				interrupt-names = "host-wake";

				pinctrl-names = "default";
				pinctrl-0 = <&wlan_default>;
			};
		};

		/* eMMC */
		mmc@80005000 {
			status = "okay";

			arm,primecell-periphid = <0x10480180>;
			max-frequency = <100000000>;
			bus-width = <8>;

			non-removable;
			cap-mmc-highspeed;
			mmc-ddr-1_8v;
			no-sdio;
			no-sd;

			vmmc-supply = <&vmem_3v3>;

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&mc2_a_1_default>;
			pinctrl-1 = <&mc2_a_1_sleep>;
		};

		/* BT UART */
		uart@80120000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u0_a_1_default>;
			pinctrl-1 = <&u0_a_1_sleep>;

			bluetooth {
				/* BCM4334B0 actually */
				compatible = "brcm,bcm4330-bt";
				/* GPIO222 (BT_VREG_ON) */
				shutdown-gpios = <&gpio6 30 GPIO_ACTIVE_HIGH>;
				/* GPIO199 (BT_WAKE) */
				device-wakeup-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
				/* GPIO97 (BT_HOST_WAKE) */
				host-wakeup-gpios = <&gpio3 1 GPIO_ACTIVE_HIGH>;

				pinctrl-names = "default";
				pinctrl-0 = <&bluetooth_default>;
			};
		};

		/* GPF UART */
		uart@80121000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u1rxtx_a_1_default &u1ctsrts_a_1_default>;
			pinctrl-1 = <&u1rxtx_a_1_sleep &u1ctsrts_a_1_sleep>;
		};

		/* Debugging console UART */
		uart@80007000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&u2rxtx_c_1_default>;
			pinctrl-1 = <&u2rxtx_c_1_sleep>;
		};

		i2c@80004000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c0_a_1_default>;
			pinctrl-1 = <&i2c0_a_1_sleep>;

			proximity@44 {
				compatible = "sharp,gp2ap002s00f";
				reg = <0x44>;

				/* GPIO146 (PS_INT) */
				interrupt-parent = <&gpio4>;
				interrupts = <18 IRQ_TYPE_EDGE_FALLING>;

				vdd-supply = <&ab8500_ldo_aux1_reg>;
				vio-supply = <&ab8500_ldo_aux8_reg>;

				pinctrl-names = "default";
				pinctrl-0 = <&proximity_default>;

				sharp,proximity-far-hysteresis = <0x40>;
				sharp,proximity-close-hysteresis = <0x0f>;
			};
		};

		i2c@80128000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c2_b_2_default>;
			pinctrl-1 = <&i2c2_b_2_sleep>;

			imu@68 {
				compatible = "invensense,mpu6050";
				reg = <0x68>;

				/* GPIO206 (ACC_INT) */
				interrupt-parent = <&gpio6>;
				interrupts = <14 IRQ_TYPE_EDGE_RISING>;

				mount-matrix = "0", "1", "0",
					      "-1", "0", "0",
					       "0", "0", "1";

				vdd-supply = <&ab8500_ldo_aux1_reg>;
				vddio-supply = <&ab8500_ldo_aux8_reg>;

				pinctrl-names = "default";
				pinctrl-0 = <&imu_default>;
			};
		};

		i2c@80110000 {
			status = "okay";

			pinctrl-names = "default", "sleep";
			pinctrl-0 = <&i2c3_c_2_default>;
			pinctrl-1 = <&i2c3_c_2_sleep>;

			touchscreen@4a {
				compatible = "atmel,maxtouch";
				reg = <0x4a>;

				/* GPIO218 (TSP_INT_1V8) */
				interrupt-parent = <&gpio6>;
				interrupts = <26 IRQ_TYPE_EDGE_FALLING>;

				/* VDDA is "analog supply", 2.57-3.47 V */
				vdda-supply = <&ab8500_ldo_aux2_reg>;
				/* VDD is "digital supply" 1.71-3.47V */
				vdd-supply = <&ab8500_ldo_aux5_reg>;

				pinctrl-names = "default";
				pinctrl-0 = <&tsp_default>;
			};
		};

		prcmu@80157000 {
			ab8505 {
				phy {
					pinctrl-names = "default", "sleep";
					pinctrl-0 = <&usb_a_1_default>;
					pinctrl-1 = <&usb_a_1_sleep>;
				};

				ab8500_fg {
					line-impedance-micro-ohms = <36000>;
				};

				regulator {
					ab8500_ldo_aux1 {
						regulator-name = "sensor_3v";
						regulator-min-microvolt = <3000000>;
						regulator-max-microvolt = <3000000>;
					};

					ab8500_ldo_aux2 {
						regulator-name = "vreg_tsp_a3v3";
						regulator-min-microvolt = <3300000>;
						regulator-max-microvolt = <3300000>;
					};

					ab8500_ldo_aux3 {
						regulator-name = "vdd_tf_2v91";
					};

					ab8500_ldo_aux4 {
						regulator-name = "key_led_3.3v";
						regulator-min-microvolt = <3300000>;
						regulator-max-microvolt = <3300000>;
					};

					ab8500_ldo_aux5 {
						regulator-name = "vreg_tsp_1v8";
						regulator-min-microvolt = <1800000>;
						regulator-max-microvolt = <1800000>;
					};

					ab8500_ldo_aux6 {
						regulator-name = "touch_key_2.2v";
						regulator-min-microvolt = <2200000>;
						regulator-max-microvolt = <2200000>;
					};

					ab8500_ldo_aux8 {
						regulator-name = "sensor_1v8";
					};
				};
			};
		};

		mcde@a0350000 {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&dsi_default_mode>;

			dsi@a0351000 {
				panel@0 {
					compatible = "samsung,s6e63m0";
					reg = <0>;
					max-brightness = <15>;
					vdd3-supply = <&panel_reg_3v0>;
					vci-supply = <&panel_reg_1v8>;
					reset-gpios = <&gpio4 11 GPIO_ACTIVE_LOW>;
					/* ESD (electrostatic discharge) detection interrupt */
					interrupt-parent = <&gpio2>;
					interrupts = <18 IRQ_TYPE_EDGE_RISING>;
					interrupt-names = "esd";
					pinctrl-names = "default";
					pinctrl-0 = <&display_default_mode>;
				};
			};
		};
	};

	gpio-keys {
		compatible = "gpio-keys";

		pinctrl-names = "default";
		pinctrl-0 = <&gpio_keys_default>;

		label = "GPIO Buttons";

		volume-up {
			label = "Volume Up";
			/* GPIO67 (VOL_UP) */
			gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEUP>;
		};

		volume-down {
			label = "Volume Down";
			/* GPIO92 (VOL_DOWN) */
			gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEDOWN>;
		};

		home {
			label = "Home";
			/* GPIO91 (HOME_KEY) */
			gpios = <&gpio2 27 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_HOMEPAGE>;
		};
	};

	/* Richtek RT8515GQW Flash LED Driver IC */
	flash {
		compatible = "richtek,rt8515";
		/* GPIO 140 */
		enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
		/* GPIO 141 */
		ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
		/*
		 * RFS is 16 kOhm and RTS is 100 kOhm giving
		 * the flash max current 343mA and torch max
		 * current 55 mA.
		 */
		richtek,rfs-ohms = <16000>;
		richtek,rts-ohms = <100000>;
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_flash_default_mode>;

		led {
			function = LED_FUNCTION_FLASH;
			color = <LED_COLOR_ID_WHITE>;
			flash-max-timeout-us = <250000>;
			flash-max-microamp = <343750>;
			led-max-microamp = <55000>;
		};
	};

	vibrator {
		compatible = "gpio-vibrator";
		/* GPIO195 (MOT_EN) */
		enable-gpios = <&gpio6 3 GPIO_ACTIVE_HIGH>;

		pinctrl-names = "default";
		pinctrl-0 = <&vibrator_default>;
	};

	/* External LDO for eMMC */
	vmem_3v3: regulator-vmem {
		compatible = "regulator-fixed";

		regulator-name = "vmem_3v3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;

		startup-delay-us = <200>;

		/* GPIO223 (MEM_LDO_EN) */
		gpio = <&gpio6 31 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		pinctrl-names = "default";
		pinctrl-0 = <&mem_ldo_default>;
	};

	/* TI TXS0206-29 level translator for 2.9 V */
	sd_level_translator: regulator-sd-level-translator {
		compatible = "regulator-fixed";

		regulator-name = "sd-level-translator";
		regulator-min-microvolt = <2900000>;
		regulator-max-microvolt = <2900000>;

		startup-delay-us = <200>;

		/* GPIO87 (TXS0206-29_EN) */
		gpios = <&gpio2 23 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		pinctrl-names = "default";
		pinctrl-0 = <&sd_level_translator_default>;
	};

	/*
	 * WL_REG_ON takes WLAN out of reset and enables the internal regulators.
	 * The voltage specified here is only used to determine the OCR mask,
	 * the BCM chip is actually connected directly to VBAT.
	 */
	wl_reg_on: regulator-wl-reg-on {
		compatible = "regulator-fixed";

		regulator-name = "wl-reg-on";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;

		startup-delay-us = <100000>;

		/* GPIO215 (WLAN_EN) */
		gpio = <&gpio6 23 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		pinctrl-names = "default";
		pinctrl-0 = <&wlan_en_default>;
	};

	/* MIC5366 GPIO-controlled regulator */
	panel_reg_1v8: regulator-panel-1v8 {
		compatible = "regulator-fixed";

		regulator-name = "panel-fixed-supply";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		/* GPIO219 */
		gpio = <&gpio6 27 GPIO_ACTIVE_HIGH>;

		startup-delay-us = <200>;
		enable-active-high;

		pinctrl-names = "default";
		pinctrl-0 = <&panel_reg_default_mode>;
	};

	/* MIC5366 GPIO-controlled regulator */
	panel_reg_3v0: regulator-panel-3v0 {
		compatible = "regulator-fixed";

		regulator-name = "panel-fixed-supply";
		regulator-min-microvolt = <3000000>;
		regulator-max-microvolt = <3000000>;
		/* GPIO219 */
		gpio = <&gpio6 27 GPIO_ACTIVE_HIGH>;

		startup-delay-us = <200>;
		enable-active-high;

		pinctrl-names = "default";
		pinctrl-0 = <&panel_reg_default_mode>;
	};
};

&pinctrl {
	gpio-keys {
		gpio_keys_default: gpio_keys_default {
			golden_cfg1 {
				pins = "GPIO67",	/* VOL_UP */
				       "GPIO91",	/* HOME_KEY */
				       "GPIO92";	/* VOL_DOWN */
				ste,config = <&gpio_in_pu>;
			};
		};
	};

	i2c-gpio-0 {
		i2c_gpio_0_default: i2c_gpio_0 {
			golden_cfg1 {
				pins = "GPIO77",	/* TOUCHKEY_SCL */
				       "GPIO78";	/* TOUCHKEY_SDA */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};

	flash {
		gpio_flash_default_mode: flash_default {
			golden_cfg1 {
				pins = "GPIO140_B11", "GPIO141_C12";
				ste,config = <&gpio_out_lo>;
			};
		};
	};

	i2c-gpio-1 {
		i2c_gpio_1_default: i2c_gpio_1 {
			golden_cfg1 {
				pins = "GPIO151",	/* COMP_SCL */
				       "GPIO152";	/* COMP_SDA */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};

	touchkey {
		touchkey_default: touchkey_default {
			golden_cfg1 {
				pins = "GPIO79";	/* TOUCHKEY_INT */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};

	sdi0 {
		sd_level_translator_default: sd_level_translator_default {
			golden_cfg1 {
				pins = "GPIO87_B3";	/* TXS0206-29_EN */
				ste,config = <&gpio_out_lo>;
			};
		};
	};

	sdi2 {
		mem_ldo_default: mem_ldo_default {
			golden_cfg1 {
				pins = "GPIO223_AH9";	/* MEM_LDO_EN */
				ste,config = <&gpio_out_hi>;
			};
		};
	};

	mcde {
		dsi_default_mode: dsi_default {
			default_mux1 {
				/* Mux in VSI0 used for DSI TE */
				function = "lcd";
				groups =
				"lcdvsi0_a_1"; /* VSI0 for LCD */
			};
			default_cfg1 {
				pins =
				"GPIO68_E1"; /* VSI0 */
				ste,config = <&in_nopull>;
			};
		};
	};

	display {
		display_default_mode: display_default {
			golden_cfg1 {
				pins = "GPIO139_C9"; /* MIPI_DSI0_RESET_N */
				ste,config = <&gpio_out_lo>;
			};
			golden_cfg2 {
				pins = "GPIO82_C1"; /* LDI_ESD_DET */
				ste,config = <&gpio_in_pu>;
			};
		};
		panel_reg_default_mode: panel_reg_default {
			golden_cfg1 {
				pins = "GPIO219_AG10"; /* LCD_PWR_EN */
				ste,config = <&gpio_out_lo>;
			};
		};
	};

	proximity {
		proximity_default: proximity_default {
			golden_cfg1 {
				pins = "GPIO146_D13";	/* PS_INT */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};

	imu {
		imu_default: imu_default {
			golden_cfg1 {
				pins = "GPIO206_AG24";	/* ACC_INT */
				ste,config = <&gpio_in_pd>;
			};
		};
	};

	tsp {
		tsp_default: tsp_default {
			golden_cfg1 {
				pins = "GPIO218_AH11";	/* TSP_INT_1V8 */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};

	wlan {
		wlan_default: wlan_default {
			golden_cfg1 {
				pins = "GPIO216_AG12";	/* WLAN_HOST_WAKE */
				ste,config = <&gpio_in_pd>;
			};
		};

		wlan_en_default: wlan_en_default {
			golden_cfg1 {
				pins = "GPIO215_AH13";	/* WLAN_EN */
				ste,config = <&gpio_out_lo>;
			};
		};
	};

	bluetooth {
		bluetooth_default: bluetooth_default {
			golden_cfg1 {
				pins = "GPIO199_AH23",	/* BT_WAKE */
				       "GPIO222_AJ9";	/* BT_VREG_ON */
				ste,config = <&gpio_out_lo>;
			};
			golden_cfg2 {
				pins = "GPIO97_D9";	/* BT_HOST_WAKE */
				ste,config = <&gpio_in_nopull>;
			};
		};
	};

	vibrator {
		vibrator_default: vibrator_default {
			golden_cfg1 {
				pins = "GPIO195_AG28";	/* MOT_EN */
				ste,config = <&gpio_out_lo>;
			};
		};
	};
};

&ab8505_gpio {
	/* Hog a few default settings */
	pinctrl-names = "default";
	pinctrl-0 = <&gpio_default>;

	gpio {
		gpio_default: gpio_default {
			golden_mux {
				/* Change unused pins to GPIO mode */
				function = "gpio";
				groups = "gpio3_a_1",	/* default: SysClkReq4 */
					 "gpio14_a_1";	/* default: PWMOut1 */
			};
			golden_cfg1 {
				pins = "GPIO11_B17", "GPIO13_D17", "GPIO50_L4";
				bias-disable;
			};
		};
	};
};