Пример #1
0
void pmic_init(void)
{
	u8 pmic_id;
	
	GPIO_SetFunctionEach(eGPIO_F1, eGPIO_4, 1);
	GPIO_SetDataEach(eGPIO_F1, eGPIO_4, 1);
	GPIO_SetFunctionEach(eGPIO_F1, eGPIO_5, 1);
	GPIO_SetDataEach(eGPIO_F1, eGPIO_5, 1);
	
	GPIO_SetFunctionEach(eGPIO_X0, eGPIO_7, 0);
	GPIO_SetPullUpDownEach(eGPIO_X0, eGPIO_7, 0);
	GPIO_SetFunctionEach(eGPIO_X1, eGPIO_5, 0);
	GPIO_SetPullUpDownEach(eGPIO_X1, eGPIO_5, 0);

	udelay(10000); /* make sure all GPIOs got applied */
	I2C_InitIp(7, 400*1000, 1000000);
	udelay(10000); /* make sure I2C controller starts up */
	/* read ID */
	IIC7_ERead(S5M8767_ADDR, 0, &pmic_id);
	if(pmic_id >= 0x0 && pmic_id <= 0x5) {
		pmic_s5m8767_init();
	} else {
		pmic_max77686_init();
	}
	pmic_print_info();
	charger_max77693_init();
	
}
Пример #2
0
//////////
// Function Name : GPIO_SetEint0
// Function Desctiption : This function setup Eint[27:0]
// Input : 			uEINT_No: EINT No.
//					uINTType: Select EINT Type. 
//								Low, High, Falling, Rising, Both
//					uFltType :  Select Filter Type
//								DisFLT(Disable Filter), DLYFLT(Delay Filter), DIGFLT(Digital Filter)
//					uFltWidth : Digital Filter Width ( 1~0x3F)
// Output : NONE
//
// Version : v0.1
void GPIO_SetEint0(u32 uEINT_No , u32 uIntType, FLT_eTYPE eFltType,  u32 uFltWidth)
{

	volatile u32 *pEINTx_Reg, *pFLTx_Reg;
	volatile u32 *pGPIO_EINT_Addr;
	u32 uGpioPort, uFunc, uType ;	
	u32 uConValue;

	GPIO_pBase = (void *)GPIO_BASE;

	pGPIO_EINT_Addr = &(GPIO->rEINT0CON0);

	// EINT Port
	if( uEINT_No <= 15)
	{
		uGpioPort = uEINT_No;
		uFunc = 2;  					// EINT Function 
		GPIO_SetFunctionEach(eGPIO_N, (GPIO_eBitPos)uGpioPort, uFunc);		// ??
		GPIO_SetPullUpDownEach(eGPIO_N,(GPIO_eBitPos) uGpioPort, 0x0);		// disable Pull-up/dn
	}
	else if(uEINT_No >= 16 && uEINT_No <= 22)
	{
		uGpioPort = (uEINT_No - 8) ;
		uFunc = 3;
		GPIO_SetFunctionEach(eGPIO_L,(GPIO_eBitPos) uGpioPort, uFunc);   		  // ??
		GPIO_SetPullUpDownEach(eGPIO_L, (GPIO_eBitPos)uGpioPort, 0x0);

	}
	else if(uEINT_No >=23 && uEINT_No <=27)
	{
		uGpioPort = (uEINT_No - 23 );
		uFunc = 3;
		GPIO_SetFunctionEach(eGPIO_M, (GPIO_eBitPos)uGpioPort, uFunc);		// ??
		GPIO_SetPullUpDownEach(eGPIO_M, (GPIO_eBitPos)uGpioPort, 0x0);		// disable Pull-up/dn
	}
	else if (uEINT_No >= 27)
	{
		UART_Printf("Error Eint No. \n");
		Assert(0);
	}

	
	//  Interrupt Type 
	if( uEINT_No <= 15)
	{
		uType =(uEINT_No>>1);
		pEINTx_Reg = pGPIO_EINT_Addr ; 	
		uConValue = *pEINTx_Reg;
		uConValue = (uConValue & ~(0xF<<(uType*4))) | (uIntType<<(uType*4));
		*pEINTx_Reg = uConValue;
		
	}
Пример #3
0
int board_late_init(void)
{

	GPIO_Init();
	GPIO_SetFunctionEach(eGPIO_X0, eGPIO_0, 0);
	GPIO_SetPullUpDownEach(eGPIO_X0, eGPIO_0, 0);

	udelay(10);
	if (GPIO_GetDataEach(eGPIO_X0, eGPIO_0) == 0 || second_boot_info == 1)
		setenv("bootcmd", CONFIG_BOOTCOMMAND2);

	if (second_boot_info == 1)
		printf("###Secondary Boot###\n");

	return 0;
}
Пример #4
0
void I2C_SetGPIO(I2C_CHANNEL eCh, bool bEnable)
{
	switch (eCh)
	{	
		case I2C0:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_0, 2);			// GPIO set I2C0_SDA
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_1, 2);			// GPIO set I2C0_SCL
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_0, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_1, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_0, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_1, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_0, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_1, 1);		// GPIO set reset value
			}
			break;

		case I2C1:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_2, 2);			// GPIO set I2C1_SDA
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_3, 2);			// GPIO set I2C1_SCL
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_2, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_3, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_2, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_D1, eGPIO_3, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_2, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_D1, eGPIO_3, 1);		// GPIO set reset value
			}
			break;
			
		case I2C2:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_A0, eGPIO_6, 3);			// GPIO set I2C2_SDA
				GPIO_SetFunctionEach(eGPIO_A0, eGPIO_7, 3);			// GPIO set I2C2_SCL
				GPIO_SetPullUpDownEach(eGPIO_A0, eGPIO_6, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_A0, eGPIO_7, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_A0, eGPIO_6, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_A0, eGPIO_7, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_A0, eGPIO_6, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_A0, eGPIO_7, 1);		// GPIO set reset value
			}
			break;

		case I2C3:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_A1, eGPIO_2, 3);			// GPIO set I2C3_SDA
				GPIO_SetFunctionEach(eGPIO_A1, eGPIO_3, 3);			// GPIO set I2C3_SCL
				GPIO_SetPullUpDownEach(eGPIO_A1, eGPIO_2, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_A1, eGPIO_3, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_A1, eGPIO_2, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_A1, eGPIO_3, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_A1, eGPIO_2, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_A1, eGPIO_3, 1);		// GPIO set reset value
			}
			break;

		case I2C4:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_2, 3);			// GPIO set I2C4_SDA
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_3, 3);			// GPIO set I2C4_SCL
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_2, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_3, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_2, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_3, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_2, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_3, 1);		// GPIO set reset value
			}
			break;

		case I2C5:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_6, 3);			// GPIO set I2C5_SDA
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_7, 3);			// GPIO set I2C5_SCL
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_6, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_7, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_6, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_B, eGPIO_7, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_6, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_B, eGPIO_7, 1);		// GPIO set reset value
			}
			break;

		case I2C6:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_C1, eGPIO_3, 4);			// GPIO set I2C6_SDA
				GPIO_SetFunctionEach(eGPIO_C1, eGPIO_4, 4);			// GPIO set I2C6_SCL
				GPIO_SetPullUpDownEach(eGPIO_C1, eGPIO_3, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_C1, eGPIO_4, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_C1, eGPIO_3, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_C1, eGPIO_4, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_C1, eGPIO_3, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_C1, eGPIO_4, 1);		// GPIO set reset value
			}
			break;

		case I2C7:
			if (bEnable)
			{
				GPIO_SetFunctionEach(eGPIO_D0, eGPIO_2, 3);			// GPIO set I2C7_SDA
				GPIO_SetFunctionEach(eGPIO_D0, eGPIO_3, 3);			// GPIO set I2C7_SCL
				GPIO_SetPullUpDownEach(eGPIO_D0, eGPIO_2, 0);		// GPIO set Pull-up/down Disable
				GPIO_SetPullUpDownEach(eGPIO_D0, eGPIO_3, 0);		// GPIO set Pull-up/down Disable
			}
			else
			{
				GPIO_SetFunctionEach(eGPIO_D0, eGPIO_2, 0);			// GPIO set reset value
				GPIO_SetFunctionEach(eGPIO_D0, eGPIO_3, 0);			// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_D0, eGPIO_2, 1);		// GPIO set reset value
				GPIO_SetPullUpDownEach(eGPIO_D0, eGPIO_3, 1);		// GPIO set reset value
			}
			break;

		case I2C8:
			break;
	}
}
Пример #5
0
int board_init(void)
{
    char bl1_version[9] = {0};

    GPIO_Init();

    GPIO_SetFunctionEach(eGPIO_X0, eGPIO_1, 0);
    GPIO_SetPullUpDownEach(eGPIO_X0, eGPIO_1, 0);
    GPIO_SetFunctionEach(eGPIO_X0, eGPIO_4, 0);
    GPIO_SetPullUpDownEach(eGPIO_X0, eGPIO_4, 0);
    GPIO_SetFunctionEach(eGPIO_X0, eGPIO_5, 0);
    GPIO_SetPullUpDownEach(eGPIO_X0, eGPIO_5, 0);


    GPIO_SetFunctionEach(eGPIO_X1, eGPIO_3, 0);
    GPIO_SetPullUpDownEach(eGPIO_X1, eGPIO_3, 0);
    GPIO_SetFunctionEach(eGPIO_X1, eGPIO_4, 0);
    GPIO_SetPullUpDownEach(eGPIO_X1, eGPIO_4, 0);
    GPIO_SetFunctionEach(eGPIO_X2, eGPIO_0, 0);
    GPIO_SetPullUpDownEach(eGPIO_X2, eGPIO_0, 0);
    GPIO_SetFunctionEach(eGPIO_X2, eGPIO_1, 0);
    GPIO_SetPullUpDownEach(eGPIO_X2, eGPIO_1, 0);
    GPIO_SetFunctionEach(eGPIO_X2, eGPIO_2, 0);
    GPIO_SetPullUpDownEach(eGPIO_X2, eGPIO_2, 0);
    GPIO_SetFunctionEach(eGPIO_X2, eGPIO_7, 0);
    GPIO_SetPullUpDownEach(eGPIO_X2, eGPIO_7, 0);
    GPIO_SetFunctionEach(eGPIO_X3, eGPIO_3, 0);
    GPIO_SetPullUpDownEach(eGPIO_X3, eGPIO_3, 0);

    GPIO_SetFunctionEach(eGPIO_M1, eGPIO_2, 0);
    GPIO_SetPullUpDownEach(eGPIO_M1, eGPIO_2, 0);
    GPIO_SetFunctionEach(eGPIO_M1, eGPIO_3, 0);
    GPIO_SetPullUpDownEach(eGPIO_M1, eGPIO_3, 0);
    GPIO_SetFunctionEach(eGPIO_M1, eGPIO_4, 0);
    GPIO_SetPullUpDownEach(eGPIO_M1, eGPIO_4, 0);
    GPIO_SetFunctionEach(eGPIO_M1, eGPIO_5, 0);
    GPIO_SetPullUpDownEach(eGPIO_M1, eGPIO_5, 0);

    board_rev =
        (GPIO_GetDataEach(eGPIO_M1, eGPIO_5) << 3) |
        (GPIO_GetDataEach(eGPIO_M1, eGPIO_4) << 2) |
        (GPIO_GetDataEach(eGPIO_M1, eGPIO_3) << 1) |
        (GPIO_GetDataEach(eGPIO_M1, eGPIO_2) << 0);

    printf("Board revision: 0x%X\n", board_rev);

    pmic_init();

    /* display BL1 version */
#ifdef CONFIG_TRUSTZONE
    printf("BL1 version: N/A (TrustZone Enabled BSP)\n");
#else
    strncpy(&bl1_version[0], (char *)0x02022fc8, 8);
    printf("BL1 version: %s\n", &bl1_version[0]);
#endif

#ifdef CONFIG_SMDKC220
    gd->bd->bi_arch_number = MACH_TYPE_C220;
#else
    if(((PRO_ID & 0x300) >> 8) == 2)
        gd->bd->bi_arch_number = MACH_TYPE_C210;
    else