|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* M, L+ L7 Z5 B- n1 X, s/ M- d
#include <linux/init.h>5 o! Z: K3 R+ J2 N3 ]9 H
#include <linux/module.h>& g- `0 s( I+ n; G
#include <linux/kernel.h>
* K! b$ [$ ^& H5 ^' M' W#include <linux/types.h>
8 Z3 E( r1 I' X( \" ~" l b#include <linux/gpio.h>( ]$ b" q H- ^* B: Y" [- w
#include <linux/leds.h>
( v2 S. a f. b( b% c8 Z#include <linux/platform_device.h>% O& H% R+ E+ X$ n
: W) v, u; Z7 \3 B7 g; D#include <asm/mach-types.h>5 _) E$ s4 G. d% x4 V- y8 h
#include <asm/mach/arch.h>4 _# S4 ~% A7 @2 q: `" W: ^1 ~9 x
#include <mach/da8xx.h>' M( Y8 `$ ^! p5 b6 B. D
#include <mach/mux.h>
h1 ~4 z/ F0 N4 v; z* d7 B! n* W' v3 i% k9 m7 V9 l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- P9 H h9 g6 p( C2 ?" a5 w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 }+ \. K r3 k- w! p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( s! m# ]0 z) W1 O2 g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 h% {4 y* l3 X
/ {# O! F/ i5 x" {" C* O _7 C/* assign the tl som board LED-GPIOs*/) ?) u* U( t/ ~' N0 E% r. `: U
static const short da850_evm_tl_user_led_pins[] = {
9 |1 C8 y2 q a: J; \+ x /* These pins are definition at <mach/mux.h> file */1 q' D2 F* `" {2 T9 ?2 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 F J! c- r# @* |: {8 T+ I( M3 a
-1- t2 A+ Q/ g" O @+ U9 i! P' m
};) _! i0 _% B$ g! Q9 S/ \1 o, y6 P7 w
% e- P2 a. W; v6 e+ u0 B% n
static struct gpio_led da850_evm_tl_leds[] = {
/ a" h. p4 U6 u" T# z; H/ E { N6 c4 V5 z9 x0 ^. m1 U
.active_low = 0,+ E5 s/ ?) S# }7 a u, p
.gpio = DA850_USER_LED0,$ f. g2 l5 a8 m3 Z" d% r R* t' v( v
.name = "user_led0",* Z0 Y+ v* X9 F
.default_trigger = "default-on",
/ K* l2 ^3 V% F% w& Y$ U- _8 e },2 d$ s$ P7 B* |$ T* t
{
1 d/ @7 ]7 u: B* ^ .active_low = 0,
* Q; ?2 K; D8 a# A- m7 c8 N" Q .gpio = DA850_USER_LED1,1 c1 a4 Z2 `4 k0 p. E5 T
.name = "user_led1",
( b0 A8 K, x$ z4 K: h .default_trigger = "default-on",( f# b/ {6 H6 \# ]
},/ i8 F9 n! L) W7 j
{
" W: Z4 v( B( a+ E! ?9 |" S .active_low = 0,
8 `2 R( r5 e( F1 ]+ ^ .gpio = DA850_USER_LED2,
1 R6 _; a1 C2 i .name = "user_led2",! E2 X. f5 b5 C7 V4 f
.default_trigger = "default-on",) R# J' N+ y$ f
},
3 h$ \' e: T3 \ {
1 c& x9 x. r! g .active_low = 0,
& P7 h! a! ?% C( t. _ .gpio = DA850_USER_LED3,9 I0 ^4 t1 H' N/ g0 N. }2 T7 w, F
.name = "user_led3",- v# _+ }6 B, n5 H
.default_trigger = "default-on",
; A) e A+ M. h },
) f7 m4 V; p" a3 ^* M};
) R) ^/ J& t3 ?& i
+ \# Q$ p$ \* a' \* N' n3 f8 F' }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ Z n% B( @% ]* N6 M& `' E0 S8 H
.leds = da850_evm_tl_leds,
. j2 r n2 f0 l9 K6 }8 W' { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* s2 B. p' x4 H$ }' i. \};$ n: [ p/ ^) c) s2 P# G. [) u" j
3 S) c2 y8 t* rstatic void led_dev_release(struct device *dev)3 g U8 K! M- k8 n; Z- t: [( F* q
{) N6 ?& A9 N# z! J
};
( q5 y* o; w% Q* R% h& i* u0 z$ B& }! i7 P% O
static struct platform_device da850_evm_tl_leds_device = {: W" n( n+ P4 p+ e: ]
.name = "leds-gpio",6 }( L6 [1 n1 B% w
.id = 1,3 e- b% w! ]0 I5 |
.dev = {
# p8 E- X. ^/ Z1 f7 o .platform_data = &da850_evm_tl_leds_pdata,
4 x) ?; e1 o1 s$ _: \ .release = led_dev_release,# ^7 S+ \# l% p
}* K( B2 r# G1 X, m2 ~' N: F
};$ s/ c9 t' J+ K
+ l$ c8 K, e6 j+ J, F
static int __init led_platform_init(void)
% @; m; _- q0 ^6 Z( w{
& |: S4 d( N5 Y4 E: f$ d% g" x int ret;
3 b0 d7 c& X+ g0 |7 X#if 0
v& `4 s3 _! V( G& e( g& n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' c [, @5 q" a! ?+ e
if (ret)9 O7 T; K% z$ K7 _$ y# o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- ~9 M$ B- A( Z "%d\n", ret);* G( r9 C. }; l5 l1 M- ?# Z5 L: g
#endif! k _2 A1 V' u( J$ ~4 |
ret = platform_device_register(&da850_evm_tl_leds_device);
1 D& e: R3 y, f& |6 V0 C if (ret)9 q" ~& @7 e$ r1 C8 N
pr_warning("Could not register som GPIO expander LEDS");
2 }/ {! @' g* r. I$ E4 ~- n3 } else
, E7 K. |2 k3 A+ `" C printk(KERN_INFO "LED register sucessful!\n");' Q( Y3 H) S; a5 Z5 t! `- O; O. R
; `" H1 k9 m; j1 g3 V p. D0 f
return ret;
1 o; a" c" [- Z/ v0 S7 V' J! q}
9 p9 |0 }6 n8 D/ g4 R9 y( m& y& m& f
: e# P) L" L& y9 |6 p$ hstatic void __exit led_platform_exit(void)( H* P4 \ w* L/ c% {+ g$ u
{
0 t1 A* e5 i* D5 M. u$ g9 O$ I4 ] platform_device_unregister(&da850_evm_tl_leds_device);
! C6 o; D* m% v7 N8 N5 B) y1 t0 v# d. f x; o( s- V. R) {( }
printk(KERN_INFO "LED unregister!\n");' k, ?, }7 V( j* `% m
}
( ^/ Q! U. q# v
. g8 p: J3 G- W- {module_init(led_platform_init);- L3 R% D3 ?; g
module_exit(led_platform_exit);, `; E% N6 }6 c, p) T
2 Y. E* z/ P/ NMODULE_DESCRIPTION("Led platform driver");
4 j/ o# u. D7 D' [- XMODULE_AUTHOR("Tronlong");$ M9 T! p3 ^3 E0 D) m
MODULE_LICENSE("GPL");: o( d$ H2 A' }( T _2 c4 K
8 }4 e3 z/ B$ b/ C% }8 ? |
|