| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- // SPDX-License-Identifier: GPL-2.0+
- #include <common.h>
- #include <spl.h>
- #include <asm/arch/timer.h>
- #include <asm/arch/ark1668-sysreg.h>
- #include <asm/arch/ark-common.h>
- #include <asm-generic/gpio.h>
- //#define SYSPLL_CLK 330
- //#define CPUPLL_CLK 696
- //#define AUDPLL_CLK 426
- #define PAD_CTL8_TMP *((volatile unsigned int *)(0x50000160))
- #define PAD_CTL9_TMP *((volatile unsigned int *)(0x50000164))
- #define PAD_CTLA_TMP *((volatile unsigned int *)(0x50000168))
- /* static void switch_to_main_crystal_osc(void)
- {
- return;
- } */
- void board_init_f(ulong dummy)
- {
- u32 val;
- timer_init();
- board_early_init_f();
- printascii("<debug_uart0000> ");
- preloader_console_init();
- printascii("<debug_uart0001> ");
- #if 1
- /* nand pad enable */
- /* cle */
- val = PAD_CTL8_TMP;
- val &= ~(0x7<<27);
- val |= (0x5<<27);
- PAD_CTL8_TMP = val;
- /*
- ale [2:0]
- ren [5:3]
- wen [8:6]
- rb0 [11:9]
- cen0[14:12]
- */
- val = PAD_CTL9_TMP;
- val &= ~((0x7<<12)|(0x7<<9)|(0x7<<6)|(0x7<<3)|(0x7<<0));
- val |= ((0x5<<12)|(0x5<<9)|(0x5<<6)|(0x5<<3)|(0x5<<0));
- PAD_CTL9_TMP = val;
- val = PAD_CTL9_TMP;
- val &= ~((0x7<<27)|(0x7<<24)|(0x7<<21)|(0x7<<18)|(0x7<<15));
- val |= ((0x5<<27)|(0x5<<24)|(0x5<<21)|(0x5<<18)|(0x5<<15));
- PAD_CTL9_TMP = val;
- val = PAD_CTLA_TMP;
- val &= ~((0x7<<6)|(0x7<<3)|(0x7<<0));
- val |= ((0x5<<6)|(0x5<<3)|(0x5<<0));
- PAD_CTLA_TMP = val;
- #endif
- printascii("<debug_uart0002> ");
- mem_init();
- }
- #ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
- void puts(const char *s)
- {
- serial_puts(s);
- }
- void putc(const char c)
- {
- serial_putc(c);
- }
- #endif
- #ifndef CONFIG_SPL_LIBGENERIC_SUPPORT
- void udelay(unsigned long usec)
- {
- timer_delay_us(usec);
- }
- void hang(void)
- {
- for (;;);
- }
- uint32_t __div64_32(uint64_t *n, uint32_t base)
- {
- uint64_t rem = *n;
- uint64_t b = base;
- uint64_t res, d = 1;
- uint32_t high = rem >> 32;
- /* Reduce the thing a bit first */
- res = 0;
- if (high >= base) {
- high /= base;
- res = (uint64_t) high << 32;
- rem -= (uint64_t) (high*base) << 32;
- }
- while ((int64_t)b > 0 && b < rem) {
- b = b+b;
- d = d+d;
- }
- do {
- if (rem >= b) {
- rem -= b;
- res += d;
- }
- b >>= 1;
- d >>= 1;
- } while (d);
- *n = res;
- return rem;
- }
- void * memmove(void * dest,const void *src,size_t count)
- {
- char *tmp, *s;
- if (dest <= src) {
- memcpy(dest, src, count);
- } else {
- tmp = (char *) dest + count;
- s = (char *) src + count;
- while (count--)
- *--tmp = *--s;
- }
- return dest;
- }
- #endif
|