|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( d; D) L! Z, P#include <linux/init.h>
; _3 z& e$ b) g& N% j/ K# x#include <linux/module.h>
" R9 X* M p! [$ }#include <linux/kernel.h>" u v+ W) y6 |5 | s
#include <linux/types.h>( h4 o; f6 s9 p% [3 I$ [ r
#include <linux/gpio.h>9 t+ K& t! p5 C. S, z6 a
#include <linux/leds.h>
# W5 V7 M0 M% l& ^' J#include <linux/platform_device.h># o' g% [6 E4 }- d( v
( S) Z2 f2 }3 @. i' y
#include <asm/mach-types.h>
0 J+ T1 d5 Z: `5 t#include <asm/mach/arch.h>
% x+ f. l v& r5 Q6 F#include <mach/da8xx.h>( k3 K( Y- K4 @
#include <mach/mux.h>
% p2 @2 J: H. ?5 u- n u0 F6 [. X$ x9 S& c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& o' x, X" \7 C9 ~! v2 U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& C9 a6 `* _5 s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 J. Z, M# n4 D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ a C# |+ f% Q9 K. p% j2 m$ @8 G( `5 b) j1 E
/* assign the tl som board LED-GPIOs*/) T) ~, K7 c8 J
static const short da850_evm_tl_user_led_pins[] = {
' Q( |2 R% r0 ^; L /* These pins are definition at <mach/mux.h> file */7 l: t$ K) g+ E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 `! v4 Y3 @; f9 a0 f$ D6 D+ [ -1
. K9 c6 ~8 E5 \/ K9 t};
9 F) Q0 ?% h" R* h0 x3 j( F& {. v
' g& T1 h1 N) Z& c: mstatic struct gpio_led da850_evm_tl_leds[] = {# S3 T2 G' n. E7 j$ s% t
{" x" t8 p& P- J! G/ z) v
.active_low = 0,
5 g$ T, n# E* w1 H! z5 q .gpio = DA850_USER_LED0,, E6 w$ n6 O0 d N$ M
.name = "user_led0",- a$ }$ p; e6 @1 z5 [
.default_trigger = "default-on",- b* G1 Y G ^' b- F4 p& D
},
' w7 _1 l8 ]+ E5 p5 v {
+ c" H+ s; A8 K9 s% g .active_low = 0,1 d. S9 n1 a$ x, p5 E b T
.gpio = DA850_USER_LED1,# ~2 u( e& i/ X) E8 r4 E6 P# ^
.name = "user_led1",
1 }& Z# a" w2 K2 V .default_trigger = "default-on",
6 x9 m2 i0 J5 M) {* T4 }: z$ A },) [3 ?5 ~5 k! p h; G6 t9 e4 I; u& S
{% N) A G7 E+ D+ n4 D L. Z
.active_low = 0,
4 \1 j1 \/ D% h! k2 x% w" }, T6 L .gpio = DA850_USER_LED2,5 ]+ N$ s X0 ]
.name = "user_led2",
* K/ V e" g6 U% H0 T .default_trigger = "default-on",& b/ _# ]$ n& D! Q# o% H
},( r! m% B: h$ s. i6 A# C2 I q
{
a6 z, c; [/ B0 H2 j2 k .active_low = 0,9 _. K9 @/ b1 G9 V
.gpio = DA850_USER_LED3,
' y* I$ a$ F, N; Z .name = "user_led3",
6 ~4 U( K* s; x' z5 { .default_trigger = "default-on",) C) Q6 G9 R6 t% J+ E: q
},# P8 B- I7 F& G1 E- c/ X; I
}; `# B+ h" L E3 h
& `3 ~$ I: C4 U6 W2 i% [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( H% A; c& S2 I8 X! r+ D& N% V .leds = da850_evm_tl_leds,
. Z5 Z* E0 ]# Q" Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 ^3 a4 i& C3 @# A& {
};. [( A; z6 _8 P d B( _
+ Y8 C2 g L# A W. y
static void led_dev_release(struct device *dev)
) j# E+ p F+ b& I" o6 N$ h% L{' _, I! [7 I$ R; y8 O
};* V- p2 e2 B4 w( X
. k. ^4 H/ X8 z' j6 z: Zstatic struct platform_device da850_evm_tl_leds_device = {# \ e5 X0 m; T, {; G
.name = "leds-gpio",
8 C! m- P8 A9 O8 t .id = 1,
! j1 D! ], k W6 T .dev = {
# U# n% w o3 E" G/ ]4 b( a$ T5 b5 T .platform_data = &da850_evm_tl_leds_pdata,: j7 s9 O e5 b5 A. e+ L
.release = led_dev_release,
0 u) y) e; G8 i+ L: j% p% q }; G/ A2 |. y. W8 O$ f6 C9 B
};0 |8 ?9 B4 f/ U
3 V' s6 V9 L; ?* @2 K& I) ~, V0 G }static int __init led_platform_init(void)
Y% }2 n: a7 I- U{
, @8 [0 @* U1 o1 f4 }9 Q: W5 S) U int ret;
" t2 q1 z6 |, J: J#if 0
: i; ]. u- N6 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 U1 A. {% V5 q; I+ _' J if (ret)3 g& G- T3 b, S6 e! [( A& v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ t; I, q: b: f6 V. k2 P "%d\n", ret);
2 S/ N$ t3 `' n% ~7 K: j#endif. J. p7 O9 r6 o u* W
ret = platform_device_register(&da850_evm_tl_leds_device);
8 V0 N0 I. R0 x h7 I: x3 u2 Q if (ret)$ w0 u+ A( Z5 I
pr_warning("Could not register som GPIO expander LEDS");
8 w) O" b5 n) v5 ?& E9 C else
" j" r6 P! s: N( \% ]' o printk(KERN_INFO "LED register sucessful!\n");7 F% j0 t' ^# \+ n- s
; o2 X* x9 E! P7 N* h
return ret;
# h! V9 }. J8 g* I' w}; s7 D: {4 l/ l
: I& _0 ]- l$ R ~9 L, Istatic void __exit led_platform_exit(void)
. |, P) q, ~4 z% p* @{
. @5 b8 Y2 M6 z- v. q0 s& O platform_device_unregister(&da850_evm_tl_leds_device);4 c. t/ t. }1 u" ^9 E4 F. @7 s
# N1 G& B/ ?& H0 ]5 p printk(KERN_INFO "LED unregister!\n");
% V0 h0 d% W! e" e0 ~# K}
& [# B+ Q5 V2 {. l0 F5 B
6 u8 T/ O, Y$ ?module_init(led_platform_init);6 n5 r& L1 z9 i) f+ i
module_exit(led_platform_exit);
/ o3 m2 y# M4 j( b6 }2 a5 ^9 Y
1 t) S6 Q/ Q4 P+ U8 kMODULE_DESCRIPTION("Led platform driver");$ _! f' z- B" {1 v/ q! t ~5 \. Y9 `
MODULE_AUTHOR("Tronlong");
5 P# a1 v8 f; T! w& S) s$ C# {MODULE_LICENSE("GPL");
3 Y. v0 p" y, g2 n+ Q
; q" w/ v8 X+ q; z. T |
|