|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 d: x3 P [0 S( ^" _2 d
#include <linux/init.h># _; o; |4 v9 ^/ A" a$ n
#include <linux/module.h>8 U: \2 W8 u$ _( G
#include <linux/kernel.h>- A Q5 j! o. B' G% t0 E) l" ~8 p
#include <linux/types.h>- T$ \! Z, w7 k( u" p
#include <linux/gpio.h>
& I8 o* U' {7 z1 J$ J3 \8 ?#include <linux/leds.h>
2 C: }) z% l9 a+ G1 S#include <linux/platform_device.h>- ?7 k) g, T. ]6 e* D2 G, G
$ T' H" W0 o5 ?/ U$ F6 Y
#include <asm/mach-types.h>
& R4 \. ~6 I2 S5 U* v' A* i! C, F#include <asm/mach/arch.h>$ R, A: v5 [/ M
#include <mach/da8xx.h>
V. @3 G0 j; I5 A0 y#include <mach/mux.h>! ?: t+ m" @, S* k; j$ ~$ x! y
1 S# Z6 v9 _: \* M3 V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, O% h% U- O( y2 P' P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 B- d3 e7 ]: g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! a& h2 ~/ Y. d! m* d5 a- @% a, y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! S$ f# g2 ?+ o6 E3 l3 @. z/ |- c6 A$ m6 T8 Y
/* assign the tl som board LED-GPIOs*/
7 N! B6 X9 {% i! H+ pstatic const short da850_evm_tl_user_led_pins[] = {
5 g* \' a' T' v# J; }: K* t# i /* These pins are definition at <mach/mux.h> file *// O2 {6 o& e# Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. D0 U1 Z9 l* Q) Q/ P7 n% m
-16 ~" k* i# X' @# c7 v$ I# I" T" H
};
* X( h- `" R. j8 U" r
/ v, B) K" [( Y V1 w! Qstatic struct gpio_led da850_evm_tl_leds[] = {( x0 ~1 t0 a0 @8 a, A+ s
{
- L; W. i. Y, x/ y .active_low = 0,
1 G* l) _' Y2 A, w2 \% o) K3 E .gpio = DA850_USER_LED0,
$ v, t F* O u- k8 l! v7 R .name = "user_led0",# h" A8 C2 E: H ~7 ] o/ g
.default_trigger = "default-on",9 p) D# Q" v* A K/ ^
},2 D, w- W c C0 h% |+ ]
{
1 E9 L, M& f# V9 ]3 L( s .active_low = 0,
# m: R' b/ X7 o! e .gpio = DA850_USER_LED1,
6 u# I$ T" z" {/ `% f6 R9 o8 S .name = "user_led1",% m3 D0 T" \! j" S. f4 j/ l
.default_trigger = "default-on",7 u9 V: x# p3 D3 X
},
: ^/ \; [1 M; ~% L0 | {
, {! Z; v8 G; W. ^+ v* v .active_low = 0,1 k! S6 G; T) M
.gpio = DA850_USER_LED2,; ?1 {+ t- h4 A. A
.name = "user_led2",1 g* l$ u4 c2 R- E* p
.default_trigger = "default-on",: {% U4 ~' \/ E/ t# ^5 z
},: ?3 {/ H% T+ q" I% a
{9 N7 U1 z+ S0 X" e
.active_low = 0,5 x1 x$ y+ w2 o2 V2 `' j( M4 |
.gpio = DA850_USER_LED3,) P1 Z& Z* x7 S5 ~
.name = "user_led3",
: G A! ?5 g2 g) I! Q .default_trigger = "default-on",* J; j- s8 N6 u$ s
},
* k) B$ a" R+ ^, B, A5 ?4 Q) k% `};0 E* t. g& m: C3 u ~) o% ?
( P; l' C! I" I/ ]5 z! d/ {8 r. i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- W O4 a5 G0 L( U .leds = da850_evm_tl_leds,* N5 A5 q% \" d5 g$ ~/ G# [) o9 Q& u& d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% L$ [& v6 N) U* [2 O& U$ m, P};* M- ~4 l: L; s6 n- }5 W
- @+ ~( P3 \* E$ D" [static void led_dev_release(struct device *dev)3 T6 c" q$ L* E( T+ U2 [
{6 X. K- w1 A( n0 {8 e \1 ^
};1 D& |+ E* x) U: E
$ C) G. \1 h* z# T
static struct platform_device da850_evm_tl_leds_device = {$ f. O$ h3 j$ d$ K7 e
.name = "leds-gpio",) N- x' s8 g; J; T' t0 f$ _. ~
.id = 1,' ^; X5 s" {0 d, V
.dev = {6 E2 b' L b7 Y G. O
.platform_data = &da850_evm_tl_leds_pdata,
! X+ J: a7 |1 C% V .release = led_dev_release,
7 B: q" T) m4 O4 e' \* I6 O }6 G6 }0 ^. @6 w! W: d
};
0 N8 |$ U) ^* N( j) _0 |6 n2 s) D8 j5 I3 S; {: W6 |. |1 f
static int __init led_platform_init(void)5 l0 ?8 [" R" P" \8 ^7 w9 n
{
' }% b3 g9 R6 H+ L* F int ret;" j/ g4 ?) K4 k. ~1 o
#if 0! M- X# I* y {# J! [( J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! a/ d: G1 Y9 y/ P if (ret)$ B5 P' {' N! x3 ?' y4 H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ `# a, [( j# b) ~* v3 q, b' g) ^$ f9 ~
"%d\n", ret);
. @2 |. _) O1 }, U9 t#endif" T) v" _$ P& C3 [8 u' }! H( @2 ^
ret = platform_device_register(&da850_evm_tl_leds_device);1 J+ s; T; |7 W: q$ S
if (ret)9 R1 X6 N+ E; g4 I z! _% l; \8 H7 j$ w
pr_warning("Could not register som GPIO expander LEDS");2 ?- K5 d# u$ h) G6 }( {5 Q. y
else; ?0 y& j- w: B$ N
printk(KERN_INFO "LED register sucessful!\n");
$ c( ]& ]. F+ a5 I, w
7 E, W7 l$ S6 g2 A. g return ret;
( V9 S1 ^4 E7 i" ~ K}: v3 C) P5 l4 D3 u9 X
/ K; V: ]3 p g
static void __exit led_platform_exit(void)( V% h7 E/ S/ W8 a( s
{/ f0 o; |5 `# {; x) o3 J
platform_device_unregister(&da850_evm_tl_leds_device);
' `# |+ [+ a! h! H) E# R
2 Y/ O/ o1 e2 @) }. P printk(KERN_INFO "LED unregister!\n");8 e: D# X, D' D" L0 {5 I, E5 @
}6 Y, J/ P3 }( z' W
9 X5 T3 W' C; L: ], y) F; tmodule_init(led_platform_init);: R# X* h7 m7 Y& S+ ?& k2 Q Z
module_exit(led_platform_exit);2 U: o5 j' `. E% W
# Z" t/ I1 f1 z, p1 K& \+ DMODULE_DESCRIPTION("Led platform driver");/ Y5 v" p: ~9 c2 n
MODULE_AUTHOR("Tronlong");/ l1 B- Y( [$ O- C& v
MODULE_LICENSE("GPL");' @; a: |* u# B% |( o( a
5 U a9 ^) |: n) Q; \
|
|