|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, {% I1 c; [# p' t1 [
#include <linux/init.h>3 z# X1 d# A2 S1 m- {
#include <linux/module.h>- M: x5 M0 A7 ]5 ~4 R& n
#include <linux/kernel.h>: I1 o8 e- n# a
#include <linux/types.h>
( E- G7 J# I& D) k% }/ z+ \- U#include <linux/gpio.h>$ ^' \: f: K* l/ ^ F
#include <linux/leds.h>- L5 g3 c* A; w
#include <linux/platform_device.h>$ |, Y" T" ^; G) l7 Y: K
' D+ D; |5 }' o% u
#include <asm/mach-types.h>
" @. y# a; _% B' X#include <asm/mach/arch.h>% E0 Z1 K! W o+ |0 b
#include <mach/da8xx.h>* @7 O4 N6 }4 \) n3 Y) s5 W: |8 ]
#include <mach/mux.h>; f7 n" l. M1 Q# H2 t7 m
- M$ t- c+ t& E1 l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: L6 d3 y1 v' C I5 R) }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. U( e: x, K t8 z" {9 x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 i, l: m7 f$ Q' F! W3 U9 ~/ J+ S/ {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 o, }4 i0 y8 n2 b; L9 u% ^2 o6 u
8 E* C. h/ u* U; G/ |/* assign the tl som board LED-GPIOs*/7 Y; j& E- d$ H" O" @* v/ U1 H' ~+ |
static const short da850_evm_tl_user_led_pins[] = {
5 ~4 {' M6 q( j* ^ /* These pins are definition at <mach/mux.h> file */
. f `. S. a3 U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. M* }/ z( D8 U/ A- _+ j -1* e& D+ V. V0 u7 q: B; o
};
( x+ |* e. ]1 r
- q; W8 }/ g* B# z5 | Estatic struct gpio_led da850_evm_tl_leds[] = {
" {9 q6 y% i% W& ?% x( B; C# N7 h {
! k( \! l5 E3 j2 [4 N$ x .active_low = 0,7 U2 K, ^" b, ]
.gpio = DA850_USER_LED0,4 O4 z" d( F( E0 H9 y, H
.name = "user_led0",4 J7 [7 {1 o: S$ X7 D0 h
.default_trigger = "default-on",+ \% C. c: ?* |) ^) [5 B7 O
},2 n8 Y1 r2 w0 h9 W
{% l2 f; g; q) i6 H* v
.active_low = 0,
7 O) i) {( Q# y4 Q .gpio = DA850_USER_LED1,
) P6 L5 O: Q( j9 `6 P7 T" d6 ^ .name = "user_led1",8 g3 y1 ?. _" T" W4 x# ~5 j X, j
.default_trigger = "default-on",
: R+ d- W: B! `: m },/ D, i1 _9 h t0 u, j6 c1 q
{
/ E+ S6 g+ U- _; ` .active_low = 0,
$ Q E( L- K% ?" a3 Z .gpio = DA850_USER_LED2,
- p8 g6 |1 g8 p# D. I( _' C .name = "user_led2",+ Y- s* k5 `# x2 T% K; `! F' \" G
.default_trigger = "default-on",. t+ u" F$ }$ i( J" E9 J) A
},
9 V, y9 w" Z" p: U5 C5 q j {
1 i% @; {8 b I- X4 t- G) \ .active_low = 0,
; ~1 u4 c( E$ h# B$ N .gpio = DA850_USER_LED3,: d4 O, p1 q9 E" D$ J& ^
.name = "user_led3",4 [% ?# C2 s& l2 A) R
.default_trigger = "default-on",8 b9 q! w5 K- S6 m! L6 i
}," b9 e! ~0 a% e" C, J+ x& l, a
};3 s! e/ W1 e; y: g
. c8 [' T" x1 V0 F! D- Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" W0 L& \! x$ W1 w8 b {6 m0 D .leds = da850_evm_tl_leds,* i( I* l m3 P) P# ~9 {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* V0 k; H8 U# l. H
};( z5 A z- f4 j
O+ `' y, Y$ Tstatic void led_dev_release(struct device *dev)% Q# w9 f& U0 N5 x7 H
{; j" |+ n0 l8 f1 v D
};
8 b/ r# y# }/ K( Y- B- j
" ^. j, k4 x( M0 I, [/ z. s4 {; Z q% ostatic struct platform_device da850_evm_tl_leds_device = {
. x9 w9 _9 o8 b% v8 O .name = "leds-gpio",
7 B4 G% V4 ^& @1 j# E .id = 1,( U9 L! q* V9 B+ w, G
.dev = {
7 y) F% t: q$ E' L& b .platform_data = &da850_evm_tl_leds_pdata,1 y! z( j. l4 `% _9 Z3 K: I% n
.release = led_dev_release,
7 u9 T: Q& F8 J( x ] }% g6 o$ Z5 b6 Z. M% Y2 C1 ` c
};6 x" \, ~. D- W! Q1 J
0 o' A9 t$ e) R1 h" F+ a- _1 y( s" }/ d
static int __init led_platform_init(void)
- ?2 {. h h# |( a& K6 b{
6 y: L$ O ~+ O1 O2 K# d int ret;
4 i, M3 K) k" d1 g# ^#if 0# r- g% P% T* A% U" y0 x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ I2 ?4 V, N+ b1 f2 g
if (ret)3 x: A9 P7 t7 I# |9 K9 T% c' O8 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", Y5 n! g: v1 i
"%d\n", ret);
% ]6 I. Y4 h; X) x' ?#endif
8 a& E) a* \) D ret = platform_device_register(&da850_evm_tl_leds_device);$ v( X6 ]2 k' N4 `
if (ret)" @, }, T; \. a" l4 C
pr_warning("Could not register som GPIO expander LEDS");8 Z; ], K4 L# l; Y; \ p4 i, E
else
9 s) R9 t* j/ P$ c% g* h5 H printk(KERN_INFO "LED register sucessful!\n");
- h5 R% H7 y( D! [$ E/ B, o" c8 W4 u# }, E
return ret;
* T, V4 g/ l: ^# l8 ?}
3 P: U7 q8 J. X4 L; p+ p
$ m% l# E" q" R7 Astatic void __exit led_platform_exit(void)2 v3 t0 A( x" ]+ t! E8 R
{
$ C v$ H' ^$ u3 b, c3 A% M% ?4 u platform_device_unregister(&da850_evm_tl_leds_device);; A6 z3 r2 x- H* c* C, z
+ |7 F: v/ V( z" X
printk(KERN_INFO "LED unregister!\n");
8 Q/ e( W" v' U}
5 S4 ]( W0 Z8 B4 S I& A2 L+ N1 Y! k1 a R
module_init(led_platform_init);+ Z; j S- e! j. Z! v- N: N
module_exit(led_platform_exit);! P: Y" y5 ?4 B3 w+ z
8 ^; \% |* A/ P# K6 I4 f# bMODULE_DESCRIPTION("Led platform driver");. n: g/ n2 e( B& z* b$ V3 V& T* c9 R
MODULE_AUTHOR("Tronlong");
1 i* y) k; a! h$ r8 p0 E& NMODULE_LICENSE("GPL");
: E0 U5 p5 M: @/ f) w
0 r3 I. }# y5 o+ {0 r$ i7 a |
|