/** NVT evb board file To handle na510xx HW init. @file na510xx_hw_init.c @ingroup @note Copyright Novatek Microelectronics Corp. 2019. All rights reserved. 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. */ #include #include #include #include #include #include #ifdef CONFIG_NVT_IVOT_DDR_RANGE_SCAN_SUPPORT #include #include #endif #include #define WDT_REG_ADDR(ofs) (IOADDR_WDT_REG_BASE+(ofs)) #define WDT_GETREG(ofs) INW(WDT_REG_ADDR(ofs)) #define WDT_SETREG(ofs,value) OUTW(WDT_REG_ADDR(ofs), (value)) #define CG_REG_ADDR(ofs) (IOADDR_CG_REG_BASE+(ofs)) #define CG_GETREG(ofs) INW(CG_REG_ADDR(ofs)) #define CG_SETREG(ofs,value) OUTW(CG_REG_ADDR(ofs), (value)) #define PAD_REG_ADDR(ofs) (IOADDR_PAD_REG_BASE+(ofs)) #define PAD_GETREG(ofs) INW(PAD_REG_ADDR(ofs)) #define PAD_SETREG(ofs,value) OUTW(PAD_REG_ADDR(ofs), (value)) #define TOP_REG_ADDR(ofs) (IOADDR_TOP_REG_BASE+(ofs)) #define TOP_GETREG(ofs) INW(TOP_REG_ADDR(ofs)) #define TOP_SETREG(ofs,value) OUTW(TOP_REG_ADDR(ofs), (value)) #define CG_PLL_ENABLE_OFS 0x0 #define CG_ENABLE_OFS 0x74 #define CG_RESET_OFS 0x84 #define CG_PLL4_DIV0_OFS 0x1318 #define CG_PLL4_DIV1_OFS 0x131C #define CG_PLL4_DIV2_OFS 0x1320 #define WDT_POS (1 << 17) #define WDT_CTRL_OFS 0x0 #if defined(CONFIG_SD_CARD1_POWER_PIN) || defined(CONFIG_SD_CARD2_POWER_PIN) || defined(ETH_PHY_HW_RESET) static void gpio_set_output(u32 pin) { u32 reg_data; u32 ofs = (pin >> 5) << 2; pin &= (32 - 1); reg_data = INW(IOADDR_GPIO_REG_BASE + 0x20 + ofs); reg_data |= (1 << pin); //output OUTW(IOADDR_GPIO_REG_BASE + 0x20 + ofs, reg_data); } static void gpio_set_pin(u32 pin) { u32 tmp; u32 ofs = (pin >> 5) << 2; pin &= (32 - 1); tmp = (1 << pin); OUTW(IOADDR_GPIO_REG_BASE + 0x40 + ofs, tmp); } static void gpio_clear_pin(u32 pin) { u32 tmp; u32 ofs = (pin >> 5) << 2; pin &= (32 - 1); tmp = (1 << pin); OUTW(IOADDR_GPIO_REG_BASE + 0x60 + ofs, tmp); } #endif void nvt_pllen(u32 id, u32 b_enable) { u32 reg_data; reg_data = CG_GETREG(CG_PLL_ENABLE_OFS); if(b_enable){ reg_data |= (1 <> 3) & 0xF); DD = ((iLibDRAMVersion >> 7) & 0x1F); VER= ((iLibDRAMVersion >> 12) & 0xF); VER_Fix = ((iLibVersion >> 16) & 0xFF); LD_MIN = ((iLibVersion >> 24) & 0xF); LD_MJ = ((iLibVersion >> 28) & 0xF); printf("\r\n"); printf("DR[%d-%d-%d-%d]:", YY, MM, DD, VER); printf("LD[%d.%d.%d]", LD_MJ, LD_MIN, VER_Fix); void (*image_entry)(void) = NULL; printf("memcpy->[0x%08x]", (int)JUMP_ADDR); if (nvt_get_chip_id() == CHIP_NA51089) { memcpy((void *)JUMP_ADDR, ddr_scan, sizeof(ddr_scan)); printf("->done\n"); flush_dcache_range(JUMP_ADDR, JUMP_ADDR + sizeof(ddr_scan)); printf("flush->"); invalidate_dcache_range(JUMP_ADDR, JUMP_ADDR + roundup(sizeof(ddr_scan), ARCH_DMA_MINALIGN)); } else { printf("Not support\n"); } printf("done\r\n"); printf("Jump into sram\n"); image_entry = (LDR_GENERIC_CB)(*((unsigned long*)JUMP_ADDR)); image_entry(); } #endif