gonzui


Format: Advanced Search

tkernel_2/monitor/hwdepend/tef_em1d/src/config.cbare sourcepermlink (0.05 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by T-Engine Forum at 2011/09/08.
   11:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   12:  *
   13:  *----------------------------------------------------------------------
   14:  */
   15: 
   16: /*
   17:  *      config.c
   18:  *
   19:  *       system-related processing / system configuration information
   20:  *
   21:  *       target: T-Engine/EM1D-512
   22:  */
   23: 
   24: #include "sysdepend.h"
   25: #include <arm/em1d512.h>
   26: 
   27: /* used device driver */
   28: IMPORT  ER       initSIO_ns16550(SIOCB *, const CFGSIO *, W speed);
   29: IMPORT  ER       initMemDisk(DISKCB *, const CFGDISK *);
   30: 
   31: /* memory region definition */
   32: EXPORT  MEMSEG   MemSeg[] = {
   33:         // Bank1/2/3
   34:         {0x10000000, 0x30000000, MSA_IO,       PGA_RW|PGA_D |PGA_S|PGA_XN},
   35:         // DDR2 SDRAM, 64Mbyte
   36:         {0x30000000, 0x40000000, MSA_RAM,      PGA_RW|PGA_C},
   37:         // EM1 internal device (1)
   38:         {0x40000000, 0x70000000, MSA_IO,       PGA_RW|PGA_D |PGA_S|PGA_XN},
   39:         // Bank0
   40:         {0x70000000, 0x72000000, MSA_FROM,     PGA_RO|PGA_C |0x90000000},
   41:         // EM1 internal SRAM
   42:         {0xa0000000, 0xb0000000, MSA_SRAM,     PGA_RW|PGA_NC},
   43:         // EM1 internal device (2)
   44:         {0xb0000000, 0xd0000000, MSA_IO,       PGA_RW|PGA_D |PGA_S|PGA_XN},
   45:         // EM1 internal Boot ROM
   46:         {0xf0000000, 0xffffffff, MSA_ROM,      PGA_RO|PGA_NC},
   47: 
   48:         {0x70000000, 0x70020000, MSA_MON,      0},
   49:         {0x70030000, 0x72000000, MSA_RDA,      0},
   50:         {0x30006000, 0x34000000, MSA_OS,       0},
   51: };
   52: 
   53: EXPORT  W        N_MemSeg = sizeof(MemSeg) / sizeof(MEMSEG);
   54: 
   55: /* unused memory region definition */
   56: EXPORT  MEMSEG   NoMemSeg[] = {
   57:         {0x00000000, 0x10000000, 0,            0},
   58:         {0x72000000, 0xa0000000, 0,            0},
   59:         {0xd0000000, 0xf0000000, 0,            0},
   60: };
   61: 
   62: EXPORT  W        N_NoMemSeg = sizeof(NoMemSeg) / sizeof(MEMSEG);
   63: 
   64: /*
   65:  * serial port configuration definition
   66:  *       list in the order of port number
   67:  */
   68: EXPORT  const    CFGSIO     ConfigSIO[] = {
   69:         {initSIO_ns16550, 0},
   70: };
   71: 
   72: EXPORT  const W  N_ConfigSIO = sizeof(ConfigSIO) / sizeof(CFGSIO);
   73: 
   74: 
   75: /*
   76:  * disk drive configuration definition
   77:  *      list in the order of port number
   78:  */
   79: EXPORT  const CFGDISK    ConfigDisk[] = {
   80:         {"rda",        DA_RONLY,      initMemDisk, 0},     // FlashROM
   81: };
   82: 
   83: EXPORT  const W  N_ConfigDisk = sizeof(ConfigDisk) / sizeof(CFGDISK);
   84: 
   85: /* boot information */
   86: EXPORT  const UH BootSignature = 0xe382;         // signature
   87: EXPORT  UB *     const PBootAddr = (UB *)0x30200000; // primary boot loader address
   88:  
   89: /* ------------------------------------------------------------------------ */
   90: 
   91: #define IICC_IICE       (1 << 7)
   92: #define IICC_WREL       (1 << 5)
   93: #define IICC_WTIM       (1 << 3)
   94: #define IICC_ACKE       (1 << 2)
   95: #define IICC_STT        (1 << 1)
   96: #define IICC_SPT        (1 << 0)
   97: 
   98: #define IICCL_SMC       (1 << 3)
   99: #define IICCL_DFC       (1 << 2)
  100: 
  101: #define IICSE_MSTS      (1 << 15)
  102: #define IICSE_ALD       (1 << 14)
  103: #define IICSE_ACKD      (1 << 10)
  104: #define IICSE_SPD       (1 << 8)
  105: 
  106: #define IICF_IICBSY     (1 << 6)
  107: #define IICF_STCEN      (1 << 1)
  108: #define IICF_IICRSV     (1 << 0)
  109: 
  110: #define IIC_TOPDATA     (1 << 11)
  111: #define IIC_LASTDATA    (1 << 10)
  112: 
  113: #define TIMEOUT         1000000        // microsec
  114: 
  115: #define IIC2_IRQ        39
  116: #define IRQbit(x)       (1 << ((x) % 32))
  117: 
  118: /* wait for register state information */
  119: LOCAL   ER        wait_state(UW addr, UW mask, UW value)
  120: {
  121:         W      i;
  122: 
  123:         for (i = TIMEOUT; i > 0; i--) {
  124:                 waitUsec(1);
  125:                 if ((in_w(addr) & mask) == value) break;
  126:         }
  127: 
  128:         return i ? E_OK : E_TMOUT;
  129: }
  130: 
  131: /* interrupt Raw status / clear */
  132: LOCAL   void      clear_int(void)
  133: {
  134:         out_w(IT0_IIR, IRQbit(IIC2_IRQ));      // IRQ39 clear
  135:         return;
  136: }
  137: 
  138: /* interrupt Raw status / useable */
  139: LOCAL   void      setup_int(void)
  140: {
  141:         out_w(IT_PINV_CLR1, IRQbit(IIC2_IRQ));
  142:         out_w(IT0_IENS1, IRQbit(IIC2_IRQ));
  143:         clear_int();
  144:         return;
  145: }
  146: 
  147: /* wait for interrupt Raw status */
  148: LOCAL   ER        wait_int(void)
  149: {
  150:         ER     er;
  151: 
  152:         er = wait_state(IT0_RAW1, IRQbit(IIC2_IRQ), IRQbit(IIC2_IRQ));
  153:         clear_int();
  154: 
  155:         return er;
  156: }
  157: 
  158: /* start / restart */
  159: LOCAL   ER        send_start(UB addr)
  160: {
  161:         ER     er;
  162:         UW     sts;
  163: 
  164:         /* generate start condition */
  165:         out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) & ~IICC_ACKE);
  166:         out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) |  IICC_STT);
  167: 
  168:         /* wait for reserving a master */
  169:         er = wait_state(IIC_IICSE(IIC2), IICSE_MSTS, IICSE_MSTS);
  170:         if (er < E_OK) goto fin0;
  171: 
  172:         /* slave address / communication mode transmission */
  173:         out_w(IIC_IIC(IIC2), addr);
  174:         er = wait_int();
  175:         if (er < E_OK) goto fin0;
  176: 
  177:         /* error check */
  178:         sts = in_w(IIC_IICSE(IIC2));
  179:         if ((sts & IICSE_ALD) || !(sts & IICSE_ACKD)) {
  180:                 er = E_IO;
  181:                 goto fin0;
  182:         }
  183: 
  184:         er = E_OK;
  185: fin0:
  186:         return er;
  187: }
  188: 
  189: /* stop */
  190: LOCAL   ER        send_stop(void)
  191: {
  192:         ER     er;
  193: 
  194:         /* generate stop condition */
  195:         out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) | IICC_SPT);
  196: 
  197:         /* wait for sending STOP bit(s) */
  198:         er = wait_state(IIC_IICSE(IIC2), IICSE_SPD, IICSE_SPD);
  199: 
  200:         return er;
  201: }
  202: 
  203: /* data transmission */
  204: LOCAL   ER        send_data(UB data)
  205: {
  206:         ER     er;
  207:         UW     sts;
  208: 
  209:         /* data transmission */
  210:         out_w(IIC_IIC(IIC2), data);
  211:         er = wait_int();
  212:         if (er < E_OK) goto fin0;
  213: 
  214:         /* NAK check */
  215:         sts = in_w(IIC_IICSE(IIC2));
  216:         if (!(sts & IICSE_ACKD)) {
  217:                 er = E_IO;
  218:                 goto fin0;
  219:         }
  220: 
  221:         er = E_OK;
  222: fin0:
  223:         return er;
  224: }
  225: 
  226: /* data receive */
  227: LOCAL   W recv_data(W attr)
  228: {
  229:         W      er;
  230: 
  231:         /* when the first data is received, switch to receive mode */
  232:         if (attr & IIC_TOPDATA) {
  233:                 out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) & ~IICC_WTIM);
  234:                 out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) |  IICC_ACKE);
  235:         }
  236: 
  237:         /* instruct the reception of data */
  238:         out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) | IICC_WREL);
  239:         er = wait_int();
  240:         if (er < E_OK) goto fin0;
  241: 
  242:         /* read data */
  243:         er = in_w(IIC_IIC(IIC2)) & 0xff;
  244: fin0:
  245:         /* when an error occurs, or the last byte is seen, then perform the post processing */
  246:         if ((attr & IIC_LASTDATA) || er < E_OK) {
  247:                 out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) |  IICC_WTIM);
  248:                 out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) & ~IICC_ACKE);
  249:                 out_w(IIC_IICC(IIC2), in_w(IIC_IICC(IIC2)) | IICC_WREL);
  250:                 wait_int();
  251:         }
  252: 
  253:         return er;
  254: }
  255: 
  256: /* start IIC send/receive */
  257: LOCAL   ER        iic_start(void)
  258: {
  259:         ER     er;
  260: 
  261:         /* initialization default */
  262:         out_w(IIC_IICC(IIC2), 0);                      // stop completely
  263:         out_w(IIC_IICCL(IIC2), IICCL_SMC | IICCL_DFC); // fast mode + filter
  264:         out_w(IIC_IICF(IIC2), IICF_STCEN | IICF_IICRSV);// forcibly start transmission
  265:         out_w(IIC_IICC(IIC2), IICC_IICE | IICC_WTIM);  // IIC mode, 9bit mode
  266:         clear_int();
  267: 
  268:         /* wait for bus to become available (since there is only one master, the bus is supposed to be unoccupied) */
  269:         er = wait_state(IIC_IICF(IIC2), IICF_IICBSY, 0);
  270: 
  271:         return er;
  272: }
  273: 
  274: /* stop IIC send/receive */
  275: LOCAL   void      iic_finish(void)
  276: {
  277:         out_w(IIC_IICC(IIC2), 0);      // stop completely
  278:         return;
  279: }
  280: 
  281: /* read IIC-GPIO */
  282: LOCAL   W IICGPIORead(W addr)
  283: {
  284:         W      dat;
  285: 
  286:         setup_int();
  287: 
  288:         iic_start();
  289:         send_start(addr);
  290:         dat = recv_data(IIC_TOPDATA | IIC_LASTDATA);
  291:         send_stop();
  292:         iic_finish();
  293: 
  294:         clear_int();
  295: 
  296:         return dat;
  297: }
  298: 
  299: /* IIC-GPIO write */
  300: LOCAL   void      IICGPIOWrite(W addr, W dat)
  301: {
  302:         setup_int();
  303: 
  304:         iic_start();
  305:         send_start(addr);
  306:         send_data(dat);
  307:         send_stop();
  308:         iic_finish();
  309: 
  310:         clear_int();
  311: 
  312:         return;
  313: }
  314: 
  315: /* ------------------------------------------------------------------------ */
  316: 
  317: IMPORT  W        pmicRead(W reg);
  318: IMPORT  W        pmicWrite(W reg, W dat);
  319: #define pmicDelay(x)    waitUsec(4)        // about 16msec
  320: #define USBPowerOn      0xe0         // GPIO13(OD), High * power is supplied to A connector only
  321: #define USBPowerOff     0xe0                // GPIO13(OD), High
  322: 
  323: /* obtain DipSw status */
  324: EXPORT  UW       DipSwStatus(void)
  325: {
  326:         UW     d;
  327: 
  328:         /* read data from read port */
  329:         d = IICGPIORead(0xd9);
  330: 
  331:         /* unnecessary bits are masked and then invert logic. */
  332:         d = (d ^ SW_MON) & SW_MON;
  333: 
  334:         /* check abort switch */
  335:         if (in_w(GIO_I(GIO_L)) & 0x00000100) d |= SW_ABT;
  336: 
  337:         return d;
  338: }
  339: 
  340: /* USB power control */
  341: EXPORT  void     usbPower(BOOL power)
  342: {
  343:         pmicWrite(27, (pmicRead(27) & 0x0f) |
  344:                               (power ? USBPowerOn : USBPowerOff));
  345:         pmicDelay();
  346: }
  347: 
  348: /* power off */
  349: EXPORT  void     powerOff(void)
  350: {
  351:         W      i;
  352: 
  353:         for (i = 10; i < 14; i++) pmicWrite(i, 0xff);  // IRQ_MASK_A-D (mask)
  354:         pmicDelay();
  355: 
  356:         for (i = 5 ; i < 9; i++) pmicWrite(i, 0xff);   // EVENT_A-D (clear)
  357:         pmicDelay();
  358: 
  359:         while (1) {
  360:                 pmicWrite(15, 0x60);  // DEEP_SLEEP
  361:                 pmicDelay();
  362:         }
  363: }
  364: 
  365: /* reset start*/
  366: EXPORT  void     resetStart(void)
  367: {
  368:         while (1) {
  369:                 /* reset */
  370:                 pmicWrite(15, 0xac);          // SHUTDOWN
  371:                 pmicDelay();
  372:         }
  373: }
  374: 
  375: /* initialize hardware peripherals (executed only during reset) */
  376: EXPORT  void     initHardware(void)
  377: {
  378:         /* enable abort switch interrupt */
  379:         out_w(GIO_IDT1(GIO_L), 0x00000008);    // asynchronous leading-edge high interrupt
  380:         out_w(GIO_IIR(GIO_L), 0x00000100);
  381:         out_w(GIO_IIA(GIO_L), 0x00000100);
  382:         out_w(GIO_IEN(GIO_L), 0x00000100);
  383: 
  384:         return;
  385: }
  386: 
  387: /* LED on/off */
  388: EXPORT  void     cpuLED(UW v)
  389: {
  390:         UB     m, d, r, c;
  391: 
  392:         m = ~((v >> 16) | 0xf0);       // mask (0:unmodified 1:modify)
  393:         d = ~((v >>  0) | 0xf0);       // set value (0:on 1:off)
  394:         r = IICGPIORead(0xb9);
  395:         c = (r ^ d) & m;               // modify flag (0:unmodified 1:modify)
  396:         IICGPIOWrite(0xb8, r ^ c);
  397: }
  398: 
  399: /*
  400:  * machine-dependent interrupt processing
  401:  *       vec     interrupt vector number
  402:  *       return value    0: unsupported target
  403:  *               1: for the supported target, processing was performed. (monitor still continues)
  404:  *               2: for the supported target, proceesing was performed (interrupt handler is exited)
  405:  */
  406: EXPORT  W        procHwInt(UW vec)
  407: {
  408:         /* only abort switch (GPIO(P8)) is supported */
  409:         if (vec != EIT_GPIO(8)) return 0;
  410: 
  411:         /* clear interrupt */
  412:         out_w(GIO_IIR(GIO_L), 0x00000100);
  413: 
  414:         DSP_S("Abort Switch (SW1) Pressed");
  415:         return 1;
  416: }
  417: 
  418: /* ------------------------------------------------------------------------ */
  419: 
  420: /*
  421:         configure GPIO pin multiplexer
  422: 
  423:                 * : used functions
  424:         
  425:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  426:         GIO_P0      GIO_P0*
  427:         GIO_P1      GIO_P1*       USB_WAKEUP    USB_PWR_FAULT
  428:         GIO_P2      GIO_P2*
  429:         GIO_P3      GIO_P3*
  430:         GIO_P4      GIO_P4*                     NAND_RB1
  431:         GIO_P5      GIO_P5                      NAND_RB2      CAM_SCLK*
  432:         GIO_P6      GIO_P6*                     NAND_RB3
  433:         GIO_P7      GIO_P7*                     NAND_CE0
  434:         GIO_P8      GIO_P8*                     NAND_CE1
  435:         GIO_P9      GIO_P9*                     NAND_CE2
  436:         GIO_P10     GIO_P10*                    NAND_CE3
  437:         AB0_CLK     GIO_P11       AB0_CLK*      NTS_CLK
  438:         AB0_AD0     GIO_P12       AB0_AD0*
  439:         AB0_AD1     GIO_P13       AB0_AD1*
  440:         AB0_AD2     GIO_P14       AB0_AD2*
  441:         AB0_AD3     GIO_P15       AB0_AD3*
  442:         
  443:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  444:         AB0_AD4     GIO_P16       AB0_AD4*
  445:         AB0_AD5     GIO_P17       AB0_AD5*
  446:         AB0_AD6     GIO_P18       AB0_AD6*
  447:         AB0_AD7     GIO_P19       AB0_AD7*
  448:         AB0_AD8     GIO_P20       AB0_AD8*
  449:         AB0_AD9     GIO_P21       AB0_AD9*
  450:         AB0_AD10    GIO_P22       AB0_AD10*
  451:         AB0_AD11    GIO_P23       AB0_AD11*
  452:         AB0_AD12    GIO_P24       AB0_AD12*
  453:         AB0_AD13    GIO_P25       AB0_AD13*
  454:         AB0_AD14    GIO_P26       AB0_AD14*
  455:         AB0_AD15    GIO_P27       AB0_AD15*
  456:         AB0_A17     GIO_P28       AB0_A17*
  457:         AB0_A18     GIO_P29       AB0_A18*
  458:         AB0_A19     GIO_P30       AB0_A19*
  459:         AB0_A20     GIO_P31       AB0_A20*
  460:         
  461:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  462:         AB0_A21     GIO_P32       AB0_A21*
  463:         AB0_A22     GIO_P33       AB0_A22*
  464:         AB0_A23     GIO_P34       AB0_A23*
  465:         AB0_A24     GIO_P35       AB0_A24*
  466:         AB0_A25     GIO_P36*      AB0_A25
  467:         AB0_A26     GIO_P37*      AB0_A26
  468:         AB0_ADV     GIO_P38       AB0_ADV*
  469:         AB0_RDB     GIO_P39       AB0_RDB*      NTS_DATA3
  470:         AB0_WRB     GIO_P40       AB0_WRB*      NTS_DATA4
  471:         AB0_WAIT    GIO_P41       AB0_WAIT*     NTS_DATA5
  472:         AB0_CSB0    GIO_P42       AB0_CSB0*     NTS_DATA6
  473:         AB0_CSB1    GIO_P43       AB0_CSB1*     NTS_DATA7
  474:         AB0_CSB2    GIO_P44*      AB0_CSB2      NTS_VS
  475:         AB0_CSB3    GIO_P45       AB0_CSB3*     NTS_HS
  476:         AB0_BEN0    GIO_P46       AB0_BEN0*
  477:         AB0_BEN1    GIO_P47       AB0_BEN1*
  478:         
  479:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  480:         SP0_CS1     GIO_P48       SP0_CS1*
  481:         SP0_CS2     GIO_P49       SP0_CS2*
  482:         LCD_PXCLK   GIO_P50       LCD_PXCLK*
  483:         LCD_R0      GIO_P51       LCD_R0*
  484:         LCD_R1      GIO_P52       LCD_R1*
  485:         LCD_R2      GIO_P53       LCD_R2*
  486:         LCD_R3      GIO_P54       LCD_R3*
  487:         LCD_R4      GIO_P55       LCD_R4*
  488:         LCD_R5      GIO_P56       LCD_R5*
  489:         LCD_G0      GIO_P57       LCD_G0*
  490:         LCD_G1      GIO_P58       LCD_G1*
  491:         LCD_G2      GIO_P59       LCD_G2*
  492:         LCD_G3      GIO_P60       LCD_G3*
  493:         LCD_G4      GIO_P61       LCD_G4*
  494:         LCD_G5      GIO_P62       LCD_G5*
  495:         LCD_B0      GIO_P63       LCD_B0*
  496:         
  497:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  498:         LCD_B1      GIO_P64       LCD_B1*
  499:         LCD_B2      GIO_P65       LCD_B2*
  500:         LCD_B3      GIO_P66       LCD_B3*
  501:         LCD_B4      GIO_P67       LCD_B4*
  502:         LCD_B5      GIO_P68       LCD_B5*
  503:         LCD_HSYNC   GIO_P69       LCD_HSYNC*
  504:         LCD_VSYNC   GIO_P70       LCD_VSYNC*
  505:         LCD_ENABLE  GIO_P71       LCD_ENABLE*
  506:         NTS_CLK     GIO_P72*      NTS_CLK                     PM1_CLK
  507:         NTS_VS      GIO_P73*      NTS_VS        SP1_CLK
  508:         NTS_HS      GIO_P74*      NTS_HS        SP1_SI
  509:         NTS_DATA0   GIO_P75       NTS_DATA0     SP1_SO        CAM_YUV0*
  510:         NTS_DATA1   GIO_P76       NTS_DATA1     SP1_CS0       CAM_YUV1*
  511:         NTS_DATA2   GIO_P77       NTS_DATA2     SP1_CS1       CAM_YUV2*
  512:         NTS_DATA3   GIO_P78       NTS_DATA3     SP1_CS2       CAM_YUV3*
  513:         NTS_DATA4   GIO_P79       NTS_DATA4     SP1_CS3       CAM_YUV4*
  514:         
  515:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  516:         NTS_DATA5   GIO_P80*      NTS_DATA5     SP1_CS4       PM1_SEN
  517:         NTS_DATA6   GIO_P81*      NTS_DATA6     SP1_CS5       PM1_SI
  518:         NTS_DATA7   GIO_P82*      NTS_DATA7                   PM1_SO
  519:         IIC_SCL     GIO_P83       IIC_SCL*
  520:         IIC_SDA     GIO_P84       IIC_SDA*
  521:         URT0_CTSB   GIO_P85       URT0_CTSB     URT1_SRIN*
  522:         URT0_RTSB   GIO_P86       URT0_RTSB     URT1_SOUT*
  523:         PM0_SI      GIO_P87       PM0_SI*
  524:         SD0_DATA1   GIO_P88       SD0_DATA1*
  525:         SD0_DATA2   GIO_P89       SD0_DATA2*
  526:         SD0_DATA3   GIO_P90       SD0_DATA3*
  527:         SD0_CKI     GIO_P91       SD0_CKI*
  528:         SD1_CKI     GIO_P92       SD1_CKI       CAM_CLKI*
  529:         SD2_CKI     GIO_P93       SD2_CKI*      NAND_OE
  530:         PWM0        GIO_P94*      PWM0
  531:         PWM1        GIO_P95*      PWM1
  532:         
  533:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  534:         USB_CLK     GIO_P96       USB_CLK*
  535:         USB_DATA0   GIO_P97       USB_DATA0*
  536:         USB_DATA1   GIO_P98       USB_DATA1*
  537:         USB_DATA2   GIO_P99       USB_DATA2*
  538:         USB_DATA3   GIO_P100      USB_DATA3*
  539:         USB_DATA4   GIO_P101      USB_DATA4*
  540:         USB_DATA5   GIO_P102      USB_DATA5*
  541:         USB_DATA6   GIO_P103      USB_DATA6*
  542:         USB_DATA7   GIO_P104      USB_DATA7*
  543:         USB_DIR     GIO_P105      USB_DIR*
  544:         USB_STP     GIO_P106      USB_STP*
  545:         USB_NXT     GIO_P107      USB_NXT*
  546:         URT2_SRIN   GIO_P108      URT2_SRIN*
  547:         URT2_SOUT   GIO_P109      URT2_SOUT*
  548:         URT2_CTSB   GIO_P110      URT2_CTSB*
  549:         URT2_RTSB   GIO_P111      URT2_RTSB*
  550:         
  551:         pin name      function 0(00)     function1(01)     function2(10)     function3(11)
  552:         SD2_CKO     GIO_P112      SD2_CKO*       NAND_D2
  553:         SD2_CMD     GIO_P113      SD2_CMD*       NAND_D3
  554:         SD2_DATA0   GIO_P114      SD2_DATA0*     NAND_D4
  555:         SD2_DATA1   GIO_P115      SD2_DATA1*     NAND_D5
  556:         SD2_DATA2   GIO_P116      SD2_DATA2*     NAND_D6
  557:         SD2_DATA3   GIO_P117      SD2_DATA3*     NAND_D7
  558: */
  559: EXPORT  const UW GPIOConfig[] __attribute__((section(".startup"))) = {
  560:         CHG_PINSEL_G(0),
  561:         0x55400C00,            // AB0_CLK,AB0_AD3-0,CAM_SCLK
  562:         CHG_PINSEL_G(16),
  563:         0x55555555,            // AB0_AD15-4,AB0_A20-17
  564:         CHG_PINSEL_G(32),
  565:         0x54555055,            // AB0_BEN1-0,AB0_CSB3,AB0_CSB1-0,
  566:                                 // AB0_WAIT,AB0_WRB,AB0_RDB,AB0_ADV,
  567:                                 // AB0_A24-21
  568: 
  569:         CHG_CTRL_AB0_BOOT,     // AB0(AsyncBus0) pin:
  570:         0x00000001,            //        configured by PINSEL
  571: 
  572:         CHG_PINSEL_G(48),
  573:         0x55555555,            // LCD,SP0_CS2-1
  574:         CHG_PINSEL_G(64),
  575:         0xffc05555,            // CAM_YUV4-0,LCD
  576:         CHG_PINSEL_G(80),
  577:         0x06556940,            // SD2_CKI,CAM_CLKI,SD0_CKI,SD0_DATA3-1,
  578:                                 // PM0,URT1,IIC
  579:         CHG_PINSEL_G(96),
  580:         0x55555555,            // URT2,USB
  581:         CHG_PINSEL_G(112),
  582:         0x00000555,            // SD2
  583:         CHG_PINSEL_SP0,
  584:         0x00000000,
  585:         CHG_PINSEL_DTV,
  586:         0x00000001,
  587:         CHG_PINSEL_SD0,
  588:         0x00000000,
  589:         CHG_PINSEL_SD1,
  590:         0x00000002,
  591:         CHG_PINSEL_IIC2,
  592:         0x00000000,
  593:         CHG_PULL_G(0),
  594:         0x55055005,            // P7,P6,P4,P3,P0: IN, pull-up/down dis
  595:         CHG_PULL_G(8),
  596:         0x00000005,            // P8: IN, pull-up/down dis
  597:         CHG_PULL_G(16),
  598:         0x00000000,            // (default)
  599:         CHG_PULL_G(24),
  600:         0x00000000,            // (default)
  601:         CHG_PULL_G(32),
  602:         0x00550000,            // P37,36: IN, pull-up/down dis
  603:         CHG_PULL_G(40),
  604:         0x00050000,            // P44: IN, pull-up/down dis
  605:         CHG_PULL_G(48),
  606:         0x11111111,            // (default)
  607:         CHG_PULL_G(56),
  608:         0x11111111,            // (default)
  609:         CHG_PULL_G(64),
  610:         0x11111111,            // (default)
  611:         CHG_PULL_G(72),
  612:         0x00000005,            // P72: IN, pull-up/down dis
  613:         CHG_PULL_G(80),
  614:         0x00400050,            // P81: IN, pull-up/down dis
  615:                                 // URT1_SRIN: IN, pull-down
  616:         CHG_PULL_G(88),
  617:         0x55000444,            // P95,94: IN, pull-up/down dis
  618:                                 // SD0_DATA3-1: IN, pull-down
  619:         CHG_PULL_G(96),
  620:         0x44444444,            // USB signals: IN, pull-down
  621:         CHG_PULL_G(104),
  622:         0x04044444,            // USB signals: IN, pull-down
  623:                                 // URT2_CTSB,URT2_SRIN: IN, pull-down
  624:         CHG_PULL_G(112),
  625:         0x00000000,            // (default)
  626:         CHG_PULL_G(120),
  627:         0x00000000,            // (default)
  628: 
  629:         CHG_PULL(0),
  630:         0x50000004,            // URT0_SRIN: IN, pull-up/down dis
  631:                                 // DEBUG_EN: IN, pull-down
  632:         CHG_PULL(1),
  633:         0x15110600,            // SP0_SO: OUT, pull-up/down dis
  634:                                 // SP0_SI: IN, pull-up/down dis
  635:                                 // SP0_CS: OUT, pull-up/down dis
  636:                                 // SP0_CK: OUT, pull-up/down dis
  637:                                 // JT0C: IN, pull-up
  638:                                 // JT0B: OUT, pull-down
  639:                                 // JT0A: OUT, pull-down
  640:         CHG_PULL(2),
  641:         0x60000661,            // PM0_SEN: IN, pull-up
  642:                                 // SD0_DAT: IN, pull-up
  643:                                 // SD1_CMD: IN, pull-up
  644:                                 // SD0_CLK: OUT, pull-up/down dis
  645:         CHG_PULL(3),
  646:         0x00000000,            // (default)
  647: 
  648:         GIO_E0(GIO_L),
  649:         0x000001d9,            // P8,P7,P6,P4,P3,P0: IN
  650:         GIO_E1(GIO_L),
  651:         0x00000604,            // P10,P9,P2: OUT
  652:         GIO_E0(GIO_H),
  653:         0x00001030,            // P44,P37,P36: IN
  654:         GIO_E1(GIO_H),
  655:         0x00000000,            // (default)
  656:         GIO_E0(GIO_HH),
  657:         0xc0020100,            // P95,P94,P81,P72:IN
  658:         GIO_E1(GIO_HH),
  659:         0x00040200,            // P82,P73: OUT
  660:         GIO_OL(GIO_L),
  661:         0x06040000,            // P10,P9,P2=0
  662:         GIO_OL(GIO_HH),
  663:         0x02000000,            // P73=0
  664:         GIO_OH(GIO_HH),
  665:         0x00040000,            // P82=0
  666: 
  667:         0x00000000,            // (terminate)
  668:         0x00000000,
  669: };