|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 |: C5 `: {- x% d#include <linux/init.h>
8 Y0 ~. s" G. D2 V/ {' ]#include <linux/module.h>
J6 P. r2 n2 V9 y#include <linux/kernel.h>
% O& C+ n5 U; N3 g; n#include <linux/types.h>! U1 r; G! i( s. z
#include <linux/gpio.h>, ~' y7 a! ?7 T( N1 A3 j
#include <linux/leds.h>( h" `5 t' [% f7 }6 X" g
#include <linux/platform_device.h># ?" x/ m+ G7 J2 |% h5 D
& N/ [ Z0 ~/ ~. o" c; Y#include <asm/mach-types.h>
3 j; B& ?- R" E) u% |9 @2 Z" @#include <asm/mach/arch.h>
4 S; J. j% @* a. ~: T5 @) B2 K#include <mach/da8xx.h>8 G9 \! i+ \( l* U
#include <mach/mux.h>
7 F8 [) ~# L9 A' @. C
. b% R" R& p+ V1 Y% a# L; U7 z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 n4 N4 r2 g. R! J' S5 u* V; M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 B( ~" p: M- ~* b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); k x0 J, T; q3 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' P0 H5 I" c! o$ y* C$ H, p- Z
- X7 Q J2 x3 F/* assign the tl som board LED-GPIOs*/
) N5 j7 c o& b" Z k+ |static const short da850_evm_tl_user_led_pins[] = {' A- W- m) C E
/* These pins are definition at <mach/mux.h> file */
1 B' o' q+ ~3 F6 R: g7 I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 C5 o* n* y, n1 [; B -1
# A2 k9 `1 m! K Y$ i};+ z# o7 ^8 a& _: u! b
* ^% s0 I1 A/ D8 _static struct gpio_led da850_evm_tl_leds[] = {
- [& `9 D3 |4 o' q7 ]& W- y0 t {2 T7 y& w3 r/ p" g' [
.active_low = 0,
2 |7 ]# D) `, i3 D) F .gpio = DA850_USER_LED0,8 j, m5 l! \% c, M
.name = "user_led0",- o9 b! ] j3 h- V; _+ h8 N, D/ `
.default_trigger = "default-on",8 ^8 Y( H# u% J' i: T3 s
},8 C: v; J# r; V, }7 {, q& t0 ]7 K
{* A9 O& U- u6 j9 e8 ]& J$ J
.active_low = 0,
+ l) e3 ^3 _- S; P& r2 r. V .gpio = DA850_USER_LED1,, J' o9 c. t' d: L5 |9 x+ G2 s
.name = "user_led1",
4 c$ i; K6 W% z A1 |" g/ _: C& ` .default_trigger = "default-on",0 ?' ]% w& p" e& P
},
/ c9 a0 m1 u* B+ x {; N; i4 j/ o: ?+ [! O& h% } `/ R
.active_low = 0,7 M5 i! k% k) W- C8 H" K
.gpio = DA850_USER_LED2,0 \1 C% f+ J$ s2 T4 D+ q" o, @+ V
.name = "user_led2",( @. ]) X9 o! {; s; e. u- F+ q$ a' ?
.default_trigger = "default-on",) K: f! F9 |* G: }9 @
},# t- a6 w9 }: f x! f* D) |
{
9 v7 z- ^7 u; P% d6 i! a .active_low = 0,
0 ^0 }+ }8 ~7 \# q .gpio = DA850_USER_LED3,* P# i' Y& s4 I4 E0 U
.name = "user_led3",# S# R, z4 o! { H
.default_trigger = "default-on",
! n5 R# o) r% g- ^2 b% L },2 b; U' v/ |: Z
};
' E3 _/ ?1 w- i& a
0 t. `3 v0 q1 L4 l O7 ]1 ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& y* F/ V) f6 B# K7 e5 b8 l J
.leds = da850_evm_tl_leds,8 R8 v) ~; o$ @) `( M( _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, p5 z. ~' ^! d};4 M- g6 U/ H1 R
' Q: L+ X- e3 U* K d! s# Q
static void led_dev_release(struct device *dev)4 _7 P- I" e9 r
{) V1 w, v" @. F5 f
};; x. `( n4 W' m
+ q- A- f9 o7 M* `static struct platform_device da850_evm_tl_leds_device = {
+ I+ I2 n8 h3 y( R- | .name = "leds-gpio",
8 m, Z3 _( u. I .id = 1,( C& p8 \) `. A4 l( G
.dev = {
% o' s: s, E4 ^- D4 f4 {, [* C I .platform_data = &da850_evm_tl_leds_pdata," V' Y! p* f5 e& y; @3 l
.release = led_dev_release,
* D/ \) n5 f* C9 {6 x) p }0 J0 }, W2 A% k$ S- R0 o
};; |) w' @3 m! `3 R
4 Y4 d3 d' w+ P1 `( h Estatic int __init led_platform_init(void)0 _) R& E& K; n* L7 A
{8 X `' p/ \ K3 k* E6 g
int ret;; d4 b* B) N9 c
#if 0
6 \0 e2 q- ?1 D/ o" {2 X8 R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( ~1 J1 f; B& E. s
if (ret)
5 H0 f0 \7 _" q$ j X" S3 z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' s) y! r8 p" U" ?* o. n4 V "%d\n", ret);
; V3 X, V" U9 R, J% q1 n& J5 y5 B#endif
+ }$ x* p+ t9 C! J5 t4 p ret = platform_device_register(&da850_evm_tl_leds_device);
2 W( j+ z: V) Y" D- t! p/ K if (ret)
0 m' A3 u$ Y4 U' b$ l4 \ pr_warning("Could not register som GPIO expander LEDS");
! O6 F8 s; L8 Q0 x, I' ` else3 D3 }; }' h0 J/ |& P
printk(KERN_INFO "LED register sucessful!\n");
$ I/ a, W+ c$ S; q( p0 G/ a6 [+ A. b( o2 ]
return ret;, v) y. a6 o0 E0 r
}
: H- p. H7 \" m [7 k$ A
9 G K( R, k2 S- M6 g9 rstatic void __exit led_platform_exit(void)
9 Q& [: ^! U8 o{; C! ~# J# D) H$ ^8 n' K# t
platform_device_unregister(&da850_evm_tl_leds_device);
- d" X5 x4 B* T+ w; r2 O/ L
# J; T1 Q% l$ L/ i- T( f# D printk(KERN_INFO "LED unregister!\n");
' c. a& v9 ], b H# D1 F' @: P}
X+ f B7 Y" i6 t& ?3 c! [- u# X. m5 F' B
module_init(led_platform_init);/ e/ z$ _, E- ^' E
module_exit(led_platform_exit);
5 Q. u' H1 A8 X# Q5 o2 g1 T
; ^: y6 n- o+ D+ @1 V/ r/ f! `MODULE_DESCRIPTION("Led platform driver");
3 a" x+ ^, Y+ nMODULE_AUTHOR("Tronlong");. m( W% X( z- R7 D2 W1 n- x
MODULE_LICENSE("GPL");) e6 k7 @7 S0 g) p, P& L
4 H: W+ u% s/ z |
|