|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 k+ [7 Q: `9 i6 Y' _; y
#include <linux/init.h>
* M) U" Q s$ o6 z$ m0 L# k#include <linux/module.h>- [4 w+ U; I) I9 {* d
#include <linux/kernel.h>
, N' E+ l5 A0 R4 q* O ~) y- `1 Y* \" p#include <linux/types.h>- C$ g. [9 |1 d; P1 h/ B+ |
#include <linux/gpio.h>
6 D9 X% `' x7 ^# j- ?#include <linux/leds.h>
0 P- d$ v7 | b4 T; C* r#include <linux/platform_device.h>
) Z6 ~/ e3 |: p2 d! j, P' S$ {
, P6 ?4 W+ F; Q#include <asm/mach-types.h>! ~1 y7 `7 l O
#include <asm/mach/arch.h>1 l( q" v: A" p, V0 `5 R n) {9 F+ f
#include <mach/da8xx.h>
0 z" A q6 Z! w# u8 V c' A2 H#include <mach/mux.h>, d: j3 \4 h1 ^
) u+ m/ `+ \& R. }) U/ D3 S5 U- C7 I/ O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 Y$ U" E" m m/ ~" C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, Y* m# ~: _+ c1 C7 n3 R- K5 O, C- _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 c& g+ X# [, {* O' z p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): {6 [: h- R" E/ R
% F1 H; o7 N5 `+ N
/* assign the tl som board LED-GPIOs*/1 Y0 A5 e/ L3 O$ q
static const short da850_evm_tl_user_led_pins[] = {
a+ \/ b! a d5 Z; W. S; j" G1 V /* These pins are definition at <mach/mux.h> file */
6 s% s! F. G y- [& j: ]- t( ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* C7 r$ b: x( _9 V( |8 X$ L -1% w& v3 O1 `4 W
};8 _* k7 Z. z8 ^* T5 i5 i; D
7 `, F d& E$ E- [$ p) u9 K. D
static struct gpio_led da850_evm_tl_leds[] = {3 C7 S X- l6 j/ H( j7 x
{! i# R% L/ ~2 m' B5 D
.active_low = 0,8 K+ A* ?7 G# x% ]7 ^. s
.gpio = DA850_USER_LED0,3 |/ {+ X5 d$ f, E [# P/ E# c
.name = "user_led0",5 e6 D W* }) ^* i/ u* q/ T; S
.default_trigger = "default-on",9 ~0 M- e& ~7 T
},# r( E0 p3 |- a* M, V% |
{
- x# H' ?. P( F6 `: p& k$ v .active_low = 0,
- g8 Q, K6 }+ i+ W .gpio = DA850_USER_LED1,/ w) g- L' n6 w/ K: w! b) z1 }8 S8 L
.name = "user_led1",/ @! Y) L8 p0 w( a1 A0 p
.default_trigger = "default-on",
4 B5 p9 R, D) G- L1 S },
" w' ~- u* F2 z3 S7 G. @; T5 [ {
4 e! ?: E3 J2 {7 }+ D .active_low = 0,
# M: I# b: n* s) T .gpio = DA850_USER_LED2,
1 H6 J- b# }+ h .name = "user_led2",5 i$ ?$ J8 K) x
.default_trigger = "default-on",: e2 ]& _6 \' D' W
},/ i6 f: }- T3 ?& Y4 R
{( Y( f! i. _( b8 F
.active_low = 0,; ^$ a3 M, C+ s q, z2 ^
.gpio = DA850_USER_LED3,$ P* D" C$ \6 N2 d6 {6 i4 P# n
.name = "user_led3",
) y( Y! ?! v7 H" O8 W, W .default_trigger = "default-on",' G) M, k* ], T7 I& ? m
},' a& V& _1 @' S1 [3 V [
};
0 K* C( C u. Y' F
; E( M& ?+ z" {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! K3 B! B. c' }; h
.leds = da850_evm_tl_leds,
. X _9 E: A; Z; Y1 ]7 q/ Z( Z2 w. p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) M. d% a1 \ M! [1 U$ m};$ g8 \; c' z5 |$ _& C) @. Q
9 ?1 r$ ~' U2 y+ Astatic void led_dev_release(struct device *dev), P( j; q& P, p+ j% K+ V
{
" `5 A7 V4 S" g0 _};
! b7 d: e6 W4 V8 F, E5 q) I+ T) I, u& U* f' o
static struct platform_device da850_evm_tl_leds_device = {
- X) k N+ E2 O: Z8 U4 { .name = "leds-gpio",
m5 f( P! ?9 k$ |- k9 c" e .id = 1,# o4 v3 _0 P6 B: K8 Y K
.dev = {
% {9 ^* L: U1 q) L# }4 p, X: R: I2 p9 K .platform_data = &da850_evm_tl_leds_pdata,9 |; I' ~2 U# x& H2 H' O1 U
.release = led_dev_release,
% m% |9 ?. H7 q& y }
' i& f# l$ `! s0 @5 B};
( w1 U; ^! g3 A
% x( Q8 V4 |+ z" w zstatic int __init led_platform_init(void)2 D0 \7 d" [3 o& S' a Q
{! A) A+ }( y4 `: {$ @ e
int ret;
* k% t: N( x( ^+ I" z#if 0
, m' Y7 @; E+ Z1 n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 t9 d3 b9 b7 }# h5 H
if (ret)& n" z4 Y' Y) G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 d' k1 O2 K- `. K8 D7 O
"%d\n", ret);
+ @0 K( }# m5 e& w* `#endif
) C$ g; x( f! `+ t4 J ret = platform_device_register(&da850_evm_tl_leds_device);
4 S% ~8 y! Q) R& S+ z. J0 n0 | if (ret) f, A" T, ~4 u: i8 {
pr_warning("Could not register som GPIO expander LEDS");
6 G; N$ a' S' Y* B% i; j' j else
- M' W" t0 u2 g3 i printk(KERN_INFO "LED register sucessful!\n");) [# K9 Y4 W3 w; |% I5 j' b% j) l6 ?
: z! F9 P6 }, k7 l3 |0 `8 g return ret;9 x7 B& x' p" J+ A3 g( F+ ^2 e
}" N. j) n1 v* x8 Z* @
4 D7 O8 x$ f: }! B
static void __exit led_platform_exit(void)
4 `# l% E# m/ t9 H( j( L{2 ?% y) I5 Q3 c$ p
platform_device_unregister(&da850_evm_tl_leds_device);/ T6 B& D& @- ]1 l* b
! T- h X8 I. r( H: F printk(KERN_INFO "LED unregister!\n");- `" W1 S8 a, X+ q
}' {2 P" ~9 L) s0 g
6 Q4 z2 D9 F: Y: _+ z3 Smodule_init(led_platform_init);
6 g( D) X7 ^% `7 l# C x$ ^" P1 O1 `# Hmodule_exit(led_platform_exit);# r- }5 c! y! O; Z0 r, E9 O" y
) K9 e! E* e7 I% R
MODULE_DESCRIPTION("Led platform driver");
: Q. t! L& a# T" y7 t- {; L" mMODULE_AUTHOR("Tronlong");
% A4 `* `) f4 RMODULE_LICENSE("GPL");3 l" ?: _: y3 D9 d9 {( `
+ z9 J. Y- `7 d, \2 x% m! j6 h
|
|