|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 a9 F6 U( n1 v* j9 e- e#include <linux/init.h>4 C6 C( J, m2 f8 X: j( {/ _
#include <linux/module.h>& A+ Y4 X" \' U4 C6 A7 d1 K8 d
#include <linux/kernel.h>
& B: C" K: o, v#include <linux/types.h>
( o; T- N6 }) e7 u#include <linux/gpio.h>
8 u# E5 G0 e/ \+ M7 k% m. R( I. x" }7 k2 N#include <linux/leds.h>+ t3 ?* M% l3 r/ s4 {: P# {
#include <linux/platform_device.h>* M, k! R" J0 K: B& Q" f6 }
) v/ c- i# ~" k
#include <asm/mach-types.h>
" U8 q/ B! L/ S+ r3 @( i#include <asm/mach/arch.h>
; g7 D) v- ~, ?#include <mach/da8xx.h>/ \# o& @; Z, `' u) s
#include <mach/mux.h>" x- A1 o9 }9 U/ H, \# k
$ W; ^" h9 w% k4 Y; a0 [; w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 L: J+ K$ K' i# p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), f( {! S- \7 G( @; q" R4 z! A8 Q7 X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& w/ f1 ^3 K9 C) l* q- D4 p* K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: `) r e, A% H& U2 S, L, U8 c+ V" \0 @/ v+ v$ P( b/ l
/* assign the tl som board LED-GPIOs*/
" d" p7 n8 f+ Dstatic const short da850_evm_tl_user_led_pins[] = {
|& d& x2 C5 m* t3 i% Y9 V /* These pins are definition at <mach/mux.h> file */4 x# f/ a* N- K5 U$ J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& e1 r H0 V3 H9 z* y
-1 U( k+ G3 Y5 L, t+ s/ y R5 [# h1 L) |
};
, m9 j. b- ~! S2 z2 f; N1 j5 E4 i& P0 P, C4 C2 C4 m! m1 y5 r
static struct gpio_led da850_evm_tl_leds[] = {
2 l/ ?0 B5 F) d' o; z {
! Q2 G+ x. N, y$ \: V% ? .active_low = 0,
* K" Q7 E: M; [: Y9 G! X .gpio = DA850_USER_LED0,
; S s9 t1 t0 o0 L" ^9 o .name = "user_led0",
% h, v: K: I8 [ .default_trigger = "default-on",: \/ Z4 r6 D% q2 e2 V! `! `1 q: x( `
},
% u f' G: X( z7 m( ` b h {
/ n* `; @1 [' C) r% a .active_low = 0,6 [* P0 M5 U$ [4 ?9 k1 ]- B
.gpio = DA850_USER_LED1,
' r& C) _1 f. I .name = "user_led1",
& A8 B" G9 g9 q1 P: [! H! k( V3 h# v .default_trigger = "default-on",
0 S/ U2 a0 z k. |' @( v- ^7 P },! o8 |) _" O0 G) k% p
{* { _6 K# r$ `# A1 }) r# a
.active_low = 0,- J/ [4 w% n0 X9 Y
.gpio = DA850_USER_LED2,8 s" b' m& o/ n
.name = "user_led2",% ~* k. H" s' p) G7 ^. K
.default_trigger = "default-on",
, q9 W/ K. Z( q# ?' M' w },
( [" I# h( ~+ a+ K( ?6 C! f {
9 {, Q; s+ l: `/ P& c W& ^; L2 T .active_low = 0,
% m, S G4 C: O% a* u# o! C+ C .gpio = DA850_USER_LED3,
8 y* m+ X4 s# p5 t .name = "user_led3",: _% S- Y. G5 {( u# R+ M. G
.default_trigger = "default-on",
" D% `6 f- J8 q" ]7 N1 d) G }," ~/ S4 P9 e7 I! z7 O. g/ f4 I3 R+ n
};2 Y: {! s/ A) A; `4 O
" g- K( b4 {# m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 Y) ~2 r" t9 r9 {, H4 k
.leds = da850_evm_tl_leds,
( z1 v8 e5 S; Z. }) Q ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 X- q7 S- W# q% q# A7 ]7 j5 a! [};! b- n: v8 V6 [3 C: n
! v, d* ^" p6 c8 `, ^; s
static void led_dev_release(struct device *dev)! x* w6 j1 p: z! r2 l# G% _
{- o# Q' t/ [9 {, _
};& ^' @( C) W0 f8 t# L- t5 f1 j: z/ S
2 q1 u, s9 J/ l. L( \4 R# h
static struct platform_device da850_evm_tl_leds_device = {
' _% ?) r, t* N .name = "leds-gpio",7 I: o, p' ^5 P6 h8 ?3 e
.id = 1,: b. v% P$ E" W% w- W, d
.dev = {
6 G) o0 M3 g; b. [ .platform_data = &da850_evm_tl_leds_pdata,1 Q: u9 O) l+ C7 y
.release = led_dev_release,3 t1 M( [! u1 K
}' i0 j! O" I$ X1 X
};
0 z( I1 |% y! N& G2 Y8 A# p7 i8 [
' m2 {6 T8 o4 P- Z1 Astatic int __init led_platform_init(void)
# g" ~- C- Y& E6 [{* K) Y! l0 d, {+ F
int ret;
, B; ^8 y3 n/ T- I) O, T' t#if 0
% g, R2 O# n3 @( H/ r0 T1 X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& ^$ W' C" R( M0 [9 Q" Y; Z if (ret). ^4 B4 {! ~' W( v' t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 T. t9 e8 b* W) M w0 | "%d\n", ret);
2 k/ }+ Z# Z& S) a* J4 u#endif
% y, e8 y# C* r g4 G ret = platform_device_register(&da850_evm_tl_leds_device);( s% e% x/ ~+ U8 G4 b
if (ret)7 z6 l+ ~, k3 x% \: Q* u
pr_warning("Could not register som GPIO expander LEDS");; _$ o* z8 w$ a: n# g1 ^ r
else
# m" g- E. F) s! h' u$ A printk(KERN_INFO "LED register sucessful!\n");3 s$ e) }( a" J5 L0 ?) u6 c
& [$ X# Y9 w% S
return ret;+ }2 m( l- O# j6 @
}" _3 I H: i; C
4 i) F$ ^" e5 B1 j0 x
static void __exit led_platform_exit(void) I# V# K6 ]1 ]4 E
{
; b3 k6 l) Q4 U l* ~ platform_device_unregister(&da850_evm_tl_leds_device);! C9 a: j @# G9 w
9 T$ l1 L% q( w6 U printk(KERN_INFO "LED unregister!\n");( K$ `/ I7 |% R2 w0 z z
}2 b: D& j- X* m8 w. l
! r% q- O& E" R% ~0 ~module_init(led_platform_init);; U8 h/ n3 w4 n7 D, z7 c/ A2 a
module_exit(led_platform_exit);; _ {1 B& o Z+ ^; u: X6 M. V
+ c" O3 n2 ]; C: k" @, W( r3 o9 {
MODULE_DESCRIPTION("Led platform driver");
, d: M" t6 _& j$ V, u* l# FMODULE_AUTHOR("Tronlong");
( E# N. @9 ^7 j: ]7 Z; s( ]MODULE_LICENSE("GPL");
* A. x* f' Z4 H- q, D! J7 _: u( E6 l' ^7 s% O; ^* c4 |8 Y: J3 ~
|
|