/*
 *       Copyright (C) 2013 Tom King <ka6sox@gmail.com>
 *		 (C) 2013 Ian McMahon <ian.mcmahon@prototechnical.com>
 *		 (C) 2014 Timothy Pearson <kb9vqf@pearsoncomputing.net>
 *
 * 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";
	
	/* identification */
	manufacturer = "Raptor Engineering";
	board-name = "Universal Laboratory Debug Control Interface";
	model = "ULABCTL001";
	part-number = "BB-BONE-ULAB";
	version = "0001";
	
	/* state the resources this cape uses */
	exclusive-use =
		/* the pin header uses */
		"P8.45",	/* GPMC: gpmc_a0 */
		"P8.46",	/* GPMC: gpmc_a1 */
		"P9.14",	/* GPMC: gpmc_a2 */
		"P8.44",	/* GPMC: gpmc_a3 */
		"P8.41",	/* GPMC: gpmc_a4 */
		"P8.42",	/* GPMC: gpmc_a5 */
		"P8.39",	/* GPMC: gpmc_a6 */
		"P8.40",	/* GPMC: gpmc_a7 */
		"P8.27",	/* GPMC: gpmc_a8 */
		"P8.29",	/* GPMC: gpmc_a9 */
		"P8.28",	/* GPMC: gpmc_a10 */
		"P8.30",	/* GPMC: gpmc_a11 */
		"P8.37",	/* GPMC: gpmc_a12 */
		"P8.38",	/* GPMC: gpmc_a13 */
		"P8.36",	/* GPMC: gpmc_a14 */
		"P8.34",	/* GPMC: gpmc_a15 */
		"P8.35",	/* GPMC: gpmc_a16 */
		"P8.33",	/* GPMC: gpmc_a17 */
		"P8.31",	/* GPMC: gpmc_a18 */
		"P8.32",	/* GPMC: gpmc_a19 */

		"P8.25",	/* GPMC: gpmc_ad0 */
		"P8.24",	/* GPMC: gpmc_ad1 */
		"P8.5",		/* GPMC: gpmc_ad2 */
		"P8.6",		/* GPMC: gpmc_ad3 */
		"P8.23",	/* GPMC: gpmc_ad4 */
		"P8.22",	/* GPMC: gpmc_ad5 */
		"P8.3",		/* GPMC: gpmc_ad6 */
		"P8.4", 	/* GPMC: gpmc_ad7 */

		"P8.7",		/* GPMC: gpmc_advn_ale */
		"P8.8",		/* GPMC: gpmc_oen_ren */
		"P8.10",	/* GPMC: gpmc_wen */
	
		"P9.11",	/* GPIO: gpio0[30] */
		"P9.13",	/* GPIO: gpio0[31] */
		"P9.21",	/* GPIO: gpio0[3] */
		"P9.22",	/* GPIO: gpio0[2] */

		"P8.43",	/* GPIO: boot select */

		/* the hardware IP this cape uses */
		"GPMC";

	fragment@0 {
		target = <&am33xx_pinmux>;
		__overlay__ {
			bb_gpmc_pins: pinmux_bb_gpmc_pins {
				pinctrl-single,pins = <

				/* address bus */
				0x0a0 0x01  /* gpmc_a0, OUTPUT_PULLDOWN | MODE1 */
				0x0a4 0x01  /* gpmc_a1, OUTPUT_PULLDOWN | MODE1 */
				0x048 0x00  /* gpmc_a2, OUTPUT_PULLDOWN | MODE0 */
				0x0ac 0x01  /* gpmc_a3, OUTPUT_PULLDOWN | MODE1 */
				0x0b0 0x01  /* gpmc_a4, OUTPUT_PULLDOWN | MODE1 */
				0x0b4 0x01  /* gpmc_a5, OUTPUT_PULLDOWN | MODE1 */
				0x0b8 0x01  /* gpmc_a6, OUTPUT_PULLDOWN | MODE1 */
				0x0bc 0x01  /* gpmc_a7, OUTPUT_PULLDOWN | MODE1 */
				0x0e0 0x01  /* gpmc_a8, OUTPUT_PULLDOWN | MODE1 */
				0x0e4 0x01  /* gpmc_a9, OUTPUT_PULLDOWN | MODE1 */
				0x0e8 0x01  /* gpmc_a10, OUTPUT_PULLDOWN | MODE1 */
				0x0ec 0x01  /* gpmc_a11, OUTPUT_PULLDOWN | MODE1 */
				0x0c0 0x01  /* gpmc_a12, OUTPUT_PULLDOWN | MODE1 */
				0x0c4 0x01  /* gpmc_a13, OUTPUT_PULLDOWN | MODE1 */
				0x0c8 0x01  /* gpmc_a14, OUTPUT_PULLDOWN | MODE1 */
				0x0cc 0x01  /* gpmc_a15, OUTPUT_PULLDOWN | MODE1 */
				0x0d0 0x01  /* gpmc_a16, OUTPUT_PULLDOWN | MODE1 */
				0x0d4 0x01  /* gpmc_a17, OUTPUT_PULLDOWN | MODE1 */
				0x0d8 0x01  /* gpmc_a18, OUTPUT_PULLDOWN | MODE1 */
				0x0dc 0x01  /* gpmc_a19, OUTPUT_PULLDOWN | MODE1 */

				/* address/data muxed bus */
				0x000 0x30  /* gpmc_ad0, INPUT_PULLUP | MODE0 */
				0x004 0x30  /* gpmc_ad1, INPUT_PULLUP | MODE0 */
				0x008 0x30  /* gpmc_ad2, INPUT_PULLUP | MODE0 */
				0x00c 0x30  /* gpmc_ad3, INPUT_PULLUP | MODE0 */
				0x010 0x30  /* gpmc_ad4, INPUT_PULLUP | MODE0 */
				0x014 0x30  /* gpmc_ad5, INPUT_PULLUP | MODE0 */
				0x018 0x30  /* gpmc_ad6, INPUT_PULLUP | MODE0 */
				0x01c 0x30  /* gpmc_ad7, INPUT_PULLUP | MODE0 */

				/* control */
				0x090 0x10  /* gpmc_advn_ale, OUTPUT_PULLUP | MODE0 */
				0x094 0x10  /* gpmc_oen_ren, OUTPUT_PULLUP | MODE0 */
				0x098 0x10  /* gpmc_wen, OUTPUT_PULLUP | MODE0 */

				/* gpio */
				0x070 0x07  /* gpio0[30], OUTPUT_PULLDOWN | MODE7 */
				0x074 0x07  /* gpio0[31], OUTPUT_PULLDOWN | MODE7 */
				0x154 0x27  /* gpio0[3], INPUT_PULLDOWN | MODE7 */
				0x150 0x07  /* gpio0[2], OUTPUT_PULLDOWN | MODE7 */

				>;
			};
		};
	};
	
	fragment@1 {
		target = <&gpmc>;
		depth = <1>;    /* only create devices on depth 1 */
	
		/* stupid warnings */
		#address-cells = <1>;
		#size-cells = <1>;
	
		__overlay__ {
			status = "okay";
	
			#address-cells = <2>;
			#size-cells = <1>;
	
			pinctrl-names = "default";
			pinctrl-0 = <&bb_gpmc_pins>;
	
			/* chip select ranges */
			ranges = <0 0 0x10000000 0x02000000>; /* CS0 @addr 0x01000000, size 0x02000000 */
	
			sram@0 {
				compatible = "raptorengineering,ulab","sram";
				address-cells = <1>;
				size-cells = <1>;
				bank-width = <1>;
			};
		};
	};
};
