|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 w, T' P% x. \
#include <linux/init.h>, _5 \6 |% F& n$ d+ D0 [+ }
#include <linux/module.h>
, J; W7 ~7 i! w7 Q#include <linux/kernel.h>. ]% j$ h+ @9 O7 B
#include <linux/types.h>, T- }# Z. I$ ?
#include <linux/gpio.h>% s0 v3 W2 ^% L! D$ z/ l8 \) d& m
#include <linux/leds.h>
% l/ [2 I) p/ j#include <linux/platform_device.h>
# m u1 q1 ~0 q d0 J3 b% `4 p0 b, L
#include <asm/mach-types.h>( s/ k9 `# A. d" H
#include <asm/mach/arch.h>
4 b; c4 f0 G; t7 d4 C3 x#include <mach/da8xx.h>6 w: v; ~2 D3 @6 |* D9 {- `
#include <mach/mux.h>
$ P+ U, a) Z4 e0 g- X7 i F" f' j1 H+ [2 ?7 Z9 c: u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* ~, ^3 _" p' v/ a( Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% c2 T7 ?3 d3 ?" D( Y' {1 _/ o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& m, a5 O+ g; Q1 J& W" w6 @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% ]/ M. p n- a1 i* S% l7 I* p9 \# H2 K$ M! ^8 Z
/* assign the tl som board LED-GPIOs*/0 |3 f+ R3 d; g& f
static const short da850_evm_tl_user_led_pins[] = {/ s+ K8 q4 h6 w n8 A2 _9 F
/* These pins are definition at <mach/mux.h> file */8 v. M9 ]- J* g0 E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: ?$ J$ S4 t6 s# _/ O -1
, @( L, J3 V& b' A- H& W};+ X+ b" \( f$ x% |0 Y: S3 \ ?
+ E1 B; a( V- c9 e% k, l3 F- H7 sstatic struct gpio_led da850_evm_tl_leds[] = {
2 I* J! K% {, v, y S {
% x* W' ?+ `% A9 V8 a% n2 P .active_low = 0,8 }$ E& _) }- P1 Q
.gpio = DA850_USER_LED0,3 v% u) l: F* I5 n+ m3 H7 {8 j
.name = "user_led0",- o, w2 {( k' i, ^3 g3 A
.default_trigger = "default-on",
6 a' A2 ~% y9 J, _! C7 h8 L },
/ U5 I+ F# m9 Y; }- z: E {
7 I9 y: o: Z& x" X .active_low = 0,% h( N2 G$ V8 P/ u6 e+ B
.gpio = DA850_USER_LED1,
( _! f( q; X: C& s2 G% @% H .name = "user_led1",
0 s* \( z1 P# _0 k! M- N% O .default_trigger = "default-on",
7 m4 ?+ R# L8 B# R( J2 T% ]$ Q( P },9 y& H( P+ x1 Y) H$ `8 E& a6 P
{0 Q4 H4 G" j9 w8 p8 D5 J
.active_low = 0,
5 F: q. O: @1 @ [8 T# u .gpio = DA850_USER_LED2,$ t7 x1 s1 _' T0 p
.name = "user_led2",% d: l; e5 z& {1 E8 f. R/ \; l
.default_trigger = "default-on",
5 \( y/ e+ ~0 T) S% @6 h# S },, M9 g9 D% ~2 W: x0 Z9 g
{
/ J2 \4 {( x; _7 l2 h' ] .active_low = 0,; Q& {7 m) j! K3 H [9 z
.gpio = DA850_USER_LED3,
* i1 [- m% m5 X0 T# q .name = "user_led3",- }; s, J# \# _2 D8 S; T
.default_trigger = "default-on",
0 ]4 n3 o) i9 X1 V/ E },
' L) j9 u, q( i s. Q7 Z};
/ \7 {& b+ C2 o, V% o
# B7 j2 e2 N0 t( O0 Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) Q8 u6 q: r- W
.leds = da850_evm_tl_leds,9 n" T' B3 ]+ p- o7 ^# b5 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% C- M7 `8 ]' {+ j4 a$ r};
- I. e( O3 i6 ?! H0 U& a
3 G; M8 v- c5 ]$ P& B. Bstatic void led_dev_release(struct device *dev)
: \( Q+ A" w1 ^( W) U{
+ E& G" d& D+ ? j' @};
4 Y- z% e6 p5 `$ \& ?8 Y! b: M" c
static struct platform_device da850_evm_tl_leds_device = {
& @& @, k" O) V/ M .name = "leds-gpio",
1 ~( h( l/ ?7 P" q2 m) G1 t3 o4 t .id = 1,
2 j* {4 N+ C" t) Q. _4 G4 Q& K; b .dev = {2 n# C6 `) T9 ?8 g
.platform_data = &da850_evm_tl_leds_pdata,
3 q2 B7 n$ }- d .release = led_dev_release,
2 O" @7 ~7 S" i' B, l; G }
) W8 l6 x- p5 i* I- @: j};
; ^1 w" B! f2 A" ~6 X
* `, |" T# f, B* ?& M) `9 sstatic int __init led_platform_init(void)
8 f" \. L" V. e9 X7 T4 K{
k, x/ Y# B/ @' o/ p% x, m% b int ret;2 v/ h* O; O! c" W2 z/ k* K1 U
#if 0! o4 z- ]. }; B9 ]9 e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! \8 \7 Z* n' R2 g4 F. o m! |
if (ret)
' ]% R1 Q/ I9 m& \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! j' G" R$ P( O' R/ X$ x* E1 K8 a "%d\n", ret);5 |. s4 C' W- J" S" y) X
#endif# n1 K& ?% I) d- Y4 G9 O
ret = platform_device_register(&da850_evm_tl_leds_device);
. s* N, K2 f2 `9 s. D' {( o8 `& M if (ret)3 \1 L' p7 k* L3 T6 g1 w$ m
pr_warning("Could not register som GPIO expander LEDS");& F- T" q' M6 X; Z
else
3 S; _ |* \: D4 T printk(KERN_INFO "LED register sucessful!\n");
% G: M* g6 I: j2 H0 I; w X/ b, [1 `" @9 S/ ^: L; r+ h. m
return ret;
4 N# M7 Z- r" q+ |5 v- @}" g, B' L5 i; O* \# r% }
! x2 g5 F2 B7 k1 x9 K8 h+ a- K
static void __exit led_platform_exit(void)
1 R$ R z/ Z# [- e- _7 t{
8 y: Z6 K+ A8 `3 i" F platform_device_unregister(&da850_evm_tl_leds_device);
9 m R1 ? C: ?* X
! W X _1 m% J6 [. A D) r printk(KERN_INFO "LED unregister!\n");
% V' Q6 ]: e* g/ _) B: C0 C}
* q# S! C/ r7 {, f( M
7 N0 z9 v$ q* c, z/ L2 O V/ Pmodule_init(led_platform_init);# g4 r% _0 {- Z( h" ]
module_exit(led_platform_exit);
$ T6 A, \2 y+ s; t/ a
# _0 q4 P+ J; K3 j' LMODULE_DESCRIPTION("Led platform driver");
# ~' r! @% [3 wMODULE_AUTHOR("Tronlong");4 r, H! F" R4 K3 H
MODULE_LICENSE("GPL");
% S, S1 q! L$ S8 [' V8 r8 `7 u) a9 o3 I
$ a# \( v6 [" m5 f3 B$ q' F |
|