|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 c0 u4 b& ?: p6 G, G, f, x#include <linux/init.h>
+ E. H& ]$ f* D#include <linux/module.h>
4 R# i' K3 a/ B, K#include <linux/kernel.h>
& I$ T% J i+ R0 |3 z! Z#include <linux/types.h>. G3 v j* e1 C: y7 a
#include <linux/gpio.h>3 _- N* {8 _+ c8 b! [: R
#include <linux/leds.h>
" s7 ^5 Z( R+ j4 B& m#include <linux/platform_device.h>, U/ x1 N/ P6 z! a( M, N
& e2 T' M5 B; V/ x+ r8 {( l#include <asm/mach-types.h>( ^- W4 `( [" D
#include <asm/mach/arch.h>0 ~$ d2 ?* `) h3 d; d0 \! Q4 P
#include <mach/da8xx.h>
3 k' E' p ~( Q. n" ~- I7 @#include <mach/mux.h>7 |7 k. k; J+ R" L3 K- X, e4 A7 |
2 z1 A+ i+ z b2 c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); }+ c- a- s& L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 K# U) a- A0 |" W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- g0 N v0 \6 V4 v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 T4 @8 F& ?8 v8 o7 Y& W: q7 y: T
6 P: P. d- R/ u; B o1 J) f/* assign the tl som board LED-GPIOs*/, E# e8 D+ y4 u' {. m$ _6 L! P
static const short da850_evm_tl_user_led_pins[] = {
3 S! |" L+ z/ |: A# D" Q$ ? /* These pins are definition at <mach/mux.h> file */
! ~9 {, o( Z* {/ R8 s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 P, a: x4 N; z( k& o
-18 @( s0 P, k" {( Z' f9 p
};( U. k( f6 i" P% q; n8 G
, M1 E# ?3 o. z' |9 @8 u. gstatic struct gpio_led da850_evm_tl_leds[] = {$ p0 H+ Z7 N+ P* i
{
K+ a4 V. F1 ^, K .active_low = 0,
0 l6 o+ f3 Q" s9 e- Z .gpio = DA850_USER_LED0,
% p2 ]' a) t2 h& v( w6 x .name = "user_led0",
5 G" g. N0 S2 m3 s .default_trigger = "default-on",
" N9 D& C1 l# R% r5 n- M },, I- |5 [$ L! m& M& X
{
- ?' w/ l; ?$ b7 d7 K: n .active_low = 0,
. O4 @1 b. {; A .gpio = DA850_USER_LED1,7 ~5 I- `4 l- K% Q( a5 q) s# {
.name = "user_led1",
" Y/ `1 V5 [" h, K* O+ a( C .default_trigger = "default-on",
- T5 M8 f: z4 I6 \+ U9 p/ M& b$ K: q7 T },
7 i# h- `& l6 t1 p {0 r( ]% ~: m+ H4 i/ [
.active_low = 0,! z$ r' ]8 w" W8 _
.gpio = DA850_USER_LED2,
# _6 s) O+ C5 l- `, f2 T+ m" Z .name = "user_led2",
! q' Y' g3 M( c3 U$ G( K2 j .default_trigger = "default-on",6 R3 {) h5 I' s0 {2 t) w
},6 @2 i4 h2 G6 Q/ r, b: F
{3 L0 v- Q8 ]# y6 S
.active_low = 0,: c1 A: G6 F! `( O
.gpio = DA850_USER_LED3,
) C7 p; ~, ?: g/ N- G h .name = "user_led3",( t: c1 `% @. ?- {9 u1 x
.default_trigger = "default-on",1 }' O8 n0 u1 p7 ~
},& @/ c! e* r' l
};' {! B' D- }: o/ l( w5 Q# c
) |' F, G; \7 {& {+ K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 O6 @( q' }+ }" d) \5 e) Y
.leds = da850_evm_tl_leds,; l# _. Y J( m1 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' Q4 |" L" H% ?* B};3 p) f+ r; l6 N! f3 O, m: R# n
6 t" R/ @+ F) F
static void led_dev_release(struct device *dev)5 t3 R5 P$ H9 l9 w
{
0 k$ ?8 I: m, U, X; p8 }};# ^6 p$ C: E- S, ]9 V0 H
2 ]$ u: g* N* N9 I2 h# F0 _5 q/ z
static struct platform_device da850_evm_tl_leds_device = {
a3 G& @8 I# s" }7 a) F .name = "leds-gpio",, f' W" Z q6 R+ M2 b' U* j
.id = 1,
# K% H: m+ h$ V .dev = {
- W8 m+ T8 T( }8 Z8 i. C6 I( R1 a .platform_data = &da850_evm_tl_leds_pdata,0 s# t) m' T' M( `( E* H$ i
.release = led_dev_release,6 N4 N2 K, Y* x! N
} Y: ]6 @' w0 }0 J% y8 ]8 S) @
};& M$ g* W+ O, Y- N4 }: f* K' u
5 d: G+ {% i9 @/ d) I8 z& |- S% c
static int __init led_platform_init(void)
7 B) _3 Z1 H) a8 v$ h{
8 M6 f( Y0 P; ]7 _2 O" U0 O( B1 P int ret;7 b2 Y* X# D) v' r0 h
#if 0
9 M# D0 a2 {0 j- k* W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( L) k1 D% Y7 L" L if (ret)
- l) c9 |# X* U6 W' ?( e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 M+ k6 j- g; |# d# }5 y/ c) v: d "%d\n", ret);
7 R+ V7 O* [1 U+ M#endif' C4 J0 c" W( F0 q: N
ret = platform_device_register(&da850_evm_tl_leds_device);
$ Y( j& A' P! C8 l7 ^/ D/ w if (ret)
2 o! X; m# t' N pr_warning("Could not register som GPIO expander LEDS");/ x4 R2 w0 t; x3 [. f$ y
else. l! E4 ^; W) {/ c2 \5 I6 Z
printk(KERN_INFO "LED register sucessful!\n");
# p3 r v( ^+ S g8 S4 g% b! L: N+ _" a# S$ h
return ret;
) X# W8 S5 R) w& j Y6 W4 W}. n) B: f8 q( o9 n+ }& l
8 I0 m% \- Y9 \ C/ hstatic void __exit led_platform_exit(void)
) [+ V: m% E: d2 Y+ R( @/ G{+ p; W& a2 m; N+ J P( o+ X
platform_device_unregister(&da850_evm_tl_leds_device);$ Q/ U" q7 u# w' U5 y F# t
$ r8 N, v' K/ H: ^1 M
printk(KERN_INFO "LED unregister!\n");
8 ]% m V* I% |* {8 n5 d$ L}
" m6 x4 A) Y+ @( j8 r/ `+ z2 U$ c$ r1 A
) w9 r% ?2 q! H/ X0 Kmodule_init(led_platform_init);
: }+ j0 n3 P/ M! h: y# Dmodule_exit(led_platform_exit);
. Y' n8 L1 f9 a5 g; n, N$ O6 m2 J, V! c- N
MODULE_DESCRIPTION("Led platform driver");! f) r4 X5 }3 [$ g: ]3 ^
MODULE_AUTHOR("Tronlong");' j1 y3 S1 {6 [
MODULE_LICENSE("GPL");7 P4 O2 V$ t* q; L; e0 F( v3 o% Y
" z, P1 m2 F; J& c! D
|
|