|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" s8 C$ a" l. b! n#include <linux/init.h>
' q2 v/ X s7 _7 i( w6 _5 Z#include <linux/module.h>
. S- s7 [1 S9 @: K" O#include <linux/kernel.h>& h8 I4 A; W0 Q Q7 u0 w `
#include <linux/types.h>' H* A9 B' p2 ?& s* L6 v+ E
#include <linux/gpio.h>: W1 z2 E6 b7 Z* T& X
#include <linux/leds.h>
$ u5 C% W/ X( p8 P" W4 e; `#include <linux/platform_device.h>3 Z, b# D3 z% d c: J j
5 ~, m# h6 g2 Y! o7 ?# O$ W#include <asm/mach-types.h>2 {" A: q2 n) G3 S) R/ I
#include <asm/mach/arch.h>! R7 ~8 t0 v9 B7 r1 l/ q: m# |
#include <mach/da8xx.h>2 G: c& [5 R0 J
#include <mach/mux.h>4 @ f! o/ d& C( {
3 R+ ^- z3 f! B- `- H# ]" [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! p$ M* w, R0 n+ T5 I$ y2 F: M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) z2 g1 n. G; [- W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( l; E) f! r. a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- k. Q/ x/ t+ e, b. w; r+ O' U" v6 j7 `3 R) k+ ]- f9 I! ?
/* assign the tl som board LED-GPIOs*/$ |$ \* U8 C H9 j
static const short da850_evm_tl_user_led_pins[] = {/ K+ e' z; k# J9 a3 s
/* These pins are definition at <mach/mux.h> file */
5 E8 ?4 ?; ]0 [( g2 q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! t, e% \, l# l0 i1 e6 c
-1+ L6 m2 S7 j( P8 a2 H" V
};
+ g- A. W( `7 L$ R0 \: m4 Z+ v
: J8 B8 n9 m$ D' i8 c# Rstatic struct gpio_led da850_evm_tl_leds[] = {
1 t2 F# o _: M. @ {
6 x7 c6 ~' ^2 F- P .active_low = 0,% ` z8 m) O& E6 X- \( {! ]
.gpio = DA850_USER_LED0,1 o# I/ w9 G Z# D& F* t
.name = "user_led0",* H& B" j7 Z# Q9 F X
.default_trigger = "default-on",
D! I) H2 C- d# {2 ]4 @ },! ^5 j( _+ r7 v) d/ k" a& l
{: T( L3 R8 b7 _* w
.active_low = 0,1 c: x" \0 ^5 G; ?
.gpio = DA850_USER_LED1,$ l8 Y- p- S* K4 B
.name = "user_led1",; N5 p+ o6 j0 ^
.default_trigger = "default-on",* K/ P8 H* x. e8 b( U
},& I6 J$ f% N* @4 x8 e$ o
{
& X* B/ L I: L& E. i. Q7 C: q3 M- a .active_low = 0,
4 s; W; f5 H3 \' x .gpio = DA850_USER_LED2,
9 h( S% H$ F+ `: R .name = "user_led2",; a( ]" U2 A4 v( N5 A
.default_trigger = "default-on",8 y1 ~& S( ~9 y* t
},
; I z' t# g& p, R( J# i8 }+ P9 z {
4 D( H/ T+ ?% x2 `& e# z .active_low = 0,$ c' V% F2 N9 t3 m& M& @+ e
.gpio = DA850_USER_LED3,2 l6 P- N. S5 d* V' F
.name = "user_led3",
/ }8 g8 U# z6 l2 d. z .default_trigger = "default-on",
9 L, M* a. Y- o! k },+ V( q4 {& Z$ Q% G& `2 Y* d
};
% w& x# R5 o9 Z
$ ^& U5 R& s- pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 w6 T. p& y _7 ]" I# c2 y
.leds = da850_evm_tl_leds,
( H9 M) [8 Z: a, r4 B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 T- U7 l3 O* L
};, X9 Y5 ]* c9 W0 y' W% S9 z+ D
7 D+ R) u; _) M5 p6 b' U, R
static void led_dev_release(struct device *dev)4 v3 z( v' {4 e( K2 F
{* \. s, R7 A% e
};: n9 r! U# b$ m7 o5 f
3 j* t9 r! d: u+ h( T% `1 p! C/ Xstatic struct platform_device da850_evm_tl_leds_device = {! k) N. w4 C0 w6 Y9 u3 W5 E
.name = "leds-gpio"," K$ P5 v L- c2 E: ?( D
.id = 1," I! _) Q* V1 v1 r/ P- A
.dev = { j) T$ ^9 B5 s0 {& O5 N
.platform_data = &da850_evm_tl_leds_pdata,
* H4 S4 g& n2 X5 a& ~ .release = led_dev_release,
# ?8 R: q9 c1 A }
. `2 e5 b; f e1 {& ~; n* T};
' b3 l4 V* N Q- x9 {. x4 R- u
v: Q2 H/ Z/ @1 P( N \. J7 ystatic int __init led_platform_init(void)3 ?2 R+ i( w, m/ B* \, p! H* E8 o4 b
{- I2 R! |, K1 l
int ret;
; j% J# C- l/ [2 N7 |#if 0
0 |; ^( u- o: R! g2 p( T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 ?4 O& s! q% t if (ret)
0 y( n1 u% V& L {/ j& S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. _2 q6 B: N9 \- @8 p1 r/ U" I7 ` "%d\n", ret);
/ q1 }& v' E! Y! { ]#endif, @* ?, Y. J1 O5 ?$ x( a6 z
ret = platform_device_register(&da850_evm_tl_leds_device);6 A3 l& k) [, u1 E2 P
if (ret)
4 e2 Q$ |/ e8 k* k6 G- y# { pr_warning("Could not register som GPIO expander LEDS");
: b; Q' M9 g& a' B' i0 u else
* U5 s! N4 d: i3 d! g1 g# }7 h printk(KERN_INFO "LED register sucessful!\n");/ F5 [6 \, M* w8 X" q; r
& N( N% `3 ~ }/ k0 _$ Z2 R return ret;
" A$ r4 a) n5 q' p6 j+ A, d}
+ A; `$ _7 @, _: I+ {4 g" T1 `8 L" c1 I
static void __exit led_platform_exit(void)
- y6 D! a* M5 ^% p{
* v# D1 k. w: q, Y2 V% o- |/ @5 m6 D platform_device_unregister(&da850_evm_tl_leds_device);
5 V) l6 t6 U# t4 `& j @% M- Z
L8 ~1 @4 o+ D printk(KERN_INFO "LED unregister!\n");. ~# P' O* e+ V9 J. j3 n
}
% H6 P" l& Z. m+ p
1 N2 Y- P ^0 Z8 K+ H/ Dmodule_init(led_platform_init);! T( D9 s) S. l3 T+ L- k
module_exit(led_platform_exit);
, `3 Q# ^2 P( B# S
% \" K6 `5 ~9 Z8 |MODULE_DESCRIPTION("Led platform driver");" a; Y% ]& Q0 ~
MODULE_AUTHOR("Tronlong");
, \; E; ~0 C, rMODULE_LICENSE("GPL");' ]+ ]; A- ]- w T8 {4 r6 ]$ ~
+ S4 m7 P* L1 G# ~' g
|
|