|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* X3 Y. ~; }2 C e#include <linux/init.h>
/ @, F1 c# k8 e0 w0 `# Y/ x#include <linux/module.h>
( m; j3 o! Y, x" n `" R#include <linux/kernel.h>3 j6 E% s9 v7 g! @! T9 Y( G5 @
#include <linux/types.h>% x# G5 f. N+ F H
#include <linux/gpio.h>: k4 {4 c% c, n7 D) j( M& r
#include <linux/leds.h>
1 R% u) `" R5 a7 Q: D4 |#include <linux/platform_device.h>. M6 B$ S3 e/ n, `6 ^; H
. \+ r5 o, _1 r' d7 D; |1 z, E
#include <asm/mach-types.h>
. x3 B b* f5 q#include <asm/mach/arch.h>7 |- U& ~/ S/ k0 g( \1 f) T
#include <mach/da8xx.h>
9 V2 ^2 U Q- J/ y! I& t3 ~( k#include <mach/mux.h>
2 |" c! f! }3 M9 y% M
; K E+ t) e `& m$ R+ S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, m4 X: V7 R& h; s5 `, P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ L& v" a7 P2 u* I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ W7 g: C$ d* f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
u; @ [9 G* r; V
; E3 D+ s, l' f4 Z! v/* assign the tl som board LED-GPIOs*/- {. ^& z0 m% ~/ \! R- ~) _
static const short da850_evm_tl_user_led_pins[] = {. N) V, p: q/ B2 N
/* These pins are definition at <mach/mux.h> file */
5 L ^. \) o9 F3 }, j8 p, Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# H0 e: A, J: t$ Q l5 _1 U- F# o -1
, V( Y" h& F" a2 o* F# y. o' R};. w" l% a+ c' T4 w$ s b4 d5 ]
# `( n, f% f3 |5 J* m7 k$ xstatic struct gpio_led da850_evm_tl_leds[] = {
# d# q* H6 Q6 z/ g. a2 Y7 W- u6 W {
5 r( m/ ?# N$ [1 H# h: \8 z .active_low = 0,
9 y7 d+ C5 R9 K3 @3 \3 [ .gpio = DA850_USER_LED0,/ w" b. `: ? h7 f
.name = "user_led0",5 v% x. Q6 a1 Y; u8 Y* E) h
.default_trigger = "default-on",# A9 C: F8 @+ K/ \! U! t
},; F# n/ G! q9 j2 B$ @) _! d
{" o- t8 X, \) P; m
.active_low = 0,8 o2 y* r3 Z) h
.gpio = DA850_USER_LED1,
$ a0 F- ^7 T8 l- {* Z# k .name = "user_led1",* e+ t. p6 s! l3 L$ r* N! Q
.default_trigger = "default-on",
% U4 d* S- J, L2 h) d },: ?: `9 I* _. A h4 }
{# }; I* u; a8 ?2 [8 b- u( M7 o0 k0 Y
.active_low = 0,9 N: k$ `% @. G9 ?0 z3 `: Z5 p% a
.gpio = DA850_USER_LED2,
H! N b r9 U8 b$ j% h .name = "user_led2",
1 y- L! W" k9 ~4 x .default_trigger = "default-on",) H y$ v0 ]4 s
},& a% K% W: n# [$ @
{5 Z6 b x, A, ]# n" y# R
.active_low = 0,
' a; a/ l" U5 r2 d0 W/ P" T G$ t9 X .gpio = DA850_USER_LED3," I x8 k+ B" ~) w
.name = "user_led3",. I4 T/ r! d- B4 d, }0 J6 m; l8 G
.default_trigger = "default-on",3 Y1 k5 B: _5 w/ t* g" I' R0 X
},
/ s6 V+ r, H% t! j4 j* Y3 L3 p! `& B};2 M4 I% u1 y+ b5 L1 w
# E1 `/ |& z+ J! ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: {! H* Q/ R; W8 \1 H. q; E. T .leds = da850_evm_tl_leds,+ i) r4 i- _8 V0 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& ~" [2 u6 U; a* J! y1 M};! a3 b: \5 C# b7 ]: W6 m
" S( L& c2 R3 r) ^ D* ?9 ustatic void led_dev_release(struct device *dev)* v5 {) e4 t0 o. S: P$ ? H4 C
{
3 d- Y/ q" [& S4 }& N2 i};
& ]( v% n1 e* _: d" J7 G8 X2 b- _$ B$ z/ q' J6 q
static struct platform_device da850_evm_tl_leds_device = {3 C$ N# ]" ?0 |$ T; Y) R* u. y
.name = "leds-gpio",, e6 {' u! l' U# G1 p
.id = 1,
, Y( V/ M# l9 H/ M% Z9 t1 \" Q .dev = {
. P4 N% B I! d/ N. [ .platform_data = &da850_evm_tl_leds_pdata,+ z2 S- A- w0 o4 w S
.release = led_dev_release,
( }$ }& Z% S @ }* C5 o6 ]3 L8 s) f% a3 q) i
};; `. e4 \+ L) b! W- z
; I$ }; \* C+ z `8 ]6 _
static int __init led_platform_init(void)
1 T( @3 }3 h/ ^% C5 }; w{1 W2 @- D V j4 @, z5 q' f
int ret;! }! C6 d; k2 }) a
#if 03 g$ N0 Z' E! c! F1 j3 W+ @! C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# W) s# n+ k. W6 m6 e
if (ret)2 R$ b q1 M% H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" Y1 V2 J) k3 n5 |( h) I9 Z
"%d\n", ret);
+ a( X0 m1 g6 k! {: [7 w. D6 @% k8 C#endif
: A4 y% g/ }6 x1 L ret = platform_device_register(&da850_evm_tl_leds_device);
y% ^" U- |$ }$ r' a6 C if (ret)6 s% ]& @% D( q4 L
pr_warning("Could not register som GPIO expander LEDS");
x) p; |' q7 |- A% k- z0 s5 u; G else
8 n. S* B9 i& {+ G2 v( _; @ printk(KERN_INFO "LED register sucessful!\n");
( R4 }) w! ^: u
. R9 k& {. }; T7 B return ret;
' G* Q& j* {9 A. f7 i, J% L}# Q; J' u2 `- a0 B0 J( C1 i
3 d8 c1 m, c, N- M# C7 x0 `static void __exit led_platform_exit(void)
1 T8 `! r1 p) B& J3 ?1 E( \& m! M{# L4 p" `3 D6 m" l' _
platform_device_unregister(&da850_evm_tl_leds_device); p5 @2 D, x& p
; L2 P1 L# U# q; s8 G( d8 f
printk(KERN_INFO "LED unregister!\n");
9 B" {5 W n/ h9 ^}9 Q2 S7 c7 x* L1 i1 m) U$ m
; Q" X, k0 s5 B; d. u9 w! Smodule_init(led_platform_init);
' Y, p0 b& P7 N9 w8 Z+ p) N4 H' rmodule_exit(led_platform_exit);( V- K( U- u7 Z2 d
1 v: L5 x/ M! U8 J* i3 n$ u
MODULE_DESCRIPTION("Led platform driver");
2 r) b7 G& i/ R# dMODULE_AUTHOR("Tronlong");
: E+ e# h$ P. e- lMODULE_LICENSE("GPL");
4 J0 Y5 |# S' w2 l& ^/ t9 `+ e
. R s& w8 @( s" Z- N' ]! J* X% @ |
|