|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 d2 L" [: r( z
#include <linux/init.h>
/ w" M# _" k" D#include <linux/module.h>8 b1 x) k# h) K3 z/ `
#include <linux/kernel.h>7 }7 y- Q) G( E7 z1 l( s" I
#include <linux/types.h>* C& v( D$ R/ _4 E) X9 C
#include <linux/gpio.h>
* l- P7 m+ J, u4 z& v0 A#include <linux/leds.h># @% v; F, N+ S) k0 [9 B/ [1 @: I
#include <linux/platform_device.h>
8 f$ k7 W8 W7 v8 _( l8 Y+ i1 j0 Z8 ]# ?# p+ T
#include <asm/mach-types.h>4 L( s2 U+ D4 i+ t8 x
#include <asm/mach/arch.h>
4 c/ A, m" S& k9 O$ i% K#include <mach/da8xx.h>8 v/ B% X& ^! _7 F
#include <mach/mux.h>
' x# o" }- H0 S' S* G: e5 W: \9 x) G( Z: ]. G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: w \) W) k4 V J: f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ g- g# R7 x5 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) \: U2 C- p: L" }8 w9 m; ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) f9 k) Y- m( k6 O
6 q1 ~7 O t- t+ X" R) w8 n h/* assign the tl som board LED-GPIOs*/6 D; y1 y% q* \+ \
static const short da850_evm_tl_user_led_pins[] = {6 \, k+ Q8 l3 U1 p$ K; v% U& u
/* These pins are definition at <mach/mux.h> file */
- T5 R6 L8 L) S: x& @$ G: p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" C, u! H# _2 ~% d8 }5 g2 k -11 @, X$ S+ ?2 t4 b% X9 O5 M
};$ N E. c5 l* X1 {8 ?
9 U$ r! {2 C; Ystatic struct gpio_led da850_evm_tl_leds[] = {5 {# S: ], ~6 k, Z& J8 X
{
$ t3 K ~ W$ _4 h4 \ .active_low = 0,! G5 G n3 O6 M9 l
.gpio = DA850_USER_LED0,6 ~8 ]% N! L# }2 y
.name = "user_led0",
9 t' Y; W0 q7 y% [ .default_trigger = "default-on",
; H6 M ^" q% [- a6 p },
( R( a) S5 ?- F3 [8 y1 H {6 y9 T1 i' T( t r4 A( E- ^
.active_low = 0,; y1 m" d. e$ y( f9 S( r2 y( \
.gpio = DA850_USER_LED1,
: x# c" S$ r4 i .name = "user_led1",2 B5 q# y- s, J( I# c& U6 e5 J
.default_trigger = "default-on",* O& L3 n8 H @! w* i- v- o
},3 x& j( E# R& O$ s' H$ i
{( i& b# B F$ R- ^
.active_low = 0,
6 \, e( J5 R- {2 B: S# b- R4 M0 }% V .gpio = DA850_USER_LED2,
2 d9 }5 ^/ F- G5 J4 @ .name = "user_led2",
7 X$ ~2 S8 N7 p( ]7 t4 h8 B' ~/ F .default_trigger = "default-on",
, r' X3 X/ X m% \ U },
% M! a4 k6 m: O9 M5 K. _7 @* m {4 M' E) \) h% _ r( _. Y
.active_low = 0,
/ d. O- b; C* }) A' K( q .gpio = DA850_USER_LED3,/ \; @8 {& h/ W# ]' o- R, f
.name = "user_led3",
- m* l8 c, \% ~ q1 y; ]7 l' W .default_trigger = "default-on",
; k; ]6 t7 Y7 A1 O0 t },9 t' S9 V. A5 J6 r5 Y p
};
; \7 ^+ W: D8 }# w- e, }' ^" {& V, B. w2 T: [% y. w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! M; H$ e) o4 ?; o' e& b' F2 `& [ .leds = da850_evm_tl_leds,1 s: S1 N& {) l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: N) E" w9 N: X( r! s$ r
};( \1 W/ }% J- b# a* ?9 y# z- O
- N) ~! W3 j" Zstatic void led_dev_release(struct device *dev)
) c" B/ ^% _$ A% m3 L' D: m6 S5 j{& g3 w( y; m6 r. J- z9 C# c4 H; c4 |. m
};% R4 {% o8 i6 w: m' q
$ @1 m( G& Q1 u4 v# Y) Q+ Wstatic struct platform_device da850_evm_tl_leds_device = {& ^+ n5 b& V9 b, p
.name = "leds-gpio",
. } a# a" y/ Q( o2 N9 ?6 D! o .id = 1,
) h! M* ^1 A/ K! z& b .dev = {% M, M$ ^- z3 n* `: l8 x
.platform_data = &da850_evm_tl_leds_pdata,
; C2 E9 }7 H" s& ~$ Q/ j p/ Y .release = led_dev_release,
0 }0 @1 B7 D' }+ Y) ~( b }$ G9 N! D: X) F& H
};8 ^7 t' M y* A3 N" k' G# A
7 p: ~: n5 {" b, ] B( Z( Z
static int __init led_platform_init(void)
5 n, A" W8 @( R6 B7 }# ?! U{, i' E/ K8 X/ i* L% b
int ret;
) ]! u, r: B5 h) a+ P$ }#if 09 H, ?+ n+ M7 R9 {. q, p( @6 z9 D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" d& V# O8 Y1 O( D: _0 u% L0 n
if (ret)- A9 z0 e( a) B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 c5 b/ c. \( [# \/ p) z "%d\n", ret);
7 ~' Y+ o1 A. F% l( Y#endif6 D, K" u0 ^3 e1 e7 \4 ~3 v
ret = platform_device_register(&da850_evm_tl_leds_device);8 X/ C% a/ n6 P5 g% p+ @
if (ret)1 z9 R% g5 o3 V3 P2 D
pr_warning("Could not register som GPIO expander LEDS");0 D) Y3 L' w' n2 r
else
3 [, ?4 b4 z+ R+ V, a8 y printk(KERN_INFO "LED register sucessful!\n");' U# p# X* g4 l& M) F
# |: w- B# C6 ?' U6 g
return ret;
2 F4 R/ m6 L4 F4 z; j}
7 r; L" v- ]0 h, r; w& J& Y9 t0 }$ S- ^, F
static void __exit led_platform_exit(void)
( P0 t% x% C2 }{/ V/ w* V S% o/ U/ a5 r, |
platform_device_unregister(&da850_evm_tl_leds_device);( e- o% l: ^) [5 L6 k, ~( Y
3 W1 X& f4 J8 R7 u/ M: \- }
printk(KERN_INFO "LED unregister!\n");7 M9 s# B' D+ C& X
}
A" ?. r' k" n6 Q$ I
% Y( g6 {9 p! h0 d6 b Bmodule_init(led_platform_init);
( E$ C! G9 B6 S* |module_exit(led_platform_exit);* D$ R- @' p- V0 q- l
5 N: O/ }: T0 k) j( q" BMODULE_DESCRIPTION("Led platform driver");
5 R* t+ q1 P1 I) |. @MODULE_AUTHOR("Tronlong");
) U6 G2 y& L8 Z* h* d! A- z7 zMODULE_LICENSE("GPL");
7 M2 q3 M# I8 G$ }9 q3 A
* i8 Z, V5 C: A3 R$ C |
|