Exynos4412 内核移植(五)—— 驱动的移植

        以移植自己制作的驱动,学习内核移植中的驱动移植,及 驱动程序的动态编译和静态编译


硬件环境:

Linux 内核版本:Linux 3.14

主机:Ubuntu 12.04发行版

目标机:FS4412平台

交叉编译工具:arm-none-linux-gnueabi-gcc


一、静态编译

1、添加驱动文件

       将写好的实验代码fs4412_led_drv.c 拷贝到 drivers/char 下

fs4412_led_drv.c 如下:

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>

#include <asm/io.h>
#include <asm/uaccess.h>

MODULE_LICENSE("Dual BSD/GPL");

#define LED_MAGIC 'L'
/*
 * need arg = 1/2 
 */

#define LED_ON	_IOW(LED_MAGIC, 0, int)
#define LED_OFF	_IOW(LED_MAGIC, 1, int)


#define LED_MA 500
#define LED_MI 0
#define LED_NUM 1

#define FS4412_GPX2CON	0x11000C40
#define FS4412_GPX2DAT	0x11000C44

static unsigned int *gpx2con;
static unsigned int *gpx2dat;

struct cdev cdev;

static int s5pv210_led_open(struct inode *inode, struct file *file)
{
	return 0;
}
	
static int s5pv210_led_release(struct inode *inode, struct file *file)
{
	return 0;
}
	
static long s5pv210_led_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int nr;

	switch (cmd) {
		case LED_ON:
			writel(readl(gpx2dat) | 1 << 7, gpx2dat);
			break;
		c
  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值