|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 Z' P) E8 W' H4 R/ g% _% x
#include <linux/init.h>
" {; _$ W; q) {) a#include <linux/module.h>1 A- D2 ~2 s$ D/ K( _
#include <linux/kernel.h>* J' U& v- s2 k2 f
#include <linux/types.h>% F( V9 Z+ q% t! Q" h7 C# N
#include <linux/gpio.h>
+ `' U# W- T- H/ _#include <linux/leds.h>6 P1 c# ]# ]; Z
#include <linux/platform_device.h>
* I; V4 _7 `, H- K! K) t% u# C& B D- r8 r0 g
#include <asm/mach-types.h>
0 p. J, _8 B# @; c% `#include <asm/mach/arch.h>( j' i1 ?% n8 X" v7 X
#include <mach/da8xx.h>
) d8 q7 o$ | c/ j% Y; B/ }) Z. j4 H#include <mach/mux.h>2 e6 O! C: h5 v f3 {) ~1 R
, | {, I; q/ l9 | Y5 u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 D2 v) B: z; Z. h# L: O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. `9 `8 A. c3 Q6 D! C' t: j6 h* ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 l0 F: _3 z; ^7 b$ ?+ A5 K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ \4 s+ o2 N, W2 o3 J9 [! W) G, Y/ l
/* assign the tl som board LED-GPIOs*/9 `: C- }: y% v5 ~$ J2 d
static const short da850_evm_tl_user_led_pins[] = {3 A- F. F% [) v5 n# }; T- K( f
/* These pins are definition at <mach/mux.h> file */
2 x! t$ a# {/ Z: Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- a' o" t. `; H- B -1. t6 l" V6 _: P, u
};
0 b+ ^0 ^( Y+ W, I: w5 j0 \ V( t2 ?/ y" c2 I- z) N: {+ a. J9 ~
static struct gpio_led da850_evm_tl_leds[] = {- ?% S( `; F' ^) c# j* S) z# U
{2 u, N2 y5 F5 u$ U" h* ]+ G
.active_low = 0,
+ j% E8 G8 b7 |! U) J7 Y .gpio = DA850_USER_LED0,, I. m5 D6 ~- {. A: T1 M! g
.name = "user_led0",
p4 E1 B# ]$ ^" V9 [ .default_trigger = "default-on",( H; f" X/ Q; s* T/ H
},
" m7 I- D4 y+ s( z/ Z4 p {9 {, K# Q$ u) z8 g I
.active_low = 0,
, d* ?! G. |1 I8 }4 ] .gpio = DA850_USER_LED1,3 C% @( a' h% g& Z
.name = "user_led1",5 J9 ?* j9 W8 O# T7 Y
.default_trigger = "default-on",9 H, a* Q- i I% ] D
},
5 V8 M' Z6 ~& ~4 {3 w, ?" i {6 k. K: \; p7 v7 m. C. E) Y. m
.active_low = 0,
- F! b' Z: ~8 K, e0 l2 B* C; Z1 f .gpio = DA850_USER_LED2,1 F6 ?7 b( a W' d
.name = "user_led2",
" d4 }! k5 ?1 D. `$ j .default_trigger = "default-on",- b U- c0 t+ D7 A/ C* u* M, b2 O
},
! R6 r b; G" R0 z; m" B {% E b& B" |/ ?, A1 w
.active_low = 0,
& @* s. G6 x# T1 K .gpio = DA850_USER_LED3,
/ a4 Q1 t6 g0 d u f! Z& C0 L .name = "user_led3",
- @: O, {. M6 B8 Y( q# ?: x .default_trigger = "default-on",
3 z3 ^" B- f) h G/ |& S, R9 v },+ i/ R1 Z. z2 `& a/ d. p
};
7 i0 C1 A- J4 W R2 S5 U6 R8 G$ o% m `5 I# r7 I& j$ s; G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
Z) F- ]1 ~9 O% k+ G .leds = da850_evm_tl_leds,4 ~) M5 \- N& O. ^+ J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 Y8 a4 x- [+ Y
};
+ l& q% ~' K& _4 ~/ O! ]! t9 {5 d* M
static void led_dev_release(struct device *dev), r. R) E$ _% x- [# @
{0 b$ `# Z7 y2 A2 Q
};* P' t3 T+ s4 p3 i
- D) q6 C8 ^1 [+ o. \, V
static struct platform_device da850_evm_tl_leds_device = {+ U7 _$ Z4 F: l* m) |, B! H) |
.name = "leds-gpio",
1 Y+ F B; h) D) h/ x8 P .id = 1,
! ?) _% s, b% R6 H .dev = { r7 F: g" x2 ]
.platform_data = &da850_evm_tl_leds_pdata,
7 e4 Z( \' U j4 ]+ J1 W( [ .release = led_dev_release,
0 e D% _9 B" Y. M% V0 ~' c }( m! `; N0 K" L& c: K- C
};' B/ p, o8 D, D3 |
; p: N. q! e @0 e8 H0 b# |static int __init led_platform_init(void)
! n3 b, B9 W5 U; e6 h d) P{
: @1 k, G: G7 C' ~ int ret;& s) o+ v! C+ u% S
#if 0
3 m- j, E' d$ c' f* S) d O! K: L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) ^ |. u- g& r( r7 s8 }$ W
if (ret)
/ w% N4 `, L3 W3 y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' K7 W' p) |6 S" w
"%d\n", ret); B' Y& \0 n- C2 |+ S
#endif/ b9 i; B! @ `2 A' w! v
ret = platform_device_register(&da850_evm_tl_leds_device);
5 T S( Q# [! M% W' ?8 h if (ret)& ^% n& @' d- P4 r) r5 q* v
pr_warning("Could not register som GPIO expander LEDS");
$ A0 Y# K0 P9 x+ l6 B9 l else
8 _1 R/ r9 G7 N7 e printk(KERN_INFO "LED register sucessful!\n");8 W. y$ `) B, E3 D' h: n
& }' B1 }' U' x! t+ \( H; A$ d
return ret;
# \$ q2 m5 T# y/ y( X}
8 ?. G9 U4 v! d5 C3 o* b8 g. g) ]. Z
static void __exit led_platform_exit(void)3 O8 q- B9 E+ r; d
{5 E5 n, ` n% l ?: d ^0 b
platform_device_unregister(&da850_evm_tl_leds_device);
4 N6 Y6 T- ?4 u4 J* X2 D# y6 m2 J/ ^- k( n& m
printk(KERN_INFO "LED unregister!\n");+ u- x6 X3 A4 x% H2 p( {- A
}
- S) Y9 `9 f; K. J0 M1 @# g* ?% V4 G0 ^$ W) b
module_init(led_platform_init);8 S; E% M5 C4 @( V5 d. o
module_exit(led_platform_exit);) b9 ?* S% V9 m1 F+ p# `/ H
" P6 x$ M9 M) d6 k
MODULE_DESCRIPTION("Led platform driver");
8 O& r* d x, |MODULE_AUTHOR("Tronlong");" V" D* {" p% r/ n' R( k
MODULE_LICENSE("GPL");% J, M5 _ e' x$ `' N; o
$ s. P7 y k7 x) k# T+ q
|
|