|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
~( [! {( Y3 d: U6 `9 w#include <linux/init.h>
* U, }5 o) c: t* W6 F0 \#include <linux/module.h>* ^) v8 [3 D8 e2 V5 d/ T; \
#include <linux/kernel.h>
: {6 [: F% x1 A#include <linux/types.h>
. d+ k. b1 g9 x2 D& d( V9 h2 }#include <linux/gpio.h>
m" L6 o' z% b6 d* K9 p0 q6 I#include <linux/leds.h>9 u) k3 n# h% j( ^- y$ v
#include <linux/platform_device.h>
* A* b6 h% O& J# R3 _6 Y9 y
$ n/ H$ B6 _" X8 k#include <asm/mach-types.h>$ O( q9 e: u7 R
#include <asm/mach/arch.h> k e+ m3 ^ B9 K$ F" O
#include <mach/da8xx.h>) R o, R' X- D. D& u% p
#include <mach/mux.h>) |0 a. K' h& |# z
3 e: n! ]5 A! K. F, A% i5 m% @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( x4 m+ H Z5 Z+ P9 I& m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( X' s9 `% ^4 }5 w$ |8 k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) W+ I+ H5 S3 j( f4 }7 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# D+ z, `/ q' u) v4 u+ g
; y& R6 O& v4 o5 o4 V' I/* assign the tl som board LED-GPIOs*/+ t9 i2 A+ u" H
static const short da850_evm_tl_user_led_pins[] = {2 ~8 r% M7 ?/ @! M9 P l7 ^+ C
/* These pins are definition at <mach/mux.h> file */# s8 A6 N% Q, R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 e$ q3 N8 W, G( O, b; p -1
! o+ n+ b* c) @& M$ R& V3 Z};
' ~ s4 f4 _9 H: u, N5 J p4 E' R+ p O2 D# W( p. P
static struct gpio_led da850_evm_tl_leds[] = {- F6 w! X3 @* b& K; c' S
{
( X) r/ j+ w( G l! D$ c+ z% G .active_low = 0,/ l4 X7 h( a$ Z. c0 |* q9 t
.gpio = DA850_USER_LED0,% I6 V9 o' N9 D( x/ L
.name = "user_led0",
8 c, `, R: f1 t, E6 i .default_trigger = "default-on",1 z3 |: h7 P' o
},9 i; C9 D( B9 S: G& b; s4 K
{. t5 Y0 Y, m" ?" [- I, f
.active_low = 0,1 E8 U1 }. T; U- x$ g% f. n
.gpio = DA850_USER_LED1,5 s5 _4 a# g/ n$ [5 Q
.name = "user_led1",& p, I V. M8 f* w
.default_trigger = "default-on",
# k# a" ]. A6 U; a2 H" Q" h },. f! M4 K) t) z% g* t: \" z
{ L4 ~6 ~( s+ j8 L, w+ |
.active_low = 0,
5 s0 ?3 i: q! { u5 e$ P0 B .gpio = DA850_USER_LED2," q1 E. ~; Z0 l/ G2 R* I# s& g
.name = "user_led2",; `4 N; P0 T; }1 ]; T
.default_trigger = "default-on",
6 J; p2 w/ T* R) y },
- S7 z# P+ w: S3 G {
: _6 p6 Q$ A" z8 ` .active_low = 0,+ I0 z- B# d- K! d
.gpio = DA850_USER_LED3,
/ P& c! E3 G/ V- M! T, |/ ` L .name = "user_led3",- X, y# p! e( O# D4 A
.default_trigger = "default-on",! M# {7 M. B; S- _! F; \+ ?
},' e' O; C- M1 z$ C; Y7 ?
};% H, \( H+ I) c
. v1 b) r& e' |" t1 _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 g, f4 q6 h$ ^. R4 m5 @ .leds = da850_evm_tl_leds,
; ~& L; ?; L1 t# {9 ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! ^0 f+ `- [, c! D# I};! n. ]1 Y% n' M+ d6 D
- J+ E# i8 Z" _6 v& _1 s
static void led_dev_release(struct device *dev); V- l, p B; s
{
$ Z( w. H7 v. B# v};* V3 Y) t. |5 L+ V5 m
6 \" C% q, X) i0 [
static struct platform_device da850_evm_tl_leds_device = {
) B$ }$ |; c u- s- D% K7 ^7 d .name = "leds-gpio",
' q) F% v5 q3 a/ v; t" g/ E .id = 1,
6 ] G, m r! h/ o+ y3 _& G/ c .dev = {
+ B2 k+ {5 R! C& S; ] .platform_data = &da850_evm_tl_leds_pdata,
: q$ Z" E! t9 K) v' k: s( X .release = led_dev_release,
* G2 p, {) m4 q, |+ [6 y }, ~! q- V- R. q; Z
};
2 F# k. O4 P) M9 I& F
1 y# [ r, b- p K pstatic int __init led_platform_init(void)1 I3 o6 t1 b- g0 M
{
+ s4 }5 L: v" V& }3 ^% _ int ret;4 `7 }6 O; H G
#if 0
/ A3 S/ N' x/ Q7 ] W# I) ^! A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); c4 H2 E0 x( U$ h
if (ret)
* D8 t; y0 e0 P( }% ^3 F# R! t) ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ B1 b/ w4 f0 g5 j( q# W7 c "%d\n", ret);
% H- U; |0 }! A4 `) r: E#endif
# z8 f+ a/ l7 Q1 b, w' k% o ret = platform_device_register(&da850_evm_tl_leds_device);
0 K3 T7 K( L1 o' `. ?- P if (ret)2 |! [4 A2 ~6 R8 \" H
pr_warning("Could not register som GPIO expander LEDS");) q; F% f4 p: }8 Z9 A/ U
else
3 V9 @1 `" \' L printk(KERN_INFO "LED register sucessful!\n");
0 x% h# L7 q6 `! i) K
0 _, ^* w$ _! c/ k! h; ?8 C return ret;. X, S* @% `# ] o8 H0 B9 e# b
}
, |" D J2 d E' L3 V8 w+ c: H! G0 B4 ?( ?
static void __exit led_platform_exit(void)6 Y! R3 w+ B$ l+ n
{
8 Q I; g; y5 a* B9 V platform_device_unregister(&da850_evm_tl_leds_device);
( A; D5 l6 g# [3 |5 W P q3 E) {, O- N
9 Y, E# S, l" R& I) R' U* ? printk(KERN_INFO "LED unregister!\n");$ X7 o1 k6 h. U
}) {" i* C7 @! G L/ Y
# `, e* ?& |( s5 emodule_init(led_platform_init);- B% z; A1 S- y, G4 U& G; m% _4 f
module_exit(led_platform_exit);: @( D9 N+ P+ A2 u- j' t0 @' F
0 M# K: o; x$ F2 e1 ]MODULE_DESCRIPTION("Led platform driver");
0 z1 a9 R% r/ IMODULE_AUTHOR("Tronlong");
4 `9 Y# c8 a' V7 }6 w/ TMODULE_LICENSE("GPL");) j+ a. L3 q+ M" q
; v- P. L0 n8 m' H; t5 a |
|