This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADD XR20M1172 to AM3715

Other Parts Discussed in Thread: AM3715

For our design we add XR20M1172 to AM3715,we think we add the driver correctly,but why we read the registers in XR20M1172,they are all zeros.

in the board.c,we add

static struct xr20m1172_platform_data xr20m1172_data = {
.uartclk = 14745600,
.uart_base = 0,
.gpio_base = 0,
.label = "eser",
};

struct spi_board_info __initdata xr20m1172_spi_slave_info[] = {
{
.modalias = "xr20m1172", /* driver name */
.platform_data = &xr20m1172_data,
.max_speed_hz = 1000000,
.bus_num = 2,
.chip_select = 0,
},
};

and in the probe() of xr20m1172.c 

printk(KERN_INFO DRIVER_NAME " at CS%d (irq %d), 2 UARTs, 8 GPIOs\n"
" eser%d, eser%d, gpiochip%d\n",
spi->chip_select, spi->irq,
pdata->uart_base, pdata->uart_base + 1,
pdata->gpio_base);

printk("the value in REG_LCR is %8x\n",xr20m1172_read(spi,0x03,0));
ret = xr20m1172_write(spi,REG_IOD,0,0xf0);
if(ret){
printk("write err!\n");
goto exit_uart1;
}
printk("the value in REG_IOD is %8x\n",xr20m1172_read(spi,REG_IOD,0));

ret = xr20m1172_write_async(spi,0x01,1,0xf0);
if(ret){
printk("write err!\n");
goto exit_uart1;
}
printk("the value in 0x01 is %8x\n",xr20m1172_read(spi,0x01,1));
printk("the value in 0x01 is %8x\n",xr20m1172_read(spi,0x01,1));

and the result is 

[ 0.033081] ****************************xr20m1172_probe*****************************
[ 0.033111] out.cmd= 70,out.value= 8,sizeof(out)=2
[ 0.033660] IRQ 0 uses trigger mode 0; requested 2
[ 0.033966] xr20m1172 at CS0 (irq 0), 2 UARTs, 8 GPIOs
[ 0.033966] eser0, eser1, gpiochip0
[ 0.033996] read_cmd(reg,ch)= 98
[ 0.034057] the value in REG_LCR is 0
[ 0.034088] out.cmd= 50,out.value= f0,sizeof(out)=2
[ 0.034149] read_cmd(reg,ch)= d0
[ 0.034179] the value in REG_IOD is 0
[ 0.034210] read_cmd(reg,ch)= 8a
[ 0.034301] the value in 0x01 is 0
[ 0.034301] read_cmd(reg,ch)= 8a
[ 0.034362] the value in 0x01 is 0

As there is no error, we think the function is performed correctly, but why the value is 0, and we have set the RST pin 1 in software,could anybody help us ?

thank you in advace

  • Hi Xiaobo Xue,

    I have not the source of the 20m1172_read() and 20m1172_write() functions but I suspect the the reason for the issue should be due to incorrect work of them. I suggest you to debug there functions.

    BR

    Tsvetolin Shulev

  • Hi Tsvetolin Shulev,

    Here are my functions,

    static int xr20m1172_write(struct spi_device *spi, u8 reg, u8 ch, u8 val) 
    {
    struct xr20m1172_spi_reg out;

    out.cmd = write_cmd(reg, ch);
    out.value = val;

    return spi_write(spi, (const u8 *)&out, sizeof(out));
    }

    static int xr20m1172_read(struct spi_device *spi, unsigned reg, unsigned ch)
    {
    printk("read_cmd(reg,ch)=%8x\n",read_cmd(reg, ch));
    return spi_w8r8(spi, read_cmd(reg, ch));
    }

    and 

    static u8 write_cmd(u8 reg, u8 ch)
    {
    return REG_WRITE | (reg & 0xf) << 3 | (ch & 0x1) << 1; 
    }

    static u8 read_cmd(u8 reg, u8 ch) 
    {
    return REG_READ | (reg & 0xf) << 3 | (ch & 0x1) << 1; 
    }

    These are my functions.I don't know which is wrong,thank you very much.