|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! K8 ]+ {! \- u0 w7 `# Q' h#include <linux/init.h>7 R1 E9 e" V6 m8 |+ x+ L. h; |
#include <linux/module.h>$ u) T s: u: ^& K8 M
#include <linux/kernel.h>
: _% V& B, k9 q! x#include <linux/types.h>& t! K7 @6 h. h) ?6 ^" l0 `3 Y
#include <linux/gpio.h>
/ H7 j) w! l, ]) M4 h! y& h#include <linux/leds.h>; f1 V6 K5 U% d0 N% K2 M( |1 a
#include <linux/platform_device.h>
9 H3 L. n! s1 k' K* J4 m- D
1 H0 Z L3 k8 h#include <asm/mach-types.h>
7 w4 V6 g* ]1 |0 G' j. Z#include <asm/mach/arch.h>" U8 p5 g! K9 _1 z6 A1 o1 W! v
#include <mach/da8xx.h>
1 C: m8 \, J/ q1 ?' }5 v; a9 v" Z! T#include <mach/mux.h>/ r6 s4 G1 E. O( M& Q
9 s( J8 w) \1 B0 y: v8 z! e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), m& \; O0 |! f$ A+ N c2 x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 h$ C x9 u6 n3 T0 N \) d( W% @! f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): E! M& v n0 L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- G. Z( Y+ a2 i/ k0 f' \# ^8 z
* M! a& V1 v; s* i0 X/* assign the tl som board LED-GPIOs*/
$ Q8 U- E% X1 ]0 ]6 y8 a6 O8 l p) Pstatic const short da850_evm_tl_user_led_pins[] = {
' ^6 e0 L) l0 X6 O0 x0 m# { /* These pins are definition at <mach/mux.h> file */' C- [& Z6 e; d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 [. Q% E! x" b% A8 s. z -12 R% t/ b1 {8 c# v' @5 j
};
$ @ o, }1 @# S1 p+ S* W4 R* ?% S9 s: j9 a( ~. w% e6 F
static struct gpio_led da850_evm_tl_leds[] = {5 |/ z' X' J0 e, j; x& l0 M
{5 x: o5 V7 c! S: E6 n; \
.active_low = 0,8 _, e6 C) g& {3 X
.gpio = DA850_USER_LED0,
5 r* F2 y$ q5 @' s! ?% ?) D .name = "user_led0",
' ~( k3 Q' Z5 m+ w .default_trigger = "default-on",# [6 X+ W2 L! Q* ~0 v7 t4 c
},1 F \3 E; u8 t" ]- y1 @" i- F
{
2 [4 A( Q: ?! `- c .active_low = 0,5 c- h5 Z$ }7 O1 i3 y9 K X
.gpio = DA850_USER_LED1,
' R; M$ g* N+ j r6 s .name = "user_led1",
" H9 A/ D! K- y9 X$ T/ Q, o .default_trigger = "default-on",9 V& f; v6 a; t5 t+ o6 G. V% t& d/ Z; N
},$ i5 m N; X" p" A6 U" F
{
1 L& U& w* {" b* k6 K .active_low = 0,
5 q8 s, Q" C' |7 q .gpio = DA850_USER_LED2,# [4 P5 p% d7 L8 ?/ b3 Y
.name = "user_led2",
- T, d' T7 ]" F3 n# x' M4 _9 Y .default_trigger = "default-on", Z/ L! c# Q- `* O/ n: V2 j
},1 M9 t6 U; |/ T+ Q9 p
{
! L+ `7 R( K; z8 k6 W; u .active_low = 0,2 R1 Q/ b: O1 s' d9 Y
.gpio = DA850_USER_LED3, L& t) [8 P! H
.name = "user_led3",* Z2 j$ o2 N! B; X! Y
.default_trigger = "default-on",3 F1 t) C; M/ w' X: u4 O5 Q
},7 j/ }) ^. V# O; f
};
1 B3 X& G- @; a5 {* {6 [" b! z* U- U0 `, i9 G0 X- { t- x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ X; C( s! ~- _1 f$ o. w
.leds = da850_evm_tl_leds,& S. B' E8 O: ~. H* I) n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 M; B, k: e2 v0 ~};
: D7 |6 I# O0 o& q$ m; [6 u" q+ v8 U* Q- D; U
static void led_dev_release(struct device *dev)0 T% e% v& c, q9 ~# e* w0 }& D
{
( d+ U! _" t- c- x0 Y};
) D9 Z! |. w. r- l6 ~
& a; t0 w4 J& g3 x& Sstatic struct platform_device da850_evm_tl_leds_device = {# D' }, t8 W5 A B
.name = "leds-gpio",
& q' I6 @( _& d, @8 d5 s .id = 1,
- D# N- I& f( H6 u, i( U7 O! V .dev = {; `3 [% g- d1 P
.platform_data = &da850_evm_tl_leds_pdata,' g& [: W5 f' Y6 V
.release = led_dev_release,
- p, j0 x8 J- J, z }' S. u2 O/ S! b5 _& g l; r9 K% s
};% _% i- N: ?4 Y" E! Y
* d4 d/ j/ H4 U* W* R# _. h
static int __init led_platform_init(void), H+ V4 c# Y7 y% s- R9 {
{, e# U s( @, e) T' ]1 ~# m7 J6 w) N
int ret;
' n) A6 m, d, B#if 0( I, ~4 z& U6 F0 ^7 }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Z- O0 ^% l9 w* n R
if (ret)
$ |4 Z& s1 @% d3 |$ \& w* d& ?6 r& e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; g+ [' A9 ?: t# C* q "%d\n", ret);
3 \4 t$ C, C3 O" y0 Y#endif( x: G9 Q# o0 P# O, G, G. T
ret = platform_device_register(&da850_evm_tl_leds_device);" m3 {4 \2 u P, n2 T$ ~0 {8 E
if (ret)
+ F$ e: q/ G; l& U% ~ pr_warning("Could not register som GPIO expander LEDS");
5 G- W/ a) [8 n: N else Z: g* r. K, _4 P4 P
printk(KERN_INFO "LED register sucessful!\n");
! l4 B6 p, J* t, g* `
1 g" v" I, I2 j return ret;
0 X6 t+ Y/ `% l}# P! {# `7 h, U! x# I5 f
8 F" v3 ]+ a. L+ o! z/ R% ~
static void __exit led_platform_exit(void)
' E% c2 W) W: x9 u{1 {1 R. s0 b8 i. a( |8 \
platform_device_unregister(&da850_evm_tl_leds_device);
6 T& m2 N. g5 j2 \# ~7 _3 t9 m. N. p/ F/ ^5 O0 ~& Z
printk(KERN_INFO "LED unregister!\n");
3 D# i4 p/ [! G r" j, _}
- d7 j1 V$ y+ o$ x( t
# C$ S1 h8 O& H6 Z; D9 D1 p9 X9 a: Rmodule_init(led_platform_init);# b; m4 y, P4 _" l& v
module_exit(led_platform_exit);
0 X6 e7 {9 a3 M8 M/ e1 M3 j" E9 g% R) r! Q3 t! P
MODULE_DESCRIPTION("Led platform driver");3 T1 }- E! m- f( z7 ~
MODULE_AUTHOR("Tronlong");
( M, g8 i% a' p7 I5 l/ ?. ]8 \MODULE_LICENSE("GPL");
0 g4 F$ y& D: s( p7 |5 f& W* |; F; R
9 Z9 m _2 K6 w$ s8 x% s9 W8 R) ~ |
|