|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* Q C8 a/ C- s0 `! a& A5 F+ G
#include <linux/init.h>
5 F0 c8 b2 k$ J, c0 K#include <linux/module.h>3 o- n# K% \4 k8 m& L1 K
#include <linux/kernel.h>0 ?5 w2 `+ l% x* ~) Z
#include <linux/types.h>
/ a% Z) D" `7 ]! H/ p/ t#include <linux/gpio.h>
* I5 C7 ~+ _( b4 U0 U- ?8 Z! v5 ^#include <linux/leds.h>! Z* {) s2 d5 \7 r& c
#include <linux/platform_device.h>1 n; E5 D v1 k3 d) ?6 k
1 \( A1 j2 W* ^
#include <asm/mach-types.h>
" h/ o( q8 @! L+ w, |2 @7 o! i#include <asm/mach/arch.h>
5 p8 R9 g2 C7 A' r# B0 K0 x#include <mach/da8xx.h>% x( D/ I0 u1 o' E* L) D- x
#include <mach/mux.h>
8 k" c: x( Q4 ^$ E B% A/ N F, t, L- i" }6 O5 N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), G8 r. \. K. ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- U1 ~) P( c' J, |0 l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 B# D0 [- v7 V1 `" f' X( _8 s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& e/ r! i+ i( p4 M8 Q9 {( ^7 v0 @
2 b4 B8 A( l5 N) f! `9 q* ^/* assign the tl som board LED-GPIOs*/
# @0 q+ r7 l& t( T" Kstatic const short da850_evm_tl_user_led_pins[] = {) f) V/ i1 n: `( `, B* u
/* These pins are definition at <mach/mux.h> file */
; t( j6 t! I6 N1 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; w: M8 e: J# t; O, x4 T- P* d -13 l3 o# j. T. o5 b& N: ?+ y
};
- _# M- t z" [2 Q' w1 o
: {! U# j* L7 K( Hstatic struct gpio_led da850_evm_tl_leds[] = {
" G0 `0 [4 S$ A: v" ^$ T {
/ `" h5 e* s0 a. _' r" X .active_low = 0,
/ o7 i8 G3 D$ s6 \ .gpio = DA850_USER_LED0,
" T3 X( @, q6 U7 L! C* Z: f .name = "user_led0",; V, N6 N5 S+ w
.default_trigger = "default-on",$ g6 p2 A$ Y2 ~: ]" Z N0 R2 P5 o
},4 [: V0 j) Q2 P5 _1 V' y5 ~
{: x/ W5 U7 I+ m: q; b
.active_low = 0,
) G3 t- x2 e- Z9 h; h .gpio = DA850_USER_LED1,7 n# v: S; z" M' j* b" o! g7 K
.name = "user_led1",( y3 r9 F- |/ v/ i" g* ^+ L0 _* ~
.default_trigger = "default-on", w" X* d/ X3 W0 X
},2 I+ W; M/ h: x3 n# T
{
2 s1 S/ W* _2 `( I* y( o! Q* W .active_low = 0,; A' P% h& C5 R/ r! R
.gpio = DA850_USER_LED2,
5 w: |6 F7 ~# ` b6 f: s3 ^ .name = "user_led2",: s* r, e% U1 A- M# l2 T" ?
.default_trigger = "default-on",
3 `* k P7 w4 `! j# b" Y2 c, r },) R$ C! \) K4 k- h6 e
{6 b) W$ Y8 x5 o( \0 S4 v
.active_low = 0,
: g7 @5 D; I2 |0 g% p .gpio = DA850_USER_LED3,
1 \9 Q! @: @) d; d- A2 m .name = "user_led3",, X" P% u$ t. |3 t2 Z: F
.default_trigger = "default-on",7 r0 o h$ C" j& _9 z7 Y4 |
},
/ [# T3 C2 Q( h2 @};2 T9 @2 M$ W5 s0 M" K c
: Y# C6 Q N! J" a, Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ _% Z& k- A' c, `; f: }) V6 \4 ~ .leds = da850_evm_tl_leds," I. y! q' }$ m: N& V. g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
H8 M& [1 U9 ~/ U0 \};
& {" G& o& n+ D
3 ^6 O5 w( q7 k: x8 A$ d( U, nstatic void led_dev_release(struct device *dev)- F8 w" b% P, R
{+ C, p/ x& l- m% m0 I% f1 V6 F
};9 M! J1 a" r* e& W
8 g& a% h) R% P
static struct platform_device da850_evm_tl_leds_device = {
$ u. G6 r8 h8 x- c4 k4 W .name = "leds-gpio",
0 Y$ k+ {* l& l, X9 ~' w& E .id = 1,
% A1 @* m% M2 v8 D9 L3 h .dev = {' q, t2 N2 f) v' ~4 r- }* Q
.platform_data = &da850_evm_tl_leds_pdata,
: q% k- R; L$ m+ Y; V .release = led_dev_release,7 Q: h9 S! g) q: }) N6 j
}
0 u* D& P% z( r6 A};
7 ~* u& o6 s% T6 q8 E' _ p- [3 U, W7 |: t" F
static int __init led_platform_init(void)
- V! z# P6 }% U6 X/ ~' k{3 J6 U8 J3 r x9 c _; |1 ]
int ret;
% O) i* n3 l( Y l$ N#if 0: }, r0 I6 \. |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ E& I: v B" ~9 ]1 M
if (ret)
% G& o% C, v1 c* H7 J, q1 q9 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ u4 U, g3 w% x+ e8 R& c
"%d\n", ret);
( |- p2 _! ]1 G, l' `) f#endif* P7 I; K* o3 _) R- s! Z
ret = platform_device_register(&da850_evm_tl_leds_device);
. g8 j7 j" ^ y0 {% N% e7 _) X if (ret)
" C; U! I$ u! r0 _" W; O0 u pr_warning("Could not register som GPIO expander LEDS");
4 K: {' u2 o2 a1 X9 N else1 l# ~, X9 e9 d q
printk(KERN_INFO "LED register sucessful!\n");# o# @9 x' K3 r0 t4 p( @. e3 r; m/ k
2 _' R$ G$ r2 V
return ret;0 z: y, a/ E' v8 _% j1 I3 w- M
}. a: L9 Y0 n* P9 Q
" e/ Z; E, P/ b' A
static void __exit led_platform_exit(void)2 ~* `# l4 H' |
{8 x# M5 c& o2 g: i
platform_device_unregister(&da850_evm_tl_leds_device);" J1 G' E. J/ g) T
+ M9 e$ x+ L' r. Q
printk(KERN_INFO "LED unregister!\n");
4 {% h3 o3 \( Y& Z* A, ^. X) k}0 j5 r# a5 s/ s7 H
5 E7 b( D+ J* a; _9 j0 \4 wmodule_init(led_platform_init);- M- p9 c8 q0 Q% c
module_exit(led_platform_exit);; f- v6 g; q2 C- D) ~3 m, O
5 q5 q5 Y* G# oMODULE_DESCRIPTION("Led platform driver");
+ ]8 c. p9 ~, R( GMODULE_AUTHOR("Tronlong");
4 Q) I9 ?1 @; q- \: C) F9 E# aMODULE_LICENSE("GPL");
& Y/ a! O# d+ [4 o6 R# j+ }- |, Q% d. y: Q* U5 T: J: j
|
|