|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% a) |9 {8 _4 Z3 ^; a7 U
#include <linux/init.h>
' ~& t2 R) \8 g$ b9 Q1 ?" J' G/ F#include <linux/module.h>
3 q* }+ i3 \5 n/ O% U+ X8 w#include <linux/kernel.h>
0 u* F# s: Q" O8 p0 B6 |3 p5 C* H#include <linux/types.h>
* X& n$ G9 B, q _1 q- {#include <linux/gpio.h>
" J& O- f, o h; J#include <linux/leds.h>
) ]+ i+ f( F& M Y#include <linux/platform_device.h>. H- f6 u# m/ H. Q _! \3 B* R
4 N7 @1 q# n7 u3 u3 t# b$ B, ]& E1 J#include <asm/mach-types.h>
9 X7 R6 v) X( ^: _#include <asm/mach/arch.h>" A" F D5 r( i) @
#include <mach/da8xx.h>
- X2 i. t6 S$ N' p _#include <mach/mux.h>
( `7 m6 z% r* v* W/ X% K( D
# _4 b0 `. j# D" w( P/ n F+ S& R) U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ y0 d J- U2 p- W" m |; j8 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ d& R% ^5 |' j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 f7 j& U5 B7 @, N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# E, R, B3 u# D/ Q
- Q. t* }8 \4 c. \8 H/* assign the tl som board LED-GPIOs*/% z1 N8 z3 k+ e- U6 }) u: T7 s
static const short da850_evm_tl_user_led_pins[] = {
6 j, h5 r* l! @$ H" S /* These pins are definition at <mach/mux.h> file */0 E2 i, O# D' L6 n! ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 G$ g) a# V9 p& `/ i( \
-1$ o+ r! `( ?' y0 w! k P% k" ?
};
, p- {- ?! ^7 i" H, r3 u
+ s/ H+ I% U5 S( G0 y# q0 H/ Tstatic struct gpio_led da850_evm_tl_leds[] = {
# s3 Y0 w0 l3 ^+ u( u- c {! A# s3 N. I4 e3 C4 c1 _
.active_low = 0,
$ u) i% G b( S6 R) y- E. G .gpio = DA850_USER_LED0,: e' h0 ~* C5 E/ Q
.name = "user_led0",( Q- ^5 W3 l) v: q- {. c
.default_trigger = "default-on",! F" t+ |, ?$ Z6 n& `/ N
},- s% Q* x M" w* Z+ e3 s% w- a! S
{
" g) w D) H$ p0 C; w1 F .active_low = 0,
* ?$ [9 V/ F, @' ?- a- l- ] .gpio = DA850_USER_LED1,2 G: w* ~7 f. I( H0 h; J7 N8 I& l0 n4 w
.name = "user_led1",
2 p: } `6 \- T& i# U! q7 u .default_trigger = "default-on",
. S- _: N( c, h },5 @* i2 `+ o9 ~4 I
{
+ C, N. C+ m" n* u: ` .active_low = 0,
j7 R A# w2 W6 z' R4 a; ^ .gpio = DA850_USER_LED2,- K* M- i/ D: E
.name = "user_led2",7 L/ b& S" C2 ]* R
.default_trigger = "default-on",
# u, l0 Y& x0 J: q% U+ C! z/ k },; H% h+ c$ f" z' ^7 D
{
: `4 k% ?* J9 R: ]! r5 `1 e. c w .active_low = 0, q' J5 b$ s0 P. p2 }% w: M
.gpio = DA850_USER_LED3,2 X$ P3 o" p6 s6 x
.name = "user_led3",
) g. m: H9 w+ j4 [+ x' O' }- v4 a .default_trigger = "default-on",$ G% Y% n/ o1 B( y
},
1 q5 M. {* [8 X. p};
2 ~( S! R3 ^5 n; D. F% R$ d% X& N8 J) a% c6 B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ ?- ~+ ]' P1 n/ I( b( v .leds = da850_evm_tl_leds,, D2 n" q& B! h' Y0 S3 r7 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," M7 j# f8 b. F$ z
};
) [" R6 M8 C2 K* ]& o0 J+ e, n* |2 K% M! ]' P. U* z, P
static void led_dev_release(struct device *dev)
. Z" w2 o# ?% g5 P+ t1 F4 S i{% d/ M1 Y# p. v1 p6 a( u% \
};0 [& P; X5 b6 u/ W" H# J$ x
5 O1 W) r+ F! T% ^
static struct platform_device da850_evm_tl_leds_device = {
% D1 I, p1 h9 W5 t# K .name = "leds-gpio"," ]0 e/ k! L* ^$ i7 n* t! B( E
.id = 1,% M/ I% z5 J7 q
.dev = {0 |/ V/ J; A* K* p" X4 s0 [" |
.platform_data = &da850_evm_tl_leds_pdata,( N) N8 Z: a# t& H
.release = led_dev_release," R# D8 ?3 m8 s+ o1 t" A
}5 Z4 a+ Q" X0 z4 X, h
};1 B' G+ ?2 [7 _
. k8 Y2 H" f- y. F) ?/ v# J; R2 P
static int __init led_platform_init(void)8 e9 I/ U1 o" O3 ~% m: O2 z
{0 k/ P" i; n E9 Y
int ret;' F- u! R. ?4 I: M
#if 0
2 z- I) _, h- l7 T9 I! N5 ]# A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# Z; z( V/ U( R4 }# T) ^
if (ret)
, g2 K& p7 `5 R; T+ s! ~. @5 K& ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :" m/ _ j: t; Y# A/ z/ ~
"%d\n", ret);7 _% H& Q- N0 Y2 s' c( I+ \
#endif
& \& o- I9 j2 O ret = platform_device_register(&da850_evm_tl_leds_device);
$ d5 {$ `2 R2 Q( V) I if (ret)
, y B4 e6 E/ f2 C ]+ l& h pr_warning("Could not register som GPIO expander LEDS");. t. E d6 W1 S2 h" G
else
+ v& O+ F" c' l4 Y+ k4 q( Y! C printk(KERN_INFO "LED register sucessful!\n");! o9 v7 b3 d9 X# p
: n; l% ?! g! V& k! J& t return ret;% M+ `+ C6 F7 c# G
}3 u9 K+ W9 Q. U5 r3 s w1 g' ^
# T0 d, W6 Y5 n. Ostatic void __exit led_platform_exit(void)9 {4 u; d( h, Y. K+ M. I2 ]
{. A% G+ W% F# [6 U$ p* P. ~5 P) m4 F
platform_device_unregister(&da850_evm_tl_leds_device);8 @7 Q- f7 Q1 j. l1 ^# e
" A1 d9 Q6 o% n& u& o# O- e# G V printk(KERN_INFO "LED unregister!\n");( q! |$ a) s7 B9 S. M
}0 V; b' v' J8 y( Z7 B0 P
! t2 I# ?2 Y; U' x
module_init(led_platform_init);8 e& T& Z$ D1 x* {: O x
module_exit(led_platform_exit);
5 @ y7 A# H( U2 ]9 T! Q, q7 z8 X$ Q2 ?% c9 a
MODULE_DESCRIPTION("Led platform driver");' R& u: ^( M: L1 w, d- a
MODULE_AUTHOR("Tronlong");
6 d) c' S' J. r- c) g- GMODULE_LICENSE("GPL");2 g7 i! o8 g+ C5 k: d0 c+ g- i3 f
' }; ?+ M- v4 z0 W1 G8 s+ A
|
|