|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& }6 w8 F* J: ?/ I#include <linux/init.h>2 k# m4 ^- l5 q3 F: s
#include <linux/module.h>
" H+ L8 S2 e* a- p3 L G9 _#include <linux/kernel.h>, @$ }% O7 Z( D
#include <linux/types.h>7 j, @3 b L6 o/ p7 C
#include <linux/gpio.h>4 v/ e8 I2 w. y+ t; ^
#include <linux/leds.h>7 }' F" C* d, C
#include <linux/platform_device.h>$ d$ t/ g; U- c
2 e l% u U2 R) ~9 ?#include <asm/mach-types.h>+ }6 ~- p4 v* r, k
#include <asm/mach/arch.h>
* K4 |% f! f9 d9 `! [6 x#include <mach/da8xx.h>4 q6 L* U) C5 D. C( c8 R
#include <mach/mux.h>
# c! m, d1 F% f/ N' t( ]5 {% q+ K$ g; X4 d7 @5 k3 ]) E9 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# @0 V/ i; |- O |8 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ o- K1 i4 G2 X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 s+ T9 ]$ j5 X+ P* V) B! v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): ~, `+ y: k- Q5 L" N
' g' A$ {7 v! l( m8 v
/* assign the tl som board LED-GPIOs*/
: v* p, |+ a/ V8 L' ^. o& P, h- estatic const short da850_evm_tl_user_led_pins[] = {
: ?6 ?+ \! x* V6 g4 Z /* These pins are definition at <mach/mux.h> file */# O6 |7 l3 Q' @0 E$ }, g+ X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ `! X( r1 b* l5 o. ~
-1, n7 Y0 G- P& C5 e( r1 ~
};# P" H! m" K G1 n3 @
. x) u1 O( {. Y
static struct gpio_led da850_evm_tl_leds[] = {
- \/ }# B& i* D' o. P8 Q3 y0 G* _ {) o9 l' q6 E! c+ @
.active_low = 0,
7 e8 `1 |; v, _+ n0 B5 o& U .gpio = DA850_USER_LED0,2 v; z0 N1 _- A+ J( j1 J
.name = "user_led0",& ]/ l, y; ]0 W0 j
.default_trigger = "default-on",
6 G7 b$ B8 `- n& `0 `/ P! r },9 Y9 e0 [) y9 I0 @ J
{& `1 D2 b( @& _, o8 G4 W% b: w
.active_low = 0,& ?8 r) w: t6 |: y) z$ g9 e4 |& T* `
.gpio = DA850_USER_LED1,
7 W6 ~& r2 Y; R. N .name = "user_led1",5 q0 D2 i1 B+ k
.default_trigger = "default-on",
. p# _ p4 o+ y7 M% `/ u! _ },
) J$ m& c- R' N3 N/ R0 s) N {0 T. e1 Z& o" c2 G/ V5 t' {
.active_low = 0,- S W B+ S! _
.gpio = DA850_USER_LED2,/ w% P/ l2 K: I. _3 S
.name = "user_led2", l& h9 O( X% V8 [+ T0 J M
.default_trigger = "default-on",- x; |2 H L& u
},
' U- f! e! j. k) c' {& i {
$ o* ]. o9 e& _$ O4 ?4 t .active_low = 0,
" p3 [5 I5 S4 p* Y& C .gpio = DA850_USER_LED3,) H" g9 y* p) a; I. _2 @0 P. X
.name = "user_led3",
: c- R8 T- q: N0 m; D .default_trigger = "default-on",/ _9 U) ~# H2 x2 T, G5 r0 V/ _
},
2 G5 M( h6 {$ S0 v! _};
" B' Y6 {+ I0 W$ @4 m6 V' P% ? g: L# C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. i* ], h; i, @4 S( ]) o J .leds = da850_evm_tl_leds,
* U. k5 z) w8 d0 {0 F$ N- K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 a* i) i2 }5 F% Y% T$ o5 P# C* |};% Q% I" c8 m- a/ R; l$ t
$ h- m7 j! }6 E! l
static void led_dev_release(struct device *dev)
& F& S6 t9 a( a5 } J{
S3 |/ N( M1 h- ?- u/ d};$ l' y% @5 g$ `0 E' d: K
. _: d. O3 G8 v& x3 i! L3 C
static struct platform_device da850_evm_tl_leds_device = {9 V: f9 F5 o$ w) G' s+ B
.name = "leds-gpio",
: p; H9 [) L0 C$ Q .id = 1,
! ]$ M+ S, z6 \( `) L .dev = {4 a/ S9 o$ \/ j4 @2 \
.platform_data = &da850_evm_tl_leds_pdata,
& F% z$ _! j+ O# R9 W$ K5 p- N# r .release = led_dev_release,
! w6 m2 v7 D; b( E' h% K }3 ~+ x" L1 g- L
};
0 E( a6 w. a( E+ E; u
3 i3 R4 r! U& l4 Qstatic int __init led_platform_init(void)
# i2 b }' I% v M) {{" d7 \6 q# e1 Y/ Q7 m2 Y. L5 x" d
int ret;: F; q6 _8 f* Q1 I+ J6 C( w
#if 0
. G. o! G! Z# k1 W( P- r, [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- I- e/ N7 j- x! H0 s: n if (ret)# L H R* y% K/ q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" X4 d+ g4 Z: k, t- a
"%d\n", ret);
# u2 W- E& b7 X% D3 w: i3 \0 s! X. ]; M#endif
+ s0 z" a1 A4 j* K! P ret = platform_device_register(&da850_evm_tl_leds_device);
4 b% }% u2 q, V if (ret)
8 ^/ B# w( `1 h pr_warning("Could not register som GPIO expander LEDS");2 t/ v. L* b( S8 Y# f* e! |# D. P
else9 I- b2 y% o) A5 Y
printk(KERN_INFO "LED register sucessful!\n");& F+ w) N/ G* Z; n2 n$ Q8 k8 f$ ?, _
9 M5 ~: w; J2 t- R# A return ret;
) }, d' `$ K4 F3 w8 f}
& c# m& `5 F. p' U1 O# _" ~6 j# `; E ?- [
static void __exit led_platform_exit(void)' u! R# v( F1 b# s/ w
{
+ q/ e Y3 s3 B. O3 N+ q platform_device_unregister(&da850_evm_tl_leds_device);# w t$ Z4 w* [( g" C3 b) X
7 B5 f& H2 j$ {
printk(KERN_INFO "LED unregister!\n");
' l1 ]7 k( d7 H3 W}
; P3 ~! B( g( V4 O+ [6 ]0 m( z! p, j' y; V% }+ @
module_init(led_platform_init);/ n+ j! r0 W9 b" w/ t& @
module_exit(led_platform_exit);
6 O( [6 W) U9 _4 F! Y4 [: Q8 |- H( Y- u
MODULE_DESCRIPTION("Led platform driver");
# j! c3 ?- Q' c' OMODULE_AUTHOR("Tronlong");& [ J5 x9 k: z$ Q" W
MODULE_LICENSE("GPL");
1 |# @! H0 y+ O6 i
% I% l0 d% E+ U% y I( I |
|