mirror of
git://projects.qi-hardware.com/iris.git
synced 2024-11-17 08:14:03 +02:00
109 lines
2.9 KiB
COBOL
109 lines
2.9 KiB
COBOL
#pypp 0
|
|
// Iris: micro-kernel for a capability-based operating system.
|
|
// mips/nanonote/board.ccp: nanonote-specific definitions.
|
|
// Copyright 2009 Bas Wijnen <wijnen@debian.org>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#define ARCH
|
|
#define INIT
|
|
#include "kernel.hh"
|
|
|
|
void board_init ():
|
|
pll_init ()
|
|
cpm_stop_all ()
|
|
// Timer interrupts and buzzer.
|
|
cpm_start_tcu ()
|
|
// sdram memory.
|
|
gpio_as_sdram_16bit ()
|
|
// flash memory.
|
|
gpio_as_nand ()
|
|
// sound controller.
|
|
gpio_as_aic ()
|
|
// micro-sd controller.
|
|
gpio_as_msc ()
|
|
// display.
|
|
gpio_as_lcd_16bit ()
|
|
// buzzer.
|
|
gpio_as_pwm4 ()
|
|
// Set up memory.
|
|
//setup_sdram ()
|
|
// Use some gpio pins for lcd.
|
|
gpio_as_gpio (2, (1 << 21) | (1 << 22) | (1 << 23))
|
|
gpio_as_output (2, (1 << 21) | (1 << 22) | (1 << 23))
|
|
// And some for sd/mmc.
|
|
gpio_as_gpio (3, (1 << 0) | (1 << 2))
|
|
gpio_as_output (3, 1 << 2)
|
|
gpio_as_input (3, 1 << 0)
|
|
gpio_disable_pull (3, (1 << 0) | (1 << 2))
|
|
// Disable power to sd/mmc by default.
|
|
gpio_set (3, 1 << 2)
|
|
// Set up keyboard: this breaks uart receive.
|
|
gpio_as_gpio (3, 0x05fc0000)
|
|
// Set up timed interrupts.
|
|
tcu_stop_counter (0)
|
|
tcu_select_extalclk (0)
|
|
tcu_select_clk_div4 (0)
|
|
tcu_disable_pwm_output (0)
|
|
tcu_set_full_data (0, JZ_EXTAL / HZ / 4)
|
|
tcu_mask_half_match_irq (0)
|
|
tcu_clear_full_match_flag (0)
|
|
tcu_unmask_full_match_irq (0)
|
|
tcu_start_counter (0)
|
|
#ifndef NDEBUG
|
|
setup_uart ()
|
|
kdebug ("\n\nSerial port initialized\n")
|
|
#endif
|
|
|
|
static void sync_serial ():
|
|
#ifndef NDEBUG
|
|
// Wait for serial port to be done.
|
|
while !(UART0_LSR & UARTLSR_TEMT):
|
|
#endif
|
|
|
|
void arch_reboot ():
|
|
sync_serial ()
|
|
// Reboot.
|
|
wdt_select_extalclk ()
|
|
wdt_select_clk_div1 ()
|
|
wdt_set_data (1)
|
|
wdt_set_count (0)
|
|
wdt_start ()
|
|
// Wait for wdt to trigger reboot.
|
|
while true:
|
|
|
|
void arch_poweroff ():
|
|
sync_serial ()
|
|
// Power off.
|
|
// Make sure the rtc is running.
|
|
cpm_start_rtc ()
|
|
while !rtc_write_ready ():
|
|
rtc_enabled ()
|
|
while !rtc_write_ready ():
|
|
rtc_power_down ()
|
|
// Wait for power down to work.
|
|
while !rtc_write_ready ():
|
|
// Delay a bit more.
|
|
for unsigned i = 0; i < 1000; ++i:
|
|
gpio_set (0, 0)
|
|
// Fall back to reboot.
|
|
kdebug ("Power down failed! Rebooting instead.\n")
|
|
arch_reboot ()
|
|
|
|
// Boot into another kernel.
|
|
void arch_boot (unsigned address, unsigned arg):
|
|
sync_serial ()
|
|
arch_flush_cache ()
|
|
((void (*)(unsigned))address) (arg)
|