|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 v- d. R9 i- [- l. C+ V2 \#include <linux/init.h>
6 B) B) w9 m# d4 ]* t#include <linux/module.h>3 p1 K- n9 `8 v0 ~1 g
#include <linux/kernel.h>4 f* e# s; `8 v, W' u
#include <linux/types.h>
" @' u$ {' z- n- R9 b/ n#include <linux/gpio.h>
3 u4 U% ?1 k$ F8 \2 M#include <linux/leds.h>
: S3 N5 U2 ]; j% T8 z6 T* `#include <linux/platform_device.h>
: `) w1 f( r X8 B7 O* t' N
/ [# Q5 {9 K9 C6 y#include <asm/mach-types.h>
3 I7 _" i) q( \+ N( `% V0 ]#include <asm/mach/arch.h>" J! q! e" ]9 B3 K* f
#include <mach/da8xx.h>
* W. w) p- ]- E1 \0 R/ c#include <mach/mux.h>1 p0 S# d+ i* O. A% @4 v$ @& @3 { G
' K, r. l8 ^% Q7 v; _- _* X7 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) t2 ]$ ?7 j1 K$ a+ ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' W# F3 ^+ y( `% g) ^$ B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" f2 x" q/ @; }5 S1 D' V4 d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& l6 e) C D$ R( P/ v8 x8 y- L9 d4 B3 g Q
/* assign the tl som board LED-GPIOs*/, Q, j9 @6 z; t' |- T* s- g, U
static const short da850_evm_tl_user_led_pins[] = {
9 y; e& c B0 s9 k: v /* These pins are definition at <mach/mux.h> file */7 k0 x0 u4 B- \5 g1 R4 F. r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 _3 x4 V' X% _ -16 q/ l7 @8 \" S) E! v; c3 P) X
};% u# N6 R+ N$ [7 _7 L* t0 `" h- R
% Z C* G& X% f! _" l1 Ostatic struct gpio_led da850_evm_tl_leds[] = {
3 t) I, ^0 h7 R4 j7 L/ F5 X1 T {2 I8 R3 Z$ Q2 @" Q4 d' A0 _9 j
.active_low = 0,6 @( j+ p: D }9 S i Y+ [2 l' n
.gpio = DA850_USER_LED0,) F" K" j) I2 X; ?
.name = "user_led0",
3 R) h0 p9 c7 B( [1 _ .default_trigger = "default-on",
: A( h {: s' c" m },
* V# M) J& M$ m) O! {( h {
& s8 A% }* D& z& U .active_low = 0,# ^- P4 C" u3 t3 z. Y! p! l4 m3 @
.gpio = DA850_USER_LED1, O. n0 q- Q$ q. q
.name = "user_led1",
. M8 ]6 O7 R, z" y2 ?" y# ~. t) x .default_trigger = "default-on",* \& E5 J2 |0 S# G
},
1 ]4 f& J' U( R+ m) l" W {
7 z$ b% `% ?# Q .active_low = 0,
1 g1 F$ H; u! C .gpio = DA850_USER_LED2,
- f: A- p6 v7 F( X) ^ .name = "user_led2",
& \$ Z' E1 h3 u- e' n: ^# g7 \ w .default_trigger = "default-on",* h& s0 L1 ?" J( P- f" \" B5 j
},
% A. L6 x* u) A# c {
6 W9 b" ]# o( }! \ .active_low = 0,/ ^" b5 K3 N- z! E: Z
.gpio = DA850_USER_LED3,/ y) D8 M9 a7 ] S
.name = "user_led3",
# {$ _8 f7 l; p* i .default_trigger = "default-on",, u' }6 u; Q$ @3 h! H- b: Z
},
" s( Y: J0 a' r) A. b) w$ N};
) l9 i( P3 Q% U1 g H
6 `: S0 F z/ }" f2 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, |3 Y/ x/ d: S- t6 K4 |
.leds = da850_evm_tl_leds,
& @) u4 F- n/ e/ W/ g( m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 W& \) I' `9 K: i; t$ H1 ^};8 D2 a+ [6 b& l6 p
}* V% C3 z. X: \$ Istatic void led_dev_release(struct device *dev)
+ z* o- x. M" F% @' ?{" R, @& _2 Z& F& ?) m0 p) ^3 `1 Y- z+ Y
};0 U4 v3 ?: e6 r" s; {3 a% g
' |+ S! z0 v- x0 `6 ?$ S. X
static struct platform_device da850_evm_tl_leds_device = {
. l4 p( Y( s" n- o6 @ .name = "leds-gpio",
3 ?5 A4 Q9 R) q, w2 M .id = 1,
! `/ h: m: N" B, a8 A; K .dev = {
' J' ^- Y: j4 U+ U# Q .platform_data = &da850_evm_tl_leds_pdata,
9 U. t- C, o# ^3 Q% I6 A .release = led_dev_release,
1 C& y) }+ p& h6 F, @ k. k }' R# U: o7 u/ x* t; A( G7 u
};# d7 V/ D. ^% F$ A/ ~2 Q# J1 p" Q
6 r# b! O4 D3 S$ O$ y! S
static int __init led_platform_init(void)
5 }% E" [! K0 }7 q5 p{
2 n v; A* g: c( m9 ~ int ret;
) `( f- K. G9 ?7 Z( r8 W#if 0: B# a- K. |2 P0 a3 C( w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; D6 w9 d; s* E8 x
if (ret); y& n$ J8 x1 Z' `7 s; ^, _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, r% P* W& g+ M6 H V3 e3 D "%d\n", ret);5 j9 V2 M# W3 i: K+ S2 ~) g* Q
#endif
8 i- t w$ l, A- V" r" Z ret = platform_device_register(&da850_evm_tl_leds_device);
1 J l# g, e7 r' s) ] if (ret)
) @, ~5 C. {9 V# h) x2 s! A* K pr_warning("Could not register som GPIO expander LEDS");- _( K/ I( ]. x0 x+ {- F
else4 O1 R Y* Y- w) B7 P
printk(KERN_INFO "LED register sucessful!\n");
& Q8 ]' ] ?" r; }) m8 p' c% d% L& s% f5 F
return ret;3 K3 v# z% r. y8 G
}
. g/ L( e" C5 X, O$ Z, L. h9 c t$ W6 T" A
static void __exit led_platform_exit(void)& N7 @4 J/ B6 A7 K
{
9 _$ Y' h- ^. z' l& d platform_device_unregister(&da850_evm_tl_leds_device);' D3 v/ j/ |5 G y/ h) M
1 P6 g( ~2 O# W) i1 Q! J
printk(KERN_INFO "LED unregister!\n");/ f* Y3 @9 ^% l" D
}! ?3 y; s: @% {& f0 d0 Q
9 L5 F5 A8 v* w+ emodule_init(led_platform_init);+ Y! H' O* j+ s, q! a
module_exit(led_platform_exit);, q2 I4 d2 w8 }9 \- q
# N9 c' T; p1 `
MODULE_DESCRIPTION("Led platform driver");
9 | ^7 }( o3 T$ i" GMODULE_AUTHOR("Tronlong");
8 V0 d K' K6 \& DMODULE_LICENSE("GPL");1 \& X% ]- T( T
( [. I& [( o6 h& b4 ?. [ |
|