// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright 2013 Eukréa Electromatique <eric@eukrea.com>
 * Copyright 2013 Eukréa Electromatique <denis@eukrea.com>
 */

#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>
#include "imx28.dtsi"

/ {
	model = "Eukrea Electromatique MBMX28LC";
	compatible = "eukrea,mbmx28lc", "fsl,imx28";

	backlight {
		compatible = "pwm-backlight";
		pwms = <&pwm 4 1000000>;
		brightness-levels = <0 25 50 75 100 125 150 175 200 225 255>;
		default-brightness-level = <10>;
	};

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

		switch-sw3 {
			label = "SW3";
			gpios = <&gpio1 21 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_MISC>;
			wakeup-source;
		};
	};

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

		switch-sw4 {
			label = "SW4";
			gpios = <&gpio1 20 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_MISC>;
			wakeup-source;
		};
	};

	led-d6 {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&led_d6_pins_mbmx28lc>;

		led1 {
			label = "d6";
			gpios = <&gpio1 23 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "heartbeat";
		};
	};

	led-d7 {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&led_d7_pins_mbmx28lc>;

		led1 {
			label = "d7";
			gpios = <&gpio1 22 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "default-on";
		};
	};

	reg_3p3v: regulator-0 {
		compatible = "regulator-fixed";
		regulator-name = "3P3V";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
	};

	reg_lcd_3v3: regulator-1 {
		compatible = "regulator-fixed";
		pinctrl-names = "default";
		pinctrl-0 = <&reg_lcd_3v3_pins_mbmx28lc>;
		regulator-name = "lcd-3v3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		gpio = <&gpio3 30 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	reg_usb0_vbus: regulator-2 {
		compatible = "regulator-fixed";
		pinctrl-names = "default";
		pinctrl-0 = <&reg_usb0_vbus_pins_mbmx28lc>;
		regulator-name = "usb0_vbus";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&gpio1 18 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	reg_usb1_vbus: regulator-3 {
		compatible = "regulator-fixed";
		pinctrl-names = "default";
		pinctrl-0 = <&reg_usb1_vbus_pins_mbmx28lc>;
		regulator-name = "usb1_vbus";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&gpio1 19 GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	sound {
		compatible = "fsl,imx28-mbmx28lc-sgtl5000",
			     "fsl,mxs-audio-sgtl5000";
		model = "imx28-mbmx28lc-sgtl5000";
		saif-controllers = <&saif0 &saif1>;
		audio-codec = <&sgtl5000>;
	};
};

&duart {
	pinctrl-names = "default";
	pinctrl-0 = <&duart_4pins_a>;
	status = "okay";
};

&i2c0 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c0_pins_a>;
	status = "okay";

	sgtl5000: codec@a {
		compatible = "fsl,sgtl5000";
		reg = <0x0a>;
		#sound-dai-cells = <0>;
		VDDA-supply = <&reg_3p3v>;
		VDDIO-supply = <&reg_3p3v>;
		clocks = <&saif0>;
	};
};

&lcdif {
	pinctrl-names = "default";
	pinctrl-0 = <&lcdif_18bit_pins_a &lcdif_pins_mbmx28lc>;
	lcd-supply = <&reg_lcd_3v3>;
	display = <&display0>;
	status = "okay";

	display0: display0 {
		model = "43WVF1G-0";
		bits-per-pixel = <16>;
		bus-width = <18>;

		display-timings {
			native-mode = <&timing0>;
			timing0: timing0 {
				clock-frequency = <9072000>;
				hactive = <480>;
				vactive = <272>;
				hback-porch = <10>;
				hfront-porch = <5>;
				vback-porch = <8>;
				vfront-porch = <8>;
				hsync-len = <40>;
				vsync-len = <10>;
				hsync-active = <0>;
				vsync-active = <0>;
				de-active = <1>;
				pixelclk-active = <1>;
			};
		};
	};
};

&lradc {
	fsl,lradc-touchscreen-wires = <4>;
	status = "okay";
};

&pinctrl {
	gpio_button_sw3_pins_mbmx28lc: gpio-button-sw3-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_D21__GPIO_1_21
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};

	gpio_button_sw4_pins_mbmx28lc: gpio-button-sw4-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_D20__GPIO_1_20
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};

	lcdif_pins_mbmx28lc: lcdif-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_VSYNC__LCD_VSYNC
			MX28_PAD_LCD_HSYNC__LCD_HSYNC
			MX28_PAD_LCD_DOTCLK__LCD_DOTCLK
			MX28_PAD_LCD_ENABLE__LCD_ENABLE
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};

	led_d6_pins_mbmx28lc: led-d6-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_D23__GPIO_1_23
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};

	led_d7_pins_mbmx28lc: led-d7-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_D22__GPIO_1_22
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};

	reg_lcd_3v3_pins_mbmx28lc: lcd-3v3-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_RESET__GPIO_3_30
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};

	reg_usb0_vbus_pins_mbmx28lc: reg-usb0-vbus-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_D18__GPIO_1_18
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};

	reg_usb1_vbus_pins_mbmx28lc: reg-usb1-vbus-mbmx28lc@0 {
		reg = <0>;
		fsl,pinmux-ids = <
			MX28_PAD_LCD_D19__GPIO_1_19
		>;
		fsl,drive-strength = <MXS_DRIVE_4mA>;
		fsl,voltage = <MXS_VOLTAGE_HIGH>;
		fsl,pull-up = <MXS_PULL_DISABLE>;
	};
};

&pwm {
	pinctrl-names = "default";
	pinctrl-0 = <&pwm4_pins_a>;
	status = "okay";
};

&saif0 {
	pinctrl-names = "default";
	pinctrl-0 = <&saif0_pins_a>;
	status = "okay";
};

&saif1 {
	pinctrl-names = "default";
	pinctrl-0 = <&saif1_pins_a>;
	fsl,saif-master = <&saif0>;
	status = "okay";
};

&ssp0 {
	compatible = "fsl,imx28-mmc";
	pinctrl-names = "default";
	pinctrl-0 = <&mmc0_4bit_pins_a &mmc0_cd_cfg &mmc0_sck_cfg>;
	bus-width = <4>;
	cd-inverted;
	status = "okay";
};

&usb0 {
	disable-over-current;
	vbus-supply = <&reg_usb0_vbus>;
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&usb0_id_pins_b>;
};

&usb1 {
	vbus-supply = <&reg_usb1_vbus>;
	status = "okay";
};

&usbphy0 {
	status = "okay";
};

&usbphy1 {
	status = "okay";
};