|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. d& k% _* s) h. J5 w#include <linux/init.h>, z$ ~* n: F0 a, E. ?
#include <linux/module.h>
6 p2 {( u( T( U% b: j- {8 C0 x#include <linux/kernel.h>4 F, o Z( k+ ` [; h
#include <linux/types.h>
1 s3 o$ h4 ^2 ]2 M" ?6 w#include <linux/gpio.h>
4 k8 Y3 U+ l- _' \& c8 t#include <linux/leds.h>
& c6 M+ R+ U+ h* q% n8 u#include <linux/platform_device.h>, j( a3 I* O, ^
2 r0 |. @8 p! T C% }#include <asm/mach-types.h>( D! P0 u- M+ J4 ]
#include <asm/mach/arch.h>& Q5 S) I/ |! h6 P- x z
#include <mach/da8xx.h>, F/ a* U5 V& d& @7 Y
#include <mach/mux.h>' k' U6 g5 j2 t1 l a7 V, T
' n" s: v9 g+ r' A, M& s- M; G" C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( n' ?" H. t: ?' O+ L' q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 q d% f( E1 b+ I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 }7 r8 [1 d+ M2 b+ z/ I# }, f0 Z6 J; q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 S6 Z; d, Y& d! N0 {7 S3 ^ w5 R' Z3 J% S0 Z5 i: m! |7 g
/* assign the tl som board LED-GPIOs*/# W9 P. b) R: P4 _! [3 U
static const short da850_evm_tl_user_led_pins[] = {7 m+ \5 P) M5 V; [! u* Y
/* These pins are definition at <mach/mux.h> file */- z+ w/ Q4 ]5 F0 p! a2 F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ x$ k3 ~3 o/ P9 _4 K/ Y$ a
-10 J# n6 v6 z/ h4 y8 n2 |
};
: A2 _1 Y( f2 s$ ^4 q! k% I% \! `* K: F8 M( [
static struct gpio_led da850_evm_tl_leds[] = {: i9 k. A: O9 s2 g$ [
{# [- y7 [9 g0 Y
.active_low = 0,
" R( d) g8 X" _4 b( l .gpio = DA850_USER_LED0,
& T6 j/ w* s9 p# M. a% Q M .name = "user_led0",
; v! [& z" s) X% C" n' H' R .default_trigger = "default-on",+ ]2 A1 n8 p6 M2 C- t/ g
},% F* j% G2 C2 K
{
* [3 I' o+ a9 `+ I .active_low = 0,
# W+ L o! h% L# M .gpio = DA850_USER_LED1,
. c/ [& d C. _ .name = "user_led1",
- p, J1 x& z A4 Z7 p2 ~1 [ .default_trigger = "default-on",( I; K L3 h1 g" d3 W
},7 j- S& F' r5 ^: {2 g
{1 y9 [0 X* J4 @9 y" G
.active_low = 0,. f/ q% V( N! J% K- E
.gpio = DA850_USER_LED2,* [; f- ~% o. _6 |6 }) _
.name = "user_led2",
2 V4 N4 d: p; G9 [: U .default_trigger = "default-on",
3 h. }! h! N1 p' V( J }," W: n9 \9 g3 K) B- n2 P
{
; a3 l0 r1 y* n* z. f .active_low = 0,
# o3 r0 O0 y2 _; t/ ]" f: ~% Q6 Z .gpio = DA850_USER_LED3,
; N Q" i' W4 o8 f! P) ?$ h9 V: H .name = "user_led3",9 ]5 T) l! N8 D% \: Q" R+ c
.default_trigger = "default-on",
% Z, k5 T9 h5 l7 }1 ?0 j4 S },4 x" M6 q1 [. T- f0 |" W9 m+ y
};; O% L. V4 @0 b; Y% S& g
& q% u! [# K! A; }3 i, }: \1 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 r. @7 m1 j6 f2 W- @ f' d( ~ .leds = da850_evm_tl_leds,
K4 i7 q7 F0 Y4 S) q$ N, T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 F4 q+ e# w% G( c0 d};
, M4 p1 Y. ^; Y2 J# `1 I: f h, n# k" j% U
static void led_dev_release(struct device *dev)) A1 `/ P$ N! n
{$ \0 f0 G2 \) J9 g7 @
};
1 N; \# l8 ^$ B: [6 C$ S7 l" K3 S! B! {# z& W# C' P
static struct platform_device da850_evm_tl_leds_device = {
$ X8 A k) i5 n% ` .name = "leds-gpio",
6 Z6 O3 q( S# E- w0 X o .id = 1,, j% Z ?0 a3 d% B5 }( v( t: b
.dev = {6 Y0 _8 `$ s; J7 Z! d: c$ n: y+ J
.platform_data = &da850_evm_tl_leds_pdata,$ q( D [4 N: A; s: R& z- h
.release = led_dev_release,
) [# u* A: ^( j& a! K/ G9 } }; d( |- i3 r' V- j F
};' P2 a9 c+ q) S
; _. A$ {8 Y+ m! B5 y
static int __init led_platform_init(void)- o- f' _/ R' L& F
{
! \2 ^6 {7 y# W0 K( W* K$ V, ?& v int ret;+ g8 @& w) e/ j7 _4 }( Q
#if 0: l. {' G% |2 ^- y5 Q* R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 o* R2 c3 I% V& Q' u/ | if (ret)( J# r& V- F: q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) u. H j7 ~9 J3 H- z1 s8 J% w "%d\n", ret);( N) J- R) T( L/ l5 u
#endif0 T8 m. e- @. _
ret = platform_device_register(&da850_evm_tl_leds_device);, _4 p4 `, q1 S' [4 S. K0 _
if (ret)
8 s k1 r& ^% u9 A pr_warning("Could not register som GPIO expander LEDS");# Q; T$ U4 Z# { W5 P
else
! _8 J# h- w: w9 o0 { printk(KERN_INFO "LED register sucessful!\n");; I5 W* J, u$ p7 `# f
! `) \& }. g& B
return ret;7 m. j. U/ w* M* j% b
}
: _1 M% N6 z# X+ F" Q8 u! {
' v( l" B& s/ a8 [3 j. k1 rstatic void __exit led_platform_exit(void) p2 C' |) S: O1 U
{: E" D& V* x7 a( m
platform_device_unregister(&da850_evm_tl_leds_device);
! S, @ q% j6 D$ T# Q* }$ o. k4 ]% T. F1 B" e
printk(KERN_INFO "LED unregister!\n");
1 o7 b) p# T: R/ F+ Q2 W/ e Q}
* P, y6 z. c& n T/ l' |
. _0 E/ Z. ^% g; lmodule_init(led_platform_init);
2 z, E, n4 n" T' f" }4 Imodule_exit(led_platform_exit);
3 c* i3 z. ~/ u+ C9 V$ ~
9 n. Y* E3 E) B' uMODULE_DESCRIPTION("Led platform driver");
s& [. x% a# m0 }/ BMODULE_AUTHOR("Tronlong");
# h+ r1 k+ }$ T& SMODULE_LICENSE("GPL");5 q& F7 w3 d& o$ j
3 |# x4 p) r0 n( k2 @
|
|