|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" U0 O9 ^: H4 S) G2 S+ j#include <linux/init.h># n+ y) i5 [) ?( h4 \
#include <linux/module.h>7 f$ g+ i: A2 o0 x
#include <linux/kernel.h>
3 _/ Q: R0 o! Q6 ?( r#include <linux/types.h>9 t+ o# J8 o# Q& w
#include <linux/gpio.h>$ n4 a9 \0 `! l; V A7 w- {& Z
#include <linux/leds.h>
0 n9 Y# X! G9 x5 l/ q6 l#include <linux/platform_device.h> X+ w# Y* ^% ^% U& J% y
. j2 D0 O3 R. a8 Y9 \# `2 f: L
#include <asm/mach-types.h>
- K+ p ~& l* j x( f#include <asm/mach/arch.h>
0 o: }6 T' E( b8 L* Z- F6 @' Y#include <mach/da8xx.h>
7 j$ O3 m5 x+ F* D9 ?# ?$ H#include <mach/mux.h>/ Z* t& [ N% c, N# X
8 t& [; b/ {/ m0 S0 t& A' [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% U" T, M$ Z/ w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( \0 L- c4 v% S7 q, k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 N+ H; X i+ J3 }9 ?& Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 f; C, L- Z& x0 }+ y1 x5 W" }. H. T6 r* G t
/* assign the tl som board LED-GPIOs*/8 d7 u! D# t q
static const short da850_evm_tl_user_led_pins[] = {) b6 X5 b7 R! J0 {& r/ q9 K ~" d
/* These pins are definition at <mach/mux.h> file */
0 t) H! U0 x* h) J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. P% q5 H& }7 n: T: \ -1
+ A! A2 j0 h( c" ~6 G* X};$ x `6 ^7 h5 B1 \0 W% G
5 m5 w2 k4 Z; h( V$ C- v! W G5 l
static struct gpio_led da850_evm_tl_leds[] = {: J6 {) @- A( h% s# @( D
{
5 e9 Y# u) D3 |# x; \* ` V .active_low = 0,! U5 t1 y) t9 {5 t
.gpio = DA850_USER_LED0,/ w0 p0 A7 v3 w9 E8 Z V1 I1 k
.name = "user_led0",
+ g3 N2 R/ u! i4 z .default_trigger = "default-on",
1 d; o% Y& G) {- z: A },
8 |1 F9 u, T! F- N {2 t% i! H: B: K! c* ]. U8 g
.active_low = 0,, ]* u( B( Y# {1 ?
.gpio = DA850_USER_LED1,8 H( ?9 ?1 z6 k
.name = "user_led1",
7 a4 j3 }$ M ]& n3 @7 H# Z .default_trigger = "default-on",7 G5 ~0 J& l) Z; S i
},
2 e( P" u! @5 n+ z4 N! S# U+ [ {. ~! s5 w! |" g
.active_low = 0,
; }0 e3 ^3 P0 b8 F% Z* C .gpio = DA850_USER_LED2,
: ^# {/ N' }. o7 c- V .name = "user_led2",
& p3 ?2 k3 Q- K! o+ ~6 z .default_trigger = "default-on",: g. t- q8 c. |) B
},
2 d: w& q/ J, p* h' V3 G {6 F2 L. S: a, S# [3 N
.active_low = 0,9 _7 X- k f7 M6 x5 S, m: l
.gpio = DA850_USER_LED3,
" G5 ~- ~7 [+ k1 P6 ^ .name = "user_led3",! o- B# B: T. c/ F! A' h
.default_trigger = "default-on",; j* ]; H% F/ D
},
% E8 F, Z* B7 M! L( Y4 W};: i, t: W9 c" m
" _0 S5 s. J$ Q( _& @% g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' `' ?# W7 F* n. s" Y \
.leds = da850_evm_tl_leds,
! e% W9 `" W) _' _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 \. W- t2 J( n4 ^. ^$ ?! Y};3 |% w0 q" P% E! G, g1 q3 d
& H4 _2 S5 b# Y4 U+ D" ~4 \8 ^
static void led_dev_release(struct device *dev): ^; U4 z; E: J" ?7 k5 [
{, h! Q$ P5 L/ G5 r' ]2 F g
};
# ~3 k' X+ v; Y$ O2 }: i8 P3 Q) Y( V; v* d
static struct platform_device da850_evm_tl_leds_device = {
; I( }! d: L: G! m: ? .name = "leds-gpio",1 q3 N5 J! A" y7 E6 ]
.id = 1,
/ s( D: X% I7 D# U- a; a .dev = {4 E( D5 ^% x# @/ Y" O' l
.platform_data = &da850_evm_tl_leds_pdata,
% K/ w9 \' m0 @6 S .release = led_dev_release,
! t0 H# `4 E- I }
( p* x# ]/ I2 q};, U, s8 Z# z7 s
$ q+ k& J2 m2 R4 z3 Ostatic int __init led_platform_init(void)
0 C/ q; {9 t8 u# f4 @/ T{+ B$ }% u( B) i( R1 {0 u
int ret;/ Z* o5 x$ p- v" {2 Z8 _9 j
#if 0
- d. M+ Q4 u. ?5 L# s. ?( Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" X. O! Y- }0 T- R. d if (ret)
8 g& C% m& w& M1 a' d2 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ @6 `* p3 X6 N; y; h; h- t "%d\n", ret);
4 r' }- o, l) r1 M6 v2 @6 c& Y#endif
4 J1 V Y9 W3 S C! z: m+ F. }3 A2 x ret = platform_device_register(&da850_evm_tl_leds_device);& W! I! a% M' a: E& A! a7 {
if (ret)1 U+ w; ?5 o4 @2 ~! e8 l# b
pr_warning("Could not register som GPIO expander LEDS");
8 d. i* `3 ?" X$ z- d3 m3 G4 J7 F else1 `/ U! u7 H$ v
printk(KERN_INFO "LED register sucessful!\n");
6 r2 z2 ^( H0 j3 r& s
6 ?" d" R1 y1 H0 T$ j& |! j return ret;5 m: {& A6 T& f9 B
}* R/ N& a+ ?8 W
' b) F% W" H* L: b+ i, ?
static void __exit led_platform_exit(void)
9 U$ s% c4 W0 m7 t{
6 V3 c+ w. Y5 T+ K' z2 M6 R# H$ e" ] platform_device_unregister(&da850_evm_tl_leds_device);- g% a7 K1 K" |' K- N+ I2 \2 J. r+ K
' I" d9 H" I. J. J$ Q+ H
printk(KERN_INFO "LED unregister!\n");
# K | F+ b4 F" n/ X3 Q}
& L6 ?5 O3 t) U r3 b9 m: w% a' E4 q
module_init(led_platform_init);' _' y+ T! i, k. }( d, w
module_exit(led_platform_exit);- O) d& l' P1 I* H$ V- \/ f
- L( v/ B/ G' \; f9 ?$ g8 ?" YMODULE_DESCRIPTION("Led platform driver");" K' B' O; \' ^5 F) B
MODULE_AUTHOR("Tronlong");
( `2 c0 I: C. s5 @/ iMODULE_LICENSE("GPL");
9 g% ?; u& S) h1 J: M/ ~3 C9 W" K4 |" m& l& @! _% h
|
|