|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 R2 L" D0 U; a/ v0 d6 Y
#include <linux/init.h>; I" K( b9 R2 ~+ t& H6 X( Y V5 e
#include <linux/module.h>4 B1 Y4 t2 N4 l3 @0 J) O5 j' W6 W+ B
#include <linux/kernel.h>
# j$ U' P1 m. q1 V3 r+ X, j#include <linux/types.h> ?1 M/ S. z1 U5 d
#include <linux/gpio.h>2 {6 ^9 k |6 _+ L# d
#include <linux/leds.h>. J) E2 j) C: c. U; n
#include <linux/platform_device.h>
, Z% t, r8 r7 Z8 ^) A
/ v, D- G3 n3 k( Q, Y#include <asm/mach-types.h>
- \9 i' a, Y X o#include <asm/mach/arch.h>
8 D6 Q8 ^3 a+ C, p8 N6 J8 b5 [, Z$ U#include <mach/da8xx.h>
, N# j; {6 R% M8 _" ~#include <mach/mux.h>
" z' U5 F% G. \0 b3 X
0 q1 l" N# I5 P* H# `" Y3 J3 k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), m9 H4 i( H8 T3 g+ ~! }0 ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); ~2 ~' C3 Z* C5 J, S) m, H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" ^1 M& C6 ~! g: K1 f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): V5 x# l+ V- H$ l8 b4 T4 u
, |1 u$ a5 |) R/* assign the tl som board LED-GPIOs*/- T2 ?) Q1 m3 P9 m' i0 k# p% T; Q
static const short da850_evm_tl_user_led_pins[] = {
! N/ d/ N. j5 f1 A /* These pins are definition at <mach/mux.h> file */, b; i8 r+ @7 y0 D" ^" w+ R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" T* {1 b. T8 v7 @- l& ?/ { -1" X; |: u' i5 b7 Y& J, }* ~
};7 u) u* x) t0 R5 V) ]0 A2 `# Z l
# {/ s" H& \5 ^
static struct gpio_led da850_evm_tl_leds[] = {" o Z! \: p9 c
{. v3 k' i- X& a8 N3 w5 {
.active_low = 0,
; e( o' I" R7 L$ c .gpio = DA850_USER_LED0,
1 d8 h1 X# G4 y, v4 g& v) ^ .name = "user_led0",, s5 @. Y4 X5 e7 A
.default_trigger = "default-on",: Q0 c6 \% ^: H: R. {5 M7 F
},4 Z4 k. H4 }& p' M
{ {/ n# ^% h D7 @# J T' B
.active_low = 0,2 r/ S! N' j, N
.gpio = DA850_USER_LED1,: w8 F# c$ N8 N+ k0 t/ k. m
.name = "user_led1",
7 V4 ]% Z) l" d .default_trigger = "default-on",+ M& m- a3 z @$ H$ ?2 i1 _
},
. A* h, P$ M& ~. t {
. T8 C; T% ] `* h6 Y+ ]# z .active_low = 0,. w7 e( T- ]4 N
.gpio = DA850_USER_LED2,, t& a! [" E5 a0 j
.name = "user_led2",1 W" \ }# D& p9 P, s" E: {
.default_trigger = "default-on",
; _+ I/ n) t; ~, Q, T N },
! i! h* [6 r. }3 M {
7 K: d& `; F3 D% \% x .active_low = 0,
% {4 v2 J" ?: i8 G9 D8 W2 c .gpio = DA850_USER_LED3,4 V$ {7 s7 k( ?
.name = "user_led3",: b; E# D: D( U$ N1 t
.default_trigger = "default-on",; H4 A5 i# Q4 q9 a) X) O
},( ]* Q" a- w4 W, i* i* i
};
( N% D0 d& B" A
1 W: m, P7 ? j7 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& u: J+ b9 b+ H+ C$ C
.leds = da850_evm_tl_leds,/ |$ g9 V, ^! L% A1 ^1 g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; q B7 @+ ^# X; U- T8 k
};$ b5 {0 s' ~: s) X2 G" n' p, a" e
x c. q, e# l$ n
static void led_dev_release(struct device *dev)
% A h* S' ~. ]" e. j7 C7 o) l{& a' B3 k' h# h# |2 g; Z" y
};! p2 ]; U! V6 X6 W6 F# ]
! z, J' L2 x' v9 b2 v5 k7 _
static struct platform_device da850_evm_tl_leds_device = {
3 x3 @) G# L. }( h .name = "leds-gpio",
: w7 ]+ {$ h. O. G .id = 1,4 y, w x& B: ^3 W g
.dev = {
$ f! u; s* D4 p0 e; `9 @ K; t6 U& Y .platform_data = &da850_evm_tl_leds_pdata,
5 {0 o( x# v3 @. E/ N. c .release = led_dev_release,
, [' ]6 Z% q- m6 D }
" j' a. X, p- C4 o# `- v};
, @3 h5 Y2 D" { s0 C, ~5 i6 B9 w
+ x+ L5 X2 q& L) m7 n. g) Zstatic int __init led_platform_init(void), O4 X4 i3 K S
{
( S. Q9 ]% k0 c9 e int ret;
3 c9 i. O! z/ R$ L5 c% M, P#if 0
! T6 K4 m6 |: {) g$ E6 K; ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- v8 d7 {# k D
if (ret)0 a$ W$ D- f& P1 u1 i2 t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" Q- W) E; V/ I" L) L( k
"%d\n", ret);5 O: g" k' o0 U$ D! t3 y. l
#endif3 o' t" v- E; t9 K( D2 z
ret = platform_device_register(&da850_evm_tl_leds_device);* I7 J: ]; K8 R
if (ret)
7 L( O/ b7 s. [ pr_warning("Could not register som GPIO expander LEDS");
7 f. v. _0 c5 \ d& d4 a& B% j) j else
" D4 O' y( D5 f/ m7 T; O1 g% `- { printk(KERN_INFO "LED register sucessful!\n");2 m6 i4 H0 S4 a b* r7 m: L/ o
& e9 B5 a5 g% H8 \2 e3 e1 g
return ret;
! |6 R: n- \/ a% V$ O5 x6 y& f}
' X: x0 a" E# x0 b" q$ l( }- }
( n- q$ J, Z' Zstatic void __exit led_platform_exit(void)
( P6 _% e( Q% V{
. H- ]. i8 Y( [% V: _8 B platform_device_unregister(&da850_evm_tl_leds_device);
' N) ?0 K; H8 d
0 w; y$ A4 L0 f5 J$ @ E) y printk(KERN_INFO "LED unregister!\n");5 W* h5 E$ z: c. J+ O' c6 i
}
6 G% O U( w+ ` v8 s
8 \3 c$ Y" B3 H4 t( `# u2 Qmodule_init(led_platform_init);; P$ n; V$ ?5 z: p: x
module_exit(led_platform_exit);
* j8 I9 k5 a, L% ]. Q8 v$ }/ ^: [5 x/ ?
MODULE_DESCRIPTION("Led platform driver");
# S* k7 r X$ D( _/ |5 PMODULE_AUTHOR("Tronlong");) k+ ]) s+ M) p6 L f. F: H! p
MODULE_LICENSE("GPL");3 E L ]! I/ D, l
# h6 B# Q2 f4 A- b* y; L& n |
|