|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% I/ x$ P$ X- Z! h2 n: k
#include <linux/init.h>) }2 O1 U, C& B9 e
#include <linux/module.h>0 ?6 ~; ^+ B. ^& C9 E2 y7 h- o7 A
#include <linux/kernel.h>
/ W& J9 S4 J; P/ z7 Z9 j/ V#include <linux/types.h>
1 W5 {1 I- Y R* E3 T#include <linux/gpio.h>& p& P1 l0 Q. Q- @* ~, R9 s
#include <linux/leds.h>
' O" c) C, H3 S o$ @#include <linux/platform_device.h>
/ r% X2 Z1 @# {7 X' M$ T+ m% h. R7 N6 e2 C* v; s m
#include <asm/mach-types.h>8 H I) z3 |/ B% J: a4 J
#include <asm/mach/arch.h>" r& c/ u T7 V: O2 M) L) x- m/ v
#include <mach/da8xx.h>8 }! j5 S g. {* C: j& P
#include <mach/mux.h>' `. T% `; |/ W! M
- j/ j1 R' \* w8 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# H' L i! r0 G8 Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 j- q, y, _- b. M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 `0 D, }7 Y6 F* Y) b9 g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 ^/ a/ `2 Q3 A. Y' Y- O6 @0 d# R8 \" _, {9 L, n! \
/* assign the tl som board LED-GPIOs*/" N N0 T4 j. N) J
static const short da850_evm_tl_user_led_pins[] = {9 t+ I2 f) x: [ `# _" z: h
/* These pins are definition at <mach/mux.h> file */
/ z) @0 T; M" I4 b( }! r0 O* Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 n$ W0 L7 ]& E* e+ j
-1
/ O! e, H6 \( @};
5 k2 k b) K! y; t" w g8 {; K( U. Q: L1 `
static struct gpio_led da850_evm_tl_leds[] = {8 T& }# r3 c% W; l; r R) l$ `
{# R: y _9 s4 S* j) c& Q
.active_low = 0,
$ M5 c; }' q; T .gpio = DA850_USER_LED0,
) j" B& E8 _, t, {7 L .name = "user_led0",. O$ n7 O% Q9 x7 `+ K. i
.default_trigger = "default-on"," @) b9 j% e, S! Q7 I
}," f! ?9 Q3 @# o
{- N6 h' A' e+ `+ h: v
.active_low = 0, S8 H2 x9 @, c0 Y f0 }$ c3 v7 {
.gpio = DA850_USER_LED1,
& J2 Z# j$ I8 y( w5 O .name = "user_led1",
; {/ @4 j, s, i7 H; {2 u8 B( z .default_trigger = "default-on",
' G3 v, |$ \! V5 R% W# s- z0 T },
2 f$ d W$ R9 [( V- _3 j; k {
* z$ g7 j+ x! Y, g7 p .active_low = 0,& ?$ v" K. ~5 @, K: a( E
.gpio = DA850_USER_LED2,
6 y u4 X" i+ ]% g( V5 T$ N .name = "user_led2",9 Z) G8 x$ O6 z. |# A
.default_trigger = "default-on",
% z% x6 a7 ^0 w M# f4 i# H, q) Y },
' O% G7 \+ G8 a$ O3 q4 m6 x {
+ o1 s% Z) P9 ~+ k! t$ I, m$ | .active_low = 0,
9 q' L' g& }/ D3 r .gpio = DA850_USER_LED3,
$ W" U6 W, j1 ^* T- u" H .name = "user_led3",
. g8 A; o" h9 i7 ]( f: K" k .default_trigger = "default-on",
, m, b9 W- S9 m6 [! o" M+ X },
% z# P% Y! V" j0 h* o};+ l( ^6 q5 K+ ^$ ^7 B3 ^
' S# P$ L5 J' k1 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ `* ~8 V5 c3 b7 I
.leds = da850_evm_tl_leds,
" n4 V% U. b; C T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
p0 P1 l" v* z4 n};6 ^: |8 a( l( q
. ?7 C3 ]6 x8 M' }' vstatic void led_dev_release(struct device *dev)
6 Q! }# _1 D$ A+ m `% U6 q7 k{
J* S# [# r& }+ Y# d6 N};, }: ]9 y: m# ?3 ~ P+ O4 Y
W% G# Y/ q0 istatic struct platform_device da850_evm_tl_leds_device = {) }$ P I& C% E) u" l! }" Q8 V
.name = "leds-gpio",4 \) I; h7 V5 q- K
.id = 1,% S$ Q, V2 `/ z6 [- A
.dev = {
8 ^( N% P" R8 y) l7 R! Q! N .platform_data = &da850_evm_tl_leds_pdata,
* C3 I3 w: l% D$ ]; }+ W; b% M. j .release = led_dev_release,/ X1 J. L) e) X
}
, O, u6 h( @1 i) K; c K8 `};" ]0 L3 e5 q: k. ~9 P6 ~3 [ z
. ^% X, w2 j# X) h! P8 R! o+ |static int __init led_platform_init(void)( ]3 s: P W1 x
{6 V0 J# K6 D+ o, Y9 {
int ret;
: }/ R4 X. A- W8 P5 e. w! k8 }9 c#if 0
6 Z$ Z% I5 A: o. S, } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- B) I+ F0 Q' A7 }, d if (ret)$ B! ~+ R- e0 Y$ N/ k4 D7 v6 h5 ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" H- m2 u* H/ @3 X3 r! R T, N "%d\n", ret);; w" c9 v" a" d9 d5 h. b/ ~
#endif
: {7 R, c3 m. ]0 R4 c7 [! e0 C ret = platform_device_register(&da850_evm_tl_leds_device);9 @, W" B& [' _! |' F$ t
if (ret)# d N; k1 Y7 _
pr_warning("Could not register som GPIO expander LEDS");
+ A" |% B* c. ^3 Z e else
6 m$ _8 Y3 n/ R# A6 m printk(KERN_INFO "LED register sucessful!\n");& ?* Z9 B" U9 J! n# a2 o
, M, E) W7 C. G0 i& \
return ret;
+ e! O: D8 Y1 F7 C! b}% `' a* _ p; `. K8 Y* Q
3 c. r7 P* Y3 V4 w3 ]
static void __exit led_platform_exit(void)
, p1 I U: z" A; q{6 d: C, Y6 d" {; `# Z. ]
platform_device_unregister(&da850_evm_tl_leds_device);* A/ r5 o( _ v
; P4 j7 }/ G% z! U2 S printk(KERN_INFO "LED unregister!\n");3 J( k/ A( D2 K* q3 `# h3 p& z
}
+ Z% O+ w3 }/ S$ D6 E" @" D- @ Z" T* R+ v% Q' J$ a
module_init(led_platform_init);4 T, t7 h8 u! Q3 x" r6 t
module_exit(led_platform_exit);5 Q2 f8 ~; l1 M9 v! E: H7 U' {
6 ]8 v$ W# t. F2 H6 X( yMODULE_DESCRIPTION("Led platform driver");
0 ^* C, g3 b) m7 y6 V8 IMODULE_AUTHOR("Tronlong");6 T# y! E2 g( K2 B! ]
MODULE_LICENSE("GPL");
$ F" Y( K; y6 N& f5 r& z- Z; ~
1 J9 h/ m" Y+ D% s { |
|