|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 v& P2 p* }! e% I' x1 j#include <linux/init.h>& G- M* F6 G* a7 [+ u) U
#include <linux/module.h>
! v% v4 {6 h: I1 o4 [; Q/ R#include <linux/kernel.h>
8 X% T9 T2 e- p% q# I) |#include <linux/types.h>4 v, d' l* [, V' V
#include <linux/gpio.h>5 [/ P& X# u8 i; ?9 ^- M8 c1 W
#include <linux/leds.h>
- r1 g/ |4 J" c, Q#include <linux/platform_device.h>% z. |7 e5 V; F7 w$ v1 R' s: L
. M% f9 [2 A. A+ r
#include <asm/mach-types.h>
" f: R* M6 f5 ?/ o#include <asm/mach/arch.h>
6 X" w; K3 \( L! F7 B6 `#include <mach/da8xx.h>- T+ K' a( t$ _6 b2 N
#include <mach/mux.h>
: N8 D' `$ d; [! j( `
+ l7 ?/ E" S4 h7 C#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 x, \- O: h' [8 }( N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# {6 m3 k: C: X& N* u# `8 Y5 o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* y1 R& \; m- }; f$ S5 g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ `. \7 K8 R, {0 H _
8 ^% E) c# C; k* m9 E- l4 P+ K/* assign the tl som board LED-GPIOs*/
* i6 ~% F/ R% Y9 ?' B1 tstatic const short da850_evm_tl_user_led_pins[] = {& z4 O( M- {& i3 t" T6 i/ ~& Q
/* These pins are definition at <mach/mux.h> file */0 |. l; ]; u! F- D# `/ L# m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 A( e/ m2 N- Z/ F: T: d8 P7 }2 s -1
5 s' F% j3 v6 O) d3 r9 t; t/ A};
( w0 ~! X3 A4 e: `. g
6 c' v2 u' y3 @& h* |+ Astatic struct gpio_led da850_evm_tl_leds[] = {. _3 w J1 E; h' Q- M1 |! T; ?% S
{% Y0 t2 W- T* Q
.active_low = 0,
. ^: p7 ?% ^* | .gpio = DA850_USER_LED0,
) D' H$ c' F& [: [ .name = "user_led0",
( n. b _7 k. z, K0 P .default_trigger = "default-on",* E- J2 u1 }2 y1 n
},
: a) ^* e' r: {$ E! f5 f. Q {
0 F, j0 d8 e0 P& q9 k- C Y+ y% b. \ .active_low = 0,) ?5 N4 y( F* O% C; S3 p
.gpio = DA850_USER_LED1, x3 ^" p8 D1 L5 H! e5 d6 R
.name = "user_led1",
+ m" Z. A/ e$ x$ b/ J .default_trigger = "default-on",
2 r( q: {+ c; [' Z },$ [, S3 I- o" P) S; P* j9 U `
{
, l5 c' G7 i# j .active_low = 0,
3 {1 n1 H7 p' w$ }6 ?( r .gpio = DA850_USER_LED2,
1 j! _; g2 a v `) w .name = "user_led2",* D5 s# Z% e7 w) M( {7 I
.default_trigger = "default-on",# t5 a' @$ q8 }. z2 P+ a
},
* g$ e2 C& Z O+ p! F4 |) H+ b {. p8 }% e+ o- T: `. j) s
.active_low = 0,% R+ T. n; Z* {2 I& g* w
.gpio = DA850_USER_LED3,
7 [/ G# ]8 }7 g% U) O .name = "user_led3",- g2 v) p: Q s/ ^3 B
.default_trigger = "default-on",5 A! p& j, N* V: _0 a) b; v1 ?
},
1 c, p. v9 b3 Z/ X8 l% {# A};
% x2 Z9 t7 |5 R) o
8 e1 B# o. s C! wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 T) A- T' H4 S" }' R .leds = da850_evm_tl_leds,
1 b4 p# ?% H! Q: t2 j" y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% U7 G5 L2 V8 Z0 u};
- U4 B% q1 s, H, U; v0 G& t) W$ {* O M7 I7 P( {: p) @
static void led_dev_release(struct device *dev)# X9 @$ Y* C( v8 d; Z
{0 U$ F6 ^) J! c2 i
};! A8 B8 c9 W& Y f0 o9 h& N: X
' j8 @% a& [ D/ b" B7 A; |3 Estatic struct platform_device da850_evm_tl_leds_device = {" Y+ N- p; F& R3 S5 O3 B
.name = "leds-gpio",
- Y* N& ^* {/ d6 ~8 Z# R! \& ~# V1 ^ .id = 1," u$ M- g, E& c# ^4 p
.dev = {
# Y' E/ E. K+ J. w9 |, [- C7 J .platform_data = &da850_evm_tl_leds_pdata,1 I" S& t! q2 `- E
.release = led_dev_release,- s2 p/ a, d% h4 r4 i, N: ~, D4 O% o
}
% d' j, R2 K! B" a8 U};! k' h5 _. g3 N; n# {. T, K
# v/ r% u& P3 |8 K9 ~static int __init led_platform_init(void)+ X: y: V8 ^& {' E/ J
{
- P# {* p, t, e3 T$ m( k l int ret;- x9 l* l) p9 K0 Z; d
#if 04 B! Q( `6 B1 Z5 A% l+ o% J2 @
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, j) ?% J6 [. p! |8 ^& `7 o
if (ret), A; Q9 _ v' D5 C* |* @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". C7 Q) V! u1 K* O+ }" r' t2 F
"%d\n", ret);
+ D4 f: {: S m( y! Z#endif
/ d" g% m% w2 U7 Z+ I ret = platform_device_register(&da850_evm_tl_leds_device);
7 V3 @( O, Z" ~5 r# W if (ret)# g. |& d6 |) t& s& V( V V
pr_warning("Could not register som GPIO expander LEDS");$ G. L, t% Y% l8 E. g8 n
else# ~- h* _% v8 _+ A% r+ B1 |6 Q
printk(KERN_INFO "LED register sucessful!\n");5 P3 D0 `0 X; s$ _: A
, k) O5 p/ n: [ return ret;( t S/ `5 t4 D( e+ n1 N
} O7 U. k$ u' _, p# l( H3 l$ E% ^
Z' t/ C9 n: s$ bstatic void __exit led_platform_exit(void)8 i0 h/ y" ^1 Y
{
; G% J7 O& C* p+ r' J! g+ k platform_device_unregister(&da850_evm_tl_leds_device);
" G0 P8 i+ c& @
: S- V# Z9 M# G7 ^1 J" p2 T( @ printk(KERN_INFO "LED unregister!\n");" A1 R# O. O7 n" R
}
& k. U* X" `/ [! z- _+ d" s8 y+ Y6 }, W! C* v2 E
module_init(led_platform_init);( I! ^" Q) S3 W3 v& `( K- S
module_exit(led_platform_exit);
/ Y m, v5 q1 c; Y) d" {' M/ A9 z7 K
MODULE_DESCRIPTION("Led platform driver");
& C9 K# T8 L' d0 f/ A# V" g a5 ^MODULE_AUTHOR("Tronlong");
. M: ?/ M0 X( `; U' CMODULE_LICENSE("GPL");
* f: O& b# ]) i: u1 ]5 ]" Y- M! Z' n2 m- q# _% a# g+ C8 x
|
|