|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: Z5 G% |; G {" f% |
#include <linux/init.h>: ^9 K' D/ K1 o y8 Y+ u
#include <linux/module.h>
, e! G& Z9 o7 v6 h#include <linux/kernel.h>& F) _* @- T! r0 u/ o6 R# P
#include <linux/types.h>5 P) `9 D& S' K) }
#include <linux/gpio.h>8 B8 U7 P- I0 ?8 u
#include <linux/leds.h>
% D; k2 J9 c6 Z9 W, [3 J#include <linux/platform_device.h>
: g# z5 F( c( R& |# M2 ]* W
/ H) ?: S0 N* Q$ `: u#include <asm/mach-types.h>- z: f9 l: @. }
#include <asm/mach/arch.h>- l2 ^; t) u( h! s$ z( W
#include <mach/da8xx.h>
! g4 R6 X1 k" z6 h' C8 t& ~#include <mach/mux.h> v( Y, Y: O# U0 b; h8 T/ d( p
, }3 V: I: {1 S: ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 z! a, c( X4 @! n; Q: d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( J! F4 }' c: S! r0 M8 X( P) {3 c7 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: p. _% ?. Q% g# |' Z0 Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ r% L; ^% d' e2 F! z3 S
+ \( ?; @. K& C: H/ y. p& u/ d
/* assign the tl som board LED-GPIOs*/
1 G* F1 a7 @* \2 Fstatic const short da850_evm_tl_user_led_pins[] = {
% U* h3 w' K% D) O% W /* These pins are definition at <mach/mux.h> file */1 h, u( g; t9 k$ s. Q# S' Q9 b: P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 V* Y( Q- \ F" U5 F
-1
7 j& M0 C9 U) D) S6 L6 x+ q" J9 S};
& _$ _8 v" X6 q* `: n: {; S* l Y5 r% h9 Z6 M
static struct gpio_led da850_evm_tl_leds[] = {& G8 y3 M8 n1 x' C* I$ O6 m2 ~
{: d/ {9 y; w* u; u
.active_low = 0,
3 D3 b" ]3 G8 V; p2 x .gpio = DA850_USER_LED0,
1 {) z& l6 |+ N9 V* S .name = "user_led0",
5 x" K! w4 c. C4 M7 [4 G1 u Z .default_trigger = "default-on",
& w0 ~7 q* b& S9 _! d; y+ O },
" ?- M/ U) [( M( } {- M; |! P9 M0 ~) M# [1 e; J
.active_low = 0,
' d! o, _" }# T" F ^; \6 @& o& m .gpio = DA850_USER_LED1,
# \7 R. W% k' D0 e1 f$ C .name = "user_led1",8 D, J- j% f( z7 {
.default_trigger = "default-on",
7 k( C& l5 q: S5 P' |4 u+ b },
5 @% h H, b/ ]7 V- d7 h" ~ {
* K+ X3 g2 M v .active_low = 0,6 ~/ r7 X2 X- G: A' Z# r" ]
.gpio = DA850_USER_LED2,8 B4 m! ~' r. Q; _( v
.name = "user_led2",6 f' u& t$ r6 v) d) n$ X+ F
.default_trigger = "default-on",& L8 d6 v/ ~8 z
},
8 ^$ I1 {6 ~9 r2 h: _# t {6 b- R. D- j0 b' U- D
.active_low = 0,; A8 c* m$ b( H
.gpio = DA850_USER_LED3,5 x# b% j- B! S' p7 y; u5 i1 U& c$ m
.name = "user_led3",
! P0 b/ H7 k' j6 s* S6 ` a: o .default_trigger = "default-on",
* M7 J u- u8 ` },; `& \9 E" y4 M4 ~' x
};' n8 p5 d- W: x$ v
' v- u' M3 j8 v% Q6 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 m# z7 m- D T/ @2 y6 ^# E
.leds = da850_evm_tl_leds,# |, I$ M% g# o( l) J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 ^" `( z, q' s};; d. O% P" }, h( K
+ a0 S1 Z# i2 S& D7 W
static void led_dev_release(struct device *dev)
- E) A/ \. ?$ a' o{$ [" B7 X/ v* b6 F( k6 `* X: i
};6 k5 N" e+ }0 t, n
7 s4 V) w8 v c6 i
static struct platform_device da850_evm_tl_leds_device = {5 c. r8 r: r4 t) a6 X w
.name = "leds-gpio",# g, l, Y0 c2 \0 q: [
.id = 1,. X& y1 P% j+ ^+ U& T6 w% W( a4 Z& p+ l
.dev = {
1 _, U* b% U9 z+ ~( E- T. H- J .platform_data = &da850_evm_tl_leds_pdata,% o% c6 X5 \, F% M9 ~) A
.release = led_dev_release,
6 E6 a6 w- B0 ?" q- f }
4 Y f$ F/ c+ l; s) j: v8 t};
! h- @- g9 l- K* a" z; n& p9 |. P; C) f# t/ ^! M0 L+ C6 M
static int __init led_platform_init(void), y" ]5 i2 D: O8 O
{
! d6 Z: s2 O4 n- k! u& x; X/ [ int ret;2 d) V: c: a0 u+ ~( Y9 n
#if 0
( a( L% f1 q4 Y' G- r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 A* {1 a# K3 V, f3 D2 Z: @ if (ret)
6 \, l# E* E& Z4 p7 k# w' E pr_warning("da850_evm_tl_leds_init : User LED mux failed :". Z5 g. v' A: }
"%d\n", ret);
9 K. E. v" P9 y2 Y& L#endif& R# d: g1 ~ G k! q* B! a6 e
ret = platform_device_register(&da850_evm_tl_leds_device);. Z' J2 L) {3 Y' t. k% U
if (ret) y, {/ I4 i$ S, g
pr_warning("Could not register som GPIO expander LEDS");
; a2 U8 E g2 Z. p else+ u4 R: ], c2 V
printk(KERN_INFO "LED register sucessful!\n");" q. x7 @2 F% }# M6 \, D( e
- q: T0 c# p) N; O" ]( Y$ ?* J
return ret;% _% f3 f9 d! ~! }) G. p
}# M/ D! B3 D" l. I9 \
; J2 O5 c% a6 xstatic void __exit led_platform_exit(void)
3 @! H- u8 ^9 D g/ ~) r5 a& Q{
4 N. ^. J, x) | _4 p+ R4 i4 p platform_device_unregister(&da850_evm_tl_leds_device);
) I9 D; z0 ~( v2 ^# ?" S6 f5 L$ w( l1 H* |' H% e, h1 e
printk(KERN_INFO "LED unregister!\n");+ @% x1 ]/ ]6 y, Z8 ~
}/ G9 _, u* Z8 u! e0 F
. V+ Q9 @: W6 f( T9 N
module_init(led_platform_init);% b1 t3 T/ a& d( G
module_exit(led_platform_exit);; n1 \: G$ ], `
2 s5 {4 [# P- _% J3 }MODULE_DESCRIPTION("Led platform driver");
& ]1 ^, }! i0 qMODULE_AUTHOR("Tronlong");4 H. N* d$ {: P4 S: w
MODULE_LICENSE("GPL");" B# _$ j: G; m& o( J) C# `
5 [! n* z1 y) C8 ? |
|