|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' F% ?# c9 t9 U( U$ r8 |#include <linux/init.h>
?1 g( F. M5 z3 v- W( E#include <linux/module.h>( M4 ]% T+ V% M& y" {5 z# ]
#include <linux/kernel.h>. {* X; O, }, l3 r
#include <linux/types.h>
7 ]: b* `( i: y/ H. z- a! [# s$ B$ v! o#include <linux/gpio.h>
9 ]% |5 \% y9 J0 B3 A9 Z( ]#include <linux/leds.h>! p. _# n; |) b( s' Q4 @
#include <linux/platform_device.h>
2 s) ^8 `" e9 n5 ~' Y, s- v5 _& \3 u9 S; V& e7 R
#include <asm/mach-types.h>+ B; c: B6 p3 c: r
#include <asm/mach/arch.h>
" {4 l4 j$ G% ?# R8 I#include <mach/da8xx.h>
& H `+ K; w0 S }' c#include <mach/mux.h>
" B) V" X& t6 n
& `( G, R/ q4 v! n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 v4 p0 S' \! s2 j3 y6 R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ A$ q$ m. v3 I) Z- A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% F5 b/ J% W2 K6 H% ~/ n. M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' X# ^* Y. Z2 R }' k% _9 i/ E M$ P5 z6 p& p# e+ q- ^; r% A
/* assign the tl som board LED-GPIOs*/" n6 \ f% N8 T; j; [
static const short da850_evm_tl_user_led_pins[] = { W1 }. r W! |( j4 s @+ D
/* These pins are definition at <mach/mux.h> file */
6 f. O; M& E2 {% Y1 N) n8 i& u6 p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 b+ ?/ z% g: s- s7 b: Y
-1
' k e5 F1 t9 C% r0 b f2 y0 W};, p+ C; x9 f: L
4 B7 A4 D; P2 ~5 H( r6 I2 f6 Gstatic struct gpio_led da850_evm_tl_leds[] = {& C5 P+ o7 [6 o: \
{
6 k' Y. z! @" q' ? .active_low = 0,
4 A! {2 p2 X! X, @% y* D .gpio = DA850_USER_LED0,
& |0 W( A, G# e$ }) ~: i% F) Y .name = "user_led0",! j @" E7 D3 D; Y- U
.default_trigger = "default-on",
4 P" ~& L6 P: `3 b: s6 Y1 N: S },
! ~0 y5 @0 a7 G. S {
+ N7 ?% ]7 g" \" d7 f .active_low = 0,
" f# W+ Z4 _4 A# P6 Q .gpio = DA850_USER_LED1,+ s4 I) U+ m2 g
.name = "user_led1",' c6 ~& A v$ Y: A6 l# l
.default_trigger = "default-on",) d4 `, y) P6 A5 h7 X) C& {
},
1 F& W! P8 D3 l" Y {8 u% Y% J; M/ A5 m$ Y3 T$ g
.active_low = 0,
5 i' A0 A/ {; e9 @& P& S9 p8 Y .gpio = DA850_USER_LED2,& f: S! s( R9 l" b1 u
.name = "user_led2",* a0 W" |* p* D0 \7 Y2 V
.default_trigger = "default-on",
# _4 n! ?9 _1 r+ _+ x4 J },) K, e" h* j% W2 v5 C5 ^
{3 i7 {. T/ g8 {+ J2 A( U( Q7 ]3 N# q2 c2 @
.active_low = 0,9 h1 y; ^( I& v/ G$ f6 j9 s
.gpio = DA850_USER_LED3,
7 y/ p8 n! G9 N9 V" q7 l+ Y/ p .name = "user_led3",
# {! z, Z, o; [1 A S .default_trigger = "default-on",4 f$ i$ q0 y- u
},! i. }/ ^& L. D! t/ h2 G5 S2 V6 e
};
: w, q) o; r% T2 v# N# S# D% \' T! @0 d. T# B2 R( @4 ~
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ b9 q: ], {+ n* h
.leds = da850_evm_tl_leds,. k0 S- r' R, D; h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& C1 [* j9 _9 P/ u/ {7 C* X
};
! X; U' N' a! e" I/ Q& M
; X* [3 d% f; b6 Estatic void led_dev_release(struct device *dev)
; o) s0 A& G3 z* R/ M: |- c{1 Z0 A/ s. S# z& W% ?+ M5 D
};5 k5 Q1 P: J0 C* I7 }2 d4 H
: @3 I7 m- y# c f: H; Qstatic struct platform_device da850_evm_tl_leds_device = {4 k" P$ R8 s" J. B3 G1 G4 ?
.name = "leds-gpio",
, M/ v1 L' |7 p3 N7 L X/ e: b .id = 1,. |" @' Y$ I$ ]) V- \1 ~
.dev = {
2 a7 K1 |. W$ z& _ .platform_data = &da850_evm_tl_leds_pdata,
, B: ] A8 f0 A .release = led_dev_release,
# Q- \/ x7 _0 E$ `; h8 [ }
0 A# r+ F7 w5 @0 U" G) Y};
5 _6 P$ Z3 V6 Z) I2 I% r) ^. H, O7 t& g* `/ u, N1 m
static int __init led_platform_init(void)
' Y" V; H7 z! d, h/ l4 J) R{
* \2 T+ z; K- S int ret;
2 s9 c+ @4 ?$ S, L#if 0
7 R, K4 g- Z( A/ t+ ]2 z b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, z' }# p+ T5 d, S: B
if (ret)
) r- ?9 ^. i/ x. s# n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 k0 B+ f: k2 I% `
"%d\n", ret);
- p, L' y% x h: `! W8 w3 U7 q#endif4 n/ x+ a& s4 \' w( |1 {4 F' S
ret = platform_device_register(&da850_evm_tl_leds_device);
" b: C1 a, j1 k4 ?: q3 Q if (ret)
) x: h0 d# Y# m- [6 { pr_warning("Could not register som GPIO expander LEDS");
9 ~6 I& p# O' P3 [( U3 I else+ _+ C$ ?6 x. ]8 B) H- G
printk(KERN_INFO "LED register sucessful!\n");8 |; c" g/ V; B& P* A
! @% J, N/ p7 }5 z6 z
return ret;6 l- ]$ r8 ~- k& F X G
}
3 f1 Z4 z/ B8 I( {( x) ~$ L: `7 w
" K* C ]/ p2 G* E" M" ystatic void __exit led_platform_exit(void)
3 u) S8 G) F6 h0 y$ }9 V" e) Z{% i" F: V$ o: k P0 P+ {% R" J; P) ~
platform_device_unregister(&da850_evm_tl_leds_device);5 r( N$ h/ G5 E/ f- G3 O
' Y# V9 x5 w% K( l# E i7 S9 O
printk(KERN_INFO "LED unregister!\n");
- {3 C/ K0 j1 v3 V9 U}1 I% ~0 a2 U( N d% `3 V/ { ~6 D: p
6 k2 L ~/ P7 C$ d. B0 Nmodule_init(led_platform_init);
3 D* L! {7 w7 C2 H' l7 \( dmodule_exit(led_platform_exit);- v" s% _2 j) }3 G& f" n
5 D X1 {2 a" g& H' v4 ?8 g
MODULE_DESCRIPTION("Led platform driver");* f- H5 A2 J( X
MODULE_AUTHOR("Tronlong");
& u( _+ V8 H9 I! s5 n9 U: MMODULE_LICENSE("GPL");
+ p5 ~$ j9 V5 w. I) K
. ^/ i0 ^) h- m |
|