|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- Y. a, f2 v) Y. `5 {4 t6 `
#include <linux/init.h>
6 C$ u" F G" e" z4 Y4 U9 i#include <linux/module.h>, z& J' Y& ?& j" y! {7 X% i
#include <linux/kernel.h> i# T* z8 p+ c2 J: h
#include <linux/types.h>
2 r, d& ~; I4 t' X6 d2 ?0 `#include <linux/gpio.h>
: ^" i% b7 u$ N9 X#include <linux/leds.h>
; P* k* ]9 J4 [/ y8 }#include <linux/platform_device.h>7 N1 o C8 d# E1 c
8 z# p# x3 m o" [2 g' c3 G#include <asm/mach-types.h>* n$ e. \6 A3 F+ T1 T% ?$ ~
#include <asm/mach/arch.h>; b1 g3 o7 H/ c6 E
#include <mach/da8xx.h>0 }$ w7 ?7 z7 h) a# _8 F; _
#include <mach/mux.h>
' V% o, F& F9 l; C4 l5 }' F3 @; f8 M4 N' I, T$ K9 Q: P4 p: S) B2 x2 l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 T( F' Q- Y( [4 R% a$ h9 }7 H0 W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 E( u5 Y4 u5 b- t. |/ ~- @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 v/ f2 Z1 R3 P6 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 M9 I |" W# L) L3 P9 t1 f
0 w( z Y) L Y% o" [- t
/* assign the tl som board LED-GPIOs*/& |9 |2 s2 ? z) ^
static const short da850_evm_tl_user_led_pins[] = {
3 Y, z3 d" i; V( ? /* These pins are definition at <mach/mux.h> file */5 a# d! ^7 P3 A2 P0 _6 Q* N8 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. O _% u9 _7 Z -1
8 C# H9 B! ?/ u: x' O};8 D6 x7 Z) ~. K2 E! z
. x2 s; H0 y4 t6 b# S
static struct gpio_led da850_evm_tl_leds[] = {
2 W( F9 |/ C. H3 Z' o2 x* R0 \ {/ K* ]* Z- j9 E A9 H
.active_low = 0,
4 M$ l* `& ]# C1 a .gpio = DA850_USER_LED0,
- j* k6 y) H+ y0 c# m8 [# u .name = "user_led0",$ u A, r U: J2 w2 L& b% @( I: o
.default_trigger = "default-on",
+ Y' ^/ D! l1 x4 W },
e9 {- o5 k m# D2 D, J; A {% s9 h; {+ f* b4 }$ Z
.active_low = 0,& M' ]2 d1 @+ E( R2 u# P0 [+ i8 [
.gpio = DA850_USER_LED1, u( K) E# a: A, }9 \# y: V3 f: f
.name = "user_led1",
u2 ^. S) ~' j( |; `/ Z4 H .default_trigger = "default-on",2 \3 a$ _1 l& `3 @7 h n
},9 j6 a: X. g }% C, s* Q0 R/ a* a$ D3 w
{
. T. G, e0 s* n. ?) Z .active_low = 0,
+ Z4 Y+ ]* P& C2 S" e- c( A8 ^ .gpio = DA850_USER_LED2,
! C) i" n- C( N9 I/ n .name = "user_led2",
/ C& K7 G7 _5 T8 Q3 D! M .default_trigger = "default-on",
+ X: h& P+ f6 L& l: K5 { },
: x/ B7 Z) O6 U5 ^/ B {
# f4 H% d! L# A$ }6 u .active_low = 0,; N# x$ N( d% N# h; N
.gpio = DA850_USER_LED3,
! q; X* T" W; H9 f' W3 U! S .name = "user_led3",
, a) Q; j* t$ U& t8 [& \1 ]* q .default_trigger = "default-on",
# [, U$ @ y. s },
7 J; \* @8 U$ _) `0 U- ~};& C0 \6 k$ C$ X/ B' C$ J5 U3 Z! Z
3 a6 p1 ~: G' ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 p) c2 P h2 @ .leds = da850_evm_tl_leds,
0 ^8 ~* `2 B) b$ }# p .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: V9 W# c; D" ]* c/ b
};8 b1 w# q+ s: A. R: k
5 ~( t* W* d4 X
static void led_dev_release(struct device *dev)' z0 u. c! p* b q( W m3 O
{, S: a4 }' @+ _) M. }! B3 l$ Q3 m
};
, c5 x" q# z7 M. n* ~1 @6 v: j0 P U# C$ ?' P% T9 t6 {
static struct platform_device da850_evm_tl_leds_device = {: J1 R1 ]: s9 |6 r
.name = "leds-gpio", X# z8 n. b7 a0 I0 s. t" f
.id = 1,
' u0 z; _8 ~% Y6 M/ ]+ n .dev = {( N, O8 D5 b2 V+ M
.platform_data = &da850_evm_tl_leds_pdata,
+ Y; u1 u# b* N" r+ f1 } .release = led_dev_release,$ ?: @. M; ~$ B6 D6 w
}
5 r! L, B3 H! e# V};
; m6 K* B/ ^' m
% ~4 J ^8 ^$ A( D' ^4 |) lstatic int __init led_platform_init(void): l4 y3 e* [+ F6 d# }; v! d
{
?- W# O9 n% o# U3 E, q6 e0 \ int ret;) h: ^2 d/ Y! v
#if 06 H2 f+ B9 X/ F+ p+ V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 X' n/ \7 Z1 [+ D; S% K
if (ret) b9 G5 Y7 R$ V' `9 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ g$ j9 N" q! n }1 v% |
"%d\n", ret);) K9 C3 i+ v3 m
#endif8 @" X9 O; Q0 Y- q$ @
ret = platform_device_register(&da850_evm_tl_leds_device);
: ]; H& O- S( B! o if (ret)
+ B. ] l" y. M pr_warning("Could not register som GPIO expander LEDS");" F2 T$ l6 W, A s5 @$ v
else
, R, B/ Z" \* S0 A9 x- h- q printk(KERN_INFO "LED register sucessful!\n");
E! q1 Z/ b2 |
/ t9 [1 h. j7 _+ x6 V6 C' B# m2 J return ret;
& c6 n- X% k- c( N: [: j}+ l5 j9 Z7 E" u# j0 `
8 Q: Z7 ]' `; w T5 p) Ystatic void __exit led_platform_exit(void)
+ x' E! V% M& x8 q( o4 T2 V; f{/ N# {6 c3 j! O) f/ K: E# i. L
platform_device_unregister(&da850_evm_tl_leds_device);
" R" _5 e% ?2 p P3 b6 _" _; e, N* X+ N0 D. q. P2 p# C0 V
printk(KERN_INFO "LED unregister!\n");& R, n& \$ _& }1 H7 O9 k
}# y# ? I5 E0 z) ]. s
4 ]# ]1 w& U$ i) Q4 Gmodule_init(led_platform_init);
1 W x" T. D- k7 l0 V+ ymodule_exit(led_platform_exit);& J& L2 @9 w6 k2 R
r# _- r/ i8 i8 c# K* G( V( a0 `MODULE_DESCRIPTION("Led platform driver");
7 \6 X* i1 s7 y* k4 h% A3 S1 [MODULE_AUTHOR("Tronlong");6 k8 S/ k# V# F
MODULE_LICENSE("GPL");
* q: X7 H1 @6 K' I7 [9 m" s2 k8 A' @
|
|