// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
 */

/dts-v1/;

#include <dt-bindings/input/input.h>

/include/ "nspire.dtsi"

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

&fast_timer {
	/* compatible = "arm,sp804", "arm,primecell"; */
};

&uart {
	compatible = "arm,pl011", "arm,primecell";

	clocks = <&uart_clk>, <&apb_pclk>;
	clock-names = "uartclk", "apb_pclk";
};

&timer0 {
	compatible = "arm,sp804", "arm,primecell";
};

&timer1 {
	compatible = "arm,sp804", "arm,primecell";
};

&base_clk {
	compatible = "lsi,nspire-cx-clock";
};

&ahb_clk {
	compatible = "lsi,nspire-cx-ahb-divider";
};

&keypad {
	linux,keymap = <
		MATRIX_KEY(0,  0, 0x1c)
		MATRIX_KEY(0,  1, 0x1c)
		MATRIX_KEY(0,  4, 0x39)
		MATRIX_KEY(0,  5, 0x2c)
		MATRIX_KEY(0,  6, 0x15)
		MATRIX_KEY(0,  7, 0x0b)
		MATRIX_KEY(0,  8, 0x0f)
		MATRIX_KEY(1,  0, 0x2d)
		MATRIX_KEY(1,  1, 0x11)
		MATRIX_KEY(1,  2, 0x2f)
		MATRIX_KEY(1,  3, 0x04)
		MATRIX_KEY(1,  4, 0x16)
		MATRIX_KEY(1,  5, 0x14)
		MATRIX_KEY(1,  6, 0x1f)
		MATRIX_KEY(1,  7, 0x02)
		MATRIX_KEY(1, 10, 0x6a)
		MATRIX_KEY(2,  0, 0x13)
		MATRIX_KEY(2,  1, 0x10)
		MATRIX_KEY(2,  2, 0x19)
		MATRIX_KEY(2,  3, 0x07)
		MATRIX_KEY(2,  4, 0x18)
		MATRIX_KEY(2,  5, 0x31)
		MATRIX_KEY(2,  6, 0x32)
		MATRIX_KEY(2,  7, 0x05)
		MATRIX_KEY(2,  8, 0x28)
		MATRIX_KEY(2,  9, 0x6c)
		MATRIX_KEY(3,  0, 0x26)
		MATRIX_KEY(3,  1, 0x25)
		MATRIX_KEY(3,  2, 0x24)
		MATRIX_KEY(3,  3, 0x0a)
		MATRIX_KEY(3,  4, 0x17)
		MATRIX_KEY(3,  5, 0x23)
		MATRIX_KEY(3,  6, 0x22)
		MATRIX_KEY(3,  7, 0x08)
		MATRIX_KEY(3,  8, 0x35)
		MATRIX_KEY(3,  9, 0x69)
		MATRIX_KEY(4,  0, 0x21)
		MATRIX_KEY(4,  1, 0x12)
		MATRIX_KEY(4,  2, 0x20)
		MATRIX_KEY(4,  4, 0x2e)
		MATRIX_KEY(4,  5, 0x30)
		MATRIX_KEY(4,  6, 0x1e)
		MATRIX_KEY(4,  7, 0x0d)
		MATRIX_KEY(4,  8, 0x37)
		MATRIX_KEY(4,  9, 0x67)
		MATRIX_KEY(5,  1, 0x38)
		MATRIX_KEY(5,  2, 0x0c)
		MATRIX_KEY(5,  3, 0x1b)
		MATRIX_KEY(5,  4, 0x34)
		MATRIX_KEY(5,  5, 0x1a)
		MATRIX_KEY(5,  6, 0x06)
		MATRIX_KEY(5,  8, 0x27)
		MATRIX_KEY(5,  9, 0x0e)
		MATRIX_KEY(5, 10, 0x6f)
		MATRIX_KEY(6,  0, 0x2b)
		MATRIX_KEY(6,  2, 0x4e)
		MATRIX_KEY(6,  3, 0x68)
		MATRIX_KEY(6,  4, 0x03)
		MATRIX_KEY(6,  5, 0x6d)
		MATRIX_KEY(6,  6, 0x09)
		MATRIX_KEY(6,  7, 0x01)
		MATRIX_KEY(6,  9, 0x0f)
		MATRIX_KEY(7,  8, 0x2a)
		MATRIX_KEY(7,  9, 0x1d)
		MATRIX_KEY(7, 10, 0x33)
	>;
};

&vbus_reg {
	gpio = <&gpio 2 0>;
};

/ {
	model = "TI-NSPIRE CX";
	compatible = "ti,nspire-cx";

	memory {
		device_type = "memory";
		reg = <0x10000000 0x4000000>; /* 64 MB */
	};

	uart_clk: uart_clk {
		#clock-cells = <0>;
		compatible = "fixed-clock";
		clock-frequency = <12000000>;
	};

	ahb {
		#address-cells = <1>;
		#size-cells = <1>;

		intc: interrupt-controller@dc000000 {
			compatible = "arm,pl190-vic";
			interrupt-controller;
			reg = <0xdc000000 0x1000>;
			#interrupt-cells = <1>;
		};

		apb@90000000 {
			#address-cells = <1>;
			#size-cells = <1>;

			i2c@90050000 {
				compatible = "snps,designware-i2c";
				reg = <0x90050000 0x1000>;
				interrupts = <20>;
			};
		};
	};

	panel {
		compatible = "ti,nspire-cx-lcd-panel";
		port {
			panel_in: endpoint {
				remote-endpoint = <&clcd_pads>;
			};
		};
	};
	chosen {
		bootargs = "debug earlyprintk console=tty0 console=ttyAMA0,115200n8 root=/dev/ram0";
	};
};