|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% S9 u- _6 Z7 O8 P$ V" e C#include <linux/init.h>, N1 B' e7 Q. F4 u* _( `8 E
#include <linux/module.h>, b& {; ?4 H7 K% q# ]8 Z2 A
#include <linux/kernel.h>
6 n( P) S6 R" _+ [ T0 q' A4 ]. e! m#include <linux/types.h>8 S. j% c! B, N# `# C
#include <linux/gpio.h>
3 A6 x: r+ R) n( l' x; K#include <linux/leds.h>4 T( V7 [ X( S0 \" G: e2 y2 ]. w
#include <linux/platform_device.h>
, G' x# V5 ~0 I( ]: x: i2 i: f( s7 b0 k, |1 h7 I5 p7 }
#include <asm/mach-types.h>
) X0 m& E8 b4 I. r# C6 q#include <asm/mach/arch.h>
' n& l5 X% g# U; v#include <mach/da8xx.h>
2 B/ Y2 X0 |( ?% H; N, i#include <mach/mux.h>. y' l! i; D& ?! j: Q, h* A
/ Q& e4 F; {3 i5 \& r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% P$ H+ S7 _1 F2 ~! \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 ? D( t0 L8 @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! Q; `& c: }/ T7 ~7 o! }5 r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. |, a i6 W* p; Z. v- u7 {+ z& |: a2 f( f/ t7 J
/* assign the tl som board LED-GPIOs*/' ?: K- N6 M+ x7 `) G
static const short da850_evm_tl_user_led_pins[] = {
+ V& j' D5 Z/ U# X' s& p /* These pins are definition at <mach/mux.h> file *// M m- f |2 i) J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( n |7 c, g) X0 S -1
2 | o/ M) `/ y' H9 ]" o9 l b' p};
9 E: U/ `( y6 u5 F: y ]. q8 B+ s9 S( p/ _) {
static struct gpio_led da850_evm_tl_leds[] = {$ j) M) G6 ~/ L
{
6 d& ~4 s& D* j9 w7 V .active_low = 0,2 v& g$ ^% v" G
.gpio = DA850_USER_LED0,
/ P3 W1 s3 n; E: U: t' X Y+ x$ B! o .name = "user_led0",% h$ K* j8 t3 [' i( f1 b' C( T
.default_trigger = "default-on",
3 t' ?* q r9 B9 L# g+ D },3 J0 C% }2 U! ~! F0 Q: @( t s2 u
{9 F+ k+ f1 C9 x- h! @6 N8 b
.active_low = 0,
% E! Z, X- H# e% ] X7 V; j; ^6 f+ s .gpio = DA850_USER_LED1,3 Y! U1 v/ @+ A: }2 E. N
.name = "user_led1",3 Y. z, S" O. {5 }) M
.default_trigger = "default-on",
/ f6 X0 N1 G( c0 Z },2 k9 {) b' ]* s' {9 F
{' M& V0 L" _9 E$ W6 M+ U
.active_low = 0,
; o* K. Z |' D) W( x Z .gpio = DA850_USER_LED2,5 B; q1 k+ @. A& p/ k5 G
.name = "user_led2",. Y* l8 u: r1 V
.default_trigger = "default-on",
' K2 J, s+ D# S ]5 }7 T },
! b' `0 l' V. ^2 L2 t! d {/ ]9 m' h# P: [( X
.active_low = 0,
% T1 [: X0 I& _/ g' F. e .gpio = DA850_USER_LED3,, D; b2 g' ~+ b! K1 M
.name = "user_led3",
) b2 v- Q, l+ F1 m .default_trigger = "default-on",
0 {" P. X( J. }. ~* Y: z },3 x1 s- G* N$ z
};# x* o. J: H0 ]+ [6 x
. S; m9 a- H4 K7 C5 Y0 |' S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 J: g! d$ Q T3 u8 s& |0 b2 i m2 ` I
.leds = da850_evm_tl_leds,$ I s' e9 a5 y* V- V2 P/ I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" C- P4 `! Q" n0 Y6 t1 c" z};4 v @& m- p+ [$ k& I& v/ J C1 c
* X& N# E6 W8 S5 P: o
static void led_dev_release(struct device *dev)
( ^* |4 h/ q4 G{6 o% ?8 h/ P/ g5 f5 i
};$ I* R- @9 Q) M- A+ O2 A
( K1 U6 q/ r$ D3 estatic struct platform_device da850_evm_tl_leds_device = {% q3 S& Q3 G/ |, ^
.name = "leds-gpio",2 R4 ~7 e. G! |6 t, d
.id = 1,
' k! `( W' F+ c# _) X .dev = {
) |; v; W1 U* N' Y5 V1 u .platform_data = &da850_evm_tl_leds_pdata,- X8 V) P- ?* G
.release = led_dev_release, T! f2 z; d+ l; ?8 O9 O6 \! d3 c. E
}1 z2 W* c; z, i6 x8 c" D. p
};
; {- @1 ]6 H( Z# r' P1 k
' j) r4 K6 [: v! I7 U/ v/ P3 r* v, Vstatic int __init led_platform_init(void)/ s3 z# E; a" O- y) y$ n7 F6 r
{2 t$ g( \$ {6 C" B7 X9 k
int ret;* J* `9 r9 i" _" e; U
#if 0
9 |2 d, k, V g8 }( T @8 ~7 ]) r8 Y& Y% A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 {% m: ?' P4 S" t6 Z if (ret)
) p4 s3 n% W4 X9 g* x" ~' R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* S+ y; {8 j9 h" o "%d\n", ret);
X3 c4 @ R' k/ m7 x#endif
. h# ^! q1 S: A9 R3 [$ M ret = platform_device_register(&da850_evm_tl_leds_device);. p/ H! {8 m4 ~/ H. k8 ?' x& h& I
if (ret)
1 s v& i/ ?: O+ F pr_warning("Could not register som GPIO expander LEDS");
D9 T$ ]/ E* @) [3 O else
9 [: h1 B* W! v" P1 ?- W' O9 T printk(KERN_INFO "LED register sucessful!\n");
+ v Q U- ?0 z7 {, p+ Z
2 m0 u8 X# `% J0 v return ret;8 X& {9 d1 H4 L+ R# n
}, A. T0 _/ X* x N1 |8 Q
/ J3 R- z( J7 A( Nstatic void __exit led_platform_exit(void)
9 ]$ V6 O! i2 ]3 d2 B0 x- E{
* b2 e& w( E" `: }) }. d platform_device_unregister(&da850_evm_tl_leds_device);
9 r0 q. o& T& F# P8 s0 i! o) m, W8 C; o1 ~
printk(KERN_INFO "LED unregister!\n");' b t0 k9 B. Z. R8 E1 R
}
9 ~0 P/ ]: H. m& m
# y; F* v7 N& t- L, [module_init(led_platform_init);
, A1 I+ ]8 M" z4 {: Mmodule_exit(led_platform_exit);- t% B9 X# _/ B# P! Z, `
" A$ `1 Q* V: s& J/ i" H
MODULE_DESCRIPTION("Led platform driver"); Y8 E7 T" _0 M4 v% I
MODULE_AUTHOR("Tronlong");
5 B6 \/ }8 H0 x! gMODULE_LICENSE("GPL");
3 ^4 a r6 Z/ J' ^/ O' y' ]& V4 S6 A6 E: T
|
|