|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 u8 G' J- ~3 E( m6 w! x9 X
#include <linux/init.h>
! G' h/ t; Z, P- o) I! N! U$ f#include <linux/module.h>
, O; |7 g- ]3 f4 f#include <linux/kernel.h>! D* z' s* k+ [; [" }, k
#include <linux/types.h>. @7 n* ]! p" @. d
#include <linux/gpio.h>2 H% g/ m, u! u: ?' s- g* H
#include <linux/leds.h>6 N8 X5 M }; g; ^
#include <linux/platform_device.h>
' U. r) l! S+ _& a( W
+ R: e0 i5 ^4 Y* k9 {% l9 h2 x( k#include <asm/mach-types.h>
" ?8 F- C9 ]5 d) q( l#include <asm/mach/arch.h> @7 D( J* \- [, e/ `
#include <mach/da8xx.h>
9 J) }2 H+ i2 C# z3 |#include <mach/mux.h>7 B) T6 R h, r M- ^5 r/ _
9 Z; I) k9 |1 `4 }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; X6 }9 t0 x" N) T. U! U# ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* ]- @; C9 ?; ]' j4 s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" y1 y* M: y7 {9 i1 t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ X0 g/ g9 v/ Q% L- c% }8 c
2 D' d) K1 |4 M R0 J( r4 w/* assign the tl som board LED-GPIOs*/
. s7 s) M& H P4 l* Q4 V8 R2 pstatic const short da850_evm_tl_user_led_pins[] = {
+ a) ^* h0 @5 j: t% ]$ b /* These pins are definition at <mach/mux.h> file */
3 a5 \8 M- U/ E+ a) e5 H9 k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 D3 n$ \7 f; Y0 y' g( ` -1+ `: v: k# K5 s* A9 w# h. Y" ~
};4 l0 i$ ?" O) u5 x
! h' |' E+ y$ D+ n$ y# m; ^static struct gpio_led da850_evm_tl_leds[] = {
# O& n. ^0 h7 }" [/ W/ E4 e {
5 D$ k- R2 B5 ~: ^ .active_low = 0,$ D1 }) H$ Q" E; R0 n5 s$ d1 r
.gpio = DA850_USER_LED0,
5 a4 {8 N& c I; w' }5 z, K+ n .name = "user_led0",
3 D9 n8 ]( s* ]# D: V .default_trigger = "default-on",
3 Z `- K! [' M4 F# _ },
8 B; ]; Q9 ]; `+ T1 L2 o {: t# G2 X: G7 @/ s1 R
.active_low = 0,5 e6 w5 {! v' _( i1 R
.gpio = DA850_USER_LED1,( o% o; h8 x) U2 t d' n! L2 Y+ P5 [5 F
.name = "user_led1",$ r7 y& e4 ]& g! O) ]
.default_trigger = "default-on",2 G) R; g' n( G) N( B
},, m4 L& b) T3 f( [
{
( s7 s$ W2 i" F- b2 x .active_low = 0,6 ^. S( q5 A0 t3 ?4 C" R
.gpio = DA850_USER_LED2,# U! O: J5 x5 Z3 K4 p% T
.name = "user_led2",
) g; j" M/ X0 m7 p" D .default_trigger = "default-on",+ M- w% \9 `9 y* c
},
; M9 b. W! I6 N; g" }) a d {
# D) e! _) H+ K2 m .active_low = 0,
2 d5 Y7 w+ U( y1 [* J- N8 p .gpio = DA850_USER_LED3,0 B& g' ~) `% V( _) j8 U9 n
.name = "user_led3",
, Y5 a3 ]+ }( v6 v+ M B .default_trigger = "default-on",7 u. |+ u a6 O
},
! j( L9 l1 X- }% j+ {};
5 J5 l3 |% A: a& e0 w$ _; y) d8 \" W7 k2 \* S" W( @" x; k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" T6 M* N" k' G$ ^7 p$ ?/ a
.leds = da850_evm_tl_leds,# O$ s" o4 S/ N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 @( o( F( `( N( O2 O
};
- H% ?/ v1 e8 n0 n: ?. H8 M4 n; s) i6 e5 T1 J
static void led_dev_release(struct device *dev)
* C7 d8 r1 }1 U% a{
2 B9 ^, ~4 ?5 n* S};1 |- n: O6 p! _, E, r! y6 D) w8 [
2 {7 q$ m; @6 P( B. Ustatic struct platform_device da850_evm_tl_leds_device = {5 D8 C4 z( O7 g; i7 W8 H
.name = "leds-gpio",
# E2 A# h0 g: d2 D .id = 1,8 H3 i; S; H& X% {8 ?+ h+ z
.dev = {
. @& F5 G) F) w, N! J .platform_data = &da850_evm_tl_leds_pdata,( d2 S- R% k) R
.release = led_dev_release,
+ r: b; H8 L: r }9 a! P# K: p* |4 V% S% a% t$ s
};1 \5 L1 r& _8 [" u8 V9 _
) _9 t- G8 }+ istatic int __init led_platform_init(void)
0 Q( |9 S$ H% k H, y! y{
* I( U( x+ o7 D7 A D int ret;6 z! Y$ ~' E* I6 I
#if 0
( F: I4 B- w' F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 F3 o5 }5 n2 |+ M; M1 y+ f if (ret)7 R* U) C y: o, a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") y- W: C1 L9 {- V- @
"%d\n", ret);
$ M: w9 p( l! { b, n" t#endif1 x! z9 L: a0 P% e3 L. S
ret = platform_device_register(&da850_evm_tl_leds_device);$ f4 u, I" _; \1 c7 s1 T
if (ret)/ E- U3 p6 w; [' z1 B4 | t2 H
pr_warning("Could not register som GPIO expander LEDS");
0 t \1 f& b( ] else: _4 q6 e! i3 K% R7 m5 R& o; @6 Q
printk(KERN_INFO "LED register sucessful!\n");
0 {( ~+ s" t K7 r4 I) c
# U5 l) U" N k return ret;/ e+ T+ \- `, X. [. r
}
( s+ E2 @* ]5 ^5 J- U; E, z: R# v% N$ B' B
static void __exit led_platform_exit(void)
& i6 O. Y7 b2 g# _2 v{
8 L+ k" }9 @0 H$ f% c platform_device_unregister(&da850_evm_tl_leds_device);6 R; ^% P$ k+ h6 @+ s: G
) E% ?1 Z) e- D5 d6 E. [ printk(KERN_INFO "LED unregister!\n");
5 E Q& i. Q" B, @! O" a8 G}' W2 g: S% \$ r; _1 u9 C
) f! y0 x: B% U
module_init(led_platform_init);& K# R/ H$ e# Z7 z* f5 t/ d
module_exit(led_platform_exit);# A: F7 M9 e, Q! V* C
% [- U0 m: g* M3 v8 r
MODULE_DESCRIPTION("Led platform driver");) m4 S+ Q3 q# B; {0 \
MODULE_AUTHOR("Tronlong");
) q8 H& b7 h# U# ?. TMODULE_LICENSE("GPL");
# W4 {+ {1 v8 @0 j/ J [2 _5 k2 j2 D. Z: M, [# y) {
|
|