|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* H$ _% R/ G$ x& R
#include <linux/init.h>6 }, z1 }1 A( e+ l
#include <linux/module.h>
) s/ j1 V6 U/ D8 E#include <linux/kernel.h>6 e! O$ P+ w* y! o
#include <linux/types.h>/ ]) C# i, y+ {% \& C
#include <linux/gpio.h>5 W. e7 q8 e4 _; Q8 L' C3 Y9 ?
#include <linux/leds.h> V5 p$ T$ [# g. N9 u' M
#include <linux/platform_device.h>. }* O$ o" h% a0 f1 \9 @* v" F
2 @7 ~/ l# I, K) V1 l' v, x; d
#include <asm/mach-types.h>
: l% m7 q. a t#include <asm/mach/arch.h>* B4 {- | Q2 k6 g8 ^7 q9 {
#include <mach/da8xx.h>
: b' Z! t% f+ a: q- c* L! h7 d! z3 q#include <mach/mux.h>8 C* V0 |4 N- _" [
1 F+ J" {% j8 Z' k, Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% p+ `0 Y1 l, |$ [! X( M! d$ m. ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 O8 n9 P7 I! B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 H* W) _0 a/ I* E#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" X% X8 C" d; |! Z# J) W. n2 h1 h) Y. `' H6 T* x
/* assign the tl som board LED-GPIOs*/+ k7 q+ m1 H! T, ~0 Y% o
static const short da850_evm_tl_user_led_pins[] = {
! E. j3 F' M( k, T, a4 N4 I9 Y1 ~ /* These pins are definition at <mach/mux.h> file */
5 x* Z. z$ v- {7 x! U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! h* p) U0 @- l9 m
-1
$ w. y$ Z. B% D: Q2 g3 x- b- P- Y5 M};
! i# P6 ?5 W* D, h
* H% b7 W$ [1 J. }) J, ostatic struct gpio_led da850_evm_tl_leds[] = {
$ R6 G0 X8 {( i4 T, k7 X: B3 f {
( n: E( L# F! a5 M# i* S( t$ n .active_low = 0,# H" [# ]+ j) D2 W# Y d
.gpio = DA850_USER_LED0,
/ e! d8 T1 L' `% l3 q8 b5 P .name = "user_led0",& I K# S$ Y) G( r
.default_trigger = "default-on",
" {5 t7 }1 r; `* K: y* M4 J2 r B },
2 e. _ N$ e& f8 d7 ` {; A" i7 x/ U0 U0 @ p0 P
.active_low = 0,8 f1 i7 i9 f; }- Y
.gpio = DA850_USER_LED1,# ^* x! @: G4 B* t$ N) C
.name = "user_led1",
7 f/ v* `4 a9 ?/ m* ?' ]9 ^* D .default_trigger = "default-on",
' ~% N7 k' `! u+ a },
! X' e- c) i8 T+ S {1 q# k/ s# h3 ]3 q
.active_low = 0,
7 X1 q; Z; F4 E# G8 M, N .gpio = DA850_USER_LED2,% c* G- Y! Y. g5 h5 ]% X
.name = "user_led2",& N' U6 T7 a+ B/ z7 }/ w
.default_trigger = "default-on",
5 a0 c* Q0 |7 p* U },. v2 N" L% k f- J8 k* {. W, F
{
* q5 ^/ [6 G1 }6 [; c .active_low = 0,- F# Q" n' O1 r" n
.gpio = DA850_USER_LED3,! v+ C1 q! `6 b
.name = "user_led3",
, B/ u" S1 q( J5 h, Z) Y+ ~ .default_trigger = "default-on",
9 M: \: W9 c; N& U# V& ?+ d },& n$ V( r/ U0 A. E4 r6 K
};+ B. K6 K A6 D# j- O/ R
7 s4 u+ v. A8 f( W) lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# M* j6 N" e$ ~+ X/ ?. Y
.leds = da850_evm_tl_leds,
. x. M- n+ t+ z: S# n# ~6 S6 v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% M# {0 G" h/ m2 D
}; M# G# N$ M1 w0 H, Z
8 O% `1 d* K, z; g" D' U
static void led_dev_release(struct device *dev)8 L' B& j7 F4 m# E
{
6 V% l8 ]! q6 N; K( H" I$ e3 [};
5 X1 i( B; Z V {" K2 y: \5 n+ D& L- z1 Y- X3 v
static struct platform_device da850_evm_tl_leds_device = {; { v, ?, E0 X( }
.name = "leds-gpio",8 m: A4 \/ W" f$ N. g r9 x9 Y# e" ~
.id = 1,# d7 u$ I9 @" v% k/ t
.dev = {
- e9 h6 [; t" i1 y; P# J4 {, e .platform_data = &da850_evm_tl_leds_pdata,
# z1 L2 b" Y1 x+ Q .release = led_dev_release,, t& ]7 E8 i. r8 b9 l
}6 w4 f# @( v+ G8 p H! ]* u- m1 n
};
E$ I4 P0 y6 ~
0 ?; v0 q5 p2 [* sstatic int __init led_platform_init(void)
2 b+ m$ ?5 H8 x# e7 K( a4 v; S5 n{
7 p3 T4 n- v4 V1 d# \- ]0 I int ret;
2 P6 P/ c; d5 I# G; A9 t5 [#if 0
a) h& P: @0 _5 O5 ?5 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 K) X/ c# A* N3 v- Z if (ret) Y; A7 Y0 g5 M! H# h* J" b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") W7 g1 ]# ?) |* o3 V/ N
"%d\n", ret);
' w# F) L; ^9 \5 k2 G" ~5 E1 n#endif- I. h6 P- ]4 c: L5 P# i
ret = platform_device_register(&da850_evm_tl_leds_device);. F0 a0 [/ [* P) }- V
if (ret): e( M' N$ L* B1 m j3 t
pr_warning("Could not register som GPIO expander LEDS");
& e8 E- M4 E; R& q else# N8 D7 J7 j' f
printk(KERN_INFO "LED register sucessful!\n");
) v- h! d1 y& r5 u% ?1 i6 @0 z2 r/ R
. A- x% p+ y p return ret;
) V6 f0 |2 \# P# |: E! A0 ?9 X}
' s; e6 z/ ?0 ?" r
; H: j. Z' Y" i, Hstatic void __exit led_platform_exit(void)
7 [4 b" g! s) n# l$ ~- X/ Y1 Z{
1 D" y/ `- t6 h8 a& _' H platform_device_unregister(&da850_evm_tl_leds_device);
' U" e# Q& W/ }3 [6 o8 H3 o3 H/ t) F" m+ w2 t- w' b
printk(KERN_INFO "LED unregister!\n");
2 L( l' R& \! A( v3 R} M5 o8 A5 p8 a& t) o1 C
U; P5 v9 p S! X4 e8 {# s
module_init(led_platform_init);
3 o' u$ m+ k" v/ }1 @$ Lmodule_exit(led_platform_exit);, e9 p( J9 ]' G( D- ?
% H& h# S( V3 ^$ I/ fMODULE_DESCRIPTION("Led platform driver");9 Q# ]5 I' ]9 I/ f. ?8 M+ r9 e! h
MODULE_AUTHOR("Tronlong");6 ?2 J$ E' ]5 g; q& j
MODULE_LICENSE("GPL");
/ C% g/ o; A- t1 {# M0 \( ~0 V# y, g# F4 A4 t
|
|