|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ ~7 o: [( R1 W: a( Y4 \1 Y#include <linux/init.h>, \! |) X2 H; d0 H5 F
#include <linux/module.h>) T3 ^. R! G3 P2 s
#include <linux/kernel.h>4 {( {; u" o% n! i5 L
#include <linux/types.h>9 U' T, V$ j4 i. p3 x! n
#include <linux/gpio.h>) F4 q7 i( C+ o2 F% G5 m5 m# U
#include <linux/leds.h>
/ K8 `. a4 Y; T p3 D( m#include <linux/platform_device.h>' K( `- p. ^- S+ }: e- U
0 H7 R" J: \* a! e, \: j& n/ J
#include <asm/mach-types.h>6 G* ?7 ]' y- K! u9 a% U8 _2 S
#include <asm/mach/arch.h>
9 j% Q2 ?% j; B: z#include <mach/da8xx.h>
f( P# m/ F6 C# I#include <mach/mux.h># B7 i+ c$ r* X5 w7 H9 r5 [
# V& l6 S) O+ j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 A' g7 c4 D: s1 w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; D& E2 @: V5 X; d- O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 b6 E9 I( ^0 `" d. T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! ^8 G b+ {6 m' P+ e
- h9 i+ A3 ^$ |
/* assign the tl som board LED-GPIOs*/
7 L5 M& o- ~, q$ [5 U8 H; U* f% Ostatic const short da850_evm_tl_user_led_pins[] = {% D. p1 L* z8 i2 v9 a8 Q
/* These pins are definition at <mach/mux.h> file */# M6 t0 a- u2 O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- T5 R* W4 o2 o- k' t9 P
-1$ L/ k0 B3 ~3 i1 f" U ~ f. t. ?( q
};
/ W( V9 I9 z! m' D$ s& I0 |6 [' {" W: s, D6 t" T
static struct gpio_led da850_evm_tl_leds[] = {
- W* Z5 Z- j. Y- Q5 u) h {- ?6 X+ e% g* }( X% T( o& p1 p6 A
.active_low = 0,$ @( |9 ~, e/ A+ ^8 F- n6 @
.gpio = DA850_USER_LED0,* ?2 I% m5 p* B0 F$ R
.name = "user_led0",
@. j, R$ ?1 |8 `) p. S .default_trigger = "default-on",8 b6 f# Z/ Q( {+ G& Q& Y$ n
},; w. ^, |$ A& W5 k7 H3 L5 x' A
{
# q2 t! `( c- y .active_low = 0, t/ t6 A$ n; z3 Y& g% ~
.gpio = DA850_USER_LED1," Q& t- j Y, U, r6 X% ^
.name = "user_led1",
1 H5 S2 Z3 q0 t .default_trigger = "default-on",5 e1 \/ e3 |) y& x
}, h+ }5 ]6 R! j
{
6 E( ]. L9 \! Q* B5 o8 {& E, c" \% w .active_low = 0,. C' g3 i& ~& C
.gpio = DA850_USER_LED2,
2 N3 x7 {, w% ]' C .name = "user_led2",
8 H/ d- q, B4 V" |4 O& E4 l2 r1 y- e .default_trigger = "default-on",
, x0 x7 X0 }& k+ Y* S4 f5 g0 ] },! l& j2 y# b' d0 ]" Q
{7 w1 q/ \' O$ z
.active_low = 0,
$ ?7 f/ ?' ]. u, E .gpio = DA850_USER_LED3,
0 Y( S* `! F9 S6 p" ~: A% q" U; { .name = "user_led3",
* |8 ?" P1 \" k" E .default_trigger = "default-on",
+ u8 B% @ V6 d2 R7 ? A6 `/ G% d. ` },2 `5 i. n& g9 F2 t- G
};
Y1 V) [0 T% ^ N: s G( V$ i& S6 \$ l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& i( z0 A# |7 a7 f: B+ e9 n1 v .leds = da850_evm_tl_leds,' p4 \, A+ ] W/ t) _2 k4 S' ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! j) R, D7 Q8 s2 W5 ~
};% N3 a6 l0 {) k. c
Y6 V* T8 G$ A+ \+ G( K+ i* Hstatic void led_dev_release(struct device *dev)! c' Q1 s( ^. G0 w9 G5 P3 U H; c& a
{
% B) y$ V' g, p5 V7 Q! z" w};0 w8 y3 y* P( q" }/ j* @) c' U$ W
; `: j# _) ^ d( d- {( l
static struct platform_device da850_evm_tl_leds_device = {; h! X1 |9 ?( M. |! S, C- r+ X
.name = "leds-gpio",7 X! j6 L: ^* s x
.id = 1,2 Y5 L" i( i* V) M: j
.dev = {; b; N f% C/ Y% E$ s$ N
.platform_data = &da850_evm_tl_leds_pdata,' P0 p# J. [0 E, p
.release = led_dev_release,; A$ ~: G: y2 S
}
0 L: Y+ ?' e9 A};, @9 n: K" J, X. ?4 M
& [* l2 H N& p, D' z4 a9 U8 s9 k Tstatic int __init led_platform_init(void)9 y# d {' E6 Q- L* H3 H
{
, ~' f. n- M* R$ x: n g int ret;
8 R; F0 _6 H$ R+ k#if 06 {9 |8 a, e0 }1 R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 L- e# V% O2 J: X. z if (ret)# ]( f. H9 D. t5 j% h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 _( a3 A7 g0 q8 e6 } "%d\n", ret);
( ^& t( C, X- M#endif
# k8 G6 a; \2 c- ^5 C- W4 P ret = platform_device_register(&da850_evm_tl_leds_device);
4 i K3 ~- G! `$ f! l+ |- k if (ret)# B* J6 ?) _ U: |# _' c
pr_warning("Could not register som GPIO expander LEDS");7 n' K( A4 c4 K* q7 H2 q# _8 x8 r
else
& ?( ]% \/ u" K' b2 w, N printk(KERN_INFO "LED register sucessful!\n");
/ Z% v, [2 `# I! |
/ L- Q+ x5 H* S5 N return ret;& Q" U* x$ S7 Z; H' H- p
}
4 `" E- N" ~$ ~- x1 \9 h7 N7 W! x9 Y% r9 V: s8 z2 _4 {& }
static void __exit led_platform_exit(void)
4 i$ |+ y {* x' B( X8 i1 P' O{0 S( }) }+ D# i+ C/ P Y- u8 u
platform_device_unregister(&da850_evm_tl_leds_device);
0 {. ]- V5 ^+ B+ I; g6 C& Y* c% |4 n; N* v1 J! u: w
printk(KERN_INFO "LED unregister!\n");/ J o3 d; i: H! l) w
}
$ Z4 S# B# ^5 Y1 h, w9 L C$ b4 i, \0 q. g
module_init(led_platform_init);
0 E0 o1 W) g4 x- x) r! Imodule_exit(led_platform_exit);2 R* x, L: w+ g- W9 F/ J7 U) i
; O* a' y+ M& D5 ~& `: k
MODULE_DESCRIPTION("Led platform driver");
, d& A; Y' A, [0 O/ F# gMODULE_AUTHOR("Tronlong");
" C# n0 l: \# H' ]MODULE_LICENSE("GPL");9 \$ G" h4 J! T8 I' `; E! \
# s; [) r; y( Y+ W2 n2 i% F
|
|