免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3216 | 回复: 4
打印 上一主题 下一主题

熟悉at91rm9200的内核源码请进 尤其是MCI这一部分的 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-10-30 20:39 |只看该作者 |倒序浏览
include/asm-arm/arch-at91/gpio.h里面
#define        AT91_PIN_PA0        (PIN_BASE + 0x00 + 0)
#define        AT91_PIN_PA1        (PIN_BASE + 0x00 + 1)
#define        AT91_PIN_PA2        (PIN_BASE + 0x00 + 2)
#define        AT91_PIN_PA3        (PIN_BASE + 0x00 + 3)
................
有很多这种定义
我看了下
#define PIN_BASE                NR_AIC_IRQS
#define NR_AIC_IRQS 32

请问上面的#define        AT91_PIN_PA0        (PIN_BASE + 0x00 + 0)这些定义是在定义引脚 ,按这样的定义 PA0的值就为32了,看了芯片的封装 DATASHEET里这个引脚序号为42啊,AT91_PIN_PAi,AT91_PIN_PBi之类的值都与DATASHEET里的引脚序号值不符合
怎么回事呢,而且我也没看到DATASHEET里AT91_PIN_PB27 复用为了MCI的DETECT_PIN啊
怎么在 linux/drivers/mmc/host/at91_mci.c - ATMEL AT91 MCI Driverl文件里有:
static int __init at91_mci_probe(struct platform_device *pdev)
{
        struct mmc_host *mmc;
        struct at91mci_host *host;
        struct resource *res;
        int ret;

        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res)
                return -ENXIO;

。。。。。。。。。。。。。。。。。。
        /*
         * monitor card insertion/removal if we can
         */
        if (host->board->det_pin) {
                ret = request_irq(gpio_to_irq(host->board->det_pin),
                                at91_mmc_det_irq, 0, mmc_hostname(mmc), host);
                if (ret)
                        dev_warn(&pdev->dev, "request MMC detect irq failed\n");
                else
                        device_init_wakeup(&pdev->dev, 1);
        }

                return ret;
}
据我的理解 正对EK开发板host->board->det_pin这个值就是在在linux/arch/arm/mach-at91/board-ek.c;里的初始化的ek_mmc_data .det_pin这个值
static struct at91_mmc_data __initdata ek_mmc_data = {
        .det_pin        = AT91_PIN_PB27,
        .slot_b                = 0,
        .wire4                = 1,
        .wp_pin                = AT91_PIN_PA17,
};
不明白怎么把一个引脚跟系统的中断号给对应了起来,和调用request_irq(gpio_to_irq(host->board->det_pin),at91_mmc_det_irq, 0, mmc_hostname(mmc), host);来注册中断

论坛徽章:
0
2 [报告]
发表于 2008-10-30 23:47 |只看该作者
对对寄存器,和封装没有关系~~

论坛徽章:
0
3 [报告]
发表于 2008-10-31 08:44 |只看该作者
由:
include/asm-arm/arch-at91/gpio.h里面
static inline int gpio_to_irq(unsigned gpio)
{
        return gpio;
}

static inline int irq_to_gpio(unsigned irq)
{
        return irq;
}

可知:
===============================================
include/asm-arm/arch-at91/gpio.h里面
#define        AT91_PIN_PA0        (PIN_BASE + 0x00 + 0)
#define        AT91_PIN_PA1        (PIN_BASE + 0x00 + 1)
#define        AT91_PIN_PA2        (PIN_BASE + 0x00 + 2)
#define        AT91_PIN_PA3        (PIN_BASE + 0x00 + 3)
................
有很多这种定义
我看了下
#define PIN_BASE                NR_AIC_IRQS
#define NR_AIC_IRQS 32
===============================================
上面给出的是引脚的中断号,不是DATASHEET里的引脚序号。
gpio的中断号是接着AIC中断号的从32开始

论坛徽章:
0
4 [报告]
发表于 2008-10-31 15:21 |只看该作者
include/asm-arm/arch-at91/gpio.h里面
#define        AT91_PIN_PA0        (PIN_BASE + 0x00 + 0)
#define        AT91_PIN_PA1        (PIN_BASE + 0x00 + 1)
#define        AT91_PIN_PA2        (PIN_BASE + 0x00 + 2)
#define        AT91_PIN_PA3        (PIN_BASE + 0x00 + 3)
这些PIN引脚都有中断号?中断号可以随便分配??是不是除了0~31这32个值不能用外,其余的值都可以分配给这些PIN引脚?不明白怎么把这些引脚跟中断号对应起来的???

论坛徽章:
0
5 [报告]
发表于 2008-10-31 17:21 |只看该作者
引脚中断号是我的习惯说法,
在内核中,每个架构都有一个中断的结构体数组,irq_desc[]
上面说的中断号 就是那数组的下标,
前面32个分给aic了所以引脚中断被分在紧跟aic在后面,
每个结构体包含对应中断的详细信息如下:
struct irq_desc {
        irq_flow_handler_t        handle_irq;
        struct irq_chip                *chip;
        struct msi_desc                *msi_desc;
        void                        *handler_data;
        void                        *chip_data;
        struct irqaction        *action;        /* IRQ action list */
        unsigned int                status;                /* IRQ status */

        unsigned int                depth;                /* nested irq disables */
        unsigned int                wake_depth;        /* nested wake enables */
        unsigned int                irq_count;        /* For detecting broken IRQs */
        unsigned int                irqs_unhandled;
        unsigned long                last_unhandled;        /* Aging timer for unhandled count */
        spinlock_t                lock;
#ifdef CONFIG_SMP
        cpumask_t                affinity;
        unsigned int                cpu;
#endif
#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
        cpumask_t                pending_mask;
#endif
#ifdef CONFIG_PROC_FS
        struct proc_dir_entry        *dir;
#endif
        const char                *name;
} ____cacheline_internodealigned_in_smp;
这样,当分配中断服务程序等操作,就可以通过操作以上结果体数组完成。

[ 本帖最后由 gbc737 于 2008-10-31 17:24 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP