|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 N, D) `* v- |& I& ?, M$ o#include <linux/init.h>4 W5 C. c. y- y* t# J5 W8 r: e
#include <linux/module.h>+ a, ?+ t& K/ e0 s! a U
#include <linux/kernel.h>4 u1 X0 V( M. M2 k& Y+ X
#include <linux/types.h>
" n* e4 s& w2 r7 P: o#include <linux/gpio.h>* l, y& l+ ]% e6 P
#include <linux/leds.h>
6 C/ W( C9 T5 g" x7 ?$ X#include <linux/platform_device.h>
: Y- L3 }( R: l+ j( \
; o+ d* i. ~" g" e#include <asm/mach-types.h>
" |! [# P" Q6 \$ d, _" U#include <asm/mach/arch.h>
0 x. G) e4 n0 H$ e! U6 a% O! A#include <mach/da8xx.h>0 U% }& {% g# T
#include <mach/mux.h>9 Y- A/ n/ i! u
$ R. T3 t8 c# O2 _' j& I$ q; E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! |7 j9 U0 t8 D6 a- j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% d% N2 H# g' W0 C4 h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 R: @% I2 i4 O0 _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( T. E2 O K4 r2 O" j: T5 z9 ]; y
4 d1 ~9 J& J. S" R# m/* assign the tl som board LED-GPIOs*/% p3 D4 d- }- t1 r" G9 V S* e6 Y
static const short da850_evm_tl_user_led_pins[] = {
) [/ X9 n- A: k% P, w* W. H /* These pins are definition at <mach/mux.h> file */9 A( ^# ]7 F% ^1 p# F9 ~4 p5 K1 ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 O& g% P8 A- S -1
- A5 z$ c0 ^$ t* c( D* V0 _# Z};
: L6 H, y, X) ^ i0 i* Q- C& o0 W# F& w2 x# a& x
static struct gpio_led da850_evm_tl_leds[] = {4 `1 x* h5 r* _. z
{
( n% D( j1 @& s5 Y: c7 g .active_low = 0,
5 x' V8 p# e$ h& D& Z8 `8 o- s8 Q .gpio = DA850_USER_LED0,7 N" i i. t( D
.name = "user_led0",
8 f2 Z: j1 h/ q, V: @( I% T: x: i- ^ .default_trigger = "default-on",
$ k+ q. ^; V7 L3 @5 x. q: \ },
2 D$ ^0 G$ S, o5 ], ^ {
9 ]3 m9 a; a* m, C7 _+ T, B' ` .active_low = 0,) ]7 ~ {; ^9 n4 {
.gpio = DA850_USER_LED1,
/ x5 i( K$ @1 O0 c' S# T, q3 ` .name = "user_led1",# a0 f( p( T4 I4 R0 Z& O9 Q1 X: O
.default_trigger = "default-on",
2 P. F- y" l" N/ b },
4 E' F `) C2 h {0 B, J+ K9 b) p4 m: s
.active_low = 0,) Y% n/ I2 r" t+ ~; ~2 T% j% X
.gpio = DA850_USER_LED2, r; e' _9 t* c/ s/ ~7 L; Z
.name = "user_led2",; k- z: ~; L1 S c( q! D" p
.default_trigger = "default-on",2 Q, P/ I( ], B( {- E; T
},9 s9 R6 Z* O6 |1 k: \( F/ {/ x* ?
{6 P, t C( m4 T& e1 q; N1 E
.active_low = 0,2 `& N( s/ D! u% N, z
.gpio = DA850_USER_LED3,( l5 g3 D4 \* ^
.name = "user_led3",
% J# r/ z( y* {& B .default_trigger = "default-on",
7 {1 |3 w9 E! x& s, t" M) Z9 q },
( Z- O: W( m3 P h0 J};( P4 Z) T D5 @! H2 _
; h! d8 w8 ]/ _- K6 X2 W: [3 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; L7 z8 P5 ~# W/ u+ f7 L: a .leds = da850_evm_tl_leds,
# _9 @& U* A" k& T. Z/ o$ A( D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 J" q6 v4 j; H0 v# [. p* f};
) `7 {; R' F, c) d! \6 T! {) _# a) S" c! Z9 ~% |
static void led_dev_release(struct device *dev)
" `/ g# P; f0 T: R: V+ ~- a{- `! R: D4 B6 _6 |6 k. N$ ]
};
& m" h& S( }( P5 j
' Y T$ C# K0 |static struct platform_device da850_evm_tl_leds_device = {
! l& ?+ Y/ D l. @ .name = "leds-gpio",
/ K, m+ K0 A, L .id = 1,
D: i" ^( N: K" B' l9 N" l! P .dev = {9 a7 q% x2 I& G4 v0 d, P
.platform_data = &da850_evm_tl_leds_pdata,
- o$ b; V& @: A$ O p .release = led_dev_release, j( P. v/ @8 ]. H1 k
}* I; h1 c$ m: F% x# D9 w0 l
};" g1 Q; x: m7 I) q. F5 h. A
" Z( M) r5 a& r
static int __init led_platform_init(void), [$ l. H: O7 p$ N( N# V6 M) B/ A
{
$ U6 J- D ?* W( D% \, B int ret;
7 m1 v, P& {3 u- T+ P. \ l& V#if 09 ]) A. b) @4 J4 N2 C; k& \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: U! _. ?1 K; C e
if (ret)
8 }; Z/ d5 |3 `( A8 [4 N6 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' F* v' g, G8 U2 u( R/ L "%d\n", ret);7 s2 Z- V: o! p( w$ {- {
#endif
& G, ?0 c" k& G ret = platform_device_register(&da850_evm_tl_leds_device);
- q* s: r5 @; L8 W1 m# d if (ret)/ Y+ x# [: _/ z* R
pr_warning("Could not register som GPIO expander LEDS"); F+ A& l% e4 \6 ~5 r: ]) _3 x
else
* b1 v3 E7 g( e2 u! C' G printk(KERN_INFO "LED register sucessful!\n");/ _. a( U' e( J9 i% f
) C9 T/ }( p' Y; J; P
return ret;
' t* T) V3 R# N+ P0 ^9 N}
1 j7 q$ J" p2 r1 ?
9 b- y6 n2 B& bstatic void __exit led_platform_exit(void)( B. l( |' h) j! z' ?- s$ `3 l
{, R3 z; M- A4 E0 k: `( j0 h/ s1 ]
platform_device_unregister(&da850_evm_tl_leds_device);
2 W) L a, H. @9 {6 }
' x) C4 @% H/ { printk(KERN_INFO "LED unregister!\n");
2 g6 v+ n& ?, T% q}
' f3 X$ N8 @3 L
- K' s# j; A4 l; A0 Z0 m+ umodule_init(led_platform_init);/ j+ y: c" H8 V6 Q U, s
module_exit(led_platform_exit);+ f" p4 ~$ X5 ~* j- A
6 r$ {7 \* X, }7 ?9 q
MODULE_DESCRIPTION("Led platform driver");
, t; {6 g( k% O& v3 r7 d- o! rMODULE_AUTHOR("Tronlong");! j) ` y+ u$ h5 s0 y
MODULE_LICENSE("GPL");
4 l4 K$ I2 l9 Q& M* T9 A5 [: y, @- F! e- o
|
|