|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- }1 E4 L7 n9 X3 u#include <linux/init.h>0 ]" W5 c/ O" m( [5 K) J
#include <linux/module.h>) ^' \3 h; E' w# i9 d- }& \
#include <linux/kernel.h>; B' G7 t: U8 F0 w" C" W
#include <linux/types.h>
9 A; I% O6 @5 t* S# p& v f* X#include <linux/gpio.h>
e p% W0 A" ?7 z#include <linux/leds.h>. f5 K% @4 y: Q% m
#include <linux/platform_device.h>0 l# U+ H- A+ w- w" V7 \& i
5 i9 R' f2 k% X. N4 o9 [5 R
#include <asm/mach-types.h>
W4 p' v& [. ]# ^" t8 K6 l6 W#include <asm/mach/arch.h>5 ~* I ~ U6 B; k7 V1 C N* v
#include <mach/da8xx.h>
* _3 X+ x/ L/ l/ P* j#include <mach/mux.h>
0 j6 q7 M- i! \) _1 r: f& M* A
$ ?5 u" O9 [# \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# Z7 U. ~& ^" ]# S- o" @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 o$ W( B7 S C& }) x: h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 G, y- e# t% s: U/ R/ V a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ W2 h9 X3 [3 G' ^+ t
! b- C9 a% ~! Z2 C" h/* assign the tl som board LED-GPIOs*/
; K; S! h, \! G9 q6 D: c& ystatic const short da850_evm_tl_user_led_pins[] = {, }! i" ?+ v# D/ d
/* These pins are definition at <mach/mux.h> file */
' c m; f/ g% c! C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: F. Y7 r9 h$ g -1' [- F1 q0 `' k
};
e& A, b3 S- O. D( n0 }+ Y8 s5 o" f! G& G# `- r0 H8 {
static struct gpio_led da850_evm_tl_leds[] = {
4 D/ v$ k( w' o, c& @" z: j3 m {
' g: G- _2 A! L& `/ m .active_low = 0,. n7 r( l. @* \+ t+ D; @' Z* l
.gpio = DA850_USER_LED0,
/ S8 {7 v5 d# R% ~ .name = "user_led0",
: a Y! G% z. h- J .default_trigger = "default-on",' i( {- I+ t1 P B8 _1 n- f
},
5 i2 n, p8 c8 V Z. L {6 f) K& C7 D5 A
.active_low = 0,
* o. b: |1 I. ~ .gpio = DA850_USER_LED1,
% E+ \4 ~. F7 m .name = "user_led1",
9 r* k+ Y! a: J4 O% { .default_trigger = "default-on",! v; ?( p( e$ w+ F) K4 J
},
5 r; j( T: Q% B' L1 h {
2 I- g3 S" Q" P% S1 \- L .active_low = 0,3 y" K) F/ {% N! G
.gpio = DA850_USER_LED2,
5 P0 j6 t" f" w, i .name = "user_led2", n% {) a. J' T! h6 m" H
.default_trigger = "default-on",) `. h. b' X: Q, |5 D! E* U
},. F8 a7 b5 m: e! [6 @( ^
{& P( N. s: g. [% Z/ R
.active_low = 0,
7 A6 z5 q; A/ k- H2 F .gpio = DA850_USER_LED3,
9 G7 b' e8 _) C .name = "user_led3",
+ w% Z; J$ z2 P# i- P5 L( ` .default_trigger = "default-on",
3 ~ t( z d2 D: ^' t$ k3 G },
4 C/ y8 H+ F; u. H};7 g# `- J0 W& x+ O
' {2 n- O1 \/ B" B. N' I0 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# c: `/ Y/ ~/ D3 S .leds = da850_evm_tl_leds,
! O1 A) l6 N( F( P: I" W i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* h- u+ K% b- e+ [0 f
};3 _9 ` R) K6 D. Y( v# g9 F
6 J3 N" k" d, j8 d& z6 Z
static void led_dev_release(struct device *dev)
8 j- t) s" q& S# }# i$ I T; ~{
$ u$ Q9 n# i3 ~# M% J) @; F};
! C# t4 S* q: P' f4 T7 Q2 d3 i+ W" `1 L# A! o3 h
static struct platform_device da850_evm_tl_leds_device = {7 R, ?3 u9 F* V. O, N
.name = "leds-gpio",
- I8 z2 ^# r" {( a1 H. t .id = 1,8 W3 h: j; g1 }3 m- I
.dev = {
9 C8 [4 p2 E; u5 ?& q .platform_data = &da850_evm_tl_leds_pdata,
2 R7 ^0 o& x& Y .release = led_dev_release,- i( ]' S/ i( M: G, {, l/ @! W& f& Z. i
}/ B, W/ m: v, Q# h5 K# V, J0 _# E0 G
};
$ N7 W) R" c x; K1 U; y7 g9 J
( V+ B! l( z+ g: sstatic int __init led_platform_init(void)9 w3 e b2 t& Z/ E: V6 {
{
- K1 y) L+ ]; Y& ? int ret;, @# ^. P8 ^ ^
#if 0
# \0 @/ v6 H g$ [+ E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. g$ B0 g) c! N if (ret)% C- q8 M! V! u6 G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" A6 c" ]* v# r" H# j$ b8 t
"%d\n", ret);: K: h7 ~+ g. j9 G( K9 P
#endif9 B& w: t h4 ?! k
ret = platform_device_register(&da850_evm_tl_leds_device);
* N& y" _: r4 M$ A1 L, y7 Y1 Q- [ if (ret)
! K! d# c8 o0 e2 F, A pr_warning("Could not register som GPIO expander LEDS");0 r# Q7 _: {' p2 b4 I1 V
else
1 k3 D0 h7 o& J) E printk(KERN_INFO "LED register sucessful!\n");; T3 B4 h' x6 K5 l/ h
$ j* X1 O3 x1 L# W, a$ J
return ret;
0 c) c; }# a5 A; Y1 q}& W# h- k, O# \
+ v4 {, f, f+ z7 l% y
static void __exit led_platform_exit(void)2 q+ N' ]6 m# N) ]) f6 M9 q
{: ]- D9 k" W- {
platform_device_unregister(&da850_evm_tl_leds_device);# e+ B; A! [# e7 c
# ?8 l, Q4 y( @9 `; C
printk(KERN_INFO "LED unregister!\n");. p7 w1 C1 }% A8 B
}
: u6 u$ z: d( R! F
, |# q; H5 _7 Zmodule_init(led_platform_init);
1 U; B# |" G( i. zmodule_exit(led_platform_exit);% F; ^. h$ I! |) [0 n: M
5 P; E# k9 h' X* m! {1 @3 I! E( SMODULE_DESCRIPTION("Led platform driver");. C' ~, P- @9 L$ U2 s
MODULE_AUTHOR("Tronlong");
( A$ O, f& q+ l/ O, fMODULE_LICENSE("GPL");: c0 l$ {" p, b0 K( S! F0 b: Z/ G& O- `
) ?- A6 B Z: E |
|