|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* e; b- M2 ]8 l( h5 K
#include <linux/init.h>2 w9 ~- H" a8 c2 _+ {- M' a ]" n
#include <linux/module.h>9 M% E' W3 J! E7 c) C4 e4 U- U$ {
#include <linux/kernel.h>1 T9 h$ N, Z& w+ i/ H% @
#include <linux/types.h>
& r# w/ A0 I! O5 c#include <linux/gpio.h>
/ @/ c' E$ v: |#include <linux/leds.h>
& K5 M' X V# k Z% u* g#include <linux/platform_device.h>
, A6 G5 J) R- C/ A! E5 Z( K1 U; H
' f$ B, W4 L4 W$ L#include <asm/mach-types.h>
" U0 o7 R% H, `; f6 p! c#include <asm/mach/arch.h>. Z( N2 `. b2 p6 ]) r; t
#include <mach/da8xx.h>( a% ]8 E: e# W6 T ?
#include <mach/mux.h>" I7 a; T, k) a! f1 Z
r% a& v, M; }) r" H$ b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- O" t4 t5 T$ V2 M4 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; T3 l4 |" b( Q! _2 ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ K: k9 Z7 B. v/ O" i" Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ G: Q) V% _4 s5 W+ \( c
; m4 ^- j- A9 L4 ?, w/* assign the tl som board LED-GPIOs*/; D3 f. G* B' s; g
static const short da850_evm_tl_user_led_pins[] = {) S( f( F$ m& {
/* These pins are definition at <mach/mux.h> file */
! q. Y k0 X3 l) J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% P( r- S. K0 M2 j6 ~4 T
-1( X( R1 a/ x ] V
};
9 v) W: C2 z; I j- O
6 R/ L) r- m# A1 f2 _static struct gpio_led da850_evm_tl_leds[] = {5 q+ J* ^$ P7 d/ J* }! W
{3 V) b8 B' |- s( a( m1 w
.active_low = 0,( \& ^- Q( p& c# f5 y
.gpio = DA850_USER_LED0,6 m G! u8 T4 X9 {& v/ \ ?: r
.name = "user_led0",
1 U0 N+ S+ k! D9 Y: q o- t! b .default_trigger = "default-on",9 |' F+ n) k" [6 B. W
},: a0 u7 u' E, G6 _1 O! ]
{8 m8 _. y$ Y9 ~7 g7 u
.active_low = 0,& e# n, d: F/ ]# k4 V+ L/ K
.gpio = DA850_USER_LED1,% E. f, u# p7 ?& f7 u% u
.name = "user_led1",
. k* ]3 B9 N# l1 T( x( j) h0 }7 y& u .default_trigger = "default-on",
, F, x% M! I; ` },
9 D% e; D1 v/ u {, k' d9 H6 Y* {8 Y; D) l
.active_low = 0,' g3 [8 l8 s6 ?7 m' I
.gpio = DA850_USER_LED2,
5 F2 i3 L+ X& x6 v .name = "user_led2",
3 p# D& c4 k; |0 ~9 i .default_trigger = "default-on",$ i5 S- ?5 f; ^* N, E/ v
},7 I, t9 x0 N7 N7 [. p- [
{
$ K+ a: y1 j- _. k: k. [ .active_low = 0,
$ y8 [( Q+ h+ H; x e .gpio = DA850_USER_LED3,# w, ^% I8 d4 ~4 T
.name = "user_led3"," G3 w: u5 k) ~1 E
.default_trigger = "default-on",7 I5 \1 N& O* O3 R3 w; G" ?
},
0 k7 ~, J5 b* X. K, b% a( Z7 q};$ ~4 r7 i4 t$ n
: E$ l8 G4 l: G% K5 \* ]% E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) m1 v5 h$ H0 ?. K, K
.leds = da850_evm_tl_leds,
; I) @/ [' ?$ `+ h+ M9 o( q) \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* K8 N0 [( f+ g! |: ^7 F, `3 k};
) v2 n$ Y4 k# l' [! k" J6 q) Y5 X$ ]( j$ K+ `
static void led_dev_release(struct device *dev)
0 ~: w4 }% o$ R2 {& f/ e: Q{- @" h+ F6 [; I# e* J6 v* I
};
2 z1 ^ Z8 X7 k
: ^$ c" n) D. u! O7 N# jstatic struct platform_device da850_evm_tl_leds_device = {' s7 |! Y: c |1 D9 g- F
.name = "leds-gpio",
7 d; ?) u% }- G1 o/ o7 E6 X .id = 1,4 L' \& Q, u! ?9 U3 ~4 _$ _
.dev = {
/ T8 Z$ W: Z7 }; w3 Q .platform_data = &da850_evm_tl_leds_pdata,9 ^2 H6 `5 R* G% |0 p( ?
.release = led_dev_release,
3 _/ b% ], s. C7 Y' {0 W3 v }- \! e" V1 u2 b
};! G D K4 F/ q/ U$ t7 R0 G9 J
7 o; }% F: K- p' h
static int __init led_platform_init(void)+ ?3 `8 k8 N, t+ ~' `& u5 r/ m
{, G! y$ `) {* m. d* x D9 M! b
int ret;
# B" D: J3 a8 f+ y#if 07 l/ s! @% X" z, M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& `/ }: @0 j( ^ if (ret)+ n. ?# e/ q( o/ |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 E8 _/ e) |) l; i( O' O: l "%d\n", ret);
: m0 y3 U p& V! l# g#endif
* U/ s# O E x& H) L) a% Q: N" e ret = platform_device_register(&da850_evm_tl_leds_device);
# D& B( Z* }1 `2 p* k& `8 X- g- f if (ret); C* t& q0 y! L: a }1 n
pr_warning("Could not register som GPIO expander LEDS");
$ {" h5 \4 f! e else' N' G, M0 {3 [" p% T5 D: s
printk(KERN_INFO "LED register sucessful!\n");
% S3 ]- m' r- I( m A( z$ ^2 O- r' }
return ret;
j2 T D9 g4 D0 n' ]}
2 A) e) m8 T L3 ^& p* x1 _- G% i* n7 y
static void __exit led_platform_exit(void)
& Q! J1 P, [% Z# s y1 X3 ]$ r. S{
" v8 m& G4 v8 \$ p' R: G) K platform_device_unregister(&da850_evm_tl_leds_device);
3 V. m! E2 s) B3 H9 R$ D$ l% S" s7 @8 d+ q* m5 Q4 l
printk(KERN_INFO "LED unregister!\n");+ Y+ I8 C4 D2 C2 y& S
}" M$ S2 A2 B! ^' f+ ^# w
0 e$ l: n) X9 x% X
module_init(led_platform_init);4 F$ b) r; Q5 `; P2 i: n
module_exit(led_platform_exit);5 f$ _" W `( t8 d4 I
6 e2 j* R5 S* Z1 a9 N8 y! [9 p3 w8 IMODULE_DESCRIPTION("Led platform driver");
, l1 K ?5 s; ]6 DMODULE_AUTHOR("Tronlong");
3 @) Z4 [) Y4 Z8 e; PMODULE_LICENSE("GPL");* \" c. f) [% d7 Z
4 D* S* T) S9 y ]6 c |
|