|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 Q2 k; \1 t. b0 L. `2 F#include <linux/init.h>0 U6 @# t, j. m4 R! d
#include <linux/module.h>
* K* l' M4 B, o9 ]: S, S0 T#include <linux/kernel.h>
5 z% u b! X' m* d$ K' q! L5 _* Y#include <linux/types.h>0 |( P8 L3 h z
#include <linux/gpio.h>6 \7 J& y- J: C' M' j* g/ V
#include <linux/leds.h>( R$ |' R+ l2 a1 D
#include <linux/platform_device.h>
6 S6 K/ Y0 t7 g: r; G; m7 F% E. M8 s1 F; i0 J
#include <asm/mach-types.h>
+ ^. e2 H; p: |" h1 Y9 W+ X#include <asm/mach/arch.h>$ ]. S1 ` d# \7 r
#include <mach/da8xx.h>. i7 d. p, Q2 L6 x
#include <mach/mux.h>
. ?4 q; v$ O0 {- Y( k- G' `* X) t+ o, S/ o: i p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 l5 p$ y2 T- H+ r6 A' a$ R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( }. g# ^; G) P: n1 z6 f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 E0 [% M) Y* s) s. t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 R2 Q5 P' b! [ v8 C- F1 M- Z
|% ^& {/ p$ l& n$ [( K7 D
/* assign the tl som board LED-GPIOs*/8 ]0 O$ S% H( [0 k
static const short da850_evm_tl_user_led_pins[] = { s3 `* F6 ^" p1 V
/* These pins are definition at <mach/mux.h> file */
5 D$ F A$ U& F6 L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) `( S4 I" W7 n/ `/ h) f- ^9 O \! J -1
4 [0 A, p5 B: U: q: y1 i};
! v$ I& p1 P4 @- F
* M' x3 {/ |9 b9 h3 rstatic struct gpio_led da850_evm_tl_leds[] = {- _9 q: }/ B9 ~6 ?
{1 |5 ^7 z( c1 C+ u' g
.active_low = 0,4 s# G1 z) D+ `
.gpio = DA850_USER_LED0, ?( E4 E0 Q- C3 z) C9 F$ r
.name = "user_led0",
2 m+ t( @" \7 I9 ^0 k0 } .default_trigger = "default-on",% ]1 n& q; ?, t; Y
},
) R p- j# [# m/ u% s1 h7 A {; A' N2 S8 H' J# H3 A' i1 w
.active_low = 0,3 d: L. h/ D' q( ?# Q0 V6 `
.gpio = DA850_USER_LED1,
+ h2 ^/ ?0 @$ H0 o: Q+ s .name = "user_led1",
, ?4 O: d4 |3 \ .default_trigger = "default-on",. T% u4 f5 Z7 c' @$ C1 b. x) l
},, U# _+ ^9 L! e7 X) V9 h+ F
{
U* Z# `3 S6 D# R* X .active_low = 0,5 g9 `! Y$ M7 K! u) S
.gpio = DA850_USER_LED2,; b2 e5 a# A* J7 Y) I, F
.name = "user_led2",& M. r% o" j1 Z2 f
.default_trigger = "default-on",
, z$ o N" |. y7 m0 X( l( ~ },
3 P: @+ I U) g, ~ v) X {
: K7 t+ w5 @6 }0 C, r# y .active_low = 0,; Q! _8 y `5 N5 [7 J& Y* L9 T
.gpio = DA850_USER_LED3,
7 J4 p% ?: g) f .name = "user_led3",) T' b" W- f/ C
.default_trigger = "default-on",
' E4 l4 s5 ^) L0 y$ V },
. e8 `7 J: L1 z! ]+ A* [) |6 D- j};3 t+ D- U' }# \4 L v
9 G' c. `: p6 x7 Y8 q3 ~4 C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: ~8 J; l9 M7 p H8 n: y- Z
.leds = da850_evm_tl_leds,
& x. n2 b7 R0 V# K6 Y+ v2 z/ I% v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 P* U# W# ~/ p5 v; s
};$ q0 O! w' y: I4 P3 Y& E2 Q/ S
) e- ~# ]! W0 lstatic void led_dev_release(struct device *dev)+ k4 }0 e; }! v; q9 w: R0 ]: g
{0 j* j+ g/ n7 c5 P7 V _& v
};* W) t* T8 z7 i! Q/ B: w& A
; w& u: O$ G3 gstatic struct platform_device da850_evm_tl_leds_device = {
) r: j, J3 s) X1 K .name = "leds-gpio"," S! B1 E5 [, \& b/ s# [. ^
.id = 1,
" K; f L) j- R9 {& [ .dev = {- @* ?/ ?4 U0 S% u: k. r
.platform_data = &da850_evm_tl_leds_pdata,
9 T0 ^0 t$ m* e% A/ p+ s) G .release = led_dev_release,
* b- q( t/ G% y' z- K( u }
P! n1 z- p- f};2 J( l& H: N1 G k; T5 s; W1 ?
) q+ M; ~' e6 E( u6 S9 l9 Jstatic int __init led_platform_init(void)
# L0 ^1 L# m$ t* @3 Q* w! m{4 d+ m6 }! R; y! A
int ret;
! z( N; S7 }8 _7 h3 ?# ]" O* j, z, A#if 0' D2 E0 E& `$ ?1 r# P6 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, j, v& M* N: p8 q) D8 v/ ] if (ret)3 b6 d' C% P5 B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") I7 H* ?) G8 ]* Y+ n$ N
"%d\n", ret);0 Y% F/ ]( C* d0 H
#endif
% q4 T" C- d3 k2 B ret = platform_device_register(&da850_evm_tl_leds_device);6 }# k2 p* B1 a1 n8 f3 S
if (ret)
7 `3 g, P- v7 Z pr_warning("Could not register som GPIO expander LEDS");+ X7 E: Y8 S, b* F$ D
else
9 w9 E _( a8 u6 \6 s5 B$ ` printk(KERN_INFO "LED register sucessful!\n");
/ s: L0 V5 b b- B
* l) d$ \) n# F return ret;
( I% l9 P* I9 R* f+ ~& E}
. l- k5 p) v9 g- ~
3 O% t0 G# _/ X$ a# `3 Cstatic void __exit led_platform_exit(void)
0 _7 p/ I2 j0 W{
7 h/ Z8 d6 J/ c: L, r; p0 P8 s platform_device_unregister(&da850_evm_tl_leds_device);7 O" C }! G- J7 w' @2 @$ K
# I& d, j1 X& l2 Z3 f* |; x3 a, f
printk(KERN_INFO "LED unregister!\n");6 D2 q4 b0 a0 |' e
}
; X8 D% y% W) G& a0 G+ I$ F. O
5 Y! Z, d7 U9 O$ |module_init(led_platform_init);
7 q- ]6 ]6 k6 B n0 y7 {module_exit(led_platform_exit);2 c/ B2 ~, y' ~* |
8 C1 c4 R4 [, U$ u# V9 TMODULE_DESCRIPTION("Led platform driver");/ w% T- v2 E) F1 ?
MODULE_AUTHOR("Tronlong");
3 O# R: F! F6 \% \MODULE_LICENSE("GPL");7 s8 i8 x! s- ^" Z* S% P
0 i1 z T6 C/ X$ p' | ] |
|