board: nexell: artik305: Add support new board
authorJaewon Kim <jaewon02.kim@samsung.com>
Mon, 19 Jun 2017 12:15:56 +0000 (21:15 +0900)
committerJaewon Kim <jaewon02.kim@samsung.com>
Mon, 19 Jun 2017 13:21:39 +0000 (22:21 +0900)
This patch adds support for Nexell S5p4418 based Artik305 board.
Artik305 board is very similar to Artik530.

Change-Id: Ia0e496d4cb91b53443eb36ee41c2a87b9d537e6c
Signed-off-by: Jaewon Kim <jaewon02.kim@samsung.com>
board/nexell/s5p4418/Kconfig
board/nexell/s5p4418/Makefile
board/nexell/s5p4418/artik305_raptor/MAINTAINERS [new file with mode: 0644]
board/nexell/s5p4418/artik305_raptor/Makefile [new file with mode: 0644]
board/nexell/s5p4418/artik305_raptor/board.c [new file with mode: 0644]

index ee9dfcddb52df988554b0f7d520f69eb7488253a..94492710afa90ff550351a67a6677f2de778fd46 100644 (file)
@@ -11,6 +11,11 @@ config TARGET_ARTIK530_RAPTOR
        help
          Support for artik530_raptor platform.
 
+config TARGET_ARTIK305_RAPTOR
+        bool "ARTIK305_RAPTOR"
+       help
+         Support for artik305_raptor platform.
+
 endchoice
 
 config SYS_VENDOR
index 04ea9428f9bdfee3c729f1118259ee615b407383..591b6fc0829e53da3ae7c9f1f9d6831d560ea616 100644 (file)
@@ -6,4 +6,5 @@
 #
 
 obj-$(CONFIG_TARGET_S5P4418_DRONE)     += drone/
+obj-$(CONFIG_TARGET_ARTIK305_RAPTOR)   += artik305_raptor/
 obj-$(CONFIG_TARGET_ARTIK530_RAPTOR)   += artik530_raptor/
