|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ n0 W# r# _' Z; o#include <linux/init.h>4 C) ~9 }3 M. w* G6 V6 g9 y
#include <linux/module.h>* E9 o& d$ s' e; U# h
#include <linux/kernel.h>- b4 T; r7 M( ]
#include <linux/types.h>* A8 ^: t/ a, E# b/ p& X) p
#include <linux/gpio.h>
% A% [: `( c7 [#include <linux/leds.h>
% s$ }; ^) C. u: X" E#include <linux/platform_device.h>. |5 ^& Y0 M! u3 k' T
5 y$ y) Y9 M) a+ Z! E
#include <asm/mach-types.h>6 g" a6 `( v$ A% N( F8 x) o* ^
#include <asm/mach/arch.h>
' z, S6 z. T' i- R6 b. d2 `7 V#include <mach/da8xx.h>
* k( }0 {2 B: }3 J#include <mach/mux.h>
3 N6 ]% X9 n2 s+ t% A% Y/ C n8 d6 ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 E+ B; c8 [9 z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 l$ `1 `, Q4 r0 g- M' y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ }) n2 u0 j+ v$ j9 u/ ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 [2 {, `, Q6 J' p/ J/ h( t+ L' [! i% U+ X! C. A4 a& e$ v6 I7 m
/* assign the tl som board LED-GPIOs*/; H+ ]! \2 q" O3 \, M
static const short da850_evm_tl_user_led_pins[] = {# S) b9 W% u: Z
/* These pins are definition at <mach/mux.h> file */& N' n3 @. p$ F; m, z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 m6 n6 q' N4 U% p$ N/ q
-1- \' z/ a s, H8 k" f6 q. ]
};
2 P& a' e; y( `( k6 k' P% ^- W! f* g }' U7 R
static struct gpio_led da850_evm_tl_leds[] = {
! M7 `& N* j' z! _8 w {3 d% P. O7 G: w9 ^6 ~; r8 g3 X
.active_low = 0,
. W; t" \4 X# i3 {# r+ H .gpio = DA850_USER_LED0,
& b7 {7 c9 L; c- y .name = "user_led0",
/ c" h+ h p3 x$ u$ @' n .default_trigger = "default-on",+ k* S% M* d( t9 v. I7 _' `
},
0 _8 F* N8 ]4 i( b {( b6 [; H# }. `
.active_low = 0,5 `+ t# e, g; v9 Z3 x
.gpio = DA850_USER_LED1,. a' f7 x, A( t: P$ ~
.name = "user_led1",
0 a% \* T5 Q6 k8 X2 P4 \2 B) |6 d .default_trigger = "default-on",
2 p4 R, X. }0 a1 C8 c! I. E },
' N% J; Q( m: s {
& `6 v) p5 z# |" R7 x# S' z .active_low = 0,
& T+ @/ }; ^1 q6 Q$ ~! y .gpio = DA850_USER_LED2,7 L4 Z2 p; p2 _0 s
.name = "user_led2",
1 B( D" k) v) i4 W6 ~9 a6 D .default_trigger = "default-on",/ I9 h! Z; C% [$ U8 ]; A
},( v8 H7 N% b# ~3 K# {$ J3 U. K
{
& g/ {* v! C, m/ h l6 c+ q .active_low = 0,
' h) d6 d) M6 w6 t& c .gpio = DA850_USER_LED3,
5 [( i: C2 u0 B l& [: p% i! a2 o2 Q .name = "user_led3",+ |( P/ q2 b4 t ?# D
.default_trigger = "default-on",& j' @6 U* I; ]( D# G) o* |( o
},7 q3 k& O$ a* Z
};+ t: A/ J$ Y4 w0 x3 j
# k1 w; d# e7 u. a# k, O& Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ R0 o' O5 E: s# M" p9 `1 S2 U .leds = da850_evm_tl_leds,. A: y7 j' u- A3 C5 j$ O5 A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ t: y) { j* W/ M+ v/ b& q};
/ Q* I4 t6 U( c- E0 X+ Y o h! Q4 u( W
static void led_dev_release(struct device *dev)* m5 p# g, T% h& R
{
9 \' q9 B1 p' t# }. Z! \};; ^3 D- @1 a7 _' i
3 D8 w( Q$ B7 n- Q# \7 nstatic struct platform_device da850_evm_tl_leds_device = {
$ Y$ B5 \' F; i- ^ .name = "leds-gpio",
, @$ y9 e+ T$ v$ {0 V9 H6 i .id = 1,
& S& j1 r; r5 T' I( ` .dev = {
, u0 K$ o7 ?: [" V) C2 L .platform_data = &da850_evm_tl_leds_pdata,6 m2 J4 u( A. g* W( j
.release = led_dev_release,- E v" d+ m3 ^" t# h! E6 y4 t( z
}
3 \) q: _+ y( U- p6 S};$ d8 d& X2 }8 s* F) I }% n
8 r% U$ V, L0 z$ k7 }' d
static int __init led_platform_init(void)' K% o C d7 O2 Z" w' F
{
& T+ S9 V w/ p- P y, s/ N int ret;$ m2 a/ \& |4 m0 j* E0 Y0 n- l
#if 0) c7 j1 w( K# ]: i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& k# ]7 k! v2 {) z, n/ i. D. v% G; h
if (ret)
( j4 }4 x6 J7 S6 K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 w( z/ p+ i. r) L+ g0 i. K- _ "%d\n", ret);$ J/ o* R5 C- M, W+ M; v2 V6 ~4 L
#endif
! b0 A6 `5 r$ I5 g U% i1 V6 R ret = platform_device_register(&da850_evm_tl_leds_device);3 c' c. L& w/ B5 r
if (ret)
5 X6 w) I- Z) w pr_warning("Could not register som GPIO expander LEDS");' s# x7 e; u/ k
else% F2 A% ?& P( ?
printk(KERN_INFO "LED register sucessful!\n");
: \5 j, w* K0 c. b6 C$ M q m& [/ U6 f6 x$ c. L
return ret; J4 V6 M; e, O5 P: g- L+ u
}" n6 q$ e' ?) m: T" N- A
' ]+ `# b2 c& G( t' s; T
static void __exit led_platform_exit(void)
9 }1 Q/ b0 b& A$ R4 t{4 f7 N- @2 k1 U, o8 ]. T9 Z
platform_device_unregister(&da850_evm_tl_leds_device);$ s3 M+ f, M4 R
3 B1 u) G* m T9 O! ]7 g+ q% \
printk(KERN_INFO "LED unregister!\n");) A+ H: g3 T9 r* T
}
1 [0 x% {+ b6 {0 L9 k6 t0 f# }4 f- \! i% l3 {+ c3 V1 D' }
module_init(led_platform_init);
6 f/ \6 P2 r# ^+ ] b5 F) \1 Wmodule_exit(led_platform_exit);9 ]) z2 ~( O5 D ~
( {# t7 j! E% G7 y7 Q R+ TMODULE_DESCRIPTION("Led platform driver");+ V" ?* \ {8 U4 L7 [4 j1 S- o, R
MODULE_AUTHOR("Tronlong");
$ \8 e" R5 P) o3 QMODULE_LICENSE("GPL");$ E8 G, ?' E; P4 T2 W
3 M6 Q8 Y4 O7 r/ v4 E |
|