|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% W9 j i a$ _1 O: P# s#include <linux/init.h>
3 A0 D9 H5 Q( [1 Q" c' s( ~#include <linux/module.h>/ Q! a$ D: z: ~3 s$ n
#include <linux/kernel.h>
! [& ?; S" H7 C8 h/ m8 A0 U#include <linux/types.h>
) j/ d. E+ o* s. J5 _#include <linux/gpio.h>
& d& o3 m" R d; P& ]6 \#include <linux/leds.h>
% W" v! z! J. _0 ^* r& u#include <linux/platform_device.h>/ w2 K; S/ K) N9 E( a
2 L7 M. C' @2 t3 \8 {5 ?: D4 l#include <asm/mach-types.h>
8 I. Z& h3 {8 H9 Y1 Q#include <asm/mach/arch.h>' J. f; q/ V; f6 a3 `" C: X
#include <mach/da8xx.h>) b8 W, s* r8 P' N& {2 N! T
#include <mach/mux.h>
4 T9 W7 p, ]/ j8 A6 W" S: \& V/ @/ U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% ^- k3 O4 ]2 A5 O+ R& ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) m4 W1 I$ M, Q+ O. D& |7 a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ ^* G7 |: ^- j. u) g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 y' j) t' F4 @' B; }5 S+ l0 K" V7 Q* u+ `
/* assign the tl som board LED-GPIOs*/
/ p$ n/ U6 @+ | V9 `3 K: ?5 gstatic const short da850_evm_tl_user_led_pins[] = {" x! {$ b9 D9 n+ f$ K: v
/* These pins are definition at <mach/mux.h> file */
# k |- Y6 l& K, h6 Q& ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 }6 Y* N4 Z& _- K6 Y) K' e1 \ -1
! `, J! B( Y- |' |: ~};
, _. Z# o! k( E0 i8 |
8 |& ^" x/ y1 K8 R& Z$ N# ]- vstatic struct gpio_led da850_evm_tl_leds[] = {5 h) }! R2 r/ o( F7 q [
{
5 Q n j: R. G1 }- z .active_low = 0,6 d% ^/ F; V+ c1 f% m+ g
.gpio = DA850_USER_LED0,
9 v0 n8 \" X! Q$ h1 I .name = "user_led0",8 ^" p- A* Q, f2 I+ S
.default_trigger = "default-on",
) x, V. r- E) @* o2 M! \ },
+ a* J2 R+ n" ~0 B9 ]; Q {7 P' j9 @; n" t5 ^, r
.active_low = 0,
* @4 i+ j7 F0 J7 W$ e .gpio = DA850_USER_LED1,
/ d3 I' r0 u* Z" G$ b0 E+ [, V .name = "user_led1",
, \4 p% |0 S6 Q! h .default_trigger = "default-on",; q* ~3 N3 B' L- l# q
},
$ m6 _7 P8 o! Y {$ d& L7 c: d# w' _8 |% S
.active_low = 0,
9 W; c' J7 q6 T# \2 G3 J .gpio = DA850_USER_LED2,
# L) l- s1 f3 H3 d! O* J .name = "user_led2",2 n7 d3 q2 I. O6 c
.default_trigger = "default-on",
6 O6 e9 a7 c0 U$ K) R# X },4 c. V2 `" k. V" |4 E
{, p. {4 R6 t5 t P- x0 |
.active_low = 0,' h$ s) F4 _. f% z1 ~
.gpio = DA850_USER_LED3,
/ m- `2 T G8 R# z8 A z .name = "user_led3",' s( u1 b& T% I
.default_trigger = "default-on",
/ s9 l3 O: x9 x5 L) | },
1 K: f* _2 Y& }$ {, }0 h: ~# Z};9 r2 k2 \4 F n
- t3 P8 d& e& M" I) k; H- C& \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* C7 J( j f& W* N0 m& t5 D .leds = da850_evm_tl_leds,
) o% g/ X3 f6 C" R, t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. s6 L1 f# T1 s- J# D3 H+ E( P% j};
9 X3 s8 e3 v! `
$ s" T4 b5 [ L8 ^+ Y1 V, hstatic void led_dev_release(struct device *dev)$ L- X/ H/ }& p: K" S9 o W& Q
{
) Y' {/ |+ s# u P' N};0 h9 W( f9 g+ I1 X" o
0 o* e- A3 Z2 \6 Hstatic struct platform_device da850_evm_tl_leds_device = {
* A' S( i, X% _: o" e* r: `! O .name = "leds-gpio",
8 K4 a6 g+ H( Y: s2 p- ` .id = 1,8 g7 o% a a5 N! D ]
.dev = {7 U) Z6 c6 J6 o- k) x) z4 j' Y
.platform_data = &da850_evm_tl_leds_pdata," u) X4 X( K3 j7 o
.release = led_dev_release,
# a# r; X E: n }
( b4 }8 y1 ]6 }4 w: A0 V" j};: [( e) w' o& b, S, U7 P
( D7 g2 f) o4 I i! c% m% ~
static int __init led_platform_init(void)- r7 V' J& m# @' v
{
1 G1 W5 T: r: L( V$ h- o int ret;5 c O5 z6 U# Z& o) k6 }
#if 0: l: @: \& k, P5 P" p4 d. F" [: S5 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 Y0 j0 k+ [8 v1 L. R7 s ^" p& v9 e, Q
if (ret)1 y( v# X* s) Q& l Z- i3 D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 L4 c& m3 c. L0 c9 d" l "%d\n", ret);
: H7 u) F9 P( _#endif
' }9 h* \1 |( L5 H) y! K: [ i ret = platform_device_register(&da850_evm_tl_leds_device);' _: G f( X( l8 e V" k+ }
if (ret)
, N9 A7 N) g2 a7 r" ~( ]! K pr_warning("Could not register som GPIO expander LEDS");
* }' _8 _+ x2 l7 n else& D: m* Z% Z1 _6 c+ T
printk(KERN_INFO "LED register sucessful!\n");1 I& D: E+ u& @% C6 p$ _- u8 J
% u# h2 ]8 B+ L, Q5 d' a9 o" [
return ret;
( ^1 j' u# ^5 \6 a0 j- a# Y" P2 ^ H}
( `- T: }( }9 w$ P. b; @/ \" L6 H( [$ Z9 L% T
static void __exit led_platform_exit(void)
g/ V: K) p3 K3 @& Q0 x( Y+ c{0 y+ c' {) V* ~- D
platform_device_unregister(&da850_evm_tl_leds_device);- Y! }9 H6 w6 W) ^, a: b9 r
/ t; x! t0 M; r- S0 g4 p2 Y
printk(KERN_INFO "LED unregister!\n");
8 j, |4 X! |- v. g$ }}
3 u5 i5 X, i% [- k' `! x- C
: i, W" t9 |' c! M( g! Qmodule_init(led_platform_init);6 q* f2 F1 V" b
module_exit(led_platform_exit);
8 f8 I5 ^# {- \- E1 H* b
- g& K: H1 J( J# T" |5 jMODULE_DESCRIPTION("Led platform driver");
+ `& @3 u3 W: B7 f4 LMODULE_AUTHOR("Tronlong");+ i2 ?6 J& i( ~: d# Z# w. ^
MODULE_LICENSE("GPL");2 o) o$ l5 ^" G
) W, P& _+ ?( o |
|