|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& |3 C8 w( @$ t% w' t- ?
#include <linux/init.h>7 P1 b* S' y8 N) H
#include <linux/module.h># @! |5 j9 S6 t' Y
#include <linux/kernel.h>
3 z' a: y! }1 Y V- e3 E; ]6 A" s#include <linux/types.h>3 _2 |- n3 T: g" q2 ~- e
#include <linux/gpio.h>
% O* M2 A- n( U, ]#include <linux/leds.h>
8 D% x3 s6 \# \7 z; n3 n" h& V#include <linux/platform_device.h>
: }& e6 T& |# M: D0 M/ ^( y, H# R* N8 W! L9 H
#include <asm/mach-types.h>- l6 I8 W B1 E- [3 u* u7 k& w) q; }
#include <asm/mach/arch.h>, J% F( {: I( \2 E! S: \# q
#include <mach/da8xx.h>+ W# } L( a: H2 H# {+ P
#include <mach/mux.h>8 @/ Y4 H- y1 A
: q1 b) m, D$ N; S: Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 \& U- l3 A; \, H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% q( b4 o- V2 Y E( P5 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' ~0 f, w- z# X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 Q' ?/ E, Z1 C: `
$ P# U+ P- X( b8 h5 A* a
/* assign the tl som board LED-GPIOs*/
9 q" f+ w* h. Estatic const short da850_evm_tl_user_led_pins[] = {
$ k: V7 r" t! W$ W /* These pins are definition at <mach/mux.h> file */
5 I( ]1 L% \4 X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 E0 b/ W1 }& `5 M -1
9 C1 V8 P* p4 M+ ~- X) _};
5 N1 h2 N4 i- k' c, X
0 _" q; \) j1 Q% Y9 n! w y J: x+ [static struct gpio_led da850_evm_tl_leds[] = {
9 y+ P+ m2 o2 f% a/ f% c {
# V, ]* t4 A+ S+ E8 J .active_low = 0,: F" H: [" R# g. I
.gpio = DA850_USER_LED0,
7 \: r# v0 g1 B9 | .name = "user_led0",
1 w6 c# r4 p) v+ y6 m7 ] .default_trigger = "default-on",1 ^2 P* g3 C8 @ k6 Q
},, @: i( x. H5 s9 c+ y- N" A
{! w4 c/ ?$ Y, Y% m, G F
.active_low = 0,5 t* q8 v# W4 M! Z6 x
.gpio = DA850_USER_LED1,% n, I5 D- j' ~+ A+ a
.name = "user_led1",
6 Y' G; K/ I: u+ n: } ?: B# p .default_trigger = "default-on",+ Z( E5 N2 s* Y" @/ c8 ?" M
},
) r- z% m% D! s- C e {& _# a9 {% W" h' n
.active_low = 0,; {* m V/ e4 z% o
.gpio = DA850_USER_LED2,
; h3 G' f( v7 s `. [ .name = "user_led2",/ D% L$ U8 q% Z7 c- g
.default_trigger = "default-on",
/ M, G/ f; T8 e' Z },
9 R7 }9 q7 R/ {) d) s$ X" ^( z8 i. H {
* a: U4 H# F3 P& _1 s .active_low = 0,
% G1 X9 s9 ~) y, _/ _ y" o) D .gpio = DA850_USER_LED3,5 m* V( p$ ]3 C2 D/ I$ W' r1 Q
.name = "user_led3",
$ | |# F. ^; A+ D9 X .default_trigger = "default-on",
' a: ]/ r8 C) a! _) | `- Q },
) y7 z. q. ~% {, K; j7 V};
& _, i" j+ v- h# c/ E1 B" q, b
. u1 Y' N5 W6 G6 L( G4 ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) b5 H' b% y/ B! U( F .leds = da850_evm_tl_leds,
Q/ A+ W: l! w+ W$ N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 m3 p6 l6 K- @ i+ o6 z3 w
};4 \9 Y' r+ f+ I. l3 O
' f9 M, J! @1 `. H9 ~
static void led_dev_release(struct device *dev)
. Q5 e! F9 v" I+ @4 R{
! N" Z, p( ` v* I( {/ f/ i8 P};. u7 e1 G2 }5 \1 S
! J p& p* y8 Jstatic struct platform_device da850_evm_tl_leds_device = {1 x6 U) `4 q$ D0 M
.name = "leds-gpio",4 S$ I! j* U \# L
.id = 1,
) f; c+ b/ w3 f7 o2 z .dev = {# ]0 z3 B% c. v/ ?
.platform_data = &da850_evm_tl_leds_pdata,# {0 X" j$ U3 k ^- e
.release = led_dev_release,
/ d4 R; G9 s8 y) \5 g }: e+ D. ^* I. r
};
, P: P, u# v9 w* U. H0 I- F, _4 ~! r2 O6 K" y5 m, {) A& S
static int __init led_platform_init(void)$ j" |6 R! y+ ]! y: O' t' ^8 e
{
; L2 n' I E2 k0 }* E. k+ c v int ret;
- ^/ S# x3 p! w2 t; k4 U#if 0
9 X9 S3 V6 _9 L5 Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; @! p8 V1 l! J+ w3 B0 h7 `7 i/ d if (ret)
7 W! a/ b1 ]! p5 K) Y3 \5 [" Z/ s1 ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) k/ L2 w5 y: h2 k( ?5 W$ C& w+ _ "%d\n", ret);+ _# }( O9 t5 C" T* |/ x- ^
#endif( o& U3 c0 |+ q% h
ret = platform_device_register(&da850_evm_tl_leds_device);
; ]8 _, a% v! c2 c! ~0 V3 O [' ` if (ret)% o7 W5 @) L5 [5 n$ l
pr_warning("Could not register som GPIO expander LEDS");: x- |6 r/ b5 B+ P8 i
else9 W7 Z1 s$ u. F/ R
printk(KERN_INFO "LED register sucessful!\n");
( a+ {" \3 R0 I% o5 s. J3 Q$ ^! K+ u/ e- T8 N/ F
return ret;
$ x( n9 r* {! e5 G}
' N2 {* h# r7 Y( @2 r; T2 h0 q
& }' a4 R- i7 M$ O$ {- rstatic void __exit led_platform_exit(void): { w6 V1 Y- d4 M# o$ A3 K
{
, {4 R9 @! O+ ]6 F platform_device_unregister(&da850_evm_tl_leds_device);
6 a+ D8 T' h I$ M8 K6 O
9 _: w1 t+ T1 q; p" s9 O* h printk(KERN_INFO "LED unregister!\n");
" V. J! J3 N- R9 G& h}
" x C2 A- `) ~% ]+ ?# X- n& B$ m: a9 y4 B, r) Q. [
module_init(led_platform_init);9 l1 ?# [* G7 ]7 h3 Y" K) D
module_exit(led_platform_exit);# ?6 J2 D! O! Z" ?7 I' a: E5 X
1 U9 l W3 j/ @( Q. i9 O( WMODULE_DESCRIPTION("Led platform driver");5 V1 Q' y7 u: ^
MODULE_AUTHOR("Tronlong");- q/ S" s& @% p" S
MODULE_LICENSE("GPL");3 Y- ~# a" H! b6 M1 L; }; X( ~; _
7 n9 ^ m3 y L3 x
|
|