|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 c* C) i3 y3 @: q$ \1 v+ D
#include <linux/init.h>! m! B8 [+ s' D( G0 n
#include <linux/module.h>
% C4 x( N; ~: L#include <linux/kernel.h>
$ u5 Q- l. w) E' C#include <linux/types.h>) j# v3 Q3 n4 h1 k2 X
#include <linux/gpio.h>
) D& G2 _9 W7 y4 J* \& Q#include <linux/leds.h>) x# o. t6 N8 N/ x* b
#include <linux/platform_device.h>' Z( N* X9 P# i
' T; D9 F. H7 ~3 @
#include <asm/mach-types.h>
! s8 W8 [- ^* W' e% x# ~#include <asm/mach/arch.h>& B. I2 ~, |3 Q5 K# \
#include <mach/da8xx.h>
& M1 `. n. H- A7 w5 s#include <mach/mux.h>
1 ^3 @8 y/ @' h- I: w6 o5 i* {5 g& V n: r' y4 J6 I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 L( E# n9 W; m7 n* q9 A1 M, g. ]3 I; B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 X9 ]/ @9 T) Z( V8 R* K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). `: o% F- G7 J$ L/ R6 x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 K* P1 K7 E. Q) N
/ C2 `2 W m% ?2 L. Z- ]! `8 M/* assign the tl som board LED-GPIOs*/5 {0 X u! [! [" c( `5 T- W
static const short da850_evm_tl_user_led_pins[] = {
" m: ?5 ^$ A! E* Q /* These pins are definition at <mach/mux.h> file */
0 s ?+ z7 N9 V1 Q: y3 [8 x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 A8 i" a* e4 c6 ~1 G) D5 X7 f -1
7 b: k' |/ y. N4 _ Y: [};& ]/ @* i" R9 V2 x% m: l& X- B7 Y
5 V3 z. x8 w" [. @: M; C$ b
static struct gpio_led da850_evm_tl_leds[] = {
, Q; `( b# J% }5 v/ a0 y/ R( _ { `' g7 W0 `8 `9 L0 }' v% W
.active_low = 0,
3 d1 s) @( d5 r8 b+ Z/ n .gpio = DA850_USER_LED0,2 W* i# k9 a/ n% }, b( _9 S
.name = "user_led0",
+ I' F- F0 I/ ^. w .default_trigger = "default-on",
+ `( L+ x4 n) w2 A; j },
# H: b/ a; u3 e7 p; h r {6 u V, D8 p5 L9 Z2 R; H* X
.active_low = 0,3 l5 X5 r* p4 H Z$ K( a, w
.gpio = DA850_USER_LED1,4 l h; }) ~! M n& t
.name = "user_led1"," E3 N& y/ E$ n( b
.default_trigger = "default-on",
' R1 A% |& P3 h2 U5 `5 p1 A },' f# E( C; n2 o9 o/ _, ~- W
{& {& F# A7 ?9 V+ x
.active_low = 0,
+ i0 `' `! u8 F! m/ v .gpio = DA850_USER_LED2,
, f; g; x3 n$ }+ i$ n .name = "user_led2",
( I5 a1 Q7 S2 W" z .default_trigger = "default-on",
, a& I8 j1 H6 p( l },
! k" ?, E' o: a% u/ {1 c7 i {, I" `6 Z- C5 k- x; B
.active_low = 0,
# U. b% [) g$ X' M( {# x! D! F' N .gpio = DA850_USER_LED3,
8 }# X! {' N' \: ?) B. i" q' b; T$ F .name = "user_led3",
C3 b& f2 r4 ]0 X% T .default_trigger = "default-on",/ y. s3 ]3 [- s
},
5 [; Y, [& L; Y; [) C- H};
) e9 z* }6 N! |7 y# R* V
9 W$ W4 y/ r& k: Z( fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ q R6 ?% S S7 j. H% K" X
.leds = da850_evm_tl_leds,+ [# ]% C' _0 l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ E2 z# P# ^/ @3 J; k};
/ S H9 ~- m- K7 n( n0 m" H7 a9 d7 m0 R) h- e! Z
static void led_dev_release(struct device *dev)
+ d6 [& C, o( `9 X1 K{
+ _* D4 i2 {( f4 y9 m};
( T' I3 Y5 W5 c7 O, Y2 u u: Y8 H: f6 d; I; c: `
static struct platform_device da850_evm_tl_leds_device = {
0 t4 v- o9 ~ Y2 z .name = "leds-gpio",
8 ^& P. `( w3 y; S9 f8 ^: c' c8 n1 A .id = 1,
' O# d. b7 Y+ A8 f .dev = {
- ]' O8 `9 `, H .platform_data = &da850_evm_tl_leds_pdata," s5 t3 `6 F0 w& q
.release = led_dev_release,, A* C3 ]: P- o5 F- |# o
}' ~$ m- k; |+ B( i
};) C0 G0 M6 j% [ V
" a1 B/ W2 I6 b Z6 Kstatic int __init led_platform_init(void)5 e1 D9 n, y. C) n
{, I3 K2 D$ O& s* v1 d5 u. ^
int ret;
4 {! _3 c, J3 s; z+ U$ w#if 0( V0 B7 P6 o7 G B' r7 f9 R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, P8 |+ w9 |; E. L if (ret)
: |" }( Q0 K2 ?8 l2 ]+ g pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; \. @) T- B1 k* e( ?
"%d\n", ret);
' }; c' ^5 i# U0 ]% Z) k* N4 x#endif
4 ^- J' w9 ?. e ret = platform_device_register(&da850_evm_tl_leds_device);
: _ i0 ^( b3 ^# w. O if (ret)
. ?# p* w. ?9 I pr_warning("Could not register som GPIO expander LEDS");3 B3 v& }/ @ t6 \5 `
else/ m$ A/ C6 V4 U0 Q
printk(KERN_INFO "LED register sucessful!\n");
( g; D% U; u8 W/ G# i" L' R& l# m
return ret;
. x5 e$ S; R- P) z9 ` z}
, t: |+ S2 {% u
! ~( a% }$ g- E# G) R* mstatic void __exit led_platform_exit(void)
6 n T5 O' e; ^{
# `- ]) c# M9 ?1 G* s" a platform_device_unregister(&da850_evm_tl_leds_device);
8 d! X% s3 ~4 z( l v1 j- {0 Z& `5 L8 k
printk(KERN_INFO "LED unregister!\n");
+ X; V- m1 k& Y: F2 g% Z}; A4 K+ Y2 Y& K
2 d3 z+ L6 g* ~# Zmodule_init(led_platform_init);
: \) ~! I3 Z( e+ V( }4 _" v5 kmodule_exit(led_platform_exit);* ]/ m8 B0 A5 p2 E% t6 o6 e
; c$ v0 z# W6 L d9 S
MODULE_DESCRIPTION("Led platform driver");
0 U5 k2 _4 s0 ?% _3 WMODULE_AUTHOR("Tronlong");! ]( ?$ H# i$ S* V$ z5 r; _
MODULE_LICENSE("GPL");1 x% t" d, g! m( l/ l1 h* \
, `5 _* H, \" Z& l+ i# X |
|