|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# O7 j' i5 c" e( T
#include <linux/init.h>2 |: R: _ d# [
#include <linux/module.h>6 e8 A# }+ P+ i
#include <linux/kernel.h>
# k/ L$ i; C& d1 s#include <linux/types.h>
8 P3 X5 v8 y! b$ H#include <linux/gpio.h>" S: P/ t/ C4 u( L
#include <linux/leds.h>. C3 s& m4 \" K- p) V0 E: U; ?& j
#include <linux/platform_device.h>
3 T$ {5 H& ^$ v2 `
6 R3 a7 @3 b1 l9 a- M#include <asm/mach-types.h>
2 ~ g+ h' m+ t& c [#include <asm/mach/arch.h>
& g4 r1 J$ M+ V! A6 l#include <mach/da8xx.h>" ]# u4 O+ I2 H: A5 p
#include <mach/mux.h>6 G. h$ k" g6 @* b i
6 |2 D3 b9 W* X2 U8 D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 S# Y8 | _3 R) P) q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' X6 J* x/ q; O( j% [0 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- Q& X' a9 n! t: T. N. _9 H9 |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 j/ q% f/ G Z7 t- x) r
$ B5 a* @+ J/ \/* assign the tl som board LED-GPIOs*/
. h- T9 P0 z2 ~( Q' istatic const short da850_evm_tl_user_led_pins[] = {3 v) R2 L e/ s$ L5 O
/* These pins are definition at <mach/mux.h> file */6 F2 @; L, R) r9 C) ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, a- M9 ?. M" ]* x' w! T# ]
-1
7 m3 {2 e, {2 A1 t};8 s8 w6 r9 V. C! d0 g: K1 z
- F* ^# n0 ^) q c' z
static struct gpio_led da850_evm_tl_leds[] = {
2 o( R6 {/ W" K& k0 t { x; n9 @1 y7 k
.active_low = 0,
5 f2 x+ ~4 ^3 z) s4 D% \ .gpio = DA850_USER_LED0,# F; U' w- G! w
.name = "user_led0",8 J$ p I. ~9 J* c
.default_trigger = "default-on",
8 [! x1 _! S( Y0 \ },
: u' r# ^3 F: m K {
7 p% `6 D- L# C& V% X K& ` .active_low = 0,- z/ k$ B! C, w4 K& q; }- c, C0 v
.gpio = DA850_USER_LED1,
2 N+ p% G9 V# C" [ .name = "user_led1",
7 Q x" x0 R9 @; q$ u .default_trigger = "default-on",
* P$ j4 ~4 \4 Q! ~5 f U3 Y4 N },
) a4 c) O& J" v7 d6 j( S& B {# S* r* x1 @5 F8 y7 W
.active_low = 0,
5 v/ i7 e0 e7 f% |: H* N$ m .gpio = DA850_USER_LED2,
3 o2 q1 ~7 j, M/ T( D .name = "user_led2",
% b7 P) x( B \9 H' S% c$ e3 V .default_trigger = "default-on",
9 E, e$ p H- z1 E" G5 U Y },
; _. B) B: p: {% k+ V9 l( j {
7 h. r% i) U. t .active_low = 0,9 c/ X/ i) o; S, b
.gpio = DA850_USER_LED3,
( j& K: w5 A) h7 e: q .name = "user_led3",- D% n+ S, }# M7 H
.default_trigger = "default-on",* p1 _5 ^" S7 p
},$ [! G3 J' L! I( e7 f
};6 M( o1 \& ]4 [! O
) E5 J; x7 z! W/ G, J8 R) u& gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( c) U( m# I4 I7 n
.leds = da850_evm_tl_leds,# }/ ]& b' b* f2 T2 z7 a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( r K Z! X3 B/ }
};
8 [' m& ]5 f1 \7 f% w
8 n/ d2 O3 W( K+ z U3 Rstatic void led_dev_release(struct device *dev)
2 Y3 a5 A9 w, n% B{ z$ S8 n6 e' [
};" J8 V; i) S5 e* f; }
0 P' H4 T& w+ ~static struct platform_device da850_evm_tl_leds_device = {% O9 f+ j' }/ E# K& v% E
.name = "leds-gpio",
7 y* F# f) @$ I& j, B/ a .id = 1,8 f7 x9 k6 f" Y! w& ?4 I7 ^+ A
.dev = {
" f0 @' W0 f1 r2 Z4 I, W& D, w .platform_data = &da850_evm_tl_leds_pdata,
) T9 y2 s7 [+ N( O7 e$ m4 X .release = led_dev_release,# a$ z1 u* B$ D+ J
}- v9 X& x7 C- W* d |0 Q9 j% d' P* a
};
8 c- @( Y8 L$ C/ \8 `' p* X p- j' Z6 `# X$ }
static int __init led_platform_init(void)8 W, s3 D8 r. r! m H
{- |" R/ q9 h( p
int ret;8 Q2 _ A" G) D0 m
#if 0
; j; [ E9 K- g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 J, m; J* M4 S/ e0 |
if (ret)
/ L; |$ i9 k/ d0 a0 M) e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 b+ U4 d, g4 U; y( P, E7 q" a, f$ ^ "%d\n", ret); \7 F! l& L% c: q7 `4 N* N7 s) b
#endif
9 R/ F6 b7 X* b- j1 K! w2 w' n ret = platform_device_register(&da850_evm_tl_leds_device);' m0 \* }, T7 ]
if (ret)! m0 `8 h0 ^- I, [
pr_warning("Could not register som GPIO expander LEDS");
1 Z" S: o0 k f2 }3 o# z( q else
N( m: v8 ^- |! _. k, s printk(KERN_INFO "LED register sucessful!\n");
. d5 N; E! q* q5 f& I% w9 g! R. @, }3 P6 Y: s8 ^3 v7 D
return ret;$ b$ J& \0 M* ^% T5 K0 Z" K
}+ }! }1 }0 j% e. T- @; `3 S/ {
1 w3 n. U6 C( g/ t3 c
static void __exit led_platform_exit(void)" d5 y- f- e/ s" s" C& D$ y5 Z* @$ v
{* }# X" w; k( o9 S
platform_device_unregister(&da850_evm_tl_leds_device);
- K7 L h3 K8 g3 O" F7 ^/ N' h& V# ~" l6 t- r) j
printk(KERN_INFO "LED unregister!\n");/ u6 {0 T4 T0 C' K) k
}
; S; t/ q- A* L- i6 f. b" K' l( o6 R' W2 u9 K" o. }2 E8 j1 B
module_init(led_platform_init);- v% e9 Y" j0 x& i6 i5 n
module_exit(led_platform_exit);
2 E) v, U7 t- v1 z8 S
6 ]9 k+ D6 ]9 Z2 @. a0 m! lMODULE_DESCRIPTION("Led platform driver");* Q) j m0 u! {# a* H+ J3 \
MODULE_AUTHOR("Tronlong");
! \: O0 Y% G3 m; e7 j tMODULE_LICENSE("GPL");
( B/ d/ r% `5 \2 N) f; O
, A: {) K! r( N6 r! I' \1 | |
|