|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 C' W6 m8 ^& i( J4 q
#include <linux/init.h>
) E( p) d9 j4 U: Z; u#include <linux/module.h>
; J( l. \9 ~4 |" p2 {#include <linux/kernel.h>/ A" R# T; ^9 ~' t# O' q+ p
#include <linux/types.h>
6 {% b) B* H% V" f2 c+ A) _+ ~! g#include <linux/gpio.h>
2 K% H' w: [, S5 O0 Y" x#include <linux/leds.h>0 K! ?' `7 ]/ G) n+ k/ g$ V% ?
#include <linux/platform_device.h>
) C5 U' d4 T, f( S4 T- _! b9 U. H' ?3 {7 _8 _
#include <asm/mach-types.h>, S! }; h! n+ [5 W7 i
#include <asm/mach/arch.h>
" p1 G; E( j% \- T#include <mach/da8xx.h>
' `* u, q5 B( I C6 K#include <mach/mux.h>, F; c- E- j" @0 a+ [4 u
$ i# `+ V1 L' B" K. ]! w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 E: z4 [+ k3 T% `$ n) V: A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ t( r* s/ ?! E) |2 K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ N5 [7 `- k- O T) S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 G9 b2 D! I( E
$ p6 K# T: g1 x9 t8 [
/* assign the tl som board LED-GPIOs*/. r4 m4 X& o0 g
static const short da850_evm_tl_user_led_pins[] = {' c- \% E S) X4 L6 r( F& F
/* These pins are definition at <mach/mux.h> file */5 D7 J$ u& T' U( x+ ?" w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 }% e- {+ y( P: W6 R -1' J* K, F: \3 h
};! q* o4 d! s- f7 C/ @
0 ?7 ? b8 a6 Lstatic struct gpio_led da850_evm_tl_leds[] = {% @; m2 ?7 }5 K ^* a
{
) d3 S$ f( e+ B! j: A' W: @ .active_low = 0,* Y9 n1 W; }9 C. ?
.gpio = DA850_USER_LED0,; n& p, i8 c, G( |7 C4 N
.name = "user_led0",) {; h% R9 {4 U S( G
.default_trigger = "default-on",# O! T8 |8 Z' T+ w
},' q: K" l _3 }7 z- |( p7 X
{
- `6 u2 n+ b4 P( T$ F8 V( _1 Y .active_low = 0,. O0 H; C( u# v+ U' N4 L/ i
.gpio = DA850_USER_LED1,
- F( A1 |1 @, C F$ r, q4 N h7 h2 N .name = "user_led1",
7 q% F3 M6 [/ z# f+ h0 c& H+ w- m6 \ .default_trigger = "default-on",( v8 v6 E H0 c) V! X* s
},
" w: B( J& y: u {9 I) o; _7 {, V' a" \
.active_low = 0," ?# c. s/ h. i
.gpio = DA850_USER_LED2,9 C& }- T, b4 L+ y- V
.name = "user_led2",
# E, H! t3 X; h3 V7 I .default_trigger = "default-on",
) H8 E) b* [, E' |2 J8 z$ X },# B8 {2 a( B6 ^: M0 E1 Z3 K4 d
{
, f' s7 `) c |. V* N! ?! E# N .active_low = 0,
3 G( M3 r8 [) W6 H$ \# J6 J .gpio = DA850_USER_LED3,
v# x3 R/ J) y4 ^ .name = "user_led3",
5 f* ]% M. n/ n2 M. K8 `! B .default_trigger = "default-on",' g1 v" q r# l4 s" b/ v0 A
},. C: B3 U0 Q. e
};
( g& Q+ A1 e) ] X6 ?' [% W/ y8 B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! l3 l) c8 O6 a1 k .leds = da850_evm_tl_leds,' y. ~& D& l. C I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# ^- m+ Q/ [- V. v. `
};
, [% Y0 Z: [: [2 |; H* r" r. Q6 w3 c, R5 G
static void led_dev_release(struct device *dev)
, j. E+ i7 E7 Y# Y) Z9 d6 O X{; ?) n& ], R# P2 A2 F
};7 r! G% X' b" Y5 {" W# [4 i
/ J' D1 [2 K3 Y. b+ |6 w- \- x
static struct platform_device da850_evm_tl_leds_device = {
( z2 P5 P8 G9 Y, z; `/ Y1 Q3 _ .name = "leds-gpio",
{3 z( X( }6 I& E4 W .id = 1,
4 [( f. M/ _& K9 ~9 X .dev = {! g. X$ F, e* E2 ?% X3 \; x5 |! Y z
.platform_data = &da850_evm_tl_leds_pdata,
. M8 X/ N0 C$ R3 M8 B .release = led_dev_release,
0 ?2 e$ _. k( q; ?( g }8 Q- e) o4 C; l) e5 I) l1 x
};
- n8 U N% n3 W8 G, [9 x/ `/ x8 Y" z5 e5 E# M
static int __init led_platform_init(void)! H9 a9 n5 Y( N& U* s& M
{
& [/ {1 J# D) N3 ^" b: Z int ret;% r8 G) \- s e) \2 c. n- F
#if 0) l- ~: m. [% D/ q/ s- b n8 |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( B* |. f# B3 z if (ret)
6 b( o2 `% `3 s: J( b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- Q2 k6 u ]5 q) }+ U6 q
"%d\n", ret);
, ?- z+ Y1 ^9 }+ B$ n#endif
( L! a7 F- o/ U/ r% [9 Q2 x ret = platform_device_register(&da850_evm_tl_leds_device);8 O9 h* q( @1 e' @/ I4 l2 f
if (ret)4 u- S2 c8 F9 }3 t2 `
pr_warning("Could not register som GPIO expander LEDS");& a/ J& O, {% G9 V$ ~+ p
else
* a7 R# |8 u/ y8 ^8 Y printk(KERN_INFO "LED register sucessful!\n");
$ J6 o8 E8 B! S' t: G9 h- F, g: a1 j
3 u) C# F3 a- z4 n0 d* ? return ret;- t" i- R: }/ a5 x0 d: m( V' h
}
" _" W) }% K) E
$ c* }2 _8 }5 e2 A: ?static void __exit led_platform_exit(void)
4 G, P) E! a g/ n{
. Z$ b* t g/ _0 o platform_device_unregister(&da850_evm_tl_leds_device);
* g# R) _0 k) U, c7 H# c" o( q |, `& p7 I) h/ a& S" @4 }
printk(KERN_INFO "LED unregister!\n");
4 Q8 `. |" A' l8 m; l) i}4 {5 G* m5 p7 G
; E- m6 g9 G- X( X
module_init(led_platform_init);1 w7 h% i2 v) S8 [& J+ O8 s$ d" t0 B/ B0 R
module_exit(led_platform_exit);1 B9 z9 h. q# P- T, }8 X
: b+ Z8 p/ z, w W
MODULE_DESCRIPTION("Led platform driver");
' `( j! |3 K- B' ?1 y5 tMODULE_AUTHOR("Tronlong");
- q2 V3 |2 j0 q( WMODULE_LICENSE("GPL");
9 p1 |" T$ |' X- x( V! \. Z( ^+ }) F9 y( P3 i# s
|
|