|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& f. w/ K* S- w
#include <linux/init.h>: s6 j+ z- g" w1 V
#include <linux/module.h>2 l* \/ X- ^+ \$ d( {! ~
#include <linux/kernel.h>) {. _: w$ i- M, j: q. o
#include <linux/types.h>
. T5 R# G. h! C" `0 V#include <linux/gpio.h>
5 S8 _. @) g( C/ q& q% D#include <linux/leds.h>
% \9 j$ O* j( Q9 `6 o/ ]+ K# d5 Q#include <linux/platform_device.h>: s8 g1 m5 H+ l7 m$ F- A
6 ^, B5 r7 |9 v& x#include <asm/mach-types.h>4 X. S" F, m2 D# Q
#include <asm/mach/arch.h>! h f. Y8 Q3 r4 H9 S
#include <mach/da8xx.h>4 ^- |% X( A( Y9 P! \% Y
#include <mach/mux.h>1 K- [2 o( L4 P0 B* [* A
! p" O- X2 {% A. Y, I) R" g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- c+ U& `- t7 ]! @' c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 G! Q: }3 b! a) V+ d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- l( @; Q; A$ B/ W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& l# Q9 M4 W T6 V$ \
2 D) t! A: K) T' X0 C; f/ [) q
/* assign the tl som board LED-GPIOs*/
4 V! A* f5 [6 V/ Gstatic const short da850_evm_tl_user_led_pins[] = {1 Q& ^. Q* Y# `4 w( i& u- m
/* These pins are definition at <mach/mux.h> file */
' h- I1 w5 c, i5 T. i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, S& X% N* E( k
-1& c$ `) s* T- b
};
0 {* T3 L- u) R0 {1 U
5 Q) d b7 X! \. R; Xstatic struct gpio_led da850_evm_tl_leds[] = {2 O; x5 Y) |! D8 f3 K
{
3 Q6 ]: \" }: ~7 S- v0 s .active_low = 0,
0 N7 \5 k& i! t .gpio = DA850_USER_LED0," R! @2 r: T1 H* M/ X8 ?# B! p7 v% F
.name = "user_led0",
: u" u/ O7 i# ?% i9 t .default_trigger = "default-on",. k5 N6 m* y9 V& ~. O5 v
},
3 Y# b/ G6 G) ^! h% \+ E8 L o {
- A% j/ u# X' j$ W' r) g3 g$ e- T .active_low = 0,. P: L& H" {# P
.gpio = DA850_USER_LED1,- G- h- b- g! l/ _ g3 A8 w
.name = "user_led1",# ?2 g/ V3 i0 I7 @- \
.default_trigger = "default-on",
% j1 F6 u2 S2 _( U2 H# ]# _ },' q2 m7 n* L- q4 Z$ f
{' X' q# i9 [, \/ d7 h, x$ a& x1 a+ w3 a
.active_low = 0,
- B2 S/ L( Q4 ?9 a. ~' j `7 \6 x .gpio = DA850_USER_LED2,, o3 [! a: T: I( i
.name = "user_led2",
1 h7 F' p/ q4 X9 P6 N .default_trigger = "default-on",! A8 ?# [0 w$ {: O
},
_$ H, A# L/ r/ R+ S2 G: Z! K {
4 x6 Y' O# K& u9 Z/ g .active_low = 0,
9 ~) I% M( w. c2 z .gpio = DA850_USER_LED3,, O J3 H' U5 P# C# g! s# |* c; G
.name = "user_led3",
3 {) B* |7 G, r; P/ e$ L' O3 f! ^ .default_trigger = "default-on", r, r5 a& o& o! V7 t
},4 O3 ~+ ~" J( n/ A# j2 T
};; N! B' }, m+ u* q+ l9 {8 S
- D3 i$ r" j, ?/ S/ U: z+ f9 p) V7 _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 `- d! S- G M' l .leds = da850_evm_tl_leds,
6 p$ q7 B' o- W( `6 [( y3 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! L" o5 [- V/ M, R( h m+ p};
/ l+ Z+ \! @6 b# {3 s6 T
" Y! W3 d0 k$ \static void led_dev_release(struct device *dev)
( {/ ~+ } H6 i4 j. u/ P+ E/ r{
9 o k( k I% h) L. E U};6 f* B5 p7 R) Y& l3 @/ Y
' f: H# _) O9 B. D
static struct platform_device da850_evm_tl_leds_device = {7 b% @0 C4 e0 F$ ?. E1 G3 a
.name = "leds-gpio",' z# z3 @! t. Q. y& O7 }1 M2 x
.id = 1,
) Y2 f5 p& }1 L0 f V. O .dev = {* g3 U* L& a* I) X- X M# A
.platform_data = &da850_evm_tl_leds_pdata,$ ~8 ]: U- n' U" V
.release = led_dev_release,
# U. |* F. C" y! b9 U9 D. g }
2 h& Q2 N3 p1 L- A/ H};
R5 P: J/ L, x Y
# ?) ~% p+ h! f4 y0 L; pstatic int __init led_platform_init(void)4 }3 J) a4 g; p
{' D, Z# r* g3 L) N2 I% w: s( F% ~
int ret;* Y3 A7 E- M( n3 w3 {7 H8 ]
#if 0$ s* U( ?. t2 J: y- U' ~% d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 O% |2 G; m6 z5 n5 L) F1 [ if (ret)" F0 a \ Q) D. c$ V3 R1 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" _1 E8 |& P5 h9 R' @0 t9 i; U l8 D
"%d\n", ret);1 M; x2 S& L6 {+ B3 { k# {
#endif {- k& v$ \/ [' I5 Y1 Z3 e
ret = platform_device_register(&da850_evm_tl_leds_device);
4 G) M* G% f% d: _# H if (ret)
1 D* s) U% l+ b4 L7 n pr_warning("Could not register som GPIO expander LEDS");
1 e# _/ b4 _5 v3 ~; n$ m$ C6 M else4 |0 F3 O" I- z& O* W
printk(KERN_INFO "LED register sucessful!\n");9 J R; a" q L/ K3 u3 q! y2 N
& g! B/ b, I' }3 O5 }2 Z7 g
return ret;2 k, @9 d) B1 c% x
}
, V6 e" J3 [8 B4 d. D9 [
% ^' q4 A; v! X, `- Dstatic void __exit led_platform_exit(void)1 T* t9 ?8 A* C! N
{1 D3 H, b N" {" W# b
platform_device_unregister(&da850_evm_tl_leds_device);% ~) K) q$ u8 `" o* p/ T: D R) [
4 [( S4 ^# O6 S# f f6 W
printk(KERN_INFO "LED unregister!\n");
4 P: k$ g3 n! Y8 e5 \' b}! C2 L4 V# ^& n- R; i8 f- d
6 w' E$ u2 {* g1 `; {
module_init(led_platform_init);/ k b" r5 W+ R% w% L6 j+ ?$ @
module_exit(led_platform_exit); ]9 p5 n4 W0 ^7 [0 p/ x B
; D5 B1 z$ C3 c$ P
MODULE_DESCRIPTION("Led platform driver");
& Y. k% J6 p. X. y! e5 JMODULE_AUTHOR("Tronlong");6 w. I( U* \( T7 m, J0 Q, v
MODULE_LICENSE("GPL");
, k( T, w, R8 s& ~6 h" y: ~6 v) t- M1 X6 u- c& Z
|
|