1/* 2 * Copyright 2013, winocm. <winocm@icloud.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * Redistributions of source code must retain the above copyright notice, this 9 * list of conditions and the following disclaimer. 10 * 11 * Redistributions in binary form must reproduce the above copyright notice, this 12 * list of conditions and the following disclaimer in the documentation and/or 13 * other materials provided with the distribution. 14 * 15 * If you are going to use this software in any form that does not involve 16 * releasing the source to this project or improving it, let me know beforehand. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29/* 30 * Platform Expert for Allwinner A10 devices (Mele A2000/A1000) 31 */ 32 33#if defined(BOARD_CONFIG_SUN4I) 34 35#include <mach/mach_types.h> 36 37#include <pexpert/pexpert.h> 38#include <pexpert/arm/protos.h> 39#include <pexpert/arm/boot.h> 40 41#include <machine/machine_routines.h> 42 43#include <vm/pmap.h> 44#include <arm/pmap.h> 45 46#include "pe_sun4i.h" 47 48/* 49 * This is board specific stuff. 50 */ 51#define KPRINTF_PREFIX "PE_sun4i: " 52 53extern void rtclock_intr(arm_saved_state_t * regs); 54extern void rtc_configure(uint64_t hz); 55 56#define uart_base gSun4iUartBase 57vm_offset_t gSun4iUartBase; 58 59static uint64_t clock_decrementer = 0; 60static boolean_t clock_initialized = FALSE; 61static boolean_t clock_had_irq = FALSE; 62static uint64_t clock_absolute_time = 0; 63 64static void timer_configure(void) 65{ 66 return; 67} 68 69void Sun4i_putc(int c) 70{ 71 if (!gSun4iUartBase) 72 return; 73 74 while (!TX_READY) 75 barrier(); 76 writel(c, UART_THR(UART)); 77} 78 79int Sun4i_getc(void) 80{ 81 return 'A'; 82} 83 84void Sun4i_uart_init(void) 85{ 86 gSun4iUartBase = ml_io_map(UART_BASE, PAGE_SIZE); 87} 88 89void Sun4i_interrupt_init(void) 90{ 91 return; 92} 93 94void Sun4i_timebase_init(void) 95{ 96 return; 97} 98 99void Sun4i_handle_interrupt(void *context) 100{ 101 return; 102} 103 104uint64_t Sun4i_get_timebase(void) 105{ 106 return 0; 107} 108 109uint64_t Sun4i_timer_value(void) 110{ 111 return 0; 112} 113 114void Sun4i_timer_enabled(int enable) 115{ 116 return; 117} 118 119/* 120 * Stub for printing out to framebuffer. 121 */ 122void vcputc(__unused int l, __unused int u, int c); 123 124static void _fb_putc(int c) 125{ 126 Sun4i_putc(c); 127} 128 129void Sun4i_framebuffer_init(void) 130{ 131 return; 132} 133 134static void PE_init_SocSupport_sun4i(void) 135{ 136 gPESocDispatch.uart_getc = Sun4i_getc; 137 gPESocDispatch.uart_putc = Sun4i_putc; 138 gPESocDispatch.uart_init = Sun4i_uart_init; 139 140 gPESocDispatch.interrupt_init = Sun4i_interrupt_init; 141 gPESocDispatch.timebase_init = Sun4i_timebase_init; 142 143 gPESocDispatch.get_timebase = Sun4i_get_timebase; 144 145 gPESocDispatch.handle_interrupt = Sun4i_handle_interrupt; 146 147 gPESocDispatch.timer_value = Sun4i_timer_value; 148 gPESocDispatch.timer_enabled = Sun4i_timer_enabled; 149 150 gPESocDispatch.framebuffer_init = Sun4i_framebuffer_init; 151 152 Sun4i_framebuffer_init(); 153 Sun4i_uart_init(); 154 155 PE_kputc = _fb_putc; //gPESocDispatch.uart_putc; 156 157} 158 159void PE_init_SocSupport_stub(void) 160{ 161 PE_early_puts("PE_init_SocSupport: Initializing for SUN4I\n"); 162 PE_init_SocSupport_sun4i(); 163} 164 165#endif /* !BOARD_CONFIG_SUN4I */ 166