|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 N% ]5 i" @8 `: z n X#include <linux/init.h>
. @& r# Z( P6 w" \ J#include <linux/module.h>. \5 u0 z9 @. z* {: @7 U7 n
#include <linux/kernel.h>) b- s/ l5 V8 [) H- x9 M+ h! ~
#include <linux/types.h>
, K! ~/ ?( ?: ~0 M( U5 S#include <linux/gpio.h>
1 S$ C9 j; R( ^7 e* h4 Q1 K4 H#include <linux/leds.h>: E D: N& l/ t: E
#include <linux/platform_device.h>
4 t5 i( V! J/ L8 q+ t* g/ v8 I" P& P1 ?3 d
#include <asm/mach-types.h>* l+ [, u% c5 H9 C
#include <asm/mach/arch.h>
1 {8 \% U6 f- @. a. E#include <mach/da8xx.h>
0 C+ i9 m( p, ^6 m( C( X! b8 m" N. @#include <mach/mux.h>
+ x* W, k. @- d: l8 @5 v7 V% |4 M5 f5 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 t/ v' W9 c( S# v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 x- ^- n. M, _) z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ V; z* A5 P+ `3 |! F- l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) @1 I5 s Y' Z C8 `
* h/ S; K; L/ ]; A1 w( {3 D" I* x/* assign the tl som board LED-GPIOs*/
4 @; e1 l2 D( s' c# t& Q }: `static const short da850_evm_tl_user_led_pins[] = {
- u; a5 f8 @* ~- h, p& j /* These pins are definition at <mach/mux.h> file */$ u& ^: ]6 x6 \- ^9 r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* j6 T# D. v+ m) c; {6 X' a+ e -1
! g( {$ I+ K7 m" p};
$ H4 ? D) T. X* o% c# K
; M" B- E- o; i5 K5 c- {static struct gpio_led da850_evm_tl_leds[] = {4 J" }# l$ a& ~0 U) `% X
{0 \) N! u, w9 m% ^( H0 o
.active_low = 0,& ~9 d" \8 y4 P" W. \6 o# U# y. i
.gpio = DA850_USER_LED0,5 c* J9 t( o) ?7 [$ q
.name = "user_led0",6 S1 g+ k K( ~: |# Y0 B, F8 F3 K
.default_trigger = "default-on",
5 J) k3 I# T% I! f' z }, w) U; T( M J7 j
{
8 i& k/ s5 }6 {/ z# C .active_low = 0,
" ]7 U; H/ y8 ?3 g1 B .gpio = DA850_USER_LED1,' Z6 c5 Q- C. b; z
.name = "user_led1",
5 u; L: N9 x6 o' R, T. I" ?: _ .default_trigger = "default-on",
# S( g0 X# v. K- O },( {4 E" d5 `5 o5 U( u2 X4 j9 R. @" N
{. o- Y" v0 S2 b9 c6 Y' I2 z+ v
.active_low = 0,
3 {# }& ~6 ?" U: C, n .gpio = DA850_USER_LED2,
; N9 x5 G0 L6 A5 j# C .name = "user_led2",
( X/ G$ l6 q/ K$ c% M% T .default_trigger = "default-on",5 i" r+ y5 G: Z1 K
},) e2 D' M. y* x- ~2 {, `
{3 B2 K$ }4 U- V c: o+ k
.active_low = 0,1 q8 Q, R [9 v
.gpio = DA850_USER_LED3,
' P' C. t, D+ T) l. Q' I+ e .name = "user_led3",
) P+ d) o8 ]/ [ .default_trigger = "default-on",
0 F4 \) S0 h( }0 q0 U7 |6 p },+ K; ?# U. h" W: k) ^8 e1 R3 Z7 h9 B
};
8 G+ Q+ {) s4 z- U% j
A+ D- Z7 C8 M( Z8 M4 Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# q* c) @, ^$ m0 B, T) e .leds = da850_evm_tl_leds,
7 V* B# l$ J$ ^/ Y% E/ A* {% { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( v# w& H3 q8 V0 V
};
* T9 f' Y# G6 Z' I+ L6 T; }
! M6 b5 j" `+ G. R8 pstatic void led_dev_release(struct device *dev)
; j# H! w( U7 i$ C0 S. ~2 y: S{9 l" W' W9 S3 X0 m B" a: E5 Y* L
};
7 P$ I$ z( p- F9 K$ _! a1 x4 {; L# l- @5 J' w2 H( W
static struct platform_device da850_evm_tl_leds_device = {
: P! x* W. |# x7 w6 N8 ^: V5 i6 L! V .name = "leds-gpio",
) n. j& q+ V* Q0 @5 n" w% `( ^ .id = 1,
, U2 X2 p9 w/ a) H6 e5 H .dev = {% K4 k! H' `! M: [- s; J
.platform_data = &da850_evm_tl_leds_pdata,
' X. @& V0 k; e: K7 p y# B .release = led_dev_release,' u) c% A) V7 A( b0 F, V
}1 }! d: u; f i5 D) K9 U3 f+ \
};
. R2 Y/ A) l+ b" e
- z3 n# R3 F3 P& u: Zstatic int __init led_platform_init(void)# {/ o+ n- n- o7 G
{
6 X# X# r7 R+ V' F2 k int ret;
( x+ R& A8 ?1 t5 p4 Y3 s#if 0* r* r! A' l, u4 P. ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 L. o1 K2 o1 M. \& d) b7 i if (ret)
4 i% X9 C5 i0 V( }) q2 F/ H/ ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 d0 y6 @ Z* K9 Y! Z
"%d\n", ret);$ l5 E0 l4 ]' w! ~* K. J" M
#endif) m6 c3 I. ~( p
ret = platform_device_register(&da850_evm_tl_leds_device);5 P ]5 _! O& B: P7 @; c
if (ret)6 e% r( _! J; u/ V j5 U# h2 j
pr_warning("Could not register som GPIO expander LEDS");
; J* S6 b% q8 n4 T5 X$ `! _ else
: ]' ^5 j1 ]; A: f5 F) e6 Z printk(KERN_INFO "LED register sucessful!\n");7 `2 h: e. _* ^0 q$ g+ {
0 K& g" }3 {5 s/ I
return ret;+ \, B$ U' z7 u3 ?4 f. H. _9 i
}& h t) Z$ z5 ]3 p. h
" \6 ]* _8 l* l& Tstatic void __exit led_platform_exit(void)6 ?4 l- n# ^0 ~6 g B
{ j: W: \( v4 k3 o; G& m
platform_device_unregister(&da850_evm_tl_leds_device);
" ?( Z" W( y; M+ E, R7 [6 K7 a H- c( d
printk(KERN_INFO "LED unregister!\n");
+ o6 Q* }) w; E8 ^7 Y4 P' f}
6 t% j5 h8 D6 V; H+ W3 T
9 z# D. d/ V9 _! Y0 Jmodule_init(led_platform_init);0 c" n: \. A) M3 W( k% A
module_exit(led_platform_exit);
& W. J! z( Z( x) e9 z1 |: K1 U0 B4 R" p8 s# q- x6 B
MODULE_DESCRIPTION("Led platform driver");
8 L2 p7 ?. Y8 h! d5 {0 s3 XMODULE_AUTHOR("Tronlong");
5 [' L8 z; R( FMODULE_LICENSE("GPL");9 N, t% b' R* q5 d; |: [
0 B3 t+ J* F3 H5 M+ }2 L$ I, A
|
|