|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 i. O" Q6 t/ a#include <linux/init.h>0 k; K8 |( P, l5 |
#include <linux/module.h>, o8 c* ~9 z% M- [% ^
#include <linux/kernel.h>
1 |2 ^! n0 e. u( Q) L#include <linux/types.h>/ \+ U% U# Z% X& x
#include <linux/gpio.h>
2 X! p- q1 ?4 V: ?$ p/ m" G, a#include <linux/leds.h>, y% n# `! \9 m/ F0 Y$ o0 v n
#include <linux/platform_device.h>( P, |1 W' _; J: O! z- C
) f1 W& F' e7 i$ I! n: e#include <asm/mach-types.h>3 d4 z: U. W+ `- r+ j2 b+ m
#include <asm/mach/arch.h>4 C* T% k# F8 s5 O" J
#include <mach/da8xx.h>( V4 N4 W N3 h. ^$ n0 S0 @2 Y
#include <mach/mux.h>, I2 z7 P0 |- ?6 R5 T
: [2 u0 t; Q2 @* b9 d8 H$ V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 f# E) X! I* _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 ^, }) a( {7 c3 u( W2 a; Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 o( Y# E, u& s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 o9 F" I$ w1 c I* L0 A5 r; w
' J: P& a: }1 _1 ~/ N1 q5 T0 r
/* assign the tl som board LED-GPIOs*/
9 n2 Q2 p, ^2 E. astatic const short da850_evm_tl_user_led_pins[] = {
& V- x. ~" b4 N( E% I+ D4 q /* These pins are definition at <mach/mux.h> file */: ^; u/ w6 \( |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ K( ^" i! b* ~6 ^( Q: K -1
( U. P3 |6 V/ v0 X7 }/ s};* Z J8 k, ~$ v- ]# k: v
4 e/ Y4 Y: L, \6 t( H4 S
static struct gpio_led da850_evm_tl_leds[] = {* s7 k' A! S' C) x. t, W
{: @: Q4 T" i8 H- q4 h, P
.active_low = 0,! T6 [$ r' {- ^ Y. I/ I2 b
.gpio = DA850_USER_LED0,5 g B$ n: K+ \
.name = "user_led0"," Q" r4 f' Q t! G/ H) n
.default_trigger = "default-on",
; q* `% S; U! p },
! z& ?5 m l* n- o {* A" ~" _, @% E
.active_low = 0,
7 T0 Y8 ?, I$ ^) h5 J# Z N .gpio = DA850_USER_LED1,
- T* n6 K: M; v9 k. b .name = "user_led1",: Y& ]3 v: w# [3 K
.default_trigger = "default-on",
% W) j" l8 i2 O4 t# z },
6 ?: x3 T: k' V; M- N2 ~ {
' r' N1 I( [ f9 q8 g' O' U+ _3 W3 u .active_low = 0,1 c( [% m# `% P
.gpio = DA850_USER_LED2,
9 m ^2 [! g( o% H( ~ .name = "user_led2",2 J" c+ X, y1 O3 ~1 t! r
.default_trigger = "default-on",
( X! y3 T* l3 M% w" H* D5 ] },5 [$ S6 X. U( Q' z3 r
{7 @+ K; d0 h; n2 M7 v6 W1 z
.active_low = 0,9 ]" k8 N: d' f4 k! [: p
.gpio = DA850_USER_LED3,
, b# \5 h( o- B+ ~& \ .name = "user_led3",2 x( B3 G m. `. ?4 r
.default_trigger = "default-on",
* f+ A8 K3 O# Q* ] },
; f& A! m& h* u};4 d, H" |9 C* f5 O9 y
% K0 E R7 H6 n) K9 ?+ Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { U4 T8 ^( n: _3 l, @. k
.leds = da850_evm_tl_leds,
1 a) J1 D- K. n4 E1 L1 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ Y1 S( I% f7 Z/ w& r+ [};
6 z( z# R8 Y2 g/ a/ ]8 f% V
! V+ K5 b9 i* u( Vstatic void led_dev_release(struct device *dev) V+ E4 [, j) L+ `
{* c) O& ^" |, E- @5 |' {+ T: ?
};
! f3 Q U/ p& U, g( v( R' I! a: G+ ?" ?( s7 t0 C& ^
static struct platform_device da850_evm_tl_leds_device = {
; I' \( ~6 y, t9 f9 q- S .name = "leds-gpio",
& ~/ ^3 n) E+ P! w& Y7 R .id = 1,
3 ~7 Y) Z$ q! N) l" x6 G .dev = {* a' M4 G! G) E: z# W) [! j% y# C
.platform_data = &da850_evm_tl_leds_pdata,/ D% d J/ Y4 ]( m. H. h; U2 u
.release = led_dev_release,
. \5 r. c/ E- U; @ }
( R8 H4 U8 T/ \3 H& u- l& M};5 W3 G: i1 i8 e; s* D! I
X$ D3 G$ m/ g6 i
static int __init led_platform_init(void)# n0 l) C6 u: V! `8 U9 h" @
{8 v' }/ `4 N2 g6 ~
int ret;- f! c- m. B9 s+ O# p( O
#if 0
. s+ K8 s& J; v" e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 h( t$ A, t4 F) P6 u if (ret)) y- ]2 m* l: T' f" D1 ?+ |; n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! W, G. i! a& h6 d
"%d\n", ret);
4 d8 E% s5 i0 Y( X4 A3 w1 e. o$ w3 p2 a" A#endif
& Q! e& E1 a3 d+ h3 H) e ret = platform_device_register(&da850_evm_tl_leds_device);
# u5 C' x* U& K: l3 e1 H; \+ ^ if (ret)7 l/ ?8 V; \; M6 G U
pr_warning("Could not register som GPIO expander LEDS"); k. o: ]8 G: U3 @
else3 X \0 v3 I1 H. z. a! {' x( |
printk(KERN_INFO "LED register sucessful!\n");) g$ P/ W5 j. q' [* k
1 q0 N0 u0 A5 A) r! i9 N/ }
return ret;! o( P+ X6 L6 x/ [, g7 y0 _4 Y
}
# F4 h$ V- P' J) Z" p! O7 M0 Q: b
static void __exit led_platform_exit(void)
7 f& F2 u2 B% R) b4 ~: @* H6 E{& V+ N. b/ i5 i5 b9 d; E$ y
platform_device_unregister(&da850_evm_tl_leds_device);: E/ i1 I0 A! S% T! w {. V3 ^
6 v# H6 H8 G0 B0 C4 U
printk(KERN_INFO "LED unregister!\n");
$ R1 V9 E6 U$ v) D: Y5 f}
. h" g0 R! J7 V# ^* e" U* l6 ]
module_init(led_platform_init);
t9 [9 |+ ?/ ~0 x$ h3 z8 wmodule_exit(led_platform_exit);
. y: S" `' p% l+ C9 }; K _. @ E |+ F# q4 z7 {
MODULE_DESCRIPTION("Led platform driver");" y0 v' p8 d! C; t, x2 {, g
MODULE_AUTHOR("Tronlong");; F& [( ~. [6 R7 J }5 @
MODULE_LICENSE("GPL");
u5 j, t$ _8 Z
; \* v) Y$ f0 g5 e3 h |
|