|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 T- z$ I' u5 H3 W* R* {
#include <linux/init.h> Q$ s# W' Z* {
#include <linux/module.h>
; K8 g2 H7 [( c4 }3 P#include <linux/kernel.h>
* y) M/ B6 h, g4 _! G5 u7 y#include <linux/types.h>7 q) f! a- h& o3 I
#include <linux/gpio.h>( s8 T' k [( x/ W2 f$ g
#include <linux/leds.h>
1 j0 J5 U8 F" w8 I! i& D$ S5 ?#include <linux/platform_device.h>+ n* f8 t. W5 X) o9 [0 y
) f/ [) c; c' w, ?0 X/ g8 m0 ?
#include <asm/mach-types.h>2 x" N; }6 k; ?6 T K* y \! c
#include <asm/mach/arch.h>
% f( v9 o6 w* x+ {, Z( X#include <mach/da8xx.h>
- l* m* s( V0 I4 G0 T" s0 j#include <mach/mux.h>& z6 t' b- B0 m" O" @/ x
' A4 L; P) A2 n+ R0 G) \3 p5 @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 o0 a& B; f! I7 q( G3 o# F5 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" `! Y$ f; Q* t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& c- W t. [7 L8 q t' Y/ Z) B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! n8 w9 G9 @! H% r1 F
8 S7 l9 ~; J2 Q& M( S2 N
/* assign the tl som board LED-GPIOs*/5 z G3 @) b: h! G7 E
static const short da850_evm_tl_user_led_pins[] = {
, t2 d7 S' d$ A6 K# c6 y /* These pins are definition at <mach/mux.h> file */
- a9 k! Z! W) f9 U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 |4 H0 z" V% m
-1
) j4 w: M* a1 \; Z! u+ Y9 r};
( h9 p/ U- `0 p* m, u7 w L9 P) C3 ]" Z, ^1 I. h2 R6 r |, L( o
static struct gpio_led da850_evm_tl_leds[] = {
, \+ x& \: z4 H) c$ X# J: w V {
7 e4 Z3 X% _# E .active_low = 0,9 \! z$ q1 S8 F$ V
.gpio = DA850_USER_LED0,7 N' B# A6 e' X# y- P$ Q9 l' H
.name = "user_led0",) h+ H# h1 D' a2 |1 L( j9 {
.default_trigger = "default-on",% H1 J0 }: h- A) ?0 o2 U x1 N: C
},
* `5 V+ b; M/ W# ?* q2 u. [9 ]& w {
9 r$ K% K, q+ p' L .active_low = 0,
4 Q' \- V3 J9 d7 c .gpio = DA850_USER_LED1," b# k8 m8 Z2 @% _0 a; p( T) s3 L
.name = "user_led1",/ p3 n; P( ], @1 ~- N5 J
.default_trigger = "default-on",
4 M: t& |4 R: z3 k9 Y7 j1 w },; `5 P ]4 ^) s& m% S! ^. j
{6 @4 g0 d6 C0 O& F
.active_low = 0,
" C! }! W [1 x8 r$ U6 }* b/ N8 l: Z9 ] .gpio = DA850_USER_LED2,% Z( y0 ?4 d2 \; @) L/ \
.name = "user_led2",$ f: ?8 x% P# N* Y0 r$ B6 D
.default_trigger = "default-on",
6 z) P* Y1 N' H- A8 C0 ?- r },
$ L9 ^. y2 d H- @6 v$ |' Q {* ]" \9 ^+ P5 G; l/ O* L+ H
.active_low = 0,
9 N- i+ }: X7 o9 O. T* {3 f .gpio = DA850_USER_LED3,
- v2 c/ z4 } P; Z .name = "user_led3",
5 Q2 s! b" X& o& z .default_trigger = "default-on",6 A; {1 a% n$ p7 ]! T
},/ l# U# q, b( G _3 J0 w
};
: n3 i% o: W& ^/ b
" b- i7 m8 }3 pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" c7 R' J P0 e3 P0 I" ^/ |4 Z
.leds = da850_evm_tl_leds,
5 B9 ]5 z3 b6 m& _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 U- _8 J) K$ ?1 B! I+ `) _};) }. \' m) e3 b# J$ P1 E! V* \
* L( f2 ?" J/ x) Istatic void led_dev_release(struct device *dev)! z# ?* ]0 I/ c1 c
{* |: Y6 P9 b: T" G B3 A
};
( |+ J$ b3 Z, \# X. M4 k' n; J) h& h
2 Q0 i+ l' h" t2 e9 i/ `static struct platform_device da850_evm_tl_leds_device = {5 R9 w' q& m# K5 k. c3 m' x6 l
.name = "leds-gpio",+ s! M" D4 D& \& f) b
.id = 1,
7 X6 V$ _( i- O8 r" Q* W .dev = {! o4 i+ I5 ^, \- x' H* f
.platform_data = &da850_evm_tl_leds_pdata,
% e7 I8 a. l* T* H: F .release = led_dev_release,. v7 [4 z9 e0 K! d% L. X
}
+ z, l( S) v' X$ a& D q) Z2 ~};
( b9 b* C) n+ c( l
) R( t3 m$ P+ K. x7 A, ^9 B& u3 wstatic int __init led_platform_init(void)% X# g; c0 t. C1 J1 u
{- }% `$ [: o) N. J4 `. z
int ret;) x7 d- t% b* d9 P- n3 X
#if 0
) g" p0 [" W' J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 p0 f+ A3 N) F! l7 O( V1 j3 w if (ret)! ^$ c6 W6 x, N4 _* i% E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, _! d$ I, Q3 Y* r# U. A "%d\n", ret);; d' j' T- Q4 ?: t' Q1 _! J+ z' L
#endif
) s: ]# T! B! q8 R4 e6 N& K ret = platform_device_register(&da850_evm_tl_leds_device);4 n9 ~; [1 T# Z
if (ret)
) z* U1 \) K1 Q- z+ \' u% _ pr_warning("Could not register som GPIO expander LEDS");% z+ Q" @. k+ A: ]
else
6 U2 ?. [2 @4 ^ printk(KERN_INFO "LED register sucessful!\n");5 W: R2 U% r2 j1 C, e7 _
- J! e4 |5 q( Y5 R/ j# I6 ] return ret;
& O! Z8 r# [# n- i}- N: I8 ^4 f4 M- v
& ~0 ]6 @# P- y8 u) S! H
static void __exit led_platform_exit(void)& S4 a4 ~2 p! E% o& \
{$ } u! m& z5 J
platform_device_unregister(&da850_evm_tl_leds_device);) a6 m0 R# i6 q3 o, c5 C
: V( C" c; W( l0 |2 F3 n printk(KERN_INFO "LED unregister!\n");
/ a+ [; p+ u+ _+ j}
+ g6 j* Z, c( ^3 U. C4 l- l+ v
' I% `' Z, r& M3 dmodule_init(led_platform_init);
, Z$ Q, v `+ F+ \/ Hmodule_exit(led_platform_exit);
8 f+ P- B: \; b7 M( O+ k
7 Y" V2 e8 o. A0 e8 T0 [MODULE_DESCRIPTION("Led platform driver");
# k) e8 O9 [+ ?/ s4 G( N3 l; TMODULE_AUTHOR("Tronlong");& J* W2 f& b& n! t; A% O
MODULE_LICENSE("GPL");
; T& t. T) a: U4 G$ e0 B% r* `- t, Q1 Y6 C
|
|