|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* x) V: V- P. Q6 r+ @9 ^
#include <linux/init.h>4 F3 e5 K2 _# X+ v/ H& H
#include <linux/module.h>
3 ^7 n7 s; d" D" q6 a& X#include <linux/kernel.h>
: T: ?) C. q4 k#include <linux/types.h>( ]" c3 x& z& w
#include <linux/gpio.h>
) N1 ?3 L0 ^& B2 Q) {) x7 B#include <linux/leds.h>
: ]; h* S( x2 ?4 R. w# w$ B#include <linux/platform_device.h>
9 s/ p8 e- Y* Z0 A3 v4 N- ?" R$ U/ {0 t8 P
#include <asm/mach-types.h>
$ o# u r# F! l#include <asm/mach/arch.h>( D( J8 x' E8 c4 O8 H; d5 k+ C' v3 G
#include <mach/da8xx.h>6 W1 {% \* k* R- p9 _9 K# ^
#include <mach/mux.h>( k: `" d0 w) T# E7 o$ H5 h
; w8 d: G& m4 Y$ V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ P! Z2 u( T. q2 E4 d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 d) z) p) a% D. I5 b% C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 P% ~2 a: k% _0 ~, P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ `- H7 n9 e! W
) F. ]4 f+ `5 D$ v V) x/* assign the tl som board LED-GPIOs*/
; f. i9 N8 a8 T% m8 ]static const short da850_evm_tl_user_led_pins[] = {
1 U0 L8 [4 z1 x+ l/ r /* These pins are definition at <mach/mux.h> file */3 ?# Z7 \: j5 r. `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 P( K; y( p! }) }& e$ u" K0 Y3 X
-1% I8 C& A- E4 L2 ^
};. H @, z5 ]* S% E* b6 @. x
. T) ] _( K+ `8 v9 Z8 wstatic struct gpio_led da850_evm_tl_leds[] = {, H X9 U8 X$ r6 s9 ^: ]
{) z7 J$ B/ b5 M. i+ D
.active_low = 0,
+ Q. d+ {! v" x: N* a) U( I& | .gpio = DA850_USER_LED0,
`; u' ]) @ N4 Y0 [ .name = "user_led0",
9 Y& V* U! m1 u .default_trigger = "default-on",
0 _/ N! t& X- n5 I0 j2 ` },0 Y6 w5 Q5 M. D2 u+ K* J; |
{
* B) d$ E; X! ]' v3 F5 N .active_low = 0,
3 k2 I3 T3 J2 k0 v3 j! T) P$ q5 o8 E .gpio = DA850_USER_LED1,1 Q/ R- |# T& N9 t# J1 \8 U
.name = "user_led1",7 S8 p6 r0 ^5 h1 I8 ?
.default_trigger = "default-on",( E5 P8 ~5 i3 o. J, r0 x. o+ ]9 ]0 n
},
1 W0 [( p5 s$ X3 a2 S {
5 u9 i, B# a& @& } .active_low = 0,
* ?! _5 l9 B+ e6 \ .gpio = DA850_USER_LED2,
8 O! x8 g6 t) c6 S7 r" `7 f .name = "user_led2",
" |% C0 p! B* W* n .default_trigger = "default-on",
% ?7 t, t7 @" g6 [ },% Y& L# t; ^3 f) x( X% j$ x
{) A# K: ?# n0 h0 f% B5 P: u
.active_low = 0,
( }# }! _1 \2 f .gpio = DA850_USER_LED3,
5 U( U; L( j- u( G& L( v% s .name = "user_led3",# p1 c# U" c9 g- `' G. V# M+ f2 a
.default_trigger = "default-on",3 v/ t5 I5 q) m% O G4 l; g
},) g' N. k9 `8 X4 ^" W" g) `8 b5 e
};
! f. ^1 F# I, G9 F
; c( Y1 G, C8 X* S/ |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; a9 a3 n# ]0 j6 J1 D+ T9 L% v& j .leds = da850_evm_tl_leds,
- V% S3 ~' i& g- o+ |6 r! f" a! B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! f- u. Q5 e0 M/ x! J8 {. e};9 J. t" X5 C+ P
, w9 f: {3 v! c0 U B
static void led_dev_release(struct device *dev)
2 W, A: I: b b{/ y/ ?% ~4 j+ Y' c8 \. t
};
\/ p/ W! J8 R$ X6 p/ J; \) s! _
static struct platform_device da850_evm_tl_leds_device = {
6 Q1 [; j- s" b6 \ b' p( V .name = "leds-gpio",2 w& c" _9 X6 y9 a) W' x2 o1 G
.id = 1,
/ x. f/ ~, V( F .dev = {! H8 C* j- K4 W+ \$ Y9 |/ a/ ^
.platform_data = &da850_evm_tl_leds_pdata,
8 Y4 f5 L0 D$ A n0 y7 \ .release = led_dev_release,; o$ y# Q' ^+ O* `) X+ G3 [
}
8 ^3 K+ \ m0 E0 ^ j( u};; Y+ a! W, O& c
9 R/ j$ s+ h9 |# ustatic int __init led_platform_init(void)5 W6 p/ M. e* N4 c( B
{
6 [9 M2 i2 e d/ e. L0 O7 G int ret;. O F0 I* B& w+ H V8 H
#if 0
; F9 c" D; ~0 z- i% M |2 Y/ H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ K5 {' Y7 _$ t6 \0 `' E5 f5 h if (ret)
7 F O+ A( K2 Y& \5 ~: c$ f& _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ N, E# M: q; x. t3 A, u: W "%d\n", ret);6 V1 Z- S8 `; D+ o' v) S
#endif
" f( i9 o3 T3 i ret = platform_device_register(&da850_evm_tl_leds_device);: m& L' y4 ]9 ^9 Z. L; p, B, f; V
if (ret)# e/ P. r9 v' L" V+ G
pr_warning("Could not register som GPIO expander LEDS");
/ i# x9 I" m/ x! f* F/ N+ o else7 f, u% |8 l ], W
printk(KERN_INFO "LED register sucessful!\n");
# |( O3 ~5 {# N* Q' N! ^2 F1 {! r& g! L
return ret;9 t( g: p# {8 r' c! h
}& w X# m$ N; r. L1 {
) P5 r6 ^8 w. ~8 ~7 E+ Y$ k/ @
static void __exit led_platform_exit(void)
. s' \" A7 a% b7 @5 ~0 c. N{
+ S1 [& W1 U% v6 t) p platform_device_unregister(&da850_evm_tl_leds_device);. B$ s+ g& s3 p4 n8 t- A
& `- K0 J' s! z4 l8 F% Q printk(KERN_INFO "LED unregister!\n");
, ?; F6 g( Y8 [9 m5 S* Q}
6 d4 V1 i$ ?6 n5 P2 \9 W# x
. n. |0 M$ s4 |9 }, M9 i Imodule_init(led_platform_init);
3 F( c8 Q' h7 J3 E$ Z! \$ \' amodule_exit(led_platform_exit);
% [% F/ s* n; S/ n8 B) v: [5 D h, c/ g& {0 z) N% N- d5 t
MODULE_DESCRIPTION("Led platform driver");
4 i$ I+ l1 `0 |! z# ?* L' PMODULE_AUTHOR("Tronlong");( M0 W( I6 { X" f8 b
MODULE_LICENSE("GPL");3 N- ]7 d v! A7 g
+ ]6 K' D2 r3 r$ [+ U |
|