|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 i$ Z$ @: T4 o2 @. o' ^#include <linux/init.h>$ y2 n ~1 _& B. k2 Y: @; ^
#include <linux/module.h>
$ P( f1 d- `3 ?#include <linux/kernel.h>/ _2 `$ `. x% I* y# y3 |
#include <linux/types.h>1 E1 [+ P0 a. h+ z
#include <linux/gpio.h>$ o2 ]# D. o- z1 I* i$ _% O
#include <linux/leds.h>
" E1 K9 S5 _! `: j: L% g#include <linux/platform_device.h>
. w3 i/ R/ e8 {) g+ H1 s( ^) F
$ f/ o2 R' \+ Y0 h#include <asm/mach-types.h>7 I& E7 E) B0 }3 e: ]/ ~: `* y
#include <asm/mach/arch.h>
) O/ U! u3 E9 P# l, I1 E#include <mach/da8xx.h>
8 g! \/ X5 E4 s8 ` e2 S#include <mach/mux.h>- ?5 Q% G+ N% t2 p/ i
/ I' T9 O* e$ J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. \9 d# Q5 V! Y+ X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 U9 E U5 C* f' o2 r" l8 I& r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 J. Y9 o! R$ Y' h* O- ^( P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 D" t$ M7 P: s; S8 y$ H( J7 Z" v
( W7 R0 I/ f* v$ r1 |2 Y% r' m
/* assign the tl som board LED-GPIOs*/8 i0 N, f) ]( |/ n* _) P/ K
static const short da850_evm_tl_user_led_pins[] = {( q0 m2 }, @# i& M
/* These pins are definition at <mach/mux.h> file */
/ \( u" a- f7 |; B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) `6 m% a0 ?& \& F7 r
-1
4 C2 X8 f3 I$ M$ R};# [9 w, Y! l M r2 @
" T# o6 ]; b+ n& L- Ustatic struct gpio_led da850_evm_tl_leds[] = {
7 R. U9 c) I- M( p {
5 V7 X3 k2 F% y& Q+ b+ `$ q .active_low = 0,; a' ]; L A* g) x2 d
.gpio = DA850_USER_LED0,
3 C' [) c, `3 I' U- p- d1 C4 Q .name = "user_led0",
; B5 ]% I1 a4 M .default_trigger = "default-on",
, F& K3 C! R3 N/ s* L6 H },
8 h! h; C/ F. R1 v {) @4 n$ U) a5 W6 N8 P+ J3 o2 {7 I
.active_low = 0,
1 p& z* J9 h# @+ a$ s/ f .gpio = DA850_USER_LED1,# Y9 y) B1 b" I7 h2 r# `
.name = "user_led1",6 F( t) U1 g4 d9 S
.default_trigger = "default-on",, t% \+ L" G" f. z [9 D/ v7 x ~
},
" T! s8 g; ?# m* |5 C/ p {
! C# P. `% C. z .active_low = 0,
' {/ c3 p" A ~ .gpio = DA850_USER_LED2,
, c) G( P- P2 D" r .name = "user_led2",
9 l& R i+ W7 y) B2 | .default_trigger = "default-on",, v5 o; ^4 Q) {* D% P
},
+ k; s$ C6 b" ?2 H" A {
' `$ @$ D) l7 U6 j .active_low = 0,; Z7 [' l5 _% R, w9 k* P; I8 P$ G, n7 E
.gpio = DA850_USER_LED3,
8 R5 T) E& {- W .name = "user_led3",
. m% N" U9 c- R7 ^ .default_trigger = "default-on",
* L& q$ s; x. N- g2 a4 ` },
; I/ F6 u0 u! }* F1 i- F$ ~};
" r% n9 w @. `/ ?/ ~6 }) k Z, S. o P/ q5 Y+ `. V8 o- F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" q* l$ t1 z& X2 P) ]9 W0 X
.leds = da850_evm_tl_leds,3 P2 i' i$ i5 g/ e; p1 c6 w* _+ G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, O4 @7 e* \- ]* g& c
};. V- U$ h6 `1 G( r6 G7 }* b U! N
! C% Q- M0 R. L) b
static void led_dev_release(struct device *dev)
5 w5 F- V: t6 [5 ~! Y{
" u/ l9 L1 [% D* t* A};- A2 g, M: G' g3 I: y
9 `" h2 V3 V3 c3 J/ I$ }3 xstatic struct platform_device da850_evm_tl_leds_device = {
7 h* Y" V/ I1 o! S* t .name = "leds-gpio",
" @! A/ q# j0 K; ^ .id = 1,! `* R7 k" \8 h% _
.dev = {4 X' f! ?( G7 I( w7 e
.platform_data = &da850_evm_tl_leds_pdata,2 U* q |! k3 D2 Z9 p) C. D
.release = led_dev_release,; ^% s2 z$ j: {
}
- c9 w( Q( K: S2 {0 _$ e};( O( P6 `5 W6 Y3 M
1 a P/ A ]7 V) W C! @
static int __init led_platform_init(void)
+ A$ I& Q- t0 ]6 ^5 S{
4 ?: [. {; B/ b$ I, T* k% E( b$ p& m$ D int ret;
8 C/ C# |$ t1 F" H8 K#if 0
# `3 p! v1 I# j. g4 B' `- s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ @# N& p3 u0 ^4 P- ?
if (ret)- f% Y. i/ U( t4 c) v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". y `. |( g% o. T, @5 V
"%d\n", ret);8 I- Z" u3 q5 P1 o
#endif
# ^6 Q3 E; a/ n7 ~0 }$ b ret = platform_device_register(&da850_evm_tl_leds_device);
* p5 {, ?9 n+ M$ Y3 b0 z% U if (ret)/ f( Q z1 T6 k# x3 I/ B& v
pr_warning("Could not register som GPIO expander LEDS");, A: B5 x3 V+ o. ^) p$ ]$ z9 l
else9 \+ A: J6 y% y6 X' ~/ D$ E9 ?
printk(KERN_INFO "LED register sucessful!\n");/ [" k. l& T2 y' C% u+ d4 B
e$ |4 {3 {% m5 i, Z5 F6 ~ return ret;( J1 J+ o K' H* y3 K; u; d, t5 M
}% q# V0 @5 s. N. N+ f$ x
7 ? m+ }" w8 t1 J
static void __exit led_platform_exit(void)" K! ]9 m4 |# @9 U8 _, t! h2 \. F
{0 d- g* p9 Q6 b1 \! U7 `& y
platform_device_unregister(&da850_evm_tl_leds_device);* Y# ?# H, E# z; h) \
- d% h: P' Z1 k
printk(KERN_INFO "LED unregister!\n");
' o; a; ~2 P _7 E( ^9 |5 e}
/ k: D5 {8 n2 {" l8 i# h7 J& L+ L7 g8 H, c% J
module_init(led_platform_init);
. H: O# v4 b/ v7 l& imodule_exit(led_platform_exit);0 [9 w+ S9 |7 Y, j; k7 [
7 T$ W% E2 y6 R3 V, w$ P0 y4 W, U: k
MODULE_DESCRIPTION("Led platform driver");
+ W3 e6 ]4 S7 q. E. V1 J# M, j2 _MODULE_AUTHOR("Tronlong");
) Q% h) u5 B9 q6 F, G6 cMODULE_LICENSE("GPL");: f7 b# P. M, O {- n6 l
- w, [9 d4 k, u6 i' o1 `5 ^
|
|