|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) T8 T+ O3 M z#include <linux/init.h>
- D5 V# q/ Z( x9 g: m& ^: Y#include <linux/module.h>: q0 n5 l' L G
#include <linux/kernel.h>1 [% X; s2 b) E4 ~) ^
#include <linux/types.h>. ^) v- F/ I% l* I
#include <linux/gpio.h>7 c: }) T9 w n2 }: n3 E2 ]& {. l
#include <linux/leds.h>
8 x J: u3 K0 f#include <linux/platform_device.h>1 B% V5 B8 n& J0 C
+ t/ V) g' C, @1 f) {8 P#include <asm/mach-types.h>) a* g A. | m& a
#include <asm/mach/arch.h>' q3 o% k' `1 L: T) s7 s( e+ t
#include <mach/da8xx.h>
4 C5 V q, X" G8 i# v#include <mach/mux.h>
4 ^2 U% V% F z% Z( ^0 }# S& y- q2 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); H3 a8 Z/ B0 E5 R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 R' X% E. t; S2 a' W* V0 K* ]9 h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. u# m& ^6 Q6 S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 u( T# V1 [; G
1 V1 i) a; Q& Y* [
/* assign the tl som board LED-GPIOs*/
5 F" e! o# h/ h* M3 O, pstatic const short da850_evm_tl_user_led_pins[] = {: C1 Q& B( }$ P) H1 R; C* c! O
/* These pins are definition at <mach/mux.h> file */9 [; Y: [6 H5 O- L* I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 k0 {! Q, p3 D7 Z5 n0 d8 ^2 E
-1
. F; l$ E3 w0 Y};
- B3 E8 u% ]$ x" {7 U7 U: h7 q! o" R8 ^7 x( h9 S; j8 B0 T
static struct gpio_led da850_evm_tl_leds[] = {4 C- J2 ^! n% D( ^5 x. m) a8 z
{4 v1 D) H) ]2 g+ t8 N
.active_low = 0,5 U: V1 ~ i( A8 N) f
.gpio = DA850_USER_LED0,
& _) B }8 {+ p2 m% {5 w: E .name = "user_led0",
( @6 j) B* q/ y8 B/ z .default_trigger = "default-on",
. b9 n& h8 {% L* T6 ^ },. O7 E0 J: r6 |, a# P) W+ ?
{. }+ K8 K9 b& y5 w) l* v# r
.active_low = 0,
( f+ l7 X" t6 {2 {; r .gpio = DA850_USER_LED1,
+ R: X. x& I. }; F$ W* D( a2 l7 B .name = "user_led1",; v- F/ ^' |% R' n
.default_trigger = "default-on",: ]6 P2 r% M, i: Y/ i
},
" f) E+ X3 q; F6 J {" i( F7 @6 X$ d6 F# d# C
.active_low = 0,8 P5 H3 b5 ^/ W* S' i5 C, W5 D
.gpio = DA850_USER_LED2,
$ |& W% S; _: V b { .name = "user_led2",5 G1 ]3 F- R/ O. f
.default_trigger = "default-on",
" J# {$ V5 U2 \, e4 p$ k },
! i7 g1 o- z2 o- N% `% i6 k6 j {' ]# S5 t' n: f5 `8 K
.active_low = 0,
* z' B- N; c& F2 D! D! @. r .gpio = DA850_USER_LED3,) ~2 @. C B9 x+ {# ~% x1 j% `$ W( Q; \
.name = "user_led3",$ g/ B& @3 J( G& ] k r
.default_trigger = "default-on",' c7 V$ G G; K- v2 T" Y4 P
},) M" C, H4 U. D
};
8 o G+ u4 Y; b) s! B
( f: Q6 i% y4 q; s4 zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' @. N- z' y5 J4 v
.leds = da850_evm_tl_leds,
3 m0 V" J1 p% a% W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' H/ s/ i8 A/ F& _* h& E& y* Q" O
};
7 ~5 E( y) I4 c2 H- S7 r& L5 @- T# W+ ~ E3 V `
static void led_dev_release(struct device *dev): D) g4 x8 B B4 B( [- `
{
. {" P9 d/ J1 j2 c# G% [! ~6 j: O};; [ a/ `1 I& y' l8 d f
# z$ G) z. ?6 @
static struct platform_device da850_evm_tl_leds_device = {1 o" Z5 |# i5 T. \* ^+ M q
.name = "leds-gpio",
9 r& J, H2 o3 ~8 Q& n1 y3 I* d .id = 1,3 E& ?9 j) c d+ \4 W/ [
.dev = {: e& M% u' C. U' [ `* [
.platform_data = &da850_evm_tl_leds_pdata,
X/ K; ]8 R: w .release = led_dev_release,4 }8 ]. `9 x `, ?* A* t
}
R: Q/ s, X5 A7 ^, ?4 w; V4 B};
0 k0 p: ]5 Y! e1 m2 S
# k/ I. ^- C( J4 Ostatic int __init led_platform_init(void): K9 s9 v! Z; a- W/ v( _
{' S2 I/ L% e# [
int ret;4 C9 G# X+ _" [9 q# J7 ^
#if 0 j$ b$ q! r* ]4 B! q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" U' {3 b$ w ^7 p0 o
if (ret)9 U' S. c: ]: G% f) r# c" i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" H% s8 a- a( g2 K1 B$ n( A6 e
"%d\n", ret);
3 }2 I1 ]& a. g8 U/ Y3 U: A#endif
8 _, M/ |: U1 R# C9 } ret = platform_device_register(&da850_evm_tl_leds_device);
8 ~8 u5 @) A: F+ R& C, ]% [ if (ret)
6 B' j% C* u$ U' z( @) R" [ pr_warning("Could not register som GPIO expander LEDS");
3 {0 I# b1 O9 |9 h else( |, x5 |- U& ~' m4 c8 {
printk(KERN_INFO "LED register sucessful!\n");
/ t G" ]: P& H, E6 ]' N5 z$ k$ s" D$ E6 |
return ret;' x2 G, }% U0 e4 U( }% u' J" A: a7 r
} G6 o2 I% r. F* g2 w' \. w( r
+ U: M4 @6 A3 ~: Mstatic void __exit led_platform_exit(void)
0 M7 r/ e9 S( N6 D3 _1 P6 K{% k) }0 S( [7 k8 \$ o' x$ f0 a* u
platform_device_unregister(&da850_evm_tl_leds_device);
& Y# I2 o N5 T8 o6 S4 l. c# g2 {* c+ Y- a: U2 u- V
printk(KERN_INFO "LED unregister!\n");
) c3 G! f% M% Q* g- v0 d/ d/ {}
% n7 J7 i; m8 }! q+ o" K$ {& m- f* n% c4 c, h7 X* W# Q( `
module_init(led_platform_init);
9 z! B! t$ c* c$ W- Z+ q A! x$ Fmodule_exit(led_platform_exit);5 U z( F& G9 F5 W7 ~+ |. Z% y5 g
1 n3 Y! p" h7 U6 L1 }/ O6 D& rMODULE_DESCRIPTION("Led platform driver");
# X: d. W5 }; I0 r( Q' {MODULE_AUTHOR("Tronlong");
& U8 j- n- G( w& c5 j1 s6 GMODULE_LICENSE("GPL");1 A' T' O- d5 m( M
y& R8 i U* W- F; |* S |
|