|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 ?4 v$ o( R# e+ G5 v#include <linux/init.h>
. w! v$ h1 C' o#include <linux/module.h>
4 u+ E4 U) {/ h: M, d+ g- M/ y#include <linux/kernel.h>" A- ~" M) z* f
#include <linux/types.h>
4 @" V& |1 }% A# F#include <linux/gpio.h>* z" Y ], E& a9 S
#include <linux/leds.h>' C: `) W& T' e' q
#include <linux/platform_device.h>
6 ?5 {8 K; A8 n$ g& r6 r6 _7 g7 S$ N
#include <asm/mach-types.h>
) G6 V! \- K+ C9 _: x#include <asm/mach/arch.h>6 J# o, N$ n: ^/ L) r
#include <mach/da8xx.h>
6 F& L9 ] G" `#include <mach/mux.h>5 H r4 Y/ d8 p$ R! R$ r% h
6 r4 c. N, c" @1 k0 Y( h7 }! ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: s+ i9 v: d% v% E) J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 s4 c% I' b' t/ w( y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), D0 H6 ^: U, f$ H$ I0 m/ B$ U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 n8 t3 j$ L |1 Q8 _$ X: a- H5 z1 x; S i
/* assign the tl som board LED-GPIOs*/3 S/ s! u9 c k1 a2 j8 ]
static const short da850_evm_tl_user_led_pins[] = {/ L/ w$ ^3 Q7 a
/* These pins are definition at <mach/mux.h> file */. o$ V9 A. Z$ s4 j: N' m& y( W+ G6 m" X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
C8 b& U5 j! F# @* \& a) t -13 J/ \4 t* i) i% S
};
. U1 ]+ W$ E6 i$ m& l3 ~( T: ]+ ?3 P+ _) J) ~3 y( |
static struct gpio_led da850_evm_tl_leds[] = {5 o3 x) ~( J- Q# E5 q" L
{$ w* }& `3 \3 l! M
.active_low = 0,1 c4 R+ Z; [. A4 C" N
.gpio = DA850_USER_LED0,
3 {( e3 }4 l8 h( t5 p1 @, X .name = "user_led0",
- T" W! n0 I1 v# y8 G- W$ G .default_trigger = "default-on",
/ x% {* K+ q. v' j$ t, w },( r; C+ [ g! Z4 }
{
- _, |" |# c2 D .active_low = 0,
" Y7 g" r7 U$ J/ P5 t! j7 y* u" p% p1 h .gpio = DA850_USER_LED1,& U1 u9 l! k( C" S
.name = "user_led1",
/ }4 S; T0 k* V- N& @) y/ N( c2 ^ .default_trigger = "default-on",
3 L! [" ^+ U' |4 O/ l },8 `. |4 t2 h- ]1 p
{$ Q6 T ]3 w: c
.active_low = 0, c) S! C% r. M+ Z p2 f1 J
.gpio = DA850_USER_LED2,
5 U0 S/ B5 B5 C7 ] .name = "user_led2",* @* g: `/ ^& @; ^1 Y' m
.default_trigger = "default-on",0 G9 Q2 P0 w) D7 m/ F1 D2 k
},! {& P2 J2 z. n( \* b
{
+ W) v% m4 S3 l3 t j7 j$ } .active_low = 0,: c+ w! {- n! c- H2 b9 i2 q1 l, j
.gpio = DA850_USER_LED3,
$ P/ k; I/ C x$ z: B .name = "user_led3",: \8 k3 @7 O6 w/ J
.default_trigger = "default-on",
9 n; }2 v8 P4 o },2 E0 P5 o$ J8 y. i
};
3 t' Q! l' P2 ^+ S$ S
; e% S/ A- t# j+ ?# O# ^1 Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) S- \/ @# \7 f3 F
.leds = da850_evm_tl_leds,: B2 g# T& V9 V8 Z0 M/ f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* m" j' C8 M+ K6 }
};
6 [$ g- A8 K* S8 Y0 i( G! ~1 t
: V' C3 `; e+ b& \& C4 `static void led_dev_release(struct device *dev)
9 J6 E& g( L1 A5 U( X7 S# M{$ W$ ]) d5 a1 ^1 v5 i& N
};
- s: ^. m8 E, a& C7 n6 _) s0 Z. @% S2 c* y
static struct platform_device da850_evm_tl_leds_device = {' x/ ~+ l" p* s' @) y( l9 M5 i
.name = "leds-gpio",
( H! v" K" N9 L6 o( F, i .id = 1,
' F, \0 o, e& w% a2 V/ f& y4 ~9 c6 P! G .dev = {
" |* g% Y$ C, x* d+ ~ .platform_data = &da850_evm_tl_leds_pdata,. C2 d, E& [- O- C- b7 H% L
.release = led_dev_release,% t# M1 A8 x9 Z. S j
}+ x. }% c& {/ E' i6 {. h0 m
};8 ~* \" j2 L- I6 S" {( W
4 O( U8 Y' j! `/ J9 `6 e$ H
static int __init led_platform_init(void)
S% Y+ [, L) x3 \, b+ E7 K: y{
# J" F5 ]+ _. b& Z( K int ret;
7 x( b+ J1 ^2 L1 w$ o. y d! o#if 0
* l4 q* M0 Y+ v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ }* g2 d# G1 D8 K. _
if (ret)& e, a: ^ V2 F( K8 u x6 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* R' ?9 b7 Z; u) f, n1 s
"%d\n", ret);
6 u8 o3 ]( R7 R+ L/ _% G9 G#endif
- m- O' [- b9 _! E$ ~" D4 t$ j( L5 N1 U ret = platform_device_register(&da850_evm_tl_leds_device);) d) r0 C, |* l/ R
if (ret)
4 E- \: |; S# E) j: D pr_warning("Could not register som GPIO expander LEDS");& [; b+ D/ U9 @8 O
else
! b2 w/ Z' O0 F6 K8 E8 u) {7 w printk(KERN_INFO "LED register sucessful!\n");. O9 \% f1 m/ F6 K( E) C
$ d; N$ t! l% b! p4 x( A return ret;
. e- W1 b- V( h g; h7 F}/ A* B/ z- B& I; S
8 C, ^" w# a- h1 Q+ }4 l
static void __exit led_platform_exit(void)
; d2 s* a8 O1 C7 T{
8 N3 w/ l4 b. W2 |! F platform_device_unregister(&da850_evm_tl_leds_device);
6 o( M# z& S( }" I/ |8 R5 @2 P% v% z& V V |6 u8 [, r0 `
printk(KERN_INFO "LED unregister!\n");
, I6 V: a: `* p V+ G}6 q0 }5 Y% n7 d/ g. K8 ^
$ j' V3 j# `% ]( U1 j3 t) @
module_init(led_platform_init);- p% q& \! m: F/ Q; L: e
module_exit(led_platform_exit);
& _& F/ s0 j% A/ p. ^9 ?) u8 N7 z# T4 J1 L
MODULE_DESCRIPTION("Led platform driver");
+ y7 k; g) R7 K8 p! P, dMODULE_AUTHOR("Tronlong");6 |7 u- \: V) b
MODULE_LICENSE("GPL");
8 G+ |' g$ E( ^" W p9 M
; b6 z' K3 w+ |. t) U- x |
|