|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# Y' U) H; e1 b#include <linux/init.h>
+ g0 `3 `8 E/ W4 D! x& d, k#include <linux/module.h>. h' i5 h M2 u7 G2 q: W+ J- E
#include <linux/kernel.h>
3 x2 R- K8 a- n2 c#include <linux/types.h>" y& w0 S* J, n1 s2 W1 i
#include <linux/gpio.h>+ {/ o& R1 y1 W1 ~2 B4 ^
#include <linux/leds.h>
; y! i; \0 O9 T( c' h#include <linux/platform_device.h>6 c- C0 e. l4 T$ F
& k% @% T: `, {7 p$ `2 D2 e#include <asm/mach-types.h>
2 |1 w% Q" ~' S# p% q( E; Z#include <asm/mach/arch.h>
. @/ N+ ?& W( T% r! c% ?! @3 s#include <mach/da8xx.h>( Q/ m6 j" D: ], F: r" T
#include <mach/mux.h>5 }2 V/ n/ W3 J5 W
4 i/ |& X1 W% y5 Z5 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 m, ^1 ` M+ Q/ N8 j8 R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 F" G- p* e- D( J- l9 U9 B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
N+ F3 T) T, X6 G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# z# [+ U2 R: v0 P$ r
" J: @( W v, X6 ^1 |5 }/* assign the tl som board LED-GPIOs*/
2 G, |" [. L: u+ ?. sstatic const short da850_evm_tl_user_led_pins[] = {" {8 `2 e3 c1 N8 V) u
/* These pins are definition at <mach/mux.h> file */
! F: l( X" h% F+ d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ G2 C+ l2 L( G8 z* l
-12 r' r" l' f% W( l6 Q2 E$ C2 s% b
};; ]& u8 G _& w0 I0 N* [% m
: c' k7 W% l; S( Y7 \+ n) A
static struct gpio_led da850_evm_tl_leds[] = {7 J: {! E5 ~/ e& G8 `
{) J* J4 L1 C4 S# K, `; s7 M; ^
.active_low = 0,
1 R, G+ @% b0 U3 z$ y; q! ] .gpio = DA850_USER_LED0,
! I' x% D: j- A* W/ R .name = "user_led0",
) ~! \, u- V- n0 d, A .default_trigger = "default-on"," R5 t* L3 J# w, N) t6 Y
},
7 u# R- _) P Y {# \% z5 J) v0 W4 t1 {8 _. A; m
.active_low = 0,9 s, x6 }2 ~- v; m' c' ]6 l
.gpio = DA850_USER_LED1,( r2 d3 E- @0 }% d% l& G( O) w- x
.name = "user_led1",
& ?( D7 C8 N+ x, k F. Q$ v! x .default_trigger = "default-on",: E2 Y4 z: ]+ I }' q7 N
},2 c& a) Q! Q- W( W3 ~
{
2 `; o& K$ B; r9 K4 L3 j) [1 Q .active_low = 0,
5 k0 v# Y$ y6 T .gpio = DA850_USER_LED2,
+ w- G) w3 d7 A" D& K2 y# v* G .name = "user_led2",
) R4 Q0 P; `' F5 O& x& T+ N .default_trigger = "default-on",- o: _ a1 H3 `" X
},* J; @' ^0 B, ^) v% J2 e1 A& Z6 C
{
. {) W/ V- S8 v; |! q' q e* z# H4 X .active_low = 0,
' A4 m0 ]' Q0 t# m/ V. i# D .gpio = DA850_USER_LED3,
i* }" X: d- v5 X .name = "user_led3",
0 z; d5 _ P! z% r& q. L .default_trigger = "default-on",
# \2 B$ v0 r- Q7 x },6 B* }; k2 @. H" Y; m: F& g
};2 C p$ X' w/ h+ `( p
% b; b) p) s- b% |# Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ a# y/ _# O. L9 z+ ^ .leds = da850_evm_tl_leds,* q! {0 \9 B8 x& }8 J0 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( B6 Z2 E6 u3 X3 w& a" l
};0 d9 Q8 X1 {5 o3 N+ s( b8 Y1 k6 D
- v: y& X! b( x3 X; J, h+ F( y6 F# vstatic void led_dev_release(struct device *dev)
. o+ d+ g) L! S3 C& c% q& b{4 W ~# u) W1 E8 A9 K3 }
};( i) ~0 o* s3 y# c
# S5 }! c7 V) T2 `2 f! ?1 s8 U
static struct platform_device da850_evm_tl_leds_device = {
2 S/ F a5 B& \& Q .name = "leds-gpio",
. v. w% _% ^/ V5 H4 T4 u' A% q0 l .id = 1,
; d9 V. j! m0 i) l( N. v .dev = {: w" M% {4 F+ S' C; E) Z' N
.platform_data = &da850_evm_tl_leds_pdata,
' j6 K( n2 b( Y3 d4 o .release = led_dev_release,
# K; C4 I `* v6 M }# k9 o+ W% R3 f
};
( _- \# b- D$ k3 ?5 v3 _8 R: a( s+ {1 V9 |$ K
static int __init led_platform_init(void)
: \% m" i. t* V{
2 K6 l9 `: x4 W5 W int ret;# r* D0 q9 ]- L: m( k! p, b
#if 06 o7 K p/ @+ O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" Q: V* H! g% y; p if (ret)) D# S- ^4 O5 L% g: b3 L! H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" _9 {3 d$ M* Q1 v- h% z$ f3 S "%d\n", ret);
& b( I, [4 w! a; s- s8 b1 _: d# v#endif
% q. s& K% d" d+ O. W" V6 ~) C ret = platform_device_register(&da850_evm_tl_leds_device);1 N. |' y$ q) i+ U3 T9 l
if (ret)4 ?0 e9 ]7 ^( q, m) H0 \& `
pr_warning("Could not register som GPIO expander LEDS");
4 {% ]% `: a& y0 p$ ~2 ]* U else" [5 z# b' D4 c1 O5 P! K
printk(KERN_INFO "LED register sucessful!\n");: n% o7 D. {" R* x! U
# F' V7 A; I3 A& X: O2 v* o
return ret;( O1 P& g$ R; f6 s0 p$ u
}
* }% K$ A @( c. c/ Y
5 d$ m9 _0 @ Estatic void __exit led_platform_exit(void)6 L6 n' V+ L0 }
{& {, U) H6 ?3 ^: L' o
platform_device_unregister(&da850_evm_tl_leds_device);) D6 j; z2 z; [* Z' \; I
& O0 G( R8 M+ k" q6 A& g* z
printk(KERN_INFO "LED unregister!\n");$ S- C( U7 _* _5 s* S) I2 n
}1 ]. V5 u4 A& E9 b5 B9 H; d
5 j$ Z8 L8 _5 Tmodule_init(led_platform_init);
5 _5 Y' ~. ^6 g3 U& B# Ymodule_exit(led_platform_exit);
/ p, \* }2 r! Z( N$ [) I8 O" y3 h* `! H7 u1 a
MODULE_DESCRIPTION("Led platform driver");- [: `& S4 U% `6 ~6 h3 d
MODULE_AUTHOR("Tronlong");
" K" e2 }. w3 y* W0 P5 ^& ~9 D: D8 PMODULE_LICENSE("GPL");
3 W5 m5 v7 i* r# s
5 ^6 ?2 X/ |, S& K( w2 g4 R |
|