|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% w5 a8 p9 v9 S0 y, X9 ^. H
#include <linux/init.h>
' I+ j# c4 W5 [% }#include <linux/module.h>6 y; z! S+ f9 f, M0 j
#include <linux/kernel.h>
! W. g6 t, F# R% W( r#include <linux/types.h>! X' \2 j, u' b8 L9 N
#include <linux/gpio.h>
* j' X4 k% _7 r# i9 L5 ]8 r#include <linux/leds.h> n3 y2 B- L1 @4 @1 ~
#include <linux/platform_device.h>) z: O6 L7 g( e& z8 R+ s O2 t- g
. N! z) B* d7 ?/ x#include <asm/mach-types.h>
0 z8 S% U! @& B! ]6 s# I#include <asm/mach/arch.h>& S H" ]* D; ]" A3 Q: i4 r' R
#include <mach/da8xx.h>' w* V! {' s7 D% `4 a
#include <mach/mux.h>
5 Q P0 |$ x8 `8 H. p6 ?
& D1 {% B R) b+ ^; Q! K! T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 @$ [- A K' ^1 E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 \) e2 F; o- @. E* o+ h" _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- ` k+ {1 t: J0 ]% {# W9 Q/ G) c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 K# Z3 q/ J2 c0 z; t
8 D$ s; L2 K+ p4 T& |; `/* assign the tl som board LED-GPIOs*/
, J9 u h/ b+ M5 q0 m. Vstatic const short da850_evm_tl_user_led_pins[] = {
2 S+ B: t' t- F$ }5 q /* These pins are definition at <mach/mux.h> file */
7 n, m5 B, f. w: M+ L% E- o, a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: H8 K1 w& \( L6 ?# A2 @ -1% |/ {$ h8 [1 l3 o! U' O
};
0 K! s; T8 B& D. w8 {% E) q3 ^# |+ d: R& {5 ~- {1 A
static struct gpio_led da850_evm_tl_leds[] = {
' M4 l& p4 I9 d2 ~0 R {
$ L4 r. O; g9 y' e .active_low = 0,
. w1 n! |8 o% e/ F .gpio = DA850_USER_LED0,4 R/ D7 J. {4 l: f* T: n$ k
.name = "user_led0",9 X+ O4 K8 q, Y& ]0 d1 _- S
.default_trigger = "default-on"," Z, l2 q; b" s: ?% J9 @
},
5 j! d4 @4 ~' J {5 g& I1 T/ Q9 x( f6 b% S; d
.active_low = 0,
: r3 E Q3 o( X% ^9 V( h .gpio = DA850_USER_LED1,
& S- H) \/ l6 T" v8 L* [ .name = "user_led1",
$ Z. r# f. X+ w( `/ `, X .default_trigger = "default-on",( b, W' A8 ~5 T9 l# P- `8 F2 l$ [
},; C5 c( ]5 M8 b2 e \
{
$ f1 x; S4 W+ v; u8 I: w2 F .active_low = 0,
# L4 d/ g8 S- N1 P0 B .gpio = DA850_USER_LED2,
6 K- B( l2 `5 Y j .name = "user_led2",
' z: Z; F" T: x" j2 C .default_trigger = "default-on",$ }9 ~0 L( X. n! A3 T0 Q& t; w
},
! @ W3 M0 w" B8 S0 ? {
) R8 }1 @# U; i9 ? .active_low = 0,
) \- J; m* h# Q6 I .gpio = DA850_USER_LED3,
; y8 n1 s) u! Y6 C0 v$ Z .name = "user_led3",
/ n. f L+ m+ q3 V, Y .default_trigger = "default-on",: i! H/ e ? H( r1 n5 i" O
},
, D. ]4 a, G5 }+ Z K: s};' S6 a8 |& I" N) N
: H1 E& D7 T( ~/ B. d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; C6 p# O1 S$ P: _8 E) e7 A
.leds = da850_evm_tl_leds,
# t7 F+ P: j! t- [: x( ]& q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ _ C4 k% Z2 b+ F9 S/ n
};
" U& A6 R* F0 n4 E5 p4 f
8 X0 e: |' r1 \static void led_dev_release(struct device *dev)
1 ]/ Y& B8 Z) z7 r! {4 b; k{
7 }2 i3 B" Q) Y* y9 ^7 y}; [9 B$ `' w; I+ }3 N0 J
" O2 Q4 W" ?- b3 _% W
static struct platform_device da850_evm_tl_leds_device = {' t5 X9 N( {! E( e
.name = "leds-gpio",4 `/ F6 o% O7 S: @
.id = 1,
* s3 G0 i$ u8 B/ c .dev = {
1 @( ?6 Y/ ` H; K R" S" p .platform_data = &da850_evm_tl_leds_pdata,
' G8 w9 E/ d& x, v4 |5 N; ~2 o .release = led_dev_release,5 D5 K% N* g8 h; [
}
" f3 u' M1 X# o};% j1 ~7 [, U" R0 a' ^, [
( N5 ?6 k f5 t% b7 g7 ystatic int __init led_platform_init(void), n$ O+ R7 t, _' G' n3 r2 _) c
{+ u' d# ^. ~1 I% b
int ret;- u) Q z- z' o
#if 0
. U- i, _. B" \' m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! m; `; m0 I, h4 { if (ret)
; [" ]2 W* {, N8 b* n$ c" H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( v( [" i; j! C# R+ T# Y
"%d\n", ret);6 D0 h3 B3 [* N
#endif. n( {/ k% E1 t9 G/ o# ]$ H
ret = platform_device_register(&da850_evm_tl_leds_device);
! w u- F$ r( t. q6 L( C if (ret)
0 _% K: N3 T0 R- N# q4 V9 H+ U pr_warning("Could not register som GPIO expander LEDS");* S9 p4 f( \$ t2 f! v1 h
else
5 c w0 o/ r2 U" K printk(KERN_INFO "LED register sucessful!\n");
, K, C% f8 x* B4 ]& d
4 ^# G$ U* h6 I return ret;
& U4 c% O% f) ^& p3 m! H, @}! Q% N6 }5 L5 \: Z0 I T
^/ ]% [3 H0 Z4 a: B2 xstatic void __exit led_platform_exit(void)7 P4 G0 ^) Z5 X, j
{
6 f3 ?3 [! e! e- T- w/ r! t4 E3 z platform_device_unregister(&da850_evm_tl_leds_device);5 \% X0 k1 S6 M
& ~8 A. s& G. p) d5 a; z3 m7 P printk(KERN_INFO "LED unregister!\n");
5 r% p% e% X$ P# T4 [% W8 m}
9 d5 A0 P: k' c I! i R1 q t, C* \% z5 f/ W! q
module_init(led_platform_init);; h$ l! e+ o) x, s: w
module_exit(led_platform_exit);
# p4 y9 G- _2 Z1 {
6 K2 Y& Q7 F3 r3 w# A: FMODULE_DESCRIPTION("Led platform driver");
) `" ^6 y" U$ `8 fMODULE_AUTHOR("Tronlong");
+ ?+ t) v5 y0 m' yMODULE_LICENSE("GPL");2 N$ f1 b- {, W% Q3 {6 c- ~" \
1 k5 }4 X5 r W( \
|
|