|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
]5 F# m& h9 w9 L( ^& W7 @#include <linux/init.h>
( E# U( Q5 v+ q6 Z% X#include <linux/module.h>& A9 D& G2 G% r3 y9 |
#include <linux/kernel.h>
6 t' e' S$ s% k( ~) q9 p#include <linux/types.h>) t& j# k, ?0 I9 f" ?8 U
#include <linux/gpio.h> b) o6 C" M' w- M
#include <linux/leds.h>/ H2 J4 h' }8 f2 ]7 m
#include <linux/platform_device.h>6 A& O3 w( j& z$ w
$ l9 P# H% U1 o) D#include <asm/mach-types.h>
9 N. x) H2 S+ V9 E+ L2 V2 { }#include <asm/mach/arch.h>
) G! ]3 ?% g& ^4 j#include <mach/da8xx.h>" W: }9 r+ {! Y9 a
#include <mach/mux.h>! q9 V5 ?! v- W& `
$ N( i3 x6 H3 {1 y' n j8 d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& \4 T, d' {. [5 X3 c" V! P: [5 X, D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& i5 U/ T1 L- A2 w' Q f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 a3 g5 P" ~7 h" }; h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" Y5 Z$ ~, k2 D8 x6 e& }( G- F
6 O$ \0 |! v* z8 N/* assign the tl som board LED-GPIOs*/, C" _/ X1 l7 @8 R/ }7 r
static const short da850_evm_tl_user_led_pins[] = {
! q4 A# T2 Z, ?$ o6 N3 t /* These pins are definition at <mach/mux.h> file */) k7 C2 A% n3 _8 k _, `5 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) l' z$ Y3 @: _! o' V7 y -1$ q7 F6 }% x. d4 t; e
};2 g# g) u( g% ]; V
5 m, p; D; {3 s3 V3 K2 x4 ?+ s s+ istatic struct gpio_led da850_evm_tl_leds[] = {0 [: _0 }9 t% ~9 q2 p8 Q
{5 S! s8 ~' D3 D+ @3 d$ t+ l
.active_low = 0,- }& E( C0 C# L) h# u8 g) o
.gpio = DA850_USER_LED0,
$ h0 E% T6 C0 d$ I' D& \ .name = "user_led0",; j* R! p* z9 w* P$ p M4 C
.default_trigger = "default-on",
1 P% r* J- ]* h. E! l },
2 j8 f% ?( O' S7 F+ N! H) N( L [ {
/ c, _" t3 w- f" f( q' s5 h! n" } .active_low = 0,/ C! K" b3 t5 ]7 e/ z
.gpio = DA850_USER_LED1,
+ M4 j, Q5 s3 Z' f .name = "user_led1",& |# T. D" G5 T' V" s7 f3 y
.default_trigger = "default-on",) K' I# x- F; V" T
},
+ z$ ^% \: T% ]1 f7 k) u {
/ w$ Z0 _1 c- B7 v .active_low = 0,6 K$ J/ V# D1 u2 n
.gpio = DA850_USER_LED2,4 H# }8 l' U0 ^* Y2 H9 }
.name = "user_led2",6 I; ?( U. ^2 L* y. ]3 g7 b
.default_trigger = "default-on",
" S& f% T( j. O1 h+ G& B& w },( \: `5 o/ }, H4 ?
{$ f3 K6 J% }0 O5 ?+ Q% L& E
.active_low = 0,% L# B! ^* L( `8 @! n+ _. }: R
.gpio = DA850_USER_LED3,
( h1 F* {" Q3 H+ k: V+ o# T6 h .name = "user_led3",8 ~$ d8 M4 i: M2 z p
.default_trigger = "default-on",
?* @5 u( w# L },# e: [9 Q' R' B( D g. z6 L
};
0 D5 ~# R/ o4 L0 Q( g
8 J9 X8 Q, J6 h' W# |$ L6 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" ]$ o# I. j% ]) N. T$ C+ u. z .leds = da850_evm_tl_leds,
7 Q' n! p8 |, u( [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ r% _% n, }. z! D* L: J% p};
) G' _& {( }: t! E9 f. a
! k0 }' u: N# O5 F* _9 astatic void led_dev_release(struct device *dev)
6 S; G) v9 k' C) ]{
, J8 J7 M; J* g2 H: V; e; g};0 J& o+ J7 y, ~7 K( A
) t4 N Z8 Y1 V4 M9 _
static struct platform_device da850_evm_tl_leds_device = {2 p# h. Q) _2 [* s5 r5 x8 A* w
.name = "leds-gpio",. k" s5 D: r" y
.id = 1,
9 f9 y, ]5 f; [4 ]0 V% I8 H .dev = {0 O7 v/ P B! o" W! p# r! i
.platform_data = &da850_evm_tl_leds_pdata,
- f3 @' `0 w; E7 T+ t .release = led_dev_release,
7 o1 p I, ^& p$ `' ^0 i }( k/ M7 G$ v3 A% r6 n9 c* L
};
$ N3 O9 y# O y# x2 O3 T" J3 G+ n+ F2 K
static int __init led_platform_init(void)9 { {7 F7 n) r
{
0 f: V2 {0 w8 U0 P7 Z int ret;
* {4 t+ T4 T. ?. ~#if 0
8 ^# T: c. y& \! M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# L, H' @( m6 O1 ^% M: W6 x if (ret)# }' `# Q) g( {0 w/ Z2 N+ Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) N x; S2 z: c J% H "%d\n", ret);
' s7 g% h9 L# `8 ~% Y#endif
/ [& U& S, M8 m5 X ret = platform_device_register(&da850_evm_tl_leds_device);
+ h3 a. \3 r& R W. S6 L if (ret)3 O H3 W/ g# u: x( J5 g
pr_warning("Could not register som GPIO expander LEDS");
; C% h2 f$ Y' p } else
; t- k3 g$ R& k% V$ V( g printk(KERN_INFO "LED register sucessful!\n");3 y5 H+ H& Y' {$ u$ ^
( b/ n+ T' T# f9 [6 j, U
return ret;
( ?1 Q& ?# g: }# u2 n, P# l L}
0 ]$ w3 y- h% s$ B! b
& B. ?# D# K) V) w- K' S- Vstatic void __exit led_platform_exit(void)8 _+ l0 J) g- ~$ @% M% L
{( W0 j$ c: `% ?& l* J
platform_device_unregister(&da850_evm_tl_leds_device);
3 Y% k6 h/ {1 |& S
" n3 s7 v8 S7 ` printk(KERN_INFO "LED unregister!\n");
0 t# I0 b6 C" J- R+ a8 [}
& V' h& r& u1 e+ f. ^8 o. _
( t1 N0 h" I0 k3 Z2 mmodule_init(led_platform_init);' \9 A% y. Z1 e; n" P
module_exit(led_platform_exit);9 M4 r* O6 j3 ^3 p. S2 X. e
! B3 K6 S" d4 kMODULE_DESCRIPTION("Led platform driver");( M3 M) e3 |) Y
MODULE_AUTHOR("Tronlong");
% C* ]) e$ B. {MODULE_LICENSE("GPL");: q; P4 |+ W( }9 U+ l) U
4 z# N+ S( @% N9 R
|
|