|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' V1 T1 e/ K0 c b7 X6 C#include <linux/init.h>
( O3 r: V# m* |/ f' m1 D6 E4 C#include <linux/module.h>
; B2 J3 o1 S& d4 Y9 }1 U& d#include <linux/kernel.h>
5 r" g9 n. S& h& S9 U2 A2 U; _#include <linux/types.h>0 ]) X( _% \ w: T7 x
#include <linux/gpio.h>
: ?2 \8 B/ ]9 l: T#include <linux/leds.h>2 B8 C. w/ L1 M4 ?: x
#include <linux/platform_device.h>
: H" w* @5 y1 R- ]' \
, M; u* D v6 M5 B' w+ s#include <asm/mach-types.h>
" h' M( ^, R& _#include <asm/mach/arch.h>
9 U" y' I! Q, \7 j( U8 r#include <mach/da8xx.h>
M4 T8 b* q* S' x% r2 p$ n$ A#include <mach/mux.h>
( f$ o( K* H# E, e! ~. z6 Q6 G" C; ~; ^/ a% C7 O. f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 i( c L# Y) |/ m) ], h8 h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; n5 h4 u# M- ^7 f* R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 T1 Z+ R8 {# H: S T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 \# B. a. u, I. @+ b# {
2 y% y: c2 Y% o+ h# T/* assign the tl som board LED-GPIOs*/
% I7 y" C# s/ i. x0 f9 F9 O( U: jstatic const short da850_evm_tl_user_led_pins[] = {
. Y4 {0 N- E1 f /* These pins are definition at <mach/mux.h> file */! Q1 u( j6 N1 G$ a# U8 Q6 Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 w- Q2 C/ L3 x1 z- [) q: } -1
7 j5 o+ I7 p: v# s" [};% g( |. P7 d5 k4 m
4 [# ]2 x! X v# N( q0 Vstatic struct gpio_led da850_evm_tl_leds[] = {
$ B0 T, W8 |4 L* r1 \3 p$ y {6 C% q8 Z' m6 w3 }* t! k! X
.active_low = 0,2 b* Z3 }$ g) \6 N; v8 t
.gpio = DA850_USER_LED0,2 G' a$ i2 r b6 C
.name = "user_led0",
% L: r: u6 E5 x .default_trigger = "default-on",
" G+ _' i8 v5 ]; Q7 A- ] },! H% K: n: r. ?6 j( e: ]- S: y
{
( B/ H: \: L( ~4 C .active_low = 0,2 O0 w7 M9 Q2 c! z
.gpio = DA850_USER_LED1,
3 F) o+ ^1 w7 D# V3 }! E .name = "user_led1",- B: r' u: K5 Y2 c! U
.default_trigger = "default-on",, R) ^+ k8 ]; X* H5 p) x6 |
},2 ?2 |( P& d6 B! y! v
{5 c3 @! I) S n( _9 h1 v
.active_low = 0,
0 j# P4 M0 X+ O8 s8 b! z .gpio = DA850_USER_LED2,
: l( X, f# k0 F1 I: D# U .name = "user_led2",% D, u; |1 x4 L o4 j' S4 O
.default_trigger = "default-on",- F8 I- Q, ?! D' ?3 m3 v/ x( s
},, r. \0 v. L! o& u
{
5 B! k. v5 g" v' u .active_low = 0,
7 e A& Q) n9 q) U+ \: A; J .gpio = DA850_USER_LED3,
0 ?" E" ]4 W+ `; k7 Q9 k5 A .name = "user_led3",) n& w# o* C% i: \9 E# V3 r( b
.default_trigger = "default-on",+ a7 b' E$ ^+ r
},
( f7 E8 J+ M3 Z3 l( t7 e9 l& k" X! X};1 y/ ?6 P! h6 ~! @; a
% V" U9 `9 c( z' K/ S0 u1 P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- B7 _ |# r8 y: a2 O# t& I _; M- V6 _ .leds = da850_evm_tl_leds,
% j3 B t9 A8 k6 e) M) T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ g( P: |9 _+ A1 {+ B};
7 p8 A3 J7 }0 d& h u
# x0 A" U' d& j1 D' s+ t* Ustatic void led_dev_release(struct device *dev)0 V% X1 c& [) [0 R% v: R# n5 c
{
8 L* G2 v# Q5 H8 X/ v};) L" a8 ]# u% I; j1 z* {3 e
+ Q: X$ A3 R `static struct platform_device da850_evm_tl_leds_device = {3 `) z% B7 z" u! z9 \9 g0 H6 c
.name = "leds-gpio",/ b# F$ Z( R% M& i8 O: |. M6 H
.id = 1,9 s3 e0 t, [7 f" g6 z
.dev = {7 S3 b& n+ Y7 U! k6 F& F
.platform_data = &da850_evm_tl_leds_pdata,
& J& s7 w: s5 z3 D& O& P& D .release = led_dev_release,6 T0 ]7 f u$ x
}. ~$ r. m c% C. h. y C# b
};
- Z5 G5 @9 f, x5 s0 ~; i) f5 t0 V, Z- M3 T7 C" X1 b- W
static int __init led_platform_init(void)% \! P# ~9 x `5 {# {8 H
{
/ V- I9 p r/ `' K2 q. V int ret;
( T+ [) z- t" |9 b, |4 I#if 0
' Y. u" g' |, J9 f+ K. ]) V% r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; z1 o1 a8 Z9 s, Z if (ret)% R2 @! ?9 K- d* g/ i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 ?! v H" n: u8 }' v& M) } "%d\n", ret);/ u9 e6 ~* G; p8 Y, P: O
#endif
" J" x$ X! `# h( J3 { ret = platform_device_register(&da850_evm_tl_leds_device);
* C6 R! T; w( r if (ret)
4 G! q+ Y( j) }7 I pr_warning("Could not register som GPIO expander LEDS");
' v u+ [7 ~: k6 \ else
* ]0 f- ]+ ?5 k `5 O1 @* B printk(KERN_INFO "LED register sucessful!\n");
8 M* l' R& G; E: d- j
/ m) o& s( A8 j1 Z return ret;
# g. U& m' o5 w7 d* Q- \/ l}/ V( z4 h7 C8 ?6 Q9 }0 F& w, ~) W
2 ^5 J3 Y) b( u/ n, c, u5 V0 u* p
static void __exit led_platform_exit(void)
: m( Q3 _. {& R" p8 M$ |7 A5 ^{
1 F) w b& Z" d: U platform_device_unregister(&da850_evm_tl_leds_device);6 x% L! |* w# o% q% M% l/ i. m
1 @1 j: w! r5 g( }+ Q
printk(KERN_INFO "LED unregister!\n");
. n- R$ i6 D. S8 a7 t7 \9 b2 O+ d. F3 n}% Z: [9 a0 g ?1 l$ n" [
2 E. G- G. n7 S) mmodule_init(led_platform_init);
1 U3 u+ k: O0 J1 F. a" hmodule_exit(led_platform_exit);
1 e" H' H0 ^) q
: N. a; v, a6 S0 g& ^$ i4 V CMODULE_DESCRIPTION("Led platform driver");/ V, I- L9 J* S
MODULE_AUTHOR("Tronlong");4 M$ G& E9 p+ H7 F* R
MODULE_LICENSE("GPL");
' c& Z0 P+ T& c, v) N: p, K3 [* A' Z% z @
|
|