|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( }4 g3 m+ ~( p
#include <linux/init.h>2 [* A0 O, x5 L4 i, ]/ o0 G2 P, ]! R0 @
#include <linux/module.h>
( F7 q" o& b7 B% W#include <linux/kernel.h>5 Y8 M1 q6 G. t4 E8 X: h
#include <linux/types.h>! u( \' x8 N# i! E+ q7 U% u
#include <linux/gpio.h>
3 P) z1 X4 f8 D+ j; v) Q#include <linux/leds.h>1 a9 R4 H7 h! v1 i/ s! m
#include <linux/platform_device.h>2 B0 K# R0 L8 x0 B
9 W* a0 _3 i9 S2 y Z8 W9 y#include <asm/mach-types.h>, ?; Z6 q* a+ g9 w" K4 v& ^+ g3 t
#include <asm/mach/arch.h>
! e6 v4 I9 V U" ~2 `#include <mach/da8xx.h>: \. }* H- u$ ^6 A4 Q# L; I
#include <mach/mux.h>/ L' w5 T/ _, H/ m# E
5 B: m m* H+ M1 N) d2 [* _/ C/ u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& W) P% L- V& c3 L. g( t1 ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) f8 T- a! o; |+ {# ^( Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 g7 F4 a! Y6 f( Y- g$ C) O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 P( s1 K' T- \# v$ v; o/ {' @6 L
$ U: V T1 @% ]+ M/ |) |9 f/* assign the tl som board LED-GPIOs*/1 t" M v2 [, x
static const short da850_evm_tl_user_led_pins[] = {
9 c1 `1 U1 S! i8 t /* These pins are definition at <mach/mux.h> file */
$ ?5 t% g' H U) ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 |# M6 G4 v" e, I# ~3 k+ u3 m
-1$ @0 M; S: K4 V0 [+ ^/ K4 O
};9 K3 w: b/ Y8 g" g
9 j/ P' P5 z# |! u2 ~- j8 L! T5 C
static struct gpio_led da850_evm_tl_leds[] = {
) h: ?3 e( q+ U1 M7 `* u+ ` @ {4 ^' ~2 @6 d( @" L* Z# p
.active_low = 0,
i! v& r3 g, k, \ .gpio = DA850_USER_LED0,3 W; w, I" q4 z
.name = "user_led0"," ^8 [9 n; z- G" s' z* ~1 m
.default_trigger = "default-on",
" B# L* D- `+ R },
. v6 o0 M v! { {( s2 c) h* V' p" l5 d
.active_low = 0,
0 w* _$ g( Q4 {( C- G! o .gpio = DA850_USER_LED1, J: _& g5 ^9 D0 y( H
.name = "user_led1",
+ f" N2 h: X; A0 e+ ?8 |% a .default_trigger = "default-on",
1 I N9 V6 E& u" d6 r% z0 Q: R },
% |( a5 M( p; d C: ~% W0 b {
% G& K# l5 G# n: i3 e0 J& i4 t .active_low = 0,
& j# ~4 ?# s$ Y% G4 I .gpio = DA850_USER_LED2,! `+ L- L9 e* s6 M! a1 ]6 A: z
.name = "user_led2",6 w: O; q0 S7 w8 Q5 F Y2 C3 z% S
.default_trigger = "default-on",7 K; s( |4 _: B4 {/ C
},
* K2 e! s# A' b- \- F1 V {
- d2 t* G! t! ? .active_low = 0,. R1 l8 m! D1 A, R. n
.gpio = DA850_USER_LED3,
5 J5 E- X& q0 F) q; u .name = "user_led3",; L r l& [) Q7 K) i
.default_trigger = "default-on",
9 F( R( S* L# l$ f },
) r2 r/ x2 X) p8 q; D/ j% W; G};0 H( N- L1 k' \' t7 Y
% F! y6 q- A! `! B7 `7 }: u6 d9 ~7 Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ O# s/ M, K3 u% _
.leds = da850_evm_tl_leds,
( B1 c8 v5 T$ n# q- n1 H; e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 R& H( p9 J9 l6 x$ ^3 S
};* J; J2 |+ q& {
( Z! X& r; N0 z3 j# F4 istatic void led_dev_release(struct device *dev). T% L& e& ~% ~7 ?3 ?# h. p( u& L
{
D0 q5 I1 @! l" {: O};
' V7 Z2 D7 t/ }, T$ G
0 B; e/ {9 B+ h S2 ~' k, ], ?4 Pstatic struct platform_device da850_evm_tl_leds_device = {& k; p# \% @: R5 u
.name = "leds-gpio",) f. y: X. `) E4 M
.id = 1,
2 s" e- v2 x" _% z& o .dev = {
7 [0 s Y, o Z) b1 S .platform_data = &da850_evm_tl_leds_pdata,4 z: @9 w! S" {( T0 J1 `
.release = led_dev_release,
& r3 S' }) s y }
# f: v8 k; n5 |9 m5 U9 Z};! x( x8 @1 f6 U. n
! S6 P' r0 P' T e, o2 f
static int __init led_platform_init(void)
/ V" G& S2 C% n6 T{, |" e9 K1 F$ U
int ret;+ {" O8 S( c" w! X9 a: M3 N
#if 0/ \, p1 i5 g, M: L: l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* Y4 R- Z$ ` ?3 }, K if (ret)
1 f- A( }, l0 D, t7 o6 } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" B ^0 u# R$ d6 Z- C4 u
"%d\n", ret);
8 f# V% p( L' G% v6 C#endif
9 C" G6 _0 d, j [* |+ q ret = platform_device_register(&da850_evm_tl_leds_device);/ q( @& `' W/ o0 C5 G' }3 C* k1 T
if (ret)! l$ h. Z1 n5 K* {2 T/ a; g' y0 ]
pr_warning("Could not register som GPIO expander LEDS");
& f4 ]6 O' U: H- C8 v/ { else, z( Y3 C* ?5 k& Q" u$ A
printk(KERN_INFO "LED register sucessful!\n"); O( Z+ l# ]2 \* S: K+ \) f
6 {! }6 y* X3 `. v3 |6 g6 u @ return ret; W+ j! R' e% N& j# Z
}% {+ _# q; n; m& z
; ~7 ~' {9 W0 i
static void __exit led_platform_exit(void)/ u& v4 I. ]7 Q0 ^* ]* {
{! V4 |6 {' u7 a2 \+ ?
platform_device_unregister(&da850_evm_tl_leds_device);
, y7 g; s' ~& k& a! K( Y0 B2 s- B6 a" l2 V2 n
printk(KERN_INFO "LED unregister!\n");
T# D: Z2 A7 l( `: p/ t9 g" x5 p}
8 C) A3 m5 ?( Z% H# }" u/ r, h( _& H
& ^6 Z1 o1 u# e5 _module_init(led_platform_init);
- u' Q' J% k" Z" M/ bmodule_exit(led_platform_exit);
7 Q# i% C9 {: C: K9 o% x
1 ]/ ?; g$ P6 Y- w: |9 y4 WMODULE_DESCRIPTION("Led platform driver");8 C9 a6 F2 u+ x- _. b: z- W, i
MODULE_AUTHOR("Tronlong");& c) j- q! d) `0 J" B( q! L
MODULE_LICENSE("GPL");
j( S3 u$ t# P; B h1 B* L ^2 _, R- p' q A o& B
|
|