|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 l. [5 x' g m; b! B
#include <linux/init.h>( c' t* P; X( z8 ^, {* L4 `
#include <linux/module.h>
5 |; w# J7 R5 j# z; |: R0 y8 L#include <linux/kernel.h>
# U& N8 r" Z; N. r3 r: q& }#include <linux/types.h>4 d0 p/ ~3 }: ?1 G2 E0 `/ w8 v
#include <linux/gpio.h>0 d/ s; @( z- {6 `
#include <linux/leds.h>0 ^# L9 }7 g* J& S- R8 n
#include <linux/platform_device.h>
1 i2 s* d3 G0 \9 L- d5 k( `/ Q$ O, m1 |: m
#include <asm/mach-types.h>6 ^- j7 f/ w# Q n: z* {: p& N6 t# n
#include <asm/mach/arch.h>) b \) g7 y, z/ H
#include <mach/da8xx.h>9 b6 f0 l8 ]- S* x9 G& s) H! k X3 k
#include <mach/mux.h>
4 u9 j; i8 Q# y* R5 R$ k) K
* C; U h- r- m0 M& n( H( s% h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' K3 v; x' ]7 f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' P1 {* V- ?2 ^. R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, B$ ~3 n0 n, _: H# U+ X- \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 V( n! _: O0 b. a8 H) h' e* r
^8 A/ B1 }/ D' u& ?; m8 {0 q. v/* assign the tl som board LED-GPIOs*/: i) X' `8 [- S( N. t
static const short da850_evm_tl_user_led_pins[] = {
}5 d. F. q, D* D6 b /* These pins are definition at <mach/mux.h> file *// ]9 W: u& x" g! H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," P. C1 w# t; n F; y
-1
0 [1 {- b$ }1 @/ g" _5 Z};
8 ~/ m7 d5 ^$ `* a0 `: ?; B, @% ]2 O( H/ N# N4 C+ Y
static struct gpio_led da850_evm_tl_leds[] = {& ~. g4 i, z! b0 W
{
% B* i6 R; @: p2 F: Z/ e .active_low = 0,
1 T4 N1 d% ?" W .gpio = DA850_USER_LED0,2 K1 v q6 S2 R, Q$ Q
.name = "user_led0",
# }+ e5 E- J. a4 L! d .default_trigger = "default-on",- ?) C5 N" e5 J8 h
},
R+ y2 h0 S/ ]5 ~; W {
% [0 Y) v, t( j .active_low = 0,6 F+ h& B$ ]# M4 i7 n
.gpio = DA850_USER_LED1,
, y/ ], m: }1 a3 E$ j+ n( K .name = "user_led1",
/ O- S* ^3 F" f( v6 q; q .default_trigger = "default-on",) m' i( w1 `3 J6 U* D# _, p
},, }+ J8 J# U7 `( k7 g
{
/ E2 L. {, L* S. {6 C f .active_low = 0,
1 @$ k: p' W9 Z7 U+ r4 W .gpio = DA850_USER_LED2,
- D7 @% Z' Z* B( @3 T .name = "user_led2",
1 G' I3 ~& s7 g6 h3 s; B .default_trigger = "default-on",
+ x, g) b6 {9 E! G# \; G6 W' J },
, Q8 ^' O/ l" n6 z {8 \( Y' ^9 m- }7 q8 H( n
.active_low = 0,
/ A" d) ~0 l* R9 {, ` .gpio = DA850_USER_LED3,
6 d% s! l' _' [2 [ .name = "user_led3",
1 Y% U% E) g$ d! q2 x8 C .default_trigger = "default-on",
* i% N4 Z% a% Y/ ~! z* t },
0 ]3 N+ y2 @ B& U2 I};
( ?5 p# C$ [$ c" S* M2 Y7 `# b$ C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) @ k# y2 h6 S5 C# b0 K5 t+ ~
.leds = da850_evm_tl_leds,5 i% N3 ?5 W3 R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, b5 G/ `4 P5 j+ Q1 t! K
};
5 c9 ^/ N6 i& {: a9 N& ?3 y7 _7 e6 X W
static void led_dev_release(struct device *dev)% S. x; D& N" F$ r. S5 [. J Q& n
{
5 q5 u5 l! R d6 l};9 Q9 _3 Q' G- z& l
- r. Z) O; v( ~1 ]' x- z" e* c
static struct platform_device da850_evm_tl_leds_device = {1 }0 q6 T2 g' x4 S1 x" J& f) b
.name = "leds-gpio",
, L0 Y6 @5 q$ f6 N# g! | .id = 1,. @( G2 F2 \/ p: _1 |8 j" l5 t6 |% K
.dev = {3 ]; e% `. n3 t R6 O1 x5 x' l9 {
.platform_data = &da850_evm_tl_leds_pdata,3 j/ f+ \9 P5 i5 s: f i! ?
.release = led_dev_release," I: H: k4 B. g$ T- `
}1 G5 r) A. s6 S
};4 g( s+ A* O3 g H3 m
1 V" I( U9 a0 m# @! K0 e
static int __init led_platform_init(void)
- n5 ?, G( e: B% ]) a3 _' P{
9 q* f4 i2 F- U! e) K int ret;
1 [2 k# v; w9 v* }+ d#if 0- ~6 Q; r' T: v5 x& R: q- h6 q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ S' m; `5 K& W. V: N+ Q! z if (ret)" R( C: ? o) Z) |! n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% @& T, }% f; O1 o$ e. n l3 H
"%d\n", ret);
8 i/ e5 H' a. Y( I#endif
+ X& H) e2 O+ g' b- I ret = platform_device_register(&da850_evm_tl_leds_device);
* j. a9 U+ H8 X9 P, j8 |+ k if (ret); c+ o6 z( P& }$ ?* Q2 f
pr_warning("Could not register som GPIO expander LEDS");& t5 a5 P3 T& n2 Z$ E
else: x4 Y& e h! h- v7 r
printk(KERN_INFO "LED register sucessful!\n");
7 N9 V- G6 B- q2 e* n4 ~. T& Z" `, p- _2 [7 v, F9 Q
return ret;
% ]0 q) W2 I& ^- s9 p}7 h/ g' [% i5 g
. I/ m% L' O6 {9 _; T
static void __exit led_platform_exit(void)! k5 B0 i' ? b5 m2 r
{
1 L0 [! h/ F- O! K1 p platform_device_unregister(&da850_evm_tl_leds_device);/ q8 p1 w0 j+ @2 N4 H7 t( Q. }% S
+ i8 `& Y1 c# d9 a
printk(KERN_INFO "LED unregister!\n");
1 \% _5 ^6 a. g7 W}
, u4 N( O$ t0 ~& Y4 `" d" O, z2 D" w9 S8 j' i- j7 A2 T
module_init(led_platform_init);* x9 ^ }/ J, v
module_exit(led_platform_exit);
* X; q. L& s0 D/ @2 l! d. D( Y% h1 T" J9 ~) H
MODULE_DESCRIPTION("Led platform driver");; M6 F* L3 b% a5 W1 g- q: i, X0 Q
MODULE_AUTHOR("Tronlong");
; d9 C! F5 z) V3 TMODULE_LICENSE("GPL");
0 ~/ o( w* ^5 R7 ^) X4 O8 _& o& @
+ q5 I$ l2 w( `# P |
|