|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) ?0 Q7 q1 d- n" n0 W; g9 }5 x#include <linux/init.h>5 @: x, K# l1 p- J4 {
#include <linux/module.h>- U, L* L& k! A. M7 l& q
#include <linux/kernel.h>
8 [, K3 Y: w& P" K2 b. Z#include <linux/types.h>
' C' s9 N% d! O$ L# p#include <linux/gpio.h>" A1 z ]. ?# x ~$ i6 ^2 d
#include <linux/leds.h>0 |3 Z: b$ h [8 C; q# |
#include <linux/platform_device.h>
7 q* Q8 w' P& B) D, |* @& C* f2 x, [# o# T
#include <asm/mach-types.h>" X' y s4 t8 F2 u3 j+ A
#include <asm/mach/arch.h>
2 s" U, @" r' u) B2 U# U#include <mach/da8xx.h>
: ?) b, N: G/ F#include <mach/mux.h>
( B, f- J% {& V* n* ^2 B. n. {- v- m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), Z# G" t+ B, |# ]+ U( X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& r4 y0 }. F+ r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). g: h3 Y. t& E7 T" L, W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ A6 l5 M$ U6 n
! ]9 k5 u& Z/ v9 J. ^2 x* `$ T4 e; i% i! h/* assign the tl som board LED-GPIOs*/7 `9 j* \( W# ?/ u
static const short da850_evm_tl_user_led_pins[] = {
* a, R ?1 o$ x /* These pins are definition at <mach/mux.h> file */
* k9 K: D! H: p) I! V3 f( w q$ H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; Z7 h" x8 z& _" W) W7 U -1
0 p1 B9 [/ Z1 U. Z- D) J8 w};
5 N' |. f* p+ s* c, V k/ d r0 x- j6 X$ m1 k/ S9 {9 n
static struct gpio_led da850_evm_tl_leds[] = {7 n5 C4 z: ] k4 @( Z
{; P" Z1 J" e' y$ y
.active_low = 0,
1 J$ Y7 a" D t; c$ f' E, M' F .gpio = DA850_USER_LED0,
: T4 `) R5 A0 q' u; @ .name = "user_led0",0 G% X. [! x5 e% @; J' L& N- ]7 D
.default_trigger = "default-on",( x9 l* h7 U' f8 w* P/ {
},8 c) F( `: i) s; }+ _
{
- x' i1 x0 Q" H- i' m8 n5 V .active_low = 0,
, h3 c5 |! W& [" P x1 l- r7 t .gpio = DA850_USER_LED1,# A; ]4 z- U$ t, ~
.name = "user_led1",
5 w& s0 O; g. e" Y .default_trigger = "default-on"," X8 o( S, t0 K$ l
},- T. h! p# |: M/ m/ ~9 o3 C/ l
{
6 A4 [( v3 }- T: _# T, ^ .active_low = 0,1 Y+ E! S: B& L; k* y
.gpio = DA850_USER_LED2,
( V5 u- f- W4 @ .name = "user_led2",
, }7 ]4 o& d$ j2 S* ^ .default_trigger = "default-on",, j4 t5 }( @9 k
},
6 b- u3 c' t; d" e! A1 y4 C: _ { H2 k6 ] w+ l9 X
.active_low = 0,) h6 _* V% N+ r
.gpio = DA850_USER_LED3,: _/ k) ` h ]! x5 ~ }
.name = "user_led3",
3 r$ v/ T0 ?* S% F/ k r* ~, _ .default_trigger = "default-on",9 m2 w- j, u, j" Z: m0 x0 Z9 S
},- F- O: B+ |; n _, e! k; v
};2 ^( l2 k* P2 B6 `: v. _% O& _& r
" r' F. a. A+ b" astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 U6 l: C1 g: ~* ]; ^4 N* o .leds = da850_evm_tl_leds,+ c" n- a& E9 m$ x8 }5 i' f2 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# `) U9 i |! a$ ^' n) e};: n4 X) F. O- U; i. ?
' A% v) n' ]6 ~: Z. D. Ystatic void led_dev_release(struct device *dev)
- J v$ l7 N0 z' `{, o- x( i& r* ?
};
! q' s3 y$ y& u+ D# T! M" [, t% F3 Y) `! d, O' U' }2 A( E3 L; B
static struct platform_device da850_evm_tl_leds_device = {$ L# K+ y E7 H. C# K
.name = "leds-gpio",# \; s, K+ f6 r/ ?8 t/ i6 o1 e+ t
.id = 1,
1 x1 d# G6 c8 Z; d9 h3 c4 O0 C; k9 n .dev = {$ d# ?% F: b, `% Y) |
.platform_data = &da850_evm_tl_leds_pdata,
2 a3 `. n, x1 @& \" v' p6 c .release = led_dev_release," n0 J) E7 U( H: R
}0 I0 w& t% F4 ~' `: }
};
& O b; e. w( I' D7 x; t, {4 B* }5 N) P9 w# E
static int __init led_platform_init(void)! B- ` X3 u4 Z/ Y4 o7 ]$ v
{
' J, i7 A/ a& D1 j int ret;: c* g2 O$ C8 F; y1 G2 Z% r0 u
#if 0& ~# Q+ J, j2 u P' P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ p( A/ H8 ~1 g1 v: I
if (ret)
0 K& M s1 R5 o. l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 t& D: C* c. o. o D
"%d\n", ret);: B" N, V/ v4 _* s4 c9 [7 k- E$ q
#endif: a, ^' M3 F+ P
ret = platform_device_register(&da850_evm_tl_leds_device);8 M" C' H. g7 F0 Q5 u
if (ret)
4 m# ~. j/ W d9 ~ pr_warning("Could not register som GPIO expander LEDS");9 _) ^% o0 w. p/ W3 b ]( w. { ~5 d
else
9 Q2 U: l Q9 S printk(KERN_INFO "LED register sucessful!\n");+ P1 U4 v: h8 r/ o
+ ?: r4 A" Q( S/ a: V3 j
return ret;$ d: u u: D8 c
}
6 N5 K( }1 p/ I) J3 K* n( v% m# P6 S7 Z' k1 b- r1 A' k! o, ?' `- Q6 [# A
static void __exit led_platform_exit(void)) C4 h; ?! A7 Q1 _+ i2 n7 q3 r
{/ H7 g7 P ? J. V/ D& `; }. j
platform_device_unregister(&da850_evm_tl_leds_device);
: V6 N* o4 Q# l' W* |3 M/ g/ f* N% d2 D. R' q
printk(KERN_INFO "LED unregister!\n");3 E$ S; H# a7 e$ U7 L
}$ L1 F) n# V' M2 N
0 n" M, Y& S# K4 Qmodule_init(led_platform_init);
{/ Z8 r7 F, y# S7 z/ U/ cmodule_exit(led_platform_exit);- d* Z$ r' s* W* d( p r9 Q
$ \( O) g0 M8 Y$ }* k0 s) ~MODULE_DESCRIPTION("Led platform driver");* S3 {4 x5 M3 ~- |
MODULE_AUTHOR("Tronlong");
* \% P. S8 r% ]% m) C% q- t4 H& uMODULE_LICENSE("GPL");, K: H) j/ y% G' l
* H8 N! x% U* `9 ]9 l |
|