⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sccx9211.asm

📁 X86 GX1 BOOTLOAD代码 ,支持WINCE操作系统!
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;**************************************************************************
;*                                                                        *
;*  SCCX9211.ASM                                                          *
;*                                                                        *
;*  Copyright (c) 1998-2000 National Semiconductor Corporation.           *
;*  All Rights Reserved.                                                  *
;*                                                                        *
;*  Function:                                                             *
;*      Initialization for the 9211 DSTN controller for SCx2xx chips.     *
;*                                                                        *
;* $ Revision:: 1                                                         $
;**************************************************************************

;REV legacy
;Revision	ID Reg 430[15:0]	Visual markings			Problems with this revision
;on case
;B1			0201			Last line: C M NSC 99 B1	FRM algorithm causes bars and shimmering
;C1			0201			Last line: C M 2000 C1		FRM counter does not increment; ID  is wrong
;C2			0302			Last line: C M 2000 C2		GPIO read back problem
;C3			0303			Last line: C M 2000 C3	

 	.486P
	INCLUDE MACROS.INC   	; Macros used throughout
	INCLUDE DEF.INC	 	; EQU Definitions
	INCLUDE PORT80.INC	; Post code Definitions
	INCLUDE STRINGS.INC	; New macros and defines
	INCLUDE OPTIONS.INC
	INCLUDE MPC.INC
	INCLUDE BDCFG.INC


_TEXT SEGMENT PUBLIC use16 'CODE'

	EXTERN	Delay_100_mSec:NEAR
	EXTERN	lcdInit:NEAR
	EXTERN	hex_dword:NEAR
	EXTERN	hex_nibble:NEAR
	EXTERN	hex_byte:NEAR

;;; Data Ports out of scx2xx to 9211
	GPIODATAOUT	EQU	GEODE_GPIO_BASE + GEODE_GPDO0

;;; Data Ports in to SCx2xx from 9211
	GPIODATAIN	EQU	GEODE_GPIO_BASE + GEODE_GPDI0

;;; Pin MASKS
	CLOCK9211	EQU	1 shl CLOCK9211CFG 	; clock output to 9211
	DATAIN9211	EQU	1 shl DATAIN9211CFG	; data output to 9211
	DATAOUT9211	EQU	1 shl DATAOUT9211CFG	; data input from 9211
	CS9211		EQU	1 shl CS9211CFG		; chip select output to 9211

FP_FUNC struct 1
	TFT_TYPE	db ?	; 5530 TFT setting
	PT1		dd ?	; panel timing reg 1
	PT2		dd ?	; panel timing reg 2
	DFR		dd ?	; dither and frame rate control 
	BS1		dd ?	; block select 1
	BS2		dd ?	; block select 2
	DISP1		dd ?	; dispersion 1
	DISP2		dd ?	; dispersion 2
	MC		dd ?	; memory control
	PM		dd ?	; power management
	FRMTABLE	dw ?	; offset of FRM table
FP_FUNC  ENDS

FPJumperTableRevB	LABEL FP_FUNC		;Flat Panel Type From Spec
;00h - no flat panel, no fixed timings
	FP_FUNC<3, 0ffffffffh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0h>

;01h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;02h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;03h - placeholder - currently 640, 480, 16, DSTN, COLOR 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;04h - placeholder - currently 640, 480, 16, DSTN, COLOR 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;05h - placeholder - currently 640, 480, 16, DSTN, COLOR 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;06h - placeholder - currently 640, 480, 16, DSTN, COLOR 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;07h - placeholder - currently 640, 480, 16, DSTN, COLOR 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;08h 800, 600, 18, TFT, COLOR
	FP_FUNC<1, 02580000h, 0f100000h, 00000050h, 00000000h, 00000000h, 00000000h, 00000000h, 00000000h, 01000000h, 0h>

;09h 640, 480, 8, SSTN, COLOR
	FP_FUNC<0, 01e00000h, 00034000h, 00000050h, 25cf3096h, 0ad47b81eh, 21446450h, 21446450h, 00000000h, 01000000h, 0h>

