|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. M# ?9 p+ b. R$ @#include <linux/init.h>. [6 B; n! l( Q/ F, s* J- J
#include <linux/module.h>
0 \) l o/ g) F) S#include <linux/kernel.h>
& L. O g# c2 `#include <linux/types.h>) @. v* ]' \. i b# m
#include <linux/gpio.h>
' ~" C: d- \6 v7 {3 l7 K#include <linux/leds.h>, f) s2 d9 Q' Z" r. Y
#include <linux/platform_device.h>
+ v( r" S/ _& c/ ^ X% p
8 I* [! m0 s* V) y B#include <asm/mach-types.h>
3 j: m N, R3 _#include <asm/mach/arch.h>. ~6 D& T' _! I! s6 P
#include <mach/da8xx.h>
8 g/ t2 s& w, U7 c4 U% O: E) `#include <mach/mux.h>
6 b5 q* R, ?; q- X7 q& {5 l$ a. p: W" o# k& O. i( w) P# B' D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 f4 `1 k/ Y8 c5 D2 z& m* B7 J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! ?' l+ t" |. D7 }' ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ J9 i" F4 T8 P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" Y1 {8 i2 {1 ]5 [/ T9 K y
X& l$ C, C3 R+ i% A1 k L+ u8 j/* assign the tl som board LED-GPIOs*/' [; u8 S0 _* A# h# y( A R& k u; d
static const short da850_evm_tl_user_led_pins[] = {( l& {* l3 l2 y! u2 b( ~; v
/* These pins are definition at <mach/mux.h> file */
7 \- D3 S* v& P$ O9 X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ B/ D/ C/ Z& x, Q' U0 X -1' y' A; F g2 h+ z, V) l
};
% g- ~8 |- k! z+ w7 t- f4 W$ b- d3 [) C
static struct gpio_led da850_evm_tl_leds[] = {& a: N$ ]( }2 i' C
{, W; g& O/ x! o8 `0 T8 r: M3 B
.active_low = 0,* s- c7 G2 s/ p! y
.gpio = DA850_USER_LED0,
' Q8 T; K2 G; G: O .name = "user_led0",& { _. F: l: [. ^5 ~
.default_trigger = "default-on",/ y' F- Z: w9 o/ x2 k: z/ g
},9 l. P8 d$ n& T- s+ z- n, G
{) S; v; |0 W8 z1 v' C3 f
.active_low = 0,3 c( ? r' N( u8 l3 y' g0 d
.gpio = DA850_USER_LED1,
% f+ Z6 R3 l( \" w8 k8 A* R1 H .name = "user_led1",% W9 E/ ^+ Q) c9 T
.default_trigger = "default-on",
* i9 y9 ?3 K; |+ n6 ?. o },! H! ?# I2 V; K3 Z
{6 m$ g: c, v0 c" O8 g
.active_low = 0,
0 {5 f4 Q* h$ z i8 O( u .gpio = DA850_USER_LED2,* e1 V: Y, @) J9 o' B# c0 ^
.name = "user_led2",
' j4 ]/ w+ g/ W+ } .default_trigger = "default-on", M2 X! k2 e: t6 O1 B+ f$ [3 ?
},
% }6 B' f+ U9 ?- r6 W7 k {
+ g; @3 U! R/ n I( j9 V .active_low = 0,4 h; w3 U `. K7 T- b
.gpio = DA850_USER_LED3,
, W1 |* j) g0 R# @- m5 ^4 S .name = "user_led3",8 n% q. `1 p( g
.default_trigger = "default-on",; F1 u7 f4 ~8 M1 g/ f3 z. t
},3 K1 c% S" ~" e D
};9 E; ?+ X; R& g* `) u
+ a. x0 |: f( O. q. I8 K4 t7 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 d* R9 j$ R" a& v
.leds = da850_evm_tl_leds,2 f% @$ o3 G1 l# Y' R7 {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' H* O# l) v6 }: `};
7 u9 p+ L7 h% L6 T/ R9 z, R$ o6 D; C( D
static void led_dev_release(struct device *dev)
5 C: V. s1 H; s) Z7 [{
0 ^7 Z3 N/ Q2 v- D};: g* V7 v) d; R9 z! p' x: `' X6 X
! d# L4 M& q. g9 i- sstatic struct platform_device da850_evm_tl_leds_device = {$ c! W$ M. y, L9 f# X1 C
.name = "leds-gpio",. L6 j o" r: Z+ c
.id = 1,
6 o1 s" v' W" I$ y& Y .dev = {/ v' k2 y7 p: a4 \9 y
.platform_data = &da850_evm_tl_leds_pdata,
; Y# F% f5 T6 s9 l .release = led_dev_release,
+ W9 \, C+ y: W5 ~9 R }# f9 S/ J, g$ P) k T7 `4 P
};
( V. \, p: }6 ]( D# K
6 h( K$ u$ [4 d M$ f$ Dstatic int __init led_platform_init(void)
& y' L$ u" d1 Z. n/ S{' s2 y- U/ S! {6 y$ z
int ret;
; G% T+ Y/ I* K ` i) D#if 0
* o6 P6 q8 y0 T& P3 v! L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ T! W1 z- ^4 p+ y1 {9 [- ~
if (ret)
' K) ~3 ]. S* V. s, o! Y, A/ t1 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ Q- f! x4 x2 V8 T6 s! S
"%d\n", ret);" M! p" A' \0 N- L* m9 w% f2 U
#endif
1 l9 l8 F; v6 ]8 r* D0 V9 k ret = platform_device_register(&da850_evm_tl_leds_device);
8 z4 Z6 W$ Y$ S) }! w: X if (ret)! h' v. @- _0 y: t4 B
pr_warning("Could not register som GPIO expander LEDS");
7 y" ?5 d( Y& d) a& H else2 Q# s" G; j4 M1 Y
printk(KERN_INFO "LED register sucessful!\n");
+ z- q- B* z3 j0 ^- [1 y- A
3 S+ u$ s9 g9 s2 @, ? return ret;9 E2 l9 ~/ d" d
}2 K" X7 |; u+ s4 M( X( k( n
: M8 c% W8 Z3 f4 }" T* `8 \' f1 qstatic void __exit led_platform_exit(void)9 h; E6 r8 k( D- D
{
1 s- P2 S/ J9 y- F7 p platform_device_unregister(&da850_evm_tl_leds_device);
7 _( g: {8 i0 R! T$ R2 w$ `/ ~ W0 {' w! _$ n( m, ]1 k* H
printk(KERN_INFO "LED unregister!\n");7 p! H, x" Q! h
}6 p! u9 N7 `$ d& H* N8 [
4 v5 F; b1 ^+ J( U
module_init(led_platform_init);
$ A: j8 c G$ v" _4 ?5 Cmodule_exit(led_platform_exit); ^3 o2 Z" {" h5 J
9 O1 z U. s5 q7 WMODULE_DESCRIPTION("Led platform driver");
# `/ c" ]8 ?; OMODULE_AUTHOR("Tronlong");; A8 m! H5 f: l4 v* d# `
MODULE_LICENSE("GPL");
; I9 l, J) v; o9 _( M! a% a6 A3 a1 }' D! E8 W
|
|