|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' I+ D3 y3 U: j#include <linux/init.h>
& w& T( o5 W6 \( l- C' ?0 \#include <linux/module.h>. U: T9 k1 h4 h. ]/ R: l
#include <linux/kernel.h>/ e+ Z5 L- ^4 w9 K' Z% u
#include <linux/types.h>- ?2 `7 s& z9 \2 C& `8 S" C, s6 S: S
#include <linux/gpio.h>
% C) T0 R1 ^3 |#include <linux/leds.h>
% N( n8 f# ~4 r5 h1 i#include <linux/platform_device.h>" d5 x! W9 W" J' i: p
1 A* h* |! d6 G" h; C2 P#include <asm/mach-types.h>
( E/ P- @% W0 K) I; G#include <asm/mach/arch.h>( a4 c- s8 H. F6 X U g6 H, m
#include <mach/da8xx.h>+ o% D1 ?; i1 b8 {
#include <mach/mux.h>) @& c% X, J, a& J, m1 Z
; ]. Y w- i, R2 ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 l. E$ G6 }- I' d: w; M, J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 R. A# k/ X- l( g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' J+ _* X G% w1 r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ U) t A; ]2 ~4 Q: F! p" B' D6 I. q( n2 u( b, ^
/* assign the tl som board LED-GPIOs*/+ a9 G, k$ g. H
static const short da850_evm_tl_user_led_pins[] = {
' g' V6 a1 w) n9 z1 u /* These pins are definition at <mach/mux.h> file */7 a, o( `+ Z- e' r; M9 j& o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ ^' a0 M6 L$ o6 b -1
5 I& W% H& K7 L. i' X* X};
. p: }& m9 D( i+ j: m: D
- @3 K* E; P' ~: {$ Hstatic struct gpio_led da850_evm_tl_leds[] = {" T1 ]2 p% ?+ l/ n
{# t' c8 H5 ^% `, t+ u
.active_low = 0,9 E7 v/ w# e# ~$ |% \. S/ x- t( I
.gpio = DA850_USER_LED0,
/ |3 b+ U5 S2 F .name = "user_led0",
! X( o& u$ J2 w: ]- t" b .default_trigger = "default-on",
: E* A# Z0 H- y& l+ R },
2 F8 `0 A2 N9 r7 ] {& j9 S5 I2 m6 X @2 O
.active_low = 0,
$ o5 w& |$ r9 i' W+ u .gpio = DA850_USER_LED1,- i! J9 `8 V( s
.name = "user_led1",
$ r; f# i1 ?& w8 L$ F# w4 W Q .default_trigger = "default-on",( U+ H+ p9 w. W0 f* w. m7 m- I
},' G; o! r% E+ H X/ u
{: z4 t6 P9 B l% p8 v5 `: G& }. E/ z) V; e
.active_low = 0,4 d- h9 M' t" T/ q1 W$ L: M
.gpio = DA850_USER_LED2,$ ~" i# l m" z
.name = "user_led2",: F2 N2 A3 z. f \& h& K
.default_trigger = "default-on",- k: b: {! S! ?* g
},0 J; q1 H$ g: a6 q+ [1 w' L4 I
{; u5 G$ b$ v! J: i! i. w$ K: l9 I1 V
.active_low = 0,, r0 d7 @7 U; C4 q% @$ e
.gpio = DA850_USER_LED3,& ?. ]3 y V2 B" F3 P& _% U, @; t
.name = "user_led3",* [* g0 H) w' N
.default_trigger = "default-on",- T- d6 O5 P; C) f; b; }
},
# X* o* N, h5 b0 G3 O+ `) T};# x* @$ k7 K! N/ c" M3 l
, I9 ^! t4 ~4 k Z i/ z' Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ P) l2 S8 W$ ^& b* [% h2 G
.leds = da850_evm_tl_leds,
2 L1 s; z6 P! N) U/ ^, y1 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! Z- N8 ^3 K% f; z! j. n
};! N8 p1 [) @# z
2 w5 E" @* d9 e. f7 q1 ]& Y: ]
static void led_dev_release(struct device *dev)
! o1 v% B" w7 \# s{
+ m1 M) T6 q. B2 d8 B" f* l};
# s& K( M8 i% y. J+ V, O6 [# O- F; @/ l- B: h. s/ W
static struct platform_device da850_evm_tl_leds_device = {
6 b" f0 J2 J/ z3 a1 N$ h" a .name = "leds-gpio",
0 A( Y8 H# L* R" a# y0 L' L .id = 1, Z4 c8 G, z7 w* M9 ^* X/ y
.dev = {: R. E3 P6 M- ]5 R* f
.platform_data = &da850_evm_tl_leds_pdata,
. R; }' v) O, _5 R$ b! Y* R; s .release = led_dev_release,4 e& ?) l3 X1 }* a
}
# c4 t" J* Q# k7 D% r& M j};
( G! N+ K1 w: j9 I% ]7 @+ v+ ]
- j5 z) i2 l' O& Ostatic int __init led_platform_init(void)3 ]5 \2 W) r+ r: y7 i7 n4 b
{
5 _8 p5 M) w9 ~4 O int ret;( E: d# R* Q6 W7 m% e
#if 09 d& P1 C1 ~8 A: r$ [* W8 A; j- P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! e2 E7 w4 X4 C% @; _
if (ret)
! x j1 y( w3 m$ F+ ?; J" X- U; ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 `# z! s$ w0 ^8 A, a "%d\n", ret);, h: |0 @; o- U ^) a9 i( T
#endif) A/ F. Y) y+ _2 m, m6 U; p
ret = platform_device_register(&da850_evm_tl_leds_device);
" y0 \" m% S: L if (ret): k6 e4 {# D \0 n2 `. C
pr_warning("Could not register som GPIO expander LEDS");
" w0 n* R8 {8 r% V5 W2 M9 w; T else
) W; {( J6 E" |- A printk(KERN_INFO "LED register sucessful!\n");9 Y0 L1 h2 L: ]3 |2 c x
* `' ~$ b* ~/ j" \7 i- L; D return ret;2 w2 ^# L+ H* ~/ h1 x4 b
}
9 L: i3 a- Z) }. X i' m) e
* ^. h% p5 c3 @& Vstatic void __exit led_platform_exit(void)
4 Z+ U$ M) {7 F: t* v" G6 g6 i9 y{
+ \8 E0 g7 B' t* f8 C& ?0 I/ D2 S- j platform_device_unregister(&da850_evm_tl_leds_device);) ?0 r5 l& m7 n; ^# `, K9 {- F
+ ^6 t( H P- y/ z# a$ D printk(KERN_INFO "LED unregister!\n");
) w5 a. m0 [7 w* i' k$ ~; z5 d}8 i* v! D% h% K/ Z
+ A3 B( w2 W$ Y! E' a9 \
module_init(led_platform_init);+ Q1 h9 J' \" x( V$ s! {
module_exit(led_platform_exit);
* |, V9 a0 z/ c; [; b+ S* K L1 x/ y& t- r1 o% p
MODULE_DESCRIPTION("Led platform driver");. X. `: D Q5 @- s, S
MODULE_AUTHOR("Tronlong");
7 _! w; K* e' Q) l, l+ v6 ]MODULE_LICENSE("GPL");
7 v; I9 C' _3 }2 W% W
) B. N) t+ ~+ ]5 B: w |
|