|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 I- G8 V7 w/ E#include <linux/init.h>4 K; p, ^7 X; Y: q- [* S8 v. i
#include <linux/module.h>
% m1 h. i5 W# A$ m7 Q% N% y#include <linux/kernel.h>
, |' W: @, B( H$ k+ Y/ O#include <linux/types.h>/ H3 n: U: @2 m+ `1 C! I' p9 ~
#include <linux/gpio.h>. X5 O& x. M1 n& p- M$ B& l
#include <linux/leds.h>
5 T6 s3 \8 Y4 {& E; U: k1 P#include <linux/platform_device.h>
" q$ [: Q& |1 h/ _/ u/ P+ [7 I, h( q
#include <asm/mach-types.h>
& J( E% ~. ^1 t#include <asm/mach/arch.h>. Q& A+ y* m, n: [ F/ F4 y
#include <mach/da8xx.h>; }" O* A$ S J8 ]
#include <mach/mux.h>) c" n$ C! s0 f! p
( j6 a0 ^' |! M9 a. @" g$ d3 F1 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* i3 D# o, i1 M; P$ O1 C/ {5 |# U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 M1 D( {3 N8 m9 V! W, _ O" A7 m5 H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ ]% z! H' ^! }! [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) F! s; ^: k8 p7 x7 \/ ^$ Y
3 J" K2 f- f. e/* assign the tl som board LED-GPIOs*/
( }: f9 U* E/ V9 j4 g( k. pstatic const short da850_evm_tl_user_led_pins[] = { I8 f) {7 N5 x `4 j
/* These pins are definition at <mach/mux.h> file */! X9 m1 ^/ V. R& S+ e, Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
F5 x6 h. z+ |# ` -1
F) ^- A7 t; q7 {};
+ u9 W. M, w/ {
5 {' U, X/ [: Y5 e% U- @static struct gpio_led da850_evm_tl_leds[] = {* a% U4 g1 b! W7 U( X+ G5 r! f$ ^
{# Y: C# K5 a# K
.active_low = 0,1 ^) Q4 O* d' U; |$ N3 U7 Y
.gpio = DA850_USER_LED0,% M# F% g& X3 n$ Y3 Q& |& J
.name = "user_led0",1 d1 O. r" f9 R/ G6 D* M$ U
.default_trigger = "default-on",7 ~/ w- b, P; J- o( ?
},
* V; c5 r- M4 e f& x5 V3 M {
" V8 M- X7 [+ e% o' K! n" t .active_low = 0,
F( m- l# w* y5 ~, J2 s2 O1 w .gpio = DA850_USER_LED1,
( g l* F* d8 H# E' z .name = "user_led1",( O; V: q8 L+ d ~ g+ I
.default_trigger = "default-on",
5 F& K! z& a( U# }, D8 i },6 c4 k. F3 b0 k- `# }
{) P* {1 a7 y. T
.active_low = 0,1 ?# [% M- F0 m% S6 [4 T/ T8 Z
.gpio = DA850_USER_LED2,
3 U7 a& Z5 g% i: y! ~ .name = "user_led2",& e+ E& B! A) H" W5 r7 Q- \7 v
.default_trigger = "default-on",
) D3 Y. L# Z) ~+ l },* ~$ [0 S" v$ `+ J( _
{2 \) ]3 u# h' k3 Q( g
.active_low = 0,7 m2 `+ w* R# ~0 x7 ^" a% Q
.gpio = DA850_USER_LED3,6 n% i+ E% `7 ?+ L( N9 a7 m+ s6 O
.name = "user_led3",
. v* E/ A# C4 {+ J* O& [ .default_trigger = "default-on",
5 C6 r8 d- ^, c/ h+ h/ Y },
+ W z! c' X+ a: ~};0 c, ^# K& O+ l: o1 d
A2 s6 Z& u& j; Q4 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- v7 h) u; h! d .leds = da850_evm_tl_leds,
8 H' E. L9 R {. C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- E7 N+ O# ~6 }' M0 D( E! i+ f
};
0 c4 E( i( I' K5 X
1 w3 H! D5 t+ d- Q$ s9 V6 \static void led_dev_release(struct device *dev)
+ s9 M+ t$ U1 \9 `{
' e" {1 u1 p: I};
' `5 R& C% G, z# D T- n+ }
, t& n) i3 j% cstatic struct platform_device da850_evm_tl_leds_device = {
5 Y8 u' l6 _0 M3 U# j% i .name = "leds-gpio",) T& k" s. F8 G. P5 d* e% U/ W
.id = 1,
/ L% M2 D D) P1 S# q .dev = {
7 \% F7 w* Y! b9 E .platform_data = &da850_evm_tl_leds_pdata,
, b' |1 J; {5 a .release = led_dev_release,
; j' ]1 z8 K' a% a& ?5 [7 w( C! A5 n }% h! d Y; D1 S0 R0 L8 o
};
5 B' a- R: {* i6 G0 A
8 b4 C; c6 _5 R vstatic int __init led_platform_init(void)
- N% c7 n0 c/ x{% V2 e9 p! K- _/ X( [ O9 O
int ret;
! Z$ m) V! ]& z3 l" k/ b s#if 0 r3 {$ d; s3 P9 {* l/ A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- u& L# @. d8 n8 J4 f- g/ {1 ?* m
if (ret)
9 S, B! T) @9 e) F/ q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 z& K H' m# x; M( n; o
"%d\n", ret);
: q3 g2 ^- v% x#endif4 ?! H I$ j# c6 M3 m+ U
ret = platform_device_register(&da850_evm_tl_leds_device);! b# o( _* H: [; {! D. p5 Q+ O# v
if (ret)
. _. p. Z% |9 f; a* a! j pr_warning("Could not register som GPIO expander LEDS");! ^. ^6 a, P7 @4 s
else% P0 w( C; j/ M" c
printk(KERN_INFO "LED register sucessful!\n");" }; h& V+ R( n$ T( e2 c
4 \: I+ Y i( R2 r* G. n/ w9 I
return ret;* x3 D+ ~7 S. [, ?, b! L. e
}
; W3 y1 e. i1 J; ^3 t6 b4 a2 F3 x9 O2 r& i4 g( J3 s1 {
static void __exit led_platform_exit(void)
: Y0 q5 m! T) C+ C1 s{
! U6 n! Q: S% r8 m/ L! u% G platform_device_unregister(&da850_evm_tl_leds_device);/ m6 Y, X$ E }5 P
/ y% ^7 T" o& X
printk(KERN_INFO "LED unregister!\n");
4 G1 [5 R; }( t6 O1 }/ F}" N( X' b7 a. ^
/ ]% O0 R2 x; U/ W( o6 fmodule_init(led_platform_init);& e; x+ r- B" m* X8 w" n6 L c1 U
module_exit(led_platform_exit);$ _5 D) c* l6 C( t3 o
1 d7 \) v& p5 O. c
MODULE_DESCRIPTION("Led platform driver");
5 n3 j+ I, @" \" q3 rMODULE_AUTHOR("Tronlong");
6 C$ v* D1 T9 |/ M K- [$ ^MODULE_LICENSE("GPL");, d h5 T2 |1 B$ w
- t& u `# b- Z6 p! I
|
|