|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 g3 q$ k$ J2 u2 y& ?#include <linux/init.h>, @9 S5 K% U; | Z" Y. |
#include <linux/module.h>' ]! S' z; ^' |' `6 f. J
#include <linux/kernel.h>
8 ]4 o) F* g, L( Z: s6 W#include <linux/types.h>1 V1 {/ Z5 e/ I7 G! I" ~
#include <linux/gpio.h>
1 ~8 `) a4 R+ O/ H2 A4 w9 h#include <linux/leds.h>
, m, s2 }0 s% j& U#include <linux/platform_device.h>
m) s1 g7 B# U: i) \0 [, C; B/ M7 X7 Q$ N: {% H2 _
#include <asm/mach-types.h>; P' P ]+ C- ]4 I0 z
#include <asm/mach/arch.h>( \" W/ F7 M/ O: ?
#include <mach/da8xx.h>6 [! m: B) k, h, I9 R
#include <mach/mux.h>
$ B; N, Y. G4 M1 _2 O
% H! _2 W& u; e2 P+ F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 l3 f' M! o) x! _0 C, K0 k h9 H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ H0 P6 W0 t8 `6 v! Q5 D3 P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 v1 t0 l$ y' B- @' B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 A' ~' b$ P- [) v
. @, C% F) Q9 @0 o3 |; t7 \/* assign the tl som board LED-GPIOs*/
5 r, J( k4 s% Sstatic const short da850_evm_tl_user_led_pins[] = {
* |+ G& E0 v8 V3 b /* These pins are definition at <mach/mux.h> file */
# E9 J9 W y) v9 L3 |* \3 n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: o- A6 T9 U' l _: @5 k -1
' ` M! ~7 i" Z};% F) i6 I4 u, M \: a/ d. r
; H3 e9 z1 z" d2 x4 w
static struct gpio_led da850_evm_tl_leds[] = {
0 R/ j. ~. |9 D8 _ {9 n( I N# Y- x8 a
.active_low = 0,* |9 W1 v% x* h, q9 U5 _+ ^
.gpio = DA850_USER_LED0,
& r& }* H% _. ?# J# o9 F .name = "user_led0",. R! V# |5 ~8 s# j2 p: b
.default_trigger = "default-on",
3 G9 _% V4 Z, Q; x: P },7 Q' u) K: T4 r7 P: f
{5 i" `. {! o+ x/ E/ {+ Z# R4 H
.active_low = 0,
$ i$ f" T$ u& b/ i! r1 D3 [6 Y ^ .gpio = DA850_USER_LED1,
! J; E# b6 I( a4 z .name = "user_led1",
5 x: Q4 R2 ?8 ?. E5 L3 d0 \& w .default_trigger = "default-on",
4 s4 \/ [- h' a" m/ y8 V },5 ^1 ~0 F& x$ @* y
{
' s+ `* A6 ^! G1 H+ b2 c; M .active_low = 0,6 b6 @" B1 n% M% K* b& a
.gpio = DA850_USER_LED2,
' x( s! {& N% X .name = "user_led2",* E/ \6 t, Y+ c! g1 @' q- T. Q
.default_trigger = "default-on",% m. Z% y+ \- c7 u; a
},6 N, y5 g, Q+ Z2 B
{. V7 X. B! _2 s
.active_low = 0,
) L# o) ~+ k5 }2 A( Y .gpio = DA850_USER_LED3,( H1 G2 L' Z* [1 j/ r% s6 @* W
.name = "user_led3",
# u! R2 @ B/ T" n: N .default_trigger = "default-on",( m5 c) |- P+ s7 N9 ^
},
0 H+ s8 s6 K6 V9 M4 O5 X};# R$ B# _# B1 X& Z$ \; T' r; i4 Z
* K" T& b2 l$ p: d5 u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ s3 |3 a: w! U ^2 \, k! s .leds = da850_evm_tl_leds,4 X& S, Y9 M6 R+ m" P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) G- E2 N- k8 A9 B" X};
: ~. A; B/ h" q% P9 C! r- `5 B5 ^% Q/ f7 c
static void led_dev_release(struct device *dev)$ a* ^% z- K, W. @+ }& ^0 G% o5 x; Z
{
. d. C& k7 H- S& B0 I6 G0 E$ K};2 p& }! ^7 W3 `) G& ?* b/ P
* |, o" U8 w+ N$ M# W
static struct platform_device da850_evm_tl_leds_device = {
5 l, f9 N& }$ \5 {/ ^ .name = "leds-gpio",* M; h; C$ B- H- s$ d
.id = 1,
+ H$ U- ~4 j! v i# J9 l; g; r .dev = {5 p$ }) j" W3 n; t, v4 W0 i3 h3 W' ]
.platform_data = &da850_evm_tl_leds_pdata,# D5 {* }2 c f& V
.release = led_dev_release,% u- \1 M) p, T1 o; x+ R* R
}$ P5 S) j$ u, j9 h4 v( z+ P* X
};/ h, N2 E: C! \* @2 |
" o& L/ M9 Q7 N; Istatic int __init led_platform_init(void) t0 b# J" E; T5 y7 p
{
% k! ^( i/ `5 Y& u% O int ret;- O2 t1 Z; H( x) l* M+ l
#if 0
( G$ @) V& ~. P1 Y# B3 p3 p( M7 t: D3 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" N. x# Q% l4 }! x) x if (ret)
9 H- k: B) R# ?. [# o% O3 f2 U5 t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 X- Y$ o5 e/ r( b4 t8 k( Z( K
"%d\n", ret);
3 |& r- b1 J/ S( r" o1 g7 h" r#endif8 B$ s7 w' u/ |/ J! w1 f& A+ _: {) V
ret = platform_device_register(&da850_evm_tl_leds_device);4 M6 c4 B* ]: u% N
if (ret)0 V- k$ ~2 E, J
pr_warning("Could not register som GPIO expander LEDS");
, x7 D; b* g$ {- o( R else
. w x+ z3 q( U" e1 g9 N printk(KERN_INFO "LED register sucessful!\n");
( _ v" D4 I4 E2 Q5 K7 |1 U
2 G2 [2 A7 l9 A return ret;4 k9 ~ Z1 | m
}
2 u, }* ^- |7 X! Q1 Y7 T: U2 x. x% A
2 c1 a6 F. M1 _/ Ustatic void __exit led_platform_exit(void)7 ?7 F; H+ i8 q/ S) h7 p7 n4 E1 m1 x8 L
{
/ _7 R7 M& t- A& m& y platform_device_unregister(&da850_evm_tl_leds_device);
& K& X2 @$ s2 W* o1 B: F3 g9 |4 k* t. R3 j/ Z: x( x/ W l
printk(KERN_INFO "LED unregister!\n");
' V% n2 |8 w0 U# r& \}8 H5 W+ K. T* P( V) ~5 n' b' o. L0 ]
6 d m j' ? \1 ` }. `# d& Q4 gmodule_init(led_platform_init);6 d- f; f, V" ]: Q; f$ P: S0 f
module_exit(led_platform_exit);
% b* }9 R5 g: w" w; ]; [9 i5 }; b1 E) L0 h
MODULE_DESCRIPTION("Led platform driver");
' o, Q+ m0 P- G( r/ n: z2 y( Y( q, _MODULE_AUTHOR("Tronlong");
9 U5 T$ c- g5 \* FMODULE_LICENSE("GPL");
9 Q* f4 _6 g/ b5 v8 @4 Y6 j+ C$ S, f" _7 K+ {: c
|
|