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.

GPMC to control CPLD

hi,

    i use gpmc to control a 8-bit CPLD , CPLD needs to select by gpmc nCS4  for base addr, nor mode. The CPLD has 8 registers, using 3 lines which attach to gpmc_a[6] ~ gpmc_a[8] to select.  its data lines attach to gpmc_d[0] ~ gpmc_d[7]. when finish  initial the gpmc ,  i do a test ,write 0xaa to CPLD( offset 0), read out from CPLD(offset 0x5). If i do correct gpmc initialization, i'll read the data 0xaa out. At last, i failed, pls help me what i have to do ,thanks a lot !

static int tzio_gpmc_init(void)
{
 int status;
 u32 reg;
 unsigned long base;
 
 status = gpmc_cs_request(TZIO_GPMC_CS_PRT, SZ_4K, &base);
 
 if (status < 0) {
  printk("TZIO_GPMC_CS_PRT req failed[%d]", status);
  return status;
 }

 tzio_device.start = base;
 tzio_device.end = base + SZ_4K-1;
 tzio_device.iobase = ioremap(tzio_device.start, SZ_4K);

 reg = gpmc_cs_read_reg(TZIO_GPMC_CS_PRT, GPMC_CS_CONFIG1);
 gpmc_cs_write_reg(TZIO_GPMC_CS_PRT, GPMC_CS_CONFIG1,
  reg | GPMC_CONFIG1_DEVICESIZE(0)|
   GPMC_CONFIG1_DEVICETYPE_NOR);

writebyte(0xaa, tzio_device.iobase + 0);
 prink("read out =%x\n",readbyte(tzio_device.iobase + 0x5));
 return status;
}

 

  • i use the kernel functions "__raw_readb()" and "__raw_writeb()" to replace the functions “writebyte()” and "readbyte" written by me. the result isn't right ,too!

    the result read out from CPLD is 0xff. But i wrote 0xaa to CPLD just before.