|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# @6 d+ ~: _4 _) x#include <linux/init.h>2 }- H8 }' b5 Y' u; h' f0 H
#include <linux/module.h>
a& |+ i# I& F, R( k ?/ W#include <linux/kernel.h>7 h8 C* n' W! \
#include <linux/types.h>
% ?- U6 f2 T; t$ o" _+ }1 F/ c#include <linux/gpio.h>
5 ~ `, ]- l5 E% i) V#include <linux/leds.h># S+ L! U* I. h# C" r
#include <linux/platform_device.h>
, }) B4 A8 Y$ c2 h4 r$ I8 u, d8 X3 S, w$ Q5 n
#include <asm/mach-types.h>1 q; w( o4 q2 \2 k. W2 W# M+ _/ R
#include <asm/mach/arch.h>
& [7 u8 ~6 i g, I#include <mach/da8xx.h># D( v' y( `+ d. Y' O. Q! n
#include <mach/mux.h>( v+ |0 a4 I& T
6 b9 X7 Q- g3 e }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! E' w& y1 n* I% Z" B5 L# X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( c; L. W% v2 N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): A" c0 W: w, t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: X1 x. Y7 d* y& O* ^+ l
" ^7 A+ Q3 q' c; v$ o2 p/* assign the tl som board LED-GPIOs*/
: o9 I$ k7 l3 v( S, _4 \7 h& nstatic const short da850_evm_tl_user_led_pins[] = {0 [2 [+ ?+ ~. n; E g
/* These pins are definition at <mach/mux.h> file */
3 S, g6 O" P. a8 @4 Q# X$ U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ ~5 B. x6 d# A1 L8 C0 b+ H -1
{/ W/ p. Z& A};
7 s i4 E9 H# o+ g6 I' L' H. {4 p& V% m8 [3 t8 Y7 h9 l
static struct gpio_led da850_evm_tl_leds[] = {( F. @( ^: ] j$ z4 j
{
0 U/ V/ N* g$ O, Y .active_low = 0,- v3 E) a2 H2 F
.gpio = DA850_USER_LED0,, [# E4 s" X& q2 l3 T: S: Z
.name = "user_led0",0 q% _) L5 @( M1 I3 c
.default_trigger = "default-on",
: B+ c/ k' i+ M% Q: |) ] },& a. X5 ^& A6 P Y
{, \ H! i9 ?+ N7 @0 C2 I+ M5 r
.active_low = 0," @: M3 f- h' w2 x8 O
.gpio = DA850_USER_LED1,
7 r+ H3 H1 u& g+ x .name = "user_led1",
5 \' }" r2 d* u5 s .default_trigger = "default-on",, e, q, }. A. l* n7 Y; O* T
},
& C) u# d9 }- z8 r6 s7 d {
4 Q5 j! \8 B1 O5 [. ]) o .active_low = 0, ?- e3 r7 A8 M2 E$ n+ Y
.gpio = DA850_USER_LED2," R% X0 X3 d8 A2 n" f
.name = "user_led2",- W% h/ v5 O$ g; d4 @2 [
.default_trigger = "default-on",
5 E' j0 L3 @. U& T },/ j3 }* Q# D0 K n
{
+ x3 E! F8 d, K .active_low = 0,# M" [8 Z- D! b V
.gpio = DA850_USER_LED3,) P. n: ~3 b% z) n$ T
.name = "user_led3"," ]- _2 k: a$ Q+ h' u( S
.default_trigger = "default-on",) ?, W- d' E5 `; K8 o
},
' M( g3 x9 P, U' ~4 D) s};; D# d4 j! T9 p* M. ]& G
2 X1 B _/ e: Z) Q7 @6 E5 [, a& mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, E; h0 B& v& t! s .leds = da850_evm_tl_leds,
7 k0 \8 a2 ^. }$ h1 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, Y; c+ f3 a0 r8 F+ q}; W4 A% }: E+ }8 r- T% Q
3 W) o ~ U- K9 I# U, e, r
static void led_dev_release(struct device *dev)5 A# B0 b8 O; m+ v% O
{! R1 F1 o6 _( x: j
};
! `" B% I1 q0 f4 L- Y4 c: X" A' A J
9 ?: W# n5 u+ q6 g/ w6 p$ i Qstatic struct platform_device da850_evm_tl_leds_device = {+ ?5 J( r& N. j; ^
.name = "leds-gpio",: U5 |/ K0 T/ W
.id = 1,
1 _6 j `" N5 G$ A5 W .dev = {
- D: Y- N3 L, l) S/ \4 W- U4 G .platform_data = &da850_evm_tl_leds_pdata,! [% u" o. n( \1 W
.release = led_dev_release,
' @( S. a* Y+ x$ B+ i! ?0 K; E }* j4 n4 f" D3 Y$ X6 o, U$ B l
};
* [* V- ^0 k% g/ }; `" ~+ h7 p# j* `$ w* N9 T5 n
static int __init led_platform_init(void); D% X7 k8 {# {* {2 R
{
; k$ f9 O6 |1 f' E* U+ O& b5 f7 ^ int ret;
* E, Z% t2 [; s#if 0
( Q! ?% w* t4 s# N- y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( R6 r7 |! f: m3 c+ {# Y if (ret)0 l$ N+ e* X8 ~8 ]! Z+ X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" Y( f; l' ^. Q3 f: z3 p
"%d\n", ret);2 n: o% T- s0 Y- @
#endif
9 t# A$ W. v2 ^/ ? ret = platform_device_register(&da850_evm_tl_leds_device);
@" r' c- `( U" C! {) Q# H) S if (ret)+ X {* ^. ^9 L
pr_warning("Could not register som GPIO expander LEDS");
5 v2 H+ g! a/ s2 t; e$ C else
) `1 e F; p9 h; D printk(KERN_INFO "LED register sucessful!\n");
4 @: n5 `3 Y+ a! R6 w0 m5 m" v) }& s$ I+ e6 K. {5 J. y- v! z
return ret;' j. l% a1 {7 r$ p
}
6 f# k" ]: }5 [, Q
* X3 \" v/ @% j, C% b0 [2 n, R/ Hstatic void __exit led_platform_exit(void)% J) e& L) V. ^( Y" p6 H
{1 b' ]' |# m+ W
platform_device_unregister(&da850_evm_tl_leds_device);3 B2 Y' O( I8 L6 p
9 o* G2 z% P! v printk(KERN_INFO "LED unregister!\n");
0 H, u; w |' m. q/ u+ z}
0 q/ Y, V- }9 _0 c. i: C& ]8 C
$ c2 w" t1 u, j5 X6 o, n0 H2 Vmodule_init(led_platform_init);
2 G1 r" O3 o" h3 C5 A( ?0 D) pmodule_exit(led_platform_exit);
' ^, K: z! J) t8 H& t$ k
6 p8 V0 K' D4 }. b9 Y# k5 QMODULE_DESCRIPTION("Led platform driver");
5 K3 o7 |9 ^+ x2 h5 M- ]6 NMODULE_AUTHOR("Tronlong");
( A/ f" i" [* O7 B, Q/ A# B8 @+ f% }; `MODULE_LICENSE("GPL");
& F! X0 a* l+ T2 J7 [/ ^
2 Q7 a6 q' u. B, g5 I |
|