|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. p* @9 V* w1 Q#include <linux/init.h>
+ t. P: l' A+ ?. L+ o#include <linux/module.h>
3 e7 o9 Z% @6 B0 v$ `0 E#include <linux/kernel.h>5 Y, O2 [. ^& G) |; \8 r8 f9 g
#include <linux/types.h>+ r1 |( f" S& q! ~' s' Y6 L1 @
#include <linux/gpio.h>
$ p8 Y" f% ?" `! j+ Y y, x) ]# S) }; C#include <linux/leds.h>$ W* ]' [: {# w4 X/ S/ d. n; o
#include <linux/platform_device.h>
: Q* Y) f- n1 q$ j3 C1 Z4 B
$ H1 l3 I4 f2 f2 G' |#include <asm/mach-types.h>0 w( I) h; d" a' c! |
#include <asm/mach/arch.h>
5 R7 [3 b! `' K, y7 f9 J3 N {0 h, ?#include <mach/da8xx.h>9 i1 `4 e* y3 R- d0 U% u' R
#include <mach/mux.h># y( a3 _/ u( E, T, y3 M; h
0 } K: p; j- X: n) e+ J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- F/ r* U% {& t4 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( _9 P! f- V' ]0 a- g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* \% d7 P# k% o# N- V# r& n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); r, c5 h4 ?' w1 @6 y
" v) `6 m( P( E! ?2 T
/* assign the tl som board LED-GPIOs*/
5 @3 z- c, ^6 V" p7 `" Sstatic const short da850_evm_tl_user_led_pins[] = {
/ f3 N+ e) {3 E/ w /* These pins are definition at <mach/mux.h> file */" W9 H7 z5 z8 ~5 F) |: V5 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% E4 U9 l! K9 M/ B, H -1- ?7 X$ k1 ^2 S0 J+ }& Q
};6 i, r$ t: D3 A& A# @
; Z& K' C) ^! @7 B3 Hstatic struct gpio_led da850_evm_tl_leds[] = {
# A4 p( t; h# }) W. y {- @: V b3 ?3 A
.active_low = 0,
$ Y9 M1 f4 K4 u- ~) f9 Z .gpio = DA850_USER_LED0,6 N" p8 U! [- R6 E4 W! D- O
.name = "user_led0",2 C( {. \( t: K I2 {& n6 | q
.default_trigger = "default-on",3 r) T6 G7 X* _) Y$ t
},
' d' Z6 p9 @) p( ] {
9 P, V/ X5 h% {+ g$ K, | .active_low = 0,
; s4 ?5 W$ M7 q0 M .gpio = DA850_USER_LED1,, r" w" V5 h! a
.name = "user_led1",
* D4 `% T- ~4 I+ p" U .default_trigger = "default-on",) W5 \# f/ }7 b' y, x& x* D
},
- k$ T+ q4 b8 [- v6 p% n k' { {
9 G; J: e; C& A# |3 v0 G3 _0 p, j .active_low = 0,9 `. N" Q [7 Q2 Q
.gpio = DA850_USER_LED2,* P1 k9 t. a1 k n3 r$ {; e
.name = "user_led2",
6 ]: H& p7 X7 X1 n4 u$ I .default_trigger = "default-on",& I0 Z* d2 f- z4 B
},
) x/ F h" {( X+ t, q1 ` {
0 C+ ^' z T h1 R; J0 Q! E .active_low = 0,
& n. k5 d! l6 X" A .gpio = DA850_USER_LED3,1 E2 V& S4 r: h4 A* N' h# C6 q
.name = "user_led3",0 A {% U$ c2 ], Z8 H: V8 l
.default_trigger = "default-on",9 N' q- {" n! N% t8 }0 o6 q
},* O9 {& E4 E) U( Z/ d/ I, j( Q
};+ ?) y! z0 r: r$ |* ?3 l* m
! j( K! I+ @6 p# O8 e5 e& b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" Z$ b( @( }7 f$ W .leds = da850_evm_tl_leds,
) x$ K8 `$ C& J" { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% ~7 _/ L$ M8 P/ V- z* O$ W
};
* U: f2 a& c: U* r2 X, t8 s1 a; ?
0 s) T2 \9 Q; N. C9 ~ Ustatic void led_dev_release(struct device *dev)
$ ~) l3 y* K8 h$ o! z5 J{
7 n% Z+ {& R) @$ J P6 o$ r1 H};
' { Y/ q! R z9 K! K5 y
7 [2 b7 L5 y+ ]' X2 \# Wstatic struct platform_device da850_evm_tl_leds_device = {
2 I* v% l8 {. k0 O l- g9 f .name = "leds-gpio",
/ s- x$ _. ?6 V' t3 H5 e .id = 1,
' Y6 R% U! P5 q8 z8 E, { .dev = {
2 `- \1 B: f; P8 R+ f .platform_data = &da850_evm_tl_leds_pdata,
1 N* ?2 G: o, x5 x- _* k) g% t% { .release = led_dev_release,, o, A0 p6 W$ C+ C: T! _1 J, R
}
% s" k; E$ w/ ]/ U7 v0 a};+ K: h/ K& L7 c
# h9 V( M: x; `, N$ i$ J
static int __init led_platform_init(void)
% c) S* y$ v8 x1 Y% z4 T{( ^; Y' y0 F2 U4 C
int ret;3 q- ~" R0 C( ]2 h: w! w' i, s- R
#if 02 _% h: n' Q" i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 Q2 H4 b" ]( c4 l8 f8 D: ] if (ret)1 `; I1 H, C U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 z4 H8 X6 R1 H0 {3 r/ f8 D H "%d\n", ret);" V' G; `* s. [& Q& M
#endif
: Q- a; i, J; | ret = platform_device_register(&da850_evm_tl_leds_device);
8 o1 A8 O* I$ K) ]% {6 z, `, ^/ p if (ret)
$ q, j- a% I. _; c) `$ X pr_warning("Could not register som GPIO expander LEDS");; C" U$ X( O% i0 H
else
% K0 J/ n* A0 p, k/ n2 U printk(KERN_INFO "LED register sucessful!\n");
/ e0 W; L0 r5 q; b: X% Q4 o9 k$ J/ C6 g8 z+ f/ z: h9 S
return ret;& I, M9 q N6 p
}
: y: v: N% o% b
, p6 ]7 C3 P! a$ ?9 Dstatic void __exit led_platform_exit(void)+ z' I# W; U) [& u' a2 ?
{0 p+ m E% Z6 j/ G4 y n
platform_device_unregister(&da850_evm_tl_leds_device);' {7 i' @. g8 Q; B; S3 P
$ m3 Z3 N) w H/ q
printk(KERN_INFO "LED unregister!\n");
: {6 \6 P2 i/ }3 R9 D- u9 U}, N9 g- t# N5 X- Z' K; ~2 b, ^/ h. \
) R8 Q3 [ Y% k: |3 C& N" U# o% \, Emodule_init(led_platform_init);
2 O' B, @. G3 w1 W' P! }module_exit(led_platform_exit);" j4 ^1 P; @0 j: e
& o r7 P# D4 U# D9 e/ v8 }; X$ J
MODULE_DESCRIPTION("Led platform driver");
; @# Q0 y8 x" u* h) J$ _MODULE_AUTHOR("Tronlong");1 ^$ V# q0 C; c4 u. R# o
MODULE_LICENSE("GPL");2 X5 ?+ w7 p1 F# v2 o0 j6 @. b
; F7 t* _) d# b, G: j+ i; B4 B |
|