|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ G/ g; K# Z+ y X
#include <linux/init.h>/ {% K$ I( W, }9 Y' r8 P
#include <linux/module.h>
) m8 s7 z8 Q: r6 _#include <linux/kernel.h>
& ?/ N+ V. S1 _* N. [4 J( B# I#include <linux/types.h>
, \; D9 v- t# H4 n8 s#include <linux/gpio.h>% {1 m" ?: f/ T" S# D- w
#include <linux/leds.h>
' ]$ V5 k. y& v( C2 m0 F#include <linux/platform_device.h>
! s3 z3 H( J/ B6 `+ F: T0 E; C! B$ x
#include <asm/mach-types.h>
! w" ~( k# d% i% H: ]# S. Q#include <asm/mach/arch.h>
6 I3 n& u, k/ x6 a5 O7 [4 \#include <mach/da8xx.h>
' h* j r& u' n9 M/ [#include <mach/mux.h>! i' C v5 U' u% w2 J
' {7 e; O8 T5 D8 u- J5 v5 ^& Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ a8 x6 w+ m: d. ?2 b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 w! f/ w$ M! k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' U9 X* L4 q! J% j( l' |" @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 a6 W2 C2 O6 h! Q) c
8 I4 h" F9 `- d& }( F" l5 R: V/* assign the tl som board LED-GPIOs*/
$ ~) c& a7 j3 [2 f9 p9 dstatic const short da850_evm_tl_user_led_pins[] = {
* U$ l( m/ e9 M5 [6 A& ~ /* These pins are definition at <mach/mux.h> file */
+ t* N7 H1 L& P$ W$ F: I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 H: s) }( P+ F -1; R6 g4 `; T: h- V" a
};
8 _" g' t* L# B/ R
# W9 ?8 M- v7 {7 [' l4 Qstatic struct gpio_led da850_evm_tl_leds[] = {4 s0 t- k( E# A; m. @4 l; B
{/ q8 m' p, F3 i, l6 m
.active_low = 0,0 o* ^% A$ ]: N8 h, n% v/ q$ T; A
.gpio = DA850_USER_LED0,
5 l4 u+ F$ v4 O$ `; W2 m .name = "user_led0",* J, p% P1 G* t1 f4 b
.default_trigger = "default-on",
7 W) \* e2 a1 J9 C },1 Z2 L1 {. l$ b; e" n
{
5 I: L# d: p* n' {& n .active_low = 0,! `. a# D* j& l2 Y6 L B- k+ i( g( H, N
.gpio = DA850_USER_LED1,
- f8 D+ u, x+ t% @* J" B .name = "user_led1",0 E9 T6 b$ ?+ z0 ?
.default_trigger = "default-on",% ~; f3 m I) [. y
},
$ }' K0 D8 ^$ ~# j) Q3 U6 y {
/ m9 ?; T3 r: T# o, Q# t" k .active_low = 0,
3 ~/ A- s% S6 z* b5 _5 g5 X. z .gpio = DA850_USER_LED2,6 D# E1 l4 Z7 q4 e4 Z
.name = "user_led2",( H0 B. x7 z+ o5 |: ?+ X, `! x
.default_trigger = "default-on",
: B& a1 Q* o E0 ]- e },
' l* T4 g: h* ?3 _& O5 n {
7 e' |1 @/ {2 J# L y, ^9 B E .active_low = 0, n0 a. l8 c" ?* a
.gpio = DA850_USER_LED3,5 S3 r5 u5 E( _2 h" h/ i4 t
.name = "user_led3",8 S6 f9 m* T5 L" V) ~! q6 Z
.default_trigger = "default-on",
9 T! `5 r. X6 }, D6 S. [0 \) _ },
( w* X% m% ?& y9 g. L2 W};
) _. ]1 L7 W9 A2 }- d' n8 l+ v% t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" e* }; z7 N- e3 w: g2 {
.leds = da850_evm_tl_leds,
9 C) B0 \; c8 x2 p' b7 \ _* q1 s5 M) C2 a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 t, O3 `* w; s! n; J5 B};
5 s. Z- p, @" V6 m2 g: A8 r9 l2 L' {; c) A4 Y9 T; u( g* f
static void led_dev_release(struct device *dev)
# |( j2 w! T6 l{
/ u% N6 k: _. Q: |7 ^$ g};8 v* v% h9 V$ b7 X; Y; O
, X$ \ |: _5 R+ \! Fstatic struct platform_device da850_evm_tl_leds_device = {) G9 N& u, b# [, ]% n O5 t0 N/ W
.name = "leds-gpio",( d" V+ z1 j# @4 J9 G1 B) A+ j
.id = 1,
0 m$ B1 Y0 H" L .dev = {
+ |( [9 s$ z& ^' _ .platform_data = &da850_evm_tl_leds_pdata,
2 X p# O9 T2 k( \* v .release = led_dev_release,$ S& x# P& M& d
}: f+ S$ m# t: ~0 u) L
};
! ~7 a- M; Z; w/ @ X6 d. P; [6 i) Z, C9 R
static int __init led_platform_init(void)
9 A3 c9 M2 B" X; n{
" A R: R8 p% D0 F4 i% h5 F int ret;3 A/ n3 G5 L+ L0 L4 Z
#if 0
4 z) l( y) @ f& h1 R2 r3 | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- m F2 V- U u8 G0 n3 m3 y. W1 \
if (ret)3 m6 m- z) J: Q/ t! O R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ N1 k" e( j# c$ R$ @ "%d\n", ret);4 P8 G' H, z! j7 E
#endif
0 r8 H3 E9 N& n' G" f8 F ret = platform_device_register(&da850_evm_tl_leds_device);6 \9 \0 g/ [& L# D7 v3 i- L
if (ret)2 f; c0 X6 J& [; o- }! d
pr_warning("Could not register som GPIO expander LEDS");
2 G* ~/ O$ ]) k- P6 P" g! `! M6 L else" N* b7 N- s9 a! e
printk(KERN_INFO "LED register sucessful!\n");
9 S1 T! y. Q' c X( C. e" D! ]4 K) H; B2 z) n
return ret; b; Q& X( X0 R; N
}
K( r$ k6 \) S" p/ S
# ]+ _1 V! z `; q/ V$ m- z- C4 Hstatic void __exit led_platform_exit(void)! ~1 V: e$ j8 k+ U) d. y0 E4 b
{
% J3 \, R/ y0 w) {5 D platform_device_unregister(&da850_evm_tl_leds_device);
: B: v% ]; H4 j$ U+ N0 Q5 V
Y8 x% x8 H2 `" r1 @ printk(KERN_INFO "LED unregister!\n");2 R1 ~2 I, j& r; E4 x9 f& u
}: t1 c# v" Q( s0 }/ ?8 D" ]6 |
5 R1 h5 E: Z( d0 \4 v- \module_init(led_platform_init);# \0 I. Y9 r3 I: |; H" G
module_exit(led_platform_exit);! q/ Z+ ^7 @) m0 R' b* R' S& ]
) n% v4 j+ O4 \. I9 C0 E7 V u# m' AMODULE_DESCRIPTION("Led platform driver");
6 P+ _; Q" W+ v& C3 U! f1 FMODULE_AUTHOR("Tronlong");
- {4 I, ~+ ]$ H6 f1 t, M6 \8 ~MODULE_LICENSE("GPL");
- e8 B {8 `( u3 q$ Z5 ]$ }& |8 K' B) o$ U/ W
|
|