/*
 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
/dts-v1/;

#include "am33xx.dtsi"
#include "am335x-bone-common.dtsi"

&ldo3_reg {
	regulator-min-microvolt = <1800000>;
	regulator-max-microvolt = <1800000>;
	regulator-always-on;
};

&mmc1 {
	vmmc-supply = <&vmmcsd_fixed>;
};

&mmc2 {
	vmmc-supply = <&vmmcsd_fixed>;
	pinctrl-names = "default";
	pinctrl-0 = <&emmc_pins>;
	bus-width = <8>;
	ti,non-removable;
	status = "okay";
};

&am33xx_pinmux {
		lcd_pins_default: lcd_pins_default {
			pinctrl-single,pins = <
				0x20 0x01	/* gpmc_ad8.lcd_data16, OUTPUT | MODE1 */
				0x24 0x01	/* gpmc_ad9.lcd_data17, OUTPUT | MODE1 */
				0x28 0x01	/* gpmc_ad10.lcd_data18, OUTPUT | MODE1 */
				0x2c 0x01	/* gpmc_ad11.lcd_data19, OUTPUT | MODE1 */
				0x30 0x01	/* gpmc_ad12.lcd_data20, OUTPUT | MODE1 */
				0x34 0x01	/* gpmc_ad13.lcd_data21, OUTPUT | MODE1 */
				0x38 0x01	/* gpmc_ad14.lcd_data22, OUTPUT | MODE1 */
				0x3c 0x01	/* gpmc_ad15.lcd_data23, OUTPUT | MODE1 */
				0xa0 0x00	/* lcd_data0.lcd_data0, OUTPUT | MODE0 */
				0xa4 0x00	/* lcd_data1.lcd_data1, OUTPUT | MODE0 */
				0xa8 0x00	/* lcd_data2.lcd_data2, OUTPUT | MODE0 */
				0xac 0x00	/* lcd_data3.lcd_data3, OUTPUT | MODE0 */
				0xb0 0x00	/* lcd_data4.lcd_data4, OUTPUT | MODE0 */
				0xb4 0x00	/* lcd_data5.lcd_data5, OUTPUT | MODE0 */
				0xb8 0x00	/* lcd_data6.lcd_data6, OUTPUT | MODE0 */
				0xbc 0x00	/* lcd_data7.lcd_data7, OUTPUT | MODE0 */
				0xc0 0x00	/* lcd_data8.lcd_data8, OUTPUT | MODE0 */
				0xc4 0x00	/* lcd_data9.lcd_data9, OUTPUT | MODE0 */
				0xc8 0x00	/* lcd_data10.lcd_data10, OUTPUT | MODE0 */
				0xcc 0x00	/* lcd_data11.lcd_data11, OUTPUT | MODE0 */
				0xd0 0x00	/* lcd_data12.lcd_data12, OUTPUT | MODE0 */
				0xd4 0x00	/* lcd_data13.lcd_data13, OUTPUT | MODE0 */
				0xd8 0x00	/* lcd_data14.lcd_data14, OUTPUT | MODE0 */
				0xdc 0x00	/* lcd_data15.lcd_data15, OUTPUT | MODE0 */
				0xe0 0x00	/* lcd_vsync.lcd_vsync, OUTPUT | MODE0 */
				0xe4 0x00	/* lcd_hsync.lcd_hsync, OUTPUT | MODE0 */
				0xe8 0x00	/* lcd_pclk.lcd_pclk, OUTPUT | MODE0 */
				0xec 0x00	/* lcd_ac_bias_en.lcd_ac_bias_en, OUTPUT | MODE0 */
			>;
		};

		lcd_pins_sleep: lcd_pins_sleep {
			pinctrl-single,pins = <
				0x20 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad8.lcd_data16 */
				0x24 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad9.lcd_data17 */
				0x28 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad10.lcd_data18 */
				0x2c (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad11.lcd_data19 */
				0x30 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad12.lcd_data20 */
				0x34 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad13.lcd_data21 */
				0x38 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad14.lcd_data22 */
				0x3c (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* gpmc_ad15.lcd_data23 */
				0xa0 (PULL_DISABLE | MUX_MODE7)		/* lcd_data0.lcd_data0 */
				0xa4 (PULL_DISABLE | MUX_MODE7)		/* lcd_data1.lcd_data1 */
				0xa8 (PULL_DISABLE | MUX_MODE7)		/* lcd_data2.lcd_data2 */
				0xac (PULL_DISABLE | MUX_MODE7)		/* lcd_data3.lcd_data3 */
				0xb0 (PULL_DISABLE | MUX_MODE7)		/* lcd_data4.lcd_data4 */
				0xb4 (PULL_DISABLE | MUX_MODE7)		/* lcd_data5.lcd_data5 */
				0xb8 (PULL_DISABLE | MUX_MODE7)		/* lcd_data6.lcd_data6 */
				0xbc (PULL_DISABLE | MUX_MODE7)		/* lcd_data7.lcd_data7 */
				0xc0 (PULL_DISABLE | MUX_MODE7)		/* lcd_data8.lcd_data8 */
				0xc4 (PULL_DISABLE | MUX_MODE7)		/* lcd_data9.lcd_data9 */
				0xc8 (PULL_DISABLE | MUX_MODE7)		/* lcd_data10.lcd_data10 */
				0xcc (PULL_DISABLE | MUX_MODE7)		/* lcd_data11.lcd_data11 */
				0xd0 (PULL_DISABLE | MUX_MODE7)		/* lcd_data12.lcd_data12 */
				0xd4 (PULL_DISABLE | MUX_MODE7)		/* lcd_data13.lcd_data13 */
				0xd8 (PULL_DISABLE | MUX_MODE7)		/* lcd_data14.lcd_data14 */
				0xdc (PULL_DISABLE | MUX_MODE7)		/* lcd_data15.lcd_data15 */
				0xe0 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_vsync.lcd_vsync, OUTPUT | MODE0 */
				0xe4 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_hsync.lcd_hsync */
				0xe8 (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_pclk.lcd_pclk */
				0xec (PIN_INPUT_PULLDOWN | MUX_MODE7)	/* lcd_ac_bias_en.lcd_ac_bias_en */
			>;
		};


             /* 	i2c1_pins: pinmux_i2c1_pins { 
                        pinctrl-single,pins = <
                                0x158 (PIN_INPUT | MUX_MODE2) */   /* spi0_d1.i2c1_sda */
                              /*  0x15c (PIN_INPUT | MUX_MODE2) */    /* spi0_cs0.i2c1_scl */
/*                        >;
                };
*/
              	i2c2_pins: pinmux_i2c2_pins { 
                        pinctrl-single,pins = <
                                0x150 (PIN_INPUT_PULLUP | MUX_MODE2)    /* spi0_sclk.i2c2_sda */
                                0x154 (PIN_INPUT_PULLUP | MUX_MODE2)    /* spi0_d0.i2c2_scl */
                        >;
                };


               spi1_pins: pinmux_spi1_pins {
                        pinctrl-single,pins = <
                                0x190 (PIN_INPUT_PULLUP | MUX_MODE3) /* mcasp0_aclkx.spi1_sclk */
                                0x194 (PIN_INPUT_PULLUP | MUX_MODE3)  /* mcasp0_fsx.spi1_d0 */
                                0x198 (PIN_OUTPUT_PULLUP | MUX_MODE3) /* mcasp0_axr0.spi1_d1 */
                                0x19c (PIN_OUTPUT_PULLUP | MUX_MODE3) /* mcasp0_ahclrk.spi1_cs0 */
                                0x164 (PIN_OUTPUT_PULLUP | MUX_MODE2) /* ecap0_in.pwm0_out */
                        >;
                };


		edt_ft5x06_pins: pinmux_edt_ft5x06_pins{
                        pinctrl-single,pins = <
                                0x1ac (PIN_OUTPUT | MUX_MODE7)    /* mcasp0_ahclkx.gpio3.21 RESET TOUCH P9_25*/
                                0x8c  (PIN_INPUT | MUX_MODE7)    /* gpmc_clk_mux0.gpio2.1  INT TOUCH P8_18 */
                        >;

		};


               uart4_pins_default: pinmux_uart4_pins_default {
                        pinctrl-single,pins = <
                                0x070 (PIN_INPUT_PULLUP | MUX_MODE6)    /* gpmc_wait0.uart4_rxd */
                                0x074 (PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* gpmc_wpn.uart4_txd */ 
				0x078 (PIN_OUTPUT | MUX_MODE7)		/* gpmc_ben1.gpio1.28 */
                        >;
                };


                uart4_pins_sleep: pinmux_uart4_pins_sleep {
                        pinctrl-single,pins = <
                                0x070 (PIN_INPUT_PULLDOWN | MUX_MODE7)
                                0x074 (PIN_INPUT_PULLDOWN | MUX_MODE7)
				0x078 (PIN_INPUT_PULLDOWN | MUX_MODE7)
                        >;
                };

               uart1_pins_default: pinmux_uart1_pins_default {
                        pinctrl-single,pins = <
                                0x180 (PIN_INPUT_PULLUP | MUX_MODE0)    /* uart1_rxd.uart1_rxd */
                                0x184 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* uart1_txd.uart1_txd */ 
				0x178 (PIN_INPUT_PULLUP | MUX_MODE0)	/* i2c2_sda.uart1_ctsn */
                                0x17c (PIN_OUTPUT | MUX_MODE0)  	/* i2c2_scl.uart1_rtsn */
                        >;
                };


                uart1_pins_sleep: pinmux_uart1_pins_sleep {
                        pinctrl-single,pins = <
                                0x180 (PIN_INPUT_PULLDOWN | MUX_MODE0)  /* uart1_rxd.uart1_rxd */
                                0x184 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* uart1_txd.uart1_txd */ 
				0x178 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* i2c2_sda.uart1_ctsn */
                                0x17c (PIN_INPUT_PULLDOWN | MUX_MODE0)  /* i2c2_scl.uart1_rtsn */
                        >;
                };

		timer7_pins: pinmux_timer7_pins {
                        pinctrl-single,pins = <
                               0x094 (PIN_OUTPUT_PULLDOWN | MUX_MODE2)  /* gpmc_oen_ren.timer7 */
				>;
				};

		profibus_pins_default: pinmux_profibus_pins_default {
                        pinctrl-single,pins = < 
                        0x158 (PIN_INPUT_PULLUP | MUX_MODE4)    /* spi0_d1.uart0_rxd */
                        0x15c (PIN_OUTPUT_PULLDOWN | MUX_MODE4) /* spi0_cs0.uart0_txd */ 
			0x1a4 (PIN_OUTPUT | MUX_MODE5)		/* mcasp0_fsr.gpio3.19 */
                	>;
                };
};

&timer7 {
	pinctrl-names = "default";
	pinctrl-0 = <&timer7_pins>; 
	status = "okay";
};

&i2c0 {
	hdmi1: hdmi@70 {
	      compatible = "nxp,tda998x";
	      reg = <0x70>;
	};
};


&i2c2 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c2_pins>;
    status = "okay";
    clock-frequency = <400000>;
};


&i2c2 {
        egalax_ts@2A {
                compatible = "eeti,egalax_i2c";
                reg = <0x2A>;
                pinctrl-names = "default";
                pinctrl-0 = <&edt_ft5x06_pins>;
                interrupt-parent = <&gpio2>;
                interrupts = <1 8>;
                int-gpios = <&gpio2 1 0>;
		linux,wakeup;
        };
};


&spi1 {
	pinctrl-names = "default";
        pinctrl-0 = <&spi1_pins>;

	clock-frequency = <1000000>;
        status = "okay";
	spi1_0{
		compatible = "spidev";
                reg = <0>;
		spi-max-frequency = <10000000>;
        };

	spi1_1{
		compatible = "spidev";
                reg = <1>;
		spi-max-frequency = <10000000>;
        };
};


&lcdc {
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&lcd_pins_default>;
        pinctrl-1 = <&lcd_pins_sleep>;
        status = "okay";
	display-timings {
		800x480 {
			hactive         = <1280>;
			vactive         = <800>;
			hback-porch     = <50>;
			hfront-porch    = <60>;
			hsync-len       = <50>;
			vback-porch     = <10>;
			vfront-porch    = <8>;
			vsync-len       = <5>;
			clock-frequency = <72000000>;
			hsync-active    = <0>;
			vsync-active    = <0>;
			de-active	= <1>;
			pixelclk-active = <0>;
		};
	};
};

&tscadc {
        status = "okay";
        tsc {
                ti,wires = <4>;
                ti,x-plate-resistance = <200>;
                ti,coordinate-readouts = <5>; 
                ti,wire-config = <0x00 0x11 0x22 0x33>;
        };
};

&uart4 {
	pinctrl-names = "default", "sleep";
        pinctrl-0 = <&uart4_pins_default>;
        pinctrl-1 = <&uart4_pins_sleep>;

        status = "okay";

	rts-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
	rs485-rts-active-high;
	rs485-rts-delay = <0 0>;
	linux,rs485-enabled-at-boot-time;
	rs485-rx-during-tx;
};

&uart1 {
	pinctrl-names = "default", "sleep";
        pinctrl-0 = <&uart1_pins_default>;
        pinctrl-1 = <&uart1_pins_sleep>;

        status = "okay";
};

&pruss {
	pinctrl-names = "default";
        pinctrl-0 = <&profibus_pins_default>;
	status = "okay";
};

/ {
        pwm7: dmtimer-pwm@7 {
                compatible = "ti,omap-dmtimer-pwm";
                ti,timers = <&timer7>;
                #pwm-cells = <3>;
        };

        pwm-beeper {
                compatible = "pwm-beeper";
                pwms = <&pwm7>;
        };
};
