|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, F4 q9 D+ V: p( l#include <linux/init.h>- A, W1 ~6 }/ p* c; e
#include <linux/module.h>
5 ~! a7 L& @- c0 E#include <linux/kernel.h>
4 J, ?/ _, U: O, w: E6 w( \- q#include <linux/types.h>8 y' R: k0 a8 f8 W+ \! o9 U7 O
#include <linux/gpio.h>
0 b1 { G) k2 s& ?5 P; ^1 d#include <linux/leds.h>
- Q) ~+ q! b% q6 q F+ ~% r+ j) q#include <linux/platform_device.h>
4 R0 w7 a* b* S! I7 H
% S. G2 h) I" Q( R0 M6 U#include <asm/mach-types.h>
! B/ e N$ f0 Z+ h% {: l! l7 O#include <asm/mach/arch.h>, h7 R, x4 T; P/ q+ N4 |4 s w
#include <mach/da8xx.h>
" `1 U9 O; [- y3 z5 r% |7 \#include <mach/mux.h>
o6 Z( {4 r1 L, J f5 a7 G, x& T. q2 @% S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ r/ w& O, S0 O% w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) X" H. w" E/ G3 U% |" I# t: g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* h ~& W9 X! ?! Y% o' M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ ]6 \# a' }. d& S5 R+ {" t( z4 q' X
5 d0 I. I" B n3 T
/* assign the tl som board LED-GPIOs*/
" s/ E3 H9 y, }. zstatic const short da850_evm_tl_user_led_pins[] = {4 H6 z- c. V4 p6 @5 b
/* These pins are definition at <mach/mux.h> file */9 j; n5 f/ i+ r9 u( @; h0 d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% c1 @# F& |1 }' X- S: y -1
. O( N9 _/ k6 ~% B* w( t};9 K! k( {% z% V5 N5 l( `
% s3 D' T* g6 Q$ y8 Z3 O' ?. I! n0 R3 ?
static struct gpio_led da850_evm_tl_leds[] = {' |% f1 N& w7 u- H6 U8 X0 G
{
# n( ~, w5 k! k7 v6 i( i0 i0 Y& s/ C .active_low = 0,9 [& E0 I7 t( S3 I7 Z/ x% q
.gpio = DA850_USER_LED0,
/ O: q3 {4 t, w9 q6 A ~; N .name = "user_led0",9 [0 \$ }1 |8 k7 d1 g7 M# @: ]
.default_trigger = "default-on",; P% L8 s9 R2 ~
},
' ]* ^, W, E: |) q3 _' J {
7 y0 n. i: F9 u3 s* { .active_low = 0,
/ {/ t+ B$ e) F- I" F: J; q .gpio = DA850_USER_LED1,4 j. ~7 |2 x! Y6 _* y+ X
.name = "user_led1",
3 H6 m2 R3 ~" D: x& y .default_trigger = "default-on",
) `4 b, M4 ~# U, s },7 i& z, w: O- p+ ]% c' r1 ^: F& H" C
{
( I& ^ v( ?/ ]2 K7 @- a .active_low = 0,% z I$ q4 r6 J8 Z, o
.gpio = DA850_USER_LED2,
4 Y, ]5 \" P% v .name = "user_led2",# M2 w! z9 R7 N* V
.default_trigger = "default-on",
# ?7 ?2 S3 {5 ^; \; n },: j/ x# U& x$ |. e) c0 y, \3 V
{
* u% ?. U8 k j .active_low = 0,! o& ?1 C5 q/ y3 q: n3 p
.gpio = DA850_USER_LED3,
* F, w7 }2 S# V7 u .name = "user_led3",5 Q5 o+ D. y# B
.default_trigger = "default-on",
, u- j0 g1 p% _; Y3 Y },
: ^ y D3 J9 J* r3 ^};
* A" |# D7 Y; `: j
# N0 n5 ?1 E' G& b- ?* wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ }$ [5 p1 |6 m% ?: z3 g' a4 [6 C
.leds = da850_evm_tl_leds,4 z3 u# r0 p' ^% `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* E# ?2 ?4 `& a$ V s6 R4 I5 b
};
! ^# m4 w' ?6 x; M* O
5 x+ u; a& f6 U& b1 B/ }static void led_dev_release(struct device *dev)
, @) e8 l- V3 I3 f! P4 p2 m& I( w{
+ f4 m5 X! o; u7 k/ ~};
L: C$ `2 r1 f$ h) Z
" s+ ~; R3 R o+ ?4 ~. V. w2 _static struct platform_device da850_evm_tl_leds_device = {& V: l3 Z, X) x, S) \1 e
.name = "leds-gpio",( c% y$ Y& L5 g" t" i1 P
.id = 1,! G9 ~8 V7 ]3 Z. D% B
.dev = {# k. ?+ x! K0 q" N0 z% o0 A* Z
.platform_data = &da850_evm_tl_leds_pdata,
* }& P; G w: V .release = led_dev_release,
; V2 D3 `! o4 y' y+ x C4 T1 l }
. \" k1 M2 P0 S};8 R& B) R' k/ p* c# @2 r- n" ]
0 q/ U" f1 E s5 e7 c) n5 _6 U5 e
static int __init led_platform_init(void): {- x; D/ T! V/ o
{
2 f" V/ _7 G$ f5 D# @ int ret;9 h9 q9 y! I6 G" Y; V
#if 0) b, {% [1 @4 O+ D: ^5 n1 a9 e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 ]) r! P9 m" N; i0 b! H
if (ret): b6 V4 o! W, H( ^+ N$ I2 U u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
J7 D* A! i" e2 V" R7 Y1 Y "%d\n", ret);- x" H7 k4 m0 }
#endif
9 z7 P( F( V' i( F ret = platform_device_register(&da850_evm_tl_leds_device);0 O6 k& g% v! k9 }4 q7 e3 K
if (ret)
8 s# J! b- ?. \: G9 ?/ E pr_warning("Could not register som GPIO expander LEDS");
* D& g& ?6 o2 Q' i/ p7 n- A else
4 A/ I; a- ~7 X: u" R printk(KERN_INFO "LED register sucessful!\n");
7 s9 v& N( ~4 i2 } P2 d5 n* V2 Z7 O7 G# F
return ret;# A* x# Q- O. {6 t/ n
}
- L* J# T/ t7 e6 J; F
6 j3 @" Q* C9 L5 `static void __exit led_platform_exit(void)
% D1 k. C5 Q) J+ E% n! @: P{
1 q8 i D- g6 d( q/ j+ K platform_device_unregister(&da850_evm_tl_leds_device);: `: \) s& K0 g
3 h0 z1 |$ s4 A* v7 a4 Q. {0 s' I2 ~; ^0 C
printk(KERN_INFO "LED unregister!\n");9 w$ r$ o" u9 Y2 `7 v! F. ]
}
8 u* a0 E* f) p, t3 x: Q: k) L4 G
* k4 ^; b9 N% }module_init(led_platform_init);
: o' l" J4 Z& G8 e n% |module_exit(led_platform_exit);
9 i% S1 d2 A) z( {7 {; C6 T) y& u4 V3 p1 x; a( K+ ~
MODULE_DESCRIPTION("Led platform driver"); R5 s2 g# E( [
MODULE_AUTHOR("Tronlong");0 |7 M0 a, e9 k, ~* e7 W5 M, A1 m
MODULE_LICENSE("GPL");9 J, F; Z2 ]& @0 P, a0 L& j/ @, l
; g! X3 i, x- {6 K( k |
|