|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" @3 A6 ?/ a! f" h' x' A
#include <linux/init.h># m7 @5 C3 T$ d: L/ o
#include <linux/module.h>( W& K) y* {' W0 W* D, S
#include <linux/kernel.h>9 D! d' B/ {6 C5 [
#include <linux/types.h>
4 e6 b. \. L+ o' B# C, m! |7 U- v#include <linux/gpio.h>
4 u r4 L! Q* t; p* f" i+ g% l. k#include <linux/leds.h>
) T1 N2 \$ N# D- O+ {& d; O#include <linux/platform_device.h>
. r5 f$ u! g5 F- P" U/ [1 d+ _' h; i \" Q+ G, f
#include <asm/mach-types.h>
( b0 W# n& E1 I! T( W- g' }#include <asm/mach/arch.h>
8 [3 b$ r- d8 V# _( s* V' m) V) A* w#include <mach/da8xx.h>
: m* \7 E" i" z8 K( @' ^" c) X7 N#include <mach/mux.h>
" l$ M* F9 V0 C) N' B
5 I2 L. J( F/ j! Q" W z9 _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& E" ~0 w& S5 T) S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- ` N+ q4 t" T5 T3 O5 M, B. k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# y7 Y& F; i0 E8 P& d+ _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* H! U& F) f- R, j) k2 a5 t
. ~& a7 N! U9 N- w/* assign the tl som board LED-GPIOs*/* x9 R% h" Y$ R% D$ H0 y0 `
static const short da850_evm_tl_user_led_pins[] = {, a3 K7 m0 @5 [9 g5 O
/* These pins are definition at <mach/mux.h> file */" \/ G1 v% F [6 p5 a$ [6 `* D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 ^ x1 z) V3 V) x -1
6 v' w$ X: j3 M8 _3 v};
; x1 ?; `' ]5 U7 L3 [: ^4 E9 H8 Z% o: t( u! @9 ~2 D2 V" m9 \, n+ G
static struct gpio_led da850_evm_tl_leds[] = {
. r2 y4 w o# { {
2 S K# o3 a8 N& c: H .active_low = 0,# b! v, [" B1 e2 l8 P$ |
.gpio = DA850_USER_LED0,& j! e- t T& n6 l7 ~$ M
.name = "user_led0",7 ], y. O: y; w- S
.default_trigger = "default-on",4 e- W F0 z5 J C4 D4 A" H- {! I# T
},
; k F8 N' w$ Z2 B. c {
& A8 G- ~5 b O' V& u% e9 B' e5 e: M .active_low = 0,
1 ?/ ^2 J% K8 ]* G# [ .gpio = DA850_USER_LED1,
" a* ?* @# s! E3 u7 A! j5 d2 o .name = "user_led1",! M( b/ X; F- v( G. W
.default_trigger = "default-on",5 C0 P/ i4 j( x4 F1 {% s( O% e5 J
},% ^$ I! E) l" g+ b0 M; o
{) O9 D! g7 |- `; W9 U4 Z X. _6 ?. s3 P$ I
.active_low = 0,% ]* J6 b& w9 F5 o! S% ?
.gpio = DA850_USER_LED2,( K# o8 O9 ]6 i! p: f
.name = "user_led2",
3 q. E4 k# T. t9 H- h- N .default_trigger = "default-on",
# u4 o- `; c. u% P' V1 l },
- Q$ [' s# Q, y7 C3 y. r1 I2 W {% G6 H! N' _9 ?+ f
.active_low = 0,
& r* {1 g0 J0 D! w& l+ D$ R5 R .gpio = DA850_USER_LED3,% b3 R% c" h$ |7 S: e- G
.name = "user_led3",
5 X) U2 E! O4 ^" T. p0 {' n .default_trigger = "default-on",
" }, m; C$ r( }2 P2 U },' E& ?% [; s: T1 Q9 |
};: \0 x2 }: M0 x7 R
. S5 _! `3 ~, v5 A! a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 M- z( n. ?" e6 z' a+ Y
.leds = da850_evm_tl_leds,
/ m9 p2 i2 E. z, _, U' |7 q' L$ { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( ~$ g2 B! K: `6 ~! @7 C
};
$ T) P; C# T8 w: g! e Z( Z5 z4 m
/ K: a6 B; x4 p' j3 [' Istatic void led_dev_release(struct device *dev)/ Z U$ M+ n/ z( I2 i
{
! g D/ Y, y- Z3 ]2 B4 _9 i8 Y G. k}; E1 R; \9 W# L$ o/ s1 R; H
- d$ }( e' j: l) W. }6 h( X0 K
static struct platform_device da850_evm_tl_leds_device = {2 z* M: X X1 F8 P
.name = "leds-gpio",, g/ W6 ?0 x" d1 P8 E6 @( @. e
.id = 1,
6 R6 D; d9 m9 M' Y+ b! @ h .dev = {
1 g9 _7 {$ M5 t7 p( I% g .platform_data = &da850_evm_tl_leds_pdata,
: A8 g3 e2 V% `8 b2 s3 x0 q1 b7 c .release = led_dev_release,' ]( s! {+ j4 s A8 ~5 K2 K8 I5 w
}: e2 o8 l2 {8 ?% O! }
};, E, y" @* L8 D: v" J: r m
' ~' `) @% h. E# D* ?2 Y2 Lstatic int __init led_platform_init(void)/ T4 x6 A5 N5 b
{& U& B4 w" z8 {9 q" A/ f. k8 b
int ret;% x* R, P/ @- h- r7 p) {
#if 0
; E. o9 p4 \, C1 @ h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" C7 x, J' q' g2 u! _+ e! a
if (ret)
) G! i+ O( v8 m/ Z. A2 d) m% C- @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) u) ]9 \. P3 \ "%d\n", ret);; v2 e3 S& w& {9 O# R3 k. S0 e
#endif
: G+ w9 `9 `! B K1 G ret = platform_device_register(&da850_evm_tl_leds_device);9 u9 N% ~3 Y% _, `" |
if (ret)
/ X. l& W: Q0 q* k: O) E pr_warning("Could not register som GPIO expander LEDS");! P* a B! A+ Y% m
else
9 L2 i# c: A! Q9 [& `( k* m printk(KERN_INFO "LED register sucessful!\n");
3 W) O9 m: Y6 D/ C1 D- |- C Q
. g: h4 f; |6 g+ @; Q p/ O% P8 i" X return ret;, { J! C; X3 I4 p) ~$ a
}& l! u/ s# Y3 ~- O* q
1 R; @3 s/ w b. H+ s w$ u8 m0 g5 Z
static void __exit led_platform_exit(void); O3 z/ D B3 E
{
/ m( P: c, }& _ platform_device_unregister(&da850_evm_tl_leds_device);1 V9 Y& q3 L3 n b, Y2 d6 z
: E t8 Y5 z3 D: l
printk(KERN_INFO "LED unregister!\n");2 I Z, {. W, v0 b& Q* ?8 S4 `
}/ k B) o5 ^1 M) Z3 j, J
) n7 d4 e# R% D. J; n+ Imodule_init(led_platform_init);- S* d1 T, M( _. D1 P
module_exit(led_platform_exit);" \- ^- d; w$ |, I! w
9 l/ a+ M! A: V FMODULE_DESCRIPTION("Led platform driver");9 ]8 m% t6 p# l! Q* J
MODULE_AUTHOR("Tronlong");! E, K, x; X' G b; O" D
MODULE_LICENSE("GPL");
0 Q/ v% M6 s5 c6 w2 }& d
- [: N! F+ i6 s3 _3 |8 y. c |
|