|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" q8 o4 c: ^4 L+ V6 t+ Y#include <linux/init.h>
: e7 x* [# }7 e+ w, P! B* F#include <linux/module.h>0 R4 r; P; q9 E! A4 m( R, V
#include <linux/kernel.h>
9 b% }9 U C3 O& E1 u- p#include <linux/types.h>2 Q7 i) P1 T/ {( [" B: `
#include <linux/gpio.h>. ]9 H7 t" y0 m' X7 X' D
#include <linux/leds.h>
! y: q. c# g1 k; Q" P7 h#include <linux/platform_device.h>5 B7 d1 \; r& v) c( @ v% I2 U
' B* S# [7 s6 w7 q# Q) q
#include <asm/mach-types.h>$ Y$ K" U4 X4 `. @8 ?1 D& [
#include <asm/mach/arch.h>, V2 H3 g/ R$ W
#include <mach/da8xx.h>& f8 M; e7 q! v) F% h. I& X( Y
#include <mach/mux.h>, m" ?9 Z! A- x) d
Y- ~: c4 [& s: B% a8 Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( ~8 n9 l* {$ P0 D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 i X+ ?$ i5 i* C# v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 T6 q8 G1 v9 M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ w2 X* b4 B' @) ]+ A& z
4 k7 s( q7 T+ L) g; g8 L
/* assign the tl som board LED-GPIOs*/
9 N4 F# @; g: t0 \; Ystatic const short da850_evm_tl_user_led_pins[] = {8 {0 N2 M% k- o' ]
/* These pins are definition at <mach/mux.h> file */- C+ ]5 |; L1 ?' `. B: b" c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- ~$ ^5 m& Z6 M# s# J
-11 Z. X$ I! ?, M9 ~2 Y% X: Y& E' m
};
! w9 R% t y: T6 v- U
- I" Y5 s; D- @, rstatic struct gpio_led da850_evm_tl_leds[] = {( k M2 B0 m5 I; p6 P9 Z
{
5 ~% ]5 @! V+ {4 _3 h/ N) C .active_low = 0,
& e! Y1 o8 M/ x( o .gpio = DA850_USER_LED0,
; W7 V6 q# f S8 _ .name = "user_led0",
+ m+ Z N3 r# d3 b .default_trigger = "default-on",
# y- f) e* N) L: o0 [+ @- r$ P },
; E/ R3 k4 |# F& M$ W2 A {7 _' W! [: W+ Z$ n4 P
.active_low = 0,6 {4 n. x( T, o4 n; s7 [
.gpio = DA850_USER_LED1,
' d& X( t2 |+ n) S( l; a* X .name = "user_led1",
' A) J( X3 U& f) P N2 v .default_trigger = "default-on",
- r4 \! l W9 P0 K% g% D. e2 } },, T2 X, `; G# y; x' ^& \
{# i c3 n/ `$ H) u5 d
.active_low = 0,% E! B% z* t C0 m% u
.gpio = DA850_USER_LED2,
b7 _/ d, ?# n& U0 \' Y0 d# }! u; i/ W .name = "user_led2",% u! j4 G6 w( Q1 U
.default_trigger = "default-on",
5 C$ ?/ G; L+ \+ b },: ~0 {7 w# y# F& J- ?# Q7 {5 J
{
3 m8 F5 Q) f* @ h5 r/ f2 [ .active_low = 0,
; J$ k7 \$ b2 ? .gpio = DA850_USER_LED3,6 d+ s" O% V& _* T0 Y8 F3 N1 X
.name = "user_led3",
& e8 F1 E9 B# a .default_trigger = "default-on",
( c6 V3 w3 X# D& D' x },$ j1 R) e5 \$ H* m |( L2 \2 y
};
/ D( X7 Y' p1 i" r# q% F& y6 N2 c6 q+ h `% w3 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 Z0 D: U2 z- ]
.leds = da850_evm_tl_leds,
5 S$ x& H+ T/ H$ J0 k2 U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- w0 Z9 b6 Y* ~; B8 B( m) i
};! F7 b1 _7 R9 ` t
0 _) p( J8 i6 \ ]
static void led_dev_release(struct device *dev)
^+ f5 w6 l0 m) H( _, X- s) H2 |{
5 f% P0 C* ~1 d% z};
. b' Y! O0 ?5 f6 Q' C- K
! m9 W* X+ s3 q( S; Wstatic struct platform_device da850_evm_tl_leds_device = {
' `7 N' o* i1 k D$ p5 L" y$ g .name = "leds-gpio",
, R' ^8 I0 P: ? .id = 1,5 Y/ t" f$ M8 Q5 x- F V$ h
.dev = {! j% `: h" H2 L9 p
.platform_data = &da850_evm_tl_leds_pdata,
2 c- j# l6 o3 m# ^- B( |! Y .release = led_dev_release,# s$ }+ e+ b0 ]' {1 q
}
; U6 P1 Q9 M/ \& y- T4 \};
* F) H S4 x. y: j* Z$ i
- Q) U& Y9 E; b. x! X- w1 J' rstatic int __init led_platform_init(void)/ A: c t. c& t Z& g$ s: Y8 e
{
, a" i0 D0 ~8 o) {. L( Y int ret;' h4 c2 f9 g3 W \4 a. E5 Q- |
#if 0, q9 O$ ]* x# d) ?4 s# o9 A, [! J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, N3 s3 m( d2 r- f4 X if (ret)) T) Q6 f& Q; k" o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 z& }& ^ W$ k. n# N* ]0 ~ "%d\n", ret);8 Z7 l3 Q8 U* E9 w+ @
#endif$ F# m' t, V8 ? o) V/ t! n, e* |
ret = platform_device_register(&da850_evm_tl_leds_device);
, R( w# n* |0 s+ p" {7 m8 _ if (ret)
* ~2 ~; j3 I( T- J; e/ \/ D" U0 M d: y pr_warning("Could not register som GPIO expander LEDS");: ?$ O- D- L9 n$ x! U. U3 n
else& m; r: I" ?' m/ @
printk(KERN_INFO "LED register sucessful!\n");, T5 y" V3 T( S. ^3 E7 c& u
* [$ w7 I3 ~* S3 W% b return ret;
- _' C7 r8 L4 o3 X% n}
6 A) M: c( P g' c3 S, a
# k. I8 D! C0 H8 Bstatic void __exit led_platform_exit(void)
6 V8 J- `: v4 Z! v% ^{
7 t- C" T; _9 T platform_device_unregister(&da850_evm_tl_leds_device);7 }/ j! V+ q+ S, o
7 }6 Q8 N" `4 n2 P C
printk(KERN_INFO "LED unregister!\n");# v, Y% E! J8 g) r( u3 g/ R# ~
}
9 A8 f5 }, M( t3 s; q, G( F2 m% ^* M% V6 i1 v3 R1 U4 T
module_init(led_platform_init);9 g7 {. p$ j/ m) f' E5 ~
module_exit(led_platform_exit);. c7 U r: @* u( N$ u- C
, o1 h7 e) @+ {% S' }' j
MODULE_DESCRIPTION("Led platform driver");
0 A1 ]7 ^6 Z7 T! _& e3 m% p! GMODULE_AUTHOR("Tronlong");5 X; B& K' e x2 }
MODULE_LICENSE("GPL");
" O4 I' m% G% m* j8 k8 i# @
3 y7 Q" p9 x6 }3 }0 A |
|