|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! i: Q% k$ k5 O1 H1 l#include <linux/init.h>9 s. i0 f( B+ V: t j9 X
#include <linux/module.h>
$ p4 t7 M6 ?+ J1 B, u3 j* u7 Y#include <linux/kernel.h>
E5 m/ Z$ F* Z1 H#include <linux/types.h>
1 q' \" e- h" D6 x# D4 N/ s) Z#include <linux/gpio.h>
6 ]7 T8 i U0 W3 m0 Q ^#include <linux/leds.h># L/ J7 e3 q5 Q9 C m! n9 h* |) v
#include <linux/platform_device.h>+ K( t ~1 z5 Y
2 \; T: i& n# L, l8 }9 r#include <asm/mach-types.h>
& I, [- q# t- I; I#include <asm/mach/arch.h># p+ k, J9 d" ~ p+ C
#include <mach/da8xx.h>' {( Y" D+ X" j9 T1 y; o# }$ Q
#include <mach/mux.h>
, U$ A! x* V* _# U: r0 @" \5 V7 i4 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# b9 F( K4 q- b: ~. W# G1 q" M0 J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ V. V8 @ W. r6 z j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" r1 F+ M0 C( c6 V2 _) C/ n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 W \$ Z3 c$ Q4 M
+ O( V* t3 `! s/* assign the tl som board LED-GPIOs*/
6 |1 f" `6 x0 C) D- L7 ]0 ?static const short da850_evm_tl_user_led_pins[] = {- y$ F3 ]( N/ {( ~3 L3 O7 z! b
/* These pins are definition at <mach/mux.h> file */
; u7 f* n& ^9 f* ~+ {7 b2 U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
o- C7 a4 w# J# { -1- S1 f3 x/ v+ ~, `6 }9 N6 }; e2 Y
};
# T2 m* S* M$ s4 \. v3 x- b# f$ A+ @3 \: S6 z. {# @
static struct gpio_led da850_evm_tl_leds[] = {
' U* W! t1 p0 y- x {; z% T! p# \5 `$ O1 ?' T
.active_low = 0, S9 |% {) b7 P( s* ^1 a! j9 D+ H
.gpio = DA850_USER_LED0,3 v% C4 E. {" D2 V0 o" `
.name = "user_led0",$ _% \; h l8 m8 Q& Y
.default_trigger = "default-on",
" M! ^1 S% f) {5 A9 |# o" J8 T },: c* \4 K+ C- G+ W. t2 v% w
{
* S+ \1 z+ o% K% s+ @ .active_low = 0,2 G7 H/ }& t4 w- c% _! B
.gpio = DA850_USER_LED1,
6 O& b: ?7 z0 Y, C; W3 B1 T6 v .name = "user_led1",
3 T: E. V9 i0 Q0 z0 V# W .default_trigger = "default-on",
1 W6 E4 o3 d. {( l/ U/ L },
* z6 ~" d8 S- H& z {
4 f* y) `" [# l3 Y9 l# U .active_low = 0,
" O1 y, U5 e- s! {, q; G+ T. V% n .gpio = DA850_USER_LED2,( Q7 w3 v( Q. l' ?1 d' K1 ^
.name = "user_led2",# `2 K+ g# c( W' }7 X& F9 @
.default_trigger = "default-on",2 p6 S& o& b2 M, a5 s: J! S4 f
},
9 E7 p2 ^$ c- x0 Q1 X$ H {
/ [9 B. T/ E; \- u6 C .active_low = 0,
; F6 I7 D% l) ^8 H# y& S .gpio = DA850_USER_LED3,
' A0 X) g/ O3 W- B& _ .name = "user_led3",6 a& ?- Y$ i! U% v
.default_trigger = "default-on",
: ~& U1 O2 g/ a0 g! k3 r },2 P1 k- W$ i7 C! O. W
};
8 N$ _2 g: T5 w+ Q% M# h5 K. ]
9 u! y: V8 K( G+ M5 mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 _8 u8 Z O* F1 L
.leds = da850_evm_tl_leds,' u: X* E* {: `, }, Z, A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ T8 r# |# r8 V3 I% z1 ~( p};! u) P& A/ Z9 [* Q. A1 W
, h9 Z- z- u! M1 V1 B, k: I" H+ b
static void led_dev_release(struct device *dev)
& v' Z* Q8 P$ i) Q{
6 I, n, Z8 Z9 y* Y; N' d* F};9 {( L8 R/ w7 u$ S4 z
# k% r$ }1 g- u8 H! c% O
static struct platform_device da850_evm_tl_leds_device = {, H) `$ @5 W6 Y/ }+ N0 _7 `
.name = "leds-gpio",7 q( o r! M0 F9 r* v
.id = 1,8 X6 m5 d; t% v, L
.dev = {
8 w$ N" O3 g4 ^9 Q t1 t7 a .platform_data = &da850_evm_tl_leds_pdata," g# o/ I K7 F8 W- Q# `
.release = led_dev_release," H! m0 N! E* L1 n9 Y/ |
}/ v. O' k& g1 Q% w' p+ @) |! g
};( k4 `# ]$ w+ G7 X% E& p- x; A# l
. `8 v0 Q" h) h1 c
static int __init led_platform_init(void)1 V) j, K$ @. _! p1 x4 N% _
{
! T7 b0 X* Z7 G9 d" T9 n J2 q5 m int ret;8 x* p9 N& ~0 x2 c* K7 m. N
#if 0
& c: {/ j- o: Z" H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 a" x) c- Y p if (ret)
$ `* T% x2 I9 r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 }8 y; u# W3 h4 t+ p8 { "%d\n", ret);* |3 N3 B M; E
#endif
9 y7 g8 C1 P# g8 T/ L1 n ret = platform_device_register(&da850_evm_tl_leds_device);
- s. I, c3 G# U& z6 O2 l if (ret)3 {, x9 |7 U/ d
pr_warning("Could not register som GPIO expander LEDS");" V+ A5 s& f2 ]: e3 Z$ ?% Y+ i) v
else; Y- j1 }% |. J8 `
printk(KERN_INFO "LED register sucessful!\n");
2 H7 l" M; j( O
( J, d4 u$ D8 l' S$ r. y8 _ return ret;
2 M1 Q. T' D" J2 W- z}' w- a; {) O o6 h
! N6 g0 l* B& e2 k) Hstatic void __exit led_platform_exit(void)4 ?% J0 E$ A, R( @* a
{2 u' \3 } A. w7 I6 H+ E8 l. V
platform_device_unregister(&da850_evm_tl_leds_device);; V" ?2 s L- g1 b/ H9 `" s
2 z" g! _- r" \ printk(KERN_INFO "LED unregister!\n");0 z* ` ^: f% o' l
}2 }. d8 c& i; n& ~
M; x: C# J% r, H1 U4 J1 ]; v* ?& E
module_init(led_platform_init);
8 Z- }( l0 A5 F/ j; f3 Ymodule_exit(led_platform_exit);
0 {" o, M0 K( r+ V+ N: n% ^8 O. O
0 h7 Z6 o5 k9 Y, k2 g! aMODULE_DESCRIPTION("Led platform driver");! `4 l' D! J' l
MODULE_AUTHOR("Tronlong");
. A. n. t L( i' H5 ^MODULE_LICENSE("GPL");5 G) p% {& X$ F- [) S' Q6 {
/ m& m" u& `) C
|
|