|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 D8 t1 Y9 J! L1 b9 e! H/ ~5 A3 r
#include <linux/init.h># x/ Q% U* d5 {7 f/ k& P
#include <linux/module.h>% W9 A* G) c! O* j4 q- v) s
#include <linux/kernel.h>
* Z( V# Z! K" ^; l; ^ S3 a( P#include <linux/types.h> M$ h9 r, p1 z
#include <linux/gpio.h>
) B5 x# F0 v6 f! B9 e4 C% u#include <linux/leds.h>, C0 c0 @" @' k: p* Y& Z
#include <linux/platform_device.h>
8 ]3 V8 J( O9 y
2 U+ X) y8 r3 p3 P3 M% [3 d#include <asm/mach-types.h>
* w9 I A' R# @% @- Y- R#include <asm/mach/arch.h>
; \+ ^, t9 v8 H9 U: H8 ^#include <mach/da8xx.h>4 b2 C( q* x( f7 e: j5 W5 |
#include <mach/mux.h>
9 Z+ k3 X' A! {: ?4 x" r! w. o
" v: \: ~' B, b- i$ V* v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 g% {& |6 z/ x9 H5 l0 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ N1 ^+ D* A+ q) a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! E, h) x0 c4 P9 O5 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 K9 i7 X# K; D1 u+ i: s. \# |, V: U9 }4 `( R
/* assign the tl som board LED-GPIOs*/
9 A2 h) e- Z7 ~1 ]! |0 X" bstatic const short da850_evm_tl_user_led_pins[] = {
$ E- V' R( W9 ~ /* These pins are definition at <mach/mux.h> file */
' ~& ^2 o: I2 V9 k, Y0 r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 E; ^( J/ }. g* s2 H -1. I) C2 [$ q9 ]. F
};
! s7 m9 O2 o6 R9 w( v7 e3 S, e( |# I1 d) s* h8 m
static struct gpio_led da850_evm_tl_leds[] = {/ L R4 Z2 v0 K' c" r0 n& H* R
{5 y" x$ \' \1 j& I, k8 K3 @
.active_low = 0,7 t$ i) z0 n& c
.gpio = DA850_USER_LED0,% @: _2 C2 B6 }( S
.name = "user_led0",! ~% r) z {; J8 H: q9 C
.default_trigger = "default-on",
. p( s/ c) |0 t },7 ?( f0 W0 `/ R8 u2 D: h* s
{
1 M0 t! [0 r. K* _ .active_low = 0,. p) C5 ~/ Z2 W; U( j1 h* c
.gpio = DA850_USER_LED1,
6 j" S; l3 _* _( y0 `& q .name = "user_led1",9 o+ E) C! r( [$ D' p
.default_trigger = "default-on",- Q G. i5 h8 L
},2 g8 c2 x. R+ h' J/ p
{
( ?' }" q. v/ `( W0 v7 T, J9 l .active_low = 0,
4 {, |) L7 c) {" E1 [' P: P .gpio = DA850_USER_LED2,! x2 o( R& Q( g; |: Q7 E; w
.name = "user_led2",
e4 ]$ l" v- g7 l2 f% v4 g; | .default_trigger = "default-on",
8 }% [+ d3 i, F' ` },
3 S0 J7 x g1 w' g) h/ q! K+ Y {8 ]- f: _+ z+ A3 B4 f+ J
.active_low = 0,* R. F! e, @/ M, U. U
.gpio = DA850_USER_LED3,
" n% X) [: ~; E0 y" j' U9 d2 t. \ .name = "user_led3",
8 p D- X9 B9 y .default_trigger = "default-on",
- F6 l0 Y3 M7 b2 ?, S },7 n0 e4 G7 [6 I
};
+ S f% |( h7 p( T
( x$ A2 U, u3 s; d& Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& z. N$ G" r7 y2 J8 }/ a1 k .leds = da850_evm_tl_leds,
3 \9 X/ m8 K- q/ _+ s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 t+ F/ b' b3 x" Q# T; M r/ y
};$ i2 o: W$ i8 P. T: I: N5 A# P
6 X8 Y* \- N, jstatic void led_dev_release(struct device *dev)
' `6 N% s* V+ J+ z{
# d0 K( a% O Z) w};4 ]( x0 O0 \/ ]
& U) [ z' J n3 E" e' ]static struct platform_device da850_evm_tl_leds_device = {
3 @; [# X% D6 R, g/ Y! d .name = "leds-gpio",
+ t M3 v8 x9 e0 _1 D# ` .id = 1,
" M; A0 z& x+ W2 Y: h- g- h | .dev = {8 z: j3 }8 p6 N3 Y! E4 d5 q" h
.platform_data = &da850_evm_tl_leds_pdata,1 B5 p) x+ `4 y2 ^9 _: d1 z+ i
.release = led_dev_release,
' ?; k) G5 o2 Y9 j3 g }
3 k% B) s8 R8 S1 u9 A};
- l' c% @% ]" p& u0 u& ?/ ?
1 c: e, d" h3 S& w' T, m) Gstatic int __init led_platform_init(void): p; ]* ]7 u; j0 r S# q" q; m1 m
{
. @! ]. o- y+ q" ?1 D5 ?9 c7 k0 P int ret;! v- o! H$ |3 R2 y+ L& l+ L5 ^
#if 07 Y$ z4 q, [9 z8 Q, z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- z5 R* G# H# Y. V if (ret)
& B( T/ S! R0 e. W, r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ ~4 @6 d- z* I* z' f' c/ V% N "%d\n", ret); Y1 Z' r% U( {( B! M
#endif& `& @; R/ a% D0 d/ [
ret = platform_device_register(&da850_evm_tl_leds_device);3 u" ~7 L' G8 f$ o: b @2 j
if (ret)
, o8 P% z8 b, b9 I3 d/ M/ P# ^ pr_warning("Could not register som GPIO expander LEDS");0 q- D$ m3 P, x7 p5 x
else
9 l; l9 b* c. K3 G' a: m printk(KERN_INFO "LED register sucessful!\n");3 D7 P, C2 h# ^
% z* f# K3 x9 W$ T3 g5 W4 A return ret;( ~% D- E" d: l: m& P: ?: t
}
/ |. [2 Y0 B t. I/ c% g1 W! Y$ W0 f7 A2 _9 l
static void __exit led_platform_exit(void)0 s- f) q3 E4 @- @8 X$ ^
{
8 T8 A# b0 T+ V# {2 m X6 R; {0 s$ _ platform_device_unregister(&da850_evm_tl_leds_device);
1 r5 ?$ t2 E4 \* y0 t! f8 |$ Q; B% Z5 i% t4 B
printk(KERN_INFO "LED unregister!\n");2 W& A9 z4 Z& F+ w" ]0 j5 |
}
$ n+ X+ R* n4 C! c$ s4 S
# |3 R4 N) U4 v6 k9 ?/ f% g1 y! z2 wmodule_init(led_platform_init);
, j, }" ]2 B3 E4 N. h4 u! N3 |module_exit(led_platform_exit);$ ]; g/ G5 n9 U. j
7 Z7 Y3 d# m a& XMODULE_DESCRIPTION("Led platform driver");: X+ g" z) a' x' m; a% t
MODULE_AUTHOR("Tronlong");/ i! A# k* i, I2 S9 N
MODULE_LICENSE("GPL");0 E2 z g( f; g: O6 E; |9 ?+ S
2 G+ u9 Z7 ~1 E" s& A% y8 z |
|