|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# W. \+ j6 l/ U2 y, y, `
#include <linux/init.h>3 F$ j: \; ]3 M& [. q
#include <linux/module.h>
7 E; |! r* n6 N$ j/ u4 W2 j#include <linux/kernel.h># G1 f7 S, U( ?/ s- q, y
#include <linux/types.h>4 u9 j* P2 n, [ u
#include <linux/gpio.h>
9 n/ b& A! d$ N# H A) a#include <linux/leds.h>. e% t9 S* E9 r" o8 n
#include <linux/platform_device.h>& m2 L! c! X- c' w$ `8 A
, r7 A1 g0 I& O3 y$ L7 N: e#include <asm/mach-types.h>6 S2 w: |* f8 S c" j6 j3 p( O
#include <asm/mach/arch.h>3 q& ]% c3 u6 r; W' y
#include <mach/da8xx.h>
# L5 n! W- y* t0 w! K% ?#include <mach/mux.h>
8 ~% s* e3 ?. f: o+ Q/ r$ b4 u7 t# P& B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# F" s% t! o, n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: k e# _, Q; H0 u. ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# k4 A# Z. U- O) i. Z$ E) ^6 K+ T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) B; o& M8 b. y1 M. `; B7 R
+ j1 X) M( V' k) J/ Q# p
/* assign the tl som board LED-GPIOs*/# `9 c# z& p0 c' b
static const short da850_evm_tl_user_led_pins[] = {: Q6 u- ^$ K: S! h4 ] p
/* These pins are definition at <mach/mux.h> file */$ j5 u# p; a0 P8 b# O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) d+ m# u; U3 ?6 l6 a6 u -1
% u" p$ P. r U% @" k$ q}; T& `6 O& n& L) O5 [; w
9 q# v3 I& K. {3 Wstatic struct gpio_led da850_evm_tl_leds[] = {
6 ]$ c" a* l" p4 i& @: ^ {% D! P m5 H# {+ \+ |. B3 m) M$ e7 s3 M# E
.active_low = 0,
# U5 U" T% ]$ x$ {) ] .gpio = DA850_USER_LED0,- n* |5 }% W& k
.name = "user_led0",' `% B# z9 x2 P; l# P
.default_trigger = "default-on",; z/ J* P& y/ h0 b* P3 H+ B/ [+ b
},: O' F, H9 i+ ^& S( @3 X" L4 A
{
: b7 O* t1 e4 ^1 E5 _/ Z .active_low = 0,
1 I* U: V2 Q; l' W .gpio = DA850_USER_LED1,; c% I, a7 U- s x3 u4 D
.name = "user_led1",# U3 F8 |- L, P* H3 [5 B6 S- @2 k
.default_trigger = "default-on"," g+ _# i6 Z. H9 c- i
},
/ X: v& \9 U! q$ b+ c {
" ^/ C" q. r) R5 v5 y .active_low = 0,- b/ a( ~& w) |
.gpio = DA850_USER_LED2,( d, D6 U* B+ R2 i2 K
.name = "user_led2",
' z$ E) F" t( O. P j .default_trigger = "default-on",
$ w% t4 D* B: }! c. y },5 G5 y( |) p. U# Z1 h1 v
{
# i# s5 q* s: Y# q: Q$ R .active_low = 0,
2 i+ j% Q& ~& o+ r; p .gpio = DA850_USER_LED3,
, X+ f* i2 {' D2 t |) y .name = "user_led3",6 E7 q! F% v" d& U
.default_trigger = "default-on",) t' O3 L7 I; w2 P* L! S$ h# Z
},# `8 s$ N4 A: X, s
};
[. u) t4 U9 @1 z7 s | X, N t2 x! J2 f. t; x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 \0 u/ i J& A/ k
.leds = da850_evm_tl_leds,
6 N" c% ~! n$ M, o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( o) X, z& ]5 z7 _
};
4 ?; n' n* @" Q
5 Z( u3 i$ C0 N0 l5 b/ {static void led_dev_release(struct device *dev)* C3 v0 t4 i; W& B1 G. q
{0 c5 |' f0 H) _5 i( @6 a
};
1 V; t) N& f- b4 }% z" [$ T7 K0 A8 l
7 H6 Y- d& R* X( Tstatic struct platform_device da850_evm_tl_leds_device = {- E" B5 ~! Y: p" w) C& U1 `
.name = "leds-gpio",
6 P3 \ ]# C D. v# Q" K .id = 1,
2 k8 n; m% Y1 M5 _! `# h .dev = {
3 @. ?3 u/ u0 a- H( ~. c .platform_data = &da850_evm_tl_leds_pdata,' W5 }+ y3 x% v' K
.release = led_dev_release,- Q _ x1 [! `5 _* T, ^9 _
}
( n( v: l; G' ^0 M% C$ k- l};
# j/ h! D1 q6 }" |* [
/ j6 H9 Q$ ^# a; z6 N7 c) B" A0 Sstatic int __init led_platform_init(void)
5 m4 {# }. W& Q. `& f{0 `5 Q' b4 p- D
int ret; v8 s$ t0 K2 F( C2 t' o5 ^
#if 0
0 x$ e3 o8 v& c ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# R) @3 [; c% q4 K1 Q% {' F
if (ret)( e% c3 G! j7 t T) n/ q# n7 {% f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ [- U' K# N0 L# J
"%d\n", ret); p7 i5 J6 S3 T, L1 B
#endif5 z4 Z3 H# R8 c/ p3 H
ret = platform_device_register(&da850_evm_tl_leds_device);
1 I# H( J$ v1 G5 P8 ]5 r* u if (ret): s# W. F) ^8 W% p& y6 r: j8 s! y
pr_warning("Could not register som GPIO expander LEDS");, T, ]5 L. q, F7 W* V
else3 c- [6 Q5 Z: G' F
printk(KERN_INFO "LED register sucessful!\n");* @) h# x/ @8 u6 y/ [
, g& r) s; {8 Z$ b return ret;0 V+ p% N1 q; _4 ]+ S
}
& v% L* Y4 t4 E! j5 d$ |- F4 e) U: g! h5 k
static void __exit led_platform_exit(void). x; D+ y, z# E
{
' v1 \; |: b7 S6 W# d platform_device_unregister(&da850_evm_tl_leds_device);& k( a3 `& f2 M# z5 O+ ^2 ~
0 ]( S, c- }( M$ w printk(KERN_INFO "LED unregister!\n");$ {) i' {4 Z" ?
}
* \2 D& c6 D( X$ S/ d3 t% p
; J" l4 {6 ^5 g; h8 Z5 Xmodule_init(led_platform_init);
+ D6 W6 _1 M/ \/ Cmodule_exit(led_platform_exit);1 \: b& | r! a1 a( A$ i9 Q+ p
3 }, z( A% Q4 B2 n; [
MODULE_DESCRIPTION("Led platform driver");
9 A3 ~- |- {1 E: AMODULE_AUTHOR("Tronlong");# X, o9 e! e$ ]- u( @1 `- N
MODULE_LICENSE("GPL");
5 T$ e' A6 U& k* L' L( r
; Z1 l/ [0 P) F. o: K$ z# c/ a) n |
|