;0ah 1024, 768, 18, TFT, COLOR
	FP_FUNC<2, 03000000h, 0f100000h, 00000050h, 00000000h, 00000000h, 00000000h, 00000000h, 00000000h, 01000000h, 0h>

;0bh 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>

;0ch 640, 480, 18, TFT, COLOR
	FP_FUNC<0, 01e00000h, 0f100000h, 00000050h, 00000000h, 00000000h, 00000000h, 00000000h, 00000000h, 01000000h, 0h>

;0dh 1024, 768, 24, DSTN, COLOR
	FP_FUNC<2, 03000000h, 80024000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000005h, 01000000h, 0h>

;0eh 640, 480, 8, DSTN, MONO
	FP_FUNC<0, 01e00000h, 00084000h, 00000050h, 25cf3096h, 0ad47b81eh, 21446450h, 21446450h, 00000007h, 01000000h, 0h>

;0fh 800, 600, 16, DSTN, COLOR
	FP_FUNC<1, 02580000h, 00014000h, 00000050h, 48c26aeh, 048c26aeh, 2468aceh, 13579bdfh, 00000007h, 01000000h, 0h>


FPJumperTableRevC	LABEL FP_FUNC		;Flat Panel Type From Spec
;00h - no flat panel, no fixed timings
	FP_FUNC<3, 0ffffffffh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0h>

;01h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;02h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;03h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;04h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;05h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;06h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;0h - placeholder - currently 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;08h 800, 600, 18, TFT, COLOR
	FP_FUNC<1, 02580000h, 0f100000h, 00000050h, 00000000h, 00000000h, 00000000h,  00000000h, 00000000h, 01000000h, OFFSET FP86TC18>

;09h - 640, 480, 8, SSTN, COLOR
	FP_FUNC<0, 01e00000h, 00034000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000000h, 01000000h, OFFSET FP64SC8>

;0ah - 1024, 768, 18, TFT, COLOR
	FP_FUNC<2, 03000000h, 0f100000h, 00000050h, 00000000h, 00000000h, 00000000h,  00000000h, 00000000h, 01000000h, OFFSET FP107TC18>

;0bh - 640, 480, 16, DSTN, COLOR
	FP_FUNC<0, 01e00000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DC16>

;0ch - 640, 480, 18, TFT, COLOR
	FP_FUNC<0, 01e00000h, 0f100000h, 00000050h, 00000000h, 00000000h, 00000000h,  00000000h, 00000000h, 01000000h, OFFSET FP64TC18>

;0dh - 1024, 768, 24, DSTN, COLOR
	FP_FUNC<2, 03000000h, 80024000h, 0000004Bh, 00004098h, 40984098h, 00000000h, 00000000h, 00000005h, 01000000h, OFFSET FP107DC24>

;0eh - 640, 480, 8, DSTN, MONO
	FP_FUNC<0, 01e00000h, 00084000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP64DM8>

;0fh - 800, 600, 16, DSTN, COLOR
	FP_FUNC<1, 02580000h, 00014000h, 0000004Bh, 00004098h, 40984098h, 00000000h,  00000000h, 00000007h, 01000000h, OFFSET FP86DC16>


;**************************************************************************
;*
;*	Proc Name: cx92xxinit
;*
;*	Use: Initializes the 9211
;*
;*	Entry:
;*
;*	Exit:
;*
;*	Destroys: None
;*
;**************************************************************************
cx92xxinit  PROC NEAR PUBLIC
	pushad
	pushf

	call	Delay_100_mSec
	call	cx9211gpioInit		; Get the GPIO's ready, direction & state.

	; Wake up the Cx9211
	mov	cx, 5
	cld
clockInit9211:
	call	cx9211toggleClock
	loop	clockInit9211

	mov	bx, 0430h
	call	cx9211readReg

	cmp	eax, 92110201h			; RevC
	jb	checkRevB
	lea	si, FPJumperTableRevC
	jmp	setgpios

checkRevB:
	cmp	eax, 92110101h			; RevB
	jne	No9211
	lea	si, FPJumperTableRevB

