|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 a! ]1 L7 B+ f1 x! `' `
#include <linux/init.h>
$ C3 Q6 m; W/ R0 D. ^#include <linux/module.h>
: f3 ]. c; R) H. }) h; x#include <linux/kernel.h>, X, B2 s, g) ]# S5 D7 I, O; Q
#include <linux/types.h>1 f! d; L$ @0 z# F, h
#include <linux/gpio.h>
/ v0 |' I" z. {6 t+ J4 [+ e#include <linux/leds.h>+ E; i+ w6 ?9 W- ]- Z0 Z0 s
#include <linux/platform_device.h>4 Z4 S, }4 y. Y5 ~2 W1 U& r$ U
1 [ F1 I: N( y
#include <asm/mach-types.h>4 i5 ?0 D8 ?- F m- V
#include <asm/mach/arch.h>* {/ w/ E, B- i' l( M) [
#include <mach/da8xx.h>
' C) q2 {7 C- I, y#include <mach/mux.h>5 Q! t/ o+ e( f& z& j( B
2 [8 U8 h& j( @. u( e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& ]& o% g# e) h% q; j$ {; {- V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* S$ o) ~/ ?( _0 x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) u& }) p9 S7 ]7 ]" |% t8 l6 t Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). ]3 S, x9 t* R* E6 h
X. L! ? `1 v/ c) t
/* assign the tl som board LED-GPIOs*/
+ `, y" ], W1 e! _% d* |$ tstatic const short da850_evm_tl_user_led_pins[] = {% L' r$ Y6 d, l3 d L9 }
/* These pins are definition at <mach/mux.h> file */
# _& }. d# V& f% n _# ]7 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' b6 _& o. W+ F0 v, t/ T
-1
- j% F8 x+ b" }5 f2 T# N: G4 W};/ L O6 ^& |* J3 h
) y; `# A. y. }/ @3 [
static struct gpio_led da850_evm_tl_leds[] = {3 Z( V2 G3 Q$ f2 N8 B& Z# Y8 i
{
% b3 c4 @" z& }. V! M1 d0 } .active_low = 0,, D" R/ {- r5 X: o: i
.gpio = DA850_USER_LED0, B1 X- o1 N: l, b% U
.name = "user_led0",/ Y, d) _2 N: T9 v8 A" I' C( L
.default_trigger = "default-on",
( @+ L$ l8 P _# c" m },) K3 ?# v+ g5 R' l2 L
{
/ ?8 C/ t1 `: P$ D- l6 M .active_low = 0," {2 w: S5 y; P; ]: q$ P
.gpio = DA850_USER_LED1,) B4 `" u1 b" c$ P4 X
.name = "user_led1", H1 M+ J5 v3 H+ m6 ^
.default_trigger = "default-on",$ ^( p' d% H* S& N$ R0 ]) S q6 u
},
- Y" M- s4 G# b8 v+ Y3 O {4 W+ q3 i2 u3 \0 g3 s( w/ i
.active_low = 0,
8 Y1 R% l9 U5 u' Z* I- F1 f .gpio = DA850_USER_LED2,$ k! k1 E& C# v1 G: ~
.name = "user_led2",7 _, o9 [+ O. Y' W
.default_trigger = "default-on",7 n; M1 Q, d3 y: \5 i5 `
},6 K" \5 G6 r% U3 L& E) J' A
{. W [% [! M: T2 f; d6 [/ U" l3 h
.active_low = 0,
6 @8 x* \+ ?1 ]: b a' n' } .gpio = DA850_USER_LED3,
* M) W" f z& s. K! k. l1 K- J .name = "user_led3",. H- ?2 R( j2 B7 R+ [
.default_trigger = "default-on",
1 h9 c. F$ z- d6 F0 z* j },
! I9 w. P' i5 \( s};3 k" n) |% c4 L2 u
& D0 P$ z: W/ T0 R' }6 ]8 w% N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 ?' f6 G, G! ]
.leds = da850_evm_tl_leds,1 F* @" h/ f9 b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 p2 m) t" V1 `; X6 U! e; L% q
};. d" N& [2 d- f9 R2 a& M' c7 f
8 N1 i3 b' p# I& d! q% T mstatic void led_dev_release(struct device *dev), k' ?3 f, e+ e8 P2 }; v0 V4 S. Z
{
: Z: Y7 N6 z8 r% O: ]$ d};
3 J$ K' p* U8 Y4 Y- ~! t/ ^0 A4 J ?3 ]' P* f( Y
static struct platform_device da850_evm_tl_leds_device = { M: G* ]0 g8 R2 u* o7 w4 y! Z' w
.name = "leds-gpio",
0 w, M3 \" q+ {2 o* D9 g R3 }' } .id = 1,
) d [' L% I [. V7 r .dev = {
% t" i# f& [6 E% B: m: e .platform_data = &da850_evm_tl_leds_pdata,
8 G& u* B. I% l: Z" W, r5 \ .release = led_dev_release,
8 r% F5 H% K* \! u/ m. u }
" k' R5 h/ p. S4 q4 }};4 E/ s6 |" i, K/ K- A
5 U$ T/ J8 f8 zstatic int __init led_platform_init(void)( ]; ]# W" Q+ g% f
{
7 o( e+ T. }' p) O int ret;4 N2 C s2 m2 N. ?) Z2 K4 N
#if 05 u& k Z$ X& ]* _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* p3 y! I9 d0 F if (ret)
7 N9 F4 f9 \ j1 B0 T+ Q+ I5 |, [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 M( c+ `. V+ {& y
"%d\n", ret);+ Z6 W/ s4 w* d. X
#endif9 A. R0 |. n, z/ }
ret = platform_device_register(&da850_evm_tl_leds_device);
) e5 Z0 M5 Y5 G( k2 N7 U9 w" k if (ret)' z% U+ o: C1 M' P+ \% b- C
pr_warning("Could not register som GPIO expander LEDS");) T& ]* {) G" |* {2 r8 d& ~
else4 i, |* w3 }! N& k3 {
printk(KERN_INFO "LED register sucessful!\n");
6 e) B9 L! {. P& e
8 a9 C( _+ ]1 { return ret;9 A5 M9 }5 h* w& T' L' ~2 b
}8 C& y6 e- W5 J3 u3 U/ M3 {- L2 Z, E% d
& U/ Q' ]+ E" N) S0 P6 Wstatic void __exit led_platform_exit(void)
* I0 c( Q6 }' [0 V+ R: \+ L/ d* n{* Q: a, X# d. y1 ]% Z% ]5 q
platform_device_unregister(&da850_evm_tl_leds_device);
; g; A4 ~, a9 {; o+ y! o8 j2 u2 z% Y( A. M0 M4 p; e
printk(KERN_INFO "LED unregister!\n");
3 i) i0 f+ R) a4 U. Z& C}
& m# P' ~! d- W* U- ~7 p2 r9 {) }+ ]. a; M3 X
module_init(led_platform_init);# }6 v; v5 {! x1 Y% m
module_exit(led_platform_exit);
1 @5 {/ {; i2 q$ g. k( L
, j* s- g# a; F9 z# i1 }! Z/ dMODULE_DESCRIPTION("Led platform driver");
, c- Y, C" T5 uMODULE_AUTHOR("Tronlong");6 n" y1 g; {) W1 I! B6 z7 [
MODULE_LICENSE("GPL");
7 P$ ~) _" X" u' u# C
; {8 _) G9 p0 v- W7 o3 {9 W |
|