|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' P, m0 o; S% F0 r+ y- ?" ^#include <linux/init.h>
5 ^. M& m2 D+ `#include <linux/module.h>
d7 L9 X7 Q( I# x0 P% F#include <linux/kernel.h>
: h4 K, R3 W: t/ k5 D+ J# r; S. S#include <linux/types.h>
! e6 t4 h0 Y' ]/ i. e/ ~#include <linux/gpio.h>) W9 r9 U) g0 U. `6 ]! N
#include <linux/leds.h>' c- S! t( W# Z P
#include <linux/platform_device.h>
! f5 C4 t& x/ y8 a5 O6 [) P; H* f/ r' u! o4 k3 s3 u i+ U# w; u
#include <asm/mach-types.h>( X4 Z1 l. W6 l1 Y! m
#include <asm/mach/arch.h>( X8 g% R+ e8 S# s
#include <mach/da8xx.h> ^8 m% A4 W ~% b0 \2 H1 R# O1 x
#include <mach/mux.h>
C7 T3 e) { V* R/ h
0 [3 W3 `' S& Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- Y8 S0 P& c+ t& k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), Z3 r! ^- {1 i" A/ ^4 e: {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# F. W/ Z6 p3 h, q. N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; m' x# l9 X+ A Q
, j/ _; d# L5 K' q1 d* F/* assign the tl som board LED-GPIOs*/1 Q. a3 F, n" i8 _: A
static const short da850_evm_tl_user_led_pins[] = {
4 H0 P0 W$ \9 C* N9 d% r /* These pins are definition at <mach/mux.h> file */
( G9 Z( G0 s6 D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% p3 a1 A' S; `6 G; f+ T4 G# }9 ] -1. W. W. u& P% A. A. {9 }
};; M5 q E0 y% x2 I
, n+ S) D7 t& z# h0 R0 ?6 p! `static struct gpio_led da850_evm_tl_leds[] = {
: \; n1 \8 S! t' Q {# Y2 q$ w5 a" M# @ F
.active_low = 0,$ Q' b; I, ~* ?" a/ L
.gpio = DA850_USER_LED0,' @, |: T/ n; N; {. p4 a
.name = "user_led0",5 r3 X, I$ I* v
.default_trigger = "default-on",
3 R/ G) G+ X! j0 V; v. e5 q1 e },
2 F+ I; {6 D- _7 }! [ {2 H! u; a! r {
.active_low = 0,
. U8 S! E& L* m2 v .gpio = DA850_USER_LED1,
+ S, d( S7 s- g0 t .name = "user_led1",
5 d, ?, H4 y( h) S .default_trigger = "default-on",, j5 Z, {6 m u% S% l
},
# |+ s! S7 P9 D {- _' w. K4 e! j" U
.active_low = 0,
( O. ]7 ]# \; P& k, I .gpio = DA850_USER_LED2,
# v8 @+ H( f$ T) ?" x/ l2 { .name = "user_led2"," @. @2 M; v% \6 F5 i
.default_trigger = "default-on",3 c5 c [, M& y
},
7 p+ f5 J8 }) q9 @ {
! j3 Y: ?$ n0 o. n6 z0 _ .active_low = 0,
. }7 n# D% ?( g- s, _; D8 ^ .gpio = DA850_USER_LED3,
$ T5 F0 a% _0 |( L .name = "user_led3",
t- c, X- k2 C2 G7 } .default_trigger = "default-on",
% t7 ?3 y, Q9 k6 Q ?5 J1 S },1 g( D* \! Z' \
};
" O2 w$ T# u0 O# l
2 ]* ]6 R- L( pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 @ `- f; }: g! j .leds = da850_evm_tl_leds,
3 \+ v$ k! Q+ e1 ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, s C5 L" f7 W
};8 A1 [6 r. L0 O8 H1 K2 R) G M
$ k) }% P( ]" @) s, L8 O) Kstatic void led_dev_release(struct device *dev)
3 U" F/ J/ v M9 Q! O{
) q7 K* r. D! G" k+ ?8 \+ j};
+ `% X( w9 n9 [( A) g" L7 K& N, J7 q1 T3 {+ U
static struct platform_device da850_evm_tl_leds_device = {
% S' Q: M- w" @! _. `/ @! l .name = "leds-gpio",
5 J W; M# @3 Y& Q .id = 1,
& v- C5 `$ m1 s0 m* {# x- _ .dev = {: R" S% C5 Q$ ~9 ? j' [
.platform_data = &da850_evm_tl_leds_pdata,
, J1 ^, V/ Q& o1 u) A1 j .release = led_dev_release,. n1 z6 O9 z$ }! `! ~$ u. e. R
}# v( t! R* h$ B
};7 ^( P% U$ G4 y* n9 |
7 h3 g+ m0 B- F) b' m) C; ostatic int __init led_platform_init(void): W9 m" ]) j4 W! t8 u9 _5 D
{
$ ^' a: o, R" v" u. y int ret;- q) U7 p) S3 m- q5 o
#if 0, c; m; j$ {: a; j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 A1 s) O7 c" { if (ret)
1 o; `+ I5 a3 y3 x A5 W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ f+ h v; { o& t5 J8 _
"%d\n", ret);
* A5 r# l/ ?/ ^) y5 Y& k0 m0 {#endif
: f L& k4 Z6 O* p- ^+ r) [2 h ret = platform_device_register(&da850_evm_tl_leds_device);# E. L/ n, q0 k
if (ret), R5 K1 Z5 A. h4 h
pr_warning("Could not register som GPIO expander LEDS");
6 X5 G9 ~" {2 g V; z0 \+ Q- u/ a* W8 h else8 y/ m( O' B: G2 M' b3 W, d
printk(KERN_INFO "LED register sucessful!\n");" d* Q& O. ?0 B* B* ?. Y
/ \8 o7 n, ^( q' e2 t9 D return ret;
: S# I8 i' @, F4 P}+ D. b3 l4 g" U2 }
* s# j" a' ^, T9 Z
static void __exit led_platform_exit(void)# z& r3 ~: O, l' |$ }
{
4 ~2 p: X& Z" E% c/ h, a platform_device_unregister(&da850_evm_tl_leds_device);; k% J+ V: `. G2 a9 n4 j* r& K" [
, o4 L2 K$ V0 J U6 {8 G printk(KERN_INFO "LED unregister!\n");, S: l& s( y( Y/ _
}7 G! D6 ^% b& A6 z/ |& i a, G
- l8 G1 ?. D: E Kmodule_init(led_platform_init);+ F1 B9 Z ^" A5 r5 {
module_exit(led_platform_exit);) |: j: J1 k5 `) G0 x, {
3 D3 M7 F" B* [MODULE_DESCRIPTION("Led platform driver");+ \- Z. B6 G/ e0 u# x0 |1 ], \: V
MODULE_AUTHOR("Tronlong");" b( o2 r8 P9 r3 r K
MODULE_LICENSE("GPL");* T2 H) r4 K4 h) B' P& V
* i7 I( j) f+ i
|
|