|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, i+ o6 K1 f8 j% k' c5 t
#include <linux/init.h>( i/ p, ?( ~3 {: H9 k7 h; Y& O9 u
#include <linux/module.h>) R5 B% I' _7 r+ G2 ~7 n
#include <linux/kernel.h>
! @: S! `9 ?" M#include <linux/types.h>& Z5 f! J9 g# _: y: ], i$ S9 V# ?- a
#include <linux/gpio.h>
8 t. C5 K3 S( t' y( Q. Q& f" h#include <linux/leds.h>
`9 A* V) D. ]0 s0 U#include <linux/platform_device.h>/ Y6 t0 G5 c: l' ^/ R+ n8 d8 k' u
$ {$ m9 m$ j0 h0 e* q- F, {
#include <asm/mach-types.h>
" ^. S& H( w6 k- A#include <asm/mach/arch.h>- e) O7 V# B& d) P. a M' ?
#include <mach/da8xx.h>* ^7 v& p; L6 R" z# v' |. ]; v8 u' O
#include <mach/mux.h>: y! j! A" n, W& O% ?7 r
8 x; D# Y. l% s* S, M, `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" v6 \9 M. Q. k% a6 s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 R# A4 M* v3 Q" r4 A: j) E% `( {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& d* x% q% L8 j. p8 L0 s/ J* U( U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* M8 w" O/ P- k# B9 B @3 m! I2 Y9 v2 z- Y4 ~9 W
/* assign the tl som board LED-GPIOs*/% @" l) l( E. H& \( a
static const short da850_evm_tl_user_led_pins[] = {, {& n2 A& c* y1 R
/* These pins are definition at <mach/mux.h> file */& J& H2 H0 O9 U- S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# J2 Q1 Y! U) e% o$ {
-1' c/ W* W) K F
}; A6 |" x; ]/ s
( _% l: |/ z* E; U5 g
static struct gpio_led da850_evm_tl_leds[] = {% E. I: k, d6 D2 b4 h# n
{ L9 T, a0 d' f3 E! L. {
.active_low = 0,. I3 l. J* W; M# b
.gpio = DA850_USER_LED0,
4 T* {/ h1 [$ P3 w2 A5 U" W1 Z, ]- e .name = "user_led0",7 F0 @+ ~% T: k: O& e8 e
.default_trigger = "default-on",) {: G2 N" t. D& S; _, N
},
# ~+ b- F" {2 ?6 ]* E' ] {3 f6 @, P0 [8 {( E
.active_low = 0,' P# J6 M, p, `( P* Q- n0 ~
.gpio = DA850_USER_LED1,# D1 i% v& @8 U! O5 f, m
.name = "user_led1",- X) g- Q# o: p( C) O1 i4 ?$ b
.default_trigger = "default-on",
% E4 o- r$ R9 ]' U0 ?, @) `2 g },9 w; J9 D( \6 m# k& {+ F# _8 d
{8 {2 J$ L) O# ]$ O" h
.active_low = 0,
6 P3 v* f( y# B, i3 s .gpio = DA850_USER_LED2,
! `9 w7 f/ x/ \, F$ _ .name = "user_led2",7 ^, F* O8 Q' K5 ~ u
.default_trigger = "default-on",9 ~: A& S7 z! e" n7 x% V
},
: v4 a7 ?' Q3 a0 B: _ {
9 Y) _9 ~. N w }. D. U! {) K .active_low = 0,
b5 X7 k% y; q) i8 ~) l- l* T .gpio = DA850_USER_LED3,- s: [( M4 J( D: d
.name = "user_led3",, B; |+ Y: C% ^
.default_trigger = "default-on",
4 u! M3 k0 W) _* M/ c8 g( } I },3 N! D/ N* j' D
};0 f ~ V% J. `9 D7 ~2 R
. Z+ v" u% G! e5 t7 c1 l1 t) @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
T& T# L$ ?$ g: \5 F .leds = da850_evm_tl_leds,+ ]3 f+ V& B6 G* ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; ^2 [. v/ k6 G+ F$ z};& x6 |4 `+ k3 d6 Y7 Y* x) P
& ^6 q% ^! {: Q( o) h' \/ P& r e9 h
static void led_dev_release(struct device *dev)0 V7 M- h& _ W! \) D
{- ~, x, u/ x+ p" w7 c0 \
};& f( v# l+ w+ v$ i; N
. P1 V$ b4 h0 T B% p
static struct platform_device da850_evm_tl_leds_device = {' f) U6 f, o/ `+ l& k3 L
.name = "leds-gpio",
, U6 K1 a4 C, |& p .id = 1,
+ `$ c- e- I/ e: _6 q6 S .dev = {" Q5 f; Q* g; y* ~' {' R8 C- [
.platform_data = &da850_evm_tl_leds_pdata, m. b- F) R( G6 p3 _0 h) E
.release = led_dev_release,/ z1 `* y' Z' O; @0 Q+ X5 n$ h( q
}3 P- V& C( z1 ~) _
};5 w* l/ S; Y' [5 l
) `- H; \ n/ L& ?4 ustatic int __init led_platform_init(void)
3 K& v/ j% F, L{
3 I2 a4 X, X) p/ k4 W% [: c8 P8 K int ret;
/ d' V9 t# j, Y7 a: C#if 0
( G& K. U4 q# h z: y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& z& D9 a8 V* n. j% r u/ W
if (ret)9 k* a7 Q1 n* x n- L$ O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% e V2 x" s) u7 c. z( y$ B4 f "%d\n", ret);
% ^3 E1 k# {8 I0 l/ j, Q% E#endif
$ S0 M% j% ] X+ r* O ret = platform_device_register(&da850_evm_tl_leds_device);
. D; T' e) E# P6 Q4 _& R if (ret)4 l/ j# g. T" _0 a: z) g
pr_warning("Could not register som GPIO expander LEDS");7 W3 H0 {, _# h3 P8 b7 L' a5 {+ J, c
else
8 v' ~9 ?+ L* M( A/ y. _ printk(KERN_INFO "LED register sucessful!\n");
6 `- ~: V+ A' ?3 T* N+ l# _3 \$ }% B! V5 S) U
return ret;
2 L- T& S( x* L# F7 k}* t8 K% D% H8 x
- O; C1 B+ ]9 a( f2 @6 w' p
static void __exit led_platform_exit(void)2 j0 J& ~4 t- U
{$ d$ H, \5 z6 M6 a% F2 G A' U
platform_device_unregister(&da850_evm_tl_leds_device);5 L3 K2 Y$ H+ ~& J& @* |
+ w/ K8 J+ q$ c" K, f5 {( P
printk(KERN_INFO "LED unregister!\n");9 ~ p: w" U+ u: i1 `$ E
}# h8 o( |! X; x: ~$ V
* k+ s3 ~% O/ Z7 a; Bmodule_init(led_platform_init);5 A/ X$ Y$ a/ o( c8 G
module_exit(led_platform_exit);
* `1 @2 `7 e% E2 |+ d6 _6 ~ V
3 d; d6 H' U0 t3 NMODULE_DESCRIPTION("Led platform driver");
% w i: q* X7 E- _ M+ `MODULE_AUTHOR("Tronlong");( H6 h" p) z, n
MODULE_LICENSE("GPL");
: }. [+ B$ v% x1 i' Y' Y
. M% [8 {* x4 A7 X |
|