|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 M5 v! N- u2 p ?; i& }5 v#include <linux/init.h>
/ x. `8 f1 `2 \" F; [#include <linux/module.h>
" u% e4 \2 B! S2 }' ~#include <linux/kernel.h>
( H8 u3 g- [7 ?#include <linux/types.h>9 `/ p7 S8 E7 O. m; T" P8 @
#include <linux/gpio.h>$ i/ h3 `- N8 K3 S/ h5 V( ^
#include <linux/leds.h>
) u, t! ~8 A% ~/ v#include <linux/platform_device.h>
' j2 v; h: L0 T
( B$ l( h9 [# t2 _3 E6 j3 _ k#include <asm/mach-types.h>
$ J$ [- r" H. b7 L#include <asm/mach/arch.h>
, F& c- G3 @; G#include <mach/da8xx.h>
% C2 z; W, `2 ^#include <mach/mux.h>3 G" A: R( Y' w7 D5 K
x! J9 n: d9 f; B4 A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 m( V8 w2 f- U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ N& y* K- B W) n. S* R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! q0 H9 W7 Y4 W2 T' l6 _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 b: l, j5 I1 f9 U9 ^8 T
4 l# B; n H& Q: ?
/* assign the tl som board LED-GPIOs*/
) Q' X+ ^2 f) Y. X; v, S. h7 {5 Astatic const short da850_evm_tl_user_led_pins[] = {2 a- S8 K7 x7 i- n$ l$ T7 p6 e
/* These pins are definition at <mach/mux.h> file */
* i1 y$ Z, E- V; v0 |' F# _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ B6 e. w2 K0 @5 w- b1 R/ Z- S
-1- ?9 n* ?* [5 V F) b% h( ^
};+ T/ N, b$ t" |$ O* s
+ v8 w2 | Y* f8 I. A7 f
static struct gpio_led da850_evm_tl_leds[] = {
$ v' O+ B& G% j/ o, { {
% e8 Z/ |, W" m! s/ o, A# R- P; _) _' g .active_low = 0,
$ q; [# G, J" c* j4 R7 ]7 s/ { .gpio = DA850_USER_LED0,
- g3 `" T# U0 c3 H5 T .name = "user_led0",( ]$ r$ T0 l. i# q" H% N
.default_trigger = "default-on",- P$ o! s6 Q1 ^5 D* ?1 n+ m3 @; h
}," W6 H4 s: W* M5 b/ Q! w
{
2 H1 f. {3 `$ z/ |% T .active_low = 0,
' A" | n+ h3 V( \ .gpio = DA850_USER_LED1,5 B/ P# T/ L. r5 _1 L. h; ^+ L: a, p
.name = "user_led1",
- M: W! S! V2 B- V: S+ c U .default_trigger = "default-on",9 D( `8 y$ r( g v) N& F
},; n2 b5 [/ M0 @8 w' v
{+ m1 c' P- G/ e) j9 l
.active_low = 0,$ @; R- m% c6 Y M
.gpio = DA850_USER_LED2,
& X' d8 w& C" z8 F- W* L .name = "user_led2",
: { T* F2 T) F2 B2 x6 D5 B3 v) G ` .default_trigger = "default-on",
6 z/ t9 @' I1 e5 C9 }% p% H: F },
& Y+ P: r" d' l' u {% O4 k4 `. g. ^: Z# t1 m
.active_low = 0,$ q0 f0 W' ?# w4 k9 c# }# e
.gpio = DA850_USER_LED3,/ b' x/ ]4 ]) U5 Q$ j
.name = "user_led3",: c3 o+ q1 u' I
.default_trigger = "default-on",
- ?: c( _' }) S9 @ },2 G" E2 o3 K! V/ K2 F" d
};$ f! n6 |6 n) b: D5 O. n0 D% V! W
, ~0 Y) G4 s' B6 r. ?7 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
{' g4 O- ^1 S: n/ S0 y- G .leds = da850_evm_tl_leds,' f$ ^* \; c7 W' w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: p: h, w& W6 b+ J- B# V7 \. y};, c0 b) v8 ?8 c3 W" j1 P$ m
5 [5 S M2 u9 K& d8 o; ?3 Estatic void led_dev_release(struct device *dev)
$ S3 E6 Z% L! {- C' X i+ w: `{
4 [5 _" D1 n6 v0 Y! H};
$ B. ]8 f. Q5 x* x. |- J2 Q9 \8 Y3 w' |% i$ y( I5 P
static struct platform_device da850_evm_tl_leds_device = {
^) w" f- a0 v& M& S9 E$ h2 I! p O .name = "leds-gpio",8 P! _) G' w1 Y, L9 |
.id = 1,8 ?& ~8 o/ y; |$ P
.dev = { c- }& ^. c3 n; t3 P7 P
.platform_data = &da850_evm_tl_leds_pdata,
! r1 T E5 @: D) H$ t/ { .release = led_dev_release,
4 }! U `! J `! e }( B4 j% b. `3 k" D9 g0 }# B
};
: M- y0 a+ p \8 r; a" L. Q% Q: z( W
static int __init led_platform_init(void)
! j5 g! ]! W/ \{
+ j3 K& ^/ M* u9 s! Y int ret;
2 {1 Q! z1 e# X: u#if 0/ L4 e) g8 e+ v: n8 {: a& |- E+ A/ E: G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 S+ U2 N8 E4 R if (ret)& O% K3 e* _6 _5 g( W/ k$ x! _& g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; R: |- s% y r
"%d\n", ret);
/ o# \4 J4 y% h% w$ ~& Y#endif( h4 s/ R( H5 @; x: y( G) w
ret = platform_device_register(&da850_evm_tl_leds_device);! \, ?+ `7 ~3 j7 x8 x, G
if (ret)
5 E( @7 M* J- P$ ]8 s pr_warning("Could not register som GPIO expander LEDS");
5 Y* }8 V0 d% y else, ?: r2 u8 {8 L G: ]) ~
printk(KERN_INFO "LED register sucessful!\n");. M/ [2 y. h. P4 S
* r" ]% W% p4 x& j& a
return ret;* m" J, ]/ O) J* J& |8 x- H
}0 f# q5 w$ g1 q7 C& e) s" L
5 n3 S7 Z5 _- gstatic void __exit led_platform_exit(void)8 _0 g% w! V5 v
{5 l9 N) \+ g( c5 U1 A- a( q
platform_device_unregister(&da850_evm_tl_leds_device);- f+ \8 W$ o/ l( H, O
8 f$ t1 x9 C: [6 W* x% L+ i! T
printk(KERN_INFO "LED unregister!\n");3 N& L6 u; Q D, @, m: C
}
! c" x' L8 l/ V8 A: o4 `0 N' \& {0 [
module_init(led_platform_init);
3 M( p+ o0 t' z) M$ M/ i- D* Pmodule_exit(led_platform_exit);
. u9 I/ l1 Q5 ~. V' s0 k% @, ?% L7 W$ {! J; W* g
MODULE_DESCRIPTION("Led platform driver");
; w8 v7 K8 e$ o6 M9 sMODULE_AUTHOR("Tronlong");7 L4 l* r. @* T1 v1 {+ P
MODULE_LICENSE("GPL");
+ G% u6 ]% R9 U( I7 ]8 Z
2 j" D) z2 b9 Q" Y* U |
|