LS1028 FSPI device driver not work

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LS1028 FSPI device driver not work

1,164 次查看
zhicheng1
Contributor III

Hi  

I want to use qspi feature of the ls1028 processer.  I change the dts as below:

dts:

spi@20c0000 {
compatible = "nxp,lx2160a-fspi";
#address-cells = <0x01>;
#size-cells = <0x00>;
reg = <0x00 0x20c0000 0x00 0x10000 0x00 0x20000000 0x00 0x10000000>;
reg-names = "fspi_base\0fspi_mmap";
interrupts = <0x00 0x19 0x04>;
clocks = <0x02 0x02 0x00 0x02 0x02 0x00>;
clock-names = "fspi_en\0fspi";
status = "okay";
phandle = <0x30>;
qspidevice@0 {
compatible = "nxp,qspi-generic";
#address-cells = <0x01>;
#size-cells = <0x01>;
spi-max-frequency = <0x1312d00>;
reg = <0x00>;
spi-rx-bus-width = <0x04>;
spi-tx-bus-width = <0x01>;
phandle = <0x31>;
};
/*
flash@0 {
compatible = "spansion,m25p80";
#address-cells = <0x01>;
#size-cells = <0x01>;
m25p,fast-read;
spi-max-frequency = <0x1312d00>;
reg = <0x00>;
spi-rx-bus-width = <0x04>;
spi-tx-bus-width = <0x01>;
phandle = <0x31>;
};
*/
};

 

Can I use "spi_sync" API to wirte the qspi device driver code as fallow? if not , which api should be called?

some driver code: 
static ssize_t qspi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
    struct qspi_dev *qspi = file->private_data;
    char write_buf[256];
    size_t len = min(count, sizeof(write_buf));
    struct spi_transfer xfer;
    struct spi_message msg;
    int ret;

    if (copy_from_user(write_buf, buf, len)) {
        dev_err(qspi->dev, "Failed to copy data from user space\n");
        return -EFAULT;
    }

    printk(KERN_INFO "  write_buf: %s\n",write_buf);
    dump_spi_device(qspi->spi);
    memset(&xfer, 0, sizeof(xfer));
    xfer.tx_buf = write_buf;
    xfer.rx_buf = NULL;
    xfer.len = len;
    //xfer.cs_change = 1;
    //xfer.bits_per_word = qspi->spi->bits_per_word;
    //xfer.speed_hz = qspi->spi->max_speed_hz;

    spi_message_init(&msg);
    spi_message_add_tail(&xfer, &msg);

    ret = spi_sync(qspi->spi, &msg);
    if (ret < 0) {
        dev_err(qspi->dev, "Failed to write to QSPI, error code: %d\n", ret);
        //dev_err(qspi->dev, "Message length: %u, Message buffer: %p\n", msg.len, msg.buf);
        return ret;
    }
 
Thanks,
zhang
0 项奖励
回复
2 回复数

1,159 次查看
mikelooijmans
Contributor IV

Most QSPI controllers can only be used in combination with flash memories (serial NOR typically, some also support serial NAND). They cannot handle "generic" SPI as they "snoop" the commands sent to control the extra data lines.

Connect your device to a "normal" SPI controller (the NXP has plenty of those).

0 项奖励
回复

1,143 次查看
zhicheng1
Contributor III

get it.

Thanks.

0 项奖励
回复