|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 X1 U4 I. V# I- b$ Y
#include <linux/init.h> F7 n2 B6 \( _! X7 D! H/ c2 q0 X0 j r
#include <linux/module.h>
0 B6 i1 I; J2 a/ q& m#include <linux/kernel.h>: W0 p; ] ~+ n# B
#include <linux/types.h>6 _, @& p( t/ }8 i, q$ m1 J& T7 F* S
#include <linux/gpio.h>2 w9 k9 a9 W8 L3 }3 {5 C0 G
#include <linux/leds.h>
7 l& u& F l/ |. ~4 O#include <linux/platform_device.h>! o6 ~& H' t- r7 @
. M1 o- k( V, ]! c" d4 p
#include <asm/mach-types.h>
! `5 _7 d$ h. c Q. a#include <asm/mach/arch.h>6 @, N& I( g Q1 s* V: H6 C) h
#include <mach/da8xx.h>
+ d6 O5 H' {1 q$ A% M- l9 H% ^#include <mach/mux.h>
& x7 L \. W5 V: r
1 w; f$ ]$ Q$ ?+ X, t( D- h" i% g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! R4 Y1 M: o7 c9 L# x! V' Y; [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). ^6 s% t* j7 W1 I& R4 K4 ?6 v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) R8 ]6 x5 ^$ O8 z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" ~# ]& b( [8 V' y& |5 [# H. a* r( f0 u ?
/* assign the tl som board LED-GPIOs*/- z3 F7 g+ O: w6 y1 a
static const short da850_evm_tl_user_led_pins[] = {, t0 b3 ?/ B: p, ~
/* These pins are definition at <mach/mux.h> file */9 i: j- s1 g& g" b/ l! P8 q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 E. `9 k: x7 [' b' k: Q
-1
6 D2 b% Q' y1 R: i1 U+ j( R' I};
+ D! m/ P) z1 L9 C& c; Y6 B; Q# a
1 a! u# l9 @9 `) C5 N% Kstatic struct gpio_led da850_evm_tl_leds[] = {" |4 o0 n" z" H* [" D$ k# _7 O1 L
{7 k' U$ o9 l5 X6 t) }2 ?0 y
.active_low = 0,5 D/ N" L+ t3 o( w1 Y$ w5 o
.gpio = DA850_USER_LED0,9 j z* b& g# U# l3 t/ q. J
.name = "user_led0",9 T3 x7 U; l# H7 a$ c/ {$ F
.default_trigger = "default-on",
- T! o, u$ P& N },9 s& e6 G5 b6 F
{. w7 ^) u" V- [" ~) x
.active_low = 0,- ~8 ~& O& U m/ X7 z1 b* u5 X
.gpio = DA850_USER_LED1,. A- S& P$ @4 C! \# w
.name = "user_led1",/ t5 O5 n' J& p2 F
.default_trigger = "default-on",
$ z) q- g5 h3 w" q },
4 q9 n3 I# x; ~' d# K {7 r$ O# h e. K
.active_low = 0,
# Z$ B; L% A& B. M3 U .gpio = DA850_USER_LED2,
1 Y7 M0 F7 R B .name = "user_led2",
. V ^9 |8 h# p" Q# N9 G .default_trigger = "default-on",
( ]3 j5 e7 o9 P3 s" g6 \ },
# V* G( w, z; S" |, w% `5 E. b! K {6 J& Y7 i+ Q' m Y
.active_low = 0,
* ~: g8 i( o e0 ]5 ^) q; t3 ] .gpio = DA850_USER_LED3,* s6 N8 T/ c. m# `8 |- @
.name = "user_led3",
2 [1 J2 `& H# g4 P& H .default_trigger = "default-on",! L9 G$ u( z4 @7 q+ _
}," X4 t8 d6 r& I& g }
};
$ J" j& h5 I5 \! c, ]1 H
+ ~ P/ R& L* A3 u8 X9 a/ j8 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! ^, ?$ n/ N/ v .leds = da850_evm_tl_leds,
6 a5 O. \/ a% R9 s% k# H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 v2 K) M$ H$ Y( Q8 _- P# v};
" F5 O2 @" F; \7 d! {) C8 l
8 r% [# a9 y; u2 w( c* k! I' Ustatic void led_dev_release(struct device *dev)7 F2 r2 i& Y+ F4 i
{
2 o1 {( S2 o. X% E& k8 u};0 X, ]5 Q" A7 C" X7 I( a6 s% n
9 v' C5 h7 w% J1 O0 m8 ^" l
static struct platform_device da850_evm_tl_leds_device = {
4 J8 E+ e2 _! |0 \3 T& a& y7 N .name = "leds-gpio",8 H2 R/ M5 m# ?; t6 ~) A* j
.id = 1,
+ M6 h h2 I, o+ E .dev = {
% |6 E$ _+ C( h( |1 V! a O .platform_data = &da850_evm_tl_leds_pdata,
5 e s5 |' h3 r3 b .release = led_dev_release,3 D5 T# ~- F, \: h
}( f- _8 y# K ?+ y! z
};
: g* H8 [ W$ s) c
/ j z! S' c6 a' b$ z5 B7 ^static int __init led_platform_init(void)
3 ^% J" `5 ~& ` \/ `{
1 |1 |: |/ I% r% X4 b0 D9 F int ret; X2 m, o' s3 W
#if 0
* k2 J3 ?: `; j ]- B* v1 z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. f8 h+ a, g) K; m. X, f( n. G if (ret)% E& v7 q- u7 N" C. V& k* y% X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* m& s# k8 b6 b) D7 [( z/ \
"%d\n", ret);4 `9 I1 F5 J' @! D
#endif# {( C( t/ s z/ I& i) v
ret = platform_device_register(&da850_evm_tl_leds_device);
# N6 x& [- c6 Q" A4 E if (ret)6 ?) w) L* [" Q
pr_warning("Could not register som GPIO expander LEDS");8 V/ K5 X1 P5 u4 S% ]7 c! |
else2 d5 G! q1 V B+ h! K+ a8 e6 ~
printk(KERN_INFO "LED register sucessful!\n");: T/ j7 ?- K8 p5 h8 R& h5 K
6 @9 Q: d8 v# C return ret;
! ^' S, [" d1 x( x* ]}
+ E% r9 E; d! |' `6 V3 O
3 F9 _2 b8 D: W- b6 rstatic void __exit led_platform_exit(void)0 S9 e- u* V4 \! d
{
2 A7 t+ U5 u' ?6 k! o platform_device_unregister(&da850_evm_tl_leds_device);4 C0 D: F0 m# J# Q! w
$ @& {4 i- X( f' C" F7 Y printk(KERN_INFO "LED unregister!\n");7 N2 X- m7 a) Z: q" i- G
}
+ D' t7 U: ]0 B7 J6 w+ D; u0 u6 B
module_init(led_platform_init);4 E$ s R! M, F+ v% j1 A; w x
module_exit(led_platform_exit);
# i6 n9 p1 [' }2 Q
. l) T$ t) X; `: A& t+ @MODULE_DESCRIPTION("Led platform driver");/ u; {5 C- D3 z
MODULE_AUTHOR("Tronlong");
g4 r/ [ B) g, jMODULE_LICENSE("GPL");
* g: a- n8 F* i7 {
% M: d$ v" u1 d+ s0 L/ X |
|