|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" H; n$ z7 _& I h4 M7 h, w+ }2 |#include <linux/init.h>
; y% l" Y* f5 L+ Q#include <linux/module.h>
: Q8 n7 u) |% x0 V9 r! p) K#include <linux/kernel.h>
- r$ j% L! w6 x#include <linux/types.h>
: S6 e* F- o" r0 o$ s0 ?, c( p% L#include <linux/gpio.h>( W/ d+ r& s! m* r) {: x8 V
#include <linux/leds.h>0 @2 F/ x1 v& u- }) }
#include <linux/platform_device.h>
( ?! z/ L6 y) i8 \* ^2 Q, w% }$ K) i: `
#include <asm/mach-types.h>. I* F# p9 r3 C; E! D
#include <asm/mach/arch.h>
) E! q8 {& E& q8 Y+ I#include <mach/da8xx.h>
. i! d7 \0 p9 B, E#include <mach/mux.h>, q1 X h* b" J+ ]. p/ {
, m% ]6 C/ o, i# U) u) k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 R8 g) u) {6 `( q0 Y4 h# }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ g' [7 e+ ~+ G& @8 A, C* c/ ^5 B+ c0 _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 ~# O* v) B* k) t5 q4 f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 e! l1 Y# }( L
8 r; \, w8 A# G1 F* t/* assign the tl som board LED-GPIOs*/( c7 h: s% G/ d0 [0 R( W
static const short da850_evm_tl_user_led_pins[] = {
8 K) C4 T& N n$ p$ @+ e: d6 M' L /* These pins are definition at <mach/mux.h> file */3 l: \4 ^# a0 y; Z% T, V: Z2 O# a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ C" u5 ?* `6 O2 z C( W( ?. O -1
5 p2 `7 U/ l# w; k9 d/ a# n};
! Q# _# d: W$ |( `& A
" ^+ s0 O6 i- r, m3 o" w5 I1 B& F" cstatic struct gpio_led da850_evm_tl_leds[] = {% x! B6 a. G& v
{9 m$ V) z! r4 }' t; j3 A
.active_low = 0,
# ~0 o* G6 C& i8 I .gpio = DA850_USER_LED0,
1 I6 ?/ U) w- u% X/ n .name = "user_led0",# ]2 q) T8 e" i& L% z
.default_trigger = "default-on",9 W5 W0 e5 r9 q) g# O
},
- q8 V2 {7 m! t8 d {5 U1 T$ b: O$ Q: b1 P8 z) k
.active_low = 0,% P& ?" r2 \9 F$ [8 l0 x
.gpio = DA850_USER_LED1,# l0 L% {+ ~% Y( [
.name = "user_led1",2 A! i/ w O2 F$ E3 @: C! Y1 K4 g; g
.default_trigger = "default-on",. ^' [1 s& @4 m# L' S* U
},
, d3 H1 p* |+ f9 N1 a/ I9 Q9 M {: D9 D' w% A8 N- p2 p+ n2 P
.active_low = 0,# g# Z8 M5 i- N# j
.gpio = DA850_USER_LED2,
1 d+ H h+ @) T .name = "user_led2",/ j/ B5 ?( ]0 [, |# [% t4 R6 C+ G- W
.default_trigger = "default-on",
/ }6 @' I) R) k7 R( \7 N/ Q9 s },' n- n3 d6 E ]' ?; i
{3 |: U: |; M( _* G
.active_low = 0,( t/ h5 T- A6 K
.gpio = DA850_USER_LED3,
8 K+ M! d: |' o9 K4 ^ .name = "user_led3",( S+ Q6 y$ ~/ `
.default_trigger = "default-on", K# ^7 {, Z4 S5 F
},
$ W1 X R( C% `: M};
+ L/ i8 U9 B: E0 d
& D+ N) [) J0 l5 v% }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, o. _4 e( c! ~+ u8 ` .leds = da850_evm_tl_leds,2 n+ X: {7 x2 g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( [4 f9 e4 _4 A ^3 U! @};
i8 W3 n( {) g2 R1 L6 W, L" H9 G, g* A N
static void led_dev_release(struct device *dev)
. r% P" U9 _+ ~8 ]0 H, z9 [{
) N! k5 }! {* ?+ _};
4 a( `; F* d ^8 T2 ?4 U% e- j! I) C8 B4 q
static struct platform_device da850_evm_tl_leds_device = {
+ y1 O% O8 }0 g( T: |* Q( [: M .name = "leds-gpio",
* i& I. n. X/ J* C3 V .id = 1,
# |9 j" ]" g9 o# }# y+ w .dev = {; _5 a# B. J C( U
.platform_data = &da850_evm_tl_leds_pdata,' ?1 m' l; f" w' S& y9 e
.release = led_dev_release,) C4 q9 I2 P3 _* j( F/ s
}
) O. I6 _6 y& ^};
1 X5 a' T- U# h4 V% @7 E% O+ U3 M" V1 o1 I
static int __init led_platform_init(void)+ u1 m G. ?+ T4 y+ ?8 a) M+ ^
{* ?3 F y2 a, r1 B
int ret;
1 P+ D1 R& B' n$ P9 U#if 0
! f# ?1 @4 ]9 y5 B( k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" Z! M( y, ]: @ if (ret)
1 D& q& Y+ P3 B8 g$ D( j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& X% k, Y$ ` M/ u- v6 |# y
"%d\n", ret);: Y& X% ~, }" k7 n, e
#endif, R4 q! V$ u7 S- a
ret = platform_device_register(&da850_evm_tl_leds_device);
9 k. t) O$ w! K) I if (ret)
* X$ ^/ S* R4 m2 z; c pr_warning("Could not register som GPIO expander LEDS");- ?; y* h- R6 W% r: }5 R
else0 H: @* ]7 }& }4 A/ W
printk(KERN_INFO "LED register sucessful!\n");2 U! ]- I! M% @- e# A# X3 x
, j; O8 z9 _$ U8 V
return ret;
9 m7 D T8 `' W9 j, q}) @) O1 H9 c6 c( q' l2 V- `; l2 A
; u6 r- ?( u. S! Estatic void __exit led_platform_exit(void)
7 M' e" Y5 E. f9 j: _{' X3 L# X5 v' Z2 w
platform_device_unregister(&da850_evm_tl_leds_device);
9 T! A$ U: m) U2 a- w2 P. u7 ~ Z# Z
printk(KERN_INFO "LED unregister!\n");1 u5 B& I9 Z. w- k1 P8 A
}
3 p1 z3 @: A0 r7 m! k: e& Q: t7 P! @% B5 L
module_init(led_platform_init);
0 P1 V2 ~" a0 ymodule_exit(led_platform_exit);
7 b/ u* p, D/ c9 d# D+ s( g0 ?+ V9 [5 n; w6 |
MODULE_DESCRIPTION("Led platform driver");
1 D/ ^1 q" A1 gMODULE_AUTHOR("Tronlong");# f9 @5 c q! F3 C' `
MODULE_LICENSE("GPL");9 R) a8 u, }% D3 e) G
A( \2 A6 o3 Q) G2 I0 u4 o) N
|
|