|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( r+ z9 ?+ E6 Z+ `1 k#include <linux/init.h>+ E* s0 }/ S* j- Q: `) {
#include <linux/module.h>
8 U2 p9 B5 d$ e @; E0 a9 a* J#include <linux/kernel.h>$ t$ _9 f8 P6 J" Z) X% X9 v7 S0 w8 {
#include <linux/types.h>
2 l/ X" B! |6 i L6 q#include <linux/gpio.h>
4 f7 I6 O3 X- q8 o8 V#include <linux/leds.h>
6 p) y# n7 r0 O. P#include <linux/platform_device.h>" [. }7 M( B+ c. y
$ N" V1 T3 ?8 A* s#include <asm/mach-types.h>
* [3 j" p3 C S3 q3 P* g- w#include <asm/mach/arch.h>
$ y2 T1 [) J- v/ g#include <mach/da8xx.h>
/ x; K/ r' K' b6 W1 {4 J#include <mach/mux.h>
2 M+ E) F$ M# x) x0 c! ?$ k- N# z$ @( y9 Y1 K k; g! |2 \' U, s Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ ~/ u* y+ O! i7 O8 K- g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 X0 q7 w# L, T8 ~0 F# f7 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# i7 [0 n' l8 n% ]# }- `- T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 e# R4 i$ k' E2 `3 j! h* z3 K$ N
0 s6 J' y- h& r( m6 L5 }( G/* assign the tl som board LED-GPIOs*/" z4 t5 F5 @7 n/ f% }5 D% H9 e
static const short da850_evm_tl_user_led_pins[] = {
) b) A1 \* b) L3 D8 N /* These pins are definition at <mach/mux.h> file */
, S' p$ X, u) Y" F+ @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, M. l4 ^* b; M. Y( [* k0 m2 L- u -1' `$ i! h G" q4 L
};
& ~/ X4 _5 c5 i0 P" J: l% x. I" |5 i1 q
static struct gpio_led da850_evm_tl_leds[] = {
5 |/ c: L$ ~% X% t5 }+ @, z {
6 N* s+ r$ J& Q- p# O .active_low = 0,% r5 ?7 A4 |! e0 E
.gpio = DA850_USER_LED0,
6 E; u% H) W0 P0 n .name = "user_led0",7 l2 L- {& d6 J) w
.default_trigger = "default-on",
! O% \- m4 k4 o/ q },3 D2 ~; o5 m- a( `' A" S* W
{
5 h% X% ^0 ~% D: ?0 y; A0 A .active_low = 0,
: ^% M. B0 p) n: D .gpio = DA850_USER_LED1,2 Y# `3 y$ `+ q! D% g7 j) ]
.name = "user_led1",0 }8 }5 K9 V- k
.default_trigger = "default-on",
4 X) C8 x0 S3 l; a2 r' I },9 t' i0 }. }( A. ?. }% F* `$ ~8 C
{
# J5 E8 {8 u8 u5 w0 W x/ ? .active_low = 0,* A- ?0 Y" T1 F+ Z7 R r: X
.gpio = DA850_USER_LED2,
4 c+ r z5 G2 @8 g: @. Z0 S .name = "user_led2",! j( f/ ^. {# E$ J6 V3 C
.default_trigger = "default-on",
- ` A. Y$ b' r j/ E4 W: }9 g },3 f( F' M% [8 o+ |6 V0 H u
{
! p2 U8 N) y; D; D! k5 H .active_low = 0,
" P- e+ n; i- ]: `4 q! I3 T .gpio = DA850_USER_LED3,3 P: z' C3 ?+ {- }
.name = "user_led3",& N* x# v) g9 i- H- f4 Q, p
.default_trigger = "default-on",, K: E" B+ ?( F6 b% S
},( Q- Z Z1 N) O0 C' R
};5 _2 l# x/ o8 L: K8 N& ^6 y. d+ u
5 P0 G, t) ?* Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. T2 @0 @; N8 ?0 {- z* g1 L
.leds = da850_evm_tl_leds,
8 L# h. G' j N8 n, P6 a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" t7 ]( w9 J. }" q9 N3 Z};" r) l( z8 k5 q1 K' @
2 k( _. G" @3 ]0 w* _& g
static void led_dev_release(struct device *dev)
7 z+ w; O' u0 W( J% M8 X{
+ k H: D6 _ C7 k0 y2 r6 k};
6 L) _5 n; Z7 {6 O9 L
+ I6 x7 M6 Q; S& k3 R q! |1 Ustatic struct platform_device da850_evm_tl_leds_device = {* H+ Q. _6 ^3 l# m, n# g: c. [
.name = "leds-gpio",
. z# W2 S1 X0 o: G/ Y- v+ I; t* p4 ], f+ E .id = 1,* {9 a/ R- K `( R6 Q1 A5 b
.dev = {
" E3 L i9 @ W% R% ]2 V0 o( D! I/ P .platform_data = &da850_evm_tl_leds_pdata,$ q- F' v$ ^1 ]5 l* k
.release = led_dev_release,
/ C6 P! D7 J) O; d: B# f9 L }
; P {0 C9 }7 M};
, e6 I! G7 G0 E( A* P" r3 V$ H) {# M- P0 m" U4 t6 j8 ]
static int __init led_platform_init(void)4 `! G$ u5 [. I; a7 d7 b9 T6 }
{& _% M* r |; E$ M9 @# D- t
int ret;; \0 V4 J/ u* X) ?- e: i- a
#if 0
+ `, W ]. ]4 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
] V( _: A/ t& q if (ret)5 S0 I6 u/ t4 C& T$ N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 x' _) l2 m: r. C6 ~ "%d\n", ret);' J/ L! u$ c2 w1 x+ @
#endif, _7 y5 p) d( J/ r" u' B8 |
ret = platform_device_register(&da850_evm_tl_leds_device);
8 Q7 t& U) d, P; K. j$ }! d$ J+ X if (ret)
& e0 X' i Z( O ~6 d* H pr_warning("Could not register som GPIO expander LEDS");1 o9 O: G0 t6 K. d# K, e
else
( Y' f9 Q9 ]6 x# x) W printk(KERN_INFO "LED register sucessful!\n");0 A% m: @6 Q# M2 \3 q" G& K" P8 s
) R7 I' ^/ X2 A L2 D9 o5 j
return ret;
' q+ X3 \- e! W7 c. J& ~1 D}
* ]7 g* V, D* e8 P& w; m s) D2 C9 @$ E' j5 N8 U
static void __exit led_platform_exit(void)% B; V3 j7 m7 h. o* |
{
# a, [4 k. z4 j4 K0 Y( I& I0 e platform_device_unregister(&da850_evm_tl_leds_device);
7 g( u; w5 ~7 e; W0 C) R4 N) Q7 T5 y/ C- M
printk(KERN_INFO "LED unregister!\n");
) p" J# T; P, |; @/ c* U9 D3 J( a; Y}
; r1 V1 g$ a% v8 W0 g# V1 @# m' n( N7 z* ^& M. h
module_init(led_platform_init);; I; A- P- Q- x; o7 D3 x' _
module_exit(led_platform_exit);
1 f/ E$ Z! n9 k o8 J! q2 v
6 P' ~9 U6 ], V `! l0 B, aMODULE_DESCRIPTION("Led platform driver");
- A! L# T$ e8 [1 Q ?% bMODULE_AUTHOR("Tronlong"); `0 p! v. @, R2 ^; X' a6 w
MODULE_LICENSE("GPL"); y6 N/ O3 k5 n2 |; [
& n0 i! g9 Y! R3 C% H& T' q |
|