|
求大神给下面的程序做注解,请稍详细些,谢谢。/ e+ u9 l# I, K3 |- K3 E
#include <linux/init.h>/ N2 l: H; o6 |% w6 o8 h9 t, o
#include <linux/module.h>6 \! @# _* y* J
#include <linux/kernel.h>: s" y6 {# C1 f& _
#include <linux/types.h>
( O0 ~8 x# y: L0 k% {#include <linux/gpio.h>' [. R6 A4 e5 h" J+ n
#include <linux/leds.h>
/ q! y5 o& K9 \" s; k! M1 A5 R5 { `. {#include <linux/platform_device.h>
. _2 U h7 O0 [' d8 a5 L7 g1 a' D8 Y
4 H7 X0 L6 t$ k+ J9 q5 b#include <asm/mach-types.h>
) i8 U( Y K# }+ e" M. g#include <asm/mach/arch.h>
9 }1 X9 Z6 X( x4 K# T#include <mach/da8xx.h>6 ~8 Y$ c k V3 j" ~
#include <mach/mux.h>: K7 v1 v: u; y: `
$ I7 `' _+ ]: m" V0 g1 z- i0 @) N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 D5 I6 {# A+ r4 k$ y/ O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 r3 u& Y* g) W- d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) k2 Z/ G/ q: w& g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! |( C$ ~+ o' V z( e8 B! O
2 u5 e# w( n$ C9 E" `$ K, K
/* assign the tl som board LED-GPIOs*/
2 C$ p0 h5 i* `' X) N" Gstatic const short da850_evm_tl_user_led_pins[] = {
' y8 C; o8 }. f" e7 j /* These pins are definition at <mach/mux.h> file */8 @7 Y) S+ ?# W- k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 R" c. K% y# z* D7 J) q7 x! C3 {3 c -1
! {8 r: h( y+ w& p};' g. m* f. ?& `, Q' ^
0 T% ?1 {$ Y5 I# @6 O( Q$ q bstatic struct gpio_led da850_evm_tl_leds[] = {) }" P: H" {+ a8 e! J2 r
{
0 M0 m' t- t/ F/ L& u1 a5 D .active_low = 0,2 H- U$ l1 z0 K8 o4 R5 a
.gpio = DA850_USER_LED0,2 S. l" U: g' m8 a7 z4 l" Q5 r
.name = "user_led0",. r# C. q$ n$ O4 m- J; `, C; \8 @
.default_trigger = "default-on",
. u0 k# d' h3 {- Z# [4 t },$ j' x- F* u' Q; r
{- g1 _' b$ x% x& w4 O. @& V& i
.active_low = 0,4 f* L6 J: |! ?" p5 A! f% e
.gpio = DA850_USER_LED1,$ u( _* O, g! r0 c: s& Y3 Y. A
.name = "user_led1",
, f+ M& A- m" v4 c, }$ L# i( [ .default_trigger = "default-on",
6 m# L* n7 s# g8 u$ _, w1 u },
: b& }2 l$ O. Z. c: B6 ] {
% H% y$ Z* p/ |3 d# u: ?0 p. N+ o .active_low = 0,8 O( G% a5 ?8 f: K
.gpio = DA850_USER_LED2,8 y' G& A( t5 ^, i( h" l
.name = "user_led2",4 @9 y6 h4 J2 ^ S$ n
.default_trigger = "default-on",
. D( l$ \7 Z% A. g" v9 y4 R },+ W& c- r6 f$ { O
{$ Y }+ P2 S. w# p* \
.active_low = 0,( D$ w5 D, s& C! ?9 n4 P
.gpio = DA850_USER_LED3,
2 G: A& |; u) q4 d .name = "user_led3",8 \3 @4 Z: d0 o7 S
.default_trigger = "default-on",; q. u+ m2 p0 R8 ~" e. V/ Q6 Y
},
7 k6 P( d2 P4 z7 D- u( F) P};
2 A& s! e7 I: x, c% Z6 a. I4 H* a
( v5 g: U/ x$ ?( q+ G9 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# G& c& g0 a, V
.leds = da850_evm_tl_leds,' p- Y& m% i3 g5 i8 Y5 m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; c; Q, n3 s# g; G: T" ^};! q5 C' P. I/ `
" D. R* i) y! O/ zstatic void led_dev_release(struct device *dev)
+ w! v& C8 N+ M2 x: Z{& \' ~8 k. ^2 D& Q
};
$ G& u, L/ M4 Q6 s' C( t( g
/ E U- A* w4 \static struct platform_device da850_evm_tl_leds_device = {* }$ Q: z2 o8 X7 `" @
.name = "leds-gpio",& h4 d+ v8 c2 W: n9 E" c
.id = 1,& R( z( N9 i- {6 R2 |1 D, F: Q
.dev = {7 x' F! C$ J1 k8 Z% @
.platform_data = &da850_evm_tl_leds_pdata,
, a: L( [( L# I) E1 x8 R6 y3 u .release = led_dev_release,. n6 [" n- P. n6 X
}7 V2 {% W& t8 c# }8 [) y8 D7 @
};. C1 O3 l2 x: A& \" U. w( i2 f
) N- ~1 f. A+ B8 E2 f1 astatic int __init led_platform_init(void)* C7 r/ i; x+ n5 B! s0 n$ a' M
{
4 F6 l3 d$ W2 g, H r0 c int ret;
% e# v! ^4 @6 {#if 0
& V" q2 U' G9 z' Q7 t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* ~3 |: D& }7 T5 C6 v if (ret)9 t( u7 I h; f( e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! l0 g5 z+ y& c "%d\n", ret);: k* G5 H& L$ |7 @( \# T9 ^
#endif
! _$ K, `0 p0 u1 H ret = platform_device_register(&da850_evm_tl_leds_device);
: L+ T8 p' Q' c. w% Z5 [. O4 @) q' Z if (ret)7 K( j; s! r; N, o$ V3 Q
pr_warning("Could not register som GPIO expander LEDS");
1 M: x2 R( F- t g9 V+ o else _( n* e5 b: I( z; h, B
printk(KERN_INFO "LED register sucessful!\n");
$ {. g, Y( R# |8 v3 U2 F6 J
5 l( x$ ~ e1 x8 l# R. K2 o6 a- `! l return ret;4 Y) u+ S& W X' k" t
}/ T" q2 u* D# h x* u1 ^1 I
7 N" K: y, v; l: Nstatic void __exit led_platform_exit(void)
+ [) H! u/ Y# H1 h2 N{; e8 U) g, U8 o3 d7 [+ Q
platform_device_unregister(&da850_evm_tl_leds_device);
' W" s1 w0 S2 p* ^5 ?) d
7 Z9 }0 q9 F/ s# K1 r. r printk(KERN_INFO "LED unregister!\n");
% y2 F" k t4 b/ @}
% K4 M& a' l' Q0 X: q) m! V4 G6 ]0 o4 e( N' l2 _1 A: C1 x1 Z z
module_init(led_platform_init);2 [7 F4 U, K3 ^% A
module_exit(led_platform_exit);
$ k' j, i" c/ Z t% s# P; I9 h1 p @
b2 d- W! {& F! ]6 R3 vMODULE_DESCRIPTION("Led platform driver");1 F9 l4 S% b6 N% {/ Z% V- J5 i8 ?
MODULE_AUTHOR("Tronlong");
" e( I& ]# x# F. vMODULE_LICENSE("GPL");6 i: s- |# ~3 V. V5 B( N5 ^1 M3 ^3 c
/ y( O2 V) U! e8 n
|
|