|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 |) y0 q6 i5 G- j7 C7 k/ |
#include <linux/init.h>0 J R( M: T2 w3 S3 e" F9 U
#include <linux/module.h>
* z O0 z1 w: O `- T) y- O; K#include <linux/kernel.h> m$ f7 `( F( D$ l: E. Z
#include <linux/types.h>
* I" a5 w: Z% ~+ S U#include <linux/gpio.h>
: m+ g6 {( ?+ }& b% M6 w1 @#include <linux/leds.h>$ m0 a# |4 B, ]% q5 B7 F
#include <linux/platform_device.h>
: s+ t; D7 ~0 Z9 c, L# S( {4 N y% r& u3 B" Z+ F5 ~
#include <asm/mach-types.h>5 B4 ?$ E% @2 s$ a
#include <asm/mach/arch.h>
1 [" W! E6 d) X! n% ?) r#include <mach/da8xx.h>
" s( t9 g3 r1 {/ V N1 f#include <mach/mux.h>
$ T0 z, @! l z
1 `8 V$ ~; G5 L- V; x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ P! Y# c' s/ h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 b& T9 M( G m% S( }6 Y1 t# }, d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 ~: j3 b: N0 v( l6 z* |: P, G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
J' J* p" D0 @5 S0 b1 K6 W6 w1 r0 {( Y4 F/ J7 a$ q
/* assign the tl som board LED-GPIOs*/! r4 u% c1 K1 o
static const short da850_evm_tl_user_led_pins[] = {, c6 h9 W$ J0 D+ K# j
/* These pins are definition at <mach/mux.h> file */& q% X9 ~ N$ b( H0 A' p" _; A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 X$ G6 c" o3 D7 H -1
. b$ `5 |: P3 i1 s* l9 F};
: T/ D5 N3 l i$ ]& |9 W1 Q% u" B1 l, m
static struct gpio_led da850_evm_tl_leds[] = {
: N/ A5 B! u9 ]) | {( r; d8 w% `. G' b1 j) \
.active_low = 0,
: |+ {* m; c y! K6 O8 d' o .gpio = DA850_USER_LED0,
* F- |% [: ?/ y1 ?) h .name = "user_led0",7 T0 x! s# |$ [! a* H, A
.default_trigger = "default-on",
; \2 R2 r1 j+ d1 `# K },1 {9 J# p& G! g; l: M" U' h- v3 l
{6 X2 M7 h" {4 j0 {! x, ^: M f0 y
.active_low = 0,
9 V: V, V0 ~& I0 F, } .gpio = DA850_USER_LED1,; v) [, T) }) ?6 y* b1 T( y V( ?
.name = "user_led1",( _* }% y7 I* I) l( e
.default_trigger = "default-on",
8 q& W; R9 [; u1 f5 g. o },: V; y; D0 L, Q" F; o u
{
8 F& P' Q* X) u+ X5 p3 [ .active_low = 0,
4 H _* @+ }/ g/ Q* T' l3 ~2 n0 Y$ { .gpio = DA850_USER_LED2,4 G, l8 b& C h
.name = "user_led2",
K5 T; b" Z8 d. K .default_trigger = "default-on",
5 S9 M/ B8 q- x; N9 S },4 [9 Q4 y+ z" H/ l& S7 d: ~
{4 N3 o% e2 F- C; s
.active_low = 0,
: S, e9 y1 ~+ {4 ] .gpio = DA850_USER_LED3,! j/ x7 j: k/ {5 I$ A
.name = "user_led3",5 w! O. y: k V8 g
.default_trigger = "default-on",
/ a: P% U# K; S- f% Z0 B7 L },
; n) Y5 A$ m T/ H! B};
; W" L8 W& z3 \0 j2 _
8 j7 G1 K- R( k8 \+ o# mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: C" A$ c/ S$ p% {
.leds = da850_evm_tl_leds,
; p+ `& i# l$ u+ V- m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% ~; L0 J- n, K& K0 `! L7 Z( }};* J+ V8 Q4 k, c) V7 Y: g' z
9 x3 I: b8 F, n+ K! cstatic void led_dev_release(struct device *dev)
e9 w- H1 I2 M+ N! r% |{
: d* k9 B3 T8 ~* @& h# z' f* ?9 r};. W, i1 S' c- z7 n5 m# i' [0 b6 k
6 e# L/ M1 t7 B! e" Y( Fstatic struct platform_device da850_evm_tl_leds_device = {/ R$ W. b( d; T- T
.name = "leds-gpio",
' d2 p% Z& [8 l$ E t2 {, p .id = 1,
$ X( J. q5 V! g4 }) @7 o .dev = {) m+ _% b& l+ t. Q
.platform_data = &da850_evm_tl_leds_pdata,! y, O* I i) z- o. A
.release = led_dev_release,
8 |1 ]( \9 l7 S' J }
+ T- t9 ]! v3 Q/ E7 i X# N' q7 [+ @};5 ]1 l& B7 b5 {5 C# Z' E$ u n' m# Z
! x& ^9 j' q. Istatic int __init led_platform_init(void); \* y- t9 R) t% t6 C& s7 U5 g: h
{
8 n) i' ? G! r. Q, ^" g% A6 B int ret;
7 v `3 Y8 N! e+ o* \. U#if 0
4 Z7 G5 L& l# T) c/ i( q9 Z* w2 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! w$ z) t/ Q* j, o) D+ ~ if (ret)+ S9 T7 E4 |$ e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& { P- v5 p% U) k/ G
"%d\n", ret);
0 ?& a$ a+ P, S w+ ?" B, G4 M#endif
) N# |. \+ j6 K" j ret = platform_device_register(&da850_evm_tl_leds_device);
! A8 X% f* l0 x/ o& y3 j; ? if (ret)6 {" G6 Z# o2 E. U3 d! R" X- P8 I
pr_warning("Could not register som GPIO expander LEDS");
9 N2 G5 _' X3 S/ q* h# G else
0 N. J) B1 |/ g$ U' _0 a7 a8 ~ printk(KERN_INFO "LED register sucessful!\n");0 Y2 p# `9 |+ ]: L/ Y! z
8 b9 r) ]5 g' n" [0 [- o4 K return ret;
% X* r; f9 X% B- H% n8 O) {/ }}
& X% o) E' l c% E$ f q) F
; w& B" }+ O [$ w7 |7 a, P; e6 Gstatic void __exit led_platform_exit(void)) R: E. W- P9 L# l7 E$ v' k0 v
{
! O8 B2 s: {! M6 m- `6 L5 q platform_device_unregister(&da850_evm_tl_leds_device);
; g( C; E# f, G u
- n1 W! R% W5 M9 X! v: k printk(KERN_INFO "LED unregister!\n");, l* i2 A# {. a; n; S
}
1 w/ X7 m* k" N* q* [) M: h7 d8 W8 W+ n- F( b
module_init(led_platform_init);, F8 u: l; g4 z8 j/ @
module_exit(led_platform_exit);
/ t/ a% ~% Y0 ]+ S$ @! }1 e9 A j/ V! d7 S' [- B1 I4 ?4 m
MODULE_DESCRIPTION("Led platform driver");
, B' m8 w: Z8 l; J3 f8 kMODULE_AUTHOR("Tronlong");/ L* l h3 G4 k$ L/ R! _
MODULE_LICENSE("GPL");; F, W% c2 }1 n/ e$ R. ]
8 C& z$ [# U- z# p, N( _* L+ Q |
|