/*
 * Copyright (C) 2013 CircuitCo
 *
 * Virtual cape for UART2 on connector pins P9.21 P9.22
 *
 * 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/;
/plugin/;

/ {
	compatible = "ti,beaglebone", "ti,beaglebone-black"; /* the cape is designed for these boards */

	/* identification */
	part-number = "cape-motoserial"; /* max 16 char. needs to match the filename */
	version = "00A0"; /* standard BB Black cape version number */

	/* state the resources this cape uses */
	exclusive-use =
		/* the pin header uses */
		"P9.24",	/* uart1_txd */
		"P9.26",	/* uart1_rxd */
		"P9.25",	/* power1 */
		"P9.21",	/* uart2_txd */
		"P9.22",	/* uart2_rxd */
		"P9.23",	/* power2 */
		"P9.13",	/* uart4_txd */
		"P9.11",	/* uart4_rxd */
		"P9.14",	/* power4 */
		"P8.37",	/* uart5_txd */
		"P8.38",	/* uart5_rxd */
		"P8.39",	/* power5 */
		/* the hardware ip uses */
		"uart1",
		"gpio3_21",
		"uart2",
		"gpio1_17",
		"uart4",
		"gpio1_18",
		"uart5",
		"gpio2_12";

	fragment@0 {
		target = <&am33xx_pinmux>;
		__overlay__ {

			bb_cape_motoserial_uart1: pinmux_cape_motoserial_uart1 {
				pinctrl-single,pins = <
					0x180 0x20	/* uart1_rxd | MODE0 */
					0x184 0x00	/* uart1_txd | MODE0 */
				>;
			};
			bb_cape_motoserial_uart2: pinmux_cape_motoserial_uart2 {
				pinctrl-single,pins = <
					0x150 0x21	/* uart2_rxd | MODE1 */
					0x154 0x01	/* uart2_txd | MODE1 */
				>;
			};
			bb_cape_motoserial_uart4: pinmux_cape_motoserial_uart4 {
				pinctrl-single,pins = <
					0x070 0x26	/* uart4_rxd_mux2 | MODE6 */
					0x074 0x06	/* uart4_txd_mux2 | MODE6 */
				>;
			};
			bb_cape_motoserial_uart5: pinmux_cape_motoserial_uart5 {
				pinctrl-single,pins = <
					0x0c4 0x24	/* uart5_rxd | MODE4 */
					0x0c0 0x04	/* uart5_txd | MODE4 */
				>;
			};
			bb_cape_motoserial_power: pinmux_cape_motoserial_power {
				pinctrl-single,pins = <
					0x1ac 0x07	/* P9_25 gpio3_21 117, OUTPUT MODE7, POWER1 */
					0x044 0x07	/* P9_23 gpio1_17 49, OUTPUT MODE7, POWER2 */
					0x048 0x07	/* P9_14 gpio1_18 50, OUTPUT MODE7, POWER4 */
					0x0b8 0x07	/* P8_39 gpio2_12 76, OUTPUT MODE7, POWER5 */
				>;
			};
		};
	};

	fragment@1 {
		target = <&uart2>;	/* really uart1 */
		__overlay__ {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&bb_cape_motoserial_uart1>;
		};
	};
	fragment@2 {
		target = <&uart3>;	/* really uart2 */
		__overlay__ {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&bb_cape_motoserial_uart2>;
		};
	};
	fragment@3 {
		target = <&uart5>;	/* really uart4 */
		__overlay__ {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&bb_cape_motoserial_uart4>;
		};
	};
	fragment@4 {
		target = <&uart6>;	/* really uart5 */
		__overlay__ {
			status = "okay";
			pinctrl-names = "default";
			pinctrl-0 = <&bb_cape_motoserial_uart5>;
		};
	};
	fragment@6 {
		target = <&ocp>;
		__overlay__ {
			motoserial_power {
				compatible = "bone-pinmux-helper";
				status = "okay";
				pinctrl-names = "default";
				pinctrl-0 = <&bb_cape_motoserial_power>;
			};
		};
	};
};

