|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* {0 Q* t! h. } h/ O
#include <linux/init.h>6 p" ^, |6 @% H) N6 B
#include <linux/module.h>
: }7 l4 c+ W$ m7 Y' C+ e2 M! w#include <linux/kernel.h>
2 k- J; V4 r) h f, |, Y# k$ Y5 a#include <linux/types.h>* J/ R; }9 f; p3 @2 f+ J
#include <linux/gpio.h>' X8 k* ]0 \# f# |7 b1 [
#include <linux/leds.h>8 S- v9 l. B, O3 O4 J8 q
#include <linux/platform_device.h># X Q" F1 I, z0 F5 O9 D+ |
! D3 i; @9 I: m7 `" g% I7 U, L
#include <asm/mach-types.h>
! v# d4 W' L% I$ X#include <asm/mach/arch.h>9 |' Y' r. V# X# i3 @% O
#include <mach/da8xx.h>
! K. _' B" ?0 |#include <mach/mux.h>. u* Q6 S! @) V# j7 |) |
( x; k" V* ^5 T$ P" M- Z8 w; p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ o$ E+ ]7 k& L- j! ]8 Z, W& h- V9 O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 H" z2 s% M% j4 F" I6 e7 a1 l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 i6 T. F4 {. Z' O: Y/ ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! r8 |+ X0 Q# A3 B) d3 L; G
7 B* _1 S$ E& i6 ]/* assign the tl som board LED-GPIOs*/
0 e, ~' A* r0 O5 M" d+ zstatic const short da850_evm_tl_user_led_pins[] = {( H# W8 j- H1 R' o
/* These pins are definition at <mach/mux.h> file *// A: L. x E: G: v6 w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 b. L! H6 k+ Q -17 i1 u. Z( C, Q4 h- _
};& s# g1 I, i+ V
* d9 L5 ~/ p3 v2 g/ Z9 V" X3 estatic struct gpio_led da850_evm_tl_leds[] = {" b x6 K d8 {* h
{
b6 b J, S; s6 C .active_low = 0,- U! _) W, d- W
.gpio = DA850_USER_LED0,
8 w7 X' k) c) K' D .name = "user_led0",
/ v. F/ J0 S$ ?+ b- \ .default_trigger = "default-on",- k/ D# X/ M% n% R. z, K" R, k6 j
},
, R3 f e' C8 P) g {4 e+ _. c n" p; D
.active_low = 0,
+ E" X$ ~0 {# G6 S .gpio = DA850_USER_LED1,4 h) X6 y! W _# {3 Y- L* x
.name = "user_led1",
, a' @1 B; l# d7 D2 B! n+ s. h0 V .default_trigger = "default-on",9 m( B3 B2 b) Q0 b
},
8 i; p$ ?' u7 G- U( f& o {
% \& Z# O' i5 L9 b .active_low = 0,
7 ?* j# y3 i8 b# N .gpio = DA850_USER_LED2,) D; A/ B- F, `8 e+ y+ G+ H, Q7 F
.name = "user_led2",
8 A% V1 N- S6 _1 M .default_trigger = "default-on",
- ^. e0 W" @" J: ~1 L },
) S! C; `; Y" i+ v* l0 ?+ y {6 X" a3 F7 v' y# I2 R' Y! y
.active_low = 0,' h' d3 A7 F- t$ c4 o
.gpio = DA850_USER_LED3,
& A5 H' c/ K W& T+ i .name = "user_led3",
- j i* D% @+ C+ z7 F8 |' W9 J .default_trigger = "default-on",
+ H/ e- D: s& ]6 z3 ?1 O },
& z& `& c! @) S! ^};9 {+ H. Y: @) C! u8 J$ G9 l! _
" Q; ?8 `6 z h" [3 d4 |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 m- ]6 d: u" \+ C, g' B
.leds = da850_evm_tl_leds,7 V) F/ ^" g6 t: Z) m2 V, ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, z7 K9 n* _5 c3 l8 x1 ]7 N
};$ W) O3 b! {. @" p
4 T5 J" f( |- f. P/ y0 e: J F4 jstatic void led_dev_release(struct device *dev)6 t6 ~' Z7 c. r
{
2 d Z& F# n2 f+ X: a' S};9 _9 }/ ~( C( V1 ~; q% ?; i
" Z& R- f8 i. n3 q0 d5 E8 h3 B+ L2 T
static struct platform_device da850_evm_tl_leds_device = {0 `/ k; Z% c* I; w, g
.name = "leds-gpio",7 u5 x0 E" b: O( J: I; p
.id = 1,
+ q8 V5 G/ P5 v5 T" T1 {- y .dev = {, J1 t+ j# x$ U& E
.platform_data = &da850_evm_tl_leds_pdata,
: X5 P" y/ q, m, ^7 x .release = led_dev_release,
2 N, Z9 ~+ J& I% u% t }3 K$ d2 }6 M3 Y. E
};
. v, w. W/ I! X- ^8 u% F6 b
: U5 ]1 k9 T& S1 H0 bstatic int __init led_platform_init(void) N% G3 }: s5 N% @/ I8 d
{
$ C% {: m! s0 x, G D# p* ` int ret;+ y/ K" s$ \! M" b
#if 0/ w+ j1 G/ L4 _+ x$ R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( P8 F# n& D) w6 H" |
if (ret)4 e+ F9 k; E/ M' Y2 k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- p7 y: Q1 i# _( Y
"%d\n", ret);3 ?4 [; i6 z* _
#endif) w. f: O4 G& J( D7 @8 g+ J- W1 o
ret = platform_device_register(&da850_evm_tl_leds_device);
/ V& b# t6 c1 A1 \ if (ret)
0 T' I! s9 R, S0 Q pr_warning("Could not register som GPIO expander LEDS");
2 J* J6 z) l6 ~. T+ x" x( D8 P else1 m" w# I% m; A) E
printk(KERN_INFO "LED register sucessful!\n");
" i9 W& q% b- r' i6 d8 _: n; {5 g7 {/ o
+ R, `- k) {/ W" K" g2 ` return ret;, i0 {4 L+ ]1 B( K+ Y$ S3 @
}3 n% I" X: e7 {9 M7 S, A M
# K- o; m" M9 a2 Fstatic void __exit led_platform_exit(void)
0 F0 u3 Y( e, @{
% K, N) Y5 t; p9 h( Q+ C platform_device_unregister(&da850_evm_tl_leds_device);
# X! B. }# @5 j" T) d2 C
. D) O" o' ?3 z# ~' a' d printk(KERN_INFO "LED unregister!\n");' x8 {( _/ E) A
}4 Z$ L6 ?- Y& a
1 E7 n+ D# ^. n$ Z2 imodule_init(led_platform_init);1 u' B1 A3 l5 g8 B8 n
module_exit(led_platform_exit);# d6 [( |- m3 e) X( D
9 q' a2 U9 I' \& oMODULE_DESCRIPTION("Led platform driver");* ]" r$ ^4 D. O2 d9 E9 i
MODULE_AUTHOR("Tronlong");
* o0 L k! n' @# ^ RMODULE_LICENSE("GPL");
! X' J: z! R' X2 z0 |
) V5 |# K2 H4 ^7 P2 y& s |
|