|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
Y& ^3 v. l& k" t1 b- c3 q% M% E#include <linux/init.h>: a+ M4 i$ w3 Y+ ]5 Q! d
#include <linux/module.h>
7 C$ K) T0 G4 l* g2 a& h5 D; g7 E. m#include <linux/kernel.h>* ]- y6 a$ G# X* }2 S/ q3 T
#include <linux/types.h>
( L+ M8 C' @- f% T#include <linux/gpio.h>
I; `9 f" Z) ]' N4 t#include <linux/leds.h>
- b S8 a+ ?* t#include <linux/platform_device.h>
8 n+ V0 v" H, R: V5 a- E" ^, @6 x4 C# ~' y0 c" {0 @# o0 F
#include <asm/mach-types.h>
" q: f0 B4 i* ]8 e#include <asm/mach/arch.h>5 [5 U4 w+ F9 c. l6 F; A8 q
#include <mach/da8xx.h>3 S$ P3 L; T- M/ N3 v2 O% l
#include <mach/mux.h>0 }) S" B; U6 @, H) x
. N( n8 U# P/ I: k: s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; s9 w! y+ m7 g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ L! Q% D: k0 i1 T: @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. ^ M( A2 y) d- W( C3 K. |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 S4 i2 B0 K8 U1 Y8 |, {+ O% l+ T# h! ]+ E1 @: ~+ L5 P' C
/* assign the tl som board LED-GPIOs*/% `, D5 p1 a7 R
static const short da850_evm_tl_user_led_pins[] = {
t) @* e! L& R7 O% [, t, ` /* These pins are definition at <mach/mux.h> file */
. s) @4 [( y; c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# p9 U2 J8 |/ S& q' E -1) d: O+ u% B( o3 l7 w3 x! m
};
/ E/ W2 \ o6 f9 J! Z2 I) F1 ^, c: C$ e! w% z- h/ |% G
static struct gpio_led da850_evm_tl_leds[] = {
) c0 S i( Q6 v5 f. q+ U1 Y5 m {" ]6 J4 g: I9 P4 V
.active_low = 0,5 x. z3 t6 m0 i( u3 k9 F
.gpio = DA850_USER_LED0,' K- r& j* v3 Y: h S
.name = "user_led0",
* F! w$ _+ d- P' x& f; O .default_trigger = "default-on",
. K# ^' G& o" n5 I% u9 r3 p, M1 o; p& @ },2 P x' s1 o/ P6 \; n
{
3 t1 [. t' _) a4 S7 X .active_low = 0,
% X( B) e6 b2 | .gpio = DA850_USER_LED1,
' [4 T2 d+ L1 [+ C0 t% q .name = "user_led1",3 a- Y( [4 N4 _9 k
.default_trigger = "default-on",6 x" |! U) ~6 v! m, y' F( [
},
! t: } X3 b6 i u$ B0 m {
. Z1 t/ d! |# D2 Y! }& z .active_low = 0,9 J: F2 p9 m' ~! ~- k, \
.gpio = DA850_USER_LED2,; a' J! O+ T9 y( c" m( j$ f
.name = "user_led2",
# @# A! P4 H* k+ b% R7 f: K .default_trigger = "default-on",
; ^! w, y% S' b$ s3 s: C },, ^; K5 b/ a/ g. p2 b
{
! S6 \) u) y5 D. W& t. W .active_low = 0,9 k) _6 z9 F: e4 e
.gpio = DA850_USER_LED3,
, [; h6 O9 f- `( H- t .name = "user_led3",: \9 `, [9 ]6 p
.default_trigger = "default-on",5 Q: l" |9 y; T+ d, p! ?
},
. s R4 e; v& u) J; o8 k};8 v5 v5 t; e; @7 `
" e% ^ `+ F8 `) U0 o# `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { _$ w- _( d/ x7 I- u
.leds = da850_evm_tl_leds,
. }6 G5 W, l, X, G. x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 o M, s5 K* i5 g" h9 b! b};
/ r# k( G7 e/ E7 V4 \8 v: B
1 j$ K7 Z2 S% \5 astatic void led_dev_release(struct device *dev) J: u: x$ h; B' u; k
{3 W" F9 T! r5 D
};; \! p- e+ o3 A! h1 g
/ n3 @4 v+ U- {, i7 J5 S* xstatic struct platform_device da850_evm_tl_leds_device = {
; _4 K* D" Z9 b9 R) C .name = "leds-gpio",- W8 E* @" `. j
.id = 1,* N4 `2 L! P% C% T- Z
.dev = {
9 A% h$ X7 x+ q- ]# Z7 K* K, R .platform_data = &da850_evm_tl_leds_pdata, d6 s- V3 E* `
.release = led_dev_release,/ p. s# J t+ O4 ~9 ~* B X
}
) e! T s) B( ~& @ I};
% b, O7 L# Z: Q0 N0 e+ c1 L0 @* W0 s9 x0 T
static int __init led_platform_init(void)1 j( p& ^) O8 z& Q6 g
{7 q! ?! i7 Z& ?
int ret;7 `, z9 B+ F. e g' a7 h
#if 0
. _$ l: C+ w* Y6 T5 F9 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" H, a5 z" [! c& B
if (ret)
2 _, W7 y2 C$ T/ F3 {1 g pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 D% {, P! N) A
"%d\n", ret);5 h0 {2 ^ _$ g. l5 W$ D
#endif
4 T/ ?6 k: C$ p/ J+ D ret = platform_device_register(&da850_evm_tl_leds_device);" d, {: G. n5 T* ^
if (ret)
# g( P6 I/ i$ i+ u4 Z: W pr_warning("Could not register som GPIO expander LEDS");) \1 ^1 n. P5 |9 y1 o. t2 {4 m
else# X: }. G( Q0 m: q% J: O
printk(KERN_INFO "LED register sucessful!\n");8 E% N5 q4 u; {. _) R# B* u& B
9 @9 x5 O$ h" u. u% ~) u* u
return ret;( K5 r, Q P. O9 l
}
7 A9 c {% w0 S" C# h
% |% G, W2 [/ I! Bstatic void __exit led_platform_exit(void)
1 M4 W& H% ]7 K$ B{
2 ^3 {7 W' H" r5 G& ]% [' R platform_device_unregister(&da850_evm_tl_leds_device);9 P* y3 ~* [# x2 h- U; G
8 z; g; x4 l# W$ q9 |2 E9 O% t
printk(KERN_INFO "LED unregister!\n");
6 ?$ t) I/ e, F& t+ }: l8 ], z}
3 s" ^( p; ] K5 [7 r2 c" A5 d
module_init(led_platform_init);# U& Z$ l& d4 R# e8 a
module_exit(led_platform_exit);
- z" K; m5 `2 u. R% r
$ _' Y9 b* L: R& R# d$ n0 LMODULE_DESCRIPTION("Led platform driver");0 `' i6 G: W: J, C9 M3 w5 s8 t
MODULE_AUTHOR("Tronlong");
- ~( m: ?- @7 d3 mMODULE_LICENSE("GPL");
& A+ `5 g1 a" u) L0 {9 M4 @3 H4 Y& V! ^+ y' j5 m
|
|