board: asus: transformer: add ASUS Transformer T20 family support
The Asus Eee Pad Transformer family are 2-in-1 detachable/slider
tablets developed by Asus that run the Android operating system.
The Eee Pad Transformers feature a 10.1-inch (260 mm) display,
an Nvidia Tegra 2 dual-core chip, 1 GB of RAM, and 16/32 GB of storage.
Transformers board derives from Nvidia Ventana development board.
This patch brings support for all 3 known T20 Transformers:
- Asus Eee Pad Transformer TF101
- Asus Eee Pad Transformer TF101G
- Asus Eee Pad Slider SL101
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101
Tested-by: Antoni Aloy Torrens <aaloytorrens@gmail.com> # ASUS TF101
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
diff --git a/board/asus/transformer-t20/Kconfig b/board/asus/transformer-t20/Kconfig
new file mode 100644
index 0000000..d5fe412
--- /dev/null
+++ b/board/asus/transformer-t20/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_TRANSFORMER_T20
+
+config SYS_BOARD
+ default "transformer-t20"
+
+config SYS_VENDOR
+ default "asus"
+
+config SYS_CONFIG_NAME
+ default "transformer-t20"
+
+endif
diff --git a/board/asus/transformer-t20/MAINTAINERS b/board/asus/transformer-t20/MAINTAINERS
new file mode 100644
index 0000000..7bf9357
--- /dev/null
+++ b/board/asus/transformer-t20/MAINTAINERS
@@ -0,0 +1,8 @@
+TRANSFORMER T20 BOARD
+M: Svyatoslav Ryhel <clamor95@gmail.com>
+S: Maintained
+F: arch/arm/dts/tegra20-asus-*
+F: board/asus/transformer-t20/
+F: configs/transformer_t20_defconfig
+F: doc/board/asus/transformer_t20.rst
+F: include/configs/transformer-t20.h
diff --git a/board/asus/transformer-t20/Makefile b/board/asus/transformer-t20/Makefile
new file mode 100644
index 0000000..8522f82
--- /dev/null
+++ b/board/asus/transformer-t20/Makefile
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2010,2011
+# NVIDIA Corporation <www.nvidia.com>
+#
+# (C) Copyright 2021
+# Svyatoslav Ryhel <clamor95@gmail.com>
+
+obj-y += transformer-t20.o
diff --git a/board/asus/transformer-t20/configs/sl101.config b/board/asus/transformer-t20/configs/sl101.config
new file mode 100644
index 0000000..4f639e1
--- /dev/null
+++ b/board/asus/transformer-t20/configs/sl101.config
@@ -0,0 +1 @@
+CONFIG_DEFAULT_DEVICE_TREE="tegra20-asus-sl101"
diff --git a/board/asus/transformer-t20/configs/tf101.config b/board/asus/transformer-t20/configs/tf101.config
new file mode 100644
index 0000000..44a1d1a
--- /dev/null
+++ b/board/asus/transformer-t20/configs/tf101.config
@@ -0,0 +1 @@
+CONFIG_DEFAULT_DEVICE_TREE="tegra20-asus-tf101"
diff --git a/board/asus/transformer-t20/configs/tf101g.config b/board/asus/transformer-t20/configs/tf101g.config
new file mode 100644
index 0000000..0ccf249
--- /dev/null
+++ b/board/asus/transformer-t20/configs/tf101g.config
@@ -0,0 +1 @@
+CONFIG_DEFAULT_DEVICE_TREE="tegra20-asus-tf101g"
diff --git a/board/asus/transformer-t20/transformer-t20.c b/board/asus/transformer-t20/transformer-t20.c
new file mode 100644
index 0000000..42fc563
--- /dev/null
+++ b/board/asus/transformer-t20/transformer-t20.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2010,2011
+ * NVIDIA Corporation <www.nvidia.com>
+ *
+ * (C) Copyright 2021
+ * Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+/* T20 Transformers derive from Ventana board */
+
+#include <dm.h>
+#include <i2c.h>
+#include <log.h>
+#include <linux/delay.h>
+
+#define TPS6586X_I2C_ADDRESS 0x34
+#define TPS6586X_SUPPLYENE 0x14
+#define EXITSLREQ_BIT BIT(1)
+#define SLEEP_MODE_BIT BIT(3)
+
+#ifdef CONFIG_CMD_POWEROFF
+int do_poweroff(struct cmd_tbl *cmdtp,
+ int flag, int argc, char *const argv[])
+{
+ struct udevice *dev;
+ uchar data_buffer[1];
+ int ret;
+
+ ret = i2c_get_chip_for_busnum(0, TPS6586X_I2C_ADDRESS, 1, &dev);
+ if (ret) {
+ log_debug("cannot find PMIC I2C chip\n");
+ return 0;
+ }
+
+ ret = dm_i2c_read(dev, TPS6586X_SUPPLYENE, data_buffer, 1);
+ if (ret)
+ return ret;
+
+ data_buffer[0] &= ~EXITSLREQ_BIT;
+
+ ret = dm_i2c_write(dev, TPS6586X_SUPPLYENE, data_buffer, 1);
+ if (ret)
+ return ret;
+
+ data_buffer[0] |= SLEEP_MODE_BIT;
+
+ ret = dm_i2c_write(dev, TPS6586X_SUPPLYENE, data_buffer, 1);
+ if (ret)
+ return ret;
+
+ // wait some time and then print error
+ mdelay(5000);
+ printf("Failed to power off!!!\n");
+ return 1;
+}
+#endif