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

本文详细介绍了如何在Exynos4412平台上进行内核驱动的静态和动态编译移植。通过在Linux 3.14内核中添加自定义的fs4412_led_drv.c驱动文件,修改Makefile,以及编译和测试应用程序,展示了静态编译驱动到内核以及动态编译为模块的过程。
摘要由CSDN通过智能技术生成

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


硬件环境:

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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值