|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 ^# R" H2 u" N% z3 O+ r" ?8 J2 B2 k#include <linux/init.h>
8 f" Q2 W5 G5 d0 d#include <linux/module.h>; n" Q: ]8 k$ M0 d5 c) x. y
#include <linux/kernel.h>
- ^8 L M4 c1 W#include <linux/types.h>( ?- u; m% c5 N" U0 _
#include <linux/gpio.h>
' @6 F7 v# x3 A#include <linux/leds.h>
: ], O' P$ N9 A T8 h6 J4 s& m#include <linux/platform_device.h>1 C" N: l- W' n5 y, v+ h& K
( M' M# M" G% m- z# E( f1 y
#include <asm/mach-types.h>
6 G; r5 u) k" X5 }#include <asm/mach/arch.h>
1 A) Q5 \4 t- R" H#include <mach/da8xx.h>8 B9 `# y" T! p1 a/ ?: ^
#include <mach/mux.h>
* A1 N5 p! D* R) ~; J2 r3 N* o
- f% F6 G& G/ {1 A8 U. E; a0 [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% b% E3 b; i% p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% C$ s" k9 b0 j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* M1 P5 C* S4 a; k% n2 j/ z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ m$ k! I6 K- g& ^
7 V3 f- I; X9 A+ M a/* assign the tl som board LED-GPIOs*/: U: R1 r; @: O6 h2 V* T8 B
static const short da850_evm_tl_user_led_pins[] = {0 X, @3 E: a; ~5 o" C
/* These pins are definition at <mach/mux.h> file */
2 U& q3 g2 V4 q+ m9 S3 a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) c' G+ i6 a1 H* ?) I
-1
9 s% c9 M' M) c' d( m0 q};9 E) ]: s* a/ W7 m
& b9 F; m7 }8 s# K1 N0 a& P1 n
static struct gpio_led da850_evm_tl_leds[] = {( y0 y0 b2 ^/ z S' k" o) j& D
{1 r+ O, K1 Y: }/ f
.active_low = 0,. E. a4 U! w% A( N
.gpio = DA850_USER_LED0,: L. s/ h0 ]: |- [( M! E9 _
.name = "user_led0",
[3 L; F1 x. y8 A# l .default_trigger = "default-on",* A9 @' a, r4 P" A2 a) A
},
( D3 K2 m4 r' j; `6 x" c {9 V# E2 `2 d# F& {5 z
.active_low = 0,9 p( V3 n; E d B9 Q. {( Z3 {
.gpio = DA850_USER_LED1,
{4 u/ W5 s# }- M! ~ .name = "user_led1",
d4 p* x2 Q1 V6 X9 m' u4 Y7 \; c2 G .default_trigger = "default-on",/ K: R) g& G6 n: {: Y* s$ }! r' s. _
},3 v5 O" @; {2 ` c
{
, D) p# b1 s1 q; ~1 }$ J .active_low = 0,6 t2 F- G# Y8 ~+ i
.gpio = DA850_USER_LED2,
: @4 o) s( F# ]. J .name = "user_led2",6 v2 x2 i& ]; T
.default_trigger = "default-on",
; S- i0 |$ k) U! t6 A. D },
+ g! G% S% s" U4 S {( ?9 E# ^5 I, z) M8 ]+ M
.active_low = 0,: w6 w. Q; a" U9 N J8 m
.gpio = DA850_USER_LED3,$ ~2 o# e* F8 k( p
.name = "user_led3",+ E5 [; J8 L5 N. I# ]: ]
.default_trigger = "default-on",
- \+ z: ~) o6 s0 n) m9 H2 d' E },( k L* |! g6 `0 e' j5 x/ a
};- H% u6 |, ]- _3 {5 N
4 X% o) t C# M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 A' z. t' N- f7 T4 g
.leds = da850_evm_tl_leds,
# r& v* l6 q! ~5 H9 X* U9 W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 F5 j: U9 n7 U* i! Z};4 E1 s' T, t3 g0 c( C- R4 s
# m3 X; a# n: B+ f/ V1 ~8 ^+ i8 j
static void led_dev_release(struct device *dev)/ |. V& c H/ x$ u
{- c2 Q8 w. h2 Z: D6 J f
};, \) t) \. g8 e! U; G% j9 T q
( M3 U4 t A( q- q! Q) fstatic struct platform_device da850_evm_tl_leds_device = {, o w- x$ o+ T. f- g% u" S
.name = "leds-gpio",+ {, R' ~* ?& Q. j; P
.id = 1,5 ?! l! ^! K H# n- a( x- d
.dev = {; w' G8 x1 _: y" f$ U
.platform_data = &da850_evm_tl_leds_pdata,
# p7 X$ h, y8 O0 j .release = led_dev_release,
0 W/ }+ r6 j) `2 q) k }
4 J- w& {, y+ f E/ K% N% m};$ R2 H0 g# K4 A7 B) @2 ]+ k
7 e$ H4 }/ t6 {& X& o! ^- o$ Y
static int __init led_platform_init(void)) ~7 L! X T2 z8 R+ X2 O
{
" ~* Z; ^! i' D int ret;
1 [/ j$ D5 J2 D% J5 X#if 02 F$ k6 E# X: m4 A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 X |, ]" P8 E$ E if (ret)7 e- Y+ j0 Y; h$ Y- {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 L- }7 c+ @2 n! ~
"%d\n", ret);. { C7 }9 k3 g& }3 X+ P
#endif& V: |: n/ j0 }# k. u% } n# z
ret = platform_device_register(&da850_evm_tl_leds_device);! u$ c8 ^+ m! s7 `' `" d& m* j
if (ret) Y: Q% b( b; ~; J: S% ~& A) X
pr_warning("Could not register som GPIO expander LEDS");2 q* j: q! G3 l) u4 I K6 G
else
0 i/ g0 L1 ?9 f3 o& b6 T printk(KERN_INFO "LED register sucessful!\n");
3 m/ F) ?7 i; j8 d9 v$ O% H8 L4 {& C
return ret;
, Y: p! w% N; X: [7 X$ d) q}9 `* _+ g4 g& [
~6 K8 K7 F/ q: P$ n% u; ]0 P! `static void __exit led_platform_exit(void)
1 q/ X9 r! K0 U6 Y{5 x, M- Q2 c4 J! I
platform_device_unregister(&da850_evm_tl_leds_device);3 V- q- E, Q2 L. |8 P
" g6 C: J. R- |
printk(KERN_INFO "LED unregister!\n");
2 p. ^* N# R5 B, W}4 b8 X3 }, W c9 z
. \+ l6 g2 B' f) w5 smodule_init(led_platform_init);1 j$ l q; }& h/ C. ]
module_exit(led_platform_exit);
& a9 \' S- d3 y c& C1 w- N8 _1 _
MODULE_DESCRIPTION("Led platform driver");1 d6 K! Y+ f. E& v
MODULE_AUTHOR("Tronlong");
" \3 F- M" `) C, }/ l7 U8 N9 }/ pMODULE_LICENSE("GPL"); s5 q- l) v' C" l8 X7 b- O7 p
$ Y5 {9 C, Z+ H" d9 J4 x
|
|