|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. }) Z2 p$ P- z. O$ \+ U! c' q. S* k#include <linux/init.h>5 V T2 H9 H6 J
#include <linux/module.h>
i: t3 p$ c# r& B$ e$ r#include <linux/kernel.h>
& ]( a6 o5 ?# j2 E# ?- w5 X#include <linux/types.h>
# R* z# E' {% H; z& j6 M#include <linux/gpio.h>6 g3 m7 c! Q9 E4 O4 p- D- \
#include <linux/leds.h>
0 @1 x; A, D& C#include <linux/platform_device.h>
. E \- o! O/ Y0 w& z" [0 n: _/ b2 e- @" I
#include <asm/mach-types.h>
( \2 T+ c, q" [1 N1 O+ ?1 b$ C#include <asm/mach/arch.h>; h+ A4 J7 f4 M2 @1 \
#include <mach/da8xx.h>: c- I X2 r6 w+ V+ j) K: ]! q
#include <mach/mux.h>% p, ], r) y& h! U
; J) a, [3 W- C/ D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 Y$ X0 H/ q: n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' R7 g9 A- j# _9 n; Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). E. }2 c' j& A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 E% O, D7 l# }. W
& Q4 w, \6 r5 M/* assign the tl som board LED-GPIOs*/
% M- Z9 U, y6 e8 D" }. Pstatic const short da850_evm_tl_user_led_pins[] = {
$ ~( s8 g+ f- K6 T* {; C0 Z& A+ v /* These pins are definition at <mach/mux.h> file */
* S0 g* [3 ` ^$ m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# E6 K, d. M) h4 K -1
8 l1 i& W3 x% m+ q$ J k: n};" t8 w6 q- K% H, K3 D
9 a4 Q# c$ y: B6 I7 `
static struct gpio_led da850_evm_tl_leds[] = {) |, Z9 N( w$ Y1 u+ m( C" I
{& T1 {8 h% S1 U; M
.active_low = 0,- s4 M( V9 t. C
.gpio = DA850_USER_LED0,, B5 Q( U! U9 Y$ J( X: x2 H
.name = "user_led0",! w" c7 Z6 y1 z7 N, K; r
.default_trigger = "default-on",. [1 h2 O1 @* I3 v
},' z. z. f" T5 N- I! F0 c) u$ l0 W
{
! e; T4 F* j4 K! I* H$ _0 I% ? .active_low = 0,
1 ] [) [: z$ y, R .gpio = DA850_USER_LED1,
2 ?$ t" k6 b7 J( F$ @( V .name = "user_led1",
, u' Q, H, _9 }/ k .default_trigger = "default-on",
1 J- Q r. u7 m5 V0 [ },0 D0 L4 }" X* A. E
{% @ t* n. w9 D. N2 V( `, ?
.active_low = 0,2 }. j6 H& _0 z8 m! I4 R" q
.gpio = DA850_USER_LED2,% }% c) g1 `6 M$ F, f+ m
.name = "user_led2",* p- S# \. V- [/ a
.default_trigger = "default-on",& p# I( ^! v3 ~9 \ e4 g
},' @# i' o* o _7 h
{
9 [* o: F" u$ p( j' H) Y, Z# p; v1 B .active_low = 0,, K) T) P; q9 k5 J4 L7 Z: f
.gpio = DA850_USER_LED3,9 {/ j2 F5 M7 }& A) O
.name = "user_led3",6 \& M3 W6 ~7 }: a s- k# R
.default_trigger = "default-on",: c8 d4 \0 d* g, B) Q
},
, }, F6 I& X4 h8 `' u- {};
8 A) U0 u, B" }6 a, ?- X- U( J1 ?
4 m1 s9 X) Z( n7 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 ]. F7 U9 C* i
.leds = da850_evm_tl_leds,5 C8 ^% `0 t3 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, e# a' P/ \; f1 O- V};1 h; X$ O. q- F. Y. [0 e
9 n6 d% o1 l* ?- Q, e" z
static void led_dev_release(struct device *dev)1 w8 f. K( s+ r9 j. H4 x" h
{
3 X+ W; s6 n& L8 L5 \. D' e1 s};
/ K) F$ w% N3 }, b0 P
; `2 {5 V8 `; H {2 kstatic struct platform_device da850_evm_tl_leds_device = {4 {8 z3 H0 X- {# F
.name = "leds-gpio",
! X* l* i6 S. ?( ]5 k4 I+ w: F .id = 1,
0 h g& K- A0 c6 i" m5 T7 e: h6 ^ .dev = {" d& v# l- l( Z% P
.platform_data = &da850_evm_tl_leds_pdata,# x/ j G6 T& `
.release = led_dev_release,
5 V$ @2 m% @9 J" N7 C: h! ` }) t& F& {5 F2 |- x) u8 S6 {# ^
};
! a( s4 [" G0 j! {- j3 c; p3 F) |+ l" s: P6 a; L
static int __init led_platform_init(void) G3 L2 C+ d* h2 C$ ^: [9 g
{
# R( z2 g8 ?8 K+ h8 v9 D int ret;8 f- i E, K8 R. _& x9 N% d. R, h2 y
#if 0) u0 h: y3 I7 Z% ?; g2 }- X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' B# @, c6 Q7 n) @ if (ret)5 m+ t+ q. v" d3 k* C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ s5 K- S1 a. I |2 | "%d\n", ret);. R5 P# W! c W/ H0 N
#endif9 U5 c% @8 [( Q5 H# ~
ret = platform_device_register(&da850_evm_tl_leds_device);
4 D. f2 a& L* q/ S6 w if (ret)
& H/ G. G1 e' S0 D% i d! z pr_warning("Could not register som GPIO expander LEDS");- j$ z3 M+ X" ~- X8 O- z! W. v
else
) x9 q# y7 t# z8 o* a printk(KERN_INFO "LED register sucessful!\n");
[6 P' q4 V2 f) {7 `( g+ `6 ]9 B. e
return ret;: w, a; R" E+ O$ V
}( P( _# Z: W: L9 `. F+ \0 h
, w" R" N& x" M* g/ G# {
static void __exit led_platform_exit(void)* J2 ?( m d1 e& N- f& b
{/ b6 C3 t/ F4 R. E
platform_device_unregister(&da850_evm_tl_leds_device);
) f; n; x6 o7 A
4 T! {. g1 X; V [7 \' r printk(KERN_INFO "LED unregister!\n");* z, W5 @3 I6 }( l
}
5 s" O! B7 t' {; [1 J3 t( l
' g X3 H4 O1 A1 Y9 W3 V" K6 Omodule_init(led_platform_init);
$ E- C1 q% s6 j+ a7 }# mmodule_exit(led_platform_exit);
7 Q1 ?1 E" W [" c0 V2 ]: P( W/ I
: Z( I2 K) L/ \+ d6 dMODULE_DESCRIPTION("Led platform driver");
" S# Y4 H `3 R5 @, oMODULE_AUTHOR("Tronlong");
6 w$ Z- C7 Z* I9 x% V7 dMODULE_LICENSE("GPL");
8 Z- [* }' @' i, ]2 h
! }- N; h: N( @, Z P |
|