|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 v1 b1 q3 }# E+ u! B+ h#include <linux/init.h>( h) _) V: N0 O: m
#include <linux/module.h>% }* Y) Z0 o6 P# G
#include <linux/kernel.h># o: ^: w# j/ {' M; E- D
#include <linux/types.h>4 I2 t6 F% J3 J# L" f( R$ x
#include <linux/gpio.h>: P% W" Y% n; O% f* K
#include <linux/leds.h>2 q L% B9 R/ S9 G8 x! t& }
#include <linux/platform_device.h>
- U+ Y) i' A+ W; y6 S" |/ c8 G
% t. }. X# N+ }' k( R#include <asm/mach-types.h>! e/ s; Z9 s8 K# e# S
#include <asm/mach/arch.h>
% w- t/ v1 s( j% r0 V' a- ]#include <mach/da8xx.h>
8 t4 e* o9 l( G7 x4 a#include <mach/mux.h>
, X! o8 d! K: e; n; h+ U; B9 g. f0 w& A- X w+ J) Z9 J- ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 p+ F3 Y. u5 T- ]1 U4 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! @; ?; u) }4 u7 @' ?$ j% `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% {2 Q/ ^' T+ p5 M/ t4 Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 P" g6 @6 |( b2 d* E
0 C) B* q% T" j: x. |7 k) j' l/* assign the tl som board LED-GPIOs*/
2 L- W% f: g( C _/ B* Ostatic const short da850_evm_tl_user_led_pins[] = {
* J- h: A) P4 q. V /* These pins are definition at <mach/mux.h> file */
, ~$ K! _ l+ G: F4 s& C6 ]! p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 a: ]" J/ w1 X, U& ] -1
0 F9 ]/ s0 l$ w9 }};4 q1 [2 `% |3 N# h7 N
: f, S. n$ r0 r3 B3 t0 ?' fstatic struct gpio_led da850_evm_tl_leds[] = {, m/ i( _3 |) J0 c5 Y
{
! ?$ K. ` ^9 i6 I( P' h .active_low = 0,
, e, W" T6 @* q" C6 e .gpio = DA850_USER_LED0,; a/ Y: H- e; r w) o x9 u% I
.name = "user_led0",3 h% ~7 m$ @+ y# S: D
.default_trigger = "default-on",
0 d& G ?, P( R },
" N5 q& ]3 F5 Y, m. d. E. E {
1 E; K9 e: r0 L8 a .active_low = 0,/ I7 v; K* v! ^! |' V
.gpio = DA850_USER_LED1,6 k1 P. l1 o9 y
.name = "user_led1",/ u. E" \# b8 Z; i6 M8 u) B+ B
.default_trigger = "default-on",
* K2 d; }: q& n6 q1 j% L8 ^, ?$ ?; y" R },
1 M8 E5 S- I! o7 v2 b$ ^ {
, E; @6 M8 G. ~9 M0 l8 @+ k .active_low = 0,+ Q! w" s# b; s: |" x
.gpio = DA850_USER_LED2,
/ N" m" C. o* m } .name = "user_led2", }# I4 O9 p$ g4 y3 e
.default_trigger = "default-on",
( X9 Y2 h* f" C- _ },$ m1 B; Z) `# w3 D) m7 _/ ~# e
{
2 P/ V2 R/ @8 L( Q8 U+ s5 M% ]4 n .active_low = 0,
& E4 J0 C) T4 P% J: j; a% t$ K .gpio = DA850_USER_LED3,
/ ?. W+ x h" h- g .name = "user_led3",2 M: A1 y/ u2 E% F
.default_trigger = "default-on",; V5 B2 D2 S9 o0 R8 Z# u
},
- ?/ g/ l1 p9 C};+ Q+ F# \; ~$ Y# g; H$ U' x# @
! E- k! Z0 @! q% B- s" a" vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; ^0 f( k! n' s .leds = da850_evm_tl_leds,
8 G0 W; L, l% _9 ?, G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 d( [" ]! l3 Y4 g* |( a9 K4 r1 d7 p};2 V. b9 d. F' Y0 U' C
; s2 Y; I* h2 |9 rstatic void led_dev_release(struct device *dev)
: y" f3 v* j0 C: I% u{
9 k R. B0 Q, Y* P4 v% R4 b};
5 v1 r: v* L+ |- g! {4 C9 @8 ^, Q. ]0 g
static struct platform_device da850_evm_tl_leds_device = {* t0 y N$ R8 {9 e4 s
.name = "leds-gpio",
# u4 z8 S0 O. U .id = 1,' _% U1 r4 j& u1 O
.dev = {
- \. b9 U; ^. x6 \1 s9 O- L# } .platform_data = &da850_evm_tl_leds_pdata,
9 _+ c9 W7 Y- a" Y' `2 [ .release = led_dev_release,: C5 t. x( Y& R! Y& v l4 {7 J h* ]
}
- w0 N: b( e P) S8 v};
1 ~9 y( b- F! `0 y P* g0 ]9 D4 b: M0 V# K
static int __init led_platform_init(void)
3 Z+ |9 Z# g+ g; |' }; x{
7 t6 p0 o# |( n$ b- p7 {4 B int ret;
! ?9 _) G+ N: a4 i1 q& T u+ a#if 0: n' U7 d ]0 T* n1 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: G D7 N( U+ |
if (ret)
( l# j. c4 f0 u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
\. P+ k i: I+ V' y# h "%d\n", ret);
! c& x- S/ a- b% T9 m#endif
# J* j# v( M4 F. X Z ret = platform_device_register(&da850_evm_tl_leds_device);1 K$ |5 f' X+ x$ C
if (ret)( q7 D/ q% J% c5 l
pr_warning("Could not register som GPIO expander LEDS");7 X) A k' ?$ |6 w& a
else
) C9 x7 y4 Z2 f3 P; q printk(KERN_INFO "LED register sucessful!\n");
1 p2 I( `6 O( s% ^8 W( T& k$ _* O
$ H: M! f3 U9 U! Q! `5 h return ret;& H& y8 G6 w3 [5 ^9 |/ P& I" `9 A- _
}
! z6 r6 _" T M5 T) d% A1 F3 @) K
3 A( r, B( |6 Q3 ustatic void __exit led_platform_exit(void)
1 o8 F* v. m( [! E" f{5 O) C* P8 Z+ ?3 G" B' G
platform_device_unregister(&da850_evm_tl_leds_device);
$ O9 s1 r/ `; \
9 { j0 E1 m5 r, u1 I printk(KERN_INFO "LED unregister!\n");
- D" u, n' i9 r! N}; c& ]% y' m1 T6 C" F
# w# i$ |7 c* Q% o' \. mmodule_init(led_platform_init);
8 e9 B4 b9 D5 a0 W6 X0 g7 Zmodule_exit(led_platform_exit);
7 [9 x$ l) y! d+ K6 C; F
. \; c0 t$ {% R* h% zMODULE_DESCRIPTION("Led platform driver");7 g7 ~, C/ O [: |/ z& I3 ]
MODULE_AUTHOR("Tronlong");
/ U0 T: x1 H, j( R7 aMODULE_LICENSE("GPL");: m8 U- C9 E. G2 ]% y8 n
m2 ~% P1 }# i4 K0 g
|
|