|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 }7 I$ ], X! l M' V1 j#include <linux/init.h>
8 G# g8 F- e+ w: i9 [#include <linux/module.h>6 S/ X$ }# c3 ^: [' d& [8 J
#include <linux/kernel.h>: {7 r1 O. V+ h
#include <linux/types.h>
5 F3 \, V# Y: D9 t#include <linux/gpio.h>
( }$ P1 i8 q/ _ q# C% D#include <linux/leds.h>
$ u* s8 U: X% J' n#include <linux/platform_device.h>. N- y# K @* g5 H
" z( v0 o( Z7 P9 @9 q) x
#include <asm/mach-types.h>
. Y) h$ z0 g1 W8 y#include <asm/mach/arch.h>$ {1 n+ k0 r; T5 f% Y& M
#include <mach/da8xx.h>& p( c0 ]7 |) a6 R! @( r# N
#include <mach/mux.h>
7 j( d6 i- @4 o
( y, [1 _- O& j% r% l. @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& T$ {6 t% o4 ]$ v6 }* _ L" X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 o R$ v4 k! n# v1 v0 C+ t, e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 Q- C. J. \/ A/ c4 T) x( C, b) [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. R4 e5 ^0 A2 i3 p3 t- z+ i& Z5 J$ G" H' [8 u/ i3 l
/* assign the tl som board LED-GPIOs*/
5 C0 x1 Y3 s2 G: f' \! zstatic const short da850_evm_tl_user_led_pins[] = { ~/ G0 n3 q3 U: S3 Q
/* These pins are definition at <mach/mux.h> file */4 D* l% z9 P4 Q, F) y* D/ D) X7 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& m) B6 n# f, i' u' O -1
2 N' t1 f% r! \- g};
8 Y; j% `" [5 J' d1 ?8 t
- w2 ~+ a# r# Q* ^/ fstatic struct gpio_led da850_evm_tl_leds[] = {; N, `5 h7 H' A) b$ [0 |
{6 o9 {3 w! _) @0 c
.active_low = 0,
8 u3 Y! b0 R/ b3 R) q .gpio = DA850_USER_LED0,0 f; F/ q+ C% B% n
.name = "user_led0",6 h( p* Q7 s& O% L* S% M1 ?
.default_trigger = "default-on",
* i! Z2 B! x9 `9 y/ F },
- q4 m9 l) ?# S7 T, C: [ {- Q) w2 H( a0 t- Y; T
.active_low = 0,$ N/ v, h8 D4 d7 y! F
.gpio = DA850_USER_LED1,* P- W, p( v3 O0 K& e8 V- q: l
.name = "user_led1",5 z" \4 n" c0 n+ J0 y; ]
.default_trigger = "default-on",9 [2 S, Y, X& n! {& v. ]
},
. l2 U0 c; R8 t4 f {
0 R, C/ I* j* ^; R( Q$ D2 w, F .active_low = 0,
- j, I2 ^& r# i, r; h2 u* v. q .gpio = DA850_USER_LED2,7 w6 N6 p* Z) O! j/ j5 P
.name = "user_led2",* F9 q$ x5 ^4 @" g7 t W
.default_trigger = "default-on",
- u7 G& Q3 n6 e8 _9 X. _! b! ` },
' y8 x& I9 X5 ?' W {: T/ B0 J4 H% t
.active_low = 0," B5 e( P% o7 t
.gpio = DA850_USER_LED3,) j0 N. h9 d- _+ P6 r6 e
.name = "user_led3",) |2 B# @6 w) H! |/ z
.default_trigger = "default-on",* v# S4 i }! v b
},
# ]3 a) ^& f! Z4 l7 g3 H};+ Q0 [3 f; o' b j, s. l, k* \
, U. i& {8 k$ f4 m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ B% x: I- ?* A% n6 k, p' b0 M- V- N
.leds = da850_evm_tl_leds,! J$ l# y# W; R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! w y1 a g+ w; t3 Z};
: [3 t' z- d7 k8 y. Q+ d- w$ e- ]4 s& V% |2 s$ c0 ?
static void led_dev_release(struct device *dev)
7 z8 K( G6 N$ T3 ]0 _. @1 q0 F{
& r; [* H; g7 ]; N};
; n' j M, ]' i% f
+ k; M i6 L& l3 C3 K h+ _static struct platform_device da850_evm_tl_leds_device = {
4 |; ~% I8 B) A: n7 i3 M1 E .name = "leds-gpio",
; o& p3 {% }+ \+ D .id = 1,
" v; U7 l: |; g; S .dev = {) c/ e- `1 F4 j- Q
.platform_data = &da850_evm_tl_leds_pdata,2 J" a5 x9 n1 C( M) |* o
.release = led_dev_release,! V5 Y% h* S# y7 @4 B+ g2 `" u
}
- ^" t, P' {& {};
. ~# V" n4 ]( H& _4 O& J5 Y7 Y8 l1 C
static int __init led_platform_init(void)! T5 `' z' V0 W2 _$ B$ i) M
{/ d H+ y: m1 f8 O- f
int ret;' A K8 z) N& @2 M% g
#if 0
/ d; \8 s; h4 ^9 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, q+ f1 @3 W6 y8 r& N if (ret)) ], b; A; t0 j0 S. {3 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& T8 e( [% y7 |, ~ "%d\n", ret);
" T% a; [" u+ w# ]2 N#endif" `7 v0 ?. U: I
ret = platform_device_register(&da850_evm_tl_leds_device);2 p& e% n: u- P/ l9 d& B
if (ret)) ` s0 {" G! H" }* x
pr_warning("Could not register som GPIO expander LEDS");/ [$ `' B9 Q' e) ~) C5 |6 F
else( \* k6 s0 F0 e; Q
printk(KERN_INFO "LED register sucessful!\n");
! y; H, X3 Z& v3 y! Y+ k$ Y
: t {% @) F- ^# C9 F5 ?4 m n return ret;- {7 m! I; D& H. d- q
}
3 P' W& k/ x5 e- y) L3 R2 R, X9 [: F8 h
) j: A3 R# S, B @* @, l istatic void __exit led_platform_exit(void)0 ~7 h) a" ~5 ~0 V: ]) ?5 _8 ]; L
{9 g' s$ h3 J3 S* X+ r
platform_device_unregister(&da850_evm_tl_leds_device);: G7 W! ]1 h( g4 R
- d0 |0 w2 P: t4 Q& a
printk(KERN_INFO "LED unregister!\n");2 @$ v' I' N* x0 d' n/ ^, r, d3 x
}
! x$ a& Q. H3 g9 S% |# d
& z8 I2 K3 B% R. H# v$ x, hmodule_init(led_platform_init);
: \ S; h6 d( M* m4 L+ hmodule_exit(led_platform_exit);
! Q( ?1 i! d4 ~* \: l2 r" s8 u$ d
MODULE_DESCRIPTION("Led platform driver");
" b2 ~3 r {, X- \' `2 t- z/ u" gMODULE_AUTHOR("Tronlong");" D' m3 K9 v$ K& [
MODULE_LICENSE("GPL");
" R G0 I" {; o G/ j2 I8 e1 }0 m9 N5 S) L3 Y$ v1 c3 z( X$ j
|
|