|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 [7 a0 C5 p5 q2 H6 F% A
#include <linux/init.h>+ x2 X6 R/ Y' s% W, ~
#include <linux/module.h>+ X/ W+ i. e% F! E! x0 x& |
#include <linux/kernel.h>
: e2 t9 C9 b' b- e+ j/ C: h% o#include <linux/types.h>
, F- \$ x& ]% g6 W! J#include <linux/gpio.h>
D1 y% L7 p8 ^/ n#include <linux/leds.h>
' F/ ]: w( w2 g! p L#include <linux/platform_device.h>
* l1 e( M( T- f" X
% \7 K; t; W$ N0 S) G, A) L1 j k# U#include <asm/mach-types.h>' O! A0 C+ b5 @- f, m! k* J+ |
#include <asm/mach/arch.h>
; ~8 Z" j8 v4 T" V' M' t& B$ X3 ^8 `#include <mach/da8xx.h>
7 ^+ i6 `5 M/ P8 z3 `3 V0 K# E#include <mach/mux.h>& e+ [5 A7 A1 N4 _
8 u, b. i9 y0 L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# }/ m6 g' w3 p# y1 l7 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) L* Q0 `# z" J5 K* M$ c5 U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), S) K5 J* x# @7 X4 ?, O! g0 Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); Q$ \1 i# |8 r3 F- G
1 V6 ]2 ~% K$ B; {0 t" n
/* assign the tl som board LED-GPIOs*/
9 E- k& k7 `3 S+ ?3 z3 u: {+ Nstatic const short da850_evm_tl_user_led_pins[] = {
4 W" R, X/ H& ] /* These pins are definition at <mach/mux.h> file */
& H" ^3 r9 \" p, j9 T DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 X6 ^/ r% p3 n7 W4 m, H/ y* _2 Z/ ]7 w9 I -1% ^2 z7 R4 k M# e: b% B" h7 y4 Y0 q
};* R. m% T2 D" k* O
_0 e6 R+ c; Q ystatic struct gpio_led da850_evm_tl_leds[] = {
1 I0 F ?6 _ s {
6 w" h# n A' Q" c .active_low = 0,
: T+ p9 p$ C: C! K& ~ .gpio = DA850_USER_LED0,
/ s Y2 Q: U5 M; ?0 b .name = "user_led0",
* l" Q8 N; D4 i S6 G .default_trigger = "default-on",! i) q4 j; D2 P; D0 F* t2 ?2 [. _
},. Y* O" S1 e+ Q2 ]+ K0 f
{$ j8 C5 f. m! |' s ~0 N) v
.active_low = 0,! E4 k- q& f1 n) T* k+ r, Q
.gpio = DA850_USER_LED1,
2 H" X+ x6 `; x2 a .name = "user_led1",( i$ p a- E- D
.default_trigger = "default-on",; R. a. | j' p$ O! P
},
E) x U7 B& f: \5 x5 ` {7 R Z# E: k$ s' e& W Z/ j
.active_low = 0,2 H/ y) n) Z; C, t: V
.gpio = DA850_USER_LED2,3 A- V1 h: E' A) L+ \
.name = "user_led2",
0 ?8 W6 Z$ R& _- x$ L0 L .default_trigger = "default-on",5 t* U1 p! e2 E$ N
},
9 T/ v1 O3 Q1 A1 E {
; G+ h3 F& G' T2 I' a .active_low = 0,5 o& O6 L# X% \7 s
.gpio = DA850_USER_LED3,$ T- Y* D9 j W4 y3 p9 H1 j# g! i
.name = "user_led3",
! g# t, R. t9 _$ w .default_trigger = "default-on",
& V- y- @# V4 A9 ^3 k, D- ?3 K },
, X8 X7 n+ w2 ]& R+ K' z* N};2 w4 v* x' |' g6 N; U$ x t
: ~ G3 p, U6 m: p2 t n( ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. V4 C: X8 \* u, x7 V .leds = da850_evm_tl_leds,* P2 h" [- Q) H( l- W8 i. _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- w# ?8 ~! d* Z* A8 t, I
};
/ C- U9 S3 c$ s8 `+ Y: D, d- T$ b
) H* m# y# T o2 L( L4 T6 mstatic void led_dev_release(struct device *dev)6 f v9 w7 J9 F) t+ z2 b# w
{
: ~! K" b2 R; `) @) N8 H% j3 F0 C};
2 a3 F9 B# T9 g A# S
! U N3 j0 g7 J' b! estatic struct platform_device da850_evm_tl_leds_device = {
# K/ c' L9 M Z$ `$ m- X .name = "leds-gpio",0 v3 |; R( `8 ^4 _
.id = 1,
7 ?, K% \ A9 E) s7 [ .dev = {; A1 g& h. a' X
.platform_data = &da850_evm_tl_leds_pdata,
- z' ^$ M/ ~$ Y. ~2 W4 Z# q+ h .release = led_dev_release,
, ]* Q& p( M* o' U$ Z) G }6 B% v0 r. i, H4 |( K' o2 e0 u
};. I1 }1 ]" K: w! X! h( K! b; c) w
$ C$ L- ]% S* t" r& Sstatic int __init led_platform_init(void)
( ]1 R$ X3 P6 f% O( c{
% S& X" k7 ^& _% f- Y h int ret;
/ k" [, B7 L" |$ X#if 0
3 M; Y$ S0 k& m0 i7 Q& M5 K2 j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 L- u* F+ k2 t: n3 r0 C% p
if (ret)
6 r# f* L6 @/ ^8 {5 z* K) n: b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- p7 V4 l4 P9 C+ d" [6 Y" U* J "%d\n", ret);# g7 J3 I7 ^: ]! V) m( d- J
#endif
, @! L5 L! H: g6 ^: l5 c0 u ret = platform_device_register(&da850_evm_tl_leds_device);
5 t: Y v2 k C: |/ S! o5 v if (ret)6 W: k& ~, c% D, h
pr_warning("Could not register som GPIO expander LEDS");2 |9 q, m. r, @2 W
else1 i( O) Q+ J3 i: ^. Q& B
printk(KERN_INFO "LED register sucessful!\n");
) v/ ]! ~* {) R* `( z9 T
; [8 |" X6 c' g return ret;# I4 s/ D/ ]2 S. b; e
}* E" _' w5 o6 {" _& |
i1 e8 b- O5 Tstatic void __exit led_platform_exit(void)
+ |" w! n5 ]( ]) e& K{" F' l# K8 @) A( k' ]5 H% ?
platform_device_unregister(&da850_evm_tl_leds_device);! w# h- u J& c) Q# b! R6 Y+ S$ V; Z5 O e
" H0 [6 S Q/ ~2 S0 ^0 C X printk(KERN_INFO "LED unregister!\n");$ `: W# {- M( u% C: y, {. j
}) H) N2 u! d; w) i/ H/ @$ M7 a
6 B0 Q/ f" w2 A) Zmodule_init(led_platform_init);! ?5 c; P2 M$ T! ~
module_exit(led_platform_exit);
$ T1 {; u8 _6 a0 U. X3 J$ S' ]1 g* K4 T
MODULE_DESCRIPTION("Led platform driver");
6 ~& p) O& F- q+ b# I2 l9 c/ NMODULE_AUTHOR("Tronlong");- \; Y3 G% q8 O& H
MODULE_LICENSE("GPL");8 w. Q) q; }1 M- ^3 S
4 F/ X5 w- D, q/ o |
|