leds.c
来自「优龙2410linux2.6.8内核源代码」· C语言 代码 · 共 161 行
C
161 行
/* * LED driver for the Atmel AT91RM9200 Development Kit. * * (c) SAN People (Pty) Ltd * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version.*/#include <linux/compiler.h>#include <linux/init.h>#include <asm/leds.h>#include <asm/io.h>#include <asm/mach-types.h>#include <asm/system.h>#include <asm/arch/regs-gpio.h>static inline void at91_led_on(void){// printk("led on\n"); __raw_writel(__raw_readl(S3C2410_GPBDAT)&~(3<<5), S3C2410_GPBDAT); __raw_writel(__raw_readl(S3C2410_GPFDAT)&~(0xf<<4), S3C2410_GPFDAT);}static inline void at91_led_off(void){// printk("led off\n"); __raw_writel(__raw_readl(S3C2410_GPBDAT)|(3<<5), S3C2410_GPBDAT); __raw_writel(__raw_readl(S3C2410_GPFDAT)|(0xf<<4), S3C2410_GPFDAT);}static inline void at91_led_toggle(void){// printk("t"); __raw_writel(__raw_readl(S3C2410_GPBDAT)^(1<<5), S3C2410_GPBDAT);}static inline void at91_busy_led_on(void){ __raw_writel(__raw_readl(S3C2410_GPBDAT)&~(1<<6), S3C2410_GPBDAT);}static inline void at91_busy_led_off(void){ __raw_writel(__raw_readl(S3C2410_GPBDAT)|(1<<6), S3C2410_GPBDAT);}static inline void red_led_on(void){ __raw_writel(__raw_readl(S3C2410_GPFDAT)&~(1<<4), S3C2410_GPFDAT);}static inline void red_led_off(void){ __raw_writel(__raw_readl(S3C2410_GPFDAT)|(1<<4), S3C2410_GPFDAT);}static inline void green_led_on(void){ __raw_writel(__raw_readl(S3C2410_GPFDAT)&~(1<<5), S3C2410_GPFDAT);}static inline void green_led_off(void){ __raw_writel(__raw_readl(S3C2410_GPFDAT)|(1<<5), S3C2410_GPFDAT);}static inline void blue_led_on(void){ __raw_writel(__raw_readl(S3C2410_GPFDAT)&~(1<<6), S3C2410_GPFDAT);}static inline void blue_led_off(void){ __raw_writel(__raw_readl(S3C2410_GPFDAT)|(1<<6), S3C2410_GPFDAT);}/* * Handle LED events. */static void at91rm9200dk_leds_event(led_event_t evt){ unsigned long flags; local_irq_save(flags); switch(evt) { case led_start: /* System startup */ //at91_led_on(); at91_led_off(); break; case led_stop: /* System stop / suspend */ at91_led_off(); break;#ifdef CONFIG_LEDS_TIMER case led_timer: /* Every 50 timer ticks */ at91_led_toggle(); break;#endif#ifdef CONFIG_LEDS_CPU case led_idle_start: /* Entering idle state */ at91_busy_led_off(); break; case led_idle_end: /* Exit idle state */ at91_busy_led_on(); break;#endif case led_red_on: red_led_on(); break; case led_red_off: red_led_off(); break; case led_green_on: green_led_on(); break; case led_green_off: green_led_off(); break; case led_blue_on: blue_led_on(); break; case led_blue_off: blue_led_off(); break; default: break; } local_irq_restore(flags);}static int __init leds_init(void){ /* Enable PIO to access the LEDs */ __raw_writel(__raw_readl(S3C2410_GPBCON)&~(0xf<<10), S3C2410_GPBCON); __raw_writel(__raw_readl(S3C2410_GPBCON)|(0x5<<10), S3C2410_GPBCON); __raw_writel(__raw_readl(S3C2410_GPFCON)&~(0xff<<8), S3C2410_GPFCON); __raw_writel(__raw_readl(S3C2410_GPFCON)|(0x55<<8), S3C2410_GPFCON);// printk("led init\n"); leds_event = at91rm9200dk_leds_event; leds_event(led_start); return 0;}core_initcall(leds_init);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?