|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 Q* E9 C& C# A+ n$ q {9 `
#include <linux/init.h>
5 p, s- @4 W; x3 ^0 E#include <linux/module.h>" T! A: v: b, x
#include <linux/kernel.h>/ ^2 Y- H8 Z) ]. m; b2 X
#include <linux/types.h>
. k0 L6 ^. q$ R#include <linux/gpio.h>
. o6 a& j# E' J5 w" g# Q#include <linux/leds.h>
0 o- F5 o W8 g! V" F. @2 u* Y#include <linux/platform_device.h>
5 E( @8 j% h( Q k1 U
- M. U; n6 C2 X! d# D, a& @2 T/ `#include <asm/mach-types.h>
, ?( i6 B( W4 `#include <asm/mach/arch.h> A5 M& t% ]$ J
#include <mach/da8xx.h>1 z5 g) w8 Y/ m$ m# g. d
#include <mach/mux.h>' i, u: {* h7 f9 _
9 z. n* L1 q( z8 `0 P; Q' L! U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' {! w$ Q: U) \6 y# G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 E5 M& a& P( O0 R/ J7 V# c5 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 ^/ p5 l$ G L6 Z8 a$ j( {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). g: E$ R3 Q6 Y1 `# Z0 r) l( H
, ^% s- E( y) t3 I- r
/* assign the tl som board LED-GPIOs*/
2 z! n' O# K9 n+ ?$ }0 o( @static const short da850_evm_tl_user_led_pins[] = {! ]0 T7 k. m4 T9 J+ ?: q
/* These pins are definition at <mach/mux.h> file */: y" g. j1 h2 T+ u
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& U/ I! e2 p+ ?8 j -1
. u# @4 N m5 E1 B! B};
A( a4 H# E+ L$ c0 d
9 _& o8 k7 [; d4 s. y* {2 Estatic struct gpio_led da850_evm_tl_leds[] = {
5 b; r' R; e6 L$ [9 R ` T3 k {% v2 ]. A$ _4 t) B4 K: r% I8 ]+ K
.active_low = 0,
0 g# ?+ R$ R. P' L) r0 j+ T) x7 i; u .gpio = DA850_USER_LED0,
* i! I, M2 ^) V: ~ R& D .name = "user_led0",& ^8 x; R3 \% n9 G! `
.default_trigger = "default-on",
1 P3 _4 o8 Y8 J; ~9 R+ b( b },& V, C, X8 R8 i+ |5 A% Y( M
{
& V# m- E7 M% K7 Q .active_low = 0,0 |) ^( @& y, _* W1 I7 s
.gpio = DA850_USER_LED1,! M6 b6 E) u4 c4 F
.name = "user_led1",1 s/ | q+ b2 D/ W* H0 T
.default_trigger = "default-on",
, Z' I# M; y1 J8 z; T) q },
# r; v% w) W: h {
1 e& I- R5 {. a' S. T" } .active_low = 0,
9 A# x, r" E$ {, a/ ? .gpio = DA850_USER_LED2,; d. u8 H' `5 y5 w
.name = "user_led2",
2 A# f9 B. @9 @# @! y .default_trigger = "default-on",
) E6 `( t* |5 s& u$ {+ K },
+ V1 @. L( T" T3 R {
2 S4 Q0 ?6 n5 b .active_low = 0,
4 J% _ n$ \) V% i( U1 p( L .gpio = DA850_USER_LED3, Q* R2 U; U8 d
.name = "user_led3",
) r# s+ e/ e9 h v9 f .default_trigger = "default-on",
8 P5 G1 Q" D% W/ ]! a! _ },
l. }2 s& ~# ^- e0 s2 h};( Y6 V( a: @; F3 B6 q
1 T% T0 D. T& i5 P0 H) r2 Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- y, x% d) ~& Q: v
.leds = da850_evm_tl_leds,- P2 |) O- @! N G- [& k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& _' j; h( L$ g/ [5 H};
& _" ?' F% o3 Y9 x2 ?' |0 _
' U0 t/ L: B- r! M- J. w* L9 o, X% P+ F1 kstatic void led_dev_release(struct device *dev)
7 H6 |$ J& H) x& o) ]2 e3 I7 e: U{" f# Y6 p& M' q# Q
};
- I% J' x8 B) w u
1 ]" r- T4 M' R7 W3 _; E" f' pstatic struct platform_device da850_evm_tl_leds_device = {
! k# ^9 u/ P P" a .name = "leds-gpio",
/ v4 {7 s3 J2 i: m& I7 ~ .id = 1,
) L* B/ ~( |1 ]5 O' z( s .dev = {
( |( r$ k7 M1 A% j5 y7 T) \2 s .platform_data = &da850_evm_tl_leds_pdata,
' k/ @1 y5 L/ c+ t! U/ {$ p6 @0 X .release = led_dev_release,5 R5 I$ m6 e# U- c
} l* r: S! q h
};0 J4 Q' N: ]2 v. L- G! w/ L
4 }2 T( P0 `. T8 t% |4 j& ?static int __init led_platform_init(void)
5 `! k+ x% R; E2 x4 a5 I{
' B( q- C; Z& T: h int ret;
' t# F( P: d6 V! B- g) ~1 s1 t#if 0% j; Y+ y8 Z+ ~7 j$ t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 w0 M) Z% Y2 L2 }3 y/ I2 h if (ret) g7 ]8 f1 \( r2 [5 ]& k% q$ B5 `/ G3 ?; p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% P! H. A. \# Y8 X1 |( R2 s T* ] "%d\n", ret);
: {! E8 I6 A- j/ o#endif
9 U9 v) { J' z) @' Y& v ret = platform_device_register(&da850_evm_tl_leds_device);
' S* j, I+ X4 ^$ G if (ret)
7 a" C- A! E+ F6 a, A E l' D pr_warning("Could not register som GPIO expander LEDS");
/ Y( q4 ]" t$ V' ?2 l& \ else
% V o5 e8 I) k5 Q printk(KERN_INFO "LED register sucessful!\n");8 X7 X2 n! G* f8 v* y
" M3 D! i! N3 q: }6 P0 L8 Y0 N
return ret;& j o0 w8 s5 e" K* G8 D" r! h
}, ?3 V# u& W' ?3 i: N
! _' _* f! k/ S4 v6 W/ D% I) qstatic void __exit led_platform_exit(void)4 q4 |& F" b9 Z/ l
{4 h) _! ~& Z- l2 v1 ?; f
platform_device_unregister(&da850_evm_tl_leds_device);9 K1 P) i% r& Q5 B
. P8 o) d. s) ?! y+ {
printk(KERN_INFO "LED unregister!\n");! H4 Y( t+ n! f5 @" o
}
2 ?2 s0 }3 {$ G( g9 n& m5 i6 u8 c8 |: o1 [# J
module_init(led_platform_init);
: ~; V) V/ G0 O% Kmodule_exit(led_platform_exit);" A' @2 p6 F3 @0 g7 `
& b/ I* r% E; ^+ i" MMODULE_DESCRIPTION("Led platform driver");
" r, j9 o$ {, r5 n5 D9 j3 WMODULE_AUTHOR("Tronlong");
* {4 q( W$ |7 T( N/ @. ?$ P5 t3 OMODULE_LICENSE("GPL");
/ A) P+ A/ ^! P. ^6 R- [- d
/ [* M! r* B% b6 _ |
|