|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' U+ \3 ]8 F( f& b0 T" s$ n
#include <linux/init.h>
6 O) x( T, h. X' P* i) v8 i* \#include <linux/module.h>0 h; ^- [1 E4 a, u) C) L9 [, g
#include <linux/kernel.h>& b U& b/ d' Y! e/ Y" s
#include <linux/types.h>
9 R3 b& }# R/ b, o2 d3 q; W7 P0 n#include <linux/gpio.h>
9 k" P( Q! U/ w" N; u#include <linux/leds.h>
0 Z! ]* g5 C( u4 O% u#include <linux/platform_device.h>
6 V7 [9 J& y* s- Q( S* E/ u8 P* H/ q/ }0 x4 g$ A! y; J
#include <asm/mach-types.h>
) m1 t; S _2 }! R4 Q#include <asm/mach/arch.h>
0 m# M, Z; P q& h& `0 p#include <mach/da8xx.h>
8 x9 f8 H1 W) I8 j Z& Y#include <mach/mux.h>
, B* X C! n/ v1 [. x3 Z m; C2 S: _, W. e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), m4 Z$ x }. z; k. O0 L/ A$ |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ T* u% L4 i9 V( \& i9 }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 d, a5 y+ b# A, Y5 V7 ^* c; U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( s. K! e% H% y. b
( k' a1 P; z4 O' G/* assign the tl som board LED-GPIOs*/
& ~/ e: F$ W& ]: `" [$ Sstatic const short da850_evm_tl_user_led_pins[] = {/ N# y7 E7 F0 S& v7 N3 W7 r2 d" |
/* These pins are definition at <mach/mux.h> file */
, n; R m6 Q9 r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) w9 Y* E: Z6 h8 X; I# S# U9 v2 \ -1# ?( z1 X1 P; F1 g) {. s
};
) ]5 ^3 ?0 b: V r" ^; | A# y( U0 M
static struct gpio_led da850_evm_tl_leds[] = {
) d: P; N0 H* k/ n& Q$ l {
" b+ R, h8 V: _6 z .active_low = 0, ]/ H0 U0 G& T8 z9 @ q
.gpio = DA850_USER_LED0,
) Z7 e* \$ q' a: u7 H8 H .name = "user_led0",
, } G5 R% i: ~& M" T .default_trigger = "default-on",
8 k9 ^: K* z. Z },! [/ P$ V1 E+ f5 L$ `9 {" ^
{
# r6 M u* F y- i/ g .active_low = 0,
6 `9 r i9 d- D: a* o+ l* _ .gpio = DA850_USER_LED1,0 j3 U1 |0 g( ~. z8 R
.name = "user_led1",: F7 j) M1 A( m( q1 W" M
.default_trigger = "default-on",& J3 c1 V* C. Q4 v G
},& \) Y. {4 s/ `9 f% C
{- Y1 D* ^7 E4 s
.active_low = 0,) p" ]0 N4 p3 l# g& |) |' n) |9 P
.gpio = DA850_USER_LED2,
! a' f9 J, [! q .name = "user_led2",. T, U# c5 V$ ^: |! J; l% q% |
.default_trigger = "default-on",
' t$ C" H: _, o2 U2 y6 v8 S },
N8 | p7 ~! T C {, n5 {; i. x. b! A
.active_low = 0,
2 \7 Q3 h7 z" _2 i! | .gpio = DA850_USER_LED3,
1 s) u9 x) J9 n7 F. t1 j .name = "user_led3",9 h5 r: ]3 K7 c, o& A" x3 [% \
.default_trigger = "default-on",3 S6 Y( d: Z& U7 @0 n
}, s6 J8 g5 P9 s( H6 J9 b! {
};
8 N: U. r0 s* ?" M; z7 _- g/ w- @7 q% q" V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- o- K/ X( P- R | .leds = da850_evm_tl_leds,
* f4 }8 E) g- g' O f, k V, l% \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 C. H) `+ t* T3 g; Y};1 D$ |( P; H& r( F9 p+ h. Z3 z
7 u/ K( ~8 L0 `) k! s) C
static void led_dev_release(struct device *dev)( m' S) [+ E. {) ~/ r+ c6 e( k" d7 h0 Q
{
5 \% p% R" [$ B h; J" Q8 j8 p};$ d+ f( M7 C$ j/ w' _% w& p6 Y
# ]. d4 H2 Y6 R. \( t
static struct platform_device da850_evm_tl_leds_device = {
0 I1 P$ Q _0 f8 _2 M; T8 ?- O) I: h .name = "leds-gpio",. Z, U* |* ?- X$ G! W
.id = 1,
4 } W6 L0 c) j0 Q \ .dev = {
; F6 D8 } E: K( } .platform_data = &da850_evm_tl_leds_pdata,3 s3 ] G# Y' t6 _7 g% | }
.release = led_dev_release,$ l) B/ A4 m7 Y3 G/ P% s
}
! j& `) C4 H2 M: r# W! V};
' v, r" [* \# W/ r. E% V8 r$ W* d' r% h
static int __init led_platform_init(void) Q8 {* X% J$ T# i( [8 ]$ [- T
{' y( n ]5 U* R+ k9 Y2 g
int ret;# o; ^# p8 o$ b B9 O
#if 0
- A5 e9 U5 z' G2 e4 ^+ Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ _8 P$ M/ C- }& i& w8 k if (ret)& X. W5 s2 E9 U* Z |: ?" u1 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 B* d+ @& E/ E, A; ]7 u8 K "%d\n", ret);
+ K1 H3 D N+ K) l4 s, v. `#endif
" w- Y1 `; s7 F9 W. {3 p4 h ret = platform_device_register(&da850_evm_tl_leds_device);
# x+ O: |. O7 c4 f D2 X. D' g if (ret)) ~. e6 c% `3 O b5 v; @/ ?9 K1 s. |
pr_warning("Could not register som GPIO expander LEDS");
: M2 h0 q9 w4 }) l" A k2 Z) x else3 H/ ?" f6 B# }' ^0 ]4 r
printk(KERN_INFO "LED register sucessful!\n");( @# y0 e/ J) t4 g- p, G
) V. I8 f$ i/ N1 N0 M$ J
return ret;
S N+ a H# D3 s+ R; ]/ V}5 s+ K) d3 R5 W1 G7 z
/ c3 Y% H' Z; o/ N) [6 Ostatic void __exit led_platform_exit(void)5 X5 b2 @9 ]+ x% B
{
" p9 x3 W. r9 _9 L platform_device_unregister(&da850_evm_tl_leds_device);
, e6 R* Q( } x4 @0 g" w, D# P( M! }! u
printk(KERN_INFO "LED unregister!\n");- ?+ u3 `4 l- R% r F
}
. g) [' N h1 e$ M1 V1 F: n% B3 u& V: L7 p
module_init(led_platform_init);6 W& q6 N& [8 E, W
module_exit(led_platform_exit);
( @4 y4 ?5 p9 }& i( F2 q* T. i+ R
! Q+ k0 h: P% h- P# |MODULE_DESCRIPTION("Led platform driver");
& G, r/ J2 }: {( Q& p% bMODULE_AUTHOR("Tronlong");
9 _0 f( {3 {4 |1 ~( jMODULE_LICENSE("GPL");3 n( C5 w, f) V( T% g- d
2 r, ?( _# q$ r- }
|
|