|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 S# g3 I3 w2 B9 l+ j( L4 }3 V j#include <linux/init.h>- b3 ?; f; v7 `# s. C
#include <linux/module.h>
! x( m. _0 f+ ]+ l+ t#include <linux/kernel.h>
, m4 w/ f0 q2 V#include <linux/types.h>
! D9 O4 g; S) X% K( V#include <linux/gpio.h>: y: }. g2 G( y1 O# c+ ?
#include <linux/leds.h>, Q$ S6 d( M% i6 l7 z r
#include <linux/platform_device.h>6 d3 T- E, V5 I
, I K: F: L$ G& b5 T5 y#include <asm/mach-types.h>7 o) o3 n$ y$ T' C' ^5 W) f+ E7 R, A
#include <asm/mach/arch.h>
, D9 {- }8 A: S, O* a# A8 X#include <mach/da8xx.h>
* C' S9 R/ @/ j1 t6 Z#include <mach/mux.h>
' u! C1 U' e+ a9 {; z; I, K" D
' y) f( _9 ?- ]9 m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! F: Q3 ?- O3 H$ |$ U/ |4 o' s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): v2 ^; ~. X' ]# |6 k: f3 k/ ]3 K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): ^1 u$ d, E O3 X- Q9 ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" l) l6 b+ ?/ Q* M7 \* S
" ]0 X- _$ h3 j( q1 D/* assign the tl som board LED-GPIOs*/1 `. ^, ~' F1 u2 l
static const short da850_evm_tl_user_led_pins[] = {
. E9 q. x* ?* T. h /* These pins are definition at <mach/mux.h> file */; c, a- r$ C+ S$ \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 Y: y# n5 r3 n- W) ]+ G; Y
-1
$ F) ?, t% W7 r$ i$ U& K};
5 Y' d( K1 k. x( W% y _' J& b
static struct gpio_led da850_evm_tl_leds[] = {$ l/ X! h+ u$ e! s1 j$ w
{
. E& T. t! x' }6 b+ i4 V5 O$ J1 N+ G6 e .active_low = 0,! _; T! r6 P `; H& m
.gpio = DA850_USER_LED0,6 y6 b7 }; i6 z
.name = "user_led0",
1 t( o" J3 c7 ` F% [ .default_trigger = "default-on",
# U. q4 V5 K2 E },
3 d1 l3 Y" m, l6 C( R {5 {; S, Q9 p; ?/ U- S1 V5 R; u
.active_low = 0,
* f) d& y0 Z* s9 t( B& h! u/ {+ p .gpio = DA850_USER_LED1,
0 i% Y6 U8 a6 y `- F .name = "user_led1",
3 c: G0 ]' }1 _7 z4 J8 r5 i .default_trigger = "default-on",
( D/ L. ?1 _$ x% q },# [" ~, D$ q) @
{
0 |% w% Q4 ^: X, N9 x; t* i; {* o .active_low = 0,
! E2 e8 s( a. N% ^ .gpio = DA850_USER_LED2,
o6 b4 E, Z* y* s4 V& f% Q, ~ .name = "user_led2",' e; ?5 P. ?% Q/ e) ]* I. ^$ o2 p
.default_trigger = "default-on",. A) O0 f; b/ [5 `. U
},, b) n" u! _2 E
{/ A7 H, U) f4 c
.active_low = 0,
3 c$ o @$ G8 n .gpio = DA850_USER_LED3,( g+ n, y: Y+ u& `6 W# z
.name = "user_led3",
! W! C% Q, `1 E* g .default_trigger = "default-on",
6 d: b$ y' A8 K- b) M },/ @( |+ `! x$ q# B* e* U. V
};
5 ^+ ]7 P. {& S/ A, f9 m/ e' G
- r" [3 ]9 l* V& z. {% R+ t ^5 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 j2 I7 A s+ ` .leds = da850_evm_tl_leds,
$ E$ u) o/ E7 H. V- O: ~* b# ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& M3 a9 w5 P1 {; f# F0 p& {
};) }* n Q1 \' c' S
1 h! C7 u# G" Y5 D
static void led_dev_release(struct device *dev)
& K; [, r V, M1 ~6 |{$ {5 G& Q# R* ~) F$ W+ A
};: O+ I1 B& w, ? M. n" m6 { P0 C9 V
, | ^. @6 b2 A/ L3 Q4 i0 qstatic struct platform_device da850_evm_tl_leds_device = {
1 r C- ]8 V' H$ V) `: ?7 Y .name = "leds-gpio",! x9 m8 J0 s/ o
.id = 1,
$ Q `. w8 ?* f+ G: c9 l) i) r% Z .dev = {, o7 e, t. ~) O8 Q, r/ ?7 Y5 E
.platform_data = &da850_evm_tl_leds_pdata," b) U4 p+ n% L: b5 N9 {0 \ r
.release = led_dev_release,
# y4 O6 ~/ J+ u+ z6 S( ^ }
/ k5 D+ y) P2 x0 E) r& z};' r; b) @, ^; B5 \% V, \
7 q; P* f) a8 _: x3 T4 Jstatic int __init led_platform_init(void). c2 y9 d T$ e+ x
{1 H1 _9 [4 K. A3 W
int ret;
- F- w7 [/ Z4 W# X, `) g( n( ^8 w! P#if 0
) Z6 C- E4 D7 w5 d5 T$ _0 }7 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' U1 r/ [( O" T0 g7 L
if (ret)2 {) X* k1 n! K& T: v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 H1 r% S ^9 U# D- ]' O "%d\n", ret);+ T: |0 k- F9 @% k! L( X
#endif$ Z1 t7 e! p$ Z0 U, K9 f
ret = platform_device_register(&da850_evm_tl_leds_device);
: \" Z- D F1 w4 q2 J9 i! ] if (ret)+ A& I4 n* D" y3 y
pr_warning("Could not register som GPIO expander LEDS");
8 }. [& z/ J: a else9 o! C! e1 c0 x4 T
printk(KERN_INFO "LED register sucessful!\n");9 v# e6 D# M+ ?$ ^5 F2 m
" K% q' [1 @! p* M# y' Y return ret;
% s0 i6 h9 I3 F" k}. W! p3 ^; e' a' r C
$ x4 l# s4 j, X: o4 c( w/ e
static void __exit led_platform_exit(void)# h; ^: s8 i! [* x. @) h
{6 s4 y1 ^9 Q1 F
platform_device_unregister(&da850_evm_tl_leds_device);5 n1 z# q5 _: K
6 z& R# s4 e* |& W$ L printk(KERN_INFO "LED unregister!\n");& @ C/ o* ?+ m3 O- X. n/ A
}
! z' o$ v% u& l+ ?6 y' W! t. I1 h! Y- N7 z$ o
module_init(led_platform_init);
+ l v3 N. a7 Mmodule_exit(led_platform_exit);0 m: ^. i1 b Q" G! b/ _
6 t" L3 d- c5 ]- V- z. C4 ?* fMODULE_DESCRIPTION("Led platform driver");
* n' W3 j2 y. p8 vMODULE_AUTHOR("Tronlong");
, R( S- r8 c: m; H7 k1 \( T: |MODULE_LICENSE("GPL");4 c7 s" n! E' Y* I
1 s# Z/ c1 v' u) b) R |
|