|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 C" D1 M* ]9 f" B9 b
#include <linux/init.h>
, s5 ~& S. W" G: l3 X- a7 h1 u+ t#include <linux/module.h>' w! D4 n( `' v7 ]: b- f6 x
#include <linux/kernel.h>
8 ]! c: _ G! Q- c. w c4 Q#include <linux/types.h>
6 ~5 v, h0 P' s+ ^: j$ ~0 r#include <linux/gpio.h>. q( B- V/ S/ `% U
#include <linux/leds.h>
) r& t6 V7 h1 U6 x% C1 X: K/ A0 X r O#include <linux/platform_device.h>4 ?/ _# _/ c% Y6 s
3 l( G M" Z4 i, J#include <asm/mach-types.h>% T0 Y, S& X: J/ r0 M) }' @
#include <asm/mach/arch.h>
. F/ w+ R; N( ~ b# p# W7 V#include <mach/da8xx.h>. z0 Q; y o: J5 G5 W! g
#include <mach/mux.h>( |$ j/ o4 J4 {: Y$ C5 A* e
6 m; K! D( H) i0 t- q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 Z. `0 E/ N) Y S+ Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 |2 L' z1 p8 M# o6 M' F! H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 e$ J/ m: U0 M3 J6 p0 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 ]# G' Z0 I6 m8 x* _. @
8 r8 L0 _$ X% u/* assign the tl som board LED-GPIOs*/
9 y9 K7 |3 z$ f' Fstatic const short da850_evm_tl_user_led_pins[] = {: l1 p% z1 H7 c7 n, H- _& `
/* These pins are definition at <mach/mux.h> file */
) r$ c6 K) @5 `# e- Z; N) r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: l* G( r4 k1 U2 \ K -1
$ c3 d8 n7 Z5 |/ u6 u+ ~};
3 o; r6 O: X# j% V; }
4 u: ^* ~; |- s9 Z% J0 pstatic struct gpio_led da850_evm_tl_leds[] = {8 D+ c' [$ _, f, s, R) E7 `* k* f
{
; ^& m5 o& B& N .active_low = 0,2 t9 e) D" t6 i$ W
.gpio = DA850_USER_LED0,- y8 ]4 Q4 g8 b e
.name = "user_led0",
0 C }6 ~2 \5 [7 v, d3 k .default_trigger = "default-on",5 `% j& i; \, c' r+ j& ]! H
},& [( G% p, x- e) n. @9 ?) `
{; S; b5 ]7 O$ h
.active_low = 0,9 S; g# g2 G6 i
.gpio = DA850_USER_LED1,
8 D' @- n* l: Y/ I' U. x .name = "user_led1",' u7 j7 l* I) s( F I
.default_trigger = "default-on",
) D1 ~2 A+ [ j; o9 K },8 A8 X; j5 V8 p7 n% S: i
{
% m8 }" q8 f; O .active_low = 0,
: A% n9 g, \' [ .gpio = DA850_USER_LED2,8 ~9 i& w, [" X
.name = "user_led2"," y V6 p' c5 p [- h" d7 B0 D3 ~
.default_trigger = "default-on",
- Y! M6 [9 V1 d" ~6 e$ W8 r6 R9 q E },
& F5 f9 L% R. e0 ~5 b" F0 A+ k {
4 a6 U$ [' @. g) e" x* s1 k# U .active_low = 0,
$ {" {+ ^5 P+ C' O7 P9 {) F3 I .gpio = DA850_USER_LED3,
4 i' Z5 c: F f! Q .name = "user_led3",
, |( I( j8 J0 ~2 x$ H# U4 }2 u .default_trigger = "default-on", t/ H1 c7 @/ ~ [
},. `4 T) {7 r6 y
};
1 o& V6 m5 S* E3 J! y6 }
4 j* t. E3 r# P. Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { u. \. |$ e$ O- Q4 ~% J2 U
.leds = da850_evm_tl_leds,4 ]1 x# `' z0 ~4 V& r, |2 T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ A$ i8 }4 _3 Z# @' Y7 ?& i};
8 [( m( F% g1 B% K0 c
2 ?( W+ q% I/ j% t; q& K( Rstatic void led_dev_release(struct device *dev)7 |" K, ^+ B9 l4 N
{) M9 p3 V& V+ r- R/ ~' l
};
% n9 H) F0 F3 c. c3 Y0 {; A; A+ g4 H. [" r1 B; u0 o
static struct platform_device da850_evm_tl_leds_device = {/ D5 P) T1 H4 l5 Y/ v) i' Q7 Q* L% d
.name = "leds-gpio",/ j( s1 k% d' S, G0 O
.id = 1,9 j( ]5 y( v1 p* s3 V* [
.dev = {& D& W8 v8 c1 A) U/ X8 _4 t* C
.platform_data = &da850_evm_tl_leds_pdata,
4 a* {* [4 ` O6 n, ~ .release = led_dev_release,6 K9 j9 c9 A+ ]+ g. e6 p# G& w
}8 ~5 D, }5 w( G3 G# y
};1 @' U8 w7 [/ ?! v
/ Z$ m3 E: `# Ostatic int __init led_platform_init(void)
) X- ?( `2 f8 t{ C8 a6 n4 j% N
int ret;
) P9 X/ `, z! V1 L% e4 Z#if 06 t6 F- {) H: l" X! d% z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); A* j6 z+ T/ z9 G% S7 B
if (ret)6 {7 m: _3 Z) N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", ?& y# x& C; }7 r% T
"%d\n", ret);: A9 ^8 Q @5 W
#endif
3 B/ Y$ b' y: I5 p* x! P% ] ret = platform_device_register(&da850_evm_tl_leds_device);6 P! j n" q7 G. m
if (ret)
- H3 X+ y, W: Z8 J pr_warning("Could not register som GPIO expander LEDS");
' a3 `# S; @' v. y else3 {1 k3 k8 f+ m3 Z( v, {" }% N
printk(KERN_INFO "LED register sucessful!\n");
% K: g0 |. ^: _/ @4 {9 I) s
: w2 Z& V& i: r9 L/ r) k; e5 R" | return ret;& c1 |) ^ }' l7 D
}
* N- g6 p* u% l/ _, [
( S( F. g+ i, a( F# `8 f' U& E6 Cstatic void __exit led_platform_exit(void)# \: O) o. M- ^$ \
{
2 A0 _5 e: L q4 H" ?3 j2 S6 E platform_device_unregister(&da850_evm_tl_leds_device);
4 }5 {" K* e) y `0 p: T) t; }. f8 ?' ? C2 k
printk(KERN_INFO "LED unregister!\n");1 F! E8 u1 O' R \+ [
}
/ \" N8 |0 u! k
& V3 X2 e+ A0 j1 |# h% P; |+ ]9 @module_init(led_platform_init);8 [/ \8 O7 r8 N% s; {
module_exit(led_platform_exit);3 Q3 p; _( `( ~! Y. K% E
! X! F0 i1 g* NMODULE_DESCRIPTION("Led platform driver");
' g" j3 {5 y7 |" {MODULE_AUTHOR("Tronlong");
. b# m" E, k$ s+ r- BMODULE_LICENSE("GPL");* q$ X! j1 s- \5 x& G6 s+ A
' Z( ]* ^4 @* w5 s" ] B+ H |
|