am335xd核心板通过总线外挂一款PT7A6525的HDLC芯片,8根地址数据总线复用,电路图如下:
选择CS3脚,驱动代码:
#define HDLC_GPMC_CONFIG1 0x00000200 //8位模式,引脚复用
#define HDLC_GPMC_CONFIG2 0x00080800 //片选信号CS OffTime 48ns
#define HDLC_GPMC_CONFIG3 0x00020201 //使用数据/地址信号切换nADV
#define HDLC_GPMC_CONFIG4 0x08000800 //读使能#OE、写使能信号#WE持续48ns
#define HDLC_GPMC_CONFIG5 0x01060D0D //读取周期78ns,访问36ns
#define HDLC_GPMC_CONFIG6 0x00000F80 // 连续访问周期间隔90ns
#define HDLC_GPMC_CONFIG7 0x00000F50 // 物理地址0x1000 0000, 16MB window
/*config pt7a6525 bus addr mapping*/
static s8 pt7a6525_gpmc_config(void)
{
unsigned int base, size;
unsigned int val = 0;
/*Disable Chip Select*/
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG7, HDLC_GPMC_CONFIG7&(~GPMC_CONFIG7_CSVALID));
#if 1
/*GPMC_CONFIG7_CSVALID查看是否被占用*/
if (!gpmc_cs_mem_enabled(HDLC_CS))
{
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG7, HDLC_GPMC_CONFIG7&(~GPMC_CONFIG7_CSVALID) );
gpmc_cs_get_memconf(HDLC_CS, &base, &size);
DPRINTK("base= 0x%x, size=0x%x
", base, size);
if (gpmc_cs_insert_mem(HDLC_CS, base, size) < 0)
BUG();
gpmc_cs_enable_mem(HDLC_CS, base, size);
}
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG7, HDLC_GPMC_CONFIG7&(~GPMC_CONFIG7_CSVALID) );
/* Delay for settling */
mdelay(30);
#endif
gpmc_cs_configure(HDLC_CS, GPMC_SET_IRQ_STATUS, 0); /*set irq status*/
gpmc_cs_configure(HDLC_CS, GPMC_ENABLE_IRQ, 0); /*disable irqs*/
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG1, HDLC_GPMC_CONFIG1);
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG2, HDLC_GPMC_CONFIG2);
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG3, HDLC_GPMC_CONFIG3);
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG4, HDLC_GPMC_CONFIG4);
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG5, HDLC_GPMC_CONFIG5);
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG6, HDLC_GPMC_CONFIG6);
/*Enable the config*/
gpmc_cs_write_reg(HDLC_CS, GPMC_CS_CONFIG7, HDLC_GPMC_CONFIG7|GPMC_CONFIG7_CSVALID);
val = gpmc_cs_read_reg(HDLC_CS, GPMC_CS_CONFIG7);
DPRINTK("GPMC_CS_CONFIG7 = 0x%x
", val);
/***********申请GPMC chip-select空间**********/
if(gpmc_cs_request(HDLC_CS, REG_SIZE, &mem_base)<0)
{
DPRINTK(KERN_ERR "gpmc_cs_request for hdlc failed.
");
return -1;
}
DPRINTK("Got CS3, address = %lx
", mem_base);
/***********申请虚拟内存空间**********/
if(!request_mem_region(mem_base, REG_SIZE, "mem_hdlc"))
{
DPRINTK(KERN_ERR "request_mem_region failed.
");
gpmc_cs_free(HDLC_CS);
return -1;
}
/******物理地址映射为虚拟地址*****/
hdlc_base = ioremap(mem_base, REG_SIZE);
return 1;
}
配置完代码,获取到
[ 4.286009] hdlc_init ...
[ 4.289426] base= 0x10000000, size=0x1000000
[ 4.323760] GPMC_CS_CONFIG7 = 0xf50
[ 4.327410] Got CS3, address = 10000000
[ 4.331439] hdlc_base =e085e000
但是通过
while(1){
writeb(0xaa, hdlc_base);
writeb(0x55, hdlc_base);
} 经示波器看AD0~AD7脚均无电平拉高,有没大神帮忙看下配置是否有问题。。。到底是什么原因啊。。。
此帖出自
小平头技术问答
一周热门 更多>