|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 u2 x" @8 O, y9 `6 d: X% m
#include <linux/init.h>
0 e( z s. D$ _! G6 n) P& j#include <linux/module.h>( g) p8 f: \ v( A3 T
#include <linux/kernel.h>
' S0 b' q4 f6 [( s9 z#include <linux/types.h>
' O# l4 N- g# f2 a& r2 \. a' c8 g#include <linux/gpio.h>
( c, @" B% J# G( `& f' l#include <linux/leds.h>9 ?6 w: W) q- P' \ |, R7 s0 x
#include <linux/platform_device.h>
$ b" E- Z0 T3 D* g" c+ _9 X# A* k! g' U8 x l
#include <asm/mach-types.h>" B+ e5 Q$ g# n! K" |. L$ f7 z' P- w
#include <asm/mach/arch.h>9 M1 V1 ]' L8 ]5 W0 a" T; B
#include <mach/da8xx.h>
' \$ U( R$ Y/ d4 y#include <mach/mux.h>9 [: h4 x8 I( V. `+ g2 ^3 F, V$ h
6 m# [: Y- I: E# }1 \1 G7 ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# _3 m) ^# A3 d" ~1 y% H% i; n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 n0 V+ i4 H! m; D" |& h6 r( r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! S* B* d0 Y& N# g I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 m0 q$ _; o+ t4 m7 ^$ U/ j! Q
5 e4 y6 c$ u$ @, }
/* assign the tl som board LED-GPIOs*/! \- e j$ Y8 z: U* T; r+ c
static const short da850_evm_tl_user_led_pins[] = {' d6 S" P/ D: T& O' q
/* These pins are definition at <mach/mux.h> file */8 p4 o% R% y' z/ H$ X! f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, N5 _" P. v- W Z3 }# ^
-1. W) t2 L5 |9 b' ]0 F% {. v8 u
};
6 R- f2 K, q: h A
8 S" x, x: R1 x" Zstatic struct gpio_led da850_evm_tl_leds[] = {
) x$ C( d! g0 o4 z, J' L {
4 M t% m- p Y7 Z/ x7 H .active_low = 0,) i( f( H2 l& n4 Z
.gpio = DA850_USER_LED0,! j1 s, h* {) f, r$ a) |
.name = "user_led0",
. d5 N3 X; b% |% @" ~ .default_trigger = "default-on",% B6 \) y1 s# K# T) U
},. U# g4 _5 U, q% K
{, |. }; F& P5 Q& Y ]" Z
.active_low = 0,) J3 } I# S1 `
.gpio = DA850_USER_LED1,; p0 \3 B, E/ V: o# a# u' c$ e
.name = "user_led1",
9 e% c' J) f7 y) w& c' i3 {! k1 x .default_trigger = "default-on", `: }9 k5 `" J$ H& W
},
' f4 T! u0 }0 [8 ~* T+ P; w( G {. c! A0 @$ K$ i" j0 E
.active_low = 0,/ j9 i; m7 l; G2 m/ }+ d
.gpio = DA850_USER_LED2,4 x. v6 d( L. i
.name = "user_led2",; K& Q; e3 H+ e9 K( @2 @
.default_trigger = "default-on",+ u) \- t, p( \% T: K. |
},7 B p( d/ {6 |# x
{
" n) n5 G) u! W; }4 r .active_low = 0,! d( J! Z$ e& f! Z2 a4 ` a/ a
.gpio = DA850_USER_LED3,0 k( V2 U7 J4 s! a
.name = "user_led3",
' F" F/ E7 d5 Q+ z .default_trigger = "default-on",
+ k2 i* z, c6 a( j9 h },
+ R1 T" h* R- w};
6 D1 W1 p% p3 h. V& n
6 ^4 F6 Q5 ?. r5 y5 sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 Q* Y5 r8 K I9 P6 ^- H2 C) b7 Y P
.leds = da850_evm_tl_leds,
; `3 j( G4 O0 ]) d# E% b b2 c .num_leds = ARRAY_SIZE(da850_evm_tl_leds), _ o& m1 b# D# E" n' o5 K, V, J
};
( Y$ ]5 e3 \5 \1 [
" c$ J0 T1 @, v& ostatic void led_dev_release(struct device *dev)& |4 R1 y# C1 k$ L" n
{2 T- b4 l7 `& P# `+ ~/ i0 j
};7 }" m9 s& \3 u! m7 b
$ F. E( }; T7 a. W" S+ O4 s
static struct platform_device da850_evm_tl_leds_device = {1 Z& v' q c6 e5 ~
.name = "leds-gpio",$ k0 j: R" V! n! P/ b2 I
.id = 1,
: I" Z5 {7 q1 E# i .dev = {7 T: M, R8 _# F% P \: p% `, O
.platform_data = &da850_evm_tl_leds_pdata,$ @- y: B& S+ b" `) l
.release = led_dev_release,. Q( I6 F4 W6 n3 ?: n$ J
}
( C5 ?+ X! x2 i};- X- F. i& [- b+ E9 T/ ]5 K; u
% P/ D1 r, g+ \( B
static int __init led_platform_init(void): Z1 ^, t! M' V. N" J% l3 ?$ P
{
$ H7 y; `2 R& v5 X int ret;6 m' ?7 L6 G7 H" d& ~* [! t3 w
#if 0& S/ d8 h m' i/ Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) d! v" n0 X9 C. m if (ret)- j- P# {) V, K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 {3 m) ^1 K8 q( L. I
"%d\n", ret);
" }5 d) n# _+ U5 X F8 \; e#endif
/ N" W+ W. `4 `$ O. n2 P, j6 v) f8 f7 K ret = platform_device_register(&da850_evm_tl_leds_device);' B" P) O' b6 W0 Y9 V( Z
if (ret)
z. L( D% \2 n pr_warning("Could not register som GPIO expander LEDS");
4 z/ i) `/ q5 ^2 a# g Z+ I( ~ else
1 _( Z/ E* |) k, o" U printk(KERN_INFO "LED register sucessful!\n");
" j% ^; o& z( c7 h7 a' d! i w! y5 h c& [. p+ h1 }
return ret;
2 I' @; ?0 a7 ?}# {7 V8 \8 y, w8 s0 n5 w% @* l
u9 ~6 Y; @5 K0 c( ^static void __exit led_platform_exit(void)
% V. ^. W* @1 K9 g( M{8 v" Z( h) U& M8 z% K; q
platform_device_unregister(&da850_evm_tl_leds_device);* V; @' k/ v9 {- L. Z5 o
8 x# S, e. p) u9 K9 j$ y- I# u
printk(KERN_INFO "LED unregister!\n");
! O* O: H7 O, t6 P' m! L" q}
4 h4 C3 D: Y) M
, `! l: }* z# b, N1 zmodule_init(led_platform_init);( e t* t+ k- X9 y+ z1 K
module_exit(led_platform_exit);1 P0 S' j A& B. J( g) X6 h
6 g( u+ C' `$ }" {$ b* ~4 Y6 N# F
MODULE_DESCRIPTION("Led platform driver");3 O2 t5 O; n6 [" f* j* r
MODULE_AUTHOR("Tronlong");
* G( G \7 k2 R4 j) e) IMODULE_LICENSE("GPL");
# `9 M& G& }/ F/ D, }6 L, c8 h+ d- h4 \7 e9 ]
|
|