|
求大神给下面的程序做注解,请稍详细些,谢谢。: e {/ I7 Q1 x% B6 V
#include <linux/init.h>8 y0 G3 S. a! |, p/ P- }
#include <linux/module.h>
3 n* U5 z X, v& T9 D#include <linux/kernel.h>$ p9 j) r4 ?6 n6 \
#include <linux/types.h>
" X% J+ V6 {+ C5 T#include <linux/gpio.h>
+ N. V0 t1 l3 b& t; L0 ?2 \$ F#include <linux/leds.h>
% o% A0 g3 B8 U" t#include <linux/platform_device.h>* z. k5 p$ T# u, [2 z; _
" n5 j/ M& ? A( c#include <asm/mach-types.h>0 Q, e2 i2 @8 h9 Z7 F" ?! S
#include <asm/mach/arch.h>5 s0 e5 x: b' N1 A0 x' H
#include <mach/da8xx.h>
* \: H2 y- t1 B0 J$ q#include <mach/mux.h>
" ^- I0 C0 ]5 Z# n2 ]5 C: o2 Y6 c9 E$ h# v4 n5 i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ E% ~3 h1 r" ~, \ s3 m; s* a) D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 d O+ p; [1 h& b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 I9 }' j. F6 `1 [$ v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% H- n* _6 X/ r3 f1 t/ s
# a [# e1 c' @4 |
/* assign the tl som board LED-GPIOs*/
, ^; s, e! G9 {static const short da850_evm_tl_user_led_pins[] = {. W" g5 f' r- }1 w8 v
/* These pins are definition at <mach/mux.h> file */
5 d5 H6 ?1 ^% N, P+ B- y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 @( s* K6 M& H6 r! | -1
$ e2 x5 ]3 L8 C$ ]};4 L. |0 a# Z, L8 R) K0 z
: z: h- ?1 ?9 Q! Qstatic struct gpio_led da850_evm_tl_leds[] = {1 u/ r* ?( @8 J7 e& J$ G/ e
{1 F# u0 O8 y* w2 z
.active_low = 0,9 J& u) y q( [3 |
.gpio = DA850_USER_LED0,4 j! T( [+ [) o8 E
.name = "user_led0",
8 w% i# }+ F, a! R .default_trigger = "default-on",# `% `2 l2 K# V q
},
" u% ^5 s8 O' V2 u5 b x- u {
7 n0 g1 f: q: G .active_low = 0,
% Z2 e& c! l2 t8 e4 N! E .gpio = DA850_USER_LED1,
6 r4 U- k9 h1 Q+ }' c, N/ R0 ` .name = "user_led1",- J6 k( p2 y2 u9 s! B
.default_trigger = "default-on",; S0 _- [% z6 k7 ^
},. ~: X9 i- n! y0 `+ c$ e
{
8 p+ V* T# P- J% E .active_low = 0,( x: Y0 b* Z3 B+ h% U) \
.gpio = DA850_USER_LED2,! U' z R2 }( t
.name = "user_led2",: u. `" i+ |5 S0 o: `* \1 E
.default_trigger = "default-on",
# Q- g- j' s- h3 S3 h1 t: W },& ]4 _" `1 a* f# }7 C( @; |
{
% h. ?/ d; b: W- g3 \ .active_low = 0,) T& i+ X1 ?+ y7 B' R: S
.gpio = DA850_USER_LED3,
" r2 r8 d& S- s$ D w R .name = "user_led3",
* I3 H9 D d5 b+ K) H .default_trigger = "default-on",6 T1 z& J7 A1 y
},$ @5 f0 k1 D5 _& S7 _, W
};! M: C! s1 }& d) T% @( `: ]
( k; _$ }& A. m/ n0 |: R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 @. m" s) ~: G1 \0 N# z% X& x .leds = da850_evm_tl_leds,8 c0 j8 N9 [2 k! U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% A1 C# U3 p$ V. Y/ s* C};' n; F6 Q' S# j
0 q- O+ N6 @) ?) s5 t H! @ \1 a
static void led_dev_release(struct device *dev)
) l3 X9 C: I5 m4 Y{
, z3 C, d8 O$ A2 v8 N};
( `; c& U2 s( q6 ]& z b q! f/ m" o
* L* t/ v( v s2 W" y0 fstatic struct platform_device da850_evm_tl_leds_device = {2 N C4 m2 H9 ]( s1 V' \- ]: H
.name = "leds-gpio",
2 e ?' g4 Y; {5 f/ K# A- Q! k+ I .id = 1,: z% u, B8 L! N; W
.dev = {+ w J' U; F% @0 H2 ^* f# F
.platform_data = &da850_evm_tl_leds_pdata,
% u1 s% ]% }9 U3 j4 ?: g1 S .release = led_dev_release,+ M6 ~0 x9 G% N7 \( V3 D5 w
}
! n, V# a" t- @, s8 m' e) G: n};7 {3 s9 D' B8 f
% f+ W9 E! x5 v4 Y& \# V% n" Q
static int __init led_platform_init(void)$ n' H V5 q: m2 I. R
{6 ^, f& Y* D% W7 U# l
int ret;
c: t* v& `* I4 K#if 0
. n; J1 k! u+ ]! `4 S: x2 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 H4 ?4 V9 X! E3 k2 R' T
if (ret)6 t* H) T" T# J8 B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; N/ s+ Z9 ?# | G9 T7 @
"%d\n", ret);
7 Y3 x. W* p' G G, V#endif
5 V$ Q4 l+ V/ _0 u2 R, R0 Y ret = platform_device_register(&da850_evm_tl_leds_device);: |' j7 @2 h' [4 o) ^
if (ret)
' S" M3 k% {. x) o& a7 G pr_warning("Could not register som GPIO expander LEDS");* @+ y, ^1 ^( C2 v. I4 @. d5 C
else
3 `. B0 b. D" P/ r printk(KERN_INFO "LED register sucessful!\n");
1 n, R9 P* o+ N5 [: ]) _3 e7 ~
- {! c5 I" R1 |# |9 d1 y, S return ret;
) d) `1 r% v: Q/ k- p8 {& }}
: i% T( v* K, y# U
2 F' R1 o, K' k3 F" B) Gstatic void __exit led_platform_exit(void)) t& o% @$ L8 K: Q: i
{
h7 _3 [* c. X+ w G, g* q# J5 u platform_device_unregister(&da850_evm_tl_leds_device);& [- L* N" e# L) k
. y; N6 S' `& Y% W printk(KERN_INFO "LED unregister!\n");
: i( C3 ?, ]% ]* q! N4 e6 L}
; a( l! V$ p$ E8 ^ B5 l
4 w0 S* M. P, Emodule_init(led_platform_init);
6 w* C3 ~, M+ X1 d3 w( E$ [- c8 R7 rmodule_exit(led_platform_exit);9 j0 G( p( f3 X
# Q' |2 y# A: K& l4 D# U# i6 D% a( R
MODULE_DESCRIPTION("Led platform driver");
3 l5 b) ~( Z+ K) `' [MODULE_AUTHOR("Tronlong");" p, n$ ?" U# h; \
MODULE_LICENSE("GPL");
5 G9 \7 |" n0 T: t, s/ ?/ ?6 ~3 F6 Q- A7 b, n- a; F" P
|
|