setgpios:					; Set 9211 GPIOs
	mov	bx, 0438h
	call	cx9211readReg
	and 	eax, 00E8E8E8h			; clear gpios
	or	eax, 00170000h			; set gpios input/normal/pullup
	call	cx9211writeReg

	; read panel type gpios
	mov	bx, 0434h
	call 	cx9211readReg

	;move the 4 panel type gpios in to bottom nibble of al, then clear the rest
	shr	ax, LCDRESGPIO1 + 1
	shr	ah, LCDRESGPIO2 - LCDRESGPIO1 - 1
	shr	ax, 1
	shr	ah, LCDRESGPIO3 - LCDRESGPIO2 - 1
	shr	ax, 1
	shr	ah, LCDRESGPIO4 - LCDRESGPIO3 - 1
	shr	ax, 5
	and	al, 0fh

inctofp:
	; get panel type from table
	cmp	al, 0
	je	Program9211
	add	si, size FP_FUNC
	dec	al
	jmp	inctofp

Program9211:
	;Set TFT to settings from table.
	mov	al, cs:(FP_FUNC PTR [si]).TFT_TYPE
	cmp	al, LCDRES
	je	SkiplcdReinit
	call	lcdInit
	call	Delay_100_mSec
 
 	; Wake up the Cx9211 if we just restarted 5530 LCD interface
 	mov	cx, 5
	cld
clockInit92112:
	call	cx9211toggleClock
	loop	clockInit92112

SkiplcdReinit:
	mov	bx, 0408h		; turn off flat panel
	mov	eax, 0
	call	cx9211writeReg
	call	Delay_100_mSec		; spec says wait for 32ms*4
	call	Delay_100_mSec		; spec says wait for 32ms*4

	mov	bx,0400h		; Panel Timing Reg 1
	mov	eax, cs:(FP_FUNC PTR [si]).PT1
	cmp	eax, 0ffffffffh		; check for no flat panel
	je	No9211
	call	cx9211writeReg

	mov	bx, 0404h		; Panel Timing Reg 2
	mov	eax, cs:(FP_FUNC PTR [si]).PT2
	call	cx9211writeReg

	mov	bx, 040Ch		; Dither and Frame Rate Cntrl
	mov	eax, cs:(FP_FUNC PTR [si]).DFR
	call	cx9211writeReg
	
	mov	bx, 0410h		; Block Select 1
	mov	eax, cs:(FP_FUNC PTR [si]).BS1
	call	cx9211writeReg
	
	mov	bx, 0414h		; Block Select 2
	mov	eax, cs:(FP_FUNC PTR [si]).BS2
	call	cx9211writeReg
	
	mov	bx, 0430h
	call	cx9211readReg

	cmp	eax, 92110201h		;RevC
	jb	RevBload
	call	RevCFRMload
	jmp	RevCload

RevBload:
	mov	bx, 0418h		; Dispersion 1
	mov	eax, cs:(FP_FUNC PTR [si]).DISP1
	call	cx9211writeReg

	mov	bx, 041Ch		; Dispersion 2
	mov	eax, cs:(FP_FUNC PTR [si]).DISP2
	call	cx9211writeReg

RevCload:
	mov	bx, 0420h		; Memory Control
	mov	eax, cs:(FP_FUNC PTR [si]).MC
	call	cx9211writeReg

	mov	bx, 0408h		; Powermanagment - turn on flat panel
	mov	eax, cs:(FP_FUNC PTR [si]).PM
	call	cx9211writeReg
	call	Delay_100_mSec		; spec says wait for 32ms*4
	call	Delay_100_mSec		; spec says wait for 32ms*4

No9211:

	call	cx9211clearCS

	popf
	popad
	ret
cx92xxinit  ENDP


;**************************************************************************
;*
;*	Proc Name: cx9211gpioInit
;*
;*	Use: Initialize the GPIOs on the SCx2xx used for the 9211
;*
;*	Entry:
;*
;*	Exit:
;*
;*	Destroys: None
;*
;**************************************************************************
cx9211gpioInit PROC NEAR PUBLIC
	push	dx
	push	eax

	;set output enable on gpios
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_SEL
	mov	eax, CLOCK9211CFG
	out	dx, eax
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_CFG
	mov	eax, 3		;; sets GPIO to push-pull output
	out	dx, eax

	;set output enable on gpios
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_SEL
	mov	eax, CS9211CFG
	out	dx, eax
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_CFG
	mov	eax, 3		;; sets GPIO to push-pull output
	out	dx, eax

	;set output enable on gpios
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_SEL
	mov	eax, DATAIN9211CFG
	out	dx, eax
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_CFG
	mov	eax, 3		;; sets GPIO to push-pull output
	out	dx, eax

	;disable output on pin getting output from the 9211
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_SEL
	mov	eax, DATAOUT9211CFG
	out	dx, eax
	mov	dx, GEODE_GPIO_BASE + GEODE_GPPIN_CFG
	mov	eax, 0		;; sets GPIO to non-interrupting input
	out	dx, eax

	; Set all PINS low
	mov	dx, GEODE_GPIO_BASE + GEODE_GPDI0
	in	eax, dx
	and	eax, NOT CS9211
	and	eax, NOT CLOCK9211
	and	eax, NOT DATAIN9211
	mov	dx, GEODE_GPIO_BASE + GEODE_GPDO0
	out	dx, eax

	pop	eax
	pop	dx
	ret
cx9211gpioInit ENDP

;**************************************************************************
;*
;*	Proc Name: cx9211readReg
;*
;*	Use: Read an indexed register from Cx9211
;*
;*	Entry:  BX contains Register to Read
;*
;*	Exit:  EAX contains Data on Exit
;*
;*	Destroys: None
;*
;**************************************************************************
cx9211readReg PROC NEAR PUBLIC
	push	ebx
	push	edx
	push	ecx

	mov	ax, bx			; Command in AX with INDEX
	call	cx9211clearDataOut

	;
	; Assert SCS input
	;
	call	cx9211setCS
	call	cx9211toggleClock	; 1 clock

	;
	; write a 1 to sdin
	;
	call	cx9211setDataOut
	call	cx9211toggleClock	; 1 clock

	;
	; transmit address
	;
	mov	cx, 12			; 12 address bits to send
	cld				; Count down
readRegIndexSend:			; send the address
	mov	dl, al			; Put lower 8 bits into DL
	and	dl, 01h			; Mask off all but data bit 

	cmp	dl, 1			; Is it SET?
	jne	readRegIndexClr		; no Its CLEAR

readRegIndexSet:
	call	cx9211setDataOut
	jmp	readRegIndexClock

readRegIndexClr:
	call	cx9211clearDataOut

readRegIndexClock:
	call	cx9211toggleClock	; 1 clock

	ror	ax, 1			; Move to Next Bit
	loop	readRegIndexSend

readRegIndexIdle:
	call	cx9211clearDataOut	; read bit = 0
	call	cx9211toggleClock	; 1 clock

	;
	; Idle Clock , 7 clocks, no data set.
	;
	call	cx9211toggleClock	; 1 clock 1
	call	cx9211toggleClock	; 1 clock 2
	call	cx9211toggleClock	; 1 clock 3
	call	cx9211toggleClock	; 1 clock 4
	call	cx9211toggleClock	; 1 clock 5
	call	cx9211toggleClock	; 1 clock 6
	call	cx9211toggleClock	; 1 clock 7

	;
	; read 32 bits
	;
	xor	edx, edx
	mov	cx, 32			; 32 bits to read
	cld				; Count down
readRegData:
	call	cx9211toggleClock	; 1 clock
	call	cx9211ReadDataIn	; read data

	or	dl, al			; store in dl
	ror	edx, 1			; move data left one
	loop	readRegData

	;
	; deassert SCS and toggle clock
	;
	call	cx9211clearCS		; Clear CS
	call	cx9211toggleClock	; 1 clock

	mov	eax, edx		; eax contains value read
	pop	ecx
	pop	edx
	pop	ebx

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -