|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* w# }7 H) E0 E& Q. [#include <linux/init.h>1 d* R, l0 q7 a. }& I3 D4 P/ B
#include <linux/module.h>" y2 w- M& n1 m* m$ P: Q1 ^
#include <linux/kernel.h>
3 R1 t! g, t, R j: s$ p#include <linux/types.h>
: D0 G5 k/ E5 K& g X0 g p#include <linux/gpio.h>9 Y+ _; I& o& o2 { e( a2 [1 P* I
#include <linux/leds.h>
" J6 J; U+ v( `#include <linux/platform_device.h>
2 S. l7 s0 D# c* B
( R$ K5 ~7 o7 d#include <asm/mach-types.h># L( k$ r- B7 ~7 k( I
#include <asm/mach/arch.h>! Y7 C$ f/ \3 ~$ ?; u
#include <mach/da8xx.h>$ a7 F1 k! l9 t0 M
#include <mach/mux.h>& Z2 S# u( c' L% k
1 [- ~ v/ T2 p6 \) t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 W% ]& h, n% M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 W& D Z% `/ @. k/ f7 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): P/ \! W+ a- _7 W& c8 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' [, {; U1 A/ p, [# {' Z8 {! l8 k
% k* W @' T. z4 _/* assign the tl som board LED-GPIOs*/9 U% E5 h% Y4 K; q6 C4 |
static const short da850_evm_tl_user_led_pins[] = {1 I* b& c: O- K) K! ]: q
/* These pins are definition at <mach/mux.h> file */7 v. G+ ^1 S0 K9 c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! L2 a! O/ u1 Q) k( i9 y8 Z' m
-1# p+ G) U$ v3 ^. R6 h, g# J
};
% n" P, S, `. F% E/ j
1 O# v% E' `. c; z& fstatic struct gpio_led da850_evm_tl_leds[] = {2 ~! `5 U+ F+ i3 U
{
: Y0 m, |: p8 h T$ c: t8 ~ .active_low = 0," P, \/ _' a- U r0 x5 ]2 p
.gpio = DA850_USER_LED0,
$ G* G# Y; T# e* N4 ^ .name = "user_led0",5 Z/ D9 N0 I1 I1 d) O
.default_trigger = "default-on",
; C9 V. f: E; w3 ]: H1 B! V },1 S. p- F7 O C5 ^/ j
{8 z% v: X+ Z& f! A" ]. I2 z
.active_low = 0,8 o ?0 e" x$ j O* U t, x
.gpio = DA850_USER_LED1,0 ~/ ~0 A. T. A P9 w1 X
.name = "user_led1",
5 H0 F/ d9 s8 t% Q+ H" K& | .default_trigger = "default-on",
* {# B( v5 ^1 A6 i5 r' E ? },( L$ \' X( s/ Y7 g
{
, F) N/ A4 Z6 `' U* R* U .active_low = 0,7 j; U7 W w' c: d; R
.gpio = DA850_USER_LED2,$ W g' P- z0 ~ J9 O8 c' \
.name = "user_led2",1 U! _+ B, i; B4 R
.default_trigger = "default-on",! p- E; F( t+ E
},) F6 A" N7 d( G, _9 `
{
( [ p) {/ j* c4 ? .active_low = 0,
; _2 }/ s3 k0 j1 y u .gpio = DA850_USER_LED3,; @ w& N3 Y) g9 L! K, d0 w+ I4 x
.name = "user_led3",, f2 c8 \( I; [# g! S, T( V
.default_trigger = "default-on",
, p, l D# ?" c- R* S6 d* a* T },3 P$ }8 f- J/ {5 S
};( T, E. O- ^4 Y7 \
! X& G- X3 n6 n3 u3 J/ `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ c- Q$ ~9 W+ Q" U5 }7 i% K .leds = da850_evm_tl_leds,
' b0 v% z k$ q, `" ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 S4 E7 m. G$ F" d) E0 y3 I8 L};
! ~" {- o5 |, }* t( K: _1 \% y! y
static void led_dev_release(struct device *dev)6 R9 p3 {* r7 Z0 `) z3 n
{
1 S8 K, I$ N! M( i};
4 k4 I! T$ w6 b- R3 e# R
& J9 Z; J0 Z0 e! Y4 fstatic struct platform_device da850_evm_tl_leds_device = {
! b# ?2 S5 x Y- w3 I8 N .name = "leds-gpio",& j$ ]. X6 r: L$ ?
.id = 1,$ c6 F" Q$ J: ~' P; ^0 v! D4 T
.dev = {! x! V1 P2 ~ {4 d2 `* i! m+ @6 J
.platform_data = &da850_evm_tl_leds_pdata,
% {( O4 C5 G+ |" \ .release = led_dev_release,7 d8 l1 V# k. |0 |* P$ W7 R
}$ R" E/ b0 q# b( s& q" y9 h
};5 V1 U; K9 ~2 e- m3 g6 S0 M2 i
' h8 ~5 {" t4 L, b
static int __init led_platform_init(void)5 _0 m* T2 v4 m5 D* S
{
4 u1 g* C r- [) K8 n( v( ~ int ret;% E4 A L2 u" T; f- e
#if 0" Q. s8 o6 S# X( h, u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; F+ _2 q( V4 R4 R4 n
if (ret)' q5 x/ D- u/ _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. h7 h# Y5 R0 V7 k "%d\n", ret);
5 q. t, C+ X# x6 ?#endif+ j+ Q5 l. a/ o; {
ret = platform_device_register(&da850_evm_tl_leds_device);
0 D* T0 a) o( Z if (ret)( C/ F- f5 k0 }; S5 r
pr_warning("Could not register som GPIO expander LEDS");# j+ I0 l9 C( y& n9 ?) ]/ ?
else
/ J, @* H' O8 ?0 X printk(KERN_INFO "LED register sucessful!\n");" T( g: u, H( ~! E8 }9 x
8 }$ j9 c$ z+ q: s return ret;
& [: ?8 K% p, U}% o. }* U' Z+ @; [+ V' A! O
. \4 ]( c6 `9 X
static void __exit led_platform_exit(void)1 l/ ]% D! F( B
{
# N1 a( t+ d$ f ]0 y platform_device_unregister(&da850_evm_tl_leds_device);
( n$ b. R2 {- \% ?7 N& y$ w4 K. h' g# ?+ \" ~0 F
printk(KERN_INFO "LED unregister!\n");/ ], l9 k: d7 U3 I, G2 ?- ?
}: |0 A2 J# \. O
. S& i/ n! R" u1 T! u; W% p" lmodule_init(led_platform_init);
) u& {- p5 g7 h9 p8 z1 i2 |6 Ymodule_exit(led_platform_exit);( v6 W, H/ D# b0 U1 b, I
) e( H6 U# G1 Y& P6 d. I, [) gMODULE_DESCRIPTION("Led platform driver");$ I* k! a3 L- _ u7 M# p
MODULE_AUTHOR("Tronlong");
; o5 m m# }# ? v2 A. \MODULE_LICENSE("GPL");' z3 f8 z: ^9 A0 e1 e
! w7 s9 {+ W c$ J! J |
|