|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 D9 F8 v! M5 {#include <linux/init.h>
# B& c: M ` p& ~#include <linux/module.h>; p1 r$ L. G; u' p4 \) b
#include <linux/kernel.h>
. t# u' f+ h" F# L#include <linux/types.h>: j1 F( [2 D* X6 j
#include <linux/gpio.h>! F$ d1 G) E! A' u( \
#include <linux/leds.h>+ b7 J8 U/ F# g3 ?$ |- s
#include <linux/platform_device.h>
3 W l- E8 t0 x$ n& ?4 G; B! Q2 [
#include <asm/mach-types.h>
% D) v, y, ~8 @; ?8 P7 \* s, G#include <asm/mach/arch.h>
; W9 k! n: N+ E( h: h* q& b#include <mach/da8xx.h>" E7 R! E5 u" n$ K. V
#include <mach/mux.h>, `- m( O1 E1 b# u5 ~$ l) B
/ r9 r( {, a2 ^, u* ?! b% q. q8 l% a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ @4 {/ Q* `0 _+ }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" `- w$ s! A- i( O }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 I2 l/ D7 @2 v) U: x3 d: m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 ^1 Q1 e# g7 A: u7 I% C- ]
4 W' o' O$ {' S0 @/* assign the tl som board LED-GPIOs*/
5 {' Z" [. I) _' vstatic const short da850_evm_tl_user_led_pins[] = {
5 C1 ~ P/ M. ] /* These pins are definition at <mach/mux.h> file */
: v% S, L$ R: A8 G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ e$ }2 D4 t9 X6 g a5 I5 A. c
-1% U4 g; q/ C- d1 \# S& l
};
* ?6 F5 u2 B* r4 ~* h- v( ]& C# n' E/ G, {, N. k% l
static struct gpio_led da850_evm_tl_leds[] = {
6 @% ~) c; w7 J X+ u {- U; E! Z6 t3 i: ]
.active_low = 0,
/ H6 H( {" e+ w .gpio = DA850_USER_LED0,* f& m1 e0 w9 k( N+ h
.name = "user_led0",% P. Y$ e( b) a9 Z1 i: v# I2 T" o, j
.default_trigger = "default-on",
" u3 B# v, y% i },
2 t/ G2 D: a8 z) c5 e5 v {5 ?% |, ^8 l, Y! Y* Z
.active_low = 0,
. {1 s. j+ S: h$ P% Q .gpio = DA850_USER_LED1,% X8 d( }& x/ t1 g; \
.name = "user_led1",
$ T3 G4 Y. Y1 L: } .default_trigger = "default-on",
* x9 W; c$ P' \+ T) Z& F: X }," W V/ X# u# t: L
{% p. ?2 Q: M; V" H$ T
.active_low = 0,
2 N$ \, \# c/ {' x% F# Y) ? .gpio = DA850_USER_LED2,' n1 h% ]8 i7 V& O8 J: Z
.name = "user_led2",4 o9 q7 z# U# B2 ^ U% ]7 r
.default_trigger = "default-on",. R& G0 v3 a3 I+ c& h
},% V. b/ H" m+ s! ~: o- \$ Y1 o0 M/ o q
{8 a# p( X2 j/ Q# y
.active_low = 0,) c8 y) p/ w G. s) d2 }; S
.gpio = DA850_USER_LED3,; A" B& r! Z2 @
.name = "user_led3",
7 w% H4 Z; t4 E# }* h .default_trigger = "default-on",
0 H: u: ?! o: j7 o },! u% m6 u' R( c4 l. f* P- O: j
};
3 P, ~& A# O7 b
2 Y" O3 {4 }- I. h* o, Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* s. j+ N" b" A( X3 r6 L, [ .leds = da850_evm_tl_leds,
3 X, W m1 j( d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: f2 R, W- M/ k/ j};
4 d! I- b: O5 Q+ M2 C' }! v- K2 \
static void led_dev_release(struct device *dev)$ L8 A0 V0 S4 c' r, I
{
+ W( c( R+ V3 B; e( G) t};
7 H5 v+ P% `$ o# P4 A, p+ M$ K. V- m" S" N' I0 q
static struct platform_device da850_evm_tl_leds_device = {1 @) e' a( A; G% P; z3 u1 m
.name = "leds-gpio",
# J1 e( t8 u' h3 @# C .id = 1, w! Z4 s; d2 W3 w6 l# n
.dev = {
$ \& S( J6 p9 P: B+ W: \: q6 g .platform_data = &da850_evm_tl_leds_pdata," s0 H+ G+ u) @7 L3 g9 [& I, _% ` I
.release = led_dev_release,5 U7 D' v9 y1 w" `, X0 ?8 ?. F
}
2 ^* { w) p. D0 }3 G};( I) j) M" i6 A# b6 r
0 B1 K2 C" m/ c8 I7 J1 ~static int __init led_platform_init(void)
* P9 s1 f7 @8 S/ _0 M" Q/ _{
1 D; d7 q2 f2 L! U int ret;
' F9 `4 f( m: a8 c% o# [5 D& O#if 08 o" }1 F! R+ S d# b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: K o6 U- F& C( N* b
if (ret)" B0 u. k/ t; w% h. q+ ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ V q. v5 ~2 `0 _8 \2 g3 b6 T; [ "%d\n", ret);1 {) c- `4 w6 ^7 f# ~
#endif
' s; I. P2 t; R ret = platform_device_register(&da850_evm_tl_leds_device);2 T; d* \% z" V3 Z" V" K, @" t
if (ret)& t6 d3 j# A4 q# f/ l' Y
pr_warning("Could not register som GPIO expander LEDS");
& D3 u* |( f# m0 ` e0 X @ else4 Z% |( Z# Z9 U- L. f" r
printk(KERN_INFO "LED register sucessful!\n");
" `0 n7 ~& {' |. _
) }5 ?- t% _3 W3 f% t i+ W return ret;3 J8 M/ l* ]0 f8 S" t! y& g
}7 k$ B, I* ]- N
1 c% O$ D$ x* o) }3 j6 O) Kstatic void __exit led_platform_exit(void)8 G8 V) g( b, J) a2 b# I, t
{
: b- v" g y+ `$ s platform_device_unregister(&da850_evm_tl_leds_device);4 q/ F& \; C! m$ |6 L
( x/ q. {) }0 A- I printk(KERN_INFO "LED unregister!\n");# v3 i- k- @$ c) j
}8 B' B/ _2 V5 T7 \0 R- w r
$ h( j0 X4 w# ]2 {5 _, J7 Y. A. ^
module_init(led_platform_init);6 P* Q; K& |8 k* l3 U; R+ W* ~
module_exit(led_platform_exit);
% T, G8 f- u3 b! T. [; y+ c% D' v$ H) g
MODULE_DESCRIPTION("Led platform driver");% z; R% i7 d3 _( n6 v( u
MODULE_AUTHOR("Tronlong");
7 _5 J, ]. V4 eMODULE_LICENSE("GPL");
! c5 g5 A* q/ T6 ]& k$ _ }9 j' X9 y
|
|