|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 j2 M, `) j9 J* x+ o( R# x2 [#include <linux/init.h>! y/ e3 M; \5 e7 r/ g7 p) Z' w
#include <linux/module.h>
/ a* I9 I0 L f% y( G: U0 _- y, s1 @- C#include <linux/kernel.h>8 | [8 G, m+ v3 v& j8 F9 B
#include <linux/types.h>
( t/ v- n1 S5 P" ~#include <linux/gpio.h>- N9 A* |1 ^4 c' W. [; a" M
#include <linux/leds.h>
$ ]; E" W2 o+ S" h. A5 |; [. \# O#include <linux/platform_device.h>
. d5 a2 U- r+ d- b7 x
$ j- p2 D& ]+ H- g#include <asm/mach-types.h>
% e, G' P& V& W5 d#include <asm/mach/arch.h>
# S( J) l, I( L6 J q. \4 M1 X#include <mach/da8xx.h>% G7 y1 Q4 L2 d ~
#include <mach/mux.h>' Z' [9 c" t$ J! T4 @( q/ g
! ~8 ~9 m( q2 r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! K* g& ]; E1 H* V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ w& c. M# p7 M& B$ x0 N( ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, q+ o* C$ H3 Z$ L7 r; P2 r- x+ }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 D: {9 c7 D1 E1 M( Z/ L! B% ?. n
7 @( K+ `5 k, ^ [7 ?
/* assign the tl som board LED-GPIOs*/
3 h, @1 e8 K& Q6 m; ]) v5 astatic const short da850_evm_tl_user_led_pins[] = {0 p* p3 r. r& Q6 _2 v. e
/* These pins are definition at <mach/mux.h> file */
% c$ ` v7 S. L% n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 u0 F; g9 K) N5 x5 M* p2 y( g -1" i1 ~/ e. |$ c8 u5 U D [% P1 f5 o& E
};
+ ]) Y/ e% d* M0 \
* S- l0 V+ W( f6 G1 ?3 Nstatic struct gpio_led da850_evm_tl_leds[] = {6 S! C) B- W2 |. k
{
]$ \7 V% n, P .active_low = 0,
9 a( k7 W; l! {" [ .gpio = DA850_USER_LED0,2 \% h; z) p5 b: i% Q1 l2 e
.name = "user_led0",
A; G" ^* u9 C5 K/ _9 w .default_trigger = "default-on",
& B* S4 T, G2 F. l. T; t },: ]2 k. @4 ]8 e8 f
{2 O1 r% }. S/ b; m1 A4 z
.active_low = 0,
7 z6 m; v) \( ^ .gpio = DA850_USER_LED1,1 ?+ d* u$ z. i( b9 g
.name = "user_led1",
3 k+ }9 Y% c, c% y6 h .default_trigger = "default-on",
5 g7 a% E2 U; U( l },$ x# j! x1 h& u! O) ~! y9 P
{% o+ j6 a) k# C* Z
.active_low = 0,# ~) K L& H0 \$ u5 x
.gpio = DA850_USER_LED2,9 w/ p3 J+ x/ f7 m% A# z3 p) ^% @
.name = "user_led2",* I- o8 o6 d% S5 }2 v7 F9 d
.default_trigger = "default-on",
+ x% Z2 ~$ k* A I# c7 |% Y! k5 p) _' { },
. c5 P Q: r: D' V/ L) U {
' f3 r+ n, Y3 C* s' y3 @, c .active_low = 0,) `# {+ r& c7 ?" S
.gpio = DA850_USER_LED3,
7 `$ u# x9 W! V1 ` .name = "user_led3",
; W: f% g% M# _7 t .default_trigger = "default-on",
& q4 N- f- _3 Q, a3 x, O) y( | },9 e$ m! Y- d, ~" b& X) ]! J
};2 X0 [7 _4 l$ {0 K$ w6 q: h9 q
, T; _) n6 G" U% J; B8 J9 g: cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ j5 z l5 a) ]$ Q x2 D
.leds = da850_evm_tl_leds,5 B, E7 E+ v9 `% H" p, Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 j9 W1 t8 E3 i. U
};" t9 B. j* U7 A9 S+ h( b
! |- f9 O. P; }& Y
static void led_dev_release(struct device *dev)
* [3 E+ i6 j; M7 ?{1 @+ f' s& V7 |) B, p- N2 w
};
9 R& z7 u. [4 R" m) r0 s' ?
4 u' ~) x5 o2 ~4 P t' _" s% Gstatic struct platform_device da850_evm_tl_leds_device = {
! d* K1 F. S. U" t% D& L! `, x .name = "leds-gpio",. ~9 ?' h) |3 a/ w4 E n
.id = 1,
5 p y; Z/ d6 ` .dev = {
( {- ?6 A7 L. S) V% D! K) ^& h .platform_data = &da850_evm_tl_leds_pdata,& M0 e8 b( V+ l. ?
.release = led_dev_release,9 y( n/ @) L) [/ P5 h5 e$ ~
}: T) i, [# S; F$ B, b" T
};* T1 S- J/ l+ d
( E' W$ \, [& B6 i+ [% U& ^
static int __init led_platform_init(void)7 F0 Z2 ~& B) p8 @/ E: O+ q4 D
{: \" O8 P! P; z
int ret;! i4 s+ U w* I% S
#if 02 ~( X. l, r: H+ O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. M" [/ i$ }$ z7 N. {. f if (ret)
E# q3 p* I I/ m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 R! ?5 G2 D5 V! h# M" E5 y. G6 r
"%d\n", ret);" ? T* A8 e$ x
#endif( u. N- N- E0 D7 n$ a8 i+ J6 I
ret = platform_device_register(&da850_evm_tl_leds_device);7 g; M) @8 ?- Q+ d5 t+ f
if (ret)
+ D# ~+ B! d7 J e7 p) f5 m pr_warning("Could not register som GPIO expander LEDS");5 o; @0 a* F/ R% O
else
: r- M# L& x. Z3 ? r7 S1 b& s printk(KERN_INFO "LED register sucessful!\n");
/ Z2 S& ^1 i% W1 Z8 |
4 I* g: K7 D0 h return ret;5 G' X; r$ z5 t: u) A+ R& l L
}- _5 r% q* |4 { Z% g
, J# R) B4 y9 \# X/ V3 V+ [1 |. h
static void __exit led_platform_exit(void)( u$ R5 W7 d' H8 O, K+ \ n
{. j- K2 R8 ?& U1 e+ m3 E
platform_device_unregister(&da850_evm_tl_leds_device);
/ ^0 Y. P7 g m9 n0 v% {& a: w, P6 {: M9 U/ `3 n; n) p1 T, R0 z/ b+ N: w
printk(KERN_INFO "LED unregister!\n");$ V1 t/ A' m: J& V) o% @
}9 Y0 e) V2 m' F8 v8 S
' J) J* F7 X0 p8 A5 ^module_init(led_platform_init);( A) ?, {: W% f' g
module_exit(led_platform_exit);. ^2 m9 ^- X: j \. z) R! Q& T
# [4 J' I5 X2 H) I+ s. XMODULE_DESCRIPTION("Led platform driver");8 Z$ m! l3 a, D- o
MODULE_AUTHOR("Tronlong");
) U$ Z% z/ f1 IMODULE_LICENSE("GPL");
/ `) [: `+ r; i
! n0 V% `7 E6 w3 z6 |8 l9 c |
|