|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 B* @, l7 t3 I$ |! ~* v#include <linux/init.h>
6 Q8 L& u! K7 \% ~& O; o5 }4 N#include <linux/module.h>8 m/ k8 ]# _- m5 q
#include <linux/kernel.h>" I& H! G/ C: h; x
#include <linux/types.h>
# R, K0 n9 {4 y) Z! a% m#include <linux/gpio.h>
0 l: D7 z; v! [#include <linux/leds.h>: m( m e4 M6 Z( j* k
#include <linux/platform_device.h>
/ W$ D0 ]+ {9 z9 `$ T5 ?2 u
4 `: J3 e" K3 w* p K#include <asm/mach-types.h>
, Z0 K ?/ c8 I. \$ _#include <asm/mach/arch.h>
/ R. e% P, c3 Q' e#include <mach/da8xx.h>; i. S$ P5 T' ~% w& F( W
#include <mach/mux.h>8 T2 `7 [, y- h! ^2 m) M! j
4 D- g( x h2 L2 M$ K3 G- R6 [' i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 ]# ]0 H$ W% ~; D( y1 o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# X v4 C7 {# h, @; a) J8 G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* F; |/ `9 p. t, H! }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 `) W1 m4 X) A" M
# B) z: o& r7 q/* assign the tl som board LED-GPIOs*/8 y0 L* {5 s: N% Q: J6 C6 G7 C' I
static const short da850_evm_tl_user_led_pins[] = {
- x* ?& ^1 _0 f5 [$ @- K$ t /* These pins are definition at <mach/mux.h> file */
& Y) r' W; R* b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 K9 U) t; o; g* S
-1
6 y O7 j+ H. `! j; O+ h J2 L0 c};
" O2 w0 P8 P: X y+ ?; x3 J7 I: |& K# a& V( D! {" ? E D
static struct gpio_led da850_evm_tl_leds[] = {3 ^$ s1 L4 P1 b0 s
{
8 Y: u0 E7 j& F* a5 j# ~7 v1 S .active_low = 0,
( f( i p. Q: J: Z) Q' U .gpio = DA850_USER_LED0,3 s8 h! o3 v1 c Z( |' [ b: \
.name = "user_led0",
; f1 a' t% {1 x* ~6 J .default_trigger = "default-on",
+ } S$ g' p- k# v) c, P2 h },
2 Z# b* g% e) `, D. d& I7 ], b4 ` {5 J3 i$ N _0 U0 A
.active_low = 0,
, k: u7 p5 ?8 s% n$ {$ S) G .gpio = DA850_USER_LED1,% U6 d( u- w5 f/ M
.name = "user_led1",
. k3 e) g. w [8 w) r .default_trigger = "default-on",
& r) n$ K. W F6 S9 B },0 {, t" K7 v) U0 S
{, P4 S( R. ~: u% V, Y, }
.active_low = 0,
; g+ ~& G$ s4 p) F( s+ m+ C% j .gpio = DA850_USER_LED2,) E& I$ R# A0 s8 B
.name = "user_led2",
3 W8 Z1 D) j" X3 l+ v: L. ]/ o% b .default_trigger = "default-on",
* o0 `7 {6 Z' ~. i4 w: C },* c1 i3 w! Q2 f8 R
{2 ^& }, X, y1 G Z" j+ A2 n
.active_low = 0,7 ], m3 i$ n. ]- _8 t, H
.gpio = DA850_USER_LED3,8 o6 t+ j) ~+ l2 t$ i$ O/ X# ^% `
.name = "user_led3",$ r4 t* Q# w g+ d3 @
.default_trigger = "default-on",
" `. E0 x8 K1 `1 {, I* r- e' X+ d },
k. C1 w4 I V5 u4 G};
3 M6 G* u# n& }+ W* u8 R" y9 [+ V/ D: T- c' V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, e. a$ L1 l o4 L8 l; p& b .leds = da850_evm_tl_leds,
0 `0 p% ?/ B# G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* E9 V+ M% f/ M7 S5 |. E: I' G};
6 R1 C) c: E9 o" z
+ N2 {4 _' v+ L2 V6 b! _4 o4 L! zstatic void led_dev_release(struct device *dev)
" }+ _& m2 V, M{
& J* y4 t+ ^6 ^8 O" J, b};- i0 F& C" o6 N
- D9 _' i% v4 t& bstatic struct platform_device da850_evm_tl_leds_device = {( @+ [# f: X1 T" F
.name = "leds-gpio", R) }) W3 ^+ z, X" C9 B
.id = 1,
2 f! m& L' @0 g' H* N .dev = {
- ]3 K. i( ^9 @, L; ~ ^ .platform_data = &da850_evm_tl_leds_pdata,
; M$ |' g+ V1 x: l) U, `9 W+ `. C .release = led_dev_release, p" w4 [) @7 \0 |( q/ F
}" @" ?, x& }0 x4 s
};0 h2 ^7 v# i3 u( m( z: ` f& @
$ \" i: `, f* }* s& C/ J
static int __init led_platform_init(void)
: q; K! O* n& Y) D. ?1 Q( ], ~7 ]( [{# L4 f7 C6 { p) h' T O2 [
int ret;$ }2 t/ V" A+ M) _8 U
#if 0
# d- a/ c: Q) U/ m$ h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 A+ b# S# {( k7 Y$ r- | if (ret)
3 Z n) c" f" J" _+ T; N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 L% L2 N1 H* x q
"%d\n", ret);
7 c3 d) z* E+ d( K' R" X# \#endif" D @0 K/ d, \# ], V
ret = platform_device_register(&da850_evm_tl_leds_device);
3 S9 D5 `% c: E7 {: ~9 g if (ret)
% ^: W% j) P* w; ~" m5 X pr_warning("Could not register som GPIO expander LEDS");
" b4 y t2 w8 {2 A) E4 N else
) U o- ~' g4 X! z1 n printk(KERN_INFO "LED register sucessful!\n");
|# P$ Y5 b; L- m, s+ A' s' }; v9 X
return ret;2 \4 c# o( X3 w+ n1 y6 y
}
0 H3 h/ K* d* }' K: w, P/ B3 C! v; I% ]' c; K: s
static void __exit led_platform_exit(void)( `2 D, J( E" Z x1 h0 L
{* Z* z: Q% Q2 ~/ b- f& F% Y1 g
platform_device_unregister(&da850_evm_tl_leds_device);
6 c+ W" t- h2 U) Z) b. i- G" y2 q' H9 N7 \# p
printk(KERN_INFO "LED unregister!\n");
; U0 ^( M/ B4 J8 x0 h- U# N}
# l0 n. l$ g% Y& `9 A9 l, G) }" x7 @2 ]$ B: J& e6 t/ z
module_init(led_platform_init);8 `7 O$ ~2 ?. M! u5 s8 L
module_exit(led_platform_exit);
/ Q2 V/ c1 y* y% b8 |0 X$ R6 S" R1 k; c" R" y( Z
MODULE_DESCRIPTION("Led platform driver");3 y& C6 Y2 [* x( C3 C# e
MODULE_AUTHOR("Tronlong");
* Q: ~4 B7 e* ]2 [MODULE_LICENSE("GPL");
$ h$ k* v8 s9 i& z
y; w5 N/ `. ]4 ?" O* p |
|