|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ l8 ?* d+ x b7 B ?8 M6 h#include <linux/init.h>- u' p: e* j% I: G
#include <linux/module.h> T' ?/ h: o6 ~+ i, ?6 f! o& U
#include <linux/kernel.h>
, {- k2 P0 b3 y* W) e; \#include <linux/types.h>
5 I0 V- O/ \( W- P8 m9 D#include <linux/gpio.h>
, P$ _ y4 H7 h# P( a#include <linux/leds.h>
" p- n9 w! Z, F5 a#include <linux/platform_device.h>
* X" X, c$ o, G6 l2 o9 F6 P! h; c
( N# \! \, g9 W$ v' }. r#include <asm/mach-types.h>
/ Y1 I$ l4 ]+ i1 }#include <asm/mach/arch.h>4 D. I5 o3 A! D( O( R7 s; o W! m
#include <mach/da8xx.h>
! q% c4 u. R1 z3 w% R" p5 |#include <mach/mux.h>
# Q5 U# @2 D. V4 W# u
% C/ U6 d' v& N0 {* q0 }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ l& S2 l; D* O/ X3 w' r: ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) G$ H$ B* b: T: }' r- g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) X8 Q. Q4 ]$ r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ i/ i8 \) B0 Z5 r0 e! |
! L/ N: F j" ^( C5 S/* assign the tl som board LED-GPIOs*/
3 {5 B4 h: Q3 F$ k5 E( H ?/ H; Vstatic const short da850_evm_tl_user_led_pins[] = {
3 d$ v& g2 \+ N' t- h$ E /* These pins are definition at <mach/mux.h> file */
2 a& o) S V4 h+ p7 I3 D9 y8 Z5 y1 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; ?/ G3 |$ M# {6 } -1* X6 v, A1 ?& X
};3 E( n% M4 P4 Y1 T4 t' z' {% m
) \! `* A: f0 l6 @static struct gpio_led da850_evm_tl_leds[] = {
; q3 G2 K! }* k% ?- ? {0 a4 n) t) R% _7 i1 C L
.active_low = 0,
: [3 S4 L! Z: z; j: o. o0 q/ k- o$ V0 y .gpio = DA850_USER_LED0,
" Y+ D( k O( d$ f/ L. u4 n .name = "user_led0",
& @, N6 {8 l$ D& C1 X .default_trigger = "default-on",
4 f+ E" |* E2 \% k( ~# f },+ {- M1 Y4 x+ q# U8 _5 R; G
{
2 l5 W- j% K: h& j .active_low = 0,$ U: t, W5 }# Q
.gpio = DA850_USER_LED1,
* n9 S$ `" S6 X8 R. ^/ o .name = "user_led1",7 ^% {1 l; e$ |$ }
.default_trigger = "default-on",
; d. w8 H# |8 e5 ^ },2 L+ j! k9 P1 l7 w4 |8 p
{- U0 A+ Q r6 k- [ t
.active_low = 0,) F8 `, c8 }2 Q. a
.gpio = DA850_USER_LED2,
5 d0 T. V# J# {$ F5 [& u! C .name = "user_led2",8 J& M5 j! p1 z! O
.default_trigger = "default-on",
$ S9 h1 J- K& N0 u% c },1 M9 ?3 X( r/ B$ c
{
@% W4 a, t7 b .active_low = 0,; i0 [- `! o9 B' c& {$ A
.gpio = DA850_USER_LED3,
0 n, l# I; t. G8 Z( p .name = "user_led3",% ^/ y$ [9 U( J* O
.default_trigger = "default-on",
) _9 |& c# }" ^/ s* g- R/ e },
0 L8 _# i, w) V* W+ w};$ t" `# s2 n) s+ \7 B( e8 h$ R
: ]% i) u: {5 R+ K/ H" i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 W" U+ v+ M S5 M
.leds = da850_evm_tl_leds,
. ^. D6 m+ @6 `' T& i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 K- I% A3 Y9 ?, _. J& K0 A
};5 p. L3 I9 j$ c$ j; C1 S
1 ]7 l" \% I4 mstatic void led_dev_release(struct device *dev)( ~) J) F! W* V8 S. q
{' @ \' ? z1 J
};
# V. y( F2 A, `1 E% q8 d
7 u* y# i$ j. e+ ^ }static struct platform_device da850_evm_tl_leds_device = {
5 c' y- M# F: ^, Q, p .name = "leds-gpio",
" V9 r) E8 G" h .id = 1,' o( \5 J% d9 B% C* v2 @ y
.dev = {
' X+ L m) B" G3 ^; O .platform_data = &da850_evm_tl_leds_pdata,
0 |+ E3 [) {/ e- E/ V+ M .release = led_dev_release,
/ ~" \; r' W: j! p; G8 [9 ? }
a, ]5 v3 m+ A! ^. ^};& j; X6 U9 A; q( \7 H' ?
3 o5 Z5 K/ m1 L+ k) h* S
static int __init led_platform_init(void)
+ Y9 ?6 M5 p. v) K& v8 W) V' ^{
0 i/ C( \9 v) _4 |2 y int ret;( {+ t# O& t8 U& H
#if 0
! }3 v' u) @( [4 j) [- z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ I: t( X* a o2 R if (ret), o- C* a! g* U4 C% l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 p: D- ~! |6 E- T, ]8 }$ }) I
"%d\n", ret);$ H. z9 B: C5 f4 s8 }* I
#endif
0 w6 a @0 g5 ^) g ret = platform_device_register(&da850_evm_tl_leds_device);+ O( I4 [8 g2 K$ c" W+ t* M( x
if (ret)! l8 {8 j/ u2 Q4 g( Y8 C
pr_warning("Could not register som GPIO expander LEDS");+ I: i: o; V1 }" \
else
7 m R, A8 ]* U. X9 l# |; W) M. T printk(KERN_INFO "LED register sucessful!\n");
4 `7 \: u' {' S2 v: D! D# l0 `
$ o" X; e8 g) s return ret;
$ l5 ?( e5 a1 x/ J- A, {9 [2 e}
9 Y- f6 F2 Z. I
+ Q. `, T% R( L. R; estatic void __exit led_platform_exit(void)3 U' ^; ?* I$ `! a1 I. x
{
* Y" T5 D7 e% f+ i# M platform_device_unregister(&da850_evm_tl_leds_device);- A' O0 o) U @' f X+ ^, D
- ? _3 w6 Q& t8 a) ]4 o* H
printk(KERN_INFO "LED unregister!\n");$ p$ _0 [' U9 }, I7 y- `6 I7 Q
}
& h! [1 w8 ^$ k8 A
$ m- q% l1 b; ~" _( t8 Umodule_init(led_platform_init);* Y& t- n: t1 H
module_exit(led_platform_exit);; T3 P+ b+ }4 |: [
& W/ W: H1 R1 \6 o1 l- qMODULE_DESCRIPTION("Led platform driver");+ E+ }; c/ E6 ?7 n. i2 u0 o# R( @
MODULE_AUTHOR("Tronlong");9 g0 r- E1 g* s
MODULE_LICENSE("GPL");
( j/ R5 `4 ^0 D) x6 J' T. H( |
: W7 x% ], w2 x0 x |
|