|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) Z" p/ p% Z, d# K) h! {% ^
#include <linux/init.h>" W2 t9 f8 T6 M# N
#include <linux/module.h>
) K9 D% I/ W3 c- G#include <linux/kernel.h>& ~6 A. [0 i. f- V3 ?# g# W* d5 |
#include <linux/types.h>& A& R9 q( v; h0 [* I
#include <linux/gpio.h># R2 B1 ^8 [ N+ H; c
#include <linux/leds.h>7 n5 I; T+ v9 m0 U% I
#include <linux/platform_device.h>
4 k' u/ \! ^8 x' w
0 M d- ^) h+ _& ~* c/ O#include <asm/mach-types.h>
3 W" H. A' C. a4 I% s! d, p/ x#include <asm/mach/arch.h>! l% C) i/ D7 R: L# j
#include <mach/da8xx.h> P: Q! l0 ?$ h: Q4 W/ Z0 D
#include <mach/mux.h>
& C/ S8 o! Z% P5 }! V2 [3 d8 K2 Y5 J5 y: K6 C r, h0 d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 @3 p# o6 J$ R$ H) c0 y8 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* k0 {, q9 J$ S6 `, x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 b- C2 |# y. L# F4 k! q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 L3 |' ^6 D' U" b2 i* d/ |
8 {& O& U" U$ G( C+ W
/* assign the tl som board LED-GPIOs*/3 D/ [# y4 v# b" R: F9 q6 m
static const short da850_evm_tl_user_led_pins[] = {
/ T! ^& g/ W, j7 U9 f+ P) S# h /* These pins are definition at <mach/mux.h> file */, y7 f5 Z" x9 Z: w/ R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. j+ A7 [8 ^& G: [. R3 X! w -1
) Z! y( I3 y, T0 L z E) x. m: E% o};
6 S2 c& f( y# p& ~) r2 p$ m4 E8 f( O, m+ I/ l/ V
static struct gpio_led da850_evm_tl_leds[] = {! G/ B- ?! i) b+ u5 Z
{' N7 |) ^% n2 [, s' ?* M
.active_low = 0," b- m+ S2 A% D- G" |# Y/ g. Q
.gpio = DA850_USER_LED0,
& f% E: l5 x j/ y .name = "user_led0",7 ?2 L! X0 R# ]/ U5 M1 G
.default_trigger = "default-on",
9 r' r- ?" W2 ~4 S },
d3 y; g7 _; e K+ p: d {0 M- _9 S* c$ u
.active_low = 0,/ u% g7 z' \* M9 z/ a0 c! G
.gpio = DA850_USER_LED1,
# c) }: E, W" k2 v( e" w .name = "user_led1",
& o: K. [, V4 g3 B .default_trigger = "default-on",
8 L/ p$ X; k [ R" L8 H7 F6 Q. G },
* w& Z# J A$ B4 ] {1 Z _8 v$ H4 _8 U3 i
.active_low = 0,+ H) ~' T: J4 [8 V% s, ?" C
.gpio = DA850_USER_LED2,: W( s5 }. p4 H3 ?
.name = "user_led2",
1 d5 |- O, n1 Z; V% q0 ]) W+ K A0 r .default_trigger = "default-on",1 |! p5 G3 W S+ \9 V
},
, y' v( R& D _, } {/ ~& m" O* [" X
.active_low = 0,
4 f3 [( [( S7 n& e2 p0 m .gpio = DA850_USER_LED3,
8 A' b6 _/ V8 n% Q .name = "user_led3",
$ N& x! ~; S5 o7 }" Q3 h! A( _ .default_trigger = "default-on",. n g$ [" e8 b# Y+ T9 A
},1 L) q! l$ v/ I
};/ {3 {+ c" P- b6 T3 ^
: P1 x2 R4 u' N6 Q% f7 y. H7 d4 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. \! Y6 g$ c9 W) ] .leds = da850_evm_tl_leds,
* D) O& r6 _1 j4 Q# ~* M4 {" S* ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ Y/ e- Z0 B- K};
5 j. [3 r+ i3 `9 X! g) w
7 ?# x+ y0 L9 I# Ystatic void led_dev_release(struct device *dev)1 e# f& }5 {' j
{
! J# N" c. E* W- d. P: J};: \1 Q2 R" H3 o' l+ W; i( K6 @2 r
, S$ y% S) M9 O! sstatic struct platform_device da850_evm_tl_leds_device = {
1 {. r6 W9 \' B& I .name = "leds-gpio",
. p. Q% i; v2 i4 x( [% t- [& T .id = 1,9 A7 ~! J" W- h- l
.dev = {" B. B' K/ q; x2 ]3 z* q5 I/ ]: P
.platform_data = &da850_evm_tl_leds_pdata,
$ z( e' E7 B# w8 I% a5 _ .release = led_dev_release,
* o6 S( w {) x% j }
7 b' c- }, g( V0 U8 N! _};
3 a% O7 ?. k5 k2 H% D9 {' n5 Y. v6 D: e/ P8 X
static int __init led_platform_init(void)
; l# Q( A+ q r* u( }{
, Q8 o D2 D, z int ret;$ O$ w! z7 u" a* d5 ^
#if 0
3 [) Q7 c+ M* X; |! S+ u5 A& a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 r; L# V7 w7 S. @/ C, o if (ret)
2 J8 ~/ c2 U" B! Q. [! s2 R8 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ j7 p y* a {
"%d\n", ret);
8 n9 J; |, |$ p1 _4 P# R5 h$ ^#endif8 r9 ? l3 ^# W7 t |2 v
ret = platform_device_register(&da850_evm_tl_leds_device);
. M. `" O3 Y. r7 U* V if (ret)8 r/ u* J, [: s8 m X
pr_warning("Could not register som GPIO expander LEDS");
5 T* W3 Y( s7 z$ l3 b2 O4 ]& y" d else8 O- g- {+ z1 C, g7 `% p
printk(KERN_INFO "LED register sucessful!\n");0 f1 p* @8 y! [" @; ?0 t1 I& r
* [' a4 ~3 @: b3 Q8 K) k, e% j% j
return ret;
: S. m; [1 w" \! H}, M6 l/ s! M1 W; ?2 Z
2 `+ W% ?+ t+ U/ J/ f# T$ k; o/ Pstatic void __exit led_platform_exit(void) z- j2 n2 i2 g0 k
{. E y9 G" w; Z3 \
platform_device_unregister(&da850_evm_tl_leds_device);! u$ Q4 G; b1 @. c; w/ P( D
, ^! L2 O" m {8 I% a printk(KERN_INFO "LED unregister!\n");. ?1 N7 n4 x7 S: N8 k$ Z
}4 u+ L" Y% {$ Y2 \" b( K
7 m4 U* Y3 W( Bmodule_init(led_platform_init);% h4 ` I, o% @2 K# ]' f
module_exit(led_platform_exit);
; b( @8 u2 l8 u, z0 U/ ^$ Y2 ]% `# [5 w3 ^- U7 D) R8 Y: ^+ L2 ~ N
MODULE_DESCRIPTION("Led platform driver");
7 e, ?+ i( l: F/ g4 dMODULE_AUTHOR("Tronlong");9 i' U6 r7 i' @7 o0 B
MODULE_LICENSE("GPL");& F3 L4 g2 a' x' Q4 N! h
, m/ k4 \9 `8 I
|
|