|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; x+ c- M3 J/ ?7 W#include <linux/init.h>8 m$ u5 \7 o: ?9 q
#include <linux/module.h>) } z' e6 q9 T9 V1 E
#include <linux/kernel.h>
+ f7 w( E, Y6 E6 y. g' o/ {#include <linux/types.h>1 \, ~+ p1 O$ T) R2 u& g
#include <linux/gpio.h>
$ V5 `9 V0 M8 }/ ] L* ]#include <linux/leds.h>, Y6 a D% _7 {6 Y$ }
#include <linux/platform_device.h>' O6 {7 O" ]6 C/ z' H: u8 e, u4 v& H
+ \' K( a. y/ }* ^
#include <asm/mach-types.h>
Z, J' e# j* c5 A2 d" ^: ^#include <asm/mach/arch.h>
, p% |2 f9 x# M3 X* H5 G/ r#include <mach/da8xx.h>
! I% t2 P& l r$ L- V#include <mach/mux.h>
$ a: b( U4 e8 f4 ~" c* S5 s0 I- }1 i
/ B% {# b f. ^/ i) [5 g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ K6 E. b0 Z! @$ a& w0 u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 s$ U1 |4 w( M8 [# Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ _6 n' k+ j3 {4 [# ]" [1 b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ A2 |3 _8 R9 q6 f' G+ }
& P# ^" M9 U0 C$ p# e' `
/* assign the tl som board LED-GPIOs*/2 t4 ^' I8 a4 s" z" w0 r1 c9 U
static const short da850_evm_tl_user_led_pins[] = {
3 |1 q% C- t) ^' U9 \, w) U /* These pins are definition at <mach/mux.h> file */
8 {( Y! f- K% ~- g& P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! x& Y3 a5 i5 c) z% v: P( J -1
4 K8 l1 P! w; N; x8 x( p};9 H! l: V5 ~" r% _- ]" x* Z1 ?
2 @7 m6 P E5 w9 _8 @! E
static struct gpio_led da850_evm_tl_leds[] = {: |7 y+ v; y2 t' Z7 |* R$ `
{' E1 z& m$ v+ K8 z- K
.active_low = 0,1 C' r) t% g% N! J2 o* R0 G
.gpio = DA850_USER_LED0,/ v1 [" T# L/ z
.name = "user_led0",, w3 n* R& t+ |& d( _1 F
.default_trigger = "default-on",* D" q5 Q' B) g; _: f
},
3 @ |1 d; \$ T; ]5 U4 C3 k% s4 K! A( k {% F- e. W7 T8 q# ~8 j* A2 w
.active_low = 0,: v6 ?- z# u/ x$ |9 t+ W- ?
.gpio = DA850_USER_LED1,9 A' o- ]: b! u* O% w
.name = "user_led1",1 e6 c/ m5 W. S
.default_trigger = "default-on",
- |# p( S% h; P6 F2 k) J. P },
6 Q7 r' `7 S' G0 X$ ^, y% U {: [6 {4 I; h/ }7 W2 A1 Y
.active_low = 0,
+ d, z& b `8 @8 G .gpio = DA850_USER_LED2,
0 L( `8 }7 c, j5 T .name = "user_led2",
+ L7 x" K8 ~% P e; X .default_trigger = "default-on",
- x" G3 d/ i, \: C1 k; _# Q- P },, d) a0 I7 c% f8 q1 @
{
/ L7 s3 V7 v- E+ a: M' H/ A7 u4 Y .active_low = 0,
0 v+ L# n) }! P- S! F$ J4 p# ~% E% r .gpio = DA850_USER_LED3,) P2 n. U$ O" }' E. O: L, u
.name = "user_led3", ]8 t& J% X, M3 w: B E" j
.default_trigger = "default-on",
' d7 l% H# a1 X( U0 E },
h6 m; a( k% e" P6 _};# c- m) P( w3 V% [. @7 h
6 f) x+ g; \, g3 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { M* ?/ Z: P. V3 f' C8 |
.leds = da850_evm_tl_leds,: S3 p- }& P# @& n; _& A8 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 B$ s8 w; p. |: P+ r9 k! M
};0 G# d+ z$ e `" w8 l4 e
. G# o: v/ u6 ^ Y+ i+ z9 ^8 [9 j) Sstatic void led_dev_release(struct device *dev)( G. k, j: q. S* ?% H1 n( c
{& L7 T3 R+ G0 F* O) V1 U# N
};
2 ^& C$ c! `- r* v/ T& j) Z0 `
$ O- T9 B$ A, g+ ]/ ?0 T9 ^# jstatic struct platform_device da850_evm_tl_leds_device = {
* M7 e" J" V) ?2 S' z! v/ e/ R d .name = "leds-gpio",
4 m: W/ a6 T1 Q9 g. ~ .id = 1,
3 W& V: D/ U* i$ l .dev = {- x* W% o- b" i2 s* v% k' M
.platform_data = &da850_evm_tl_leds_pdata,( X9 Q1 L/ Z- _$ Z( D
.release = led_dev_release,
' {! w! F: D5 I0 N e+ c }
% L x/ x: Y5 U- z- ^( X a};6 M7 \! I/ |" C9 m# Z8 D0 _6 P
) R- n* i! w0 Wstatic int __init led_platform_init(void)9 r% p8 [% v" t" y; o x
{
0 Q: l( S9 X' R q1 g int ret;* b2 @# B+ R$ A3 T% z
#if 0* H' E! J4 J( A. A3 [# d, {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 X" H* R: _' O, [# \: {0 U6 N
if (ret)2 z+ \' k4 D" B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 k; ^0 |: Z7 F% v7 h% r" {5 W
"%d\n", ret);7 \( B' `5 a) s/ V1 ^
#endif& u& c( v4 G" g4 D/ x
ret = platform_device_register(&da850_evm_tl_leds_device);
3 T3 i2 @9 u2 G: @$ n, S# O" [ if (ret)
# H. x6 A0 a3 o/ `- d0 @& Y pr_warning("Could not register som GPIO expander LEDS");! S7 X7 Z" y- `7 w1 E- B2 W1 @ S) K
else3 M; G2 J& R, Z8 t) W3 I2 n3 }7 w
printk(KERN_INFO "LED register sucessful!\n");
9 F9 A. E. p: m7 d H- s. @3 b M9 b, [$ P* _+ @
return ret;# [' s& X, v4 I
}
* d; F* P- r/ m8 G! C4 ?) d( I# L. C" Y' X
static void __exit led_platform_exit(void)
2 a, B) Y4 ?8 D{4 u3 @! ^# `9 h& m6 a5 U% q* N- e
platform_device_unregister(&da850_evm_tl_leds_device);+ _; s1 Y/ t; s' t. c
9 p$ l$ }8 ^9 M
printk(KERN_INFO "LED unregister!\n");
3 H5 ~8 y: \- ]}
& z7 \0 d4 Z( ]& K6 @; g/ J! T1 B3 Y* B: @% ?7 M; K
module_init(led_platform_init);1 u# G% d- C9 v
module_exit(led_platform_exit); J8 W6 E8 O2 n" v- {
& k" n. S: h9 @3 f5 X
MODULE_DESCRIPTION("Led platform driver");
# ^8 m# g! [1 W& V, ^* OMODULE_AUTHOR("Tronlong");
2 p7 \# k8 [+ Q, p* P. e9 }MODULE_LICENSE("GPL");
) c2 A( M3 @2 U9 C9 S6 l& f- z3 A" L8 Y) j+ L7 S" i |
|
|