|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# u( {" [; N3 `% U. U" J$ r& ~3 ?#include <linux/init.h>
' D: T$ e0 ?! r2 B- U5 n9 s#include <linux/module.h>( j$ k1 ^# d/ B y) n- d% \3 @
#include <linux/kernel.h>
( W8 |9 N' l9 k' ^9 f* f8 p#include <linux/types.h>
7 k3 L$ f+ \* [9 @. ]#include <linux/gpio.h>
+ }$ P) d1 e' Q: R#include <linux/leds.h>
' t# j% j/ N! t/ q" j+ W#include <linux/platform_device.h>
9 h- _( ?; N% A# ]" a
6 }1 m- l0 y4 ^! a: t: B5 e) n#include <asm/mach-types.h>
0 a7 \4 a5 x5 _, y, {3 d5 ~#include <asm/mach/arch.h>
6 j N5 X& f& a/ I) M7 z#include <mach/da8xx.h>) z+ f: l! a' A& v' P& V$ R
#include <mach/mux.h>
' s4 t: ^7 {# X+ z' S' V8 ^ O7 i+ W3 w% \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). U2 w0 K3 A- m( S+ d7 ^ q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 j9 S# P+ g# o8 a2 I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# E( k3 o+ @7 ^9 W6 f% e5 d) z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 A! ]7 o" ~/ k- s4 V
+ W0 Z5 t' C2 C' E8 U+ s/* assign the tl som board LED-GPIOs*/
4 b/ E* {4 M7 Q5 }4 w5 @static const short da850_evm_tl_user_led_pins[] = {
3 A P* ~( C" S /* These pins are definition at <mach/mux.h> file */! k+ q2 }+ R o0 |- h9 Q/ S/ W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& Q& r) P6 M( I& m- u
-1- _0 r2 L$ \2 i0 z. e8 r8 f+ s
};1 K. {- E2 M5 U) m% P# I7 p" d# ~" [
9 d- V1 r3 S4 a" M1 Pstatic struct gpio_led da850_evm_tl_leds[] = {4 L) ]4 z& K) B3 s2 h1 ]; R
{
3 R; l6 C# h, C9 z4 h2 m6 \ .active_low = 0,
3 r+ T1 J; P+ K* j$ Q3 X: C- _ .gpio = DA850_USER_LED0," I0 J( G" x7 N+ b0 V( K! i/ _
.name = "user_led0", @0 d4 ~2 Y) j' y" X8 |- |
.default_trigger = "default-on"," o* _( n1 T# _; ~, n0 Y7 {# C
},! T' m* j U9 p6 J4 @; @5 a
{
5 I0 ?/ {- n7 W! R# r. O .active_low = 0,4 l9 E& |* p9 i4 G4 @- E
.gpio = DA850_USER_LED1,5 ~/ j s. `+ Q8 T( t+ Z
.name = "user_led1",! R* C; I$ B3 ?4 X3 j! \( M
.default_trigger = "default-on",
6 y3 ?. n7 x; x4 l },
3 W! e$ @/ |$ |0 n {
4 v2 m" k, G. I) r3 _ .active_low = 0,) R" l4 \+ \1 s9 N7 I# j
.gpio = DA850_USER_LED2,
0 r( t/ T$ W9 c& Y) e+ K% e .name = "user_led2",
u5 c" @: f1 b5 z8 Q* ?3 n% H .default_trigger = "default-on",- l+ _! O* k3 y2 ?# t
},' B' G& y6 W( v: U( S( o
{) ^* n) C& {9 S* X# F) i0 t- e4 F
.active_low = 0,+ K1 ^9 ^& I6 n2 U6 q
.gpio = DA850_USER_LED3,( u* ?" a4 c, v8 z k) Q
.name = "user_led3",
: E7 t" i0 q# ?6 _. R7 N& k .default_trigger = "default-on",
7 P0 f: c, V- q: o4 b4 W0 y3 w },6 L/ Q) \5 f/ V
};; a- Z7 G+ \3 V2 |
9 ]6 T1 s" L% _- Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& q& a3 m, f, ?" l) X8 k .leds = da850_evm_tl_leds, N. h8 `: u p5 h& x8 Y; `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 y; o: o# ~ d3 f};
. E7 a: o4 U+ x3 W- k+ f' j6 W7 {/ z/ ]% b
static void led_dev_release(struct device *dev)
& ?6 L* Z9 Q' t$ \% }7 P{
7 ?# J: y4 S" g9 c" {};! Z+ \% Y3 P: |- s( q3 S( R5 b9 c6 ^
7 C' V) N) s& Y2 {static struct platform_device da850_evm_tl_leds_device = {
7 v" x6 j' d2 f* `& e .name = "leds-gpio",
0 {2 Q! X3 f( | .id = 1,
+ M p& {4 h6 U2 U" c .dev = {
. c# I, Q; }! S5 a" L! J, Q .platform_data = &da850_evm_tl_leds_pdata,
* ]+ J, T5 z5 t5 X* r4 ^) G .release = led_dev_release,1 }# l& t+ L, }- m* s; b/ `
}
, m; V0 [& m/ o0 J* w s: Q/ O};1 a! Y# P& k% N6 y( X2 K8 o
& w' H9 h& I& s8 M5 N# hstatic int __init led_platform_init(void), A! A$ [$ j. v% \0 H$ s7 B
{
7 W$ d7 Y1 F( k int ret;1 B" |. ~# Q1 W" S4 u: U
#if 0; N6 H1 c. r. V, f3 v5 b6 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* v+ T& C9 d z3 M: }3 m$ _ if (ret)
! Y O4 e- G; P* a- ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 R* H. [! m2 a0 b1 @ "%d\n", ret);
' w) ]- i8 I/ _- f1 k0 C#endif6 n$ [1 a! z) Q" u) c
ret = platform_device_register(&da850_evm_tl_leds_device);2 U7 N! O' Z. t* K% t4 X: z
if (ret)
4 ]% E$ ~& `: @5 T pr_warning("Could not register som GPIO expander LEDS");4 _0 k: g$ ?0 m- G. x! k
else4 V1 N5 e8 ~$ r0 m T
printk(KERN_INFO "LED register sucessful!\n");
, ]1 b; c8 p: U1 m# h0 a7 L" M' J, U, D2 I
return ret;
3 s& v" ]0 v- y& q" p}
+ o. Z! U7 C; Y
$ l( A5 p" }) Bstatic void __exit led_platform_exit(void)
5 ]9 O( ]$ c' D$ H% W# _4 K% n' c5 W{5 ~ P a/ Q1 F2 R+ O& F
platform_device_unregister(&da850_evm_tl_leds_device);
7 x3 r, ~. `( v* m# @! g# d& d9 V( q- T* `$ z
printk(KERN_INFO "LED unregister!\n");7 k( k6 m- m- i( J3 H( V2 E
}
- R$ n' }+ Q" Z# w+ @. ]6 r) ]3 m. l, n0 K# g7 y0 I
module_init(led_platform_init);- {" m& v" @9 `2 r" F5 W m
module_exit(led_platform_exit); H* Q2 m6 G' g& u4 M
5 N, Z) Z2 Q2 x4 IMODULE_DESCRIPTION("Led platform driver");+ c2 w9 p) U; k1 r# [5 f4 C
MODULE_AUTHOR("Tronlong");
* e+ l7 z/ B# A, OMODULE_LICENSE("GPL");
c8 h) l3 s: a& n* f. {* W$ g4 C7 I% r3 E
|
|