|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! z% U9 }0 {6 K& [: }% Z. U9 G#include <linux/init.h>0 ^: L9 e( `5 X. L% I
#include <linux/module.h>, m' A9 A! B( N; I( [
#include <linux/kernel.h>
+ r5 h/ m5 f& O' h0 @0 q#include <linux/types.h>
1 t6 o! }/ q; [$ C2 Z#include <linux/gpio.h>5 q. s7 H9 Q2 {
#include <linux/leds.h>! t( |9 b+ Y( v& F# C! f6 O. ?0 P( A
#include <linux/platform_device.h>. T. ^) r% a- m/ `( I* Z5 G
2 k6 |: {: Z/ a! S+ h9 x4 R! j
#include <asm/mach-types.h>; e3 j, [2 S4 L
#include <asm/mach/arch.h> ^) a8 `" z7 k3 n& @5 g
#include <mach/da8xx.h>
. h, \6 W; f S2 p8 ]#include <mach/mux.h>
: j: a& u2 k0 j M% F. z; e3 X" b8 } r4 _: \4 I! k: K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 @) G; x+ V$ y" n% A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" y9 Z. P) C+ S3 N+ {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 }% B- G' I$ _/ ^8 S0 C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& Z Q* V+ Y$ a) ~9 r& }, O% q. ~ D+ B f8 L1 I" k
/* assign the tl som board LED-GPIOs*/* z0 L: c+ i( d" h0 n
static const short da850_evm_tl_user_led_pins[] = {. P8 G2 A R8 U+ C6 m5 F1 g I+ ^5 \
/* These pins are definition at <mach/mux.h> file */0 g5 M, b$ a. U P$ M3 P _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," K+ J* a! t- n( L( Q
-1
, P4 k* t% v7 o. a, x};
' G$ T) M9 B4 }2 |0 |0 y% ?' W4 S) T
static struct gpio_led da850_evm_tl_leds[] = {( \; B7 m/ E0 o! e) z4 N, ?/ C4 U
{
4 K4 h. P" |5 A1 a2 h# [) C .active_low = 0,& _8 f" X; k+ F4 l8 C* T
.gpio = DA850_USER_LED0,
7 C. I A7 `3 a .name = "user_led0",
/ i; C, b3 `3 ]- b- f .default_trigger = "default-on",
+ Z! b6 s% N' w7 ]! C- [* z3 _7 ~/ X: z },5 ^" k% T q4 r0 i9 W0 w+ X
{
. r& _7 [* N8 s" x& `9 H/ h" @ .active_low = 0,# v" T$ i. d: M& J$ y
.gpio = DA850_USER_LED1, w1 I, e I/ @6 S1 t0 O
.name = "user_led1",
; W5 M6 y: t8 j) \3 I$ ~5 L: |% A. g1 g& [ .default_trigger = "default-on",6 `% n0 I6 d% E( ?" M7 Z! j
},
W4 g& f0 |) `" ] {; n* u( [+ K# Q
.active_low = 0,3 e$ u0 o+ p, [0 C/ `
.gpio = DA850_USER_LED2,- d% A# ]* B7 v
.name = "user_led2", @" d' m5 L1 Z' y! Q0 B
.default_trigger = "default-on",
0 K7 |6 j& l( D5 } },' S1 S+ v4 M$ v+ T. R4 o( {7 E k
{8 v- }) s% d+ _! A( w* y
.active_low = 0,
7 P% x M5 D) O& n6 h& j$ N' ` .gpio = DA850_USER_LED3,( l; G+ E0 u9 Z
.name = "user_led3",: _$ B' F7 |( [( n7 X- a+ T, X$ |
.default_trigger = "default-on",1 @1 e# y: t# y+ x
},: I0 q7 Q3 O) y& R" n% t
};$ M; E( H' ]5 p; O& g
& O8 g& d" f+ K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! E# r w! T/ ]& v' J/ ^ .leds = da850_evm_tl_leds,2 W0 s2 y" H! A0 B5 u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; p3 b. _! ~0 y* f! b
};. C2 l3 ~) N% q
' W- p X/ P3 k) _; f9 F. y' ^static void led_dev_release(struct device *dev)) _( o7 W7 @0 }9 Z5 x' ]& |& Q
{
4 z. o a/ @* @" ~9 ?$ d! R};
& R- C6 g/ S; _6 j8 x
1 p( p; o0 d/ Q* _static struct platform_device da850_evm_tl_leds_device = {
S7 e; T& J+ g/ }8 j) D .name = "leds-gpio"," l2 k$ J/ s( D6 P$ g4 V
.id = 1,; n4 T+ ?$ v3 h! I
.dev = {" W7 c9 s" x9 T2 K d- S
.platform_data = &da850_evm_tl_leds_pdata,
- [! u: z2 b' |5 b5 l+ D- T& u+ c .release = led_dev_release,: w3 U; \7 D$ k9 o, j3 u
}
- i% U! h- m/ e0 j3 F};. O# s7 I; I, C/ o
; _& n4 ?6 _% a6 ~! s, M6 i
static int __init led_platform_init(void)* F1 |1 ]( }4 ^5 K
{
* P" ]6 e" h W0 u/ J5 K int ret;
) \7 f" Y X x5 W- X* r5 S/ p#if 0
) G( Z- |) e4 }: e. f! n9 V" I3 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 V" H, g( B& p- ^. I8 s+ U$ b if (ret)4 V7 `& n7 p, @3 \4 n& a9 G1 f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 U9 K2 r7 w2 C" f( W7 O' _ "%d\n", ret);5 D8 n9 t) ]' P9 |& y8 C: l' ^7 R
#endif
& b" `# ~, `8 r" R4 P ret = platform_device_register(&da850_evm_tl_leds_device);
5 x! S `% ?/ _$ f7 J6 v if (ret)# p5 } l( j1 P4 Y/ \+ O8 E
pr_warning("Could not register som GPIO expander LEDS");- w8 A% p7 k ^( ?5 ^; x$ S
else
6 [6 p$ ?8 u4 |2 U% s9 @ printk(KERN_INFO "LED register sucessful!\n");! R/ j1 [5 ^4 c- ]; n2 t" [
, z9 f0 K. c: [
return ret;
9 R! E$ Y' v. ]. E% m}
# m8 \( X% P% E* ?+ `. W$ Q3 b/ e$ r, ^- ]" Q+ }
static void __exit led_platform_exit(void)
6 L0 v! F4 M- ?* i3 y) P# C0 V3 X1 K4 m{
! R1 Q& x e" V9 T- G platform_device_unregister(&da850_evm_tl_leds_device);: n& p. O" T5 H; x
& m) }5 [; \% ] printk(KERN_INFO "LED unregister!\n");2 _( o) D$ n$ G
}
5 C. N- J4 x- I+ s7 {
& v+ ]' M l9 j1 U& ]! J5 }2 Q6 o2 Kmodule_init(led_platform_init);7 u: ]+ t$ y9 K& a$ }
module_exit(led_platform_exit);- Y7 x1 J# t! C& b) t( x- W% {
# b7 @+ U: I1 E% M# P4 f3 n# k, kMODULE_DESCRIPTION("Led platform driver");
4 x! @$ g- ~( U& v9 IMODULE_AUTHOR("Tronlong");3 j% u" _; T* J* U8 K D
MODULE_LICENSE("GPL");
6 Y/ c7 c$ q3 M0 F3 Q. ^) B' {7 X5 J, y" m# C
|
|