/* * Routine: board_init * Description: Early hardware init. */ int board_init(void) { __maybe_unused int err; /* Do clocks and UART first so that printf() works */ clock_init(); clock_verify(); #ifdef CONFIG_SPI_UART_SWITCH gpio_config_uart(); #endif #ifdef CONFIG_TEGRA_SPI pin_mux_spi(); spi_init(); #endif /* boot param addr */ gd->bd->bi_boot_params = (NV_PA_SDRAM_BASE + 0x100); power_det_init(); #ifdef CONFIG_TEGRA_I2C #ifndef CONFIG_SYS_I2C_INIT_BOARD #error "You must define CONFIG_SYS_I2C_INIT_BOARD to use i2c on Nvidia boards" #endif i2c_init_board(); # ifdef CONFIG_TEGRA_PMU if (pmu_set_nominal()) debug("Failed to select nominal voltages\n"); # ifdef CONFIG_TEGRA_CLOCK_SCALING err = board_emc_init(); if (err) debug("Memory controller init failed: %d\n", err); # endif # endif /* CONFIG_TEGRA_PMU */ #endif /* CONFIG_TEGRA_I2C */ #ifdef CONFIG_USB_EHCI_TEGRA pin_mux_usb(); board_usb_init(gd->fdt_blob); #endif #ifdef CONFIG_TEGRA_LP0 /* save Sdram params to PMC 2, 4, and 24 for WB0 */ warmboot_save_sdram_params(); /* prepare the WB code to LP0 location */ warmboot_prepare_code(TEGRA_LP0_ADDR, TEGRA_LP0_SIZE); #endif return 0; }
static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 4) return CMD_RET_USAGE; char *usb_controller = argv[1]; char *interface = argv[2]; char *devstring = argv[3]; int ret, i = 0; ret = dfu_init_env_entities(interface, simple_strtoul(devstring, NULL, 10)); if (ret) goto done; ret = CMD_RET_SUCCESS; if (argc > 4 && strcmp(argv[4], "list") == 0) { dfu_show_entities(); goto done; } int controller_index = simple_strtoul(usb_controller, NULL, 0); board_usb_init(controller_index, USB_INIT_DEVICE); g_dnl_register("usb_dnl_dfu"); while (1) { if (dfu_reset()) /* * This extra number of usb_gadget_handle_interrupts() * calls is necessary to assure correct transmission * completion with dfu-util */ if (++i == 10) goto exit; if (ctrlc()) goto exit; usb_gadget_handle_interrupts(); } exit: g_dnl_unregister(); done: dfu_free_entities(); if (dfu_reset()) run_command("reset", 0); return ret; }
int board_init(void) { gd->bd->bi_arch_number=MACH_TYPE_MESON6_SKT; gd->bd->bi_boot_params=BOOT_PARAMS_OFFSET; #if CONFIG_JERRY_NAND_TEST //temp test nand_init(); #endif #ifdef CONFIG_AML_I2C board_i2c_init(); #endif /*CONFIG_AML_I2C*/ #ifdef CONFIG_IR_REMOTE board_ir_init(); #endif #ifdef CONFIG_USB_DWC_OTG_HCD board_usb_init(&g_usb_config_m6_skt_b,BOARD_USB_MODE_HOST); board_usb_init(&g_usb_config_m6_skt_h,BOARD_USB_MODE_CHARGER); #endif /*CONFIG_USB_DWC_OTG_HCD*/ key_init(); return 0; }
int do_thor_down(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 4) return CMD_RET_USAGE; char *usb_controller = argv[1]; char *interface = argv[2]; char *devstring = argv[3]; int ret; puts("TIZEN \"THOR\" Downloader\n"); ret = dfu_init_env_entities(interface, devstring); if (ret) goto done; int controller_index = simple_strtoul(usb_controller, NULL, 0); ret = board_usb_init(controller_index, USB_INIT_DEVICE); if (ret) { pr_err("USB init failed: %d\n", ret); ret = CMD_RET_FAILURE; goto exit; } g_dnl_register("usb_dnl_thor"); ret = thor_init(); if (ret) { pr_err("THOR DOWNLOAD failed: %d\n", ret); ret = CMD_RET_FAILURE; goto exit; } ret = thor_handle(); if (ret) { pr_err("THOR failed: %d\n", ret); ret = CMD_RET_FAILURE; goto exit; } exit: g_dnl_unregister(); board_usb_cleanup(controller_index, USB_INIT_DEVICE); done: dfu_free_entities(); return ret; }
static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { const char *str_env; char s[] = "dfu"; char *env_bkp; int ret; if (argc < 3) return CMD_RET_USAGE; str_env = getenv("dfu_alt_info"); if (str_env == NULL) { printf("%s: \"dfu_alt_info\" env variable not defined!\n", __func__); return CMD_RET_FAILURE; } env_bkp = strdup(str_env); ret = dfu_config_entities(env_bkp, argv[1], (int)simple_strtoul(argv[2], NULL, 10)); if (ret) return CMD_RET_FAILURE; if (argc > 3 && strcmp(argv[3], "list") == 0) { dfu_show_entities(); goto done; } #ifdef CONFIG_TRATS board_usb_init(); #endif g_dnl_register(s); while (1) { if (ctrlc()) goto exit; usb_gadget_handle_interrupts(); } exit: g_dnl_unregister(); done: dfu_free_entities(); free(env_bkp); return CMD_RET_SUCCESS; }
int board_late_init(void) { #ifdef CONFIG_AML_I2C board_i2c_init(); #endif /*CONFIG_AML_I2C*/ #ifdef CONFIG_USB_DWC_OTG_HCD board_usb_init(&g_usb_config_m6_skt,BOARD_USB_MODE_HOST); #endif /*CONFIG_USB_DWC_OTG_HCD*/ #ifdef CONFIG_AW_AXP20 set_dcdc2(1500); //set DC-DC2 to 1500mV set_dcdc3(1100); //set DC-DC3 to 1100mV #endif return 0; }
int board_init(void) { /* @todo implement this function */ DECLARE_GLOBAL_DATA_PTR; gd->bd->bi_arch_number=MACH_TYPE_MESON_8626M; gd->bd->bi_boot_params=BOOT_PARAMS_OFFSET; #ifdef CONFIG_CMD_KGDB kgdb_init(); #endif #ifdef CONFIG_USB_DWC_OTG_HCD board_usb_init(&usb_config); #endif return 0; }
int board_init(void) { gd->bd->bi_arch_number=MACH_TYPE_MESON6_SKT; gd->bd->bi_boot_params=BOOT_PARAMS_OFFSET; #ifdef CONFIG_UBOOT_BUILD_VERSION_INFO print_build_version_info(); #endif #if CONFIG_JERRY_NAND_TEST //temp test nand_init(); #endif #ifdef CONFIG_AML_I2C board_i2c_init(); #endif /*CONFIG_AML_I2C*/ #ifdef CONFIG_IR_REMOTE board_ir_init(); #endif #ifdef CONFIG_USB_XHCI_AMLOGIC board_usb_init(&g_usb_config_g9TV_skt,BOARD_USB_MODE_HOST); #endif /*CONFIG_USB_XHCI_AMLOGIC*/ #if defined(CONFIG_VLSI_EMULATOR) run_command("video dev open 1080p", 0); #endif #ifdef CONFIG_PWM_E_OUT_32K printf("init pwm_e out 32k clock.\n"); writel(readl(P_PERIPHS_PIN_MUX_9) | (0x1 << 19), P_PERIPHS_PIN_MUX_9); //set mode GPIOX_10-->CLK_OUT3 writel(0x16d016d, P_PWM_PWM_E); writel((readl(P_PWM_MISC_REG_EF) & ~(0xFF << 8)) | 0x8001, P_PWM_MISC_REG_EF); #endif //default power on 24M writel(readl(P_PERIPHS_PIN_MUX_10)&~(1 << 11),P_PERIPHS_PIN_MUX_10); writel(readl(P_AO_GPIO_O_EN_N)&~(1 << 18),P_AO_GPIO_O_EN_N); writel(readl(P_AO_GPIO_O_EN_N)&~(1 << 2),P_AO_GPIO_O_EN_N); return 0; }
int board_init(void) { /* @todo implement this function */ DECLARE_GLOBAL_DATA_PTR; gd->bd->bi_arch_number=2956; gd->bd->bi_boot_params=BOOT_PARAMS_OFFSET; #ifdef CONFIG_CMD_KGDB kgdb_init(); #endif #ifdef CONFIG_USB_DWC_OTG_HCD board_usb_init(&usb_config_m2c); #endif init_osd_param(); return 0; }
/* * EHCI-initialization * Create the appropriate control structures to manage * a new EHCI host controller. */ int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { struct exynos_ehci *ctx = &exynos; #ifdef CONFIG_OF_CONTROL if (exynos_usb_parse_dt(gd->fdt_blob, ctx)) { debug("Unable to parse device tree for ehci-exynos\n"); return -ENODEV; } #else ctx->usb = (struct exynos_usb_phy *)samsung_get_base_usb_phy(); ctx->hcd = (struct ehci_hccr *)samsung_get_base_usb_ehci(); #endif #ifdef CONFIG_OF_CONTROL /* setup the Vbus gpio here */ if (fdt_gpio_isvalid(&ctx->vbus_gpio) && !fdtdec_setup_gpio(&ctx->vbus_gpio)) gpio_direction_output(ctx->vbus_gpio.gpio, 1); #endif setup_usb_phy(ctx->usb); board_usb_init(index, init); *hccr = ctx->hcd; *hcor = (struct ehci_hcor *)((uint32_t) *hccr + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); debug("Exynos5-ehci: init hccr %x and hcor %x hc_length %d\n", (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); return 0; }
int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor) { struct ipq_xhci *ctx = &ipq; unsigned int ipq_base; int ret = 0; if ( index == 0 ) ipq_base = IPQ_XHCI_BASE_1; else ipq_base = IPQ_XHCI_BASE_2; ctx->hcd = (struct xhci_hccr *)ipq_base; ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET); ret = board_usb_init(index, USB_INIT_HOST); if (ret != 0) { puts("Failed to initialize board for USB\n"); return ret; } ret = ipq_xhci_core_init(ctx, ipq_base); if (ret < 0) { puts("Failed to initialize xhci\n"); return ret; } *hccr = (struct xhci_hccr *)(ipq_base); *hcor = (struct xhci_hcor *)((uint32_t) *hccr + HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase))); debug("omap-xhci: init hccr %x and hcor %x hc_length %d\n", (uint32_t)*hccr, (uint32_t)*hcor, (uint32_t)HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase))); return ret; }
int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget) { bool dfu_reset = false; int ret, i = 0; ret = board_usb_init(usbctrl_index, USB_INIT_DEVICE); if (ret) { pr_err("board usb init failed\n"); return CMD_RET_FAILURE; } g_dnl_clear_detach(); ret = g_dnl_register(usb_dnl_gadget); if (ret) { pr_err("g_dnl_register failed"); return CMD_RET_FAILURE; } while (1) { if (g_dnl_detach()) { /* * Check if USB bus reset is performed after detach, * which indicates that -R switch has been passed to * dfu-util. In this case reboot the device */ if (dfu_usb_get_reset()) { dfu_reset = true; goto exit; } /* * This extra number of usb_gadget_handle_interrupts() * calls is necessary to assure correct transmission * completion with dfu-util */ if (++i == 10000) goto exit; } if (ctrlc()) goto exit; if (dfu_get_defer_flush()) { /* * Call to usb_gadget_handle_interrupts() is necessary * to act on ZLP OUT transaction from HOST PC after * transmitting the whole file. * * If this ZLP OUT packet is NAK'ed, the HOST libusb * function fails after timeout (by default it is set to * 5 seconds). In such situation the dfu-util program * exits with error message. */ usb_gadget_handle_interrupts(usbctrl_index); ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0); dfu_set_defer_flush(NULL); if (ret) { pr_err("Deferred dfu_flush() failed!"); goto exit; } } WATCHDOG_RESET(); usb_gadget_handle_interrupts(usbctrl_index); } exit: g_dnl_unregister(); board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE); if (dfu_reset) do_reset(NULL, 0, 0, NULL); g_dnl_clear_detach(); return ret; }
static int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { const char *usb_controller; const char *devtype; const char *devnum; unsigned int controller_index; int rc; int cable_ready_timeout __maybe_unused; if (argc < 3) return CMD_RET_USAGE; usb_controller = argv[1]; if (argc >= 4) { devtype = argv[2]; devnum = argv[3]; } else { devtype = "mmc"; devnum = argv[2]; } rc = ums_init(devtype, devnum); if (rc < 0) return CMD_RET_FAILURE; controller_index = (unsigned int)(simple_strtoul( usb_controller, NULL, 0)); if (board_usb_init(controller_index, USB_INIT_DEVICE)) { pr_err("Couldn't init USB controller.\n"); rc = CMD_RET_FAILURE; goto cleanup_ums_init; } rc = fsg_init(ums, ums_count); if (rc) { pr_err("fsg_init failed\n"); rc = CMD_RET_FAILURE; goto cleanup_board; } rc = g_dnl_register("usb_dnl_ums"); if (rc) { pr_err("g_dnl_register failed\n"); rc = CMD_RET_FAILURE; goto cleanup_board; } /* Timeout unit: seconds */ cable_ready_timeout = UMS_CABLE_READY_TIMEOUT; if (!g_dnl_board_usb_cable_connected()) { /* * Won't execute if we don't know whether the cable is * connected. */ puts("Please connect USB cable.\n"); while (!g_dnl_board_usb_cable_connected()) { if (ctrlc()) { puts("\rCTRL+C - Operation aborted.\n"); rc = CMD_RET_SUCCESS; goto cleanup_register; } if (!cable_ready_timeout) { puts("\rUSB cable not detected.\n" \ "Command exit.\n"); rc = CMD_RET_SUCCESS; goto cleanup_register; } printf("\rAuto exit in: %.2d s.", cable_ready_timeout); mdelay(1000); cable_ready_timeout--; } puts("\r\n"); } while (1) { usb_gadget_handle_interrupts(controller_index); rc = fsg_main_thread(NULL); if (rc) { /* Check I/O error */ if (rc == -EIO) printf("\rCheck USB cable connection\n"); /* Check CTRL+C */ if (rc == -EPIPE) printf("\rCTRL+C - Operation aborted\n"); rc = CMD_RET_SUCCESS; goto cleanup_register; } } cleanup_register: g_dnl_unregister(); cleanup_board: board_usb_cleanup(controller_index, USB_INIT_DEVICE); cleanup_ums_init: ums_fini(); return rc; }
/* * Initialize the OMAP EHCI controller and PHY. * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1 * See there for additional Copyrights. */ int omap_ehci_hcd_init(struct omap_usbhs_board_data *usbhs_pdata) { int ret; unsigned int i, reg = 0, rev = 0; debug("Initializing OMAP EHCI\n"); ret = board_usb_init(); if (ret < 0) return ret; /* Put the PHY in RESET */ omap_ehci_phy_reset(1, 10); ret = omap_uhh_reset(); if (ret < 0) return ret; ret = omap_ehci_tll_reset(); if (ret) return ret; writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP | OMAP_USBTLL_SYSCONFIG_SIDLEMODE | OMAP_USBTLL_SYSCONFIG_CACTIVITY, &usbtll->sysc); /* Put UHH in NoIdle/NoStandby mode */ writel(OMAP_UHH_SYSCONFIG_VAL, &uhh->sysc); /* setup ULPI bypass and burst configurations */ clrsetbits_le32(®, OMAP_UHH_HOSTCONFIG_INCRX_ALIGN_EN, (OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN)); rev = readl(&uhh->rev); if (rev == OMAP_USBHS_REV1) { if (is_ehci_phy_mode(usbhs_pdata->port_mode[0])) clrbits_le32(®, OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS); else setbits_le32(®, OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS); if (is_ehci_phy_mode(usbhs_pdata->port_mode[1])) clrbits_le32(®, OMAP_UHH_HOSTCONFIG_ULPI_P2_BYPASS); else setbits_le32(®, OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS); if (is_ehci_phy_mode(usbhs_pdata->port_mode[2])) clrbits_le32(®, OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS); else setbits_le32(®, OMAP_UHH_HOSTCONFIG_ULPI_P1_BYPASS); } else if (rev == OMAP_USBHS_REV2) { clrsetbits_le32(®, (OMAP_P1_MODE_CLEAR | OMAP_P2_MODE_CLEAR), OMAP4_UHH_HOSTCONFIG_APP_START_CLK); /* Clear port mode fields for PHY mode*/ if (is_ehci_hsic_mode(usbhs_pdata->port_mode[0])) setbits_le32(®, OMAP_P1_MODE_HSIC); if (is_ehci_hsic_mode(usbhs_pdata->port_mode[1])) setbits_le32(®, OMAP_P2_MODE_HSIC); if (is_ehci_hsic_mode(usbhs_pdata->port_mode[2])) setbits_le32(®, OMAP_P3_MODE_HSIC); } debug("OMAP UHH_REVISION 0x%x\n", rev); writel(reg, &uhh->hostconfig); for (i = 0; i < OMAP_HS_USB_PORTS; i++) if (is_ehci_hsic_mode(usbhs_pdata->port_mode[i])) omap_usbhs_hsic_init(i); omap_ehci_phy_reset(0, 10); /* * An undocumented "feature" in the OMAP3 EHCI controller, * causes suspended ports to be taken out of suspend when * the USBCMD.Run/Stop bit is cleared (for example when * we do ehci_bus_suspend). * This breaks suspend-resume if the root-hub is allowed * to suspend. Writing 1 to this undocumented register bit * disables this feature and restores normal behavior. */ writel(EHCI_INSNREG04_DISABLE_UNSUSPEND, &ehci->insreg04); for (i = 0; i < OMAP_HS_USB_PORTS; i++) if (is_ehci_phy_mode(usbhs_pdata->port_mode[i])) omap_ehci_soft_phy_reset(i); dcache_disable(); hccr = (struct ehci_hccr *)(OMAP_EHCI_BASE); hcor = (struct ehci_hcor *)(OMAP_EHCI_BASE + 0x10); debug("OMAP EHCI init done\n"); return 0; }
static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { bool dfu_reset = false; if (argc < 4) return CMD_RET_USAGE; char *usb_controller = argv[1]; char *interface = argv[2]; char *devstring = argv[3]; int ret, i = 0; ret = dfu_init_env_entities(interface, devstring); if (ret) goto done; ret = CMD_RET_SUCCESS; if (argc > 4 && strcmp(argv[4], "list") == 0) { dfu_show_entities(); goto done; } int controller_index = simple_strtoul(usb_controller, NULL, 0); board_usb_init(controller_index, USB_INIT_DEVICE); g_dnl_clear_detach(); g_dnl_register("usb_dnl_dfu"); while (1) { if (g_dnl_detach()) { /* * Check if USB bus reset is performed after detach, * which indicates that -R switch has been passed to * dfu-util. In this case reboot the device */ if (dfu_usb_get_reset()) { dfu_reset = true; goto exit; } /* * This extra number of usb_gadget_handle_interrupts() * calls is necessary to assure correct transmission * completion with dfu-util */ if (++i == 10000) goto exit; } if (ctrlc()) goto exit; WATCHDOG_RESET(); usb_gadget_handle_interrupts(controller_index); } exit: g_dnl_unregister(); board_usb_cleanup(controller_index, USB_INIT_DEVICE); done: dfu_free_entities(); if (dfu_reset) run_command("reset", 0); g_dnl_clear_detach(); return ret; }