Dear all:
I've build an bootloader MLO based on starterware tool 2.0.0.1.
Which the MLO can work in the Beaglebone Black(BBB).
However, we made the customized board.
The HW team designed the am335x's i2c1 intefacing with tps6517c.
In fact, I made some modification in ~/(starterware2.0.0.1)/bootloader/armv7a/am335x/bl_platform.c
I tried to cange the code named I2C_0 to I2C_1
here's the part of changed source code :
-------------------------------
#define I2C_0 (0x0u)
#define I2C_1 (0x1u)
void SetupI2C(void)
{
I2C1ModuleClkConfig();
I2CPinMuxSetup(I2C_1);
/* Put i2c in reset/disabled state */
I2CMasterDisable(SOC_I2C_1_REGS);
I2CSoftReset(SOC_I2C_1_REGS);
/* Disable auto Idle functionality */
I2CAutoIdleDisable(SOC_I2C_1_REGS);
/* Configure i2c bus speed to 100khz */
I2CMasterInitExpClk(SOC_I2C_1_REGS, I2C_SYSTEM_CLOCK, I2C_INTERNAL_CLOCK,
I2C_OUTPUT_CLOCK);
I2CMasterEnable(SOC_I2C_1_REGS);
while(!I2CSystemStatusGet(SOC_I2C_1_REGS));
}
void SetupI2CTransmit(unsigned int dcount)
{
I2CSetDataCount(SOC_I2C_1_REGS, dcount);
CleanupInterrupts();
I2CMasterControl(SOC_I2C_1_REGS, I2C_CFG_MST_TX);
I2CMasterStart(SOC_I2C_1_REGS);
while(I2CMasterBusBusy(SOC_I2C_1_REGS) == 0);
while((I2C_INT_TRANSMIT_READY == (I2CMasterIntRawStatus(SOC_I2C_1_REGS)
& I2C_INT_TRANSMIT_READY)) && dcount--)
{
I2CMasterDataPut(SOC_I2C_1_REGS, dataToSlave[tCount++]);
I2CMasterIntClearEx(SOC_I2C_1_REGS, I2C_INT_TRANSMIT_READY);
}
I2CMasterStop(SOC_I2C_1_REGS);
while(0 == (I2CMasterIntRawStatus(SOC_I2C_1_REGS) & I2C_INT_STOP_CONDITION));
I2CMasterIntClearEx(SOC_I2C_1_REGS, I2C_INT_STOP_CONDITION);
}
void SetupReception(unsigned int dcount)
{
I2CSetDataCount(SOC_I2C_1_REGS, 1);
CleanupInterrupts();
I2CMasterControl(SOC_I2C_1_REGS, I2C_CFG_MST_TX);
I2CMasterStart(SOC_I2C_1_REGS);
while(I2CMasterBusBusy(SOC_I2C_1_REGS) == 0);
I2CMasterDataPut(SOC_I2C_1_REGS, dataToSlave[tCount]);
I2CMasterIntClearEx(SOC_I2C_1_REGS, I2C_INT_TRANSMIT_READY);
while(0 == (I2CMasterIntRawStatus(SOC_I2C_1_REGS) & I2C_INT_ADRR_READY_ACESS));
I2CSetDataCount(SOC_I2C_1_REGS, dcount);
CleanupInterrupts();
I2CMasterControl(SOC_I2C_1_REGS, I2C_CFG_MST_RX);
I2CMasterStart(SOC_I2C_1_REGS);
/* Wait till the bus if free */
while(I2CMasterBusBusy(SOC_I2C_1_REGS) == 0);
/* Read the data from slave of dcount */
while((dcount--))
{
while(0 == (I2CMasterIntRawStatus(SOC_I2C_1_REGS) & I2C_INT_RECV_READY));
dataFromSlave[rCount++] = I2CMasterDataGet(SOC_I2C_1_REGS);
I2CMasterIntClearEx(SOC_I2C_1_REGS, I2C_INT_RECV_READY);
}
I2CMasterStop(SOC_I2C_1_REGS);
while(0 == (I2CMasterIntRawStatus(SOC_I2C_1_REGS) & I2C_INT_STOP_CONDITION));
I2CMasterIntClearEx(SOC_I2C_1_REGS, I2C_INT_STOP_CONDITION);
}
void TPS65217RegWrite(unsigned char port_level, unsigned char regOffset,
unsigned char dest_val, unsigned char mask)
{
unsigned char read_val;
unsigned xor_reg;
dataToSlave[0] = regOffset;
tCount = 0;
rCount = 0;
if(mask != MASK_ALL_BITS)
{
SetupReception(1);
read_val = dataFromSlave[0];
read_val &= (~mask);
read_val |= (dest_val & mask);
dest_val = read_val;
}
if(port_level > 0)
{
xor_reg = regOffset ^ PASSWORD_UNLOCK;
dataToSlave[0] = PASSWORD;
dataToSlave[1] = xor_reg;
tCount = 0;
SetupI2CTransmit(2);
}
dataToSlave[0] = regOffset;
dataToSlave[1] = dest_val;
tCount = 0;
SetupI2CTransmit(2);
if(port_level == PROT_LEVEL_2)
{
dataToSlave[0] = PASSWORD;
dataToSlave[1] = xor_reg;
tCount = 0;
SetupI2CTransmit(2);
dataToSlave[0] = regOffset;
dataToSlave[1] = dest_val;
tCount = 0;
SetupI2CTransmit(2);
}
}
void ConfigVddOpVoltage(void)
{
SetupI2C();
#ifdef beaglebone
unsigned char pmic_status = 0;
/* Configure PMIC slave address */
//kuso modified1
I2CMasterSlaveAddrSet(SOC_I2C_1_REGS, PMIC_TPS65217_I2C_SLAVE_ADDR);
TPS65217RegRead(STATUS, &pmic_status);
/* Increase USB current limit to 1300mA */
TPS65217RegWrite(PROT_LEVEL_NONE, POWER_PATH, USB_INPUT_CUR_LIMIT_1300MA,
USB_INPUT_CUR_LIMIT_MASK);
/* Set DCDC1 (DDR3) voltage to 1.5V */
if(isBBB)
{
TPS65217VoltageUpdate(DEFDCDC1, DCDC_VOLT_SEL_1500MV);
}
/* Set DCDC2 (MPU) voltage to 1.275V */
TPS65217VoltageUpdate(DEFDCDC2, DCDC_VOLT_SEL_1275MV);
/* Set LDO3, LDO4 output voltages according to the board */
if(isBBB)
{
TPS65217RegWrite(PROT_LEVEL_2, DEFLS1, LDO_VOLTAGE_OUT_1_8, LDO_MASK);
}
else
{
TPS65217RegWrite(PROT_LEVEL_2, DEFLS1, LDO_VOLTAGE_OUT_3_3, LDO_MASK);
}
TPS65217RegWrite(PROT_LEVEL_2, DEFLS2, LDO_VOLTAGE_OUT_3_3, LDO_MASK);
#elif defined (evmAM335x) || defined (evmskAM335x)
/* Configure PMIC slave address */
I2CMasterSlaveAddrSet(SOC_I2C_1_REGS, PMIC_CNTL_I2C_SLAVE_ADDR);
/* Select SR I2C(0) */
SelectI2CInstance(PMIC_DEVCTRL_REG_SR_CTL_I2C_SEL_CTL_I2C);
/* Configure vdd1- need to validate these parameters */
ConfigureVdd1(PMIC_VDD1_REG_VGAIN_SEL_X1, PMIC_VDD1_REG_ILMAX_1_5_A,
PMIC_VDD1_REG_TSTEP_12_5, PMIC_VDD1_REG_ST_ON_HI_POW);
/* Select the source for VDD1 control */
SelectVdd1Source(PMIC_VDD1_OP_REG_CMD_OP);
#else
#error Unsupported EVM !!
#endif
}
-------------
How to (1)modify or can I (2)skip to read i2c but set the correct parameter in this code?
Thank you very much if you have any comment and suggestion.