|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ f, P. o( T) I$ O! u7 e
#include <linux/init.h>
" G4 i; g& S$ {- P' |7 x#include <linux/module.h>6 x( c6 N( @6 `7 P& ]1 y
#include <linux/kernel.h>& F, x, G: m+ d0 m" N5 h& ^
#include <linux/types.h>% X4 b, v9 z* K
#include <linux/gpio.h>2 n: g B, h: K" e( Q( q3 D; E
#include <linux/leds.h>
/ G$ r6 S1 C& E# c8 R( Y#include <linux/platform_device.h>: n( I$ |6 u8 @4 T0 R
5 A) R* g! U/ j* i {
#include <asm/mach-types.h>, q% S" h+ `' U9 E+ S0 A
#include <asm/mach/arch.h>; A0 L! X; N( x) I
#include <mach/da8xx.h>* o' T7 l# _/ A5 ~
#include <mach/mux.h>
8 |6 K4 z; e( w0 H! I3 {) l' m3 u$ O* \( o- q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 i0 K, o$ c, J: v# [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 T* o! ]( `- m! G% e' [* L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* m4 i9 M; Y& T. \/ K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& U3 [! D; ^( ]0 Z0 ?2 i4 c+ e
6 w: y* q* m. x" x0 c
/* assign the tl som board LED-GPIOs*/! R0 k2 ~# |7 u+ D
static const short da850_evm_tl_user_led_pins[] = {
+ F5 J) [0 O( `9 { /* These pins are definition at <mach/mux.h> file */
c' h) I# I2 X. n: @: G1 e% f: N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! k- p! A5 q, c5 P4 Z1 Q -1
: _" Z$ k' w3 H+ ^$ |, w" [- f3 G};
. b7 H- u9 L0 m& q' M% Y4 P
& O4 i% _* ` O' ~static struct gpio_led da850_evm_tl_leds[] = {
/ l' m% y" R/ Z6 y- j {2 E0 q' @5 o8 e9 T0 P7 T+ v1 Q
.active_low = 0,
" \6 A4 ?0 _$ S/ C- k .gpio = DA850_USER_LED0,
1 ?, p& s9 W6 S& c .name = "user_led0",3 L! \& L4 x9 x0 h2 H0 s
.default_trigger = "default-on",/ i$ u0 L _5 n/ ]! C4 i
},: |" t' ?+ u& o" Z% N
{+ M0 [. P, @* m G; F% o% g! H% K( z
.active_low = 0,
4 b2 O9 q, {. I8 Y7 ]4 O& [ .gpio = DA850_USER_LED1,
2 a. S' }( E/ \ .name = "user_led1",
. w$ x: ]/ Z# Q .default_trigger = "default-on",2 z7 s r8 Z, N& Q- a; ~7 r4 o
},, d/ B8 j. ~( ?3 q. x
{
4 L$ r9 Q' e5 L& m) x- S9 T( f2 A* D .active_low = 0,
8 f, P7 B2 G1 ]6 E9 n .gpio = DA850_USER_LED2, ?9 g1 [5 w1 ? X
.name = "user_led2",/ R$ \5 `6 q: ]. n3 g' `
.default_trigger = "default-on",+ [/ b& N5 x6 P
},) g2 \, y+ Y) ?8 h
{
3 {* U/ ~9 v" ~- l .active_low = 0,
# P! j! r) r& t7 A5 p% a/ h .gpio = DA850_USER_LED3,
5 w8 R3 s D: Y4 @$ e! Q .name = "user_led3",
b" L/ K- u3 C0 F6 I" l0 t. Q .default_trigger = "default-on",
' z/ l' t5 H; L, P, b },; u' E1 t( j, U- S W1 M
};
* z3 Z9 n+ e. Y& v& r! p+ a! [9 v# I/ N+ r/ W( S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& Q& I R" m9 V9 _4 T0 b
.leds = da850_evm_tl_leds,3 x4 R2 `2 L T( q1 o2 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 g. o; L6 W0 Y: ^6 E};
: b4 p, c% X. [/ X9 ~4 v( n. n
3 S, Q3 z! f" J% _+ B; ~5 w% f8 Lstatic void led_dev_release(struct device *dev)5 Z0 N. q$ \$ M5 i# I
{
- v4 u2 y. \8 J' T* t};
7 v0 y. [* |. O4 o- [- @1 S1 U* f4 c; f' {& W0 k c
static struct platform_device da850_evm_tl_leds_device = {
5 w9 L. k0 f: l .name = "leds-gpio",$ g* J& c/ x0 w* z
.id = 1,
$ k' P( {( q! z' M! \" u .dev = {
3 m% [/ I* h' B0 ]2 @! V e .platform_data = &da850_evm_tl_leds_pdata,) R8 y# r" t* U0 w& @0 \. B
.release = led_dev_release,# |# z3 h1 p" E4 F
}
6 e$ l) S8 h" N};
8 ?2 S' Y b9 m$ v! Z7 `% X' J) H4 k8 a; L
static int __init led_platform_init(void)2 y2 T4 i; h# x4 j: r4 p( `% a
{, N0 \# K; V3 X7 T! A
int ret;/ X+ m \, k4 [, B( g6 r
#if 0
9 J: N1 j. c, Z1 | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
[9 H% F S ~8 U1 y. Y4 H if (ret)2 h' L5 w4 u% C( C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ O2 `; E9 d ^% W8 R* |$ a
"%d\n", ret);1 A8 `% H7 I3 s% u- C- H4 X/ p/ E
#endif9 S8 p+ k8 M8 U7 p
ret = platform_device_register(&da850_evm_tl_leds_device);/ H4 _6 o7 g2 K( p/ ]. `& X
if (ret). L( w ]) i2 R. }3 Y/ S5 |; p. \
pr_warning("Could not register som GPIO expander LEDS");/ }$ U: A- f8 V. s
else7 b* H* r5 c3 q# b- V) _
printk(KERN_INFO "LED register sucessful!\n");
. j" t% c7 a! l& |7 t& \! b6 J
8 S4 ?. I1 i% A$ e& f return ret;; U/ v4 h8 U8 l, A! b
}; Q5 L' J% h# p% q6 ~
( m) g& {1 d$ O# {static void __exit led_platform_exit(void)
$ J0 e, o' S4 J5 \{
9 H: e) b, J. d$ s0 M0 \ platform_device_unregister(&da850_evm_tl_leds_device);4 t* U: q2 l% T' z9 U$ G
% B: L4 @2 i( M
printk(KERN_INFO "LED unregister!\n");
9 U% ?3 {: U9 |6 A1 x: P+ L8 u}6 f; ^' y: j' t6 Y) y" y
, o' \5 r+ n. q% Z3 xmodule_init(led_platform_init);5 \2 r h; X: q1 I
module_exit(led_platform_exit);" H6 r0 x% W* ]$ J: }% O7 W# E
1 N) }* V4 @6 Z& b1 v u# z9 kMODULE_DESCRIPTION("Led platform driver");
. w/ k) c" b7 a/ h& v2 rMODULE_AUTHOR("Tronlong");+ \7 t F6 v. u, r
MODULE_LICENSE("GPL");7 F% F& N/ k/ U, g
" {6 x" E0 f3 `! F0 u) P! I- } |
|