|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, N& p1 }( G: q' }* p; A) B7 q
#include <linux/init.h>9 D. e0 L' R# e2 g
#include <linux/module.h>. Z3 d. \4 j" B; U! n7 V# ~' ]5 Z
#include <linux/kernel.h>& u9 {! \# w6 a& Q# D
#include <linux/types.h>5 e, E* U2 Z& G+ }3 [- W0 z5 `: M
#include <linux/gpio.h>
* ^7 Y( L1 o5 b, o. }4 V#include <linux/leds.h>
* f; Q- q) q' V: E7 f/ A5 c6 g#include <linux/platform_device.h># c) w1 n; U8 M, {$ ?- F. t9 \2 O4 X
7 ]8 M) u# @. O#include <asm/mach-types.h>" { L }7 t3 s3 b
#include <asm/mach/arch.h>
, ~4 P8 b! Z3 R3 e# M9 G' u5 r. f#include <mach/da8xx.h>; m" X+ z- H5 n
#include <mach/mux.h># d5 H% _. P' e, R
! x- P9 w7 n/ C#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% ?+ z; |) x# c- {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 O" o/ J8 Z4 r2 j0 T8 y+ |. x, q1 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! @( N% L- t! h- d9 R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 ]( `8 _: \" P0 _1 c
0 E+ i" M" H0 y+ X y6 }
/* assign the tl som board LED-GPIOs*/
0 H0 D/ N3 k/ y/ n5 ]3 _static const short da850_evm_tl_user_led_pins[] = {# s. N0 b! q" y9 E: x5 e) ?0 Q" B1 K
/* These pins are definition at <mach/mux.h> file */2 c: p* j4 ]& Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% m: e$ `: G. u. D+ ^% w -1
7 W7 e5 X+ {) k7 }* D# @};
7 L3 V" H, `+ t% v# S, t* e, M9 A! c
static struct gpio_led da850_evm_tl_leds[] = {
, E$ Q4 w9 Y2 U# o$ y" a% u, u {
: i0 {' _' h) f .active_low = 0,! z2 z9 N! K2 p& G# s- h
.gpio = DA850_USER_LED0,
9 G; u2 {! g1 e, [* l+ s7 v .name = "user_led0",
k, r7 v0 h; J .default_trigger = "default-on",* d" ?: }. ]$ O% F& l3 Z+ m* i
},8 n# @& l1 @6 S& p8 T) W! j. F* E
{
6 G; Y6 A& e0 E .active_low = 0,3 S! j" B$ M Q/ M, c& j3 W
.gpio = DA850_USER_LED1,
* ]8 y5 l! r' D5 ]! \3 h .name = "user_led1",
$ q- r* L2 _! u/ T' j& @ .default_trigger = "default-on",* ]- G8 H7 L2 x9 p* E# x$ T0 s+ d
},! ?0 ]- b1 q- w/ g" A6 r! A2 a
{
4 F9 r% u: p; g9 j .active_low = 0,( i8 M4 c& ?& d! m, V4 _' v9 {
.gpio = DA850_USER_LED2, _+ | F i5 V) Q% V5 [- A8 Z
.name = "user_led2",# h2 {1 J( [1 l; i% I) T! U7 `
.default_trigger = "default-on",
# h8 |; F3 P5 H A- }: v' O },5 l# m N3 B# E1 `# m
{
: u; Q v+ J, T E' f .active_low = 0,) l I2 K3 L$ L- R0 x
.gpio = DA850_USER_LED3,
) i" C1 h- F7 L; t+ l, l/ c; M# Z .name = "user_led3",
6 p" j& x3 B M% ` .default_trigger = "default-on",
3 w" u5 [6 p# d2 ?) A# Z' E0 ~ }," y* J0 |# n( {9 n1 R1 i, s
};% U; f" s7 E5 Q+ K
; L$ b2 {' Y; m% R' {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 Z2 }! n$ I" [. Z% v7 B+ M# \ .leds = da850_evm_tl_leds,
; N% |& t: O( T Z# y, G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 n( s' u0 P8 p
};
8 L: a. c( G3 Q0 N0 x- P8 w: f5 ^( A r2 x+ S- Q7 g; o% g
static void led_dev_release(struct device *dev)7 X1 W( y! a+ w1 A& ^2 X# z& K& O
{
& E! W; d9 F! |6 d: _6 L1 F};& _* V. ? [6 l' z5 N/ P% D
2 w- R, V' ` v* e0 t! M
static struct platform_device da850_evm_tl_leds_device = {1 B0 i+ S# a( {) G3 ]
.name = "leds-gpio",
7 H8 m% E) D, j) p' g; k. L .id = 1,
* l% f% n" z6 w" r- R0 S .dev = {) M9 f$ s- c$ ]) J/ e* \
.platform_data = &da850_evm_tl_leds_pdata,
7 R9 c% w8 I0 p, O( T `5 [2 F/ m .release = led_dev_release,0 V- T2 q8 [. C! T' t8 W0 w, V+ N
}
9 p6 `0 \) |/ _+ ?2 G5 t# K};) |/ G1 Q4 e# S& \
* Q: \: `% c' k T/ b9 vstatic int __init led_platform_init(void)9 E" l: S7 }+ e/ G
{4 t' q( {$ `9 ?# ]7 N7 f1 O; b
int ret;
1 V) N$ W8 m! X#if 0* J% |' B0 S0 l; M- D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" x. C6 y$ F% q0 k( f6 C# T$ a if (ret)
3 x* S5 g) Q+ `# z" ~6 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :". O3 y& K% C5 }
"%d\n", ret);
* H7 B, a }1 H#endif6 A4 L; F6 {/ w7 l* i" x& ^% p0 Q" @
ret = platform_device_register(&da850_evm_tl_leds_device); l9 s. J! i ^- C& v4 r, q7 y
if (ret)
& }# C( j+ `/ D5 Y7 a pr_warning("Could not register som GPIO expander LEDS");
4 D9 C4 {1 G' X4 U! f% N$ i2 P' E else6 t3 ?/ G9 j% N* L+ S
printk(KERN_INFO "LED register sucessful!\n");
! y- z/ N4 s$ J! B1 _- I* Z% k" u t& y! D+ d
return ret;3 f$ i4 M2 x* ?, k% D/ i
}
9 V3 S0 n9 o/ t0 i9 h' D5 {- M- \ y1 E, ~) W. @$ [. b
static void __exit led_platform_exit(void)% R U( J! a* n5 a0 I
{
8 `# ]! p; K/ p/ v n" ]6 B4 P8 |! ] platform_device_unregister(&da850_evm_tl_leds_device);7 f0 j$ J) s- q# T5 j9 r h, b
( l. u& T# n7 I' x! _ printk(KERN_INFO "LED unregister!\n");
) n0 g* R; _( q+ {7 L* j& |" X}" f) h! D0 A L7 m. u
5 V d. V }. d( h# `4 Y
module_init(led_platform_init);+ A8 `5 K: B# _
module_exit(led_platform_exit);
- u/ o5 |4 f7 X: N
/ y" [9 ]7 @9 T$ R: CMODULE_DESCRIPTION("Led platform driver");
& v+ N& w# D1 n$ Z: @0 cMODULE_AUTHOR("Tronlong");
8 v+ F5 b* \% ~1 n) bMODULE_LICENSE("GPL");
. o8 I, W! ?4 G) k" _& O- [: |; m; }$ l4 k/ a
|
|