|
求大神给下面的程序做注解,请稍详细些,谢谢。
! |, w/ w2 k# F4 R#include <linux/init.h>
& P% x. T7 u I0 o! |; T, y( s#include <linux/module.h>
" Y j+ f% c F0 ] e* W#include <linux/kernel.h>; j# c. t8 [0 G' o+ K
#include <linux/types.h>8 h! o* @9 G, }5 }. H4 S$ R
#include <linux/gpio.h>
3 w& ~* |1 f+ Y; F# \1 A#include <linux/leds.h>
& T( `9 {9 _( U% O9 v2 G4 T#include <linux/platform_device.h>1 e: r9 h' e* K9 f" H
' V5 {* q% o, i0 K' u% X1 r, x6 c3 f#include <asm/mach-types.h>
: w( ^) i) H; d T( i8 n#include <asm/mach/arch.h>
# y, _2 Z" _% v; ?2 j#include <mach/da8xx.h>
9 w; B# Q; V0 L' X( w0 _#include <mach/mux.h>1 @2 {! U# ]4 o% z; @' G, B/ z
0 {7 ^% z* ?& W; Z Q- \9 x$ h( o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 e4 {- h. N- y5 G- |9 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), ?; K6 o$ e; ]% J; {+ F+ ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 g$ q! F+ _ k3 E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 O4 p; T M8 }+ ]# A! U
, Y- |& ~3 O, N0 Z2 J! e/* assign the tl som board LED-GPIOs*/
) M1 }6 `, P% Z% Sstatic const short da850_evm_tl_user_led_pins[] = {
+ S5 r" r. X3 R" D8 n /* These pins are definition at <mach/mux.h> file */
1 D" a. O ]" J. r# }9 C3 r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 q6 B, Y- Z8 r5 w- c @. o -1
, _8 g/ k p8 J};! P) w+ { |( C5 I
$ o: D# m0 Z7 g+ vstatic struct gpio_led da850_evm_tl_leds[] = {
( O+ R, |$ p8 a8 c {" Z" {! e3 U7 y
.active_low = 0,+ m# ?! `4 ?! a3 _8 Z! v
.gpio = DA850_USER_LED0,
0 e% @! ? E, w .name = "user_led0",
. A' l% B9 |4 Q6 B! j } .default_trigger = "default-on",) O& f8 M+ r* G8 y
},
( j! D) r3 _9 i; [" N3 | {6 ? X/ c; B) r0 k6 J
.active_low = 0,
; I" \( p2 L4 f- C; Q- {; v( q .gpio = DA850_USER_LED1,
1 H0 h* c. d4 F& S: ^ l .name = "user_led1",! O9 P( x$ U% C/ p' K" W
.default_trigger = "default-on",
6 p! u2 o2 L2 d3 O },
j: g: m6 g% Q- j {* {2 S; A% F$ U
.active_low = 0,$ A6 E7 I7 t. Y# r1 q3 u9 m
.gpio = DA850_USER_LED2,
t% O. _0 v- p" i, S* u' K .name = "user_led2"," O5 I B9 E- J+ Y$ r8 L7 n
.default_trigger = "default-on",( E/ p7 L @+ [5 t! M4 i- C1 ^
},6 V& H' h, d8 q: S' l9 a2 |5 `: g3 H
{
0 @2 b6 F. g, C( C# G2 x .active_low = 0,4 L* ]: E. B' Z! n6 V# B( e2 z3 u% a& |
.gpio = DA850_USER_LED3,
4 c5 r' p2 W0 b; v .name = "user_led3",1 s% Q8 U4 j. _' {* r" ]
.default_trigger = "default-on",9 o. W' e- a+ @. E9 ]: ] t
},6 E* C6 M6 a" v m* K; H. S
};
1 m- a/ q) _* Z$ \- b& p/ q) `2 {" Q" X# E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 v3 G; r: W: ^3 F6 a9 w) f
.leds = da850_evm_tl_leds,
6 i. r8 j& \$ D- P: r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 c. V! p0 K1 g) m( f4 `! @};
" L8 ]. s; B# H3 U5 b; _" j( p$ `* W1 ^) C7 A
static void led_dev_release(struct device *dev)
5 h. v2 T! J& {( D( Z! t{
$ R9 j/ B5 Y! l( d: q8 P};
$ ?! R6 V( x l7 ]5 E0 |2 `+ Q7 I; R4 O9 v0 W: f
static struct platform_device da850_evm_tl_leds_device = {
& \. D% x, A/ S .name = "leds-gpio",% g% b% ~+ ~2 `+ v) r& n
.id = 1,8 q W+ _5 i* x
.dev = {
( o h# a V1 a/ ~7 t% Z! j .platform_data = &da850_evm_tl_leds_pdata,2 _2 u% f' Q- W1 a
.release = led_dev_release,3 n6 e3 V1 Y, l5 x# F% s t
}
$ E9 @' j0 d: r: V0 e};
1 i6 I7 K) j& u0 U0 g8 I- [! B8 o- K5 @+ _7 ~$ |
static int __init led_platform_init(void)0 ?, N9 x4 p- n1 m+ \" _
{
% e; i* j; t# V& L7 U, y int ret;2 l. Z) Q k; b9 e9 z$ y
#if 0) s6 B, H5 T8 k0 }) b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 A3 ]1 j. u( s$ R7 ?+ p if (ret)* q6 [5 L* U0 Y6 g9 F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 B) v* Q( A3 | ?" N "%d\n", ret);
# ]7 t* U- Z) F& W6 }$ {( \& I#endif6 ?5 X6 h' l' s, }! X, M- z6 ]
ret = platform_device_register(&da850_evm_tl_leds_device);
* b w' W- c& m: s/ t1 L% a$ Y \6 b if (ret)' X5 d. o F2 d/ \. h- M
pr_warning("Could not register som GPIO expander LEDS");
1 O' G% |2 O: v6 x8 B1 M2 V6 O else
0 h& S( c0 X7 O0 t+ N printk(KERN_INFO "LED register sucessful!\n");6 S; k8 N+ H* E+ [2 L# X! F! Y
* N* y, N, n6 y j
return ret;
) A G9 A! }& X8 u$ k1 G}
( I$ O3 H3 G" [! b! |/ ^2 V. Q% W, `. u# r+ t! |/ h
static void __exit led_platform_exit(void)
- z+ N2 Z( f! N, y2 \{
1 ^+ ^- y4 w- a7 t. M platform_device_unregister(&da850_evm_tl_leds_device);
% w3 e0 K: `: c* D- P' U! z. d4 f1 G' a# I! E" f+ P G2 {0 o9 q
printk(KERN_INFO "LED unregister!\n");
3 y% J' ^0 u6 a& ]; z6 m+ Z2 L}
8 j! B+ r! _3 U' k5 x- n% S
% x& z% W2 F, e; N+ B9 P/ X& dmodule_init(led_platform_init);
3 ^5 V/ o3 P6 `4 L1 }module_exit(led_platform_exit);
& R2 B9 _3 C7 l; A- L
4 t0 {" v9 P! \& w6 X: PMODULE_DESCRIPTION("Led platform driver");" V( V* H3 R+ L7 z
MODULE_AUTHOR("Tronlong");" f6 F1 m$ r2 G1 e. q5 A" z
MODULE_LICENSE("GPL");
6 {( m! l( l) ]3 }, {+ ?
; M! v0 X, [3 a- x' G |
|