|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 X Z9 I) G9 T# h9 T5 y7 f0 X" z0 I% _% l#include <linux/init.h>
. ~ b+ [0 T; w+ y& { V/ i#include <linux/module.h>5 W7 ?6 x% @: j
#include <linux/kernel.h>4 F- L( w. P) v, `
#include <linux/types.h>
) H: G( W5 E: |' y#include <linux/gpio.h>
8 u8 R5 i) R5 A+ F4 q#include <linux/leds.h>
7 U/ c+ t, q# p$ T8 d w ^#include <linux/platform_device.h>
. G" ]$ b0 v/ Q2 ~; u9 I
) }/ X6 H! {. b0 g( H Y6 R#include <asm/mach-types.h>
, i0 l9 ^0 R1 V#include <asm/mach/arch.h># v t9 g2 W. x' @& Y- q
#include <mach/da8xx.h>
( W" r/ {# W/ w, Q) X#include <mach/mux.h>4 X) L/ B+ e# U$ M. R* j
8 ]& O, M. g0 y8 P4 K. Y& T) K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 p: J7 ~5 H! B4 j9 [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: H% Y( P; h) [" ?$ i, e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ p1 w1 w- S7 o4 `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' E& X, O) h A2 Z
3 w: r# T* i5 s! @: ^* |/* assign the tl som board LED-GPIOs*/
" ^4 v6 h( k4 o) [8 cstatic const short da850_evm_tl_user_led_pins[] = {
9 P2 s0 x- N$ v7 X2 ? /* These pins are definition at <mach/mux.h> file */
: X L, Q& c4 {& D! I, f7 L2 h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 n5 i& s( m4 X2 c
-1) I' [' A6 N3 W& c& X
};
+ k; H4 H. i# m! |7 } j! b7 k3 o2 I) a: e
static struct gpio_led da850_evm_tl_leds[] = {7 M8 d: w+ w0 Z# R/ h; F! ~6 e
{" c' k1 r6 r/ k0 i! K$ m4 N( Y
.active_low = 0,
* @& j* L: ^ ~ .gpio = DA850_USER_LED0,' L& V4 I$ n5 W
.name = "user_led0",6 m, `+ A6 P' f8 ]- c
.default_trigger = "default-on",! r# u- p# h( I% B- q
},0 c o5 v/ S0 }- W! ^
{; n6 u; V' v" `
.active_low = 0,
% E2 C- P7 P+ _% [' C7 z- y .gpio = DA850_USER_LED1,
8 L3 I. e3 i/ a8 U0 M2 u1 K- L .name = "user_led1",% B Q: o. S6 j6 ], ]9 o0 o$ i
.default_trigger = "default-on",, {+ u) ?7 M1 d" F, b- q: o0 J
},
$ c2 c# {. B" l3 S7 ^ {$ Z' B1 R! }. H, f! J
.active_low = 0,8 H; O( m" \: G2 T6 k9 w! N
.gpio = DA850_USER_LED2,
6 w V; ^; G5 ~3 y$ M, V- E9 W .name = "user_led2",: k8 A, B6 w. h, O' A
.default_trigger = "default-on",
0 u/ q8 ]* A. [* l# l9 @* d7 P },
9 ]; r) i7 h5 O0 f( k4 G: D {. _* P- u2 N+ K
.active_low = 0,
$ p% M" f9 \+ ]" C s; [ .gpio = DA850_USER_LED3,
" \; r# |* t% j! t; A .name = "user_led3",( G* o4 c# e# K4 S" F8 g
.default_trigger = "default-on",
, J4 X) x# P, O2 F. V& ~' B1 I4 [ },
0 Y& \8 d; U3 b};- ^5 s% }& |$ C! @9 }; K
. @* |. V4 d5 T8 X3 x, ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 G9 g: _' z; x+ h0 c' F# f .leds = da850_evm_tl_leds,
& R7 d- {2 z7 N" ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 J5 h. R* a# k
};5 O2 C- j1 \& b0 |) H
Q; q" e( M7 r' _ ^/ e' _! w& Ystatic void led_dev_release(struct device *dev)" }- o; V: V c6 d9 @7 M( g
{
% j3 c1 J/ y9 ]$ A( M" y) k0 I};
' j! U7 r* Z! a5 Y9 }; x* y6 L, g2 R1 _& S
static struct platform_device da850_evm_tl_leds_device = {* I: H! `: [; a! f# N2 Z/ P
.name = "leds-gpio",
' N. g, { a. p, g7 { .id = 1,
& m+ h$ G3 j9 f K- e' i5 U .dev = {8 X6 o( X4 r* ]. d
.platform_data = &da850_evm_tl_leds_pdata,
) N% d' m& A1 ~# F8 u' p .release = led_dev_release,- B% j6 S8 P3 n8 ^' {9 h9 K: E
}
7 a1 V. i; n, w/ O) k$ Q* [};
# S" q4 r/ I* v+ Z) n6 p0 b8 k6 s* I- _- j0 H( ^
static int __init led_platform_init(void) R3 P3 n: v8 u ^% W
{9 x2 n: ~$ y/ k' b. X
int ret;3 V; K1 I: `) X/ y2 _
#if 0/ ?* ]2 I. G2 r* l7 B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 L: r0 Q4 h6 p2 z: \
if (ret). J& r1 b0 {2 c9 W7 ^0 F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" i0 \& X8 f+ g
"%d\n", ret);
S. X" O; n3 t+ ^& \#endif7 U9 [) m, R7 [! g: c, M7 K
ret = platform_device_register(&da850_evm_tl_leds_device);! }. b0 q& K+ Q
if (ret)% Q; v+ B# o/ `5 [; M: o' @
pr_warning("Could not register som GPIO expander LEDS");
. g" s) E- z0 i: T% q+ U; s2 m. Y( D else2 t$ f/ l- Z& a& @' L& U5 j
printk(KERN_INFO "LED register sucessful!\n");
4 W6 R; z! Q# H" @1 b" H
! g, p& t- f( C7 ^2 o return ret;
/ s( q- Z C3 c' N, e x}
. K0 W, _! i# V4 ^
# Z, Y8 g# `# E0 I6 x$ h: _static void __exit led_platform_exit(void)
! f6 {! y! N( C$ P. {* _4 }& L) K{
6 m' k$ z/ b8 x/ |6 x platform_device_unregister(&da850_evm_tl_leds_device);
) E) ^% }4 Z5 i# c$ A
, H# P1 }1 ?$ d+ w) o) i printk(KERN_INFO "LED unregister!\n");
. C2 X" e1 @" Q# p- J* R" S}$ j) V1 z1 q3 d! e( t& W- t0 I
, u1 P* T& Q" }2 ]module_init(led_platform_init);
9 c4 r3 d2 f/ u3 P/ v) i" E8 l* Gmodule_exit(led_platform_exit);
4 H/ q, ?& s4 p
$ H* \/ D, B+ f2 ^MODULE_DESCRIPTION("Led platform driver");
& j! o1 @, X# n& c: [: x7 CMODULE_AUTHOR("Tronlong");# q' I. d, ~' L8 S) g
MODULE_LICENSE("GPL");
& [, X( u" Q x/ O1 s0 k1 d% a+ }7 s3 i4 L, _- t& d
|
|