|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' Y* S ^: Q$ W#include <linux/init.h>
# k5 {0 T2 `) `0 a7 C7 N#include <linux/module.h>
7 Q( ~0 ~/ s' P, ^7 T" m! N. c#include <linux/kernel.h>% |# O6 {! m) ~1 O2 o+ A$ P/ u
#include <linux/types.h>+ l0 }6 Q" j; \' S$ g& C' C y! y
#include <linux/gpio.h>4 r* f& V5 F) I. c- @5 `: y4 \/ e1 c
#include <linux/leds.h>. J: r! M. e7 G
#include <linux/platform_device.h>5 k) @& n6 B9 f0 |4 e6 [* H
8 G$ ?# a4 K# b6 t2 f#include <asm/mach-types.h>
5 m) W6 X; Q! d4 ^ x z9 j#include <asm/mach/arch.h>
. o; F8 W( j3 [7 o6 y8 N! y#include <mach/da8xx.h>
+ Y/ Y# ]# B; t$ w# f, V#include <mach/mux.h>
, ~8 |7 o; k7 G; d5 f, H2 C( p. P9 x, A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 _, M6 b+ G9 k3 ~5 S* b; `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) \5 _3 A" x- H! Q* s [* Q4 K% i0 A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
Y3 e. F" F! T- [6 ~3 w, ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 h1 W8 i' H% g; p- S6 C Y- H
% h; q* r+ l. h1 A P/* assign the tl som board LED-GPIOs*/9 }0 ~! f8 ?6 B1 f1 m3 B! N/ v
static const short da850_evm_tl_user_led_pins[] = {* j# W q8 r1 Y
/* These pins are definition at <mach/mux.h> file */
' W; \, Q5 a9 x! R" v) X; _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- ]# A* D, k; A( ?3 g
-1
. T K V+ D/ }* H( @) N# U# V};
]" f* E3 V6 `# J4 ~
5 C8 K6 _& B6 P/ x+ a( G% M2 ?static struct gpio_led da850_evm_tl_leds[] = {
* }* R9 K( J6 I4 n6 R4 g' t/ _8 @* c {! T# e# F: f$ |' f, } u$ H" D; ?
.active_low = 0,
1 f7 X7 @( n( l# |. T% y/ S .gpio = DA850_USER_LED0,
0 ~9 U" J" m; S x2 D7 k .name = "user_led0",! i1 A0 _* l$ Z, C6 ?/ e/ q% K- H
.default_trigger = "default-on",
; Q) A. I, j% L. }( A& { },4 K. A' A& @; u; L5 f+ K
{
# ]( q) v8 _$ \' d+ [" o. O/ N, j3 M .active_low = 0,
4 E$ w; Z' Z1 f$ |1 H .gpio = DA850_USER_LED1,1 |: H( W, a( h
.name = "user_led1",0 G3 e: K* R1 [2 }& i4 I/ Q
.default_trigger = "default-on",
9 @: T" W' B1 [5 |3 C7 Z3 g },2 J) \6 b9 f3 |. P* P; t4 O
{
7 A& N, y+ b7 E9 w. l2 r .active_low = 0,- A# {/ G5 Y* _9 |
.gpio = DA850_USER_LED2,
$ v! P0 d: `5 s .name = "user_led2",( N1 Z m5 @. G4 i( R/ B# S
.default_trigger = "default-on",; v3 x- O( [; |% a5 x5 U
},
( L+ p+ _2 Z) P8 D/ u5 m( c: m8 S4 N h {1 h" I# T% G9 v. _
.active_low = 0,
/ A& G2 E5 X2 @( R .gpio = DA850_USER_LED3,1 N0 G3 x0 N: V2 X6 Y
.name = "user_led3",
9 ~6 |1 @7 c/ O% F5 L9 M .default_trigger = "default-on",
5 ^5 ?1 x; N. g( | },) O; K' x- H! Q
};/ x1 w. _. S: m0 Q2 M& E
) I9 y+ P* R: k4 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 `* l. n3 d, C# T7 B. B
.leds = da850_evm_tl_leds,
. W+ _( j- p8 P. P( U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( [0 O$ D+ D$ e& v( V+ C};9 c$ w* [, i& s# p# d! M
; g4 X' A4 g( E; X) ^+ U* ~static void led_dev_release(struct device *dev)
8 R7 a, z' _# A1 G4 Y4 n{7 \4 ^* t! }" s
};: u# |+ V* U! J$ m+ }( A) Q
9 c: u. G3 i& }, B3 x9 P
static struct platform_device da850_evm_tl_leds_device = {
* k# F, ?0 k S& `- ~3 ] .name = "leds-gpio",
# Z3 `- e4 m8 ?+ p+ e- h5 K .id = 1,
8 {! \# [, K9 h .dev = {
2 U% Z) W1 ]7 i/ f .platform_data = &da850_evm_tl_leds_pdata,
" I% ]5 t& _+ ^8 |- v .release = led_dev_release,1 u1 U* g3 o1 C# W. B
}
n. n" d* L( i3 s2 c( s% W};8 S+ J; ]$ w5 A: c* Y0 `. b
- y2 ^: S6 G. I; h" }5 y6 sstatic int __init led_platform_init(void)0 J+ e7 t7 L* R! t
{
% N9 c( S/ D: O! @, G int ret;6 M$ U; t& s# a2 x
#if 0 r1 n ^& @8 _% z( K9 N c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' }2 ~' |) X. o. Y. O0 Z/ @ if (ret)6 K2 ]/ Z( b- J& e$ K( Y7 S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") p8 `- A0 x' G# L U7 }5 v0 Q
"%d\n", ret);
0 `3 [! w* N$ W. T: q$ {#endif
6 K0 k6 T1 g, A ret = platform_device_register(&da850_evm_tl_leds_device);6 K+ m1 S/ o1 L# l
if (ret)- v/ [" v# M0 h7 M8 u
pr_warning("Could not register som GPIO expander LEDS");
, t, u; _% d0 Z; }, e else* e4 P5 `6 ?7 ^
printk(KERN_INFO "LED register sucessful!\n");
% P7 l' S+ I. l9 t4 V y$ g4 @( k( O/ k# C' k
return ret;6 @/ N* _0 ?* M2 a) x& H1 S& `
}4 J2 Q' o; J/ E( c0 J, _
$ K8 x9 v; [& X
static void __exit led_platform_exit(void)
0 @1 J" ~# H3 U6 I% ^{# Y: ^3 v% q, T/ ]. i d3 U
platform_device_unregister(&da850_evm_tl_leds_device);6 G; y( ~, K3 f. c# t
: c( O4 I; W. c0 P8 Q- x2 y printk(KERN_INFO "LED unregister!\n");/ O M: E8 h+ [2 Y% l
}7 i: d+ X7 F# D" W$ E7 N) ~& H( _
. [8 ^$ ?" O- Y9 {- W0 m$ v
module_init(led_platform_init);% ^% L9 m$ ^) l1 A) q' u1 V- G8 s
module_exit(led_platform_exit);: L" c$ B- o7 Y
: h! C& P) f3 o7 X
MODULE_DESCRIPTION("Led platform driver");
+ {5 b* }1 D# U0 N0 [MODULE_AUTHOR("Tronlong");
: u- m2 c# v9 n5 i8 IMODULE_LICENSE("GPL");+ E$ j+ A" [$ m M' x
2 ~% d# f- ^3 k! `0 F+ d |
|