NanoPayload

Annotated stage2/board-minipc.c

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