Browse Source
1. Porting the 3A+690E x86emu module to 2G+690e platform and it works correctly. 2. The HT frequency is adjusted to 800MHz. 3. The start address of PCI IO and memory space are adjusted according to the 3A+690E platform. 4. The framebuffer address(0xb0000000) doesn't map through TLB. The pcitlb.c is added in start.S, but it doesn't work. 5. Fix the IO-read/write base from 0xa000_0000 to 0x0000_0000 in sys/linux/io.h.master
LI Wengang
15 years ago
committed by
LIU Qi
29 changed files with 9814 additions and 7564 deletions
@ -0,0 +1,107 @@ |
|||
/* |
|||
* Now the function on 2g_+690e platform couldn't work |
|||
*/ |
|||
|
|||
li t0, 0x20000000 |
|||
.set mips64 |
|||
dmfc0 t1, COP_0_TLB_PG_MASK, 1 |
|||
or t1, t1, t0 |
|||
dmtc0 t1, COP_0_TLB_PG_MASK, 1 |
|||
|
|||
dmfc0 t0, COP_0_CONFIG, 3 |
|||
ori t0, t0, 0x80 |
|||
dmtc0 t0, COP_0_CONFIG, 3 |
|||
.set mips3 |
|||
|
|||
li t0, 0xfff000 |
|||
mtc0 t0, COP_0_TLB_PG_MASK # 16MB page |
|||
|
|||
li t0, 15 |
|||
|
|||
li t3, 0xd0000000 # entry_hi |
|||
#dli t4, (0x00000e0010000000 >> 6)|0x17 # entry_lo, uncached, valid, dirty, global |
|||
li t4, 0x0e001000 |
|||
#li t4, 0x0efdf000 |
|||
.set mips64 |
|||
dsll t4, t4, 10 |
|||
.set mips3 |
|||
ori t4, t4, 0x17 |
|||
|
|||
li t5, (0x1000000>>6) # 16M stride |
|||
li t6, 0x2000000 # VPN2 32M stride |
|||
|
|||
.set mips64 |
|||
1: |
|||
dmtc0 t3, COP_0_TLB_HI |
|||
daddu t3, t3, t6 |
|||
|
|||
dmtc0 t4, COP_0_TLB_LO0 |
|||
daddu t4, t4, t5 |
|||
dmtc0 t4, COP_0_TLB_LO1 |
|||
daddu t4, t4, t5 |
|||
|
|||
.set mips3 |
|||
|
|||
mtc0 t0, COP_0_TLB_INDEX # 16MB page |
|||
nop |
|||
nop |
|||
nop |
|||
nop |
|||
nop |
|||
tlbwi # random++ |
|||
|
|||
bnez t0, 1b |
|||
addiu t0, t0, -1 |
|||
|
|||
###################################### Video RAM mapping ########## |
|||
|
|||
li t0, 15 |
|||
|
|||
li t3, 0xf0000000 # entry_hi |
|||
#dli t4, (0x0000000070000000 >> 6)|0x1f # entry_lo, cached, valid, dirty, global |
|||
|
|||
#if 1 |
|||
li a0, 0x3f000000 |
|||
bleu msize, a0, 1f |
|||
nop |
|||
li t4, 0x0000f000 |
|||
b 2f |
|||
nop |
|||
#endif |
|||
1: |
|||
li t4, 0x00007000 |
|||
2: |
|||
.set mips64 |
|||
dsll t4, t4, 10 |
|||
.set mips3 |
|||
ori t4, t4, 0x1f |
|||
|
|||
li t5, (0x1000000>>6) # 16M stride |
|||
li t6, 0x2000000 # VPN2 32M stride |
|||
|
|||
.set mips64 |
|||
1: |
|||
dmtc0 t3, COP_0_TLB_HI |
|||
daddu t3, t3, t6 |
|||
|
|||
dmtc0 t4, COP_0_TLB_LO0 |
|||
daddu t4, t4, t5 |
|||
dmtc0 t4, COP_0_TLB_LO1 |
|||
daddu t4, t4, t5 |
|||
|
|||
.set mips3 |
|||
|
|||
addiu t1, t0, 16 |
|||
mtc0 t1, COP_0_TLB_INDEX # 16MB page |
|||
nop |
|||
nop |
|||
nop |
|||
nop |
|||
nop |
|||
tlbwi |
|||
|
|||
bnez t0, 1b |
|||
addiu t0, t0, -1 |
|||
|
|||
|
|||
|
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,64 @@ |
|||
#include "rs690_struct.h" |
|||
/*--------------------------------------------------------------------------------*/ |
|||
|
|||
/*
|
|||
* internal used, most will be filled by vuma init |
|||
*/ |
|||
struct ati_integrated_system_info ati_int_info = { |
|||
/* basic */ |
|||
0, // size of this struct, filled by init
|
|||
|
|||
0, // major_ver, filled by init
|
|||
|
|||
0, // minor_ver, filled by init
|
|||
|
|||
0, // bootup_engine_clock, filled by init, 10KHz unit
|
|||
|
|||
0, // bootup_memory_clock, filled by init, 10KHz unit
|
|||
|
|||
0, // max_system_memory_clock, filled by init, 10KHz unit
|
|||
|
|||
0, // min_system_memory_clock, filled by init, 10KHz unit
|
|||
|
|||
0, // num_of_cycle_in_period_hi, filled by init
|
|||
|
|||
0, // Reserved1
|
|||
|
|||
0, // Reserved2
|
|||
|
|||
0, // inter_nb_voltage_low
|
|||
|
|||
0, // inter_nb_voltage_high
|
|||
|
|||
0, // Reserved3
|
|||
|
|||
0, // fsb, MHz unit
|
|||
|
|||
0, // cap_flag
|
|||
|
|||
/* upstream part */ |
|||
0, // pcie_nbcfg_reg7, filled by init
|
|||
|
|||
0, // k8 memory clock, filled by init
|
|||
|
|||
0, // k8 sync start delay, filled by init
|
|||
|
|||
0, // k8 data return time, filled by init
|
|||
|
|||
0, // max_nb_voltage, filled by init
|
|||
|
|||
0, // min_nb_voltage, filled by init
|
|||
|
|||
0, // memory_type, filled by init
|
|||
|
|||
/* others */ |
|||
0, // num of cycles in period, filled by init
|
|||
|
|||
0, // start_pwm_high_time, filled by init
|
|||
|
|||
0, // ht_link_width, filled by init
|
|||
|
|||
0, // max_nb_voltage_high, filled by init
|
|||
|
|||
0 // min_nb_voltage_high, filled by init
|
|||
}; |
@ -0,0 +1,39 @@ |
|||
#include <sys/linux/types.h> |
|||
|
|||
struct ati_integrated_system_info { |
|||
u16 struct_size; // this struct size
|
|||
u8 major_ver; // major version
|
|||
u8 minor_ver; // minor version
|
|||
u32 bootup_engine_clock; // unit : 10KHz
|
|||
u32 bootup_memory_clock; // unit : 10KHz
|
|||
u32 max_system_memory_clock; // unit : 10KHz
|
|||
u32 min_system_memory_clock; // unit : 10KHz
|
|||
u8 num_of_cycles_in_period_hi; |
|||
u8 reserved1; |
|||
u16 reserved2; |
|||
u16 inter_nb_voltage_low; // intermidiate PWM value to set the voltage
|
|||
u16 inter_nb_voltage_high; |
|||
u32 reserved3; |
|||
u16 fsb; // unit : MHz
|
|||
#define CAP_FLAG_FAKE_HDMI_SUPPORT 0x01 |
|||
#define CAP_FLAG_CLOCK_GATING_ENABLE 0x02 |
|||
|
|||
#define CAP_FLAG_NO_CARD 0x00 |
|||
#define CAP_FLAG_AC_CARD 0x04 |
|||
#define CAP_FLAG_SDVO 0x08 |
|||
u16 cap_flag; |
|||
|
|||
u16 pcie_nbcfg_reg7; // NBMISC 0x37 value
|
|||
u16 k8_memory_clock; // k8 memory clock
|
|||
u16 k8_sync_start_delay; |
|||
u16 k8_data_return_time; |
|||
u8 max_nb_voltage; |
|||
u8 min_nb_voltage; |
|||
u8 memory_type; // bits[7:4] = '0001'DDR1 '0010'DDR2 '0011'DDR3
|
|||
|
|||
u8 num_of_cycles_in_period; |
|||
u8 start_pwm_high_time; |
|||
u8 ht_link_width; |
|||
u8 max_nb_voltage_high; |
|||
u8 min_nb_voltage_high; |
|||
}; |
File diff suppressed because it is too large
@ -0,0 +1,96 @@ |
|||
/*********************************************************************
|
|||
* |
|||
* $Id: theater_out.h,v 1.1.2.2 2004/01/27 22:50:35 fulivi Exp $ |
|||
* |
|||
* Interface file for theater_out module |
|||
* |
|||
* Copyright (C) 2003 Federico Ulivi |
|||
* |
|||
* 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 2 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, write to the Free Software |
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
* |
|||
* AUTHORS: F.Ulivi |
|||
* NOTES: |
|||
* $Log: theater_out.h,v $ |
|||
* Revision 1.1.2.2 2004/01/27 22:50:35 fulivi |
|||
* Support for positioning/sizing of image added |
|||
* |
|||
* Revision 1.1.2.9 2004/01/18 23:01:12 fede |
|||
* Functions for get/setting h/v pos/size replaced by |
|||
* theaterOutSetAttr/theaterOutGetAttr/theaterOutGetAttrLimits |
|||
* Circular inclusion with radeon.h fixed |
|||
* |
|||
* Revision 1.1.2.8 2004/01/11 21:43:32 fede |
|||
* Fixed problem with definition of TVStd |
|||
* |
|||
* Revision 1.1.2.7 2004/01/05 00:09:59 fede |
|||
* Functions for setting/getting H/V position added |
|||
* Functions for setting/getting on/off attribute removed |
|||
* |
|||
* Revision 1.1.2.1 2003/11/26 19:50:10 fulivi |
|||
* Support for ERT added |
|||
* |
|||
* Revision 1.1.2.6 2003/11/25 20:44:00 fede |
|||
* TV_STD_KEEP_OFF added |
|||
* |
|||
* Revision 1.1.2.5 2003/10/14 18:41:32 fede |
|||
* forceERT changed to forceVIP |
|||
* |
|||
* Revision 1.1.2.4 2003/10/11 12:30:30 fede |
|||
* Support for ERT added |
|||
* |
|||
* Revision 1.1 2003/09/28 21:42:37 fulivi |
|||
* Theater_out module added |
|||
* |
|||
* Revision 1.1.2.3 2003/09/28 15:26:09 fede |
|||
* Minor aesthetic changes |
|||
* |
|||
* Revision 1.1.2.1 2003/08/31 13:36:35 fede |
|||
* *** empty log message *** |
|||
* |
|||
* |
|||
*********************************************************************/ |
|||
|
|||
#ifndef _THEATER_OUT_H |
|||
#define _THEATER_OUT_H |
|||
|
|||
/**********************************************************************
|
|||
* |
|||
* TheaterOutPtr |
|||
* |
|||
* Pointer to TheaterOut struct. Actual definition is in theater_out.c |
|||
* |
|||
**********************************************************************/ |
|||
typedef struct TheaterOut *TheaterOutPtr; |
|||
|
|||
/**********************************************************************
|
|||
* |
|||
* TVStd |
|||
* |
|||
* Tv standard |
|||
* |
|||
**********************************************************************/ |
|||
typedef enum { |
|||
TV_STD_NTSC, |
|||
TV_STD_PAL, |
|||
TV_STD_PAL_M, |
|||
TV_STD_PAL_60, |
|||
TV_STD_NTSC_J, |
|||
TV_STD_PAL_CN, |
|||
TV_STD_PAL_N, |
|||
TV_STD_KEEP_OFF, |
|||
TV_STD_N_STANDARDS /* Must be last */ |
|||
} TVStd; |
|||
|
|||
#endif /* _THEATER_OUT_H */ |
@ -0,0 +1,64 @@ |
|||
/*
|
|||
* Modifications to support Loongson Arch: |
|||
* Copyright (c) 2008 Lemote. All rights reserved. |
|||
* |
|||
* Redistribution and use in source and binary forms, with or without |
|||
* modification, are permitted provided that the following conditions |
|||
* are met: |
|||
* 1. Redistributions of source code must retain the above copyright |
|||
* notice unmodified, this list of conditions, and the following |
|||
* disclaimer. |
|||
* 2. Redistributions in binary form must reproduce the above copyright |
|||
* notice, this list of conditions and the following disclaimer in the |
|||
* documentation and/or other materials provided with the distribution. |
|||
* |
|||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|||
* SUCH DAMAGE. |
|||
* |
|||
*/ |
|||
|
|||
/*
|
|||
* VESA framebuffer support. Author: Lj.Peng <penglj@lemote.com> |
|||
*/ |
|||
|
|||
|
|||
/* For vesa mode control */ |
|||
#define GRAPHIC_MODE_100 0x100 /* 640x480 256*/ |
|||
#define GRAPHIC_MODE_101 0x101 /* 640x480 256*/ |
|||
#define GRAPHIC_MODE_102 0x102 /* 800x600 16 */ |
|||
#define GRAPHIC_MODE_103 0x103 /* 800x600 256*/ |
|||
#define GRAPHIC_MODE_104 0x104 /* 1024x768 16*/ |
|||
#define GRAPHIC_MODE_105 0x105 /* 1024x768 256*/ |
|||
#define GRAPHIC_MODE_106 0x106 /* 1280x1024 16*/ |
|||
#define GRAPHIC_MODE_107 0x107 /* 1280x1024 256*/ |
|||
#define GRAPHIC_MODE_10d 0x10d /* 320x200 32K(1:5:5:5)*/ |
|||
#define GRAPHIC_MODE_10e 0x10e /* 320x200 64K(5:6:5)*/ |
|||
#define GRAPHIC_MODE_10f 0x10f /* 320x200 16.8M(8:8:8)*/ |
|||
#define GRAPHIC_MODE_110 0x110 /* 640x480 32K*/ |
|||
#define GRAPHIC_MODE_111 0x111 /* 640x480 64K*/ |
|||
#define GRAPHIC_MODE_112 0x112 /* 640x480 16.8M*/ |
|||
#define GRAPHIC_MODE_113 0x113 /* 800x600 32K*/ |
|||
#define GRAPHIC_MODE_114 0x114 /* 800x600 64K*/ |
|||
#define GRAPHIC_MODE_115 0x115 /* 800x600 16.8M*/ |
|||
#define GRAPHIC_MODE_116 0x116 /* 1024x768 32K*/ |
|||
#define GRAPHIC_MODE_117 0x117 /* 1024x768 64K*/ |
|||
#define GRAPHIC_MODE_118 0x118 /* 1024x768 16.8M*/ |
|||
#define GRAPHIC_MODE_119 0x119 /* 1280x1024 32K*/ |
|||
#define GRAPHIC_MODE_11a 0x11a /* 1280x1024 64K*/ |
|||
#define GRAPHIC_MODE_11b 0x11b /* 1280x1024 16.8M*/ |
|||
#define USE_LINEAR_FRAMEBUFFER 0x4000 |
|||
struct vesamode { |
|||
int mode; |
|||
int width; |
|||
int height; |
|||
int bpp; |
|||
}; |
@ -0,0 +1,589 @@ |
|||
/*
|
|||
* Modifications to support Loongson Arch: |
|||
* Copyright (c) 2008 Lemote. All rights reserved. |
|||
* |
|||
* Redistribution and use in source and binary forms, with or without |
|||
* modification, are permitted provided that the following conditions |
|||
* are met: |
|||
* 1. Redistributions of source code must retain the above copyright |
|||
* notice unmodified, this list of conditions, and the following |
|||
* disclaimer. |
|||
* 2. Redistributions in binary form must reproduce the above copyright |
|||
* notice, this list of conditions and the following disclaimer in the |
|||
* documentation and/or other materials provided with the distribution. |
|||
* |
|||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|||
* SUCH DAMAGE. |
|||
* |
|||
*/ |
|||
|
|||
/*
|
|||
* VESA framebuffer support. Author: Lj.Peng <penglj@lemote.com> |
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
|
|||
#include <dev/pci/pcivar.h> |
|||
#include "xf86int10.h" |
|||
#include "xf86x86emu.h" |
|||
#include "linux/io.h" |
|||
|
|||
#include "mod_framebuffer.h" |
|||
#include "vesa.h" |
|||
#include <mod_sisfb.h> |
|||
//#include "bonito.h"
|
|||
|
|||
extern struct pci_device *vga_dev; |
|||
|
|||
int vesa_mode = 1; |
|||
|
|||
/*
|
|||
* The following macros are especially useful for __asm__ |
|||
* inline assembler. |
|||
*/ |
|||
#ifndef __STR |
|||
#define __STR(x) #x |
|||
#endif |
|||
#ifndef STR |
|||
#define STR(x) __STR(x) |
|||
#endif |
|||
|
|||
/*
|
|||
* Configure language |
|||
*/ |
|||
#ifdef __ASSEMBLY__ |
|||
#define _ULCAST_ |
|||
#else |
|||
#define _ULCAST_ (unsigned long) |
|||
#endif |
|||
|
|||
/*
|
|||
* Coprocessor 0 register names |
|||
*/ |
|||
#define CP0_INDEX $0 |
|||
#define CP0_RANDOM $1 |
|||
#define CP0_ENTRYLO0 $2 |
|||
#define CP0_ENTRYLO1 $3 |
|||
#define CP0_CONF $3 |
|||
#define CP0_CONTEXT $4 |
|||
#define CP0_PAGEMASK $5 |
|||
#define CP0_WIRED $6 |
|||
#define CP0_INFO $7 |
|||
#define CP0_BADVADDR $8 |
|||
#define CP0_COUNT $9 |
|||
#define CP0_ENTRYHI $10 |
|||
#define CP0_COMPARE $11 |
|||
#define CP0_STATUS $12 |
|||
#define CP0_CAUSE $13 |
|||
#define CP0_EPC $14 |
|||
#define CP0_PRID $15 |
|||
#define CP0_CONFIG $16 |
|||
#define CP0_LLADDR $17 |
|||
#define CP0_WATCHLO $18 |
|||
#define CP0_WATCHHI $19 |
|||
#define CP0_XCONTEXT $20 |
|||
#define CP0_FRAMEMASK $21 |
|||
#define CP0_DIAGNOSTIC $22 |
|||
#define CP0_DEBUG $23 |
|||
#define CP0_DEPC $24 |
|||
#define CP0_PERFORMANCE $25 |
|||
#define CP0_ECC $26 |
|||
#define CP0_CACHEERR $27 |
|||
#define CP0_TAGLO $28 |
|||
#define CP0_TAGHI $29 |
|||
#define CP0_ERROREPC $30 |
|||
#define CP0_DESAVE $31 |
|||
|
|||
/*
|
|||
* R4640/R4650 cp0 register names. These registers are listed |
|||
* here only for completeness; without MMU these CPUs are not useable |
|||
* by Linux. A future ELKS port might take make Linux run on them |
|||
* though ... |
|||
*/ |
|||
#define CP0_IBASE $0 |
|||
#define CP0_IBOUND $1 |
|||
#define CP0_DBASE $2 |
|||
#define CP0_DBOUND $3 |
|||
#define CP0_CALG $17 |
|||
#define CP0_IWATCH $18 |
|||
#define CP0_DWATCH $19 |
|||
|
|||
/*
|
|||
* Coprocessor 0 Set 1 register names |
|||
*/ |
|||
#define CP0_S1_DERRADDR0 $26 |
|||
#define CP0_S1_DERRADDR1 $27 |
|||
#define CP0_S1_INTCONTROL $20 |
|||
|
|||
/*
|
|||
* TX39 Series |
|||
*/ |
|||
#define CP0_TX39_CACHE $7 |
|||
|
|||
/*
|
|||
* Coprocessor 1 (FPU) register names |
|||
*/ |
|||
#define CP1_REVISION $0 |
|||
#define CP1_STATUS $31 |
|||
|
|||
|
|||
#define PM_4K 0x00000000 |
|||
#define PM_16K 0x00006000 |
|||
#define PM_64K 0x0001e000 |
|||
#define PM_256K 0x0007e000 |
|||
#define PM_1M 0x001fe000 |
|||
#define PM_4M 0x007fe000 |
|||
#define PM_16M 0x01ffe000 |
|||
#define PM_64M 0x07ffe000 |
|||
#define PM_256M 0x1fffe000 |
|||
|
|||
/* Page size 64kb */ |
|||
#define CONFIG_PAGE_SIZE_1M |
|||
|
|||
/*
|
|||
* Default page size for a given kernel configuration |
|||
*/ |
|||
#ifdef CONFIG_PAGE_SIZE_4KB |
|||
#define PM_DEFAULT_MASK PM_4K |
|||
#elif defined(CONFIG_PAGE_SIZE_16KB) |
|||
#define PM_DEFAULT_MASK PM_16K |
|||
#elif defined(CONFIG_PAGE_SIZE_64KB) |
|||
#define PM_DEFAULT_MASK PM_64K |
|||
#elif defined(CONFIG_PAGE_SIZE_256KB) |
|||
#define PM_DEFAULT_MASK PM_256K |
|||
#elif defined(CONFIG_PAGE_SIZE_1M) |
|||
#define PM_DEFAULT_MASK PM_1M |
|||
#elif defined(CONFIG_PAGE_SIZE_4M) |
|||
#define PM_DEFAULT_MASK PM_4M |
|||
#else |
|||
#error Bad page size configuration! |
|||
#endif |
|||
|
|||
|
|||
/*
|
|||
* Values used for computation of new tlb entries |
|||
*/ |
|||
#define PL_4K 12 |
|||
#define PL_16K 14 |
|||
#define PL_64K 16 |
|||
#define PL_256K 18 |
|||
#define PL_1M 20 |
|||
#define PL_4M 22 |
|||
#define PL_16M 24 |
|||
#define PL_64M 26 |
|||
#define PL_256M 28 |
|||
|
|||
/*
|
|||
* Macros to access the system control coprocessor |
|||
*/ |
|||
|
|||
#define __read_32bit_c0_register(source, sel) \ |
|||
({ int __res; \ |
|||
if (sel == 0) \ |
|||
__asm__ __volatile__( \ |
|||
"mfc0\t%0, " #source "\n\t" \ |
|||
: "=r" (__res)); \ |
|||
else \ |
|||
__asm__ __volatile__( \ |
|||
".set\tmips32\n\t" \ |
|||
"mfc0\t%0, " #source ", " #sel "\n\t" \ |
|||
".set\tmips0\n\t" \ |
|||
: "=r" (__res)); \ |
|||
__res; \ |
|||
}) |
|||
|
|||
#define __read_64bit_c0_register(source, sel) \ |
|||
({ unsigned long __res; \ |
|||
if (sel == 0) \ |
|||
__asm__ __volatile__( \ |
|||
".set\tmips3\n\t" \ |
|||
"dmfc0\t%0, " #source "\n\t" \ |
|||
".set\tmips0" \ |
|||
: "=r" (__res)); \ |
|||
else \ |
|||
__asm__ __volatile__( \ |
|||
".set\tmips64\n\t" \ |
|||
"dmfc0\t%0, " #source ", " #sel "\n\t" \ |
|||
".set\tmips0" \ |
|||
: "=r" (__res)); \ |
|||
__res; \ |
|||
}) |
|||
|
|||
#define __write_32bit_c0_register(register, sel, value) \ |
|||
do { \ |
|||
if (sel == 0) \ |
|||
__asm__ __volatile__( \ |
|||
"mtc0\t%z0, " #register "\n\t" \ |
|||
: : "Jr" (value)); \ |
|||
else \ |
|||
__asm__ __volatile__( \ |
|||
".set\tmips32\n\t" \ |
|||
"mtc0\t%z0, " #register ", " #sel "\n\t" \ |
|||
".set\tmips0" \ |
|||
: : "Jr" (value)); \ |
|||
} while (0) |
|||
|
|||
#define __write_64bit_c0_register(register, sel, value) \ |
|||
do { \ |
|||
if (sel == 0) \ |
|||
__asm__ __volatile__( \ |
|||
".set\tmips3\n\t" \ |
|||
"dmtc0\t%z0, " #register "\n\t" \ |
|||
".set\tmips0" \ |
|||
: : "Jr" (value)); \ |
|||
else \ |
|||
__asm__ __volatile__( \ |
|||
".set\tmips64\n\t" \ |
|||
"dmtc0\t%z0, " #register ", " #sel "\n\t" \ |
|||
".set\tmips0" \ |
|||
: : "Jr" (value)); \ |
|||
} while (0) |
|||
|
|||
#define __read_ulong_c0_register(reg, sel) \ |
|||
((sizeof(unsigned long) == 4) ? \ |
|||
__read_32bit_c0_register(reg, sel) : \ |
|||
__read_64bit_c0_register(reg, sel)) |
|||
|
|||
#define __write_ulong_c0_register(reg, sel, val) \ |
|||
do { \ |
|||
if (sizeof(unsigned long) == 4) \ |
|||
__write_32bit_c0_register(reg, sel, val); \ |
|||
else \ |
|||
__write_64bit_c0_register(reg, sel, val); \ |
|||
} while (0) |
|||
|
|||
#define read_c0_index() __read_32bit_c0_register($0, 0) |
|||
#define write_c0_index(val) __write_32bit_c0_register($0, 0, val) |
|||
|
|||
#define read_c0_entrylo0() __read_ulong_c0_register($2, 0) |
|||
#define write_c0_entrylo0(val) __write_ulong_c0_register($2, 0, val) |
|||
|
|||
#define read_c0_entrylo1() __read_ulong_c0_register($3, 0) |
|||
#define write_c0_entrylo1(val) __write_ulong_c0_register($3, 0, val) |
|||
|
|||
#define read_c0_conf() __read_32bit_c0_register($3, 0) |
|||
#define write_c0_conf(val) __write_32bit_c0_register($3, 0, val) |
|||
|
|||
#define read_c0_context() __read_ulong_c0_register($4, 0) |
|||
#define write_c0_context(val) __write_ulong_c0_register($4, 0, val) |
|||
|
|||
#define read_c0_pagemask() __read_32bit_c0_register($5, 0) |
|||
#define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val) |
|||
|
|||
#define read_c0_wired() __read_32bit_c0_register($6, 0) |
|||
#define write_c0_wired(val) __write_32bit_c0_register($6, 0, val) |
|||
|
|||
#define read_c0_info() __read_32bit_c0_register($7, 0) |
|||
|
|||
#define read_c0_cache() __read_32bit_c0_register($7, 0) /* TX39xx */ |
|||
#define write_c0_cache(val) __write_32bit_c0_register($7, 0, val) |
|||
|
|||
#define read_c0_count() __read_32bit_c0_register($9, 0) |
|||
#define write_c0_count(val) __write_32bit_c0_register($9, 0, val) |
|||
|
|||
#define read_c0_entryhi() __read_ulong_c0_register($10, 0) |
|||
#define write_c0_entryhi(val) __write_ulong_c0_register($10, 0, val) |
|||
|
|||
#define read_c0_compare() __read_32bit_c0_register($11, 0) |
|||
#define write_c0_compare(val) __write_32bit_c0_register($11, 0, val) |
|||
|
|||
#define read_c0_status() __read_32bit_c0_register($12, 0) |
|||
#define write_c0_status(val) __write_32bit_c0_register($12, 0, val) |
|||
|
|||
#define read_c0_cause() __read_32bit_c0_register($13, 0) |
|||
#define write_c0_cause(val) __write_32bit_c0_register($13, 0, val) |
|||
|
|||
#define read_c0_prid() __read_32bit_c0_register($15, 0) |
|||
|
|||
#define read_c0_config() __read_32bit_c0_register($16, 0) |
|||
#define read_c0_config1() __read_32bit_c0_register($16, 1) |
|||
#define read_c0_config2() __read_32bit_c0_register($16, 2) |
|||
#define read_c0_config3() __read_32bit_c0_register($16, 3) |
|||
#define write_c0_config(val) __write_32bit_c0_register($16, 0, val) |
|||
#define write_c0_config1(val) __write_32bit_c0_register($16, 1, val) |
|||
#define write_c0_config2(val) __write_32bit_c0_register($16, 2, val) |
|||
#define write_c0_config3(val) __write_32bit_c0_register($16, 3, val) |
|||
|
|||
#define read_c0_framemask() __read_32bit_c0_register($21, 0) |
|||
#define write_c0_framemask(val) __write_32bit_c0_register($21, 0, val) |
|||
|
|||
#define read_c0_debug() __read_32bit_c0_register($23, 0) |
|||
#define write_c0_debug(val) __write_32bit_c0_register($23, 0, val) |
|||
|
|||
#define read_c0_depc() __read_ulong_c0_register($24, 0) |
|||
#define write_c0_depc(val) __write_ulong_c0_register($24, 0, val) |
|||
|
|||
#define read_c0_ecc() __read_32bit_c0_register($26, 0) |
|||
#define write_c0_ecc(val) __write_32bit_c0_register($26, 0, val) |
|||
|
|||
#define read_c0_derraddr0() __read_ulong_c0_register($26, 1) |
|||
#define write_c0_derraddr0(val) __write_ulong_c0_register($26, 1, val) |
|||
|
|||
#define read_c0_cacheerr() __read_32bit_c0_register($27, 0) |
|||
|
|||
#define read_c0_derraddr1() __read_ulong_c0_register($27, 1) |
|||
#define write_c0_derraddr1(val) __write_ulong_c0_register($27, 1, val) |
|||
|
|||
#define read_c0_taglo() __read_32bit_c0_register($28, 0) |
|||
#define write_c0_taglo(val) __write_32bit_c0_register($28, 0, val) |
|||
|
|||
#define read_c0_taghi() __read_32bit_c0_register($29, 0) |
|||
#define write_c0_taghi(val) __write_32bit_c0_register($29, 0, val) |
|||
|
|||
#define read_c0_errorepc() __read_ulong_c0_register($30, 0) |
|||
#define write_c0_errorepc(val) __write_ulong_c0_register($30, 0, val) |
|||
|
|||
/*
|
|||
* TLB operations. |
|||
*/ |
|||
static inline void tlb_probe(void) |
|||
{ |
|||
__asm__ __volatile__( |
|||
".set noreorder\n\t" |
|||
"tlbp\n\t" |
|||
".set reorder"); |
|||
} |
|||
|
|||
static inline void tlb_read(void) |
|||
{ |
|||
__asm__ __volatile__( |
|||
".set noreorder\n\t" |
|||
"tlbr\n\t" |
|||
".set reorder"); |
|||
} |
|||
|
|||
static inline void tlb_write_indexed(void) |
|||
{ |
|||
__asm__ __volatile__( |
|||
".set noreorder\n\t" |
|||
"tlbwi\n\t" |
|||
".set reorder"); |
|||
} |
|||
|
|||
static inline void tlb_write_random(void) |
|||
{ |
|||
__asm__ __volatile__( |
|||
".set noreorder\n\t" |
|||
"tlbwr\n\t" |
|||
".set reorder"); |
|||
} |
|||
|
|||
#define ASID_INC 0x1 |
|||
#define ASID_MASK 0xff |
|||
|
|||
|
|||
/*
|
|||
* PAGE_SHIFT determines the page size |
|||
*/ |
|||
#ifdef CONFIG_PAGE_SIZE_4KB |
|||
#define PAGE_SHIFT 12 |
|||
#endif |
|||
#ifdef CONFIG_PAGE_SIZE_16KB |
|||
#define PAGE_SHIFT 14 |
|||
#endif |
|||
#ifdef CONFIG_PAGE_SIZE_64KB |
|||
#define PAGE_SHIFT 16 |
|||
#endif |
|||
#ifdef CONFIG_PAGE_SIZE_256KB |
|||
#define PAGE_SHIFT 18 |
|||
#endif |
|||
#ifdef CONFIG_PAGE_SIZE_1M |
|||
#define PAGE_SHIFT 20 |
|||
#endif |
|||
#define PAGE_SIZE (1UL << PAGE_SHIFT) |
|||
#define PAGE_MASK (~(PAGE_SIZE-1)) |
|||
|
|||
|
|||
/* For vesa mode control */ |
|||
#define GRAPHIC_MODE_100 0x100 /* 640x400 256*/ |
|||
#define GRAPHIC_MODE_101 0x101 /* 640x480 256*/ |
|||
#define GRAPHIC_MODE_102 0x102 /* 800x600 16 */ |
|||
#define GRAPHIC_MODE_103 0x103 /* 800x600 256*/ |
|||
#define GRAPHIC_MODE_104 0x104 /* 1024x768 16*/ |
|||
#define GRAPHIC_MODE_105 0x105 /* 1024x768 256*/ |
|||
#define GRAPHIC_MODE_106 0x106 /* 1280x1024 16*/ |
|||
#define GRAPHIC_MODE_107 0x107 /* 1280x1024 256*/ |
|||
#define GRAPHIC_MODE_10d 0x10d /* 320x200 32K(1:5:5:5)*/ |
|||
#define GRAPHIC_MODE_10e 0x10e /* 320x200 64K(5:6:5)*/ |
|||
#define GRAPHIC_MODE_10f 0x10f /* 320x200 16.8M(8:8:8)*/ |
|||
#define GRAPHIC_MODE_110 0x110 /* 640x480 32K*/ |
|||
#define GRAPHIC_MODE_111 0x111 /* 640x480 64K*/ |
|||
#define GRAPHIC_MODE_112 0x112 /* 640x480 16.8M*/ |
|||
#define GRAPHIC_MODE_113 0x113 /* 800x600 32K*/ |
|||
#define GRAPHIC_MODE_114 0x114 /* 800x600 64K*/ |
|||
#define GRAPHIC_MODE_115 0x115 /* 800x600 16.8M*/ |
|||
#define GRAPHIC_MODE_116 0x116 /* 1024x768 32K*/ |
|||
#define GRAPHIC_MODE_117 0x117 /* 1024x768 64K*/ |
|||
#define GRAPHIC_MODE_118 0x118 /* 1024x768 16.8M*/ |
|||
#define GRAPHIC_MODE_119 0x119 /* 1280x1024 32K*/ |
|||
#define GRAPHIC_MODE_11a 0x11a /* 1280x1024 64K*/ |
|||
#define GRAPHIC_MODE_11b 0x11b /* 1280x1024 16.8M*/ |
|||
#define USE_LINEAR_FRAMEBUFFER 0x4000 |
|||
struct vesamode vesamode[] = { |
|||
{GRAPHIC_MODE_114,800,600,16}, /* default 800x600x16 */ |
|||
{GRAPHIC_MODE_100,640,400,8}, |
|||
{GRAPHIC_MODE_101,640,480,8}, |
|||
{GRAPHIC_MODE_102,800,600,4}, |
|||
{GRAPHIC_MODE_103,800,600,8}, |
|||
{GRAPHIC_MODE_104,1024,768,16}, |
|||
{GRAPHIC_MODE_105,1024,768,8}, |
|||
{GRAPHIC_MODE_106,1280,1024,16}, |
|||
{GRAPHIC_MODE_107,1280,1024,8}, |
|||
{GRAPHIC_MODE_10d,320,200,15}, |
|||
{GRAPHIC_MODE_10e,320,200,16}, |
|||
{GRAPHIC_MODE_10f,320,200,24}, |
|||
{GRAPHIC_MODE_110,640,480,15}, |
|||
{GRAPHIC_MODE_111,640,480,16}, |
|||
{GRAPHIC_MODE_112,640,480,24}, |
|||
{GRAPHIC_MODE_113,800,600,15}, |
|||
{GRAPHIC_MODE_114,800,600,16}, |
|||
{GRAPHIC_MODE_115,800,600,24}, |
|||
{GRAPHIC_MODE_116,1024,768,15}, |
|||
{GRAPHIC_MODE_117,1024,768,16}, |
|||
{GRAPHIC_MODE_118,1024,768,24}, |
|||
{GRAPHIC_MODE_119,1280,1024,15}, |
|||
{GRAPHIC_MODE_11a,1280,1024,16}, |
|||
{GRAPHIC_MODE_11b,1280,1024,24}, |
|||
}; |
|||
|
|||
struct vesamode *vesa_mode_head = vesamode; |
|||
|
|||
|
|||
static u32 io_vaddr; |
|||
|
|||
|
|||
void tlbmap(u32 viraddr, u32 phyaddr, u32 size) |
|||
{ |
|||
u32 tmp_size; |
|||
u32 pid, idx; |
|||
write_c0_pagemask(PM_DEFAULT_MASK); |
|||
|
|||
pid = read_c0_entryhi() & ASID_MASK; |
|||
|
|||
printf("tlbmap vaddr %x paddr %x size %x\n", viraddr, phyaddr, size); |
|||
for (tmp_size = 0 ;tmp_size < size; tmp_size += (2*PAGE_SIZE)) { |
|||
viraddr &= (PAGE_MASK << 1); |
|||
write_c0_entryhi(viraddr | (pid)); |
|||
tlb_probe(); |
|||
idx = read_c0_index(); |
|||
printf("viraddr=%08x,phyaddr=%08x,pid=%x,idx=%x\n",viraddr,phyaddr,pid,idx); |
|||
/* Uncached accelerate */ |
|||
write_c0_entrylo0((phyaddr >> 6)|0x3f); |
|||
write_c0_entrylo1(((phyaddr+PAGE_SIZE) >> 6)|0x3f); |
|||
write_c0_entryhi(viraddr | (pid)); |
|||
|
|||
if(idx < 0) { |
|||
tlb_write_random(); |
|||
} else { |
|||
tlb_write_indexed(); |
|||
} |
|||
viraddr += (PAGE_SIZE*2); |
|||
phyaddr += (PAGE_SIZE*2); |
|||
} |
|||
write_c0_entryhi(pid); |
|||
} |
|||
|
|||
#define BONITO_REGBASE 0x100 |
|||
#define BONITO_PCIMAP BONITO(BONITO_REGBASE + 0x10) |
|||
#define BONITO(x) *(volatile unsigned long *)(0xbfe00000+(x)) |
|||
#define BONITO_PCIMAP BONITO(BONITO_REGBASE + 0x10) |
|||
#define BONITO_PCIMAP_PCIMAP_LO0 0x0000003f |
|||
#define BONITO_PCIMAP_WIN(WIN,ADDR) ((((ADDR)>>26) & BONITO_PCIMAP_PCIMAP_LO0) << ((WIN)*6)) |
|||
|
|||
int vesafb_init(void) |
|||
{ |
|||
u32 video_mem_size; |
|||
u32 fb_address, io_address; |
|||
u32 tmp; |
|||
|
|||
fb_address =_pci_conf_read(vga_dev->pa.pa_tag,0x10); |
|||
io_address =_pci_conf_read(vga_dev->pa.pa_tag,0x18); |
|||
//io_vaddr = io_address | 0xbfd00000;
|
|||
//io_vaddr = io_address | BONITO_PCIIO_BASE_VA;
|
|||
io_vaddr = io_address | 0xb8000000; |
|||
|
|||
/* We assume all the framebuffer is required remmapping */ |
|||
#ifdef USETLB |
|||
/* Remap framebuffer address to 0x40000000, which can be accessed by same physical address from cpu */ |
|||
_pci_conf_write(vga_dev->pa.pa_tag, 0x10, 0x40000000); |
|||
/* FIXME: video memory size should be detected by software, but now fixed in 2MB that's enough in PMON */ |
|||
video_mem_size = 0x200000; |
|||
|
|||
#if 1 |
|||
/* Map cpu physical address 0x40000000 to BONITO address 0x40000000 -> PCI address 0x40000000.
|
|||
* Master0 window 3 */ |
|||
asm ( |
|||
".set mips3\n" |
|||
".set noreorder\n" |
|||
"dli $2, 0x900000003ff00000\n" |
|||
"dli $3, 0x0000000040000000\n" |
|||
"sd $3, 0x18($2)\n" |
|||
"dli $3, 0x0000000040000001\n" |
|||
"sd $3, 0x58($2)\n" |
|||
"dli $3, 0xffffffffc0000000\n" |
|||
"sd $3, 0x38($2)\n" |
|||
".set reorder\n" |
|||
".set mips0\n" |
|||
:::"$2","$3","memory" |
|||
); |
|||
#endif |
|||
|
|||
/* If framebuffer bar is NULL, then it has too large memory to be alloced in kernel mode */ |
|||
/* TLB map physical address to virtual address in kseg3. Start address is 0xe0000000 */ |
|||
tlbmap(0xe0000000, 0x40000000, video_mem_size); |
|||
#else |
|||
|
|||
#if 0 |
|||
/* 0x10000000 -> 0x40000000 PCI mapping */ |
|||
_pci_conf_write(vga_dev->pa.pa_tag, 0x10, 0x40000000); |
|||
tmp = BONITO_PCIMAP; |
|||
BONITO_PCIMAP = |
|||
BONITO_PCIMAP_WIN(0, 0x40000000) | |
|||
(tmp & ~BONITO_PCIMAP_PCIMAP_LO0); |
|||
#endif |
|||
#endif |
|||
|
|||
printf("VESA FB init complete.\n"); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
/* dummy implementation */ |
|||
void video_set_lut2(int index, int rgb) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
int GetXRes(void) |
|||
{ |
|||
return vesamode[vesa_mode].width; |
|||
} |
|||
|
|||
int GetYRes(void) |
|||
{ |
|||
return vesamode[vesa_mode].height; |
|||
} |
|||
|
|||
int GetBytesPP(void) |
|||
{ |
|||
return (vesamode[vesa_mode].bpp+1)/8; |
|||
} |
|||
|
|||
void video_set_lut(int index, int r, int g, int b) |
|||
{ |
|||
linux_outb(index, 0x03C8); |
|||
linux_outb(r >> 2, 0x03C9); |
|||
linux_outb(g >> 2, 0x03C9); |
|||
linux_outb(b >> 2, 0x03C9); |
|||
} |
File diff suppressed because it is too large
Loading…
Reference in new issue