|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 t6 J0 o1 x0 t
#include <linux/init.h> ]' r! t- f0 p* k" E
#include <linux/module.h>
& d3 L; c( L0 J6 P1 K#include <linux/kernel.h>
0 l) E; N% |' X#include <linux/types.h>
3 p$ ^, N/ k! ~) Q" R; t#include <linux/gpio.h>( E3 s1 l# \% H6 Q
#include <linux/leds.h>7 V3 [# n4 O4 n* N8 V. _
#include <linux/platform_device.h>% F3 E6 A* S+ c9 h* @
& z. h/ ]! i, ^, _7 v U* Z) c
#include <asm/mach-types.h>, @/ N% d2 N0 s9 I( _# A
#include <asm/mach/arch.h>9 R; B! Y" I7 R+ X a+ `
#include <mach/da8xx.h>; w) z7 Q; ?% e F6 D! b( |2 b
#include <mach/mux.h>
. P* h% S9 K5 n7 V; B4 [3 L. A2 K& @6 O% \6 I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% B, q7 ^. x, J4 t! D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 B+ P! B* P4 d9 E$ P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 r" {' [6 S: k6 _' T3 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' K" T. I v! s
. B( C9 l* q! C' V0 k$ J/* assign the tl som board LED-GPIOs*/
2 Y. v* T" y2 s* z ~2 I$ Vstatic const short da850_evm_tl_user_led_pins[] = {/ @+ c8 ]9 c9 g- E6 D8 v5 C
/* These pins are definition at <mach/mux.h> file */
' [5 V7 K7 x9 t9 @. H5 ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ I) I. @, T |' ]4 I; E
-1/ ~+ @3 `6 C/ r- g$ a" t
};
% L1 L0 o. W* ?& N" F9 e5 |
, e& ]- ~9 h: b' J4 Estatic struct gpio_led da850_evm_tl_leds[] = {+ m! c' W) r6 t- Y
{( }$ g6 {1 V" y( k K1 h
.active_low = 0,
) k/ s: l0 h& Q7 X6 n& j" N .gpio = DA850_USER_LED0,! Z8 X0 o0 s6 ^* q
.name = "user_led0",
6 [8 ]1 M5 ^6 `( B6 q/ L .default_trigger = "default-on",
6 B% |1 E! C$ @. V: g7 _ },$ Z0 Z( p( g) k+ a! M2 j
{
: F6 `$ P0 x+ D5 m .active_low = 0,
- ~0 f$ ]! I# H4 O; f& M9 r6 [ .gpio = DA850_USER_LED1,
3 Z* y+ R0 ^! _4 {: s .name = "user_led1",* G" M$ T$ F4 v0 m: ?, N6 A9 ~: e" O" N
.default_trigger = "default-on",3 t, [/ a5 W: h
},
& ^8 P( v/ s6 x( I5 o- U1 Z. X {
% |/ Z) W* z8 h3 c. V .active_low = 0, w; L6 B3 Z6 d/ N5 s4 X) R
.gpio = DA850_USER_LED2,
+ N6 t F- `8 C% p .name = "user_led2",
+ U6 }+ V# e, E+ _' f1 |0 [ .default_trigger = "default-on",6 z( ^( s; I! u- j* S6 K1 D) V
},* m* M& o6 }7 ~( c# f
{& v7 Y. I, v( ?# o
.active_low = 0,7 p, R z4 Y+ h0 M3 p1 N
.gpio = DA850_USER_LED3,
8 E5 d0 }7 f( F4 S% m .name = "user_led3",
9 [5 Y! v- H7 L N4 r3 ^ .default_trigger = "default-on",9 c3 l7 g1 }) G$ H7 j8 D
},3 {# Y! E) j9 `- H( L
};6 Y" C7 J3 w A/ n4 x
3 }6 a* j1 L' q, J- J: B4 M! @" q8 O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 {1 D# Y2 z4 p V! N; `8 l .leds = da850_evm_tl_leds,
4 D1 o0 K$ n7 T4 }2 q1 |- O. [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 ?& a7 r6 D# c, C4 T( V2 u% m};
& P" ?% X" z5 i
4 ~+ ~/ ^/ s* K1 q3 fstatic void led_dev_release(struct device *dev)
" P4 O8 e: } q! n2 T4 X$ g{
; o; ?, Y) d) D9 T7 i7 z5 t! a};3 \: H# {3 Z# ?- c, N
^( L- p) L' q. U. S
static struct platform_device da850_evm_tl_leds_device = {" b5 i# o% `; f4 Q3 [1 p* q% g
.name = "leds-gpio",# I8 m1 b9 d- z0 c& ?. i9 T
.id = 1,/ H1 H7 _3 f7 K$ k& {: [4 u* S! ?' D
.dev = {
. o a" O) X. d6 H- |1 { .platform_data = &da850_evm_tl_leds_pdata,
5 A: P+ t! r, W3 U/ ~, b2 o .release = led_dev_release,8 o4 x8 Y0 b( w; z( H5 U
}7 t& r4 B _2 Z, g& F
};/ @/ x/ {! K2 g" E) ^
" X( ~$ G5 G9 W# F) D, o% T
static int __init led_platform_init(void)2 o* _5 b" y% V
{
. h# Q0 {9 w- Y* K+ H! V2 e/ a; _ int ret;; W' {5 e) o% ^& R$ |. {
#if 0( a6 Z& |* b+ @" ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: D9 f5 J* G$ T7 r- L if (ret)1 S8 q& b+ ]3 d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", F& P$ E& A$ w* k
"%d\n", ret);% M. g# V& q" k4 ^% c ~
#endif
' l- o5 V9 e1 Y" T0 w' Y ~. _9 V ret = platform_device_register(&da850_evm_tl_leds_device);) H4 F S$ y+ f: r# [
if (ret)9 |. h, @# O5 x/ k7 D
pr_warning("Could not register som GPIO expander LEDS");0 H; W, X; ~4 k8 W( O
else+ x/ k( Z/ T3 ^) N
printk(KERN_INFO "LED register sucessful!\n");
" j4 U3 X# A0 a. L
* |* P n( V; m: j, {7 K return ret;( I, v$ Y/ \6 V8 D% `
}$ a. j& p( ^6 a" p0 m7 v
4 c( [3 s' z% _7 z" q, I, V7 ]) sstatic void __exit led_platform_exit(void)% B9 p1 \; ], _
{! L V* _: B, ~4 Y" w3 w
platform_device_unregister(&da850_evm_tl_leds_device);
. x- ~/ M/ K1 M3 e2 G$ v0 q# `* a9 f4 u- V, l3 v
printk(KERN_INFO "LED unregister!\n");9 D, `( ~( ^! b4 Q
}* v$ n6 B( q" G4 n/ O0 ~
5 \# W% l" x" f b+ H0 P
module_init(led_platform_init);
/ o; @' @* z$ P3 L9 ]+ dmodule_exit(led_platform_exit);
, x" N) r& T4 L2 U2 K% M+ P: f+ }. J8 p. I: P9 G7 u
MODULE_DESCRIPTION("Led platform driver");9 a6 i- s# I" B
MODULE_AUTHOR("Tronlong");
" W4 Q- _. V) @, [1 `; SMODULE_LICENSE("GPL");$ e" C% u1 o# b
' {5 N; G9 F2 }& {
|
|