|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* d/ ]* G" I6 X- f) O' A/ h#include <linux/init.h>
/ Y1 ?- J1 v/ l. @9 u( P#include <linux/module.h>/ _$ O3 o7 z* x: n$ y
#include <linux/kernel.h>5 W2 R; ]/ ?7 Z, |3 j
#include <linux/types.h>0 h' ~! O; R2 j8 r3 V
#include <linux/gpio.h>. f F$ ~3 y( X3 R0 T; O, X" _
#include <linux/leds.h>
8 ~5 Q, y- s$ k7 B#include <linux/platform_device.h>0 D* w8 {3 k3 u+ b% i6 f, i8 [+ ~
: P' v7 ?% m! }- q
#include <asm/mach-types.h>
4 v7 [* @- i9 h7 r3 ~. M#include <asm/mach/arch.h>
, V9 N8 k4 u2 z#include <mach/da8xx.h>
) M u8 L! x9 `. ]7 ?5 r. O8 S#include <mach/mux.h>
! X3 N' b' r6 B/ L, C
1 t1 n7 k; Z' z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* f j' d9 u8 e4 d! W W8 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% `" T" }( p# B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ u6 k/ b$ t8 H6 Q8 I( e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' U1 r4 t+ y5 b' P! j6 i8 a% o
D: {# E' N9 Y9 s/* assign the tl som board LED-GPIOs*/; O6 J" I7 q/ q6 Z3 Q
static const short da850_evm_tl_user_led_pins[] = {% E; A1 G' I- c. _" ~; G
/* These pins are definition at <mach/mux.h> file */3 R y; f9 i6 w3 K1 t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! _8 ], r1 P* y) V: l1 |& O -1% l" {4 P) C- |* D- i+ S6 \
};8 U$ p* R7 W" C/ }* M) ^' i7 X
( B) t U+ z: L2 l5 t) H7 L5 e/ H& G6 o
static struct gpio_led da850_evm_tl_leds[] = {& R9 u8 F" p# i( B
{& _$ G5 @3 a( v! P# w$ Q
.active_low = 0,6 [& O( J) {; N! l3 V
.gpio = DA850_USER_LED0,5 F6 N' B3 W, ~/ x% Q+ M6 S9 T$ Q
.name = "user_led0",1 p- k0 z. f$ n$ {) p) f' U
.default_trigger = "default-on",
7 G6 H% `5 a& Z( q' q },3 q9 M& I5 R) n4 j" [% I. @ o+ W
{
+ P1 I! W3 B" v/ ` .active_low = 0,
# X3 r1 X. C. G. c4 A" ^ .gpio = DA850_USER_LED1,
: ]$ @% a h1 q0 G E2 t .name = "user_led1",9 C$ u& G3 [; P; y# E) Y# ?0 Z8 C8 n
.default_trigger = "default-on",0 r& N( Y' q i3 E4 `
},% ]1 ?6 c3 A/ s0 p3 a( c
{
; f& H7 _4 X# `4 C3 o .active_low = 0,% h* ~, l) a" _8 T2 ^5 P
.gpio = DA850_USER_LED2,
" Y+ ~3 D6 ]% F/ {2 b0 D: m; W .name = "user_led2",
q! I. Y4 N5 u+ A( u, ~ .default_trigger = "default-on",
9 y- Y. a6 w/ w9 o h) m },1 v& W. v1 F2 d1 q
{
6 m+ V* e5 m. v8 J* G* l .active_low = 0,! K7 c9 |. ^) [7 `) x! x
.gpio = DA850_USER_LED3,% z5 G# f; B, g, f, H
.name = "user_led3",# l6 p4 r: B$ |, j
.default_trigger = "default-on",
. [1 X! p! @7 J' { R5 T },
+ u' e4 s2 E5 G% M% |. {};6 _+ M1 p, s" E" x1 N; w b! g# d/ \
* p" b! {$ I9 g4 K* x% G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% U, J) p) O. X, [5 G, s .leds = da850_evm_tl_leds,
3 Q7 T5 P1 n8 L6 W/ X5 Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) t0 t. W$ k8 O7 y2 ^; g
};
% g2 C$ c8 A! I' y. [" t# s) A2 h; J1 d
static void led_dev_release(struct device *dev)) w" \7 J9 u5 O/ Z0 B$ b* c
{
! ?* v3 m0 [6 K5 H1 D4 E# i};& Q! I; Z/ L2 x8 _/ N! c
. P+ Q; ~- h" f* K( ^ q
static struct platform_device da850_evm_tl_leds_device = {
) ?8 u& G9 Q! s) x2 ? .name = "leds-gpio",; I& ]+ r8 [$ }) L
.id = 1,
: M3 N0 f/ K. h .dev = {
# v# R; Z: P' h# L .platform_data = &da850_evm_tl_leds_pdata,+ O K/ l ~! Y. ?) K
.release = led_dev_release,# T3 i" D$ U$ V
}% \! i* G" A8 D: T+ u0 H; w. Q
};
! X. Q4 p9 ?2 u: O" l9 {, f
! C! V. ?1 m" l. Q' R, Istatic int __init led_platform_init(void)
+ Y% _% i) O C/ _+ i3 W0 S/ a{1 K$ D$ K+ U* z$ S7 G- M0 U6 T
int ret;
3 T% h; x6 _8 H2 _#if 03 p- e' @; E3 S3 S2 [- s# @; _0 d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& e, n. g8 c) T+ k n( s( C$ h' T if (ret)
& }$ y! L6 Q8 D1 Q" m9 r6 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :": f( H* J$ n% Y1 g
"%d\n", ret);
' |# B: N5 D5 o. Q. j#endif( i6 d% I5 q2 a E | m0 u; H
ret = platform_device_register(&da850_evm_tl_leds_device);1 C r$ `( N0 A) ~
if (ret)3 [% u: V J9 w& P/ {
pr_warning("Could not register som GPIO expander LEDS");( J3 N! w5 j6 a: L/ n5 ?$ _; D
else5 ?5 @) I, q' l J( q
printk(KERN_INFO "LED register sucessful!\n");1 Q% _9 i5 c. t/ K( X
1 \8 c9 N( H# L* ~
return ret; Q. A* B7 P8 M! N5 Y0 {
}7 B; }# k \0 ^
) E! @! M( u% ]/ `' f* B `static void __exit led_platform_exit(void)
" T2 H; j: E' e K# d0 F0 ^, [2 r{
* T/ C& Q+ z4 i% Y2 f# [ platform_device_unregister(&da850_evm_tl_leds_device);" W$ p' @/ y3 Y, u. F8 z, W' O
! ?9 \+ T: ]3 j5 X
printk(KERN_INFO "LED unregister!\n");
9 W- H N r7 i7 f( f* G}! K( S# k5 ^6 G. G' `% r
( m- E& \3 }: y9 Z$ R+ R' ] ^module_init(led_platform_init);) B' f8 d& ]0 z6 w* F
module_exit(led_platform_exit);
$ [$ R3 n/ W3 n
: [. F% n2 f) z7 Q tMODULE_DESCRIPTION("Led platform driver");
6 Z0 g1 r" o8 c6 aMODULE_AUTHOR("Tronlong");. K9 M" A: x+ C7 K5 |5 K. Z: [
MODULE_LICENSE("GPL");
" V3 \7 H/ \+ }; S5 d& B& I4 b8 s5 a& a( h( D3 q
|
|