|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 J2 J8 u6 K K* H O, A
#include <linux/init.h>
8 e9 x0 M$ w, L$ |' o! R1 j#include <linux/module.h>
; W9 r8 }( Y: R#include <linux/kernel.h>
) s3 A7 K4 R; P; p3 u1 _#include <linux/types.h>0 B. D1 S; l: b
#include <linux/gpio.h>
* U Q# T) b3 V* f3 x#include <linux/leds.h>
0 ^3 N* s- K1 m! s! D7 [! x#include <linux/platform_device.h>: S& K& h U3 N& D! v, G
. I1 ^% t9 `+ ?/ E. G
#include <asm/mach-types.h>5 j/ a# A0 f; o7 L9 T
#include <asm/mach/arch.h>
7 j) O' Z1 U9 }5 W2 p- n( B#include <mach/da8xx.h>6 m7 ?. y. } }7 f
#include <mach/mux.h>5 }+ W+ R1 c( S5 B5 z1 N" \- A
; F& y; {6 A1 \5 q( \$ l: W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" l) B. m" F' T- |: G, b/ a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# d4 ] e: |' O7 ?3 K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ Y( A) I7 T# y0 c4 V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
A! k8 b$ f: e% ?+ G* Z( B% a% s' S5 P! Z
) J( ]$ N% x1 {+ E6 {( R) ?2 H. s/* assign the tl som board LED-GPIOs*/, w2 n6 z" N# \0 P* Q
static const short da850_evm_tl_user_led_pins[] = {
9 U7 N6 }9 @1 g2 r7 W /* These pins are definition at <mach/mux.h> file */6 K' D9 p/ S) |" j# |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 g$ Y0 K+ X3 u" m) g0 `2 _ -12 H6 C0 x7 W! w% {7 Y$ k2 N
};
( W, A0 _* q% l# C) i
5 m7 X) K8 t, t" ^2 [/ y$ Estatic struct gpio_led da850_evm_tl_leds[] = {5 q% b3 F: \ m
{
, j) Z- j$ Q" }/ V+ ^$ D3 {1 z .active_low = 0,
, O' F4 v/ `. h9 d% p .gpio = DA850_USER_LED0,
, H0 G2 d X* ~ .name = "user_led0",* [5 t! y3 G& W) O# t! L
.default_trigger = "default-on",
% g( r* [2 r) Y) p9 B0 {8 y) ` },
7 L* [% g2 {0 w3 O8 n4 o {! U) \7 k9 d$ a
.active_low = 0,) h9 _! Q+ r: ~* J
.gpio = DA850_USER_LED1,
) M7 W' {, S$ K* t .name = "user_led1",( r5 S/ M, z( s1 V8 ^- w$ ]' Q
.default_trigger = "default-on",
9 U* x2 o; n/ x, ^; T( R4 b, E5 E3 d },! @' m1 P. t9 f- o
{9 F6 X5 F' U* A" P7 f2 C; N
.active_low = 0,. E' D0 D8 @# z4 Z' m
.gpio = DA850_USER_LED2,
( f# P4 g; e: v8 ], `% d .name = "user_led2",
) w# _9 N9 T/ q" w$ W- B1 `8 n7 C .default_trigger = "default-on",1 o I5 [3 G0 L7 r1 ?' r
},
3 n2 ^* e/ ~: v2 S/ s {$ t! f/ U# A/ y+ i6 P/ g6 e( B
.active_low = 0,
_7 E; {# V) E! L+ \ .gpio = DA850_USER_LED3,
; {4 ~6 T9 q0 @) f. W: X b7 r, l .name = "user_led3",3 n6 u- O5 K, I5 |' ?- g# J
.default_trigger = "default-on",
- T% b$ J& n/ |0 C9 {2 Y; u) i7 v/ Z },, \, y! \2 B) Y+ ~) J! V2 B( h
};+ O8 {3 M3 C- x6 w
+ p' A1 f' H( a1 L, \% pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 V* `) s. l* K! e$ d# g .leds = da850_evm_tl_leds,* ]7 y% ~( ~/ r- A" V( Z& ]% J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* s/ H" S- Z& a2 z% H( @& C" q# C};+ [0 c" v, B( o, S6 c
7 ?) D/ a/ p# Y5 ostatic void led_dev_release(struct device *dev)7 L- C+ Y( }; t2 u$ m- l
{; Y7 q6 ~1 ^( T3 `# n
};
) D x6 V' V P# f% ^, s+ i2 C2 R
static struct platform_device da850_evm_tl_leds_device = {
' t E4 Q1 ?5 Q" P .name = "leds-gpio",( F& L$ l6 E7 d8 t6 B
.id = 1,9 |: s( b& t3 i. H# v& c8 V {, P
.dev = {
* v7 q1 ~( p6 v, E' k! e- T5 { .platform_data = &da850_evm_tl_leds_pdata,. r$ h K/ M9 E* S( a Q" _
.release = led_dev_release," m$ x& K7 b% T! M0 r
}
/ U4 h" O: C1 Q& g};, D0 p' i6 U2 A" G, \; k
# |5 m& m- e: fstatic int __init led_platform_init(void)
8 L, f( n3 U9 N: s' ^4 y0 B* A# ~{. H" H3 f5 z* V% Z
int ret;
8 r, u4 Y& A4 _' r: p" k) ~#if 0
b% [6 I9 g- |/ f, P( s2 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: J1 \/ `, C4 C8 H+ F; O# w; F% e if (ret)
3 L6 E. M) F: f4 w/ l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 E; H5 B3 F; X: }
"%d\n", ret);
* }8 S7 T* w; ]) q0 X#endif
/ v( I+ P J' J ret = platform_device_register(&da850_evm_tl_leds_device);
' X$ o+ z" I. q. |* p if (ret)3 @" k l' }( s! ~& X' U4 _) J
pr_warning("Could not register som GPIO expander LEDS");! _1 |& S6 c0 J
else. ?' w6 l( _. m/ F1 O8 l
printk(KERN_INFO "LED register sucessful!\n");
$ p8 U: j- L" R4 @. `; b: O2 F7 u. j) i1 w- ^7 U
return ret;
8 N4 n8 |; Z% M6 q; j}% X" \7 O+ l, }" v
) F8 z, u" E7 O9 B( v0 n0 Z+ wstatic void __exit led_platform_exit(void)
4 @) G7 T, v/ P q$ ^* a6 @{
6 V7 q- O& O% f3 x9 z; R platform_device_unregister(&da850_evm_tl_leds_device);1 N+ v- v a3 Z# n, U9 j/ C* S* s
. y0 h: H& K" ~* y; ~; D' k8 r printk(KERN_INFO "LED unregister!\n");
+ W# _; y. n! ~* G}
5 X( c- N" ~" T' r L P0 X7 l; m' m' g6 W/ b5 Y9 z
module_init(led_platform_init);9 a8 W8 X1 A6 ^4 ?
module_exit(led_platform_exit);
5 W3 F: I4 f" y% u
9 B# K6 E6 _- j9 o' `% yMODULE_DESCRIPTION("Led platform driver");/ B) O9 x4 V# J [
MODULE_AUTHOR("Tronlong");
9 L( {1 K/ J' B* {3 |MODULE_LICENSE("GPL");9 u# V! A: w2 R2 m
' L4 L: D( ?' z
|
|