|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 g' ]/ B2 g4 A) o+ e' A- X2 ~ J
#include <linux/init.h>5 \. i/ N: ^9 i Q0 |" I9 J
#include <linux/module.h>+ c* y$ Z9 S# t7 O9 t7 _
#include <linux/kernel.h>- s# x/ i3 f& w. r" d! p, w
#include <linux/types.h>* Y( ^, l- H9 \* L4 O
#include <linux/gpio.h>
" o; J7 e) r" Y$ m& c#include <linux/leds.h>7 k3 m' a: Z W% v, m
#include <linux/platform_device.h>
b: I: E* a$ n' ^6 s" o6 p. t7 Q. V* o+ a
#include <asm/mach-types.h>/ T: ?( W8 e" ~' {) u
#include <asm/mach/arch.h>* a) D* h H9 f
#include <mach/da8xx.h>+ B' {* F) X/ c- W3 _8 T
#include <mach/mux.h>& w2 I! W1 _) O/ ]) A
# |+ l( L( {) U a- l& T) L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* P$ h2 T! P: t* b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' A6 B& W7 J* P. X% T7 `- i) ]5 a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 K. P" w. ?8 I) F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 O G7 F. ]. w' Q
1 P! \. o0 A3 ~1 m- C$ m5 Q/* assign the tl som board LED-GPIOs*/# u) E& Q& S r/ k
static const short da850_evm_tl_user_led_pins[] = {
1 L1 j) j6 R: M ?6 U /* These pins are definition at <mach/mux.h> file */
7 c( e" N- `( b, r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- T0 X( i- ?6 i) c -1
8 @0 Y; J# i( \};
" O3 V+ w0 ^4 R$ S8 l! }
. k9 N9 l* J. dstatic struct gpio_led da850_evm_tl_leds[] = {
4 k+ l I" U+ z9 g {! H* I6 V" e$ Y6 e7 ^; m
.active_low = 0,
/ r# m6 F& G* l- D .gpio = DA850_USER_LED0,/ W8 f& ^4 t4 R7 F. U8 \$ H
.name = "user_led0",( e y$ j R& R$ E& f" u, U
.default_trigger = "default-on",
* N' O9 i) d- P4 F" U },. |5 E2 p0 u1 K
{
1 i* m: L. x4 \! [ .active_low = 0,- P8 p; W! C/ I' T, X/ `: I. v- ~" p9 Y
.gpio = DA850_USER_LED1,
$ V7 ^2 P2 }: y) }( _: u- A+ R .name = "user_led1",/ @ o0 B) W, }: G
.default_trigger = "default-on"," C6 y& q. R% N6 n+ O( ~6 B
},
* |0 G. E" x3 `. ^& ? {
2 M1 j& \! `- O .active_low = 0,
9 r! Y" n6 B' z: ^9 E- O5 J+ |, ? .gpio = DA850_USER_LED2,9 `3 l8 } q( s. Y' |8 @5 l. }& O
.name = "user_led2",
7 p) o- T8 B% n1 ~1 t .default_trigger = "default-on",
8 s$ c" M, l1 W6 N0 ^( ~& Q( \ },
: F6 y' ~" L% h3 V {
/ N7 A9 h7 F3 d" h" y .active_low = 0,
- v, Q6 G; A3 B4 g2 } .gpio = DA850_USER_LED3," N% \; g' g `8 X1 U g
.name = "user_led3",0 H x5 X4 {8 w O5 K; I8 s% D, R3 T
.default_trigger = "default-on",
: F. t; _- _1 o6 A9 C8 H) E, i },5 x) [* p4 }1 I# ~( W" F- v
};
) K0 E# h. G* R n7 F7 y1 h( j% E; w# X+ [0 i; _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 a! [: A, t* [- @, Q6 c E
.leds = da850_evm_tl_leds,
5 Q1 ?4 T7 b4 N8 C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
_6 _. |& ?1 [4 b6 I7 k};
. j2 j" a' d2 h6 I# f% v, R- ? D" _0 v" P4 u% F
static void led_dev_release(struct device *dev)0 {. }3 u) L5 P: h- A
{3 w1 m. I6 L3 a$ r5 F) f5 T: B2 o E
};. n5 m' y- o ?8 k' S7 V6 i
3 x+ E* N1 [% o2 \* U# }8 }
static struct platform_device da850_evm_tl_leds_device = {. r" U) ^2 \: w) \! k/ j. m$ s
.name = "leds-gpio",- [7 u* m4 [' `* |" p8 Q b' ]
.id = 1,
1 o) _: `0 s6 i1 U$ q4 s0 ^ .dev = {
B5 ]' u: E6 ~. r( k3 ` .platform_data = &da850_evm_tl_leds_pdata,8 S- U- W% B* u, {5 P4 k) ^
.release = led_dev_release, z# H& I9 R: N4 S8 M9 ^
}+ F. B. Z! d: z* O( B p
};8 N: F, P4 G2 L! A$ }7 @0 y
/ f- z, J3 V0 W3 O. Wstatic int __init led_platform_init(void)
4 x" C3 _! X: W/ @{
# V/ r+ Y. V$ w Z9 _4 t* t int ret;
( a4 T; e6 J5 q#if 0: m' r7 K6 q* J' Z' V/ _2 p1 t. z. Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 h' C$ e; A% P! l- | if (ret)
* |# m7 e$ e! H pr_warning("da850_evm_tl_leds_init : User LED mux failed :". H6 `5 D* a9 k# ]5 ~8 j, l
"%d\n", ret);
r+ M6 v: r* c3 s; x D#endif1 y/ R+ U% M6 d( H4 A4 J
ret = platform_device_register(&da850_evm_tl_leds_device);' G2 z7 u: L& _: W
if (ret)
' N# P1 P; h2 P' o5 p& L pr_warning("Could not register som GPIO expander LEDS");
/ X% p7 {: p+ d! x6 o* G% n" [ else
% `6 v1 o/ |$ X% {6 |% T6 C) T printk(KERN_INFO "LED register sucessful!\n");
6 \- s9 D6 d4 m' z9 g' q' I* D6 I9 L! f+ g7 P6 ]$ |) U# B" Q) F) Q
return ret;
3 y. S1 T: x5 Y$ b" C" x}8 j' M( ~: ^. _: A& i6 ~
{# p5 N8 c% h/ b6 u9 n. ostatic void __exit led_platform_exit(void)
5 t- _8 V+ b {. t1 I( p( O+ a" |0 s{
$ N" ~" C { ]; T% E platform_device_unregister(&da850_evm_tl_leds_device);% F, @$ c. a! _0 c7 |7 a* v# ^
& ^) ?" j3 ]2 v+ [) h printk(KERN_INFO "LED unregister!\n");
2 W/ H D6 |# N( r}
5 ] M1 j; M' ]" \7 Y+ R& M
r# X( h1 q Y1 [. jmodule_init(led_platform_init);- D# b8 Z2 P/ x$ [7 T1 F
module_exit(led_platform_exit);
* [# y- T8 P* }. g& M% _ X7 ^. |/ ], n. H
MODULE_DESCRIPTION("Led platform driver");
! Q* x. |% n4 t' v8 s) h+ d5 HMODULE_AUTHOR("Tronlong");. r6 S4 u L; u: d/ u
MODULE_LICENSE("GPL");) }- ~" ?( Y' }7 @7 z. S0 i; ?
) O# j+ r! F9 z, h8 r |
|