|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 `( ?. C$ L0 D$ y; l" ]0 A#include <linux/init.h>& P+ I5 g8 ^& S$ _4 q
#include <linux/module.h>% b+ b0 \7 w9 x/ Q5 V0 T( ^
#include <linux/kernel.h>
: l5 W& ?5 S# `% r) B( n#include <linux/types.h>
) M' {/ k, ^6 r#include <linux/gpio.h>/ C9 ^0 b# q5 ], A9 @7 |) `1 t' F
#include <linux/leds.h>
7 E) V9 t4 M, z8 L#include <linux/platform_device.h>
/ {# J2 g9 {/ y( B# q, b) v9 q. C3 F4 s9 `+ V' b/ O
#include <asm/mach-types.h>+ x3 _& n; a0 y; ~
#include <asm/mach/arch.h>8 M! P4 l8 A" T" }4 k
#include <mach/da8xx.h>4 }; w; W7 O* U$ @
#include <mach/mux.h>0 @1 I D4 a6 x% ~
. @4 }+ h' y/ e! W* _. @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. d0 D7 R- r5 ]9 @ ^5 W* s% f# V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" ^6 a. [4 e6 T4 d# Y6 b9 G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: K9 s( k! N- N! I. h. \; }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 x% C) d* ~# `, n7 a4 n- R
: a& [) f% x. p( y+ c4 r
/* assign the tl som board LED-GPIOs*/- A( C$ M% C. R- A
static const short da850_evm_tl_user_led_pins[] = {' M- P0 ]& \& T- ~
/* These pins are definition at <mach/mux.h> file */
) L: ] e3 y+ ]' |( p* T0 z0 i+ E) ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," i9 L+ Q2 M3 o3 N
-12 }$ V8 o8 Z- R$ Y! P- a }
};
# F- z! p+ Z1 J, P' N! d" c
7 q0 ^) d* u$ e7 ?2 Z" Fstatic struct gpio_led da850_evm_tl_leds[] = {' o/ T, ?# ?6 ~2 j. H% _0 J! b8 \
{
% }3 y- E0 }, N$ } D2 Y+ N+ i9 W .active_low = 0,
& F+ D3 W; M7 {" S .gpio = DA850_USER_LED0,
* h; {/ M. Z' o, U+ z .name = "user_led0",
. Q [& F. y" k* z .default_trigger = "default-on",- a. z$ D& i1 W$ `( ^ Q) L c
},
# e% b" ]) u3 a! ~0 M { T( O4 W3 F( l0 I. o }
.active_low = 0,& U1 M' K0 g, k8 o" r: s8 t
.gpio = DA850_USER_LED1,
$ h8 N- a' }4 b; k3 q .name = "user_led1",, r9 w; w4 s1 x w7 e' [
.default_trigger = "default-on",5 J8 v# K7 n* X
},
: x3 {3 C/ h. t/ Q4 T {& ` E+ R8 w9 L, d
.active_low = 0,' f# c: g# l# \- @4 ^
.gpio = DA850_USER_LED2,
' _7 }# Q1 ?6 F" Y .name = "user_led2",
# Q$ I; d. ~3 p [ .default_trigger = "default-on",: ~$ x1 Z' C) V6 I" B P9 Q# e/ ?2 ]
},
+ G5 I+ i9 r9 B {
0 g+ i2 O. m3 L .active_low = 0,, R: X3 P q) T& n) l$ x
.gpio = DA850_USER_LED3,7 O. O+ H* h' @
.name = "user_led3",& m' i2 F/ @# o0 i
.default_trigger = "default-on",) \7 ~: l3 l* I7 T+ |2 P
},
$ @( d, Y2 k+ E+ w};/ |& I* C, D6 g, \8 z
* c N& J; j" Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; R- u7 h; |: U3 Z! O
.leds = da850_evm_tl_leds,7 a6 |0 P3 l; P! l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& r, Z9 E& g' E: y' g. Y
};( X8 p% ^5 |4 R$ r- F# h8 {
0 v7 f% {+ _3 @$ i+ [" Kstatic void led_dev_release(struct device *dev)/ ?& t9 M* `$ `0 c& O C# @1 e
{$ g5 G Q( f- `6 W6 F( A6 v/ {5 {
};
' p, B8 R/ D( a0 [& O7 Z" {) l7 j4 L4 U0 Y9 B3 O! }
static struct platform_device da850_evm_tl_leds_device = {
$ E, l, t H1 b$ j2 |- D+ B# E .name = "leds-gpio",
* g7 W2 E" Q" f' F$ e* D .id = 1,
' B3 L, U, N5 F& q7 Z .dev = {9 V+ Z4 h/ m: Q% w5 b9 Q+ b# Q9 T' E
.platform_data = &da850_evm_tl_leds_pdata,
. z3 e, k' Q1 V3 \! K .release = led_dev_release,0 W/ O0 S# ]8 v$ p/ Y5 o* h
}2 ~& m) V$ j: J+ T/ A/ |
};) ` d+ Q0 S" \. R. _
& A0 N! ], ?% H7 l* b; G3 qstatic int __init led_platform_init(void)3 E- {# `) T+ M, K4 o: s) ]
{
* \5 _; m8 b" |/ L int ret;
& L, E( i0 [4 k* ]6 \+ f1 \+ n#if 0
* R6 X, w; V/ D& g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' @ c0 L8 ~. J1 a6 ~+ \, {
if (ret)
3 v5 g$ U" w! i: P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 ?- s/ Y# h' J4 |2 D "%d\n", ret);9 y4 j) ^* [+ _6 X+ o) b0 H
#endif
* W6 Y5 p" z- _+ J! H2 ] ret = platform_device_register(&da850_evm_tl_leds_device);
) ^( X: A) H" \3 i* ?$ Y8 R( L$ J if (ret)
9 m2 W0 N8 O" i+ C5 s pr_warning("Could not register som GPIO expander LEDS");& S( f+ S) o1 u' P& X/ n# A
else
- O+ H; o7 O9 u V! W- X t" k. @ printk(KERN_INFO "LED register sucessful!\n");
; r3 [. `. `5 ]' F2 o4 G; {3 @* N# d% d% t! x4 F; Y
return ret;
* ]& k; l- j: m/ K}
6 w3 l4 F' p! c! ]8 U. s3 ? k8 |) R' P8 \( b+ r) @7 q8 X
static void __exit led_platform_exit(void)5 b. f7 {- a: M$ O2 N
{
& R2 t `& c! `0 J k platform_device_unregister(&da850_evm_tl_leds_device);
4 @& k/ S. {0 z! d! A0 ^9 u0 m4 G1 ^3 l
printk(KERN_INFO "LED unregister!\n");
/ q4 n; n) y4 D$ S# E% f( |}# x- T7 D8 Y0 ^+ U# ], ^5 }. @
: M" M- _4 B. }$ |! p4 Jmodule_init(led_platform_init);
# Y6 L7 [" _/ a' lmodule_exit(led_platform_exit);1 b9 z! E; |5 N& y
7 O d# Y- @( G
MODULE_DESCRIPTION("Led platform driver");% V1 W$ |" H3 G N, G# ]' c: t
MODULE_AUTHOR("Tronlong");: a; S# e! ~$ |* `4 c
MODULE_LICENSE("GPL");; E; H. ~8 @; A& M2 ]3 s7 {/ ~
- w" X. l6 p" _ ~' U" Z6 D# A
|
|