|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. Z3 t$ ], D$ s H- O- H#include <linux/init.h>
& @- c% Y' X1 O- k7 d#include <linux/module.h>
- `# A$ c7 g! l; X#include <linux/kernel.h>
# X: l4 h* m& ]#include <linux/types.h>
6 h! Z, E2 Y; r% @$ S& E( G#include <linux/gpio.h>
7 Z5 R- R. @3 |" u4 W#include <linux/leds.h> v$ ]. ^# m1 k
#include <linux/platform_device.h>! p) R: j/ m8 V8 ~' T1 V" s2 X5 J
K6 d, X! q$ k#include <asm/mach-types.h>9 {8 i7 t4 w& q" B9 A
#include <asm/mach/arch.h>
) T0 R# n( `2 l, K' k- t* a t#include <mach/da8xx.h>( Y ~4 c4 a9 J- E1 x9 [! _: Q* J2 X
#include <mach/mux.h>& H* w7 Y$ j# s
8 C$ k: `; e1 ]2 W1 V5 w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 d1 H+ K: ?+ t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 ]0 K2 ]$ d+ \% S1 L* x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): G3 i: z$ N! B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 }1 w/ {0 ?" T1 N! B4 ]0 N+ I
. O# g3 H' t4 o+ k3 `/ ]9 X ?
/* assign the tl som board LED-GPIOs*/
9 L3 X8 b d$ R. a+ S w' vstatic const short da850_evm_tl_user_led_pins[] = {
& l& Q% Z8 g# j2 R: ~ /* These pins are definition at <mach/mux.h> file */
3 p8 b/ p* A# Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 F9 R% ?( K2 E" V -1
" x) b# E2 f0 a2 _4 l- ^};1 G7 H0 X4 J8 l) ]" d1 g% u
( t5 C* B- p5 cstatic struct gpio_led da850_evm_tl_leds[] = {8 R" E, [3 A$ I- {) K$ t" a- p; y
{; `" F, w2 g0 L7 t6 {6 W9 _
.active_low = 0,3 H; F5 d# f1 Y1 j9 f! x9 L
.gpio = DA850_USER_LED0,' g) E( j D- A& P0 N: G. }% k6 S
.name = "user_led0",& u9 F5 z4 s# C' r
.default_trigger = "default-on",
$ U P; w, C7 T. Y3 ` },
2 S. y1 P0 t, _( {. T: F* O {8 G' R7 \" i0 ?, o# f
.active_low = 0,
% P8 f( n# p! X2 o9 G3 l7 N .gpio = DA850_USER_LED1,# c0 _9 h8 J. J" O# y+ W
.name = "user_led1",
, Y# ~7 u0 c3 b% U .default_trigger = "default-on",
$ g" M7 i2 l( \) Y6 B) X },
7 W; a" ~& Y# e3 u7 M {
5 K6 E: J0 `% P7 K .active_low = 0,6 x: {. q* Q. O! }/ E4 Z9 ~ S
.gpio = DA850_USER_LED2,* V& q, I: I- O3 V) b8 m
.name = "user_led2",0 X+ @% w; M1 t+ ^/ S3 n0 D5 y
.default_trigger = "default-on",8 ^: E! G1 j" l: i. a% I& d
},
3 f0 ~4 s8 } ~# \& i/ U9 k {, j, x; o/ a. K' T, V
.active_low = 0,4 ?! Z* S. ]1 x
.gpio = DA850_USER_LED3,
1 n; k5 d% o" Z7 o .name = "user_led3"," O3 ]" a. K9 y& z, ^5 W3 n
.default_trigger = "default-on",
! s) Q b+ |' @. ~! s },
: B/ ?/ O3 O& g* s( ~};
: x. e+ a b1 ^) ~& k6 r2 ~4 }" Z4 \8 z& K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) X8 g9 S$ M; ? .leds = da850_evm_tl_leds,+ N9 G. F, H3 s. `' |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ j9 b; N9 w; q- k# ]# b" Z2 W7 P- R};
. H. l& \) \% M; c& L) h( {$ ?9 n, Q/ |) S$ t `7 L6 |
static void led_dev_release(struct device *dev)5 N" i4 a: ?1 R
{
- j& s* M# O0 @/ u n};
. v0 y7 T1 u& ]$ i. c; o9 K/ B- R. O+ z4 O$ \
static struct platform_device da850_evm_tl_leds_device = {
9 a ^! B6 s0 J; G) x .name = "leds-gpio",
& G5 H+ f; b5 ^) c .id = 1," U5 `9 K5 O* P- q" Y1 n* u
.dev = {
; o( w( i. Z4 l% s+ K! D8 d .platform_data = &da850_evm_tl_leds_pdata,! u) [* `2 \! _, J1 t4 |
.release = led_dev_release,
& U3 G3 g: O' x }
% `: C& y1 u6 ~3 y( c};1 B, n1 n" n# V# n8 ^" t
C5 u$ l4 _( D! b9 ~0 I4 Istatic int __init led_platform_init(void)
% S8 f1 T* D# D% g7 M. }{
# }4 g) z1 U+ }; r. F( i int ret;, L4 ^1 l/ S8 v8 `6 A8 B' }
#if 0
' }) g- Z/ T" X- W- r/ C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 Y. d$ }+ ^& l" B1 K+ h if (ret)2 C" }8 e; a- e B" r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 T& L3 l8 e! I8 g: J J3 S "%d\n", ret);
- h m! Z1 P/ d0 m6 `1 ?% o9 z#endif8 ?. N- R2 P7 Y# f
ret = platform_device_register(&da850_evm_tl_leds_device);, y0 G& R/ |$ f4 b2 a3 y- p. c9 V. u
if (ret)( X- m+ g* K3 l! h
pr_warning("Could not register som GPIO expander LEDS");$ ]/ K# H' W N, N1 o
else, x) u4 f. x A7 S) r
printk(KERN_INFO "LED register sucessful!\n"); Z1 n, @7 J$ z* [# ?2 ]
0 }5 g9 v6 f, G# I% o
return ret;, d4 z6 J/ E& `, [1 t/ Z
}( D; K6 {- Y, G e2 [
; n# O8 `% ` {! w) G
static void __exit led_platform_exit(void)
: ]% }- f" P9 S{1 n# v. _: _- o, y5 e% c
platform_device_unregister(&da850_evm_tl_leds_device);
1 }* r! Y- S) ?2 \0 S7 d5 H8 c- z6 p6 c! T" y5 L
printk(KERN_INFO "LED unregister!\n");$ ^4 d. @% @! R" M% Z* L! U
} t- p% }$ t* Q$ ?5 T
2 i7 U+ O1 V# v) Y |
module_init(led_platform_init);3 Y6 ~7 |" P8 |0 y6 ^& c" m
module_exit(led_platform_exit);
3 S" q) z( o9 b0 j8 p7 M! u- q3 o9 B/ G' [3 a
MODULE_DESCRIPTION("Led platform driver");
$ g4 w% S8 X/ Z' c2 b, E( L1 TMODULE_AUTHOR("Tronlong");
6 w" T. l5 v" ^( cMODULE_LICENSE("GPL");( Y- K' c+ a$ k; h. N; l
0 Z2 ]4 A7 {1 W& D) M5 ]$ M3 S4 ` |
|