|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 d, c( X! r% U7 K8 w) ~5 ^
#include <linux/init.h>
" e6 A8 X) {# p#include <linux/module.h>
0 a* z! I; S8 \6 g8 J" G#include <linux/kernel.h>
2 D9 n2 m# q0 U9 Y#include <linux/types.h>0 w/ l5 W' ~6 L$ h
#include <linux/gpio.h>0 J: v/ ~8 Q% i9 ^ ]7 D! g4 c
#include <linux/leds.h>& F% |! u, I0 h# I
#include <linux/platform_device.h>/ C/ P/ F" U3 h0 l
" D+ g, x/ R3 n( M: H
#include <asm/mach-types.h>2 E# H6 T% j% v' z9 M, T9 n
#include <asm/mach/arch.h>* \+ g! r! {& }" Y6 b% b. c* g. u
#include <mach/da8xx.h>5 B+ M1 s) d0 G9 ]5 @/ L
#include <mach/mux.h>
. E# N4 Q3 G+ f) z9 v& {6 n1 U' N. l2 U' O- \ Q: P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' I- j) m3 }0 g2 k$ [& Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
j g+ {; B+ {0 R4 ^& P/ g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). m3 W4 R4 C; w" ^5 v2 r+ {% Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 f5 u9 D: C5 J S" y# c
4 x9 x7 j5 l* f: S0 `! b/* assign the tl som board LED-GPIOs*/3 [$ U' Q( n) z
static const short da850_evm_tl_user_led_pins[] = {
" A" v2 I M+ r( n* f /* These pins are definition at <mach/mux.h> file */
' L' T: e* N B6 O) I! U/ J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, j! o5 E& x) j( |; P
-10 O; L0 n# U/ o* r! k
};
: ?, I! O2 T; P. z5 h2 j
6 @* q0 R# _+ wstatic struct gpio_led da850_evm_tl_leds[] = {
0 {& J. u! J: N& ` {- D3 Q. g, T- j# h$ X
.active_low = 0, W/ r) @& `- l8 _0 X% I
.gpio = DA850_USER_LED0,
, N; O4 `9 a) O A$ e .name = "user_led0",' R6 o, P' w# J7 x) m/ l
.default_trigger = "default-on",+ b( j/ c1 {( M R. Y! c
},
- D7 t# F8 ~2 x5 _( J7 L) y, K {& M8 p! p9 s/ B; Y- n' K
.active_low = 0,
& R% ]3 C$ y l3 y* ] .gpio = DA850_USER_LED1,
; t. G4 _: W7 C) j9 M .name = "user_led1",* `% w! T5 U1 ~, r) O
.default_trigger = "default-on",3 T' Q+ L) {- E, ]5 h2 [
},+ v# P' @9 a! r- m$ C3 v
{
- E6 ^( W4 Z7 f: x* n7 k4 S .active_low = 0,* S0 T! h9 M, V
.gpio = DA850_USER_LED2,
h l7 F7 a: W* Z: U .name = "user_led2",9 Y$ |2 `" c I: { c
.default_trigger = "default-on",
. `1 U0 J; Y) L6 J },3 d8 t" N, f3 D1 P; D. P
{8 U7 b6 _2 o5 Y5 h; d
.active_low = 0,
6 H/ g; O c. C0 p& P2 A& J .gpio = DA850_USER_LED3," z5 L* O* X8 `% j, _( v, V0 M
.name = "user_led3",: O2 I' B* N+ O- z# Z! @3 ~5 c' ~
.default_trigger = "default-on", |. R- Y1 k& u5 s8 c% I( _; h; b
},% P$ L( Y7 b* c& | u
};
+ d/ X' n9 W* ?* |9 O r" S
% i1 y2 n) I( K, a" n0 i" ~# X/ n3 M' ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' V- |2 E( |. S. K .leds = da850_evm_tl_leds,5 _2 K4 a) l/ Q: U- ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 L7 z3 {/ `! M2 d. y# W& r! M6 j};: A1 u- e) U: S4 L: A
( p: I( F5 T2 b8 r; [& K
static void led_dev_release(struct device *dev)* [/ Q$ q4 X5 T! ]! _3 @* p3 n
{+ K7 N# f' I3 |9 i
};2 y, S5 N5 S" S$ r
+ t7 r7 Y: G5 c3 X5 _( [/ _+ y
static struct platform_device da850_evm_tl_leds_device = {
5 O; o) c! e' _" j' ?$ @ .name = "leds-gpio", A+ o: x6 \' B7 R: t
.id = 1,
6 ~: T+ r* q* c U .dev = {
, E0 M7 M/ q. b1 \ .platform_data = &da850_evm_tl_leds_pdata,9 S+ v$ C" Q! o: \9 S" d
.release = led_dev_release,- O# j7 ^* @1 n0 @
}
# E4 |; q$ K& ^6 c) A& _};
" n$ z' y5 n6 H/ H" \5 ?5 e0 G# G7 I9 L
static int __init led_platform_init(void)0 C Q' S/ g: v; ?, e
{
& q3 L7 t: ]& u. p, ` int ret;
, s7 {9 e* X+ L$ r' Q6 {) x6 H9 Q: i#if 0: {7 ?- e& ~+ U7 [5 U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 Z! g, C+ V3 T& ^2 O; ^ if (ret)
0 _1 O6 W3 ~; A& u& ~( \; W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( d4 s* w0 E! r. s# ^9 @& e8 w O5 z "%d\n", ret);% v# S& ~) h0 s7 g; u5 f+ U! ^
#endif
5 m& O$ K5 E2 ]0 m1 W$ O# y2 O ret = platform_device_register(&da850_evm_tl_leds_device);
6 p3 s( L# x' p( Z0 D if (ret)* k4 w+ l( z( c5 v1 w, N5 S
pr_warning("Could not register som GPIO expander LEDS");: D0 E! h0 p, T0 v
else
4 S' ]: A/ f4 o printk(KERN_INFO "LED register sucessful!\n");& s/ d8 U( h2 F) b9 W
( ?& V% B5 b6 [( {3 @' l* } return ret;5 E9 ]. D8 U# B- E. I8 J
}
+ ^7 r+ [: ?1 n, ^* }; x
- F, p" g2 N6 f% Istatic void __exit led_platform_exit(void)& G; |, R4 x7 U2 v; \
{, Q0 \. X, ~! a! @+ w
platform_device_unregister(&da850_evm_tl_leds_device);& v x1 _8 h2 C& O# U) d
1 ^& A+ g7 J( M' A printk(KERN_INFO "LED unregister!\n");
; r6 d$ P3 H x$ f}
M9 h" g! k7 _& g, F
& H: M- \+ U! L( g) Emodule_init(led_platform_init);) _$ |/ i! H3 ?: {" p
module_exit(led_platform_exit);! ?, }+ |9 P4 Q% v( P
) X7 Q3 T" |5 ^+ F& B
MODULE_DESCRIPTION("Led platform driver");
' h2 ]& h) _+ a& X# P# UMODULE_AUTHOR("Tronlong");
4 P4 n- s& U: \2 @2 K1 A+ v. U, XMODULE_LICENSE("GPL");
/ I' ?2 u: f" L9 a5 G9 d# M% ~" ^ W. R4 o
|
|