| #include "common.h" |
| #include "gpio.h" |
| #include "board_init.h" |
| |
| #include "board_config.h" |
| |
| #include "diag_pll.h" |
| #include "pin_init.h" |
| #include "pinmux_setting.h" |
| #include "Galois_memmap.h" |
| #include "global.h" |
| #include "i2c_driver.h" |
| #include "gpio.h" |
| |
| #if defined(PV_COMP) |
| #include "pv_comp.h" |
| #include "chip_voltage_info.h" |
| #include "pmic_select.h" |
| #endif |
| |
| /* |
| * Initiailize GPIOs used by bootloader. |
| */ |
| static int board_gpio_init(void) |
| { |
| GPIO_PortSetInOut(BUTTON_GPIO, 1); // set gpio button to input |
| return 0; |
| } |
| |
| typedef enum { |
| VPP_CFG_CASE_A = 0, |
| VPP_CFG_CASE_B = 1, |
| }VPP_CFG_CASE; |
| |
| |
| int detect_reset_state(void) |
| { |
| unsigned int value, warm_boot = 0; |
| GA_REG_WORD32_READ(MEMMAP_CHIP_CTRL_REG_BASE + RA_Gbl_CHIP_RESET_TRACKER, &value); |
| |
| // Bit 0 is used for usb boot |
| // Bit 1 is used for other purpose |
| // Bit 2 is used for reset state |
| if ((value & (1 << 2)) == 0) { |
| lgpl_printf("chip is cold boot.\n"); |
| } else { |
| lgpl_printf("chip is warm boot.\n"); |
| warm_boot = 1; |
| } |
| |
| value |= 0x1 << 2; |
| GA_REG_WORD32_WRITE(MEMMAP_CHIP_CTRL_REG_BASE + RA_Gbl_CHIP_RESET_TRACKER, value); |
| |
| return warm_boot; |
| } |
| |
| static void set_usbphy_reg(void) |
| { |
| //here apply diag usbphy setting D |
| writel(0x0EB35E84, 0xF7ED8000); |
| writel(0x80F99004, 0xF7ED8004); |
| } |
| |
| static void pinmux_init(void) |
| { |
| unsigned int i = 0; |
| unsigned int num = sizeof(pinmux_table)/sizeof(pinmux_table_t); |
| for(i = 0; i < num; i++) { |
| pinmux_write(pinmux_table[i].index, pinmux_table[i].value); |
| } |
| pinmux_display(); |
| } |
| |
| |
| #if defined(PV_COMP) |
| extern void pv_comp(int cpu_pll, int vmeta_pll); |
| #endif |
| /** |
| * Board specific initialization |
| */ |
| void board_init(void) |
| { |
| //int ret; |
| |
| pinmux_init(); |
| pin_init(); |
| set_usbphy_reg(); |
| |
| board_gpio_init(); |
| |
| #if defined(PV_COMP) |
| CLOCKO_t cpuclock; |
| extern void delay_ms(unsigned int ms); |
| extern const dvfs_ops_t sy8824b_ops; |
| extern const dvfs_ops_t sy20276_ops; |
| extern const dvfs_ops_t sy20278_ops; |
| |
| /* wait for bus to be idle after pimux settings for i2c */ |
| delay_ms(1); |
| |
| if (sy8824b_ops.get_vcpu_volt() > 0) { |
| lgpl_printf("PMIC detected with SY8824B\n"); |
| set_pmic_id(SY8824B); |
| goto pv_comp; |
| } |
| |
| if (sy20276_ops.get_vcpu_volt()> 0) { |
| lgpl_printf("PMIC detected with SY20276\n"); |
| set_pmic_id(SY20276); |
| goto pv_comp; |
| } |
| |
| if (sy20278_ops.get_vcpu_volt()> 0) { |
| lgpl_printf("PMIC detected with SY20278\n"); |
| set_pmic_id(SY20278); |
| } |
| |
| pv_comp: |
| cpuclock = diag_get_cpupll(); |
| lgpl_printf("cpupll: %d\n", cpuclock.clocko); |
| |
| pv_comp(cpuclock.clocko, 0); |
| #endif |
| return; |
| } |