Reputation: 499
I have configure for spi_gpio driver and its working fine as in this link Spidev do not write/read simultaneously using ioctl, I came to know that the spi protocol is working fine, now I want use that spi protocol to communicate with AT45DB321D 4M seria flash. I found mtd_dataflash.c is same as my device by looking at the data-sheet of AT45DB321D.
Is the way I am gong is correct...?
If so how can I map this driver with spi to communicate with AT45DB321D serial flash...? guide me to solve this by providing useful docs are suggestion.
(I am using cortex-m3 LPC1788 development bard with uclinux)
EDITED: I am able to read the device ID by the following code and using /dev/spidev0.1
int ret = 0;
int fd;
unsigned char buff[10],buf[]={ 0x9F }, str[4];
ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
if (ret == -1)
pabort("can't set bits per word");
ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
if (ret == -1)
pabort("can't get bits per word");
/*
* max speed hz
*/
ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
if (ret == -1)
pabort("can't set max speed hz");
ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
if (ret == -1)
pabort("can't get max speed hz");
write(fd,buf,1);
read(fd, buff,10);
LPC178X_CS_HIGH;
sprintf(str,"%02X%02X%02X\n",buff[0],buff[1],buff[2]);
printf("Devce ID: ");
puts(str);
my question is how can I write a data in to flash AT45DB321D memory please any help...?
Upvotes: 0
Views: 1030
Reputation: 3892
Useful docs and suggestions always come from the kernel sources. Read how SPI framework work and look what other developer did. For example, you can see how Atmel 9260 register the mtd_dataflash. The modalias field is used by the bus infrastructore to match the device with the driver. The other fields are specific of your hardware.
Upvotes: 0