Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1148332
  • 博文数量: 241
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 2279
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-27 19:53
个人简介

JustForFun

文章分类

全部博文(241)

文章存档

2023年(8)

2022年(2)

2021年(3)

2020年(30)

2019年(11)

2018年(27)

2017年(54)

2016年(83)

2015年(23)

我的朋友

分类: LINUX

2016-08-17 11:26:56

 linux-digilent-3.3.0-digilent-12.07-zed-beta\arch\arm\mach-zynq\platform_devices.c     板端文件

#define DMAC0_BASE  (0xF8003000)       //芯片里DMAC这组寄存器的基地址
#define IRQ_DMAC0_ABORT  45
#define IRQ_DMAC0  46
#define IRQ_DMAC3  72
static struct resource dmac0[] = {
 {
  .start = DMAC0_BASE,
  .end = DMAC0_BASE + 0xFFF,
  .flags = IORESOURCE_MEM,   //表示是内存资源,使用的时候需要ioremap的
 }, {
  .start = IRQ_DMAC0_ABORT,     //???
  .end = IRQ_DMAC0_ABORT,
  .flags = IORESOURCE_IRQ,            //#define IORESOURCE_IRQ  0x00000400      include/linux/ioport.h
 }, {
  .start = IRQ_DMAC0,
  .end = IRQ_DMAC0 + 3,
  .flags = IORESOURCE_IRQ,//表示是中断资源,不用映射
 }, {
  .start = IRQ_DMAC3,
  .end = IRQ_DMAC3 + 3,
  .flags = IORESOURCE_IRQ,
 },
};
struct pl330_platform_config dmac_config0 = {
 .channels = 8,
 .starting_channel = 0,
};
static u64 dma_mask = 0xFFFFFFFFUL;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct platform_device dmac_device0 = {
 .name = "pl330",
 .id = 0,
 .dev = {
  .platform_data = &dmac_config0,
  .dma_mask = &dma_mask,
  .coherent_dma_mask = 0xFFFFFFFF,
 },
 .resource = dmac0,
 .num_resources = ARRAY_SIZE(dmac0),
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

static struct platform_device xilinx_pmu_device = {
        .name           = "arm-pmu",
        .id             = ARM_PMU_DEVICE_CPU,
        .num_resources  = 1,
 .resource = &xilinx_pmu_resource,
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static struct resource xilinx_pmu_resource = {
        .start  = 37,
        .end    = 38,
        .flags  = IORESOURCE_IRQ,
};


/* add all platform devices to the following table so they
 * will be registered
 */
struct platform_device *xilinx_pdevices[] __initdata = {
 &dmac_device0,
 /* &dmac_device1, */
 &xilinx_pmu_device,
};

/**
 * platform_device_init - Initialize all the platform devices.
 *
 **/
void __init platform_device_init(void)
{
 int ret, i;
 struct platform_device **devptr;
 int size;
 devptr = &xilinx_pdevices[0];  //见struct platform_device *xilinx_pdevices[] __initdata 
 size = ARRAY_SIZE(xilinx_pdevices);
 ret = 0;
 /* Initialize all the platform devices */
 for (i = 0; i < size; i++, devptr++) {
  pr_info("registering platform device '%s' id %d\n",
   (*devptr)->name,
   (*devptr)->id);
   ret = platform_device_register(*devptr);//设备注册函数
  if (ret)
   pr_info("Unable to register platform device '%s': %d\n",
    (*devptr)->name, ret);
 }


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
图片 
 ?
阅读(1272) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~