|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# \& x) g4 \) U% x& Q+ n" k
#include <linux/init.h>
8 T2 ~+ m; w$ y, |" T#include <linux/module.h>1 i& N& y2 h; c' W! g1 B0 U6 A6 |
#include <linux/kernel.h>) s# k* C4 F5 y2 H; V9 m
#include <linux/types.h>
. e* O$ Z8 a. k#include <linux/gpio.h>
0 h% u1 p6 v3 W9 z6 F#include <linux/leds.h>3 K! p: N/ J0 o* [
#include <linux/platform_device.h>- g4 Y& E4 d) M3 E0 M5 Z
9 N* C# Y/ l( q9 ~, } t#include <asm/mach-types.h>
3 {: ^3 E- X4 u; J2 _# @#include <asm/mach/arch.h>
! C$ \. X8 T& H+ y- K#include <mach/da8xx.h>
& D5 [+ t+ @" m& r#include <mach/mux.h>5 n: c7 _' j _4 d7 _# f
9 r5 f6 e% Q& o% f1 w5 R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 Z' l* P3 f9 [( l4 ~$ j$ S- e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- k9 u( V$ R0 D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); w0 H: A! v# @+ ?, t/ K' i _3 x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 ?& w+ s) G. D$ f' }1 M* O! P4 C6 Y) J7 f; V( ]4 L( A5 l4 e( A
/* assign the tl som board LED-GPIOs*/
) U O+ \5 f5 q" e) Dstatic const short da850_evm_tl_user_led_pins[] = {% z- H; z6 i% {: O
/* These pins are definition at <mach/mux.h> file */2 | X: ]& V( t, ^9 S! h8 {1 d( x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, @3 H6 s& V, J: b* L3 p, o -1
& [ P8 m6 q1 _};+ |$ q" ~# X: r3 r8 i5 \4 l6 U
% G Y a. q s5 e* e5 z9 A' \4 c
static struct gpio_led da850_evm_tl_leds[] = {
9 e% R/ g% T0 Y: X8 K# [2 p9 O e+ @ {
3 z1 ^4 s$ N; e0 ~ .active_low = 0,' {- W" F' T5 w2 m
.gpio = DA850_USER_LED0,/ v1 k" ^! x a& }) c
.name = "user_led0",2 ]1 ]; n0 X+ r+ I
.default_trigger = "default-on",
8 [0 h8 I$ G, Z$ Y$ Y$ @0 ^3 F },5 w" N, i7 N5 l
{
5 x1 x: L M! F# f .active_low = 0,# |; Q# D) R1 H3 E x
.gpio = DA850_USER_LED1,
3 P2 C. m5 f) k; Z .name = "user_led1",
$ N9 W( M6 y6 _7 H( W; I .default_trigger = "default-on",# R1 a6 t/ X) n% e
},
0 ~: w* W" a' V6 S( r. r {- x [& D/ z! P# O6 m$ z9 }
.active_low = 0,
9 s( E/ _! K' k9 n, x2 U7 h .gpio = DA850_USER_LED2,9 g' h( E6 X3 K: y8 Q, A. \
.name = "user_led2",
# [6 {/ r( h% Y6 C .default_trigger = "default-on",
1 g5 d; W$ v6 j+ D },
6 `+ p. ]1 w- S( k {
3 }" H+ Z2 M9 N' c+ n .active_low = 0,
2 G; l T, n. h .gpio = DA850_USER_LED3,
# m% @. h {( Q0 u" {/ n .name = "user_led3",
, L: R6 R) P$ K/ N5 G) q9 N .default_trigger = "default-on",
% k: C! z9 w: n0 _/ I9 l) k1 L },
, B/ l5 L; Y$ E( J' \% S+ W) p; O5 ~3 @};1 g: M3 T7 d$ n3 ~
0 d4 x# Z% A4 N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 ]6 l! n% [. J0 C ~6 } .leds = da850_evm_tl_leds,9 I! ?" H, [, C" u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ a9 [: I) B% J# h) ?* ^ |! @1 y};
+ d, S* R4 b) ]7 ^+ l, N3 h; ^4 e9 u1 H# `
static void led_dev_release(struct device *dev)% b4 p& C2 V0 c6 H e" W
{9 Y' j' {; A; R. M- L
};/ v; l7 E& x5 I/ T; [
' {4 ^7 E# g! s: W5 U2 M* a5 Tstatic struct platform_device da850_evm_tl_leds_device = {
& `- J) L5 q( v .name = "leds-gpio",
, p; A: z- c7 ?! @5 K u .id = 1,6 t" {4 X d8 J
.dev = {
# P. |( j& v" r" h+ t+ ?# { .platform_data = &da850_evm_tl_leds_pdata,4 M6 k& |& M6 \- ]+ E
.release = led_dev_release,$ O4 e9 S2 V( \* ~( D& y
}: H$ B2 P; D; g1 p8 L- D7 l
};
' S0 z1 E7 R7 B4 t: @% ]! ?6 P. h) L R/ C9 @ f; U& G! J
static int __init led_platform_init(void)- R1 Z7 l' j2 X' d9 H' O4 e/ q0 m
{
1 s+ y( `: T: j; x7 \/ L) D int ret;- p8 l1 ~' r# g
#if 0 [4 q8 |; h8 o2 }3 @5 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Q1 R( ?: f/ H' ]- w0 T" ?
if (ret)
! K) }+ B5 e. p. b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 i( c s+ l* b. A9 v: i
"%d\n", ret);
4 ]) i3 f; Y2 t#endif
7 c3 _' l! o4 } \' ~/ _ ret = platform_device_register(&da850_evm_tl_leds_device);
3 ~# W2 U2 e: h& \: D if (ret) Q% x& d9 e# W8 H3 j# r+ w/ \
pr_warning("Could not register som GPIO expander LEDS");
, r( U5 O9 q X. _5 D: V/ D# ^ else
% K- @4 \6 B4 X- [ printk(KERN_INFO "LED register sucessful!\n");
, [% l$ m Q8 Y. ^2 z
8 \6 |3 t+ T1 Y return ret;: c8 E1 r; X b) u' s# D( L
}
2 B& N/ k1 A* A6 y
6 D$ p0 Q h! Ostatic void __exit led_platform_exit(void)
6 |1 d& I0 ~& U4 W1 j2 e& [{9 t1 D6 C# e7 T& U
platform_device_unregister(&da850_evm_tl_leds_device);
1 m4 G8 t: h1 e: C: i4 c- p2 b$ q% [) _
printk(KERN_INFO "LED unregister!\n");) b* f/ }* d" \8 \# W# B
}5 l, G5 R' J6 p* _6 j& M8 H
' R3 @3 s5 z( |. a6 h1 @
module_init(led_platform_init); H. R& B0 s6 l: n( I) R
module_exit(led_platform_exit);
; I: l3 D9 ?& w6 V
! i: `" b$ W' E2 E3 i4 j' w& mMODULE_DESCRIPTION("Led platform driver");1 E: D+ Q; a' t0 M
MODULE_AUTHOR("Tronlong");* t# _1 M* _3 `0 A' j5 P6 C
MODULE_LICENSE("GPL");
7 ~# _8 k9 l5 V, e. L# h6 Z! h, b" L- T* e. I* j* N9 T w% V
|
|