|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% `4 ]8 A, o! x#include <linux/init.h># Q7 u2 l% {8 |0 r! p8 O! l# Y
#include <linux/module.h>
5 }+ u, {" H% _( E' z#include <linux/kernel.h>! s0 }( F1 u% g" e
#include <linux/types.h>
9 w0 M3 V+ B5 z" m" [' V#include <linux/gpio.h>
) i6 s M4 Q( ?+ G' g+ ^, J# X8 H% W#include <linux/leds.h>" P& v2 D; O# v2 U( o
#include <linux/platform_device.h>
$ s1 U$ V2 S! D+ c F. X& D0 u( @/ x& [: p9 D! u e
#include <asm/mach-types.h>4 x: z: H* k% U! T) J
#include <asm/mach/arch.h>4 c" e3 {0 \. I- u
#include <mach/da8xx.h>; G$ ^' C: b: I9 n
#include <mach/mux.h>
+ u) a4 O: A2 s o* E( j5 D4 D' `& U6 V p* [$ z6 _) k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ W, w. I) ~6 s! L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
P' q6 H! U% z3 i6 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% U* b! o7 f0 A! w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" A8 I: |. P- s7 y5 _& \+ c$ |9 p2 W& C2 O( C7 l2 U/ I
/* assign the tl som board LED-GPIOs*/
* W4 y: P; R" A; E. ustatic const short da850_evm_tl_user_led_pins[] = {4 ~, ]! W" r, c
/* These pins are definition at <mach/mux.h> file */
9 A( j! _, [2 g/ Y) Y0 N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ O& W! ~% G7 j1 u
-1
1 F) j& Y& W$ v \- ]2 G};% s/ G8 b9 P- @
5 y* u+ n# r& b/ D; {' }- b' d% n
static struct gpio_led da850_evm_tl_leds[] = {
, b! H+ S, d1 A: V( `5 r. X6 B {; I, F9 m) S) i9 J a
.active_low = 0,
9 U* K! w3 h5 I+ r .gpio = DA850_USER_LED0,$ S; G( P2 H" E. L1 P
.name = "user_led0",9 n, Q% b7 A& K4 `+ Y' n1 t+ t+ u2 u
.default_trigger = "default-on",
# g! K3 O+ k5 U- A1 n; a( H* ] },
/ _ }+ _0 J2 A/ | {
+ q3 L: p* F5 k) P0 }+ r3 S* q .active_low = 0,: q) j I) Y3 }" t
.gpio = DA850_USER_LED1,
0 W, F- m$ J- x/ v+ M6 E9 [ .name = "user_led1",
* A3 r5 f' k/ H% d/ D X# T3 [* L( v .default_trigger = "default-on",
: B- i" U0 t- m4 A4 u0 d },( L; _& n$ \! P! ?, z* G# B
{
& V$ r: G/ P( D .active_low = 0,
* n5 }2 U7 r2 {; v0 Y; u. j .gpio = DA850_USER_LED2,
, {- t K' x$ k .name = "user_led2",
+ i. i* h$ ^' x5 @5 @; _: W .default_trigger = "default-on",9 c4 G: Q7 N; b1 j0 d2 d
},/ J8 z/ K `# f8 m4 C, N
{" G6 ] |0 X8 o4 ~/ H' K9 f- t* d
.active_low = 0,* b6 F% U- b" M) f' X1 M
.gpio = DA850_USER_LED3,( ?, o3 E; L9 R5 S4 Q3 N& [9 C
.name = "user_led3",
+ a" b% h; I, ^' O .default_trigger = "default-on",; G5 r% @3 ]% T! z
},
7 w6 v& w8 p; W8 N5 T( S/ F};
/ ]! R+ u4 H. M F4 @
X* p; s* ?1 M8 f' O0 b2 ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! f" g. B* c+ m0 d$ D. e .leds = da850_evm_tl_leds,
4 T. c4 | \$ l$ N# x: K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# a" }' H9 I6 z% G* q};
, \" V' ^+ U C* j* H# s( {
3 |6 Z- U7 m' G7 X) \* {# [static void led_dev_release(struct device *dev)
1 d, A& K( i) \+ F! H/ d9 F- z{
6 Z( |6 q- L' M+ @5 } ?};
- g) c9 L7 j* p: E
0 @% w( b" E! C. t9 M/ Ostatic struct platform_device da850_evm_tl_leds_device = {& R. C& }! c4 G; e# P. i
.name = "leds-gpio",* I0 y% a6 e, Q' b; K- S
.id = 1,
& A. j( Q" z! v' w& Z .dev = {
$ p0 d2 a4 H2 \+ U% \6 b# \# f .platform_data = &da850_evm_tl_leds_pdata,- [* x; t% D, l! p/ Y3 I% M& N, Q
.release = led_dev_release,
( b* \+ h7 l7 {0 m9 o* O: K# N }
1 `/ `& A$ J, n' c};
6 Y H2 G- I; Z# L1 n q9 t: f/ j Y d- f C7 }0 P
static int __init led_platform_init(void)
' F3 q I) w" j: l{
8 g2 K9 \& G5 H8 d' o& z int ret;' U8 v+ B1 S: @7 z4 z2 i
#if 0 I) |+ }2 A( `/ ]6 p! }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# ~5 ?7 h/ b. _5 |6 J
if (ret)
# O+ E$ O' x0 D, B' | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 O$ M, n; \: q6 h) C "%d\n", ret);) l# F8 Z- P* u3 o2 R
#endif3 C; @: ^' h+ k1 F* c7 M0 Q
ret = platform_device_register(&da850_evm_tl_leds_device);
/ D' l$ D7 K/ z* u% v" V9 h& W8 u if (ret)
" j) s; o( |- S" H5 y. r4 R pr_warning("Could not register som GPIO expander LEDS");
8 a5 n5 ?+ d9 U7 p; s else
' O7 U/ c0 T/ P7 K0 ?: `! H printk(KERN_INFO "LED register sucessful!\n");
) Q1 W& B: R% A: V V* q! _
$ w) Y6 O' X5 O$ V return ret;/ e) l- ]/ {6 V- s6 _' o# t! ~
}
, B* i4 Y& S9 u0 Y2 }4 E3 n, V( |0 \" C' K: ?, {
static void __exit led_platform_exit(void)
# l8 J9 A0 E) J/ T{
) j _- [% _$ g% H platform_device_unregister(&da850_evm_tl_leds_device); S# F. J: P7 N2 `
5 V& k; G* m2 Y$ n printk(KERN_INFO "LED unregister!\n"); J6 E1 ]- u) ], K& p
}
9 U# d$ n ^' F( z$ V) r' k- s$ V. Z( ~9 ^) Q6 _& w% D
module_init(led_platform_init);
2 a# f& N/ _9 F+ Y' u, Imodule_exit(led_platform_exit);' N& m$ M8 B/ V( Y* Q8 Z* f0 y5 D: }! E4 S
) x9 }- Q% J- C8 a& xMODULE_DESCRIPTION("Led platform driver");' g( G$ S/ z3 n1 ]. ~$ F
MODULE_AUTHOR("Tronlong");
8 R. T. k2 V$ |! W. WMODULE_LICENSE("GPL");4 N0 K3 w' d: u9 }% {) p5 ?6 F
0 b! f9 ]: j0 Q3 r$ U5 y9 a
|
|