|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 R( t( e/ q) A$ I) P' U
#include <linux/init.h>
; M2 i1 G3 ~% [ P8 t#include <linux/module.h>) `' W! x$ |- v9 \1 r& n
#include <linux/kernel.h>5 q1 E c# ~9 Y& v, n* f
#include <linux/types.h>
2 i$ H( U% N( \' ?#include <linux/gpio.h>
" t; Y5 ~7 A, I% {#include <linux/leds.h># \& Q# e, b [: U
#include <linux/platform_device.h>8 {2 p# {* _3 ?. L* m# Z; j% l- P* f
8 O) H1 y5 e/ y, N d
#include <asm/mach-types.h>0 h8 f5 `1 R9 _* L0 _
#include <asm/mach/arch.h>: [$ `- P. H) O
#include <mach/da8xx.h>
0 f& Y! }: T( a; ^#include <mach/mux.h>
) Z3 X2 @9 U. h* ~. \; p, p3 p3 z" F$ C( k! q" I4 x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): p- Z; M" p" l6 z- |* b% g; `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& a; e6 k, m1 h- L# N6 I7 w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ W1 P% V% d* \% `8 j2 _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 m/ d& n; L4 t1 o/ ~" u
, U' W1 I$ i* Y6 |' A8 ^" h/* assign the tl som board LED-GPIOs*/% }6 ?$ ]& ^) J( s/ U6 q
static const short da850_evm_tl_user_led_pins[] = {0 h: g9 Q8 E; Z7 `9 ^
/* These pins are definition at <mach/mux.h> file */* t( K+ p6 s X7 }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& m! V0 T+ f- E) \ -1
! q o0 N, I( p0 T ]1 r# b$ o};4 Y/ Y& g6 m7 e+ c. t0 p) M
1 I; j, t$ d2 q$ {: Istatic struct gpio_led da850_evm_tl_leds[] = {
W$ w: j2 t* ~4 r {2 D4 z( d' S, c E
.active_low = 0,' N* i2 K; H0 Z! r3 b9 y3 k8 W$ U, C
.gpio = DA850_USER_LED0,0 S& x+ F9 Z$ ]" Y" A+ |
.name = "user_led0",8 R4 ?& K+ [* J( b
.default_trigger = "default-on",8 r4 p6 W7 m5 q1 L: l; V' F# H( f
},) u8 k, ]% Q, H7 `9 G; v# E% ]* H
{& P/ i" {2 R* G% D) V2 O+ |9 R
.active_low = 0,
) f% x' z1 h" |) H/ H* b8 i8 i2 D .gpio = DA850_USER_LED1,4 \! U/ G- z- b& f4 Y! n9 ]& @9 A
.name = "user_led1",
2 D) F3 X# S" b9 b( k* p .default_trigger = "default-on"," G: M7 X' ?9 `8 J1 {8 C
},1 |. @- X: r# G! w# G
{
/ X2 r1 Z2 Q' T3 _% m% | .active_low = 0,
3 i+ @ P# g0 O: B9 | .gpio = DA850_USER_LED2,
2 }4 [' L# i: \# k .name = "user_led2",
4 W9 Q- }2 b6 c$ [ .default_trigger = "default-on",, ?6 q* i- e" N* U! m
},
8 c4 L8 C9 d, j$ r6 c {
9 }4 W0 |, W1 W: B .active_low = 0,+ ^" x, U% a% v8 W" b# |# P* ]
.gpio = DA850_USER_LED3,
% i0 v9 q3 d' k, O1 { .name = "user_led3",1 g+ W* S) i: ~: K v
.default_trigger = "default-on", W; i) i/ u, w3 s) w E
},6 B& |6 y A" d# [' O: f
};
$ q+ s# r5 { L# ]" t- j
a2 u$ ?5 T2 e9 Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( d- a! C+ @. J
.leds = da850_evm_tl_leds,
3 Q# E$ k& G9 Q W S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 J! A" D& `5 U6 W% r+ X
};) ?- _; U6 q' q# g8 M
8 {: b* x" x- q
static void led_dev_release(struct device *dev)
2 Q, ^7 M0 v2 Q$ N; M M{5 X9 A. }- Z( W, o) w4 S
};7 q- k* a$ E; Z! u$ N0 {
8 s7 Z! Q. y. I* w
static struct platform_device da850_evm_tl_leds_device = {( w4 x" I/ p! S7 t; ]1 e+ n4 R
.name = "leds-gpio",
e4 \9 @; @$ X0 n% k& p% f, v/ Q .id = 1,1 I+ l1 R( a0 n3 o
.dev = {
3 m4 [' w* j. F8 ` .platform_data = &da850_evm_tl_leds_pdata,4 Z: Z+ j# O; |# \& w6 }7 x
.release = led_dev_release,
4 p% L8 J( X& r4 } }
; b' |& T5 F8 P$ w( K/ t};
) o8 X E& P. M5 b$ Y" N
0 e/ x6 F& n) ?* G) @, xstatic int __init led_platform_init(void)# T! @ s: d, E- \. D' x
{
1 ~! a& Y6 F* f. u int ret;
& H+ g* P% ^2 a3 @5 x#if 01 C) b* b5 i7 H6 ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 x# g: n4 r4 ? d7 u8 j: \! v b if (ret)
6 Y n# @3 h- X0 R' e; O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 g4 z; [' Z2 z& P# |! H! f. u "%d\n", ret);
# I" t# V+ }# p# |) O7 f# D#endif+ R5 ^) w8 O6 p
ret = platform_device_register(&da850_evm_tl_leds_device);# l2 @7 M: w8 ?, R* U3 K
if (ret)
% b5 q+ k8 t& a- W0 y pr_warning("Could not register som GPIO expander LEDS");$ V& O/ W5 S2 \7 \
else
C& ]2 B* ~6 } printk(KERN_INFO "LED register sucessful!\n");
- w) B( A; G* J6 K- N) _( M7 N- V
% b2 U" b8 M$ M0 T return ret;' G1 C. p$ R2 B2 \* A5 l: x% Y
}1 I: I! c2 }/ Z- I5 U/ w- Z
# r H( P; ?5 Y0 Q# k
static void __exit led_platform_exit(void)
! t, Y: O* V2 L, E- Y! M4 J7 f{
3 s& a6 ^4 e/ Z platform_device_unregister(&da850_evm_tl_leds_device);
5 }( o5 m9 h- a1 a, X& l
3 T( p9 V, ~/ U9 _9 Z printk(KERN_INFO "LED unregister!\n");0 G+ L5 ?4 m( I
}9 p+ }) U" x; y
1 B% ]2 ^% {/ `3 x
module_init(led_platform_init);6 A& R H7 e9 z: I E
module_exit(led_platform_exit);
6 f2 g4 V" L* {
2 a* _" x: Q3 m& dMODULE_DESCRIPTION("Led platform driver");
4 s/ p% @, S3 F9 x: O; [) xMODULE_AUTHOR("Tronlong");
- w8 t- }# z6 e7 S$ s2 Y2 xMODULE_LICENSE("GPL");4 @" i! m( J f3 G+ \
+ \) n" l* G. E |
|