|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 I( z& |; R3 ~) X" x#include <linux/init.h>" Y3 i) }% U6 L0 c- M A8 s
#include <linux/module.h>
) X) D* _2 _& _, a: M1 R. G# X# \& f2 _ l#include <linux/kernel.h>
- c/ s9 l- \: ~2 J- z#include <linux/types.h>
( U7 x5 E4 p% A8 F#include <linux/gpio.h>
5 e* R: B, }% X Z }$ H#include <linux/leds.h>
H8 i7 R/ X b#include <linux/platform_device.h>
6 r4 v& H( [% U& S" W+ }! O! l
& U& L7 v1 m5 H' ]9 ]& ]) J4 _#include <asm/mach-types.h>
1 @4 n ^3 F, g9 A5 S x#include <asm/mach/arch.h>
. E( O1 s+ v# X+ s' |4 }. Q; ]#include <mach/da8xx.h>6 t5 w4 _. H# t2 E: h
#include <mach/mux.h>' [+ |. _0 W% e9 ]: b$ x' \
) c F5 t6 i% G* Q- \8 [3 k' _! j4 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 j: b' i$ C: t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* s0 O, v4 c4 c, t7 C/ G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; ?: P3 f* V9 g9 d: \4 s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. e2 `' C' S9 Z" }" W o+ ], X, B
' m- E5 j4 I* n" {0 O6 u9 G/* assign the tl som board LED-GPIOs*/
4 B0 l5 L& b/ v1 dstatic const short da850_evm_tl_user_led_pins[] = {
/ }6 s% L9 Q) P# j6 J: Y& t /* These pins are definition at <mach/mux.h> file */; k* z2 e1 K6 Y4 }* }; G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# u. R! d9 x( }* c5 L
-1( ?3 D/ S7 M2 [; d+ V9 {
};
6 l! b- ~3 t5 i9 m+ l! H! A( ?
1 K& ?+ ^$ V7 |6 fstatic struct gpio_led da850_evm_tl_leds[] = {
) W; ~( ^8 M) I) s2 y+ T {
N1 f. \+ @0 _ \# m .active_low = 0,
; v! |9 z8 h- v( Y: e6 k. ` .gpio = DA850_USER_LED0,
. x+ S5 N# f! W' U: P/ r .name = "user_led0"," b! r* F0 z+ U' a8 B% J
.default_trigger = "default-on",; N& a+ c, `! G- m9 d6 m$ X9 x8 ~; a" {
},
. H8 F; ?' K5 c8 @; T6 b( m7 |1 F {( G$ V! s2 q3 `
.active_low = 0,9 h: F. [" O) r5 A4 z
.gpio = DA850_USER_LED1,0 X/ z) o# V6 E" d/ I% S. I
.name = "user_led1", N5 b; R! ^* @. i
.default_trigger = "default-on",
# J# f& v% C4 \$ U* Q },
% e5 s6 c+ d& M3 \ {" x! t C/ A) J& x" I; R
.active_low = 0,
+ N/ O5 i j% ?5 G .gpio = DA850_USER_LED2,: s8 A& U. M6 k B8 c
.name = "user_led2",/ f9 i v1 K3 U/ y0 j
.default_trigger = "default-on",
; \6 J) H& g5 `( ]( U& } },
9 h2 E; t; O x v. l: x4 N9 J6 i: I {& s1 x! @2 r5 O0 @& ?
.active_low = 0,
. I; r' v6 e6 I4 l" @ .gpio = DA850_USER_LED3,
% B0 L" s+ |; N2 H7 I .name = "user_led3",
$ x4 l# _! F. l: j4 X .default_trigger = "default-on",8 t V0 {9 y0 J9 f) \+ b7 c
},8 Y3 z; z1 J3 P+ x
};2 h1 U6 t% [ J+ E+ T9 |4 P
Z5 F% e3 C! M/ estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ d# \2 w# W! ~/ a% p1 _2 z, q8 Q
.leds = da850_evm_tl_leds,) Z- D; p4 o! U* W4 B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 J" b! k$ G) }" c
};9 N7 k) k: |' w% z9 g9 `
) I5 r$ V) E7 L, _static void led_dev_release(struct device *dev)
9 o- k- o0 }' M, Z+ l% {$ o6 J{
; r) W# r% @, }6 q2 u};2 M3 x7 @/ b" _+ Z( |( Z5 {
# ^ Q9 G- t8 j) O! O1 T
static struct platform_device da850_evm_tl_leds_device = {% N( _3 i2 l4 b" @/ m6 Q
.name = "leds-gpio",
3 f ]3 N; V( y8 I7 {' L .id = 1,4 v- _" f4 e% ~+ E2 L5 a; a- K
.dev = {' I [0 m7 M1 j- p
.platform_data = &da850_evm_tl_leds_pdata,
/ Y9 i x# |9 t6 F3 q5 m .release = led_dev_release,
4 e' F' g6 O5 u }9 L# u& n1 r S- p
};
! s' P( r! I& Q5 n A8 d' X/ @6 [5 d& _: r; s, h' x6 n' d
static int __init led_platform_init(void)% _% K' x' }5 ]$ N% P
{% l) ?- r) M5 a) _
int ret;- r! q! J0 a' Z& I- N, X) c8 u
#if 0) R8 V. I1 k5 u8 U5 Q; I9 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' P$ w) f5 e5 B0 c4 V0 P7 s# q
if (ret)7 ^. w2 g9 n* T" Q9 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# ^2 H x9 A/ I# I9 J' x$ ?
"%d\n", ret);
. e! A5 @4 {. l Z8 U* a3 T#endif
4 o3 V$ k% V9 X ret = platform_device_register(&da850_evm_tl_leds_device);
# R. S2 k* i* B+ X if (ret)4 d: d& O% x8 o4 ^' e
pr_warning("Could not register som GPIO expander LEDS");
7 W) ]! H& O1 q0 ~: p& w% k else
8 f- s. o/ }! U6 |' p printk(KERN_INFO "LED register sucessful!\n");+ M0 P9 r7 |/ @5 c* G
: u }. t6 o& e- M7 }* c8 f return ret;
) B; m; c# t# H}
+ n9 p6 K8 \& T5 f2 u5 w' {- |( g1 T' `$ X
static void __exit led_platform_exit(void)
2 m6 ^. U+ j- |- A4 s{
7 p$ U5 k* ?& g; L: u! O9 ~; @) D( E: m platform_device_unregister(&da850_evm_tl_leds_device);- H+ m6 {. s) S( r9 A
. p& _% b% X% ^9 i' q
printk(KERN_INFO "LED unregister!\n");
5 P+ n, ^5 W$ x- h4 M1 F}) `' ?. x$ B. e8 Q& I2 M1 r+ V0 K) O
8 _6 |* Z! b4 t& I: U& F( y. ^( ?9 y. Z
module_init(led_platform_init);" ?" |" @. r' _2 n: ?
module_exit(led_platform_exit);
! j- ?& W0 c) H }2 j" N9 t6 G# X+ a3 y
MODULE_DESCRIPTION("Led platform driver");
% Q( x8 y7 o- M! mMODULE_AUTHOR("Tronlong");
. N3 z! W! H6 i7 f; bMODULE_LICENSE("GPL");; @2 K B' j$ _( A0 i/ l4 h: }
: R$ S/ f& {5 q" D+ U+ i5 c |
|