diff --git a/board/nexell/s5p4418/artik305_raptor/MAINTAINERS b/board/nexell/s5p4418/artik305_raptor/MAINTAINERS
new file mode 100644 (file)
index 0000000..54584d0
--- /dev/null
@@ -0,0 +1,6 @@
+ARTIK305_RAPTOR BOARD
+M:  Jaewon Kim <jaewon02.kim@samsung.com>
+S:  Maintained
+F:  board/nexell/s5p4418/artik305_raptor/
+F:  include/configs/artik305_raptor.h
+F:  configs/artik305_raptor_defconfig
diff --git a/board/nexell/s5p4418/artik305_raptor/Makefile b/board/nexell/s5p4418/artik305_raptor/Makefile
new file mode 100644 (file)
index 0000000..c87252c
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2017 Samsung Electronics.
+# Jaewon Kim <jaewon02.kim@samsung.com>
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+obj-y                  += board.o
diff --git a/board/nexell/s5p4418/artik305_raptor/board.c b/board/nexell/s5p4418/artik305_raptor/board.c
new file mode 100644 (file)
index 0000000..39627bd
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * (C) Copyright 2017 Samsung Electronics.
+ * Jaewon Kim <jaewon02.kim@samsung.com>
+ *
+ * SPDX-License-Identifier:      GPL-2.0+
+ */
+
+#include <config.h>
+#include <common.h>
+#include <asm/io.h>
+
+#include <asm/arch/nexell.h>
+#include <asm/arch/nx_gpio.h>
+#include <memalign.h>
+
+#ifdef CONFIG_DM_PMIC_NXE2000
+#include <dm.h>
+#include <dm/uclass-internal.h>
+#include <power/pmic.h>
+#include <power/nxe2000.h>
+#endif
+
+#ifdef CONFIG_USB_GADGET
+#include <usb.h>
+#endif
+
+#ifdef CONFIG_SENSORID_ARTIK
+#include <sensorid.h>
+#include <sensorid_artik.h>
+#endif
+
+#ifdef CONFIG_ARTIK_OTA
+#include <artik_ota.h>
+#endif
+
+#ifdef CONFIG_ARTIK_MAC
+#include <artik_mac.h>
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_REVISION_TAG
+u32 board_rev;
+
+u32 get_board_rev(void)
+{
+       return board_rev;
+}
+
+static void check_hw_revision(void)
+{
+       u32 val = 0;
+
+       val |= nx_gpio_get_input_value(4, 6);
+       val <<= 1;
+
+       val |= nx_gpio_get_input_value(4, 5);
+       val <<= 1;
+
+       val |= nx_gpio_get_input_value(4, 4);
+
+       board_rev = val;
+}
+
+static void set_board_rev(u32 revision)
+{
+       char info[64] = {0, };
+
+       snprintf(info, ARRAY_SIZE(info), "%d", revision);
+       setenv("board_rev", info);
+}
+#endif
+
+#ifdef CONFIG_DISPLAY_BOARDINFO
+int checkboard(void)
+{
+       printf("\nBoard: ARTIK305 Raptor\n");
+
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_SENSORID_ARTIK
+static void get_sensorid(u32 revision)
+{
+       static struct udevice *dev;
+       uint16_t buf[5] = {0, };
+       char panel_env[64], *panel_str;
+       bool found_panel = false;
+       int i, ret;
+
+       ret = uclass_get_device_by_name(UCLASS_SENSOR_ID, "sensor_id@36", &dev);
+       if (ret < 0) {
+               printf("Cannot find sensor_id device\n");
+               return;
+       }
+
+       ret = sensorid_get_type(dev, &buf[0], 4);
+       if (ret < 0) {
+               printf("Cannot read sensor type - %d\n", ret);
+               return;
+       }
+
+       ret = sensorid_get_addon(dev, &buf[4]);
+       if (ret < 0) {
+               printf("Cannot read add-on board type - %d\n", ret);
+               return;
+       }
+
+       printf("ADD-ON-BOARD : 0x%X\n", buf[4]);
+}
+#endif
+
+#ifdef CONFIG_SET_DFU_ALT_INFO
+void set_dfu_alt_info(char *interface, char *devstr)
+{
+       size_t buf_size = CONFIG_SET_DFU_ALT_BUF_LEN;
+       ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size);
+
+       snprintf(buf, buf_size, "setenv dfu_alt_info \"%s\"", CONFIG_DFU_ALT);
+       run_command(buf, 0);
+}
+#endif
+
+/*------------------------------------------------------------------------------
+ * intialize nexell soc and board status.
+ */
+
+static void nx_phy_init(void)
+{
+#ifdef CONFIG_SENSORID_ARTIK
+       /* I2C-GPIO for AVR */
+       nx_gpio_set_pad_function(1, 11, 2);
+       nx_gpio_set_pad_function(1, 18, 2);
+#endif
+}
+
+/* call from u-boot */
+int board_early_init_f(void)
+{
+       return 0;
+}
+
+int mmc_get_env_dev(void)
+{
+       int port_num;
+       int boot_mode = readl(PHY_BASEADDR_CLKPWR + SYSRSTCONFIG);
+
+       if ((boot_mode & BOOTMODE_MASK) == BOOTMODE_SDMMC) {
+               port_num = readl(SCR_ARM_SECOND_BOOT_REG1);
+               if (port_num == EMMC_PORT_NUM)
+                       return 0;
+               else if (port_num == SD_PORT_NUM)
+                       return 1;
+       } else if ((boot_mode & BOOTMODE_MASK) == BOOTMODE_USB) {
+               return 0;
+       }
+
+       return -1;
+}
+
+int board_init(void)
+{
+#ifdef CONFIG_REVISION_TAG
+       check_hw_revision();
+       printf("HW Revision:\t%d\n", board_rev);
+#endif
+
+       nx_phy_init();
+
+       return 0;
+}
+
+/* u-boot dram initialize  */
+int dram_init(void)
+{
+       gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+       return 0;
+}
+
+/* u-boot dram board specific */
+void dram_init_banksize(void)
+{
+       /* set global data memory */
+       gd->bd->bi_arch_number = machine_arch_type;
+       gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x00000100;
+
+       gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+       gd->bd->bi_dram[0].size  = CONFIG_SYS_SDRAM_SIZE;
+}
+
+#ifdef CONFIG_DM_PMIC_NXE2000
+void pmic_init(void)
+{
+       static struct udevice *dev;
+       int ret = -ENODEV;
+       uint8_t bit_mask = 0;
+
+       ret = pmic_get("nxe1500@33", &dev);
+       if (ret)
+               printf("Can't get PMIC: %s!\n", "nxe1500@33");
+
+       bit_mask = 0x00;
+       bit_mask = pmic_reg_read(dev, NXE2000_REG_PWRONTIMSET);
+       bit_mask &= ~(0x1 << NXE2000_POS_PWRONTIMSET_OFF_JUDGE_PWRON);
+       bit_mask |= (0x0 << NXE2000_POS_PWRONTIMSET_OFF_JUDGE_PWRON);
+       ret = pmic_write(dev, NXE2000_REG_PWRONTIMSET, &bit_mask, 1);
+       if (ret)
+               printf("Can't write PMIC REG: %d!\n", NXE2000_REG_PWRONTIMSET);
+
+       bit_mask = ((0 << NXE2000_POS_DCxCTL2_DCxOSC) |
+                       (0 << NXE2000_POS_DCxCTL2_DCxSR) |
+                       (3 << NXE2000_POS_DCxCTL2_DCxLIM) |
+                       (0 << NXE2000_POS_DCxCTL2_DCxLIMSDEN));
+       ret = pmic_write(dev, NXE2000_REG_DC1CTL2, &bit_mask, 1);
+       if (ret)
+               printf("Can't write PMIC register: %d!\n", NXE2000_REG_DC1CTL2);
+
+       bit_mask = ((0 << NXE2000_POS_DCxCTL2_DCxOSC) |
+                       (0 << NXE2000_POS_DCxCTL2_DCxSR) |
+                       (3 << NXE2000_POS_DCxCTL2_DCxLIM) |
+                       (0 << NXE2000_POS_DCxCTL2_DCxLIMSDEN));
+       ret = pmic_write(dev, NXE2000_REG_DC2CTL2, &bit_mask, 1);
+       if (ret)
+               printf("Can't write PMIC register: %d!\n", NXE2000_REG_DC2CTL2);
+
+       bit_mask = ((0 << NXE2000_POS_DCxCTL2_DCxOSC) |
+                       (0 << NXE2000_POS_DCxCTL2_DCxSR) |
+                       (1 << NXE2000_POS_DCxCTL2_DCxLIM) |
+                       (1 << NXE2000_POS_DCxCTL2_DCxLIMSDEN));
+       ret = pmic_write(dev, NXE2000_REG_DC3CTL2, &bit_mask, 1);
+       if (ret)
+               printf("Can't write PMIC register: %d!\n", NXE2000_REG_DC3CTL2);
+
+       bit_mask = ((0 << NXE2000_POS_DCxCTL2_DCxOSC) |
+                       (0 << NXE2000_POS_DCxCTL2_DCxSR) |
+                       (1 << NXE2000_POS_DCxCTL2_DCxLIM) |
+                       (1 << NXE2000_POS_DCxCTL2_DCxLIMSDEN));
+       ret = pmic_write(dev, NXE2000_REG_DC4CTL2, &bit_mask, 1);
+       if (ret)
+               printf("Can't write PMIC register: %d!\n", NXE2000_REG_DC4CTL2);
+
+       bit_mask = ((1 << NXE2000_POS_LDOEN1_LDO1EN) |
+                       (1 << NXE2000_POS_LDOEN1_LDO2EN) |
+                       (1 << NXE2000_POS_LDOEN1_LDO3EN) |
+                       (0 << NXE2000_POS_LDOEN1_LDO4EN) |
+                       (0 << NXE2000_POS_LDOEN1_LDO5EN));
+       ret = pmic_write(dev, NXE2000_REG_LDOEN1, &bit_mask, 1);
+       if (ret)
+               printf("Can't write PMIC register: %d!\n", NXE2000_REG_LDOEN1);
+
+}
+#endif
+
+int board_late_init(void)
+{
+#ifdef CONFIG_DM_PMIC_NXE2000
+       pmic_init();
+#endif
+
+#ifdef CONFIG_REVISION_TAG
+       set_board_rev(board_rev);
+#endif
+#ifdef CONFIG_CMD_FACTORY_INFO
+       run_command("run factory_load", 0);
+#endif
+#ifdef CONFIG_ARTIK_MAC
+       generate_mac();
+#endif
+#ifdef CONFIG_SENSORID_ARTIK
+       get_sensorid(board_rev);
+#endif
+#ifdef CONFIG_ARTIK_OTA
+       check_ota_update();
+#endif
+       return 0;
+}
+
+#ifdef CONFIG_USB_GADGET
+int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
+{
+       if (!strcmp(name, "usb_dnl_thor")) {
+               put_unaligned(CONFIG_G_DNL_THOR_VENDOR_NUM, &dev->idVendor);
+               put_unaligned(CONFIG_G_DNL_THOR_PRODUCT_NUM, &dev->idProduct);
+       } else if (!strcmp(name, "usb_dnl_ums")) {
+               put_unaligned(CONFIG_G_DNL_UMS_VENDOR_NUM, &dev->idVendor);
+               put_unaligned(CONFIG_G_DNL_UMS_PRODUCT_NUM, &dev->idProduct);
+       } else {
+               put_unaligned(CONFIG_G_DNL_VENDOR_NUM, &dev->idVendor);
+               put_unaligned(CONFIG_G_DNL_PRODUCT_NUM, &dev->idProduct);
+       }
+       return 0;
+}
+#endif