|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; s8 L8 c# r i7 `% s9 p
#include <linux/init.h>
: ?7 q; k# H2 w: L+ ]2 j) f#include <linux/module.h>
7 s7 y/ ]4 {0 X. E#include <linux/kernel.h>: H/ O# J6 j; R' v
#include <linux/types.h>
+ p8 [" ]& U" L! p/ h. {3 D#include <linux/gpio.h>
: ]: I9 U7 f. `, u! K#include <linux/leds.h>
8 z; |8 X! b4 m' J% U#include <linux/platform_device.h>
: `0 `2 X& i0 N, q1 l! b6 s% h4 t( [, Y$ g4 _7 n2 r
#include <asm/mach-types.h>8 ?. W0 n" d; F* @1 Q
#include <asm/mach/arch.h>
, H9 I& s# X( s! n& d! U- Z#include <mach/da8xx.h>5 E3 H! b1 q( s$ n
#include <mach/mux.h>1 C6 c' [- M& P8 T8 {. ]
' k: A; ~3 C. T# M+ U2 r' d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 I: n! A( }5 w( I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; M0 q" k" p2 {* x! M. W1 P( o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( m* }+ a' l# @& S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- K: n: x& V! W" q* ^7 ?# g, b' Y
7 @, y" K* I3 ]/ E' q7 k9 x$ F! p; |
/* assign the tl som board LED-GPIOs*/8 D: W) |; s* D( \$ i# T* C
static const short da850_evm_tl_user_led_pins[] = {6 ~: Y- j l: ^
/* These pins are definition at <mach/mux.h> file */) {$ `. _- {! c: X" t! E, U0 J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; [; V; d' @) G3 ~/ i, e. z0 x -1& _6 x+ ^4 s, Z% c9 s6 D
};' L0 @- I: d% W' g: b4 R
1 I" H; w& e2 |5 H# K5 }0 Estatic struct gpio_led da850_evm_tl_leds[] = {! m+ i4 c$ A8 j' E) I/ [
{
4 a* t/ Y/ d3 d- S% W& b .active_low = 0,
9 X e8 f( U h1 M1 p .gpio = DA850_USER_LED0,
. Q5 z0 q- r( N( D .name = "user_led0",
* H! O8 a, |0 Y5 }+ k' w .default_trigger = "default-on",) G+ R% @! {" y6 e1 t
},8 t" b1 c1 s8 y5 a1 w
{
& N8 Q# V o- L1 e/ F .active_low = 0,
+ `+ r4 {* W+ ^4 o .gpio = DA850_USER_LED1,
3 n1 H* s7 \: M8 g- h* X .name = "user_led1",8 R L3 E# J0 Y6 w: o+ v+ M
.default_trigger = "default-on",
8 k4 V# Q7 `$ c },1 k9 W! K2 w8 \9 X3 f
{% H/ |& @" P8 @- y5 m
.active_low = 0,
$ U, S8 J: q+ A0 I, v' o .gpio = DA850_USER_LED2,, o* F3 P7 b; I+ [( R- I$ `) |
.name = "user_led2",' `& U) S* Q) J4 \( g: p* F Z: J
.default_trigger = "default-on",
( ^! _# K9 A! t p, N },$ z1 [/ p* G# a" U x% t
{
# W" ~: p- I0 ^% O* Z9 d .active_low = 0,
$ a$ S9 P; w$ ]9 o! }+ H .gpio = DA850_USER_LED3,
8 ?1 o4 o6 ?4 ~, L! n5 e# ] .name = "user_led3",: E6 E3 ?& k8 P+ F* X
.default_trigger = "default-on",' U: p- ]6 k; {1 K. B7 j' D
},
/ Q7 s1 E- j( Q0 i};# ^: E, o K4 h4 D5 w) ?- M
0 h" F a; ]( u( P% J) R9 v Z6 i& _- | t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* U# {) E4 S& U( `% l3 `' n' V, ^
.leds = da850_evm_tl_leds,4 ?2 Q& L- }$ x( G5 J2 p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% S9 d# f- ^3 ~0 v8 r
};& N" N- j1 V8 O. g |$ V+ C: H K
% C3 m4 b( R6 O, }5 A' G2 [
static void led_dev_release(struct device *dev)
4 Q% a! F6 J3 E2 p- [; q{* P- l5 J2 J: l7 Q
};* P0 i. D# B4 T1 O
, p% X! w% \3 K" b1 U* nstatic struct platform_device da850_evm_tl_leds_device = {- N' c( b) G/ K+ Y5 f
.name = "leds-gpio",- _$ }3 y$ ^9 {
.id = 1,
% J7 g Z* R$ p5 |" ? .dev = {
/ R0 T6 E( R& {$ m6 w .platform_data = &da850_evm_tl_leds_pdata,
d6 G% p1 V* H3 \6 V# ~ .release = led_dev_release,' M7 K- ]! L* U9 p
}
- I* ^5 ?9 ]- h8 l5 f6 r: Q8 M};3 x' O# Z+ u2 u8 q& {
& n( `% n& U& J6 @5 ^static int __init led_platform_init(void)* B% s- t ^5 |* t, \
{9 i: u! I8 r& {5 c/ C
int ret;
i i' s% h7 K1 w#if 0
- O; [% K( ?- ]& N& h2 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( K. Q `6 ]1 \% i, m
if (ret)8 o1 B6 G- [& L+ T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 `' P' R# p; H9 m5 t& w$ s5 |" d "%d\n", ret);/ g4 Z$ t% m8 ?4 H
#endif
& m: w0 @- l% ]5 V& S ret = platform_device_register(&da850_evm_tl_leds_device);
3 M5 q1 g. L0 x if (ret)- J* B1 \& O" x5 h: H( k- O: N, X
pr_warning("Could not register som GPIO expander LEDS");3 H9 N2 I2 p& Q9 w8 ?0 F
else+ ^# E- m/ f) I% I5 y+ V
printk(KERN_INFO "LED register sucessful!\n");: T4 t- {" l' b# ~ e
0 l. v6 J1 G6 _5 s" q return ret;5 M5 A4 x) {$ H; D
}
) ?# H& g: p8 T: q
' a) e3 I4 |# Q1 X5 ~2 Tstatic void __exit led_platform_exit(void)- @/ x$ g4 D: |( a
{9 j" E h2 A9 L: {
platform_device_unregister(&da850_evm_tl_leds_device);
2 ], p9 f) z$ n. o* J9 b
: c8 \1 ?: T! j$ s- J; N printk(KERN_INFO "LED unregister!\n");9 H, G# l, a9 ^7 T, [
}
! |& F4 P: }! E% p' u# X4 ]( y8 ?0 u
module_init(led_platform_init);# I! F# |" P# ^% @/ [- c
module_exit(led_platform_exit);
4 S# y. }1 w% }' i1 P' Z# R$ _) v
0 ? C- X* ^4 x7 h1 V L' ]5 GMODULE_DESCRIPTION("Led platform driver");
) c% S9 ~- v6 I) KMODULE_AUTHOR("Tronlong");
; T- z4 P; x3 F3 ?# u* ~MODULE_LICENSE("GPL");
9 k; H6 @6 b1 j7 t. \2 b! v4 `
/ \/ M4 K/ _9 |( ~" l4 ] |
|