|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' d6 a, J( d0 z: c#include <linux/init.h> c; x/ Q: u4 ~2 ~4 x' Y9 o+ b
#include <linux/module.h>: |, m* O1 [, g$ `. B# _- y2 G
#include <linux/kernel.h>
" L9 K9 Y) P( l4 f1 X/ k3 C#include <linux/types.h>. u$ R7 M6 o& _2 {
#include <linux/gpio.h>/ m: V0 Z$ O0 N3 W. m
#include <linux/leds.h># f" C4 Z8 V9 p. o1 `9 z
#include <linux/platform_device.h>* S4 F+ _" O$ L. Q. Y w% W9 Y7 g( V
0 U4 b$ B3 G+ v- z#include <asm/mach-types.h>/ @3 U8 U4 E5 R0 z( Z% U3 M w& l
#include <asm/mach/arch.h>2 K: x) [7 s. |. S7 {
#include <mach/da8xx.h># {7 l. T- c( A$ p
#include <mach/mux.h>
1 ]2 n2 K! b1 z$ f+ E& o+ I3 d4 F6 z" \ f$ h5 N8 L7 G! F0 a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( T; u: Y# N. k9 F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 U0 o, O5 [9 R. ?5 J9 `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 f+ q+ o+ Q* z S# r8 D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! J% X9 F/ q, T1 s
" k8 F( c3 V2 V4 F. V W/* assign the tl som board LED-GPIOs*/
* b3 h; Q. z4 [3 xstatic const short da850_evm_tl_user_led_pins[] = {
2 i! W# h! @& f6 G8 r /* These pins are definition at <mach/mux.h> file */
0 Q# _( A2 d5 C8 D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ Z) Z/ `: `$ [ Y! h# S
-1
2 R' `. `: I" f6 ^ i! f8 w1 r};
/ x5 D& x; \. f
# ]2 s% O% ?- \- T. Istatic struct gpio_led da850_evm_tl_leds[] = {& e" C# k$ N6 B0 _! ~% K/ i# ^7 ^" a
{
; K$ H# ^% E2 h! a( [ .active_low = 0,
7 E' V; J& q6 \: e( U .gpio = DA850_USER_LED0,
: z) N0 E! ~( ?0 g .name = "user_led0", S; \* X" N3 Q0 U
.default_trigger = "default-on",
( e4 i& a8 X! @, `) n- b },
) n: q ^2 @+ o# P6 q6 | {# a' _4 v' _ K7 @8 N4 g* r- L
.active_low = 0,
# J# O/ a6 t$ u6 d O! ?/ C7 J .gpio = DA850_USER_LED1,+ q3 s D: k" w# w6 D" Q. r {
.name = "user_led1",
) S0 ]% }2 W }$ I; d4 l2 | .default_trigger = "default-on",
+ B- x- z; S7 k) P V },
8 Q% M* M/ P9 R; y% U; `4 f1 p {0 [1 Q& `9 {( ^' a7 n; d7 V
.active_low = 0,
" S4 h: m- k- j u .gpio = DA850_USER_LED2,
2 r9 a8 s8 y& A% _: ~: c% ^- R .name = "user_led2",- Q, F E; L5 G& G/ l3 L
.default_trigger = "default-on",
) P0 f3 @) [: {9 @0 X, g' N },
; \1 e: U0 Y3 u8 `- L4 m. L, f$ @9 Q {
8 w+ S! @1 d7 U& {6 p7 G3 ] .active_low = 0,
/ C4 S$ s% }+ C4 E% `+ Y .gpio = DA850_USER_LED3,2 {$ _0 L$ l% o9 q
.name = "user_led3",4 q- p0 a. ~% n! u4 o
.default_trigger = "default-on",! ]- v; X6 i% L0 [5 U) K7 r
},9 i" p. K6 ^7 H# Q+ F
};
4 o: o2 T' n/ G
4 ?1 h6 g4 V: \' nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 B( ~* j4 G: @& T' j+ G5 n4 i
.leds = da850_evm_tl_leds,
4 E a t0 D( J6 p3 V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 d. E _! E& f& ^4 I};8 L s' x+ s- I. u/ i( x) S, w8 w
! A* Y! N1 f% J% \) dstatic void led_dev_release(struct device *dev)
3 n5 E% X6 O1 U5 F8 f l1 u{+ P" e* {1 C5 [3 p
};
% p T2 o9 X" D0 Z9 e5 S$ ]4 ~
9 S4 N9 P: A% e) P" bstatic struct platform_device da850_evm_tl_leds_device = {9 x8 s, @' c( S+ z1 j1 o. Z
.name = "leds-gpio",& u8 S3 y o! W- w0 B# R& y; ^0 F5 |
.id = 1,7 f# Q/ | G9 I" v3 M$ x+ t2 V: Y( m
.dev = {! b$ H# {/ A# a: _
.platform_data = &da850_evm_tl_leds_pdata,
$ J2 ~8 ?9 V- b6 a* q1 z! p .release = led_dev_release,
, S. ^% j9 l1 h6 |/ s }
& B" q/ I3 i9 U! Q};. s; k1 Z/ w4 j/ }
o& `& H% A( H0 S" q6 i
static int __init led_platform_init(void)
$ S; M7 m) \# P+ q$ q' c* I{5 A. m8 w ~3 i' {/ f& O# J" k K1 K
int ret;
% F& R) x5 R6 N#if 0
1 A6 v9 q* q, N# z7 o6 I5 u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! w e+ J7 m' f5 I
if (ret)/ t" ^5 y* ^3 `$ x/ S7 W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") K2 A4 L. y; e8 g" d9 g+ I
"%d\n", ret);# F# N! C& p" N4 ?8 ]
#endif
# k( I, h) e% t6 | ret = platform_device_register(&da850_evm_tl_leds_device);. J. V* |# W) \ ]0 N& @1 k$ |
if (ret)3 s' ~( e: j. v3 b; B
pr_warning("Could not register som GPIO expander LEDS");" C7 I, y% u9 b/ X( k/ q' B
else7 O% ^9 E! F/ K/ r
printk(KERN_INFO "LED register sucessful!\n");1 q, Z' i, |5 m; _% I3 A
6 i( \! ~' {+ Y/ R$ Z5 k return ret;
% L6 ` }5 {; c$ a1 V; F+ d& ?}
9 T. a; u: t' y8 n7 G( k n. Q1 M- z7 |/ y% R/ V7 P) U
static void __exit led_platform_exit(void)+ q6 @3 C: e* S! d/ ~
{' X+ N4 n. w2 @
platform_device_unregister(&da850_evm_tl_leds_device);
5 r3 D8 C0 |, S1 M% u! A# I' |( G* k) r: r
printk(KERN_INFO "LED unregister!\n");
8 o8 L) `. ~1 v8 e4 c}- Q4 Q$ r% `, Z& }
6 `( c8 [* U( Kmodule_init(led_platform_init);4 e* T8 Y: e6 X2 m0 m( s2 ?
module_exit(led_platform_exit);* z2 d: [- P5 A
0 D& r" @1 ^* l1 B% I7 I9 ZMODULE_DESCRIPTION("Led platform driver");* `3 j' N/ D# \8 }, R
MODULE_AUTHOR("Tronlong");
, C! ?* ~' g3 H$ hMODULE_LICENSE("GPL");
% L b/ k; U! |; h* D
3 p6 B* Q( t$ c8 |% }% X |
|