|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ Y) O! B9 @0 E3 o$ U
#include <linux/init.h>
. y9 t) V+ _8 }* m0 p/ X% q) h#include <linux/module.h>
8 {* `% ~" _( v# u; [ R#include <linux/kernel.h>1 z5 s' U: ?) y. S* V
#include <linux/types.h>
" R; a3 `; \; v, T. `+ | I8 n#include <linux/gpio.h>1 R) k5 L- x5 g: l% b' ~
#include <linux/leds.h>0 `4 F! j8 L2 W; ]3 A- z) D
#include <linux/platform_device.h>; A: u$ v* G+ D, s' K' [" m2 }
3 Y5 d7 g0 b3 |- ^1 D: N9 x a#include <asm/mach-types.h>% d! b0 o$ C+ _0 B
#include <asm/mach/arch.h>
# N/ I! y' o! d#include <mach/da8xx.h>, V# J/ `5 |/ k2 W" Q% ~. u5 \4 c. p
#include <mach/mux.h>: |( q4 L* E* f1 m/ i2 R, d
# y" g0 Y# J* ~4 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# J6 D1 g' U8 m9 Z S/ d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 \8 W+ V8 I* F$ ~9 e# i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ b7 R5 _) D7 U# }9 \2 z m1 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! J( a g, H1 _3 [0 o1 k
/ v T! X3 V5 t9 s- c+ |$ t/* assign the tl som board LED-GPIOs*/$ n8 X( X1 ` j% j" I6 h
static const short da850_evm_tl_user_led_pins[] = {; @! F6 b8 j# v7 s& z1 {7 k
/* These pins are definition at <mach/mux.h> file */) [6 D( G/ \9 I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) ]. i* r0 L' l2 V' K- A
-1. q' O9 |2 G) l5 i$ r
};. }6 F0 A3 j3 P' }7 r8 m
% J2 k$ I7 n$ S1 ?
static struct gpio_led da850_evm_tl_leds[] = {
& Z* `0 H: s7 _. i {
5 G; _7 S% S* r+ O5 k- ^ .active_low = 0,
8 |; _3 J6 [* X5 _" V .gpio = DA850_USER_LED0,( q% r. y5 X; b( h+ G& I
.name = "user_led0",' r7 B5 B; n* A M: |6 U: E
.default_trigger = "default-on",( L+ c; f% x# d, u4 \) w
},) N$ v7 Z" |$ H& y
{
2 Y% d/ _/ x: b8 j8 S( o .active_low = 0,
2 E/ |. L3 ^# ? ^ .gpio = DA850_USER_LED1,# X" e. {0 D7 O5 X5 l9 W/ s
.name = "user_led1",; \( o6 ?' }5 `( x" n
.default_trigger = "default-on",1 @ S) H2 Y/ x* C5 _6 h1 M
},
! r7 \; L* Y$ n6 N D {
! g3 Y. X& U7 _( D .active_low = 0,) u" ?. z4 O$ [4 s5 k+ h( ?6 Z% n( w
.gpio = DA850_USER_LED2,
/ [* j( D: J; x4 ] .name = "user_led2",! H7 k2 ]0 T! p& S& S! ~; ?. \' k; U$ T
.default_trigger = "default-on",
: ]- j0 q3 B9 ^# D },: ^9 B+ u; {; k* I) f
{
- j7 V* w) _8 q" ]7 m' a .active_low = 0,
2 S, F; m$ a2 I2 C! I3 w .gpio = DA850_USER_LED3,* _/ v/ U& F1 \" {! W5 G; q
.name = "user_led3",
4 C4 t! v! Z' w* x( l1 T .default_trigger = "default-on",
S& k) u; W" G$ D2 |% b. d },
* b! x5 _9 a) f8 u! }0 P};
3 l3 k8 G- J6 F& w, R/ Q3 b# q/ V9 m- [7 o4 z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 L0 p j9 [' [3 ~5 ^ .leds = da850_evm_tl_leds,, B; L. I7 b9 j7 U$ l+ \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. \( R4 K9 Y: A9 L4 B& {+ M};
3 R3 [$ p& n5 y
; q3 ~& L0 s4 `6 Cstatic void led_dev_release(struct device *dev), s U5 g& Y4 R
{
( T( {2 ^2 |$ z9 k" w/ v2 O! o% Z/ R}; G+ t' W- T. \* G
& q2 G0 {' ]) `1 g7 V
static struct platform_device da850_evm_tl_leds_device = {% c3 w v/ k2 z6 [( x/ M
.name = "leds-gpio",% l0 t% |/ Y. Z# ^
.id = 1,
+ e+ G$ z& y9 n .dev = {
$ C& a& j$ }( j9 C3 M L .platform_data = &da850_evm_tl_leds_pdata,
" c1 Y: E* q' b2 G Q, t* x( o/ g! q .release = led_dev_release,
8 Q* p+ ?( S4 w S1 e/ ^. g% V2 M }& ~+ b5 n( i8 F: k9 A8 Z! E
};
4 j( r2 e% {+ a2 J: h4 [# k! m% a U) U/ X5 P9 r3 v5 {
static int __init led_platform_init(void)8 Q/ C7 ^7 L0 @ O. M
{" X: d/ h: o; |; {
int ret;0 N8 J% K4 R2 [2 _; N9 \: F
#if 0
( M) \( j8 v: C* [0 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% W5 |7 v( K. N# A* b0 H6 Y9 v) H
if (ret)
) ~5 D; p( c! {0 |9 J1 P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 ?" U r$ C! y% i6 e2 J' ] "%d\n", ret);# c; j2 h1 h2 |. r
#endif
$ F! @3 F* N2 O( V& d+ s( R ret = platform_device_register(&da850_evm_tl_leds_device);% @% ?8 R1 O" a5 [
if (ret) z0 X# J5 s ~ E
pr_warning("Could not register som GPIO expander LEDS");
8 g# M k4 F4 e. q& p0 g else- h$ D7 I U# Z
printk(KERN_INFO "LED register sucessful!\n");
* Y. H2 E6 I; G" m7 N' h% B1 U( A% m/ L* J% Y8 r! G9 X
return ret;1 K9 ?+ `, Y) r$ k3 o
}
3 Q o# H" o* a3 G. S& [9 f f; R( _; W/ m e# J+ B
static void __exit led_platform_exit(void)6 x! c) J0 l7 _3 D( G! f3 v8 n
{
m$ @0 x3 E9 O8 k: F, [ platform_device_unregister(&da850_evm_tl_leds_device);
+ }6 [7 l# [; c" |' [; i. I+ ~4 d J9 N- S; Q/ L4 f
printk(KERN_INFO "LED unregister!\n");; n; A5 v* z6 _+ x
}. q, Z- L# Z5 z, \
/ a* `- O1 a& B: j8 H
module_init(led_platform_init);
+ F& R1 i- x* T% Y2 u* Gmodule_exit(led_platform_exit);& Y, Z. b. |& {# T5 t9 \
& b; r; o; A. h( p+ a; IMODULE_DESCRIPTION("Led platform driver");
$ {8 I# f) D6 I }MODULE_AUTHOR("Tronlong");
: C6 a0 `- b( _% G; W# S" Y( Q1 _MODULE_LICENSE("GPL");
. \3 t8 n; m4 ^% W. z2 `' p1 f) b5 A T+ Z" \
|
|