|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 p8 {5 z: @6 ?) d5 p! y W#include <linux/init.h>' L7 ^' D+ a0 Y( Y' y9 N$ g, ?
#include <linux/module.h>8 r7 I! i, ]' e/ M, d# n7 [
#include <linux/kernel.h># X* L3 p' m% ~ j/ G
#include <linux/types.h>8 y5 B& ^1 e' R B! x" a
#include <linux/gpio.h>
} }! {5 x6 V- \" R#include <linux/leds.h># \, b8 l1 ^( M# g% t/ U9 w0 h$ b
#include <linux/platform_device.h>" Q7 Y! }# \9 _+ ?' p2 ?
; N9 W3 ~+ u2 [$ u#include <asm/mach-types.h>% N1 d. v7 p" t: o
#include <asm/mach/arch.h>4 i0 J4 m( h7 E: U. K; U+ a
#include <mach/da8xx.h>
1 j3 P ]& D9 }9 }& c( A#include <mach/mux.h>
" [' F% e9 S& d
1 j. S' u! h: z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). R- D5 m. z1 ^, _! V" Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ V; E8 D7 o* M/ m2 O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. q8 |/ o% m% ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 g/ r5 J5 O) o2 e; u1 J3 F" q. @0 |6 T# T
/* assign the tl som board LED-GPIOs*/
: `, S+ t% M6 c2 Mstatic const short da850_evm_tl_user_led_pins[] = { x+ A: q( D6 Q
/* These pins are definition at <mach/mux.h> file */
* D! \& p I, B# N6 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# l% W) x8 [7 b; X! [- t# m
-1" Z! Z6 I. h- N* R% Q; K* w+ \% e
};
+ }. @& f. H: X: Q* @; Y/ l E) x6 U
8 e$ P: M( r% q% }static struct gpio_led da850_evm_tl_leds[] = {
8 w! g6 C! e1 }* b6 c( M {# d; @+ {2 r+ [0 S; T- @& E! x
.active_low = 0,6 k5 ~0 @1 E" m3 q/ I) w5 T/ u; k
.gpio = DA850_USER_LED0,
7 d' M: j' ]) [8 j3 C8 Y# B .name = "user_led0",
5 T1 @1 ]$ d9 C; `% f .default_trigger = "default-on",
D+ a+ G- r2 M. a },: d& D( b& V+ }; @" h0 ]# c: E! R
{
: i8 [ U; M: E2 G$ y0 r$ ~4 i4 O .active_low = 0,4 F8 R; V. [/ `: i
.gpio = DA850_USER_LED1,2 \: I; q6 B: X& r- }3 c$ D4 n
.name = "user_led1",' _% _% ?' y# t( G' c" d. _
.default_trigger = "default-on",. P. {( b( c; u1 I' e
},% C7 ~8 H. y+ |* c3 ` B
{, s$ i6 ~& x2 W% Y/ s4 e4 e
.active_low = 0," R$ V5 [: l3 A6 q: x' G8 m- A
.gpio = DA850_USER_LED2,) M" ^6 z) L$ f% r2 ?' f0 S
.name = "user_led2",
# T* d p6 A7 x% {& f .default_trigger = "default-on",
7 q. S- T, P) Y- N! ` },
+ [* B8 I8 a+ S4 b( I- L7 W {5 w! m) o) N: X* P3 j
.active_low = 0,# b/ Y' ?$ Y9 p4 W
.gpio = DA850_USER_LED3,3 |, C$ n6 g6 v% o$ T$ {; t
.name = "user_led3",. y8 O, t# \+ f* j! [6 F7 O( M/ X
.default_trigger = "default-on",4 w- {4 v n- J7 g% S; x
},
8 ] c0 g V. V8 b};) c. l0 h( U2 q( h
8 R4 }2 T2 a* F# N5 K6 B7 m4 S4 Z1 ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
_. Y9 q/ \, L! I& V+ ~8 A9 M .leds = da850_evm_tl_leds,
5 i& N. D# y8 S' G2 |/ w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 N5 G5 ?; S* |+ K7 P/ H$ d5 u8 F! \};
- ]/ J; X- ?2 P8 _8 X" m& d6 ^3 ?
static void led_dev_release(struct device *dev)5 O' Y) Z3 j# b& z* J
{* h; w( [; b% h, H/ ^
};
1 D) D# @( ^, d9 }
8 e5 ~. i/ T& w# Z1 W# sstatic struct platform_device da850_evm_tl_leds_device = {+ j+ t- r* ~6 [. T, c# Y. N
.name = "leds-gpio",
& R) @3 N! X! V; T* P .id = 1,
; U8 B. _, c) @7 t- |7 f .dev = {
9 F: T/ G6 n3 j5 c) m6 | .platform_data = &da850_evm_tl_leds_pdata," J- T& k( U) x# B
.release = led_dev_release,
( o$ e5 t. v' S, ~* W }7 A& D4 Y# o$ a% ]1 v
};
) X [: y. T3 q! x; d% g
& z# v: A8 J* k+ Nstatic int __init led_platform_init(void)1 R0 {! R/ b# J$ A& V* L. D7 `0 P
{
4 u9 o2 m4 C8 O int ret;
) D, C% W" g7 { Q+ l. |( k#if 0
& h; Z& S, Q' V4 I, k$ } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- b1 Q% K) c4 C0 A2 d8 v. E, @ if (ret)
0 C- h# b# O4 }( q' A! q' | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 D& B% T! u' |0 W+ v+ w
"%d\n", ret);
|# ^6 t2 Q9 F3 b* L( e/ E#endif
4 O/ W1 F5 a1 _+ M t ret = platform_device_register(&da850_evm_tl_leds_device);
: u4 f, r) l7 s$ g if (ret)0 J+ A, W5 z8 {" f2 D% ^' ?' p
pr_warning("Could not register som GPIO expander LEDS");& d0 z k* |+ R8 r9 w/ D0 h* b1 |$ X
else6 R' f- [9 V U* A' s# H
printk(KERN_INFO "LED register sucessful!\n");
) }7 t5 ^) @( |9 L! ^+ x0 V9 I* s* L* _$ \( ^
return ret;/ s/ c! ?+ v0 O' G) m
}6 J9 p7 i! p/ H* ^5 J1 G
5 C& D' J* \; O( E# S/ nstatic void __exit led_platform_exit(void)7 p1 y' G2 a! d& j; o+ u/ S
{
% `0 V+ d5 a. k3 ?, C platform_device_unregister(&da850_evm_tl_leds_device);. I# h. ^: }# T6 a4 g
0 }7 N9 Q* ~- y2 v. ] printk(KERN_INFO "LED unregister!\n");- e* N6 j* |/ ^ j( K1 d& O! q" M
}$ c# B) o2 n6 h1 a0 w2 J# [
# `/ X0 W, D% T0 M9 pmodule_init(led_platform_init);5 Y) [3 B9 ?' T/ B6 M4 Q* j) k
module_exit(led_platform_exit);) i: F5 F( u9 p' i7 U3 [9 f
+ {: Q9 }- u' N. I- ?6 ~8 I
MODULE_DESCRIPTION("Led platform driver");
# Q- q2 t- X8 t0 C( ~MODULE_AUTHOR("Tronlong");9 {" C* E4 }- W" b) t/ n2 K
MODULE_LICENSE("GPL");
; j" C: V' w; c: [: d; W2 M! {7 j2 h0 {( r2 J
|
|