天嵌 ARM开发社区

 找回密码
 注册
查看: 2900|回复: 4

TQ2440上面GPIO端口怎么定义的?

[复制链接]
qianguozheng 发表于 2012-2-18 21:14:51 | 显示全部楼层 |阅读模式
看到天堑技术手册上说S3C2440芯片上面使用的LED灯用得是GPIO的 GPB5,GPB6,GPB7,GPB8这几个定义,
但是我看到地板图上面标的是nLED_1,nLED_2,nLED_3,nLED_4。。

我不明白 GPB5等这些定义在哪里有?
对于下面的LED等的驱动

static unsigned long gpio_table [] =
{
S3C2410_GPB5,
S3C2410_GPB6,
S3C2410_GPB7,
S3C2410_GPB8,
};

这里的 S3C2410_GPB5 是宏吗?在哪里定义的呢?

/*************************************
NAME:EmbedSky_hello.c
COPYRIGHT:www.embedsky.net
*************************************/
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <asm/irq.h>
#include <mach/regs-gpio.h>
#include <mach/hardware.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/delay.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/ioctl.h>
#include <linux/cdev.h>
#include <linux/string.h>
#include <linux/list.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>
#include <asm/unistd.h>

#define DEVICE_NAME "GPIO-Control"
/* 应用程序执行ioctl(fd, cmd, arg)时的第2个参数 */
#define IOCTL_GPIO_ON 1
#define IOCTL_GPIO_OFF 0
/* 用来指定LED所用的GPIO引脚 */
static unsigned long gpio_table [] =
{
S3C2410_GPB5,
S3C2410_GPB6,
S3C2410_GPB7,
S3C2410_GPB8,
};
/* 用来指定GPIO引脚的功能:输出 */
static unsigned int gpio_cfg_table [] =
{
S3C2410_GPB5_OUTP,
S3C2410_GPB6_OUTP,
S3C2410_GPB7_OUTP,
S3C2410_GPB8_OUTP,
};
static int tq2440_gpio_ioctl(
struct inode *inode,
struct file *file,
unsigned int cmd,
unsigned long arg)
{
if (arg > 4)
{
  return -EINVAL;
}
switch(cmd)
{
  case IOCTL_GPIO_ON:
   // 设置指定引脚的输出电平为0
   s3c2410_gpio_setpin(gpio_table[arg], 0);
   return 0;
  case IOCTL_GPIO_OFF:
   // 设置指定引脚的输出电平为1
   s3c2410_gpio_setpin(gpio_table[arg], 1);
   return 0;
  default:
   return -EINVAL;
}
}
static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.ioctl = tq2440_gpio_ioctl,
};
static struct miscdevice misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &dev_fops,
};
static int __init dev_init(void)
{
int ret;
int i;

for (i = 0; i < 4; i++)
{
  s3c2410_gpio_cfgpin(gpio_table, gpio_cfg_table);
  s3c2410_gpio_setpin(gpio_table, 0);
}
ret = misc_register(&misc);
printk (DEVICE_NAME" initialized\n");
return ret;
}
static void __exit dev_exit(void)
{
misc_deregister(&misc);
}
module_init(dev_init);
module_exit(dev_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("www.embedsky.net");
MODULE_DESCRIPTION("GPIO control for EmbedSky SKY2440/TQ2440 Board");

Pony279 发表于 2012-2-18 23:49:46 | 显示全部楼层
不知道你的IDE的代码编辑器有没有 右键->go to definition of .. 的功能,有的话就可以看到

对于GPIO的配置问题,可以看S3C2440的datasheet的GPIO部分。
 楼主| qianguozheng 发表于 2012-2-19 21:01:27 | 显示全部楼层
Pony279 发表于 2012-2-18 23:49
不知道你的IDE的代码编辑器有没有 右键->go to definition of .. 的功能,有的话就可以看到

对于GPIO的配 ...

您说source insight? 这个有,项目太大了额。。。
亚瑟王 发表于 2012-2-27 12:27:14 | 显示全部楼层
亲,在这个文件下:mach/regs-gpio.h
it1988 发表于 2012-2-28 11:28:12 | 显示全部楼层
mark一下。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2024-9-29 05:35 , Processed in 1.033137 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表