|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ I& b. b$ \; {( {7 P/ b1 W
#include <linux/init.h>- z+ t; Y( k! H' o, c3 s
#include <linux/module.h>: j% W! K, Y; O' Y; v9 F+ w
#include <linux/kernel.h>: p- P3 j8 F" R3 \) @( B
#include <linux/types.h>% C) P. }; U% `2 m
#include <linux/gpio.h>( }: `& N5 m& c3 I1 D" E
#include <linux/leds.h>
; R1 v3 V5 J0 e8 `8 B#include <linux/platform_device.h> x+ ~. L5 I. _! D X# {( W
$ E# p" V' Q( S0 w4 g
#include <asm/mach-types.h>
9 W5 e3 R" ~* A: g#include <asm/mach/arch.h>/ Q8 w. H F5 `. w# \! n) l5 X1 Q
#include <mach/da8xx.h>9 W' Y5 H. i3 F4 u. E
#include <mach/mux.h>2 r: |; C9 x. t5 H
* s% P$ Q; {. s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& x; X( E5 U4 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 {* i' i( b2 [% q7 b* _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 x0 \& P% W; u/ w" F2 S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- `$ e( e2 Q) C: `2 ~
' ?) F" o. F0 f/* assign the tl som board LED-GPIOs*/* ? H* n- L9 j& F, z0 t; A
static const short da850_evm_tl_user_led_pins[] = {, m& x o K# H; O9 x9 ]
/* These pins are definition at <mach/mux.h> file */
. d- e6 }) w7 M; U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 g" \' ]1 \: o+ Q: e
-1
: f; y7 e0 r1 `};3 e: y _5 ]8 k; ]: Z3 H
2 u( Q$ \# `+ a1 \static struct gpio_led da850_evm_tl_leds[] = {
' M. V) N+ v8 c' w l {
8 S6 B! Z$ J; {8 W! B3 t; Q! Q .active_low = 0,
) [, ^, _" j7 _$ J .gpio = DA850_USER_LED0,
5 u" W6 X- j% v& ]+ D .name = "user_led0",
7 Z3 J9 C' I$ E `" n8 T .default_trigger = "default-on",' F \8 E" e$ g2 Z
},* [% w3 o; g6 Y
{
2 [; @) I# S/ I+ R4 j% J .active_low = 0,. e) s% m2 c* V( O) @
.gpio = DA850_USER_LED1,9 a5 A' q$ e- c" U$ U
.name = "user_led1",
& m6 S* C4 Q m& K2 ^0 T p g .default_trigger = "default-on",
' k! U9 j w% f# X6 C },$ L4 P7 b+ v- u0 u" |: x$ G
{. @7 C/ a* e2 F1 E- J
.active_low = 0,( u( O |; c8 J \1 B
.gpio = DA850_USER_LED2,6 c- p/ |9 e# g! V3 P& \: n9 G
.name = "user_led2",# |1 [' s9 X4 C) b9 s9 l$ D' |
.default_trigger = "default-on",
" j5 T& I6 K& {% ~) { },& s- z' z, v4 b5 `" ^: a
{2 ^9 b0 A, i# W2 X' A5 ]
.active_low = 0,
# C+ i+ @& Y# E( U .gpio = DA850_USER_LED3,
( {$ B% ^! c8 B% E .name = "user_led3",
) D7 s$ R+ L8 G2 u .default_trigger = "default-on",5 { c! t( d6 p" w2 U
},
0 l' |9 ^6 @ a8 P! Z9 J2 c" Z};
/ }' y- q z7 @' v6 ~9 C$ q1 J( o% U# \7 N, m; g A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; J4 N3 q( l. p) q3 w3 F9 S .leds = da850_evm_tl_leds,5 D5 F/ S! T: w4 }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( \" h! h- P8 M}; f( k0 u2 Q, j: S2 R$ z U
5 R5 f+ W9 r0 u; b" v3 {6 h$ ]
static void led_dev_release(struct device *dev)+ U& O8 O3 L% X2 x* x4 J2 @' [. K
{+ U* ^3 W6 t9 \9 q- w
};. ~# y o9 L* N1 I6 m+ C% {- A
) W7 C% [% `0 |& p( G
static struct platform_device da850_evm_tl_leds_device = {
$ [+ Z& l. b. r2 } .name = "leds-gpio",0 H6 _! n6 l d* @/ x, Y
.id = 1,6 u! z; g' x& v1 g- ^
.dev = {
5 @8 X1 {$ \5 ~1 r! D/ F .platform_data = &da850_evm_tl_leds_pdata,7 J# B+ S: ]% f; ^8 C; Y. r
.release = led_dev_release," i) J Q+ @" X6 G! x
}
& d- f! \! i9 k8 |) ^};8 [5 H& s: X6 Z" n+ t8 T
8 ^8 v7 z5 H& }3 Lstatic int __init led_platform_init(void)
/ k; p- B H+ v; X# N/ v{
5 E3 N y( U- s6 q8 x# V int ret;. o2 f! X0 L% A7 D
#if 0
* B9 Z6 D7 u4 H! T. o0 [1 f+ H5 u; E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- M1 U3 i6 w' O; Q& B. ^
if (ret): F) N- A/ d2 \" z _ b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 g* F$ {- c1 U. {9 ^
"%d\n", ret);
% i, ^8 J* ]' @( ~9 q: R# j#endif9 @! H* H+ n- M, Q2 ^
ret = platform_device_register(&da850_evm_tl_leds_device);
% K: t+ X2 Q. E8 N- }) s9 Z/ n6 p5 a if (ret)
# Z( w) d1 _! }# @$ e' P0 x pr_warning("Could not register som GPIO expander LEDS");4 n8 J2 b; j" R- \9 |4 b' H! E6 b, H
else- j( J9 i8 j: d" K6 V1 Z2 T* l2 s
printk(KERN_INFO "LED register sucessful!\n");
[; Z: ]# W7 [5 H
' l1 f0 Y! ^# q t return ret;9 `2 M; b3 m! ^, ^; h
}, B# s j+ }5 f7 b9 w' D
0 l l! L- M/ U% N) b4 @
static void __exit led_platform_exit(void)
6 C$ \1 `0 W% X. I, I{2 P8 P1 d1 B! U' K
platform_device_unregister(&da850_evm_tl_leds_device);* B6 ]" [& s& Q& M4 F6 l. m! i
8 n( `3 \5 X4 o' G/ P printk(KERN_INFO "LED unregister!\n");
* ^7 \. `: b8 O8 h}
/ k( a( d: i# ^: G' I6 o7 l
4 r# t0 w- Z9 ^' c& J# {' v% \module_init(led_platform_init);- L* i% |7 [% z3 L+ G
module_exit(led_platform_exit);
* N' i% b) |. p' {' p5 `2 t8 T1 {
MODULE_DESCRIPTION("Led platform driver");& V# E V3 Q& d% R7 D* R
MODULE_AUTHOR("Tronlong");
2 a* B/ t+ K$ A1 C$ P ^5 w* kMODULE_LICENSE("GPL");
% T3 j0 F9 A" L, U( n2 Z$ d+ Y7 K6 d( k
|
|