|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% ~" Q8 ^6 [0 E& M* d) h#include <linux/init.h> H4 u1 ]: o/ A9 j4 m! l' ~
#include <linux/module.h>4 r0 f ?! K8 A/ s9 K
#include <linux/kernel.h>
3 V) v$ a; c3 s#include <linux/types.h>/ [- s- ?' d& U( W1 K
#include <linux/gpio.h>
2 B( @9 |9 R6 U$ A d#include <linux/leds.h>9 c8 B r; T) s, S
#include <linux/platform_device.h>
* U4 R2 g/ m, G
( X8 A& i; A# R0 r/ ` [#include <asm/mach-types.h>
q+ A1 w2 R+ h8 `3 }#include <asm/mach/arch.h>$ p8 ]9 {1 a7 e H9 {- K! u
#include <mach/da8xx.h>8 K; Y4 _( O4 h8 ~
#include <mach/mux.h>
' }9 E8 r( Q: {8 A
3 H7 ~& G( K3 t- k( Q1 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* r: n/ N; W% g+ ]" ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 G8 W$ A& c, \- e6 P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 |9 p" n. U5 S" @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- n! h' y# U1 D( ^ e1 L$ D& c- q' z) j }& b
/* assign the tl som board LED-GPIOs*/. b/ h! f0 k3 s5 u/ i( ]
static const short da850_evm_tl_user_led_pins[] = {
9 K4 M0 }4 L7 K8 W, _ /* These pins are definition at <mach/mux.h> file */7 ~5 E9 Z8 b, G, f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' J1 K& v8 C5 s, f* P, b8 _
-1
% I0 b$ w1 A! d M};
' i# M5 k9 T) [7 V* |- e8 n
, ?+ s% A; W- ]5 Kstatic struct gpio_led da850_evm_tl_leds[] = {
3 `) M; f8 s' i2 l; @2 s {: `1 z- k: D5 |& z# e
.active_low = 0,
3 v" a1 e1 ]" K/ [" _ .gpio = DA850_USER_LED0,- |5 K$ ` L; d0 \* n: v; N! q: M
.name = "user_led0",. z+ C, n6 {0 H1 W# b3 M- c
.default_trigger = "default-on",+ z1 }0 ?$ U+ l/ r
},5 p/ [. t- V+ q5 ]2 c; o
{
/ F6 ^ S" Z- ]/ q, {! Y .active_low = 0,7 P% B$ O" [* N& |
.gpio = DA850_USER_LED1,
: g. Y2 U! C! O" v7 c( ]! W .name = "user_led1",
5 G% [; u9 G* h9 [3 j; X9 R .default_trigger = "default-on",
! J6 e( s9 C7 Y3 N. j },
7 [0 B3 B6 Y; s' P4 q# q9 f {# O( \- }, U- R
.active_low = 0,
- c; w3 J' }. u9 B7 p$ H .gpio = DA850_USER_LED2,
: j) j' N; H& e! A/ s5 Y .name = "user_led2",9 I$ f" f- ~; t9 f# O, q
.default_trigger = "default-on",
$ N/ r8 A4 Q7 R" `8 N2 } s% y },
, M0 F8 t! ]3 ? N8 A& L; Q {- M8 e8 l* e. {
.active_low = 0, K/ ~9 [- J9 g& e1 `
.gpio = DA850_USER_LED3,
5 j7 f; w, V: j0 x# d) r( P& j0 C .name = "user_led3",
% J9 A" u/ @/ ~1 r- P .default_trigger = "default-on",% V! I" q9 w( ]" e$ S
},
: Q7 N: O0 N; Q};8 V% ~3 d+ i `% m8 ?' Y
+ s/ ]. Z; o- l) j. o! b& sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# k6 z( w6 J' q) S
.leds = da850_evm_tl_leds,7 g* _3 Z- E/ V' F( |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
C# O* |7 J7 f5 \};
$ Y( B+ w5 q- W2 c7 f; K+ f0 X! G) g. W v o6 Y2 \
static void led_dev_release(struct device *dev)1 ~9 \' V( x; X( I4 @
{3 W4 P4 {# H1 N: G
};
8 p; A& v# M- Y: P& h6 i6 Y* u( j0 q3 S' F
static struct platform_device da850_evm_tl_leds_device = {( y: i7 n# o- u% `
.name = "leds-gpio",( Z" K" e# c. E& [! P% {0 r
.id = 1,1 ~% @9 V: x. K7 c" O# W" b+ Q
.dev = {
3 p- l* o: a4 ~" ? [: a" Q. N8 n+ L6 E .platform_data = &da850_evm_tl_leds_pdata,
P; {1 L3 q! D. K5 F( g5 ?7 ~ .release = led_dev_release,0 Q! E! R5 U3 ~
}
8 i& s' y! \$ B. S/ n0 M1 N};) P" Y6 X6 M N
* }+ q; Q% ~& Y" M
static int __init led_platform_init(void)% y+ q g' r' S% {4 C* [9 q4 K
{* Y8 u1 ` ]" \3 }8 }
int ret;
, k; r7 m, ?( _. c! G5 I#if 0& r/ h8 C' O( ? d9 Z/ I; f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 ?6 H8 `9 w0 V+ d4 r- a7 h( c" n: q
if (ret)
4 n) L" \; I. H4 P" u' K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 d V$ K5 p* l; ]
"%d\n", ret);
3 k% J- n+ k `2 H% \0 ~#endif
2 m6 z# G1 z4 D- `% E+ o: s ret = platform_device_register(&da850_evm_tl_leds_device);
, n2 c4 C' i9 O$ {( K if (ret)" R' x2 s7 \, j2 ?5 l
pr_warning("Could not register som GPIO expander LEDS");7 y& [0 p. h( Q) Q: d
else/ `- Y" @( E3 @. o X! n
printk(KERN_INFO "LED register sucessful!\n");/ h$ Q; Q0 B+ x' d
! o9 r, L x0 `! _, \, _8 m- S return ret;/ D' V' r5 t: j2 n9 d2 l$ o
}
- R f, r/ s) o( c. e- f, ^; M. U, Y. e8 J' R" L: }: w3 F7 w Z
static void __exit led_platform_exit(void)! I2 A* c6 b1 o: d3 z$ h4 I0 z
{# o+ M1 f3 K- V3 X
platform_device_unregister(&da850_evm_tl_leds_device);1 q3 M7 Y1 f$ ~9 x- E8 S# i5 x
1 D0 [ }" m3 P; |" s5 J printk(KERN_INFO "LED unregister!\n");
6 \/ b. E; N9 s1 G w5 b}
! i7 i# s8 A4 O# m. p
8 ^* W" [6 p& h5 R. Lmodule_init(led_platform_init);
p* t8 s5 x) a$ Q! Wmodule_exit(led_platform_exit);4 ^8 U2 X% |& i, |2 N9 x) D! d
, _) L2 }1 H# qMODULE_DESCRIPTION("Led platform driver");4 i. b: S$ Q/ G
MODULE_AUTHOR("Tronlong");
' H5 Y: k" W! Q$ m9 u( y7 qMODULE_LICENSE("GPL");
+ ~9 b( ?* O% B8 f2 @4 d/ }2 P* g* w* E
|
|