|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ ?: y1 O* ]3 O0 |2 E* N#include <linux/init.h>
5 Y/ j7 L/ X7 a, `" P$ M% ]& }! g#include <linux/module.h>/ j/ {: B+ ^2 m' f
#include <linux/kernel.h>! q/ a+ `! S$ U4 T# Y2 r
#include <linux/types.h>
+ N' N+ z# n1 P5 A/ @+ _#include <linux/gpio.h>' D. F! J0 ^, A0 h
#include <linux/leds.h>
& A/ J+ B9 J: X% Q# G4 K#include <linux/platform_device.h>
- |+ w: U/ S7 P5 B0 Z: V; `! b% a/ s$ s8 `0 j: M: a E/ d8 J/ |
#include <asm/mach-types.h>5 w7 r* y9 D% e' g. S4 M
#include <asm/mach/arch.h>
/ q" N* S/ h- ^ t! `#include <mach/da8xx.h>/ `# w6 J h1 G0 i
#include <mach/mux.h>
' Q' |8 g) M5 g9 }. h) ]' ]8 O: E8 }/ \1 l% c7 M1 e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: n* @+ h* h! N7 G( H! t4 P8 H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* W8 C5 N' ^' A1 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): P: U2 U) A8 s1 \$ J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 C. \6 P. {. p% W9 ?! Y
R w5 r' u% Y4 ~. v/* assign the tl som board LED-GPIOs*/
+ o3 A9 a, A% N, @" s2 U4 G/ w( ^static const short da850_evm_tl_user_led_pins[] = {2 ]1 c; f, S6 r+ b
/* These pins are definition at <mach/mux.h> file */2 A) _; N6 [8 a3 b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: ?$ K: y7 n$ a4 L" ^$ y -1
/ K1 R4 L7 F! f7 j4 [0 Z* A};
" I. ?2 t* q3 d5 k7 l# g
4 _: x$ u: O( k; Nstatic struct gpio_led da850_evm_tl_leds[] = {
. |4 z) S0 m6 Z6 R& D {
( }2 D! Q. Z i1 x+ X+ z3 m .active_low = 0,2 G' W4 W& H: L9 o: ?* X7 x
.gpio = DA850_USER_LED0,
" g9 {9 S2 t5 F5 Y& v0 V5 D .name = "user_led0",, G8 I9 z5 G- ^" w8 v7 t9 n" x
.default_trigger = "default-on",, D7 I4 q) p5 Z3 E
},' F' B. g9 q& t3 ?+ G: ]
{; Z+ y* I+ J8 J2 e4 X% ^ h
.active_low = 0,) O o1 @3 ?! `$ D( a+ Y' F
.gpio = DA850_USER_LED1,# B8 W( f5 R+ q8 G/ L
.name = "user_led1",
1 t- e8 z/ M! `+ L9 u# O; r .default_trigger = "default-on",
! H6 a/ }" v0 m/ x5 t },' W) ~( W1 a i6 | h
{ r- e$ X( Q# T) j& G% r
.active_low = 0,( V! W- {2 ^0 ]( ~! d
.gpio = DA850_USER_LED2,
5 f8 z' u$ {1 o4 B/ j' u& H .name = "user_led2",
2 F! e* H- u& e0 v$ S7 o, v .default_trigger = "default-on",
' }2 x7 t8 ?4 V4 A& _0 I9 h },1 T: J9 M: u% b( e& f& f1 o
{
0 r4 I- @. y8 h- R4 Z .active_low = 0,6 c$ J/ j$ c! |2 t* I+ `
.gpio = DA850_USER_LED3,* Z" A* F8 F1 ?: w& a" W
.name = "user_led3",) ~4 S3 p* X! @, L* ?0 g; x
.default_trigger = "default-on",
* p' L: P7 t2 W },& W, p0 o" C5 P! Y& x+ M
};6 V2 ?4 w% H& r1 ~5 q K3 y) E
* \" K$ l. q+ Z U& Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 z( n/ W/ M+ s8 q$ Y5 `/ R# U
.leds = da850_evm_tl_leds,
+ s- \3 B0 i% E+ ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 a) G* }( K, l5 q4 l3 H. H
};
' G a* b) u& X: Y7 S7 {- U/ p; }% G( X t) `& x9 H' f: j
static void led_dev_release(struct device *dev)
7 w; w9 w: ?+ j7 t- Q{
* k9 Z" ~- ?. w/ V/ {};
9 I. N5 Q v2 k" F$ N4 F7 B4 p- T* o* s! n; h1 F6 {
static struct platform_device da850_evm_tl_leds_device = {
$ J; d. n5 k# v/ v) o .name = "leds-gpio",
: O p9 p- { b. K .id = 1,
) N! Q& P1 o# Y* z" G .dev = {( a0 @7 Y9 U, F; [* r
.platform_data = &da850_evm_tl_leds_pdata,
5 E8 M" F8 v1 W) T& ?3 ` .release = led_dev_release,1 K }2 h# i7 N4 r% o
}% w8 [' v5 \) \- \
};
" h$ y! s; p& K* m. t& @! w
& A2 }* U5 b) x: a( }7 e" cstatic int __init led_platform_init(void)# A* u. R& R. q% h2 y6 O0 |
{
, S& x2 U- C! t, g, p( q int ret;% N, H1 L6 q, K
#if 0! z: R2 d! n, L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 e) s1 _+ z3 A& s0 G0 M
if (ret)
' h% T# V- U S+ ~' ?5 R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 E: A8 P* {* X3 R "%d\n", ret);: |3 h. U7 y5 _. p
#endif6 X4 y- [, d' O- H$ O0 Q
ret = platform_device_register(&da850_evm_tl_leds_device);
% e V7 p0 [3 ?9 x, } if (ret)
& ~+ N+ ^3 h$ y7 U! K9 U% o5 r2 R | pr_warning("Could not register som GPIO expander LEDS");* y2 u$ A8 R+ t& R! l' j1 B
else
: j! z5 x7 p G% x5 W printk(KERN_INFO "LED register sucessful!\n");, t) F" U) [3 B$ P/ _4 b# x
1 d% s- o! F! O. h" s. { return ret;
6 J6 @8 I. z! {}
( g- h3 ~' f7 R! N" g8 A3 K8 W; ?$ a% u T/ P. {; ]* r
static void __exit led_platform_exit(void)
) a* [3 e. I+ f! F" `; _5 \{# Z7 U8 E# |1 c& l7 Y5 b5 M0 F
platform_device_unregister(&da850_evm_tl_leds_device);
C; v! x0 A* z( J* N: G( `
6 y9 G8 Z, l+ ?% [ printk(KERN_INFO "LED unregister!\n");6 _( J+ T4 ~; s
}1 c% \0 v& |& N/ X: e. S/ \
8 N' n; n, h8 ?0 N8 Lmodule_init(led_platform_init);
' k& u( P; v( y' T: gmodule_exit(led_platform_exit);9 d" O0 l& ~% X( P. p6 d( h- z; M& W k
3 m D5 x. }. _1 {" PMODULE_DESCRIPTION("Led platform driver");
. c$ d# P l, |# p, @4 t6 cMODULE_AUTHOR("Tronlong");+ P- x7 g6 \) @
MODULE_LICENSE("GPL");& M3 m! N% f; y" s0 L! t7 C5 {
4 g* n J. a2 R1 u
|
|