| 1 | /* |
| 2 | * (C) Copyright 2006 |
| 3 | * Ingenic Semiconductor, <jlwei@ingenic.cn> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; either version 2 of |
| 8 | * the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 18 | * MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #include <common.h> |
| 22 | #include <command.h> |
| 23 | #include <asm/mipsregs.h> |
| 24 | #include <asm/jz4740.h> |
| 25 | #include <asm/addrspace.h> |
| 26 | #include <asm/cacheops.h> |
| 27 | |
| 28 | void _machine_restart(void) |
| 29 | { |
| 30 | __wdt_select_extalclk(); |
| 31 | __wdt_select_clk_div64(); |
| 32 | __wdt_set_data(100); |
| 33 | __wdt_set_count(0); |
| 34 | __tcu_start_wdt_clock(); |
| 35 | __wdt_start(); |
| 36 | while(1); |
| 37 | |
| 38 | } |
| 39 | |
| 40 | static void gpio_init(void) |
| 41 | { |
| 42 | |
| 43 | REG_GPIO_PXPES(0) = 0xffffffff; |
| 44 | REG_GPIO_PXPES(1) = 0xffffffff; |
| 45 | REG_GPIO_PXPES(2) = 0xffffffff; |
| 46 | REG_GPIO_PXPES(3) = 0xffffffff; |
| 47 | |
| 48 | /* |
| 49 | * Initialize NAND Flash Pins |
| 50 | */ |
| 51 | __gpio_as_nand(); |
| 52 | |
| 53 | /* |
| 54 | * Initialize SDRAM pins |
| 55 | */ |
| 56 | __gpio_as_sdram_32bit(); |
| 57 | |
| 58 | /* |
| 59 | * Initialize UART0 pins |
| 60 | */ |
| 61 | __gpio_as_uart0(); |
| 62 | |
| 63 | /* |
| 64 | * Initialize MSC pins |
| 65 | */ |
| 66 | __gpio_as_msc(); |
| 67 | |
| 68 | /* |
| 69 | * Initialize LCD pins |
| 70 | */ |
| 71 | __gpio_as_lcd_16bit(); |
| 72 | |
| 73 | /* |
| 74 | * Initialize Other pins |
| 75 | */ |
| 76 | __gpio_as_output(GPIO_SD_VCC_EN_N); |
| 77 | __gpio_clear_pin(GPIO_SD_VCC_EN_N); |
| 78 | |
| 79 | __gpio_as_input(GPIO_SD_CD_N); |
| 80 | __gpio_disable_pull(GPIO_SD_CD_N); |
| 81 | |
| 82 | __gpio_as_output(GPIO_DISP_OFF_N); |
| 83 | |
| 84 | __gpio_as_output(GPIO_LED_EN); |
| 85 | __gpio_set_pin(GPIO_LED_EN); |
| 86 | |
| 87 | __gpio_as_input(127); |
| 88 | } |
| 89 | |
| 90 | static void cpm_init(void) |
| 91 | { |
| 92 | __cpm_stop_ipu(); |
| 93 | __cpm_stop_cim(); |
| 94 | __cpm_stop_i2c(); |
| 95 | __cpm_stop_ssi(); |
| 96 | __cpm_stop_uart1(); |
| 97 | __cpm_stop_sadc(); |
| 98 | __cpm_stop_uhc(); |
| 99 | __cpm_stop_udc(); |
| 100 | __cpm_stop_aic1(); |
| 101 | __cpm_stop_aic2(); |
| 102 | __cpm_suspend_udcphy(); |
| 103 | __cpm_suspend_usbphy(); |
| 104 | } |
| 105 | |
| 106 | //---------------------------------------------------------------------- |
| 107 | // board early init routine |
| 108 | |
| 109 | void board_early_init(void) |
| 110 | { |
| 111 | gpio_init(); |
| 112 | cpm_init(); |
| 113 | } |
| 114 | |
| 115 | //---------------------------------------------------------------------- |
| 116 | // U-Boot common routines |
| 117 | |
| 118 | int checkboard (void) |
| 119 | { |
| 120 | DECLARE_GLOBAL_DATA_PTR; |
| 121 | |
| 122 | printf("Board: Hanvon n516 e-book (CPU Speed %d MHz)\n", |
| 123 | gd->cpu_clk/1000000); |
| 124 | |
| 125 | return 0; /* success */ |
| 126 | } |
| 127 | |