|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% u( c& n: H% m% H$ A#include <linux/init.h>
, k# k, ~7 g7 z4 u#include <linux/module.h>
; J N" b* w$ G$ J#include <linux/kernel.h># b1 w. H: _9 O( P- s
#include <linux/types.h>+ z% a; f2 S/ s" N- z0 z' T) d# ?8 E
#include <linux/gpio.h>) P, E$ e6 g! [+ y Q, e2 j- b
#include <linux/leds.h>
% q B" a1 s' \#include <linux/platform_device.h>
% f/ ^) q: v& N# w8 \4 u' b1 G8 d
+ ^5 h( H: T) L! O#include <asm/mach-types.h>
/ B+ q7 Q# _- G& w; {+ m#include <asm/mach/arch.h>
4 r4 S4 ]. ]- \8 y: b#include <mach/da8xx.h>
6 u0 ~% L, C$ Q& c% W8 O#include <mach/mux.h>4 a \5 w X! j7 X/ J/ [0 D1 P! }; e
' j% o6 x7 Y z% f7 K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 a p' u# p3 [* H3 Q6 U( {1 |# } E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 M6 B; A6 _8 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ e! F( s$ H! b: y! f- _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 x* Z+ G2 V4 x. @- Z
9 T+ Y4 d7 J2 {* V. m! k/* assign the tl som board LED-GPIOs*/) O5 D0 s- M4 p( H9 w y. o! `) Y
static const short da850_evm_tl_user_led_pins[] = {6 d% }* g5 f B$ P
/* These pins are definition at <mach/mux.h> file */7 S# X/ S* k4 t0 x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 f/ B, @5 I# a
-1
0 Q! X5 C( _9 `6 Y D};
5 l- f- l% z4 W0 u h9 G4 ^; H4 r# V# p
static struct gpio_led da850_evm_tl_leds[] = {$ F9 \1 {6 b' \$ Y( e) h9 H
{/ X" n. }. [7 l; H" ]; ?, C
.active_low = 0,
2 r* h; Y* d% ]7 N8 J: R .gpio = DA850_USER_LED0,8 D T1 p+ t9 ] e! X
.name = "user_led0",
6 {7 B/ d; @2 e! l: \2 g) T1 [2 | .default_trigger = "default-on",* L: J8 I7 i, ~
},* q6 d( B( h: G4 p
{) V G. m0 H# t2 p d
.active_low = 0,
( N. E( b' a. D/ @6 F" l# T .gpio = DA850_USER_LED1,# ?" f6 k- o/ c% K3 l
.name = "user_led1",
! l5 a% c$ T# z$ G+ }, h .default_trigger = "default-on",
4 U- G: g5 ~" N/ _; ~. S. F- S j },
; U& G7 A5 h1 O5 K; u {3 z, z) D, r7 @5 _, y" t7 y6 Z
.active_low = 0,
+ x5 {9 K( A3 T! D0 w) l6 l* L .gpio = DA850_USER_LED2,. w7 R( o! R8 P b/ n6 }( r
.name = "user_led2",
- Y0 _4 F& r1 L" w .default_trigger = "default-on",
" p5 `/ ^ `2 s9 E },+ `$ ~! n% q" Q. f7 r# t
{
9 j- Y6 |& c" n. P0 F, T .active_low = 0,
7 J3 }* \& O1 U4 a: G* J .gpio = DA850_USER_LED3,
# G& V+ H" Z. X$ z3 D2 q/ f4 \& G .name = "user_led3",6 J& o* Y. g+ Q5 g: S7 C7 B
.default_trigger = "default-on",* ]- L& r, d- M4 j8 z1 F
},. I- Q# c" p) y Y* X- K U4 L/ E" Q
};
; H0 f. ^% a7 h8 l2 T& f6 ~5 [; w$ k0 a4 a' h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 J. n! `& G5 F( r z4 e& X1 L" p
.leds = da850_evm_tl_leds,
* J5 ?8 r6 i) s# R a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& Z: i% K( r! k( f. n4 l1 P};
, G- E3 T% k2 v8 E: Y6 ?; \, ~, Q1 p w, O4 Z H7 n
static void led_dev_release(struct device *dev)$ W% Y) p! H0 w/ E2 x
{' ^8 j; n# i9 N: q5 S# [: p1 y/ |
};# |* q: w* q S! v8 U
4 ?2 B; [1 r3 R; `& q6 ]! {
static struct platform_device da850_evm_tl_leds_device = {
0 h5 h% q8 V0 r$ h .name = "leds-gpio",
# p; c* ]. _. E) A4 c/ t .id = 1,
7 N% C. J* f) Q# a5 m$ F .dev = {
8 r* m/ S; K Y0 ?. }! R: @$ _ .platform_data = &da850_evm_tl_leds_pdata, j5 U4 u/ R) ~
.release = led_dev_release,
1 t' d _8 {+ D7 m! a }
2 F) S2 F6 a# Z- j};" F, x/ w) e, {. x6 A A: V' E& x- m
3 x6 j0 U( O, D1 l
static int __init led_platform_init(void)
1 j) \- Z8 e5 ?$ K{
! |) j! m* m" | int ret;8 X, e& ^* `% }& ^" X% H5 }
#if 0
% p4 n5 j5 W. K( Z$ X* } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 |; S# A. g: h$ B% x% Q @$ q
if (ret)& G& w" T, Y8 i- i/ O5 G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% i' A4 @0 ~! a' b- f$ [0 V: I) E6 C
"%d\n", ret);) P2 Y. M L- B
#endif
6 L: q5 [1 G9 d6 n! [ ret = platform_device_register(&da850_evm_tl_leds_device);
r+ H6 I6 r5 k if (ret). ^, n5 n* \4 o& `
pr_warning("Could not register som GPIO expander LEDS");
8 |# Z( T$ S( a else, H3 X+ X2 z) i; h! [, C/ |
printk(KERN_INFO "LED register sucessful!\n");( U! K6 ]& @4 h8 C- d/ a" W
6 A& ~4 S" g: N. a: y3 z
return ret;
2 \6 W* ~/ w: ^9 h}3 W$ K* M* T& u5 l7 ]: t
; G& l$ x7 a1 \$ Ustatic void __exit led_platform_exit(void)8 ]. o! {* G, R5 X# x
{
5 a6 L0 c) Q- M: T- G% i; B platform_device_unregister(&da850_evm_tl_leds_device);
4 X |" ~5 t# N( U) t" f
8 E% O. R1 b# Z7 G! b printk(KERN_INFO "LED unregister!\n");5 I* f6 \$ D$ I7 J: J7 [
}2 a7 d; q' q0 G+ E9 x0 `; \, M& p
/ J$ e( t) `1 L! o: U
module_init(led_platform_init);
; Q% _3 X2 H7 K* P2 ]# k# x- n, Gmodule_exit(led_platform_exit);
/ k+ [) r; M# ~( g/ N+ L$ D3 m m/ k9 t3 P+ p+ g, R% K
MODULE_DESCRIPTION("Led platform driver");
; q4 O$ `3 L n) TMODULE_AUTHOR("Tronlong");: ^+ U5 {$ K9 m& G
MODULE_LICENSE("GPL");
. [! P2 @3 G- {& r7 Y) R4 H5 X0 }) a" S- F
|
|