|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( p, ?- _9 d, A#include <linux/init.h>$ _) f) ~7 d! l9 n6 ?
#include <linux/module.h>
9 m0 y9 D7 u( s#include <linux/kernel.h>0 d5 c/ R1 y! X1 {) V9 W
#include <linux/types.h>
: }! L$ _7 A4 W0 W& i#include <linux/gpio.h>
7 \% d. o: F. r6 z+ Z#include <linux/leds.h>% o5 j. |% I2 Q0 O: z9 |3 h9 L. Y
#include <linux/platform_device.h>
W( }( y W# A) m
0 y2 U" o& M9 R; x" D' {#include <asm/mach-types.h>
P) V& u4 Z) Q#include <asm/mach/arch.h>
" j9 _. F+ k( P7 K) `$ G5 f#include <mach/da8xx.h>
* M) X J; t* X3 x7 r9 {& A#include <mach/mux.h>
7 B7 E U, c5 e7 f" Z% _' B% D' T5 P- k+ h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" A$ {' t1 Q) w5 \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, w% O" V) l8 Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ u7 t1 @, h, p
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% F3 n0 B1 ~( w7 ]! f7 M" P! s- N
+ w, q: f/ E+ X6 X7 l" }# ]8 a
/* assign the tl som board LED-GPIOs*/
2 K) [# b: f1 O$ xstatic const short da850_evm_tl_user_led_pins[] = {5 E8 W3 @: f7 \0 H' F6 d& \
/* These pins are definition at <mach/mux.h> file */
7 X( _( W: H9 s' K3 _: K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, u: O0 e& S/ f/ x -1
' {/ M5 {6 F" T2 a6 l* I4 ^};6 Q6 T9 z) @2 ]" D; n/ H! p9 B) o
* p# i0 u& \3 ^4 R) C; t
static struct gpio_led da850_evm_tl_leds[] = {# P7 G* i- `2 T. g; \1 k1 \6 g/ W" {
{
4 V% y6 }4 `/ ]: F6 p9 M .active_low = 0,
! k2 d* C, k# Y) v4 X) Z- g/ [ .gpio = DA850_USER_LED0," M6 u5 j8 v, G3 X* C+ c
.name = "user_led0",2 E" k2 \+ q$ ^$ H
.default_trigger = "default-on",
V, X( t4 b7 b" w0 F },
h4 J4 _& o* L' b, D {
, X+ ^. h! x. K9 q( M+ l .active_low = 0,5 {0 M( E8 A- p$ w* U: {# g
.gpio = DA850_USER_LED1,1 n: K8 t& h, L
.name = "user_led1",
; q, T1 }, I) `) y; y7 _# A5 w .default_trigger = "default-on",5 o, \9 M5 A |9 j- D1 B: O
},( h3 M5 c! r* ?/ e
{
0 C. G7 P' U) {7 z8 }2 a ~9 y .active_low = 0,5 Y2 a) o1 f5 T% v- `
.gpio = DA850_USER_LED2,
' P$ {! f/ G' x# i o/ l' G( |0 r .name = "user_led2",
& p2 U9 y2 D* q/ K; s7 E .default_trigger = "default-on",
6 E* |0 S+ N- m I8 { },$ r% w8 d* Z$ T* [* Q
{
+ C/ I; b9 S, b2 Y* B4 s- U .active_low = 0,5 _- r( g3 g* S8 Q* M
.gpio = DA850_USER_LED3,
4 E- q' E6 Q# C9 w8 E .name = "user_led3",; ?- W2 k, V5 v# S8 A: }; P
.default_trigger = "default-on",4 { s2 i1 k2 @' ?9 S+ _
}, M& \9 Y8 J9 U& F
};
8 n6 }8 f/ q+ C! I; T% o8 V/ z+ `0 h, ?- ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( U7 t% R: {% }- m6 `
.leds = da850_evm_tl_leds,
3 l2 h$ `; n3 i* Y n2 r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ j$ S7 F- r5 Q( m9 h. L* ^; _};
2 W6 o; n2 k1 P5 E3 M, |/ _3 o/ E8 s2 S
static void led_dev_release(struct device *dev)
% Q8 v& R: m9 ]7 `8 {{5 m( O1 f- f/ D& z; ?/ r
};' b7 d0 T7 `5 O: b& W& q6 N
6 ~: ]) N$ m7 U! b/ a
static struct platform_device da850_evm_tl_leds_device = {
9 }# W" i5 ?6 B9 @! f .name = "leds-gpio",
, p) R0 y5 y5 ^+ y* H: U' G .id = 1,( t6 f8 i8 M6 i# ?: t' z4 n
.dev = {: B! b; A( A$ o R, ^
.platform_data = &da850_evm_tl_leds_pdata,& R, O. {5 k6 o7 y z( `5 J
.release = led_dev_release,+ E- F, ~& \) b. [+ s
}* ^# z) s: l" w! [" ^
};
& u$ [5 S% m: A
A5 F& y; y; V* Dstatic int __init led_platform_init(void)
5 v7 c" G$ s! q( L' H9 q2 ^{# s) R [/ O; \3 d" T2 N
int ret;
9 b: e0 |. G3 k" U/ w. C9 h3 [#if 0
7 V+ [. N; F( r. j9 Q# E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( ]2 I- c8 n6 b9 d3 B
if (ret)
! \& b' T1 F! W8 ]3 F pr_warning("da850_evm_tl_leds_init : User LED mux failed :", O1 M+ X' v* X
"%d\n", ret);, c2 w4 n) h! h6 J9 c p' K- \
#endif# S# n! t x( x7 @1 I6 M
ret = platform_device_register(&da850_evm_tl_leds_device);
4 B! [/ v, ] w4 I" l5 R- x if (ret)
8 D. \1 e4 [& c# Y% \. z& T pr_warning("Could not register som GPIO expander LEDS");
: s7 [1 O& X. Q( `# V+ o% j else. ] I+ q0 |1 J
printk(KERN_INFO "LED register sucessful!\n");
% k1 I* T4 w# Y) ^/ O" U( w5 f- ^
return ret;
- _. k1 U+ y0 j: V) Z* A9 p}: D6 L$ z3 `) A; p
( a6 K+ r2 }4 j. f2 P; rstatic void __exit led_platform_exit(void)* S8 G" Q% K. o9 @4 E
{1 q' j5 F% K/ a5 w
platform_device_unregister(&da850_evm_tl_leds_device);
Q( e0 i8 O) R* P% r' G6 S5 ^0 g6 P$ O. ?
printk(KERN_INFO "LED unregister!\n");
: w3 d% I3 }- G, {7 |}
/ t# u9 n3 ?) N2 f% |1 ?
. M/ D, d: |& n. H: O+ {7 `, i/ x7 Kmodule_init(led_platform_init);
2 x% f9 t) P, J! M0 |module_exit(led_platform_exit);7 t B' r7 I% M. x
4 S: I( A1 j1 V* k% J. J, bMODULE_DESCRIPTION("Led platform driver");
D( k( G( E, m0 HMODULE_AUTHOR("Tronlong");
' C. J9 g6 l, C7 ]. h$ sMODULE_LICENSE("GPL");
0 V6 l! ~4 w/ \$ u r; F% D$ }6 q
) Y! [9 D3 F) t0 {, [ |
|