|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; G% G4 f. {0 [" F#include <linux/init.h>
. k9 h% y- m, @8 L0 W# E, L6 C& j4 Y" ?#include <linux/module.h>
! _" }5 s! i$ S- b. E#include <linux/kernel.h>
. }3 i) s+ U2 M' m2 O. e#include <linux/types.h>
3 D& Q. f1 j% s' f#include <linux/gpio.h>
+ P6 X; i" g0 [& u3 f4 C#include <linux/leds.h>
: ?; O9 Q7 D) [#include <linux/platform_device.h>
k$ O& z. b2 L1 r% v/ s
! G, L1 Y5 t. ^, a3 V: l n& \7 s#include <asm/mach-types.h> \, m M5 h0 W, J3 _7 Z
#include <asm/mach/arch.h># M2 N9 ]) ~+ C; N
#include <mach/da8xx.h>9 _& S/ D# j5 u3 M
#include <mach/mux.h>$ T' j4 a( @3 C3 x P
7 T0 U* R. o1 X% S8 M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- f4 U E0 s$ j4 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( t8 q! |6 g0 g! n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 q7 Q5 d Z8 o0 I; z' Q8 q7 C2 {% V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 Z, |- l, g2 X! L
2 ]% ^+ i K. b5 f8 ?9 f
/* assign the tl som board LED-GPIOs*/6 ?, _& O1 ?- Y' F+ H
static const short da850_evm_tl_user_led_pins[] = {
" C: j& g& @2 ^9 G1 c+ W /* These pins are definition at <mach/mux.h> file */
& h9 Z2 J6 c. j$ Z; F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. u! H6 r& F* d9 ^+ @
-1: B" t5 d9 ^1 h, b) h+ F
};
' O2 |/ i" n, U- d9 t0 K! u
" ~. y% I/ b! t/ D* @6 ~static struct gpio_led da850_evm_tl_leds[] = {
* ]. X: J0 U( k* ]& K3 ? {
5 Z' Z# J, k# r' c8 q! ] .active_low = 0,, d! F n$ j& @+ U0 L2 u2 _% U+ o
.gpio = DA850_USER_LED0,' {, Z$ w4 ]8 Y' G
.name = "user_led0",
% Q2 D$ [" n# Y# e, }! I .default_trigger = "default-on",5 ]' p2 y8 {4 K% L/ ]. I
},
1 n0 A( m4 A, i" P {+ W( m; g) A/ e' O* b1 J. e1 r
.active_low = 0,2 s+ T8 N @. j& P; I
.gpio = DA850_USER_LED1,
+ p6 U0 B' O" _2 V% y6 w .name = "user_led1",9 n% g0 M6 g8 V( H. X9 z. r4 W
.default_trigger = "default-on",
9 B4 Z# `5 E0 i$ Y" N' `; f },1 i9 O0 m8 G: }( L9 L
{
3 a& C+ p5 f K1 q9 L .active_low = 0,; ^- b; e, r/ U2 [! l5 _1 R. z
.gpio = DA850_USER_LED2,# k$ U$ P8 }: U1 ~/ g
.name = "user_led2",
# i$ b! f4 y* Y- e& N8 r .default_trigger = "default-on",) @) g0 _( _8 _6 _/ I# N
},+ Q$ E0 |; z+ x
{
' d% O2 v4 S2 @$ S, m; d2 s .active_low = 0,4 V ^: |! }! Q8 Q% t! w
.gpio = DA850_USER_LED3,
, P o% s0 I5 S/ T6 l/ s) h$ n% S .name = "user_led3",
1 B5 ~# p$ h0 `' |8 V% n7 x .default_trigger = "default-on",. T3 p n: z9 r6 F
},
% G O. I( [7 q1 c, _};
9 A% G& c7 J k; [' @, V6 B6 y/ S6 H; K% c" M% }# u7 y% ^8 ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" q P3 q5 g" s6 b5 W! ?5 a, Z0 C .leds = da850_evm_tl_leds,' T9 ^0 P/ Q6 ?8 q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# ~3 `2 j6 C6 N" n1 n9 S2 h
};9 K+ Y9 o% b- ~' C5 ^9 v+ A
' _% b9 B8 p! i4 e7 M$ i, lstatic void led_dev_release(struct device *dev)0 A' D4 s: {" }9 U" X l& T* D
{
6 l5 E" v3 @9 u- r" i( I};6 r i# u# L* T; |
& u3 f& l' Y! c9 A1 T( |- mstatic struct platform_device da850_evm_tl_leds_device = {( Q) A1 j# C8 }
.name = "leds-gpio",# F; q5 f; l" B2 b' `3 y
.id = 1,
& r. H( ?& O* i) d' r .dev = {
$ [- T" _. F$ ~- ^: _' v .platform_data = &da850_evm_tl_leds_pdata,
6 a+ {+ A) Q# w, N1 s* n3 N# e .release = led_dev_release,
6 t/ j+ T" u. Q' T% w2 L+ P }8 i2 O& t, Q! t2 X) [& ~
};
: w# I2 F7 i4 r" E: I( t& P/ g2 ~ p3 ]# r% [
static int __init led_platform_init(void)- c/ \* G: r' L+ w1 V) x9 m) L) |
{* d& y7 Y% d% o& U0 U
int ret;
. X- \/ q( D3 e#if 0
+ `: U3 g& [: x; L. Y N" e* e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- `9 ]7 Q' Q3 I0 S: e' b if (ret)
' a' p' f# b7 k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ m4 e6 x9 }: s# y$ C( B "%d\n", ret);
2 k# U- Y# ]& S9 W3 F: L# C#endif8 i( _* z! x7 }
ret = platform_device_register(&da850_evm_tl_leds_device);
2 I/ Y' e) \+ h: J# T if (ret)
% C# @0 V8 Q2 s( ]1 | pr_warning("Could not register som GPIO expander LEDS");! L0 n: }6 d. F# A0 z4 y. @/ z
else
# D! ]4 c+ n0 ]5 ^, n printk(KERN_INFO "LED register sucessful!\n");
/ L' Y7 M- Q8 T
6 h/ Q0 E! S2 m! r/ x return ret;, e/ g' s5 i/ G2 e: _6 b
}
$ u0 ?; t, l1 m8 p8 \" i9 O& E: e3 u
static void __exit led_platform_exit(void)3 f) Y8 }/ L2 A$ y: {
{- D0 Q+ Z- ?8 A7 Z6 ?
platform_device_unregister(&da850_evm_tl_leds_device);
: i9 v" m) l5 V0 U
3 {! [$ L1 J, w- X0 ^, W printk(KERN_INFO "LED unregister!\n");
+ j+ W$ M- T5 Q1 _}
5 \" r2 l8 U: b5 A( r. J0 `7 T* i
" X1 C( Z3 {4 k0 g, W4 Fmodule_init(led_platform_init);
% \& s' p8 i+ F- qmodule_exit(led_platform_exit);0 A+ `( g# ~0 I1 `6 l1 s
2 @+ u5 |) O9 d: g: _; V9 D, VMODULE_DESCRIPTION("Led platform driver");: l& }' ^. R; {
MODULE_AUTHOR("Tronlong");
& O5 V1 _8 `) n( t; y8 x8 e% c9 }MODULE_LICENSE("GPL");. p6 r' A& h: i( ]0 l: b2 \$ _: D
. R' r2 l8 l3 r9 ~ |
|