|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) O3 C$ G. V4 z. g5 n+ ]: b#include <linux/init.h>
9 y6 r# ^/ O2 f9 ?" a#include <linux/module.h>6 \ q2 d% {. i% e# A/ r9 q
#include <linux/kernel.h>! ~ n2 n1 q& e
#include <linux/types.h>
9 ?/ U- Z6 R9 {! \/ A3 n#include <linux/gpio.h>3 ]) Q% X, g% E. }' T' M% |
#include <linux/leds.h>
- [+ C6 e* N+ U( A# z% k; n% v; c#include <linux/platform_device.h>
2 j S% v: a" g* R3 E% z O
* {! ]6 V# @6 t9 f#include <asm/mach-types.h>
* j) l/ B' s% g. J |; B$ c5 u#include <asm/mach/arch.h>
- h' T& j/ F$ {0 L, ]7 W9 G. j" P#include <mach/da8xx.h>4 M. _2 k6 [; Q8 C% f) M9 P
#include <mach/mux.h>
+ U7 J* {. X3 w$ s
$ O: j* {6 }8 J! l4 g( `: y& A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& @ l7 Q) v% Z- U$ F. Y& D# a
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 O9 w0 j8 x2 b0 W0 M& R0 F0 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ F# G7 x, T$ T( P) h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( e! Z) Y O2 t1 I @0 h0 P
2 b; o3 p7 d6 s) O4 j/* assign the tl som board LED-GPIOs*/7 a! _2 v+ O, V" w
static const short da850_evm_tl_user_led_pins[] = {
( k' m$ k( h$ z3 S4 d /* These pins are definition at <mach/mux.h> file */
$ n6 b$ |1 r- u* D" n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; E* m# f) B# l/ b4 N' r* P( c
-1
4 ^+ K) ~* B4 ]% A, Z};2 z3 r9 U, z) m4 k4 }! l$ L
$ y1 \6 f2 G/ {' U$ N% k
static struct gpio_led da850_evm_tl_leds[] = {
% {1 t+ J- y, P2 D* n) } {, {* w' e" T1 Y2 R% |
.active_low = 0,
& v" y5 [9 T/ b0 ] Z& U$ Y# o .gpio = DA850_USER_LED0,
- |" w0 b. b% ]) k, b& T8 O$ G9 i0 j .name = "user_led0",
, T+ W6 N$ V5 h' ]5 h& E .default_trigger = "default-on",9 I. M/ {/ ]1 i$ m9 `4 T
},
8 E/ b! m1 @+ J; c) E* I {
7 C( ^* \0 Y5 i4 s5 z .active_low = 0,
2 I0 e, h: s$ M5 x .gpio = DA850_USER_LED1,
8 _3 r. R( A% s0 J- J: ]' F t .name = "user_led1",
3 [4 h c& O4 B# R .default_trigger = "default-on",
: ^5 k' \" m/ N2 z },
0 {% H2 _3 C0 q# n4 }8 i* T' k9 n/ K {) Q. _- S, j- X0 t- t& s
.active_low = 0,
7 d# ^6 Q& L1 r T3 q) p) ~ .gpio = DA850_USER_LED2,
, D8 ]+ k" H- p .name = "user_led2",/ X1 c. @2 U w+ e0 o3 _ X: ?
.default_trigger = "default-on",# D" t, L$ s9 n; E- X
},( I3 R3 [9 W0 d- C
{; L- F/ v& t+ ^. \& P B3 I# d, x
.active_low = 0,
) j4 u9 f9 M ^+ a! B .gpio = DA850_USER_LED3,5 ~, z' s* V) C- B% Z- F
.name = "user_led3",, N/ X5 i2 { y/ `! N0 y1 B
.default_trigger = "default-on",
* x7 d8 V3 H7 l x* l w4 i },
7 r7 F; W+ T+ W6 y};
' H2 {: ~; f! |& B) T" a& R7 @
8 ~) J- Z7 x8 p# T* Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( }( R7 V& c2 d4 Y .leds = da850_evm_tl_leds,
. ^! \! t- |$ |1 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: V$ U7 h7 c9 C# Z
};( [4 a6 _+ H& X* ~
) P" X5 O4 ~# q! E8 T" e
static void led_dev_release(struct device *dev)9 u$ v" l: u q, D# s9 |
{
f" z8 e0 j- }2 M" z) A2 \! q};# n4 ]3 S. ?+ y( C6 a
( E i6 g/ }6 b ` rstatic struct platform_device da850_evm_tl_leds_device = {
0 M+ B" e" i( b& L d/ e7 o" @ .name = "leds-gpio",
5 c1 N, R3 M/ Q3 Y% c .id = 1,$ T& h2 l$ U- w0 I
.dev = {1 p* P7 \* K* Z
.platform_data = &da850_evm_tl_leds_pdata," a0 U! k' X3 y& N
.release = led_dev_release,; Z% O: ^3 l# N, @5 x6 s
}
. X6 X: e! G1 K! y; e6 M};9 X" U* }( E' U7 A* H) P$ C
' n0 ]4 T, X: T9 ~6 h. m# S% `8 o
static int __init led_platform_init(void)/ `5 u) x+ J1 B9 {) D
{
$ |6 h. A' j6 I& s' F4 g. T; B int ret;7 j$ Z2 P7 E0 b) d) s/ e
#if 0; P: }+ K7 f1 L: F! b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! |. a0 m+ @3 G$ x% | if (ret)& v; x6 J$ z& Z! n7 n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 n* I# R3 {% `- x
"%d\n", ret);: t' g" W) i5 l
#endif0 u/ l) \1 v& F. S O" B
ret = platform_device_register(&da850_evm_tl_leds_device);3 ^+ q9 r0 k9 M' a8 p7 t
if (ret)$ W ]1 T7 @5 u5 \( S; I: D
pr_warning("Could not register som GPIO expander LEDS");+ ^5 ?; ~7 |: K
else V( k; ^1 ~+ e) P) `0 V
printk(KERN_INFO "LED register sucessful!\n");
7 U' Y H7 \: N6 B5 k9 e; G
2 V. |' y4 @' r4 s3 |* W return ret;
7 B W! [- M! ?/ ~6 H/ K/ o}, n8 {4 @' |# c& h. {9 b5 F7 g
) U; f" b. ~4 @: R
static void __exit led_platform_exit(void)
6 ~( J+ i% x( h$ R" m$ D{6 K5 L4 n3 |7 w8 E9 [. j
platform_device_unregister(&da850_evm_tl_leds_device);
7 I r9 M t8 X
# x4 Y' y6 R2 ^; ?& C U printk(KERN_INFO "LED unregister!\n");
) ]' {6 c+ F2 u5 s7 M0 J; d/ H}% K2 d/ ~/ L; W' T3 u7 d
$ W: s5 R1 w1 t" ^
module_init(led_platform_init);
1 h+ ?; P" b8 F8 h1 S1 ?+ J% ]% Tmodule_exit(led_platform_exit);
; y/ @9 ^1 S( s! {8 L7 u
) T! {6 X% F' [" s( `$ l. q& {MODULE_DESCRIPTION("Led platform driver");4 d/ C, u+ R) \: ^3 x5 L; c: {
MODULE_AUTHOR("Tronlong");' s1 P- d p4 C% t8 t% N/ Y
MODULE_LICENSE("GPL");3 A$ d( O0 ^7 q: M: Y; K1 \. O* B
# P2 A1 T# R+ n: Q
|
|