|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 Z; }1 N' B& P+ b
#include <linux/init.h>
- C p. @& w) [#include <linux/module.h>
/ ^! B' ^# R+ x# Q5 S#include <linux/kernel.h>! Y c: V/ I" J6 B& j% I
#include <linux/types.h>
+ ^! Y8 i7 ]: Y6 X6 a: X/ c* w! g: w5 E#include <linux/gpio.h>
$ W% S" T( O! v2 B#include <linux/leds.h>& c* d/ U+ ~1 q$ n& X; ?( j& |# d
#include <linux/platform_device.h>* u6 y9 T+ u, v
5 L" r S, o2 x+ `9 Q+ B
#include <asm/mach-types.h>
. I j) n7 Y2 p" @3 `1 @#include <asm/mach/arch.h>& R1 L4 a0 r3 b8 ~- Y4 t5 g" M$ t$ A
#include <mach/da8xx.h>7 k' J5 t- X: E7 {8 f- S8 ?
#include <mach/mux.h>6 X1 p! B8 v( V) v
, s; y" F- g0 B4 M4 x. y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ X( o( [7 V) k% X6 v6 J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& h3 |9 u! y" J& M4 S' ?& P0 Z# R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" g1 V/ F+ V- E8 N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 T. V6 E5 I; N" K2 D J* d
- p* u4 ?4 f; b& ~7 M, P0 R
/* assign the tl som board LED-GPIOs*/8 {4 P% r1 g; L$ o( ^! m
static const short da850_evm_tl_user_led_pins[] = {
' V9 Y3 n7 T; g( }& C5 } @, z /* These pins are definition at <mach/mux.h> file */& H$ {+ c! |, f7 Q9 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' S: X( H$ z6 v8 \3 z3 u* `! g
-12 v9 i+ }' e+ {& t5 \; H8 p
};9 {) r( c6 u5 m& k+ L* T
7 ?, o, P, ]# i) E' P$ x9 m2 Lstatic struct gpio_led da850_evm_tl_leds[] = {
9 r! g8 g$ d l o/ P {
' s' ]! | n0 b* p- _4 b .active_low = 0,; c* B2 b. e9 @
.gpio = DA850_USER_LED0,4 @! z4 l }6 L4 s: D
.name = "user_led0",5 p: X/ Y" l7 c- J, |
.default_trigger = "default-on",
# ]: a0 ]# a! k5 }! _, M: a; [ },
# N2 x4 q- C: [, \( Q1 d' C {
% p( O& i+ H Z1 D$ M .active_low = 0,6 Q, L- B9 Y# ^# n+ p3 k
.gpio = DA850_USER_LED1,- z) K/ r6 G( ]' h
.name = "user_led1",+ }7 y Y& B# k: c
.default_trigger = "default-on",
% ?1 c7 M$ P& m1 A, Q- n },
- R* e7 l7 M9 x! Z: a {
( X7 M5 [+ B% |5 b$ d0 X .active_low = 0,
S( x& Q# _3 u5 w4 C, q .gpio = DA850_USER_LED2,
! }9 A" G0 S6 v5 A .name = "user_led2",
9 y) l$ K* k" ?- | .default_trigger = "default-on",9 A2 i6 l& R% w5 x7 z9 ~: y
},
8 k k. o( O/ K7 q% N H z5 e {
( C3 l; G. _# Q7 W6 s .active_low = 0,- ?4 R) Z3 n" g2 h
.gpio = DA850_USER_LED3,
, ]2 I) y( h8 ^$ ? .name = "user_led3",: }5 ?3 p1 e) Z. c9 S: z
.default_trigger = "default-on",$ _& k% R7 T' F/ t4 G
},
1 o: x* M4 V* L2 ^" g3 H" |; M};
+ A" y/ T1 V; z7 p0 l
4 e7 F" E6 e7 p& p9 n) Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 b: S6 u! L9 j .leds = da850_evm_tl_leds,
: X& z# a- p4 Q3 {4 `: l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 Y3 ], U$ |, L4 ]9 X};1 o& ^% k# k( ?! _# A+ `3 Y
4 f6 O3 M0 T8 O: c7 ~; M, U2 Y# v/ @
static void led_dev_release(struct device *dev)
; @0 D+ ^6 i/ R{ P% i) c. b, a; C
};
0 [9 n$ n8 P! D
5 Q; d& m/ q N; W/ i( n+ Ustatic struct platform_device da850_evm_tl_leds_device = {
6 M- o) S& X- ^3 U6 A" j .name = "leds-gpio",# }: z% J: @0 L+ D# r0 o) [
.id = 1,
& [0 t' p" A2 O2 L1 R* y .dev = {6 _! n' V0 A0 n- y$ t
.platform_data = &da850_evm_tl_leds_pdata,3 J; y* w2 k! _
.release = led_dev_release,
' O3 w4 u# W5 C; |& H8 m }
1 [) M6 I- H" r/ e" K& N5 \+ G8 k};
( A( H+ b" d% ]( [3 X4 Z$ f) h
; B" Z. \9 l, Z# z! p) Ostatic int __init led_platform_init(void)* Q* i j0 p# \# R! A
{' `2 ~, }4 X+ b) |. l5 I( b0 [; o
int ret;
; N5 o- l+ O: z6 H3 ~2 G7 n#if 0
3 m6 P6 [) `% Z: { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; h4 E/ }" F; K9 n if (ret)2 l v1 B9 d+ o, m0 H* @2 K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") A: h) |: |% P' \
"%d\n", ret);' _- ^( e) Y: t0 e. R
#endif
, \& J c* R/ G6 R6 M/ `. { ret = platform_device_register(&da850_evm_tl_leds_device);
- u8 w O4 M' v8 Y3 C if (ret)
7 U, U( @5 _+ l. v- `! H# J% e' r pr_warning("Could not register som GPIO expander LEDS");' h! C R# X& q! `: `2 ~
else
6 S. D" u' s; _- E, y6 G! Z printk(KERN_INFO "LED register sucessful!\n");
4 N( k7 l/ ]/ Y, @( Q+ g
, |/ s% `, Z( M' v* d: R' Q return ret;
% D" r) U+ _: Q; x4 [3 F}
5 Q H; w" o9 `# K) m" Z% Z( c2 Z N) e. ^1 g- }2 ], j
static void __exit led_platform_exit(void)" k+ _6 l6 d/ Z& T6 t+ \9 e2 u
{
& A) z/ ^% p8 a6 i1 L! b8 ^ platform_device_unregister(&da850_evm_tl_leds_device);
6 M& t4 h2 A: h- Q& e9 U, O1 y: ~2 M: M' Y9 }9 v" e/ T. x
printk(KERN_INFO "LED unregister!\n");- _- E, u/ l7 _# m4 W! o
}
4 Q/ ]" w+ W9 K# u+ {( M2 m
+ C7 u* Z7 h3 F+ l' R4 m3 amodule_init(led_platform_init);8 s: v" n; M Q3 T
module_exit(led_platform_exit);! x" _/ Y- W3 R/ o6 s3 I t. J
I5 q7 }8 S7 g1 `MODULE_DESCRIPTION("Led platform driver");7 k2 ]6 ^# w! G+ D
MODULE_AUTHOR("Tronlong");# Z$ S6 t( K; b j# O
MODULE_LICENSE("GPL");
5 Y( N# [- J' }2 x$ t/ J
. c: T; A7 b% a( M0 M- j$ s |
|