|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 \8 O2 t, T& I: v3 h. O3 U
#include <linux/init.h>; f, h6 z$ W; _ b
#include <linux/module.h>
r$ i" }8 \% k0 t, u( p0 _6 f& s& v#include <linux/kernel.h>
+ g3 m9 Y! Y9 I+ A# {3 x7 r1 n#include <linux/types.h>
) V+ B) b. [0 ~/ `2 E: G% s, {' q#include <linux/gpio.h>
/ d ^( J! }2 y9 x#include <linux/leds.h>9 L& Q7 e9 N3 g; r# {( E: F4 p
#include <linux/platform_device.h>
0 `+ E" K- {) \) j
- {& k/ j) ~1 l7 m#include <asm/mach-types.h>
6 ^' F0 x# i6 E4 O. o$ F+ [#include <asm/mach/arch.h>( o; l& a- e$ I* U3 V
#include <mach/da8xx.h>
. A6 m' I! @8 j' ?( w#include <mach/mux.h>! F( S7 j+ f8 k+ x
1 d; I9 X( g- g, ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" G2 {* k; h9 Y* H8 R2 J; Y" f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); y& z/ c7 K4 \$ p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% W; ~- A/ k8 _$ P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# M. Z; ]$ v/ W6 }
8 j% g+ v9 i% l) h3 G1 ~/* assign the tl som board LED-GPIOs*/
* s2 _1 t7 M; |4 U! ~ {static const short da850_evm_tl_user_led_pins[] = {
* e, I% @' M+ d2 i Q& G9 `, l, V /* These pins are definition at <mach/mux.h> file */
; G$ R+ F/ l! B7 x4 b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- J0 i; ^6 _" E$ |3 A2 C& D. T -14 B) V' N$ _' z, r5 L$ w& P* N
};
( a, T& C" D2 V# ?- a$ ~
- B% ~6 h) f; @6 i, x# ~9 Kstatic struct gpio_led da850_evm_tl_leds[] = {6 x1 n; E, F x$ `5 F, v+ w" r
{
, x$ I) P$ k7 L- { c5 q .active_low = 0,4 @: N, {; H; J: G3 ~$ \
.gpio = DA850_USER_LED0,& F" K9 g+ h0 k8 L
.name = "user_led0",
+ a+ A* e; G# J2 {# w) f& u* W .default_trigger = "default-on",
6 P& Z1 L; ?% f0 v3 H# \! k },
5 l. R$ ^" U; ~$ Z s- z g: Q {
; ~" s5 R, b$ k Z+ D .active_low = 0,
t8 C3 U+ T. K .gpio = DA850_USER_LED1,1 `- J* _5 }" ?/ _; Q
.name = "user_led1",0 o1 g" k: _8 V* ~) z
.default_trigger = "default-on",* Z8 f' l( T. ^7 i8 l
},
2 c6 n4 I$ i% C9 D- S" L, w+ y {
% _4 q8 y7 _- c( h' L+ H6 J" F* p .active_low = 0,. n9 \- j3 x6 f- y" R( l
.gpio = DA850_USER_LED2,
2 F, }( c7 T: w: v2 P: `# n' B" U .name = "user_led2",
0 e/ M" O1 E" Y .default_trigger = "default-on",
( n/ @+ B4 B, x# M },5 F' ^" k4 W3 S2 ~
{) s3 d' p0 }% R# Q
.active_low = 0,3 V* C) N- t: R) G$ ~' Y5 l1 V
.gpio = DA850_USER_LED3,: c2 M. g" s9 u: W" u( U
.name = "user_led3",
I2 P* S G5 @5 i+ Z+ u7 c .default_trigger = "default-on",, R( ~. Z l, q% n3 E3 ~7 `) K
},
, B! i! }, `& Q( O};% g4 E# E; L/ u! Z' I
7 Y9 d8 i* [/ Q% F; qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 w7 ?2 @ [7 O# ?8 g0 C! ]4 g .leds = da850_evm_tl_leds,* _% g1 {, \$ ]. S/ K$ Y! z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# \- C+ s( [. s- R3 I8 p1 _) U
};
% M& t. i# y% t6 Z7 j0 r l" `( P0 m8 K! b0 C: S9 l
static void led_dev_release(struct device *dev)/ Y3 g* _. {* c/ b3 o
{
; g6 G$ ^! a. \. l+ K3 r: ~' q};
6 Z1 w4 E. f% [1 O3 h: Z6 J: E
( h6 _) Z( Y3 ^' P/ Dstatic struct platform_device da850_evm_tl_leds_device = {8 {/ K, w* D* j, ?
.name = "leds-gpio"," b+ y' h; V' s6 o n7 [
.id = 1,
( C! W' V9 w8 {7 [# M9 ?/ P- E! ]$ { .dev = {
) t) ?, |# B3 Y* n .platform_data = &da850_evm_tl_leds_pdata,
. U" s" L( T3 H5 n. [" m' T9 J9 k- j .release = led_dev_release,
4 i7 E( ~9 N, I+ K" G }
( ^9 n+ |& |3 m. H; H7 j2 g3 m};8 {2 e' O3 c! n) @" H4 a
0 D. l3 ?& W; |# E" z) f- p% wstatic int __init led_platform_init(void)
2 x5 c& _7 n% \7 B' A4 ~- @$ a# I6 R{
0 {, i& Z7 r0 Q) b3 ?$ v' R# } int ret;. w% S. A: D6 ]# {+ F5 }
#if 02 A9 S. X4 Q+ K9 g1 j4 i' P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% ]6 ^" C- \- I* s0 w" {
if (ret)
: X5 n2 b( n5 n, | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ ~/ H* Y& K5 F6 r: H$ Q$ o D* N
"%d\n", ret);
4 P9 X8 S7 f1 `4 p" D0 g#endif
1 G; r6 o2 q+ h" w( \ ret = platform_device_register(&da850_evm_tl_leds_device); c3 l/ Y' l$ U/ h: Z& U
if (ret)
& [; T; j: K3 G) [ pr_warning("Could not register som GPIO expander LEDS");
- O8 z% j3 w. ^ else3 x1 i% p/ u1 {0 Q
printk(KERN_INFO "LED register sucessful!\n");" i' ?: q, C* N4 s( i- m% J6 h
8 k- x1 f' u6 L% q% u return ret;4 P4 V9 ^* z4 T* ^. P0 t
}
" N: U K* b3 X( i
5 w, j# Q% V& ?static void __exit led_platform_exit(void)
- n8 O1 `( O4 q) g8 ?5 N{% z: I/ J4 f; x4 Q
platform_device_unregister(&da850_evm_tl_leds_device);) K4 \' Q( d5 J7 n0 ^0 M4 M Q7 R& d
/ V* w5 a5 T! b& @4 M& N# g8 i& A
printk(KERN_INFO "LED unregister!\n");
" R0 H( d8 ^& P* W}
$ J7 c' @0 v$ J) E% ?; x( R% V$ E Y4 z% k
module_init(led_platform_init);
0 @ W9 x3 j8 m2 {9 Xmodule_exit(led_platform_exit);
7 O# H5 y" z6 k% C- f7 U2 Z3 U" g) J
2 [1 v! }( [" n& `: RMODULE_DESCRIPTION("Led platform driver");
|1 D: ?2 V% R3 wMODULE_AUTHOR("Tronlong");7 S( B! q6 v" V1 F; E' |7 m
MODULE_LICENSE("GPL");
w: A% s. \5 r0 C6 l, i! |
# x% f9 m7 Y, X& H$ P4 r4 G |
|