|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! |0 I" K; R2 Z$ _3 |, F#include <linux/init.h>
: h. B! P4 z% j" G0 n. v* V, C% l#include <linux/module.h># {% Z6 P$ d, L* e4 @& F# T
#include <linux/kernel.h>$ [ H- {5 w) B- B3 p
#include <linux/types.h>
, Y: D y, n5 X9 D% t- o1 D, f' H#include <linux/gpio.h>
S) T9 M$ I) A, W#include <linux/leds.h>9 M! a" ?7 O1 M# D! e
#include <linux/platform_device.h>
. D1 }% [8 A6 K% C* U
% M; j g% }/ U) w! x4 S! |#include <asm/mach-types.h>1 Y. v. L* u* N5 |
#include <asm/mach/arch.h>7 f0 o& u1 S u5 c
#include <mach/da8xx.h>
F( b' {4 T* P: E! ~$ p#include <mach/mux.h>
$ m- `5 |0 G" Q( p9 _) o; O1 V2 U$ V' m! H+ A$ a' G: f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 f" J: I8 a. I* p- Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 w& c: }% o! c' j% E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 k# O3 \2 k4 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 Y+ d/ v7 \2 k; i* H: w
/ ?" ]; n' h$ D5 Y; h6 c" f2 n3 @/* assign the tl som board LED-GPIOs*/7 n1 D1 |/ j2 V7 ]! F
static const short da850_evm_tl_user_led_pins[] = {5 W( ]3 T( B; S% b( L! I
/* These pins are definition at <mach/mux.h> file */4 y) q4 K2 A3 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 p! H+ A0 B$ C6 {; u7 n, d -17 ]/ X3 i& T2 v8 L4 w+ z% d: S" t6 K
};" R& Y0 W' H: S' K/ b# C* }' I
( I8 g7 H: k J3 o
static struct gpio_led da850_evm_tl_leds[] = {& Z. {5 m6 l1 m2 m( b# `! M
{* j% G7 n5 _# G. l
.active_low = 0,% \1 u; |1 \1 [2 y
.gpio = DA850_USER_LED0,
, g, [6 D, X0 j. @ .name = "user_led0",7 [' o% o: H. N/ Y5 R
.default_trigger = "default-on",) a' e$ y, w. N" d# |
},
+ y9 e; f3 g1 t) z$ M { z) N( b- x- M% ]' D
.active_low = 0,# _: i6 }2 i9 @+ A
.gpio = DA850_USER_LED1,2 W3 y# E" B. L; D! U
.name = "user_led1",
, n8 X6 F) {. E: L4 |( z .default_trigger = "default-on",* E. e! t! R6 I6 x6 w+ r
},! S- B0 z' L' `% ]2 X
{+ k, o2 i0 k' j, R
.active_low = 0,
/ f) @( `5 \# g7 s .gpio = DA850_USER_LED2,
4 f) B1 n9 t0 N. _ .name = "user_led2",8 }' {9 ^7 t/ H! v% x6 j' L1 r' G
.default_trigger = "default-on",
$ H3 G% a7 \, g! }6 J; Y9 q2 ~6 D },; h6 U$ A1 x& K+ \ Q. y8 n% g- S
{9 @& C6 l1 Z6 x
.active_low = 0,- v4 ]& G$ {- q Q Q2 a
.gpio = DA850_USER_LED3,' V% D1 Z# m& v; v
.name = "user_led3",( j8 o4 U3 z9 T' a1 {
.default_trigger = "default-on",
: e# _9 Y/ T9 A7 F },
3 y0 h( r8 n$ D; C! ~};7 s6 R$ u& d# i# u6 B
$ E& R, I) x( v b, V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! V2 ^) p. x* \8 X, `$ X; V6 x .leds = da850_evm_tl_leds,
- O* a" @ X$ Q/ C0 L6 Q4 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ h6 k9 G6 Z& R+ [) o
};
9 {) d/ |2 R' Y& E
8 ], ]% l5 A, }6 H- F& m, e' R7 Pstatic void led_dev_release(struct device *dev)9 m4 D* A0 Q' L7 E- m: @
{
r2 d v7 E$ Q/ P+ l& c};9 I2 g8 r0 p# }- C) S% Y
+ I5 W+ o$ s7 ^. E, estatic struct platform_device da850_evm_tl_leds_device = {
8 B/ Y9 E5 o C .name = "leds-gpio",
4 r* O, t. X; i9 U/ @% m .id = 1,0 S( H$ n' K: R: J' F8 d
.dev = {, A, |7 g# R6 C" `) [& @$ W0 l
.platform_data = &da850_evm_tl_leds_pdata,
" U, N* N; j' b. L; U8 H2 F, h5 [0 h .release = led_dev_release,/ T" I, L2 ^# `- W9 r
}2 V3 l, U: Z1 a6 B; @8 X1 v
};$ l( ` g7 P# C8 f5 f
N; r6 W( U) m$ c# k2 P1 C- l
static int __init led_platform_init(void)' p$ o% a8 o. j" x
{. X8 e6 a- v6 l' o1 z& H% ~
int ret;
# _6 q6 X9 M) |, D" _#if 0
/ w, K4 G6 q5 C! u' i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" @5 j7 X2 Z8 ^, R7 Y4 v+ C
if (ret)
- U2 l, }+ V; Y2 b: u3 l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" y2 B4 x. _* P6 s. z8 ?0 R! Z
"%d\n", ret);
' w1 i' b* V3 s" @& G' R( A7 M; A( D#endif
, H/ D8 u0 ]+ [* h ret = platform_device_register(&da850_evm_tl_leds_device);
0 _& e' \$ ?, i% c if (ret)
! C1 B! |1 u! F) U pr_warning("Could not register som GPIO expander LEDS"); ~9 Z$ s1 r, q; Q
else; k& _2 y9 k. I+ Q) @1 \
printk(KERN_INFO "LED register sucessful!\n");6 y. J# `- Q% r) g5 I
/ @' K' s1 l, K. X _$ o2 {2 I
return ret;& U' \7 ?! T3 I5 v. w
}
* ?* t. B! h: W2 x1 N* ]4 e, X& `' q$ V9 E
static void __exit led_platform_exit(void)0 n. i/ ^" Y/ t$ a! w) J( j
{
! W! G+ d# d4 {. [7 S) a' ^/ j platform_device_unregister(&da850_evm_tl_leds_device);
. d% b9 a' R% M) o0 f0 \" m7 T# {/ Y8 r6 n0 \
printk(KERN_INFO "LED unregister!\n");& K' V8 m+ s) Q+ `/ A
}2 [$ ]8 \4 z; T& H0 l0 d
' G3 ^. _! a) p" Q9 Q& ^7 p1 E( Xmodule_init(led_platform_init);
0 o5 z5 Z% h8 t( t6 lmodule_exit(led_platform_exit);$ d5 |' D x) w' ~
* ]5 I6 ]. j0 M% p/ \ oMODULE_DESCRIPTION("Led platform driver");
! ^# S) \: n, @4 \MODULE_AUTHOR("Tronlong");' O; M8 v, Z3 f3 }) K% M
MODULE_LICENSE("GPL");
& X1 g; j* a0 p: s5 r
3 H: n8 V- X4 ~: m# i0 v: A% Q |
|