|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 g ^8 t1 ?9 i; j* O! @8 \#include <linux/init.h>* s$ l7 i0 h, ]. i% C! a. v
#include <linux/module.h>
0 y9 o n9 ]7 b+ v0 ?% {#include <linux/kernel.h>2 g0 H+ J ^$ @" w/ A1 G4 D k4 K
#include <linux/types.h>; L5 E9 r# Y( I$ I2 F+ G& P
#include <linux/gpio.h>
% F: z; ~: Y; @7 n `#include <linux/leds.h>
" A3 U! v3 N, ?0 E% m: ?: z#include <linux/platform_device.h>1 \: z! D( Y0 X; y9 ^) K$ m9 ]
' y: j1 w9 K/ I: N: {& C#include <asm/mach-types.h>
8 I& \8 J* X* b6 w#include <asm/mach/arch.h>4 g0 _- p5 _: I+ k
#include <mach/da8xx.h>
' N$ k8 b) y' U2 p; n8 P. f, ` O* o#include <mach/mux.h>7 f; i! C6 L& z: u) R! P6 f; Y
$ A' w% ]7 }7 [) c2 l1 E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 d, ^3 p) B- V9 U3 w: V. ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ F4 {- S( L6 U1 N& B! c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ I+ k! b, ^/ P% H* o. ~ x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' b) u; m7 z2 v8 m- w$ \" S' d! @; `& @" c; I& u7 {1 Q! z- e
/* assign the tl som board LED-GPIOs*/
& ^- x$ o3 A; Tstatic const short da850_evm_tl_user_led_pins[] = {) h) ^0 s5 I6 f$ Z' Q
/* These pins are definition at <mach/mux.h> file */2 d& F: D, n+ R C% V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ J1 l' k% |8 g4 r -1- g6 `; _- L' z* `( N2 l/ k: J
};8 V1 k# D) \4 d. V3 z& H% N
* ~: G3 W t1 j* \
static struct gpio_led da850_evm_tl_leds[] = {+ Y; V" P& I- O7 s! u) {
{
; |+ Y7 h4 a/ M .active_low = 0,7 Z3 \( N2 J+ N$ `. ^& I
.gpio = DA850_USER_LED0,' h, k. z) m) M& ?9 }
.name = "user_led0",! C( v ~ E2 S+ k! D
.default_trigger = "default-on"," x. R. Z: g% \. {' E
},& o" Z! r3 h& U) s- @
{/ k9 T+ h% K- k/ h
.active_low = 0,
6 z4 J- O- @; P" `% w" J# _ .gpio = DA850_USER_LED1,7 c8 l) w2 _& q
.name = "user_led1",5 F. `( V! @" Z- `1 E
.default_trigger = "default-on",
: V* N8 p. m9 o# ~) |, e8 z# o },+ d% A& X p; c6 i
{
/ ^0 _: E G0 Z6 i7 p& p* L# n .active_low = 0,
n0 r. X/ r+ G5 k2 e, W .gpio = DA850_USER_LED2,
/ O9 ~+ l: s: E- ^7 f; z .name = "user_led2",4 a, F1 C2 z v6 a9 D+ C( J
.default_trigger = "default-on",
- d( p9 w/ y( }- G! b1 a: E },
( A. p/ ~, U, \: D {9 s. R! q {8 F' ]: [8 S- j
.active_low = 0,
3 _% L# W3 z8 o& f! q .gpio = DA850_USER_LED3,* I) ~! T4 k: ~
.name = "user_led3",3 q2 G! h& t% j1 {
.default_trigger = "default-on",' |) Q3 ]2 ?9 w+ A0 R8 z) P! U
},
0 w9 P% h3 }8 T) b};
; n3 ~8 E6 x5 k" b0 X3 _
1 a* |0 I4 T: z; G0 Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 P1 B5 J0 T! [0 k& Z6 F% X
.leds = da850_evm_tl_leds,
& Q% ~( _) y1 H3 ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' \7 z* B2 Z" t2 h6 v
};
( l- F- L; v7 u* R, _: V* K$ s( L6 \8 G7 C" I- D8 h
static void led_dev_release(struct device *dev)
% k. O; g3 g, m% c+ | b5 @{
4 g, X ?. v( W6 G& o( H/ w; i6 O};3 K1 {1 B" {6 P z% k
9 [( ^& Y+ f0 a# P" U
static struct platform_device da850_evm_tl_leds_device = {
# q8 B# C& u: k% c& Q .name = "leds-gpio",
* I9 X2 b* T; \1 R .id = 1,
0 N7 n9 \9 z& d7 Q .dev = {
z5 I) ]3 v5 G% K& ] .platform_data = &da850_evm_tl_leds_pdata,
1 T# r7 ?2 }3 t m' U .release = led_dev_release,
% ?( C' x: n! P5 f [$ F; I }
3 T9 j& Y# D4 R/ t) p1 ?4 r4 Y- }};% a! A! N* `7 z! m& p6 T) [
' F! @/ V/ d! S1 x1 D! {static int __init led_platform_init(void)
8 P! y7 @" H, \$ N" @; x F{
/ }* y4 N1 M5 W$ B% |, i. Z int ret;
1 {1 N, T) V4 q) c#if 0
0 v* D& K& J+ m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 ~- X! k; p# s c0 ^ if (ret)
2 d8 s C! P4 T1 N3 d1 Q- z; m pr_warning("da850_evm_tl_leds_init : User LED mux failed :": s$ I5 m+ C( @8 X5 k
"%d\n", ret);( G# T* C- F' M# ?
#endif( D8 E( R- [' ], F# k
ret = platform_device_register(&da850_evm_tl_leds_device);: Q) _- N9 t: f) r8 J Q% |' Y
if (ret)3 _2 \9 o9 S h- h8 v+ {
pr_warning("Could not register som GPIO expander LEDS");: @. _' B t( ]( w# G+ d
else; v0 i) g, d% F) M. ]8 n
printk(KERN_INFO "LED register sucessful!\n");3 d$ j8 I) S% K0 z
5 q& c* j8 b1 j) @/ R return ret;
8 O* |9 ~2 S8 Q}+ ^! J3 n' u/ {& ]
% F* ^# f4 P) Z4 D0 Z( Mstatic void __exit led_platform_exit(void)
( V8 ?4 B) H; v1 G- _, h{
$ c) P* u4 z5 b: @2 Q9 z platform_device_unregister(&da850_evm_tl_leds_device);) i5 P# d( f) C5 s1 C- d
. g% V# F; J& [! d0 H
printk(KERN_INFO "LED unregister!\n");
7 q! w) A* M/ y, d }& e}
9 _3 J9 _$ z/ j8 k( M+ h5 U
" H: T G/ s, r, H; pmodule_init(led_platform_init);
+ ]" X) b% f; ?3 amodule_exit(led_platform_exit);
2 R( W0 e U6 F2 J1 p, V+ s( ~' l$ b- k/ L0 i* D& K3 [
MODULE_DESCRIPTION("Led platform driver");$ i- x0 E) B( U3 } s
MODULE_AUTHOR("Tronlong");6 C u0 M) x/ m o0 ^$ X
MODULE_LICENSE("GPL");
5 s; o; M# k: b/ l) a3 E
4 ]8 a9 m3 Y4 t" j$ C |
|