|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. ?4 e5 w! D6 f. r. T#include <linux/init.h>
7 Q5 s( K. t5 g#include <linux/module.h>
7 w5 ]& w9 k# T, U/ H5 k#include <linux/kernel.h>
$ j' L* c# @6 `# P) n7 [#include <linux/types.h>( p" W$ @1 U7 H& o7 Y& k
#include <linux/gpio.h>
* B% @% |3 g' @$ [/ s/ Y#include <linux/leds.h>
' K Z L/ U S) o5 e#include <linux/platform_device.h>
2 z8 o2 z7 y0 J- d6 s
7 i0 C7 F* M! k% o#include <asm/mach-types.h>
+ g/ V* w$ \! a#include <asm/mach/arch.h>
9 g; J- {% O% b% I#include <mach/da8xx.h>
; O3 j3 D+ [$ _/ s4 }' Z#include <mach/mux.h>; B' i# h' o* q0 W/ X% I3 n1 c
+ n) L# U: i- J- K0 u) |4 v; g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) N! v* [% Q! l: N5 m# V6 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ m5 A. l+ _1 i% a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, H- g$ Q, p+ h% |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# b* y1 I$ T& k# A8 c# O
) d3 h# ?$ ^) l: j9 a# P* m8 }" P4 }
/* assign the tl som board LED-GPIOs*/3 s: |7 |; d' |) K" x" o, ^" }% R
static const short da850_evm_tl_user_led_pins[] = {
, }" M/ ^. R7 q: _) W /* These pins are definition at <mach/mux.h> file */
6 K0 D2 h3 ]! i2 R2 y- C1 _7 _1 { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: d; q" R4 W- k- ^7 e" L
-1
# Z' q, L3 A* }: C! k& I" J; c};8 c5 i/ ]/ D5 `: V7 t" s
) j& N4 D7 z. ]# X: O% Wstatic struct gpio_led da850_evm_tl_leds[] = {
+ r+ O( ]" G4 b/ x9 y7 w" t% M {) u7 j8 u; h% O$ P4 \6 b
.active_low = 0,
; k; q/ ~. d4 b0 U) c0 u .gpio = DA850_USER_LED0,
& y& V" B/ c6 U .name = "user_led0",3 B( }6 |2 g# u0 P* s- S/ h! o d8 H
.default_trigger = "default-on",
+ j2 R1 ]: p" U j) [ },* @, q/ |6 U% y8 A4 B5 e# G: i
{
6 b B& a& f5 [2 V3 K8 i .active_low = 0,
B3 m( Q- m/ j( ~ s$ \ .gpio = DA850_USER_LED1,
1 _( m+ }# m5 x% t/ L1 E .name = "user_led1",6 K1 L6 W0 A0 ^% ?0 W7 I: l
.default_trigger = "default-on",5 J, ~7 k0 w; N5 u2 r
},
" s3 Y8 H. [+ s# a7 l) _ {
; R' w. M& C/ H* u3 i .active_low = 0,
6 u6 h% ?5 Q; F" ~/ w .gpio = DA850_USER_LED2,# `4 D( P# i Z6 O1 w
.name = "user_led2",
) r( P' P3 _( O! s/ v1 F/ [* D" u .default_trigger = "default-on",
/ r& P. V! c8 ~; N3 R: p: { },
2 @3 e5 J) m$ g' l5 y( H {
* p5 T+ k6 k: |) |. m/ X* u) ^5 Y .active_low = 0,
1 f3 J0 k" Z, N" q .gpio = DA850_USER_LED3,$ B; f7 l* I8 y( W- K8 @7 d! u' O
.name = "user_led3",* q3 V& e. e* x
.default_trigger = "default-on",
" q& E" ^! N* C5 M( h0 E },4 J- S7 C. o6 v' F
};( U9 D$ A1 g* {
9 A% m/ ]0 B! }" p, ?+ l; p Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 {: _4 q2 G2 a
.leds = da850_evm_tl_leds,' `" O. q/ M5 V
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; W9 m+ o) c9 }0 u};
( I3 F' X: K0 m3 k, ~- C$ x4 D! K6 ]6 y! r9 _0 Z6 H
static void led_dev_release(struct device *dev)
5 ^* w/ @9 ^* } s* [{
2 @# D& [+ |% H3 H};
; Y1 e7 k9 U3 K) r1 h! r" L' n6 [
static struct platform_device da850_evm_tl_leds_device = {
u3 X- b- ]0 _0 s/ j: O, R0 J9 T .name = "leds-gpio",# P, F% v! D- y9 I
.id = 1,
a' d1 I. F4 }3 R5 u7 ` .dev = {0 f6 Z. b2 @- }
.platform_data = &da850_evm_tl_leds_pdata,! R1 C V5 k' l
.release = led_dev_release,' l8 x. ?- d i( J
}
- Y! } B& M# g u1 H4 b1 Q2 Z};
4 F- L; l2 [- _& C) T0 D) o! [6 N0 X( s- G6 {1 }* {( _1 y0 }
static int __init led_platform_init(void)
& A2 C4 C$ r, C. u- ]. f: ~{ R: U$ x! }8 j/ h/ H' {# c( p& N
int ret;
" C' |3 I8 B& r2 {#if 0
3 I* y. Q2 d# r: w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ w. f0 X& O) y$ ~9 H- x' i if (ret)# X. Y$ |: x2 U6 c: U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 M2 u! R6 l7 [3 m: T
"%d\n", ret);8 K5 T. r, t8 Z. Y- h
#endif& ?; ?7 O7 a5 ~( y( w
ret = platform_device_register(&da850_evm_tl_leds_device);0 s7 U% H1 \9 v3 w2 w1 n
if (ret)
4 G( R7 C1 Z' j pr_warning("Could not register som GPIO expander LEDS");
' S+ B8 i) b) R- ` else4 c" [. g7 a$ j! [" a6 T r* u
printk(KERN_INFO "LED register sucessful!\n");
8 h$ ]4 y! y: f* |% `! J- f/ f6 |3 I4 ]/ H( \+ B# V
return ret;1 g; G9 |$ F! c, C+ Y2 u
}
4 s4 K( p# g2 Q `% t# o% L- \; [. l/ }1 o+ H4 c4 I
static void __exit led_platform_exit(void); K2 S$ j5 {6 ^3 M
{
' E! j; C: ~0 f- c( N# r% k( l: V platform_device_unregister(&da850_evm_tl_leds_device);# s2 l. R# w$ u+ e- B6 N
& p l6 v l& F
printk(KERN_INFO "LED unregister!\n");3 B# E' O: j/ a, \/ x
}* O S4 S; W, i, m
& T+ T% r2 J+ qmodule_init(led_platform_init);* j d" G! r9 B# k* v' f
module_exit(led_platform_exit);
- d6 i9 l) y" h; O7 F& ^3 u% O
MODULE_DESCRIPTION("Led platform driver");
, t7 w2 @5 Q5 _ ?1 w b' qMODULE_AUTHOR("Tronlong");* R! F( J4 M0 T4 s- J
MODULE_LICENSE("GPL");" q6 F; W; u* b# I
@ ]& B2 f/ }- y# k
|
|