PXA310的电源管理(1)

 

PXA310的电源管理(1)

2011-6-30 20:42:24
ipmc.c

相关驱动是作为一个杂项设备注册到系统中的,对应的设备节点为  /dev/ipmc

杂项设备(misc device)

杂项设备也是在嵌入式系统中用得比较多的一种设备驱动。在 Linux 内核的include/linux目录下有Miscdevice.h文件,

是一种主设备号为10的特殊字符设备。

cat /proc/devices

 可以看到ipmc的主设备号为 10

cat /proc/misc

可以看到ipmc的次设备号为90

关注一下ipmc 对应的操作方法

static struct file_operations ipmc_fops = {
 owner: THIS_MODULE,
 open: ipmc_open,
 read: ipmc_read,
 write: ipmc_write,
 poll: ipmc_poll,
 ioctl: ipmc_ioctl,
 release:ipmc_close,
};

 

性能资源管理 PRM(Performance Resources Managemen)

使用prm_resource 来描述一个性能资源

struct prm_resource {
 struct prm_client *access; /* Only one client can access it */
 prm_resource_id id;
 struct prm_resource_state priority[MAX_PRIORITIES];
 struct proc_dir_entry *dir;
};

每个资源都有一个资源状态数组

/* resources state */
struct prm_resource_state {
 struct prm_client *allocate; /* which client allocate the resources. In every priority, there can be only one client allocate the resource*/
 struct prm_group *group; /* which group it belongs to */
 int active;
 struct prm_resource *resource;
 struct list_head entry; /* used by prm_group->resources for link the resources into the group */
 struct proc_dir_entry *dir;
};


所有资源都存放在一个静态数组中

static struct prm_resource prm_resources[RESOURCE_NUM];


那么谁来使用性能资源?一个资源使用者,作为一个客户端

struct prm_client {
 unsigned int id; /* client id */
 unsigned int pid; /* process id for the client */
 prm_priority priority; /* priority for the client.(LOW or HIGH) */
 char *name;  /* name of the client */
 unsigned int group_cnt; /* How many groups in the client */
 struct prm_group *groups[MAX_GROUPS]; /* support MAXGROUP groups, some may be NULL */
 void *client_data;
 clientcallback notify; /* notifier for resource appropriate and ready */
 irq_handler_t handler;
 void *dev_id;
 struct proc_dir_entry *dir;
};


在初试化的时候,注册了软中断

#define IRQ_PMU  PXA_IRQ(12) /* Performance Monitoring Unit */

软中断的处理函数就是就是调用prm_client的hanlder 方法 。


接下来回调ipmc的操作方法

open

1 创建一个会话,优先级为IPMC_CLI_PRI

  对于PRM 来说就是在 prm_clients中找一个空闲位来存放新分配的prm_client地址
 
  返回数组中的下标。
 
2 分配资源
  根据前面返回的数组下标,资源ID和组ID来分配资源
 
  PRM可以根据资源ID,找到对应资源和对应于该优先级的资源状态
 
  查找资源状态信息,看资源是否已经被分配了,
 
  如果没有就继续,否则返回失败
 
  分配一个prm_group
 
  把资源状态加入到组中
 
3 提交资源

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值