|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: V' Z! l0 M: h% m
#include <linux/init.h>
# S- |$ r8 k4 B8 P#include <linux/module.h>' p: [+ k& N" b, u
#include <linux/kernel.h>
+ R1 ]9 t; [! M#include <linux/types.h>
8 _* ~/ P' c$ s6 H#include <linux/gpio.h>
; a) E# H9 B, t3 n( D" I#include <linux/leds.h>* q) {( f( ^$ N. ~+ b
#include <linux/platform_device.h>& K% S# {; Q5 y6 i; s* Y. z5 E
2 j5 V+ k6 Z3 _7 X, l3 P
#include <asm/mach-types.h>
" e' m! g9 \3 _/ E5 G; E#include <asm/mach/arch.h>
" t$ X; ?! I5 H/ r E- a4 A#include <mach/da8xx.h>
, f/ V1 h) C9 s v* j0 U2 `; F#include <mach/mux.h>
- r) X) [3 c, E1 t, @# o& O4 j; C) X3 _4 K: K! |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 J' x$ ]2 O* R$ q! ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 @( D( @, N7 g5 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ e2 r% @/ _6 w+ J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% w0 y! p- x. r7 P" S D" q1 w7 v5 @0 }$ Z
/* assign the tl som board LED-GPIOs*/
/ n* B. u; W& ostatic const short da850_evm_tl_user_led_pins[] = {
: b$ X/ ?7 }$ Z /* These pins are definition at <mach/mux.h> file */
& ~- m& D. ]. H7 k6 p ?3 Q" ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, G( R+ @3 ~" J7 V -1: v- \9 R- @: V: }
};' e. o' W3 K r/ _$ l- C
* a1 P6 ?& w' r% `2 x0 ostatic struct gpio_led da850_evm_tl_leds[] = {
5 I, C% ^: h: ~/ R0 W( e( X {& f& ]$ n+ |; e, ~' ^0 i5 M; I
.active_low = 0,: e) t; A, I2 t8 O6 E# K6 n% ]. [
.gpio = DA850_USER_LED0,
. p5 `" s( D9 w, s! |- E .name = "user_led0",
! @' l1 U# u! Q3 @ .default_trigger = "default-on",
` d2 x- C2 L- j* P },. h2 l! A. h, z
{
9 p$ T1 g l( v .active_low = 0,
) m' r$ g; U- q2 r! Z* _% N. i# X .gpio = DA850_USER_LED1,* M9 ~1 H1 v# m, m+ L6 N# S. y
.name = "user_led1",+ v1 D7 U) a8 M0 [
.default_trigger = "default-on",# L& c- o' f3 c+ e* d1 i
},
+ I, M0 j; B5 ~, I {8 n/ q( A& M! B" w; a" a u
.active_low = 0,. M2 L1 k7 W7 I5 p# G
.gpio = DA850_USER_LED2,( P5 H2 H4 P, ]/ b7 B" Z
.name = "user_led2",* Q. M) i8 }5 G, z5 |7 x( m
.default_trigger = "default-on",
4 n8 I/ y, K* s$ z: \& { },
. y6 P8 i9 i% Q- Z+ ~6 Q+ e' l% T {
. {7 G I4 b4 I; p$ G- K$ K( I$ y .active_low = 0,; n+ r s3 J0 A0 Y
.gpio = DA850_USER_LED3,1 v3 c H- R z# f- T6 U+ X+ p3 e
.name = "user_led3",& @2 u: I2 q3 A% V+ P* ]6 J
.default_trigger = "default-on",
- N. ^/ U8 K. V+ F },
5 y+ U R7 b5 x( ]' W6 o};
( {2 O+ u, }' i2 }' b
/ o2 w# E7 g! b: A# astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ P1 Y' y: K# _5 p( L: t .leds = da850_evm_tl_leds," T+ H, W) u; |, K: p7 N2 p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" n( |3 _9 B- N9 h: T};& C0 ` @) @9 Z9 B+ }7 [7 [
8 H. g- x1 ]* T8 @6 ~) Sstatic void led_dev_release(struct device *dev)
/ x- O( a% H( N' p9 J* j* v$ P{
7 J3 ?( L; c7 z" ^0 ~+ I" `};
- F4 Q! m) Y5 K* u1 c N5 J7 w- x& j% A: n1 Z5 s- K
static struct platform_device da850_evm_tl_leds_device = {9 A( b" Y# P- N! K+ Y
.name = "leds-gpio",
; L) l4 Y$ k9 |' y! d .id = 1,
" d# _2 ^0 g5 F* { F% D .dev = { c0 h7 M' S7 ^0 p; _) m3 q3 Z
.platform_data = &da850_evm_tl_leds_pdata,
! ^. K! z2 t; H/ T8 Y8 x0 M .release = led_dev_release, A1 f r# e8 R# X: j3 P* p
}
/ g+ m/ z. _( U. I( `};
+ S. Y' p1 `& ^$ T7 t
: _, c5 e) T4 Ostatic int __init led_platform_init(void)
6 @& r7 q: {! }& B D) B. U2 G{- V$ G' U4 J- P6 j: |% m/ {
int ret;9 m# L" y/ d |; \+ [
#if 06 b* M/ _7 g0 W+ a# j/ y# N v5 S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# l! l( v& e# b, R5 F" v, Y) b if (ret)
$ P$ n3 f/ O- s* p" W& A pr_warning("da850_evm_tl_leds_init : User LED mux failed :") v# j+ t6 h. }* _* F+ q
"%d\n", ret);
' I7 t( c( Q9 c* \#endif C% j c2 D, v
ret = platform_device_register(&da850_evm_tl_leds_device);5 x3 F- t* X/ }" M6 I
if (ret)/ n7 w2 ~ V( R
pr_warning("Could not register som GPIO expander LEDS");$ { W$ {% v- f* y) ]& w. G2 K
else, f: s9 D9 f# F& ~. `: l" [& x
printk(KERN_INFO "LED register sucessful!\n");# N9 M* c, ]3 G0 t2 [9 W. Q3 H
/ k% F3 |' U4 \, \7 z, b1 A return ret;6 I0 l* B8 q4 o
}
5 Z& W1 X% x/ _3 a; p
3 |8 A# }. ^, D& n7 m Gstatic void __exit led_platform_exit(void)
+ ~) R' f! i' Q% N# w& Q{
$ \4 x9 M; I( F% A platform_device_unregister(&da850_evm_tl_leds_device);0 _* L* Q3 s# G# y4 `) c
/ n0 c/ s# e) X$ M
printk(KERN_INFO "LED unregister!\n");
1 D D+ M9 p! _* }}# B& }6 l$ y7 W0 M% b6 A6 j
1 q7 h& o0 S6 L; a3 ~1 z* u' Y
module_init(led_platform_init);! b* P3 ^( ]* [! w# ^
module_exit(led_platform_exit);
" F: {: A1 B- F8 `7 O) \9 D( B, S% |7 W
MODULE_DESCRIPTION("Led platform driver");
& F; o. J$ B4 w* U+ CMODULE_AUTHOR("Tronlong");! |. b, c) O( o% z7 s# k
MODULE_LICENSE("GPL");4 a/ r/ U. u- f% u( ?
! n% d3 z* ^" p& ]6 C
|
|