|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# x b, {4 e: h5 p9 A" E
#include <linux/init.h>
, z$ J+ {: ]- b+ X" l#include <linux/module.h>
8 O6 V L6 S2 H3 X( t# b#include <linux/kernel.h>
( b# P% H/ v7 d6 J* s#include <linux/types.h>" _. d9 T6 X4 U! ~) H
#include <linux/gpio.h>
2 o% t+ s+ b* o1 p#include <linux/leds.h>
: f+ x- s) k' `. A#include <linux/platform_device.h>0 N/ s/ p& V* P8 w/ P' O% c
! M4 ]' g# p5 C
#include <asm/mach-types.h>7 K) a2 s1 ?" k$ g0 E/ J
#include <asm/mach/arch.h>- e `, T) r& e5 a
#include <mach/da8xx.h>; t8 }9 k0 C' U* D6 }
#include <mach/mux.h>, ?) n' W5 F- F# K' a8 l; c: S
# j3 c$ ^7 @& N1 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ B: W7 v( d9 n' w) W) L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 c( w8 F @6 ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 e/ b+ g* p$ \% U# o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) P/ n- m7 R1 S
F8 ~$ V1 {% H" @0 K/* assign the tl som board LED-GPIOs*/
; Z7 o {, @* W# q6 t' v. Xstatic const short da850_evm_tl_user_led_pins[] = {$ j0 s+ ^; n6 z- X
/* These pins are definition at <mach/mux.h> file */
3 b% [4 F3 h. O* h, @7 D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ I* O8 v- i" z9 q- R
-14 O* u+ x u' B1 _. j# p
}; o8 Q, m- }+ E( G$ H8 p9 Y/ M2 n
' d" N! O+ j, _! j/ s& z
static struct gpio_led da850_evm_tl_leds[] = {
/ T: T i3 B- U' d& Q* g# u4 V% B. ? {3 V ?- q B+ B* N. T) ~
.active_low = 0,( O! C0 u% V- s6 U- ^: i. h
.gpio = DA850_USER_LED0,
+ Z+ e( j% j& _' p) q3 U+ i .name = "user_led0",
. ^* I- U! T: Q8 f) p* w .default_trigger = "default-on",
7 ?* ^( l' {) a# M" h },- F6 n. c7 o, @* J3 B1 L
{
5 S1 `7 J7 }/ W- _. M- P .active_low = 0,
& O9 A9 J; K8 P8 b6 a( e4 ^0 i+ u .gpio = DA850_USER_LED1,2 V5 O) N" y9 J% d
.name = "user_led1",7 O* O$ N+ A1 @
.default_trigger = "default-on",
# N+ c3 Q0 w. }$ {- } },
. w: c- M" {* p5 Z c- n {
9 D9 ]5 r+ x, H0 t. D. f6 L( S .active_low = 0,
, V' n* H, i" y9 O% Y0 H7 s- V .gpio = DA850_USER_LED2,7 o% [: p( c2 k) g
.name = "user_led2",
+ z4 f& P, ^/ S( Y- S2 c .default_trigger = "default-on",4 ^) f# E) N" h
},
+ J- R0 J L4 L, Y$ y {( v! H- f6 _+ R9 O/ G) ^8 R3 L+ a+ K
.active_low = 0,0 K' W4 Q4 Z4 X2 I2 @* b
.gpio = DA850_USER_LED3,$ _$ a2 z, G$ n( y+ b6 k
.name = "user_led3",
+ J' N& ?* k* O" s+ e1 _7 ~3 a .default_trigger = "default-on",. T" r6 f# t6 ]% h( t+ h4 W
},
/ F: u+ q( Y/ A( l};
7 [* ]1 x. F Z9 z" ]
2 F$ z" a1 c1 t& Z" q! G$ Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! ?: Z& }" u Q) @6 } .leds = da850_evm_tl_leds,. }, ^8 L. d$ \- W- {9 Z3 d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 d+ c4 c& M$ y |' i8 k7 a M};) |/ ?4 F! v9 j8 C* v$ b7 V5 ~
: A4 i% ~+ W( h1 h3 z1 Vstatic void led_dev_release(struct device *dev)
% l7 P2 _' {; J+ Y{$ m5 p8 l! z* l3 a) P2 a4 K
};$ r2 W. L: e1 C$ Y
. ?! |3 l! i1 a7 @$ T+ O* L6 [static struct platform_device da850_evm_tl_leds_device = {
7 W4 a. S* g$ f$ b% {# Y .name = "leds-gpio",* e7 [& }+ ]( `5 V% f- q- R
.id = 1,
; _0 O$ T0 f9 X* I b( R" J1 ~ .dev = {0 _4 [# Y" n _) U
.platform_data = &da850_evm_tl_leds_pdata,7 |0 {3 t( s/ h. l' a
.release = led_dev_release,
) M$ e7 p. c' p1 L: r }+ z: Z) p1 T& R$ h( t- O8 }
};
: q8 K+ q" u/ V' y
! m% m+ S# A1 c6 ^: astatic int __init led_platform_init(void)) X, }0 H) n j7 n2 B5 c
{
7 R; M$ U1 ~/ h int ret;, r6 m0 f% r W8 d& V% v& |- L5 z2 \
#if 0+ M ?0 G% ]2 ^1 Q" h3 I" ]- p% C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 K' r8 e! t/ k; J2 o
if (ret)
2 O @& W* }- z) r+ B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( y/ K- x5 |1 s! u4 C( ]. t
"%d\n", ret);4 r U8 N! z# z8 E
#endif" i1 O* X7 R. Z% |7 ^0 ^% \3 W
ret = platform_device_register(&da850_evm_tl_leds_device);
: k# O% D) j! _) R if (ret)6 J7 a: A4 ?" ]
pr_warning("Could not register som GPIO expander LEDS");
8 Z( C; U% X& x# u" I/ j+ [ else P0 n+ x$ ~1 M: y6 h: D; \
printk(KERN_INFO "LED register sucessful!\n");% \# {* V$ W. z# h, W
2 H+ S* f6 S5 S' G. E3 K return ret;
* h& f+ l3 x8 I1 Z. \8 {* F}# a8 [, [) L, K/ S5 K
* s7 u }- [1 E" p/ o
static void __exit led_platform_exit(void): w' @& ^* T! u4 a Z$ h4 I
{
5 C6 f6 [; L/ Z, o a3 Y platform_device_unregister(&da850_evm_tl_leds_device);
0 O: ?9 J% r; x; H7 S% X1 n. k7 J; {2 F* Z R2 ~
printk(KERN_INFO "LED unregister!\n");
. Q+ W1 r5 ]: m5 j, `+ l}7 m# ]; Z. v: u
8 \% k- x. |* \) P+ z# u" P. L
module_init(led_platform_init);2 j0 D) u6 X* p7 u) _5 t9 T1 x
module_exit(led_platform_exit);/ u3 Z" W1 d) e0 Y5 _
$ @) ~: g: y* J! ?$ G4 A
MODULE_DESCRIPTION("Led platform driver");6 w, U" I' g* x/ d. A
MODULE_AUTHOR("Tronlong");+ A$ F0 p7 X3 {% K
MODULE_LICENSE("GPL");
' |8 g* ?5 M. s( J6 V, ?9 I' U, u1 f* N8 z* Z
|
|