|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* m4 _- E5 c3 [' c$ I4 c( s% C
#include <linux/init.h>
: R/ j6 H3 |- F+ l) C5 b+ C8 x#include <linux/module.h>
: [7 O5 ~# S7 [5 ^" P+ `#include <linux/kernel.h>& i% p+ C u7 Q
#include <linux/types.h>
$ f( J# v& X# U& G0 O# \" {3 p0 O9 \#include <linux/gpio.h>$ d; p5 w9 g9 X. l/ i; l6 k
#include <linux/leds.h>
/ S$ f+ O9 R l- r8 |" b#include <linux/platform_device.h>
, D ^- }8 A1 T& |1 v6 A O- ~$ `) Q3 h+ u) m& C' K% F* ^
#include <asm/mach-types.h>( P7 ]* U! e0 o6 t# O4 G0 c1 ]: O* @
#include <asm/mach/arch.h>
5 [1 }. q7 I% K# d( p#include <mach/da8xx.h>
- [% V) ]0 s$ {% `: y/ p( e#include <mach/mux.h>9 _$ N5 u" U1 g
* C# N/ ~" _! ]# s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, A( d4 \9 V2 g1 q- g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! { e# _/ X6 |) d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ n& V: p, m# \5 S+ _3 P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- b- s- P1 t; v* A b
1 a. i! T S& o$ u6 p4 E% A5 E; @/* assign the tl som board LED-GPIOs*/
6 U. s w$ x6 U5 l6 ?, Rstatic const short da850_evm_tl_user_led_pins[] = {6 _$ @# L8 p3 g3 g( }( P p% L
/* These pins are definition at <mach/mux.h> file */
2 @/ @% x5 i9 b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. S8 h7 B! A% A4 b' ?% _4 q( |: h -14 h/ C. `" s# O* \
};, k1 ~( a8 d# D6 k1 i+ c7 P2 T
3 O# g F2 P4 G- sstatic struct gpio_led da850_evm_tl_leds[] = {
1 \! z5 r0 W- W( q1 l2 W1 z7 o1 h {
- B( ^: X0 d& ]* F! i .active_low = 0,6 ^ r; o& x) \/ z4 M
.gpio = DA850_USER_LED0,& b4 U: \' Z" {3 y
.name = "user_led0",! _) E( o& Q8 `9 M
.default_trigger = "default-on",+ h: P5 w$ b. Z; X% X$ {6 l
},
9 w( Q/ ^ ?2 a1 y( P0 X9 C1 v {
$ o( s0 M# e5 A0 Q8 U; ~: ^3 y% { .active_low = 0,
! C T* i) h# c+ e& H& q .gpio = DA850_USER_LED1,; O1 l5 d7 i- E- c% A! ?
.name = "user_led1",
3 K% Q" q7 k' Z; b. l6 s; `: Q G .default_trigger = "default-on",
! T9 [: G B, e/ u/ C/ `' }; e },9 D6 j4 R! u9 _' ~- o
{+ t5 O* C5 @, O* I' [
.active_low = 0,
( n: t* D1 j; \1 X# ^ .gpio = DA850_USER_LED2,
h* Z L& e% \+ `0 n& N3 f .name = "user_led2",
6 y$ _# U7 x" F7 R6 n. _' { .default_trigger = "default-on",1 R6 y. Z ~2 H1 w+ J! ?/ c' v1 w: c, z
},
" z( U, N9 x$ ` {, g! F7 |7 ~' r
.active_low = 0,% m& p3 C; v0 H
.gpio = DA850_USER_LED3,
6 H6 v0 L6 I& g# m .name = "user_led3",1 U2 ^* ?( [; i) r; S
.default_trigger = "default-on",) Z& ]/ W5 y Z( l1 k9 ?7 i( [
},6 X. Y" x- ~$ T/ n% j. K3 Q1 @9 x r
};
$ ^( }$ W9 Q, H3 D7 t s
+ S8 Y u( [6 Y5 g; A+ gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" W1 W+ g, t1 s9 F& O5 @& K7 ?* U
.leds = da850_evm_tl_leds,
4 a2 E/ r% H3 D3 _( ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 V2 \# \9 q9 I! I4 S};9 Z) n6 N% L; |6 }3 V# i. |: l
2 d5 y+ [. N) `5 j9 Ustatic void led_dev_release(struct device *dev)! m. `' i& _( S6 v& v( |- \
{
$ k' m& Y, S n6 W0 k0 b4 g' J};0 d/ D4 ~( I. G x) N; {: F& }; p$ `
* T4 i m h4 Z: u0 \/ I: V
static struct platform_device da850_evm_tl_leds_device = {! M( U% j: {. J3 l4 Q2 z# ?
.name = "leds-gpio",
8 A; e- o4 r* M' g! E .id = 1,. a1 m1 [( u" y
.dev = {
2 P- O' f4 U. K1 m2 k# D$ T6 m .platform_data = &da850_evm_tl_leds_pdata,% j" c- A3 C# C; `$ Q
.release = led_dev_release,& r# f- B/ f5 d/ t. y
}9 ~, ?* J6 g+ w' M2 [* C
};
: `: J' D7 n l( p c" L
. d6 E, @8 K) X. g( Pstatic int __init led_platform_init(void)7 `1 ?2 w/ d* O7 L
{2 h6 `' T- J1 s3 {
int ret;
4 h0 f% ?8 _" P" H# h+ Y/ d8 s#if 0; N2 X' H7 X5 y. B4 c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 b6 C- ?2 D# g+ J% d9 q. x if (ret)
5 N: h" {& g% Z1 M$ e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ }9 |# d# ]$ V3 g0 s5 C "%d\n", ret);( y5 S; H9 K+ _9 i
#endif q2 ^( u- m" i4 K
ret = platform_device_register(&da850_evm_tl_leds_device);
" Q2 K* ?8 Q" X7 r if (ret)
5 W) } W& H8 E+ e+ |' y! ? pr_warning("Could not register som GPIO expander LEDS");
) D( L/ w1 g4 r* H else2 T" Z" K6 G0 Y* i* Z! `
printk(KERN_INFO "LED register sucessful!\n");
1 K' {7 q M* A0 [
2 f+ a" m$ h# }3 w; V$ U return ret;
, J3 X7 f% G- d4 z) z# s}( t$ l& j9 l: h, h w( p4 P6 p
( }: G1 K3 i% c! P7 J ~3 X" Zstatic void __exit led_platform_exit(void)
2 ?2 y Y3 a6 F! `, a2 O6 C5 Y& T8 A{
7 @: r' E1 f4 _& E$ e% c5 `$ i platform_device_unregister(&da850_evm_tl_leds_device);" F/ @6 O* d. ~! W; q
* i/ A! h l1 J4 ?' a; p printk(KERN_INFO "LED unregister!\n");. B! c; c: t! s2 Q
}
3 G6 ]4 o3 Y- O- L! ~7 P _: q# O
module_init(led_platform_init);
; `4 ]; p4 I- {module_exit(led_platform_exit);
3 l1 @4 X5 D# q) V' Y/ V3 O! b, t3 E! ~
MODULE_DESCRIPTION("Led platform driver");1 H9 |% X: u* Q! J
MODULE_AUTHOR("Tronlong");/ O6 V% Z1 ?( i1 T
MODULE_LICENSE("GPL");# Q, l' z/ o) B& l3 E1 @/ e
( w5 x. Y4 C# n1 `
|
|