gpio.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:48k
- #include "user_init.h"
- #include "pu8560.h"
- #include "config.h"
- #include "regmap.h"
- #include "global.h"
- #include "epp.h"
- #include "gpio.h"
- #ifdef SUPPORT_CARD_STORAGE
- #include "cardfs.h"
- #endif
- //#define GPIO_DBG 1
- #ifdef EASTWIN
- #include "iop.h"
- #include "kernel.h" // Kevin Sep 20,04
- extern void show_level(int id,INT8 level,BYTE total_level);
- #if 1
- /* Default parameter table of AN2526H */
- unsigned char color_drv_data[16] = { 0x84,0x8b,0xbf,0x73,/* 0,1,2,3 */
- 0x47,0xca,0xad,0x7f,/* 4,5,6,7 */
- 0x5f,0x5f,0x85,0x7f,/* 8,9,10,11 */
- 0xe4,0x6e,0x3c,0xcc /* 12,13,14,15 */
- };
- #endif
- #if 0
- /* Default parameter table of AN2526H from Maple */
- unsigned char color_drv_data[16] = { 0x13,0x11,0xe0,0xdd,/* 0,1,2,3 */
- 0x8f,0xed,0xa5,0x80,/* 4,5,6,7 */
- 0x7f,0x73,0x80,0x80,/* 8,9,10,11 */
- 0xff,0x82,0x80,0xac /* 12,13,14,15 */
- };
- #endif
- #endif
- #ifdef SUPPORT_Auo_2inch_Digital_panel
- void init_auo_digital_panel(void);
- #endif
- #ifdef SUPPORT_Auo_UPS053_Digital_panel
- #if 0
- BYTE auo_053_ntsc[25]={ /*00*/0xE3, /*01*/0xE0, /*02*/0x96, /*03*/0x06,
- /*04*/0x00,/*05*/0x0E, /*06*/0x52, /*07*/0x02,
- /*08*/0x6A, /*09*/0x9C,/*0A*/0xB4, /*0B*/0x50,
- /*0C*/0xF7, /*0D*/0x80, /*0E*/0x20, /*0F*/0xC1,
- /*10*/0xCE, /*11*/0x07, /*12*/0x91, /*13*/0x01,
- /*14*/0x80, /*15*/0x00, /*16*/0x00, /*17*/0x00,
- /*18*/0x00
- };
- #endif
-
- BYTE auo_053_ntsc[25]={ /*00*/0xE2, /*01*/0x28, /*02*/0x96, /*03*/0x06,
- /*04*/0x00,/*05*/0x10, /*06*/0x52, /*07*/0x02,
- /*08*/0x6A, /*09*/0x9C,/*0A*/0xB4, /*0B*/0x50,
- /*0C*/0xF7, /*0D*/0x80, /*0E*/0x20, /*0F*/0xC1,
- /*10*/0xCE, /*11*/0x00, /*12*/0x91, /*13*/0x01,
- /*14*/0x30, /*15*/0x00, /*16*/0x00, /*17*/0x00,
- /*18*/0xc7
- };
-
-
- void init_auo_ups053_digital_panel(void);
- #endif
- //
- // FUNCTION
- // reset_gpio
- //
- // restore GPIO initial state
- //
- #ifdef PORTABLE_DVD
- #include "gpio_portable.c" //0725 splitted for portable
- #endif
- #if defined(PMP_DVD)
- extern void hwHddPowerOn(void);
- extern void Set_PMP_Key(void);
- void PMP_gpio_init()
- {
- regs0->sft_cfg0 &= ~(0x1 << 5); //set GPIO 38 ca8202 pin161
- GPIO_E_SET(PC_USB_CONNECT_PIN, 0); //pin161 is Pc Usb Vcc detect pin
- //pin61 set it to be high , let 8202 ide bus switch on
- regs0->sft_cfg4=regs0->sft_cfg4&(~(1<<0x04)); //pin61,GPIO 4
- GPIO_M_SET(IDE_BUS_SWITCH_CONTROL_PIN,1);
- GPIO_E_SET(IDE_BUS_SWITCH_CONTROL_PIN,1);
- GPIO_O_SET(IDE_BUS_SWITCH_CONTROL_PIN,1);
- //pin64
- GPIO_M_SET(USB_DEVICE_CHIP_POWER_PIN,1);
- GPIO_E_SET(USB_DEVICE_CHIP_POWER_PIN,1);
- #ifdef PMP_PCB_VER_B
- GPIO_O_SET(USB_DEVICE_CHIP_POWER_PIN,0);
- #else //PMP_PCB_VER_C
- GPIO_O_SET(USB_DEVICE_CHIP_POWER_PIN,1);
- hwHddPowerOn();
- #endif
- #ifdef PMP_KEYBOARD//xyy add 2005-1-13
- Set_PMP_Key();
- #endif
- }
- #endif //#if defined(PMP_DVD)
- void reset_gpio(void)
- {
-
- #ifdef IR_SWITCH_CD_USB_CF_OTHER //dingzhy use vfd data test bus switch 4-10-22 10:41
- GPIO_E_SET(23,1);
- #endif
-
- #ifdef AKI_2CH_KEY_SCAN //linrc add for AKI 2004-12-31 10:42
- GPIO_M_SET(22,1);
- GPIO_M_SET(23,1);
- GPIO_E_SET(22,1);
- GPIO_E_SET(23,1);
- GPIO_O_SET(22,1);
- GPIO_O_SET(23,1);
- #endif
-
- #ifdef NINTAUS_612_SCAN_KEY //linrc 2004-6-9 17:52
- regs0->sft_cfg1 &= ~(0x1 << 3);//PIN29 use as CARD_RESET gpio3
-
- GPIO_M_SET(3,1);
- GPIO_M_SET(4,1);
- GPIO_M_SET(54,1);//set used by RISC
- GPIO_M_SET(55,1);//set
- GPIO_M_SET(56,1);//set
- GPIO_E_SET(54,0);//set CLK as input
- GPIO_E_SET(55,0);//set STB as input
- GPIO_E_SET(56,1);//set STB as output
- GPIO_E_SET(3,1); //linrc modify 2004-6-7 19:30
- GPIO_E_SET(4,1);
- #endif //end NINTAUS_612_SCAN_KEY
-
- #if defined(HANYANG_SCAN_KEY)||defined(HJ2439_SCAN_KEY) //caoh 2004-4-19 12:00
- regs0->sft_cfg3 &= ~(0x1 << 5);//PIN163 use as SCART_RGB gpio57
- regs0->sft_cfg6 &= ~(0x1 << 5);//PIN151 use as SCART_SW gpio18
- GPIO_M_SET(54,1);
- GPIO_M_SET(55,1);
- GPIO_M_SET(56,1);
- GPIO_M_SET(57,1);
- GPIO_M_SET(18,1);
-
- GPIO_E_SET(57,1);
- GPIO_E_SET(18,1);
- GPIO_E_SET(55,1);
- #endif
- #ifdef DP3240_KEY_SCAN // add xrh
- #ifdef STBY_CONTROLLER_IO_61PIN_12GPIO
- GPIO_M_SET(12,1); //pin 61 gpio 12 s-by
- GPIO_E_SET(12,1); //pin 61 gpio 12 s-by
- GPIO_O_SET(12,1); //pin 61 gpio 12 s-by
- #endif
- GPIO_M_SET(PLAY_LED_1,1); // gpio 13 pin 62 led 2
- GPIO_E_SET(PLAY_LED_1,1); // gpio 13 pin 62 led 2
- GPIO_O_SET(PLAY_LED_1,1);
-
-
-
- GPIO_M_SET(POWER_LED_2,1); // gpio 14 pin 63 led 3
- GPIO_E_SET(POWER_LED_2,1); //gpio 14 pin 63 led 3
- GPIO_O_SET(POWER_LED_2,1);
-
- #endif
- #ifdef DP2030_SCAN_KEY //caoh 2004-4-19 12:00
- GPIO_M_SET(PANEL_LED_PLAY,1); //PANEL_LED1 pin82
- GPIO_E_SET(PANEL_LED_PLAY,1); //SETUP AS OUTPUT
- GPIO_O_SET(PANEL_LED_PLAY,1); //PLAY
-
- GPIO_M_SET(PANEL_LED_POWER,1); //PANEL_LED2 pin83
- GPIO_E_SET(PANEL_LED_POWER,1);
- GPIO_O_SET(PANEL_LED_POWER,1); //POWER
-
- GPIO_M_SET(23,1); //SCAN_KEY1 pin84
- GPIO_M_SET(93,1); //SCAN_KEY2 pin226
- GPIO_M_SET(94,1); //SCAN_KEY3 pin227
- GPIO_M_SET(97,1); //SCAN_KEY4 pin230
- GPIO_M_SET(98,1); //SCAN_KEY5 pin231
- GPIO_M_SET(100,1); //SCAN_KEY6 pin233
- GPIO_M_SET(99,1); //DOOR_SENSE_GPIO
-
-
- GPIO_E_SET(23,1); //KEY1
- GPIO_E_SET(93,1); //KEY2
- GPIO_E_SET(98,1); //KEY5
-
- GPIO_E_SET(99,0); //as input DOOR_SENSE_GPIO
- GPIO_E_SET(94,0); //KEY3
- GPIO_E_SET(97,0); //KEY4
- GPIO_E_SET(100,0); //KEY6
- //GPIO_O_SET(DOOR_SENSE_GPIO,1);
- #endif//#ifdef DP2030_SCAN_KEY
- #ifdef DP30H0_KEY_SCAN //add 2004-5-14 xia
- //wthsin
- regs0->sdc_data_cnt[6][0] |= (0x0c);//Disable ROM_A21(Pin226),ROM_A22(Pin227) as GPIO93,94
- GPIO_M_SET(21,1); //PANEL_LED1 pin82
- GPIO_M_SET(22,1); //PANEL_LED2 pin83
- GPIO_M_SET(23,1); //bit PIN 84
- regs0->sft_cfg1 &= ~(0x1 << 4); //gpio 94 intput
- regs0->sft_cfg1 &= ~(0x1 << 5); //gpio 97 output
- GPIO_M_SET(93,1); //SCAN_KEY1 pin226
- GPIO_M_SET(94,1); //SCAN_KEY2 pin227
- GPIO_M_SET(97,1); //SCAN_KEY3 pin230
- GPIO_M_SET(98,1); //SCAN_KEY4 pin231
- GPIO_M_SET(99,1); //SCAN_KEY5 pin232
- GPIO_M_SET(100,1); //SCAN_KEY6 pin233
- GPIO_E_SET(21,1); //SETUP AS OUTPUT
- GPIO_E_SET(22,1);
- GPIO_E_SET(23,1);
- GPIO_E_SET(97,1); //KEY3
- GPIO_E_SET(98,1); //KEY4
- GPIO_E_SET(99,1); //KEY5
- GPIO_E_SET(100,1); //KEY6
- GPIO_E_SET(93,0); //key1
- GPIO_E_SET(94,0); //key2
- GPIO_O_SET(PANEL_LED_POWER,1); //POWER
- GPIO_O_SET(PANEL_LED_PLAY,1); //PLAY
- GPIO_O_SET(PANEL_LED_CLOCK,0); //clock
- GPIO_O_SET(IR_LED,0);
- #endif//#ifdef DP30H0_KEY_SCAN
- //dingzhy 3-11-17 10:15
- #ifdef USE_VFD_GAME_PORT_TO_KEYBOARD_HJ_DP313
- regs0->sft_cfg6 &= ~(0x1 << 4); // A11 as GPIO14
- regs0->sft_cfg6 &= ~(0x1 << 6); // BA1 as GPIO15
- GPIO_M_SET(14,1);//1 risc use
- GPIO_M_SET(15,1);
- GPIO_M_SET(56,1);
- GPIO_M_SET(55,1);
- GPIO_M_SET(54,1);
- GPIO_E_SET(14,0);// 0 input
- GPIO_E_SET(15,0);
- GPIO_E_SET(56,0);
- GPIO_E_SET(55,0);
- GPIO_E_SET(54,0);
-
-
- regs0->sft_cfg1 &= ~(0x1 << 3);//GPIO3 pin29 use as MP3 LIGHT
- regs0->sft_cfg3 &= ~(0x3 << 14);//GPIO62 63 pin175 176 use as DVD CD LIGHT
- regs0->sft_cfg2 &= ~(0x7 << 2);//GPIO62 63 pin175 176 use as DVD CD LIGHT
- GPIO_M_SET(3,1);//1 risc use
- GPIO_M_SET(62,1);
- GPIO_M_SET(63,1);
- GPIO_E_SET(3,1);// 1 output
- GPIO_E_SET(62,1);
- GPIO_E_SET(63,1);
-
- GPIO_O_SET(3,1);
- GPIO_O_SET(62,1);
- GPIO_O_SET(63,1);
-
- #endif
-
- #ifndef ROM_ATA_SHARE_BUS
- regs0->sft_cfg1 &= ~(0x3 << 1);
- #else
- #ifdef SUPPORT_CARD_STORAGE
- regs0->sft_cfg1 |= (0x7 << 0);
- regs0->sft_cfg1 &= ~(0x1 << 3);
- #endif
- #endif
- #ifdef PORTABLE_DVD //Jack added for all PDVD customers
- portable_reset_gpio(); //0725 splitted for portable
- #endif
- #ifdef SUPPORT_RECEIVER // benosn add extrenal AD interface PIN 130,131,133
- #ifdef SUPPORT_EXT_ADC
- regs0->sft_cfg0 &= ~((0x0fffc)<<1);
- regs0->gpio_master[2]|= 0x01b0; //GPIO 37~47
- //regs0->gpio_oe[2]|= 0xe980;
- regs0->gpio_oe[2]&= ~(0x01b0);
- //regs0->gpio_out[2]|= 0x0900;
- //regs0->gpio_out[2]&= ~(0xe080);
- regs0->sft_cfg3 &= 0xfff8;
- regs0->sft_cfg3 |= 0x0004;
- #endif
- /*
- #ifdef SUPPORT_8202_EXT_ADC // benson add 2004.08.18 pin 69,71,72
- regs0->sft_cfg3 &= 0xf3ff;
- regs0->sft_cfg3 |= 0x0400;
- #endif
- */
- #ifdef SUPPORT_8202_EXT_ADC // benson add 2004.08.23 pin 169,171,172
- regs0->sft_cfg3 &= 0xf3ff;
- regs0->sft_cfg3 |= 0x0800;
- #endif
- #endif
- #if defined(SUPPORT_USB)&&defined(HOST_SL811HS) //wthsin, 2004/1/12 01:36pm
- regs0->sft_cfg1 |= (0x7 << 0);
- #endif
- /*a block is removed. huziqin 2004-2-26*/
-
- #ifdef PCM1742 //Jeff 20030917
- regs0->sft_cfg1 |= (0x7 << 0);
- regs0->sft_cfg1 &= ~(0x1 << 3);
- #endif
- #if defined(PCM1742)&&defined(CHECK_DAC_ZERO_FLAG_TO_GPIO_MUTE) //gerry,3-10-20 11:36
- regs0->sft_cfg6 &= ~(0x1 << 4); // SA11 as GPIO 14, pin 109
- GPIO_M_SET(14,1);//GPIO_M_SET(35,1);
- GPIO_E_SET(14,0);//GPIO_E_SET(35,0);
- #endif
- #ifdef USE_CD_SENSE_PIN_AS_LED_GPIO //gerry,2004-2-10 18:33
- GPIO_M_SET(4,1);
- GPIO_E_SET(4,1);
- GPIO_O_SET(4,0);
- #endif//USE_CD_SENSE_PIN_AS_LED_GPIO
- #ifdef USE_PIN31_CONTROL_POWER_LED //gerry,normal led is high on,2004/2/11 05:31