|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ l8 I) ]/ r7 S& f#include <linux/init.h>, O5 s+ _; H( W8 }$ f3 g" q/ y
#include <linux/module.h>
& T. J# d+ r1 C8 _#include <linux/kernel.h>: e) `; f" N6 E3 a; S! i, \
#include <linux/types.h>) P: S+ \5 Q) M* J
#include <linux/gpio.h>8 h+ P; {9 {6 t; y
#include <linux/leds.h>
' S5 H h- ~. E4 ^ {#include <linux/platform_device.h>
$ z. o/ m! [- Z* I/ m/ J' l. w% |& F5 g
#include <asm/mach-types.h>/ a' |. f4 R5 j
#include <asm/mach/arch.h>6 e) |. n. t9 S: X6 s) K
#include <mach/da8xx.h>
1 l' T3 C& c" q3 Q! ^* l#include <mach/mux.h>$ r0 O; E* [) T1 X& O' ?3 D
6 \# A" m' x6 c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& Y3 O+ t' B: K5 W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! W& `/ d" c) u( t9 ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; n7 [7 @/ j% f5 c2 \8 \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), X$ ? r- W: Y0 I4 R* _
% v$ Y' w. m5 _# Q5 Q' x/* assign the tl som board LED-GPIOs*/
& l+ X: ?2 T/ C0 M; n% Dstatic const short da850_evm_tl_user_led_pins[] = {
! D# O7 p2 F# J: K$ J4 |6 l /* These pins are definition at <mach/mux.h> file */ N( k. \5 r. J# E# P" u& ]% S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," K+ _( k2 R/ J g# {8 S: v
-1
6 f% B3 ~: J! m6 q; ?1 r6 }' ]};: o( a9 ?+ q \- y( S
" x7 k/ w/ ^! d) {static struct gpio_led da850_evm_tl_leds[] = {
# D1 Y& H; }. l$ ]$ ^4 J1 U {# r3 r1 ^! I) t, p6 w. K
.active_low = 0,
/ S# i2 F0 _0 R5 o+ f" g .gpio = DA850_USER_LED0,/ w6 b- Z, w* t; z
.name = "user_led0",
' b1 ]' R1 Q r' }1 G2 X .default_trigger = "default-on",
m! D5 w& U8 z. x* ^+ ~; c; g },
0 h+ ]: n% Y5 E3 [" _" c {3 A! P: o$ x( X, N
.active_low = 0,' }' @* E" P/ i3 Y3 Y# {0 z& P
.gpio = DA850_USER_LED1,
6 i* d3 I% N) s: X .name = "user_led1"," X+ {# i; [3 M
.default_trigger = "default-on",* ?8 f8 {' A& `' z
},9 S3 \( B& N1 Z; I% L
{
: \, \5 L4 S: n( a .active_low = 0,1 [) R' X/ E7 K7 r
.gpio = DA850_USER_LED2,3 A2 A5 d8 k# b5 A( S$ J: G! E* t
.name = "user_led2",
W1 b1 |. b; ]: ~. T: r .default_trigger = "default-on",
2 k! W# I4 D& p3 s+ J },
+ q9 `, c9 I8 [$ d {
; f. ]# X" @" N6 y! [ G .active_low = 0,
3 a A8 V f1 g% Y* e/ L/ [ .gpio = DA850_USER_LED3,# j& Z6 ~" U+ u0 u
.name = "user_led3",+ g6 F% H. _3 U+ ~& P
.default_trigger = "default-on",- b6 n: h! [, A/ L
}," a5 R' r6 \) M+ D8 ]8 v* m' K1 V
};, J, v9 E; U5 }8 m4 t
, ] K7 i1 E( A" i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 d8 @8 f4 ]) Z; R) B/ q7 T .leds = da850_evm_tl_leds,
( }# f( b7 M' s+ t5 s W5 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
]0 r* y" E" A9 D};! b1 q) \( A$ U. S+ l; C4 Y
- ^4 d7 U' r. |( j( Nstatic void led_dev_release(struct device *dev)4 U/ A9 D+ a( d o. \
{
( v9 @ y' p- R};
/ }. P# Y* Q R( M) `
# Z; z8 k# u" _9 `+ sstatic struct platform_device da850_evm_tl_leds_device = {
' c1 L; i1 I8 ]& m .name = "leds-gpio",
" {" A2 M0 _ t .id = 1,* c4 T! [1 \4 A- d' E
.dev = {2 B9 E$ x6 y/ P3 o
.platform_data = &da850_evm_tl_leds_pdata,
x2 [8 E+ O5 l" G+ {) X. r; v .release = led_dev_release,
) Q1 ?% h0 P9 \/ q! \- T+ r }* X" \) s7 |9 i7 {! H
};
2 I, C, X% E, M/ `9 l
' ^7 W6 [# r# L8 pstatic int __init led_platform_init(void)! O8 h& Z5 [! M: Y& ?5 B
{4 E9 l6 @& A( }, B! H
int ret;
2 _. i$ \8 b! r c5 O6 t) i w6 B#if 02 T/ i0 G ~( |3 y8 R. [" d- W! n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 w8 N9 y7 I2 G( T+ k
if (ret)
5 \+ Z/ r+ \ A% [8 Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :". T z, i/ G& u$ n, N, }4 T& Y
"%d\n", ret);7 D- d& [' Y' |1 A5 B0 F
#endif
6 L8 |% t- s1 J5 Z ret = platform_device_register(&da850_evm_tl_leds_device);- `" U- j% s, J6 \2 I
if (ret)
) ]& S, u9 T4 l8 J# l2 Z pr_warning("Could not register som GPIO expander LEDS");
# j6 s2 i# N$ r9 J else! x3 U( h% c1 N8 b. {* u
printk(KERN_INFO "LED register sucessful!\n");5 B! o2 c& U0 l
) V* T* u" L6 b" E0 O
return ret;
# [% J `- Y- H" @0 F0 u}
# F4 L' p( U/ }# a8 A
( D2 { H" q$ m( xstatic void __exit led_platform_exit(void); n5 s' f" D4 u1 m2 z* X/ m
{2 a2 e, K6 M7 b5 h' C3 A
platform_device_unregister(&da850_evm_tl_leds_device);5 b" e; w# f3 ]! D- e2 x8 [- ?
8 F* R( ]5 z; E printk(KERN_INFO "LED unregister!\n");; [, S8 {0 k0 }6 F% s7 f! v4 K/ k7 G
}+ e) A8 {0 B4 U/ V: Y% u
# t! l* r( B8 K& \
module_init(led_platform_init);
' i3 M% Q2 [: \ Z+ kmodule_exit(led_platform_exit);. q: `# D' G/ I( [5 H
5 B; }2 r0 A- m2 y
MODULE_DESCRIPTION("Led platform driver");& x1 j S2 ~. t, ~0 }
MODULE_AUTHOR("Tronlong");
3 S, I$ i/ [/ J5 r9 Q# lMODULE_LICENSE("GPL");
# z7 X: g/ M: e6 R% Z- o( }
# J" I4 X3 F+ d8 L9 N" f9 M+ C |
|