diff --git a/Targets/Bonito2g690e/Bonito/i2c.S b/Targets/Bonito2g690e/Bonito/i2c.S index 09a6b768..ee57a163 100644 --- a/Targets/Bonito2g690e/Bonito/i2c.S +++ b/Targets/Bonito2g690e/Bonito/i2c.S @@ -1,25 +1,27 @@ +#define BONITO_HTIO_BASE_VA 0x90000cfdfc000000 + LEAF(i2cread) addu a0,a0,1 /* set device address */ //li v0, 0xbfd00000 + SMBUS_HOST_ADDRESS - li v0, BONITO_PCIIO_BASE_VA + SMBUS_HOST_ADDRESS + dli v0, BONITO_HTIO_BASE_VA + SMBUS_HOST_ADDRESS sb a0, 0(v0); /* store register offset */ //li v0, 0xbfd00000 + SMBUS_HOST_COMMAND - li v0, BONITO_PCIIO_BASE_VA + SMBUS_HOST_COMMAND + dli v0, BONITO_HTIO_BASE_VA + SMBUS_HOST_COMMAND sb a1, 0(v0); /* read byte data protocol */ li v0, 0x08 //li v1, 0xbfd00000 + SMBUS_HOST_CONTROL - li v1, BONITO_PCIIO_BASE_VA + SMBUS_HOST_CONTROL + dli v1, BONITO_HTIO_BASE_VA + SMBUS_HOST_CONTROL sb v0, 0(v1); /* make sure SMB host ready to start, important!--zfx */ //li v1, 0xbfd00000 + SMBUS_HOST_STATUS - li v1, BONITO_PCIIO_BASE_VA + SMBUS_HOST_STATUS + dli v1, BONITO_HTIO_BASE_VA + SMBUS_HOST_STATUS lbu v0, 0(v1) andi v0,v0, 0x1f beqz v0,1f @@ -30,14 +32,14 @@ LEAF(i2cread) /* start */ //li v1, 0xbfd00000 + SMBUS_HOST_CONTROL - li v1, BONITO_PCIIO_BASE_VA + SMBUS_HOST_CONTROL + dli v1, BONITO_HTIO_BASE_VA + SMBUS_HOST_CONTROL lbu v0, 0(v1) ori v0, v0, 0x40 sb v0, 0(v1); /* wait */ //li v1, 0xbfd00000 + SMBUS_HOST_STATUS - li v1, BONITO_PCIIO_BASE_VA + SMBUS_HOST_STATUS + dli v1, BONITO_HTIO_BASE_VA + SMBUS_HOST_STATUS 1: #if 0 @@ -54,7 +56,7 @@ LEAF(i2cread) nop //li v1, 0xbfd00000 + SMBUS_HOST_STATUS - li v1, BONITO_PCIIO_BASE_VA + SMBUS_HOST_STATUS + dli v1, BONITO_HTIO_BASE_VA + SMBUS_HOST_STATUS lbu v0, 0(v1) andi v0,v0, 0x1f beqz v0,1f @@ -64,7 +66,7 @@ LEAF(i2cread) 1: //li v1, 0xbfd00000 + SMBUS_HOST_DATA0 - li v1, BONITO_PCIIO_BASE_VA + SMBUS_HOST_DATA0 + dli v1, BONITO_HTIO_BASE_VA + SMBUS_HOST_DATA0 lbu v0, 0(v1) jr ra diff --git a/Targets/Bonito2g690e/Bonito/loongson2g_ddr2_config.S b/Targets/Bonito2g690e/Bonito/loongson2g_ddr2_config.S index 2ba0c811..529a4303 100644 --- a/Targets/Bonito2g690e/Bonito/loongson2g_ddr2_config.S +++ b/Targets/Bonito2g690e/Bonito/loongson2g_ddr2_config.S @@ -3,6 +3,38 @@ and set up the memory space on L2 Xbar */ + /* Set SMBus(I2C) base address */ + #bus:device:func:reg = 0:14:0:90 + dli a1,0x90000cfdfe00a090 + li a0,SMBUS_IO_BASE_VALUE | 0x1 + sw a0,0(a1) + nop + /* Enable SMBus host controller */ + #bus:device:func:reg = 0:14:0:d2 + dli a1,0x90000cfdfe00a0d2 + li a0,0x01 + sb a0,0(a1) + nop + /* Read SPD data */ + li a0,0xa0 + li a1,0x00 + bal i2cread + nop + beq v0,0xff,1f #No ddr2 device + nop + beq v0,0x80,3f + nop +1: + bal beep_on + nop +2: + nop + b 1b #loop + nop +3: + nop #Continue + //i2ccfg + ####################################################### /* Undefine the two to enable both */ #define MC0_ONLY diff --git a/Targets/Bonito2g690e/Bonito/start.S b/Targets/Bonito2g690e/Bonito/start.S index 194d9dda..a5efa52c 100644 --- a/Targets/Bonito2g690e/Bonito/start.S +++ b/Targets/Bonito2g690e/Bonito/start.S @@ -1007,6 +1007,22 @@ gs_2f_v3_ddr2_cfg: #include "loongson2g_fixup.S" +########################################## +/* + *__Start "bi..." + */ + nop + bal beep_on + nop + li a0,5000 +1: + addiu a0,-1 #delay + nop + bnez a0,1b + nop + bal beep_off + nop + ########################################## TTYDBG("NODE 0 MEMORY CONFIG BEGIN\r\n") li s1, 0x0 @@ -1799,6 +1815,26 @@ LEAF(tgt_putchar_COM1) nop END(tgt_putchar_COM1) +/* Beep on/off function */ +LEAF(beep_on) + nop + dli t1,0x90000cfdfe00a080 + lbu t0,0(t1) + or t0,0x04 + sb t0,0(t1) + nop + jr ra + nop +END(beep_on) +LEAF(beep_off) + nop + dli t1,0x90000cfdfe00a080 + lbu t0,0(t1) + and t0,0xfb + sb t0,0(t1) + nop + jr ra +END(beep_off) #include "i2c.S" __main: