1 /* 2 * MiniPC board late initialisation, based on uboot-xburst and xburst-tools. 3 * 4 * Copyright (C) 2000-2009 Wolfgang Denk, DENX Software Engineering, <wd@denx.de> 5 * Copyright (C) 2005-2006 Ingenic Semiconductor, <jlwei@ingenic.cn> 6 * Copyright (C) Xiangfu Liu <xiangfu.z@gmail.com> 7 * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> 8 * 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #include "board.h" 24 #include "minipc.h" 25 26 /* Later initialisation functions. */ 27 28 void gpio_init2(void) 29 { 30 /* LED enable */ 31 __gpio_as_output(GPIO_LED_EN); 32 __gpio_set_pin(GPIO_LED_EN); 33 34 __harb_usb0_uhc(); 35 __gpio_as_emc(); 36 __gpio_as_dma(); 37 38 /* 39 * Initialize LCD pins 40 */ 41 __gpio_as_lcd_master(); 42 43 /* 44 * Initialize MSC pins 45 */ 46 __gpio_as_msc(); 47 } 48 49 void cpm_init(void) 50 { 51 __cpm_stop_all(); 52 } 53 54 void rtc_init(void) 55 { 56 /* NOTE: May only be accessible via I2C. */ 57 } 58 59 /* Timer routines. */ 60 61 unsigned long timestamp; 62 unsigned long lastdec; 63 64 /* 65 * Timer without interrupts. 66 */ 67 68 int timer_init(void) 69 { 70 __ost_set_clock(TIMER_CHAN, OST_TCSR_CKS_PCLK_256); 71 __ost_set_reload(TIMER_CHAN, TIMER_FDATA); 72 __ost_set_count(TIMER_CHAN, TIMER_FDATA); 73 __ost_enable_channel(TIMER_CHAN); 74 75 __cpm_start_ost(); 76 77 lastdec = TIMER_FDATA; 78 timestamp = 0; 79 80 return 0; 81 } 82 83 /* Timer interrupt activation. */ 84 85 void timer_init_irq(void) 86 { 87 __ost_enable_interrupt(TIMER_CHAN); 88 /* NOTE: Need flag clearing? */ 89 __intc_unmask_irq(TIMER_CHAN_IRQ); 90 } 91 92 /* Board startup detection. */ 93 94 int is_started(void) 95 { 96 return REG_CPM_MSCR != 0; 97 }