|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 m) G2 B$ \2 D( r2 f#include <linux/init.h>
% H0 ^& u% F' s! {#include <linux/module.h>" H; X$ g6 @8 v: D9 m
#include <linux/kernel.h>) p1 f+ ^6 G4 C8 E. i/ m
#include <linux/types.h> F6 `2 P' C, L- L/ p
#include <linux/gpio.h>% y3 j$ ]1 _' m) p$ o7 T
#include <linux/leds.h>0 E6 G6 ^" `' k" e
#include <linux/platform_device.h>
! t- w7 d- D6 \# u9 Z4 t+ a
& X- l7 V# j7 [! T2 B#include <asm/mach-types.h>9 N, Y5 p! m- g( E- ^
#include <asm/mach/arch.h>. D5 s, u6 m" D! U, e8 A/ H+ j/ o
#include <mach/da8xx.h>' {+ J7 `+ i# F# ?) I+ r. \* d
#include <mach/mux.h>" P/ o. S+ ?" Y5 L5 q
2 p5 {. t8 B" e$ t7 `* k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ S N- @! r! @8 I; ^, O; e: D& Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& C/ e4 }( N+ f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- u, C0 o1 r# M8 r: L4 C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 I: Y% R2 r# d$ m% s+ D* A8 A. ^: M
6 E% h1 Q" m7 \" N/* assign the tl som board LED-GPIOs*/
. J% }* ~# V+ }/ e3 E! h0 q4 Gstatic const short da850_evm_tl_user_led_pins[] = {
; L; ~8 J* s% U! \) } ?* J /* These pins are definition at <mach/mux.h> file */
) Y, t& V* _! a/ w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& f8 O: X) D/ k4 S) m
-1/ `8 n" M9 j( ?$ K2 P- O+ z; U4 ~3 m
};
, f4 v' g1 p- Q, |( O. ]( y, Y' t, {7 |, z
static struct gpio_led da850_evm_tl_leds[] = {5 a* }) Y# r3 w0 E" ~
{
! L1 u* q$ D7 X& k# C .active_low = 0,5 c4 ?- [/ |) e1 R) |
.gpio = DA850_USER_LED0,1 h! S% `! t/ q5 N% C' c- q
.name = "user_led0",
* k8 ], x1 c) @* \$ G0 Q .default_trigger = "default-on",/ A* A* `7 {' Q# V* C; K
},7 H5 n6 ~1 q) t
{8 e" w( o C. V8 O
.active_low = 0,6 E( ]5 m/ U; b: x, C$ `, u1 X3 i3 I) A
.gpio = DA850_USER_LED1,
% \2 P3 X3 y i4 f$ w# p+ d/ } .name = "user_led1",+ h. T0 d @4 T% g/ [, Z! {
.default_trigger = "default-on",; u8 ~9 x7 z8 t6 h
},
3 B/ k9 x5 L+ T6 u: M {
* I v/ l8 d; t& |3 K .active_low = 0,+ q' g: c+ F* l$ q
.gpio = DA850_USER_LED2, ]9 H! Z W% P9 w3 t2 t
.name = "user_led2",7 J0 P J/ y+ ], r o
.default_trigger = "default-on",
# q# U" n+ e+ O },' \! {$ X( l7 c8 Y9 l {) g
{) I4 |4 z7 q: F9 Y
.active_low = 0,7 g3 o; t3 p% |+ V" Q
.gpio = DA850_USER_LED3,: T v4 r* G$ {& a0 b
.name = "user_led3",
+ V* T6 i/ G8 i2 t .default_trigger = "default-on",* z& z K6 ~/ x* t' b
},
& \% t1 L7 {5 r1 \7 m};
0 K! N) w' _8 R+ e- q `1 l* U* h
' \, d6 R* p1 p: ]- n0 K* fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' L) b7 q) s. R7 x+ b2 w/ S .leds = da850_evm_tl_leds,9 [2 d& L# o( v6 R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 M& D7 P/ Y. B};. d# O/ m* t. }8 [" N0 @
; d" d' h( q8 Z) o' k- X- p$ U/ Ustatic void led_dev_release(struct device *dev). ~4 S- M/ O- i
{! U' d; d/ P! u3 _- ]7 z
};: W0 m# Z' w1 e& [
. \( F: i1 U2 N3 R& y- M
static struct platform_device da850_evm_tl_leds_device = {
2 a6 @+ v) u7 t# L8 ]6 v& j .name = "leds-gpio",- w% E1 h7 ?: }5 n* w8 {
.id = 1,
- g. _+ l4 l0 X) H0 ?4 P .dev = {1 F3 U! Y" S7 L( z! @) | @% W3 s
.platform_data = &da850_evm_tl_leds_pdata,5 K$ {" Z4 y$ D' ?
.release = led_dev_release,' o# C! s# h) M0 t! L
}# ~* M k6 x# [8 l. r- d& J
};4 S2 O! f5 C4 g( k4 _- d
3 f. N" {* Z3 Q+ ~7 Qstatic int __init led_platform_init(void)
( g3 f. v4 x# q- j8 z+ u6 d{0 e, R! x% I6 _6 g0 ^/ O* O
int ret;
5 {0 `0 C7 g, ]$ p" F5 [#if 0
9 k, }* t. }5 u5 f7 A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 y& N! e: S @. q+ ]
if (ret)) l! u. j4 z- u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& i' w1 @9 ]: r "%d\n", ret);
P3 L+ U2 ?8 A1 T# |#endif
8 [, g; Z3 C9 R+ ]$ W0 q3 f. S ret = platform_device_register(&da850_evm_tl_leds_device);1 c$ L" @9 I; D. a% H# n& y7 M( Z
if (ret)9 s, b- `$ _' ~. L* C$ R. u4 P7 F
pr_warning("Could not register som GPIO expander LEDS");( l' p' l, e8 k$ ]. \: Y" \
else5 J/ [: U) s, j
printk(KERN_INFO "LED register sucessful!\n");$ h9 n8 j# `8 I: f( R7 W
! b, T: B5 T I/ j, r return ret;! Q& b" j, T& l) V6 V9 k- c0 \. ^! I- o
}6 z% V: x/ ?: U1 [: U
" I( K Z- a" [: i; ~
static void __exit led_platform_exit(void) B4 V3 z2 y' H; U$ M/ v" s
{
9 F4 l" z5 H j platform_device_unregister(&da850_evm_tl_leds_device);7 z( @% @4 d6 S4 L
% ~5 t. y" t( P3 P/ X$ f' g% z
printk(KERN_INFO "LED unregister!\n");
; ~0 R/ u% l* i4 t: M0 C; A}+ J2 l5 G- k+ L( q9 O' R1 t
+ c7 `3 s. c3 s1 Y: s* ?- T$ }) ?) w6 Hmodule_init(led_platform_init);
$ C) d: \0 ]$ W, lmodule_exit(led_platform_exit);9 m) X0 o) ]+ [2 e6 m( [; o- Y
* Z7 [& O4 l1 u' YMODULE_DESCRIPTION("Led platform driver");/ p- ]% E: a1 {9 l9 k
MODULE_AUTHOR("Tronlong");
( n* c+ [; i8 s% A- X% {MODULE_LICENSE("GPL");
; {# z, n$ w% D
% J5 m1 K% N. p- ?, B |
|