|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 n' f* ^1 j' i% L
#include <linux/init.h>4 I% [: L8 r) ]: O' p8 L! }9 t1 L! l& _
#include <linux/module.h>0 \/ u9 ?3 Z6 z7 X2 D: G O% a; c
#include <linux/kernel.h>% W6 t/ N# Y+ h+ j; L1 \( ?4 E6 y
#include <linux/types.h>1 c% ~+ J G4 `% [, t) c
#include <linux/gpio.h>
7 _' l( @- s$ R0 g& D#include <linux/leds.h>+ e8 B" h9 j5 f
#include <linux/platform_device.h>: o6 d+ d( @. \7 v. M
5 k% j0 G9 l$ l! U+ H4 I% N
#include <asm/mach-types.h>
' s* n# _) R' B$ U+ u- j; H#include <asm/mach/arch.h>
, Z' F) Z1 i* F' S# p#include <mach/da8xx.h>
+ U2 B3 d8 x! v5 j4 u) ]+ Q#include <mach/mux.h>! p; }0 s3 O1 _6 O. a# p1 \
, I7 p, F, L4 G1 G2 R& ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# s5 \% M3 B% ^% M, ^' ^ ^# f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 W- T" P( T# Q- p" c( H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 R; F( c3 v. J$ G: p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); l) `+ C4 I" \# E1 i, h
+ d& `& C& n; T" o
/* assign the tl som board LED-GPIOs*/1 X$ R; q1 w3 a8 K* B
static const short da850_evm_tl_user_led_pins[] = {6 J- r8 y0 E" r" S
/* These pins are definition at <mach/mux.h> file */7 J8 q' p9 B6 @0 E. ^7 }0 C5 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 a. h3 u* U2 Z; P5 ]5 Y -1! n6 I! K* z: a( ?% u6 ^
};) E2 a4 y2 F- H* s$ f
$ o% F/ b6 k q) G
static struct gpio_led da850_evm_tl_leds[] = {4 n+ q. f( [( `1 y0 [
{ d7 i" i- {& S8 D
.active_low = 0,# M( x7 j$ s* V y5 R
.gpio = DA850_USER_LED0,4 P% C9 d( {) P7 s6 [; c
.name = "user_led0",) ~/ i s2 ^- d2 u5 h( [
.default_trigger = "default-on",. v/ c* u* y4 t j4 g. P. J" ]8 B
},
* X e Z3 _* N' V$ }4 ^1 \ {$ w* D6 N4 G* K8 j+ h$ w2 x
.active_low = 0,
n. X* q! a# Q* j2 d( ^2 r2 M .gpio = DA850_USER_LED1,0 o8 z4 Z& B8 Q/ T" A3 l/ t3 U
.name = "user_led1",7 [8 ?! G A5 ? h5 E6 \
.default_trigger = "default-on",% G9 m [ Y$ v8 ^' A
},$ G; \5 } ^# l; H b
{
( L8 G" D6 y1 m7 [# i9 P( c1 {) ^' V .active_low = 0,
4 i c7 S; d' {, Z5 v; u( n; l .gpio = DA850_USER_LED2,
! ?' }% H4 U3 n5 W .name = "user_led2",
* \; S- R e3 _ .default_trigger = "default-on",, Y. u2 l1 J b0 w
},% C0 w+ t* q7 @
{
: D1 c% x* `6 e7 d- A4 ] .active_low = 0,8 t6 \. y* F' \2 \ \% e
.gpio = DA850_USER_LED3,* v( o5 Q0 Z% s
.name = "user_led3",* }1 A$ L" b/ o0 m ]8 y
.default_trigger = "default-on",
% E* x) G+ d( G$ H7 t1 w. H1 w1 H },
- H1 ~* Y/ ~- g* u2 N$ A};
. q. u/ S2 j$ j0 Z# c# [
+ K( z* t9 J4 k( a4 \7 N) f9 }& t% sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ W: o3 O1 l* |; o/ f3 \7 G; ] .leds = da850_evm_tl_leds,( t& |& x3 q" x; b8 G+ s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ v- y2 i5 j1 ~5 y
};4 M; ]0 f% k3 d! c
3 ~* K: T. g8 I" {* j; r5 ~static void led_dev_release(struct device *dev)
- \2 d" Q" h. \0 A& D8 A X{- e, V" Z/ G( j" [1 z, A# y; k
};: c% {2 R, {/ k$ F
% f _3 E. W2 O4 h0 x/ e: P
static struct platform_device da850_evm_tl_leds_device = {4 G/ t4 a* ?% k) t
.name = "leds-gpio",, w1 A) R, g4 P. n
.id = 1,: U# Q+ @& b6 S4 ?7 n/ f
.dev = {
) E+ r3 g3 |: y, y$ u$ `5 X .platform_data = &da850_evm_tl_leds_pdata,
: z/ D R+ K. q3 |3 i* | .release = led_dev_release,
7 _, ]9 A, ~8 V0 v$ i) p8 o% ~ }
9 k( E2 ?1 ^; H9 U};
* F( e( e! g: V" q( X+ p! ^: r( c4 |
static int __init led_platform_init(void)
8 d+ s: B4 K4 b3 O{' q7 M: y- G( D" s! B" l
int ret;4 s2 o+ t7 V2 v: i5 E6 L
#if 0' ^4 I* x# n b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ n9 X6 F! k3 R; u1 H if (ret)
5 o8 n1 L9 V1 G/ i2 [; e2 D D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 b; ?; M, {' K! u7 k' o
"%d\n", ret); q$ L+ C: @7 x; |" \/ Q
#endif
- L: r4 l8 ^: V+ c' [& a5 H ret = platform_device_register(&da850_evm_tl_leds_device);
0 V8 @" H X1 A if (ret). ]& p; V Z9 ?2 j2 ^. J
pr_warning("Could not register som GPIO expander LEDS");
! W% g: I; I$ O# H" y else1 J, W* H1 a3 a5 ~ e
printk(KERN_INFO "LED register sucessful!\n");
7 v4 Q; J" R7 L- B# }$ r1 P. e
3 e3 M) D# {& J2 j return ret;
) W5 @, w- Q5 Y) l* _* g% E}
6 w. h: c6 W- o% q6 k' X
, u' o" O" H, I3 [8 Ostatic void __exit led_platform_exit(void)
$ t/ H! I& }" @, i- [" d{
, T/ g7 d. R/ c9 ^- K platform_device_unregister(&da850_evm_tl_leds_device);
' d1 J) o- U8 V* {1 u8 e3 q* j
( I, F, d( j6 s( c! e& K1 M printk(KERN_INFO "LED unregister!\n");
8 L. X( T- m B- u. n}/ f: ~" I g) _/ Y
5 F* P0 Q3 { `/ V0 ~& M0 smodule_init(led_platform_init);
3 ?3 X! \( j+ emodule_exit(led_platform_exit);
6 Y& t4 S+ d+ E+ g j
$ c& r/ \- ^! M' wMODULE_DESCRIPTION("Led platform driver");
' q5 j. m6 E1 r! Q) [MODULE_AUTHOR("Tronlong");5 A6 D3 w$ Z' F; m6 N! A+ S
MODULE_LICENSE("GPL");
% s- m9 k# A8 K o0 I5 {# k! Y4 @9 U3 p
|
|