|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 P; L3 G& q- v1 l#include <linux/init.h># ^% O7 C# g. y% a7 j
#include <linux/module.h>/ y# I' g Y/ x* S. t
#include <linux/kernel.h>9 A9 @7 f7 }* \- k7 j" U
#include <linux/types.h>
2 u- m9 G7 q5 {% C#include <linux/gpio.h>- ], a& e6 ?" P. W
#include <linux/leds.h>
9 m! ?; T" \8 \! Y6 u#include <linux/platform_device.h>: I M( V1 c0 t) y
: v/ `& B0 Z6 o& @#include <asm/mach-types.h>
) f8 B" k8 F0 |' f0 E: @, G#include <asm/mach/arch.h>
% o" H6 `" W( y% i0 P9 n#include <mach/da8xx.h>
1 B5 s: I+ W& `; h, B#include <mach/mux.h> g2 r& S; W/ a Z8 z
1 H0 ?& I2 q' M6 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# d" d/ v5 H9 g: T% l; }& I) u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# d. s3 L+ J5 t) ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ o9 F, t$ }4 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 G! M* G* U6 R
8 P+ E# e) B U% A1 J4 l/* assign the tl som board LED-GPIOs*/" q" t+ ]/ z7 ]. I( C
static const short da850_evm_tl_user_led_pins[] = {
: C# B& S8 S g: g /* These pins are definition at <mach/mux.h> file */
- o$ M- W* I5 p' X4 @8 c! ~; | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. F$ B' }# z8 |, n( K. r
-1
& t/ ?' z4 b, n; C+ Z6 @6 ]' s, h};
. M8 C' _: s# `
' }" d/ V# `* T8 Fstatic struct gpio_led da850_evm_tl_leds[] = {
3 G* T3 Q/ m8 j+ h; p- p {* j# Y( Q7 g: c/ ]
.active_low = 0,( l; i( D7 m7 D. L1 ~+ c1 F9 P" [
.gpio = DA850_USER_LED0,4 H2 N2 Y6 o" Y2 e. n
.name = "user_led0",
/ _8 g( t. Y1 t* a+ I0 i; | .default_trigger = "default-on",# o# I# V9 g9 n. ?- y+ n% D
},
; N6 c+ ~' Y. o6 ?' N {
! ]) q0 Y6 g, P+ a .active_low = 0,4 f' G4 z# T+ M) o# I$ \
.gpio = DA850_USER_LED1,% t$ d) R" R" h" E" a6 X* i
.name = "user_led1",
1 ]+ Y2 T; i/ F. ?$ M4 } .default_trigger = "default-on",
. p/ @6 [- P4 d2 { }, g, v" ?8 C% @
{
4 z+ R. j1 z& `/ a9 x .active_low = 0,$ x2 c; p, e9 k8 ^
.gpio = DA850_USER_LED2,9 t1 i$ J& o$ n+ Q: @
.name = "user_led2",# K% S7 c; Y% L: `) [, {( t
.default_trigger = "default-on", O% x2 ^4 g. u/ Z/ }0 x
},
5 {& z, h2 I+ L# y {
) ]( B* S( [& [2 Y% Z. ], q) V t .active_low = 0,
) T9 ?% i9 l7 R .gpio = DA850_USER_LED3,
6 t. [1 r7 }. J! V. a! Y .name = "user_led3",
# c) |6 c) Q3 f6 a( P .default_trigger = "default-on",
' h/ J% m' t& M* A/ P7 e },& E. G, |. L& J% K: E: E
};9 e, ?, u$ W& K# ~
6 L% _2 L# T+ U6 x" E2 B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; @& j4 E$ ^( n+ U" G# ]$ b+ H4 K .leds = da850_evm_tl_leds,$ B, H+ g, |; N, X' B1 k: D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 t1 j- Z5 |! }. @4 W4 v
};; E9 ~% F% s$ F( L/ R$ T- E
' |1 g! j% G. n; ^+ h% Y% E$ G4 c* g" Q j
static void led_dev_release(struct device *dev)
( ?& u" Z! j1 B; g{
/ h5 B4 ]( ~' Q# |: c$ ]: D};" X' A; D( L4 o4 y. y4 H
+ M c/ R% T( g$ astatic struct platform_device da850_evm_tl_leds_device = {9 W8 b3 d2 `0 _$ Y, ~
.name = "leds-gpio",$ v' ], j* P, j3 R/ {/ W3 p5 @
.id = 1,
2 Z: w. F, _7 X6 P: |7 Z. } .dev = {
; Z4 l. _- C7 C0 q) k- H .platform_data = &da850_evm_tl_leds_pdata,
( q, N, P1 z& Q8 {3 |0 G* h .release = led_dev_release,9 X- }: X0 B$ i
}
: a4 ?: w" w* I};/ Q5 ~, ]- _3 g( U; f. H5 m: w
" z/ F) C7 `% E1 ~ L
static int __init led_platform_init(void)3 ?* S, [1 ~5 c" U0 z
{" {1 N* N. ^9 {/ O
int ret;. S1 @- D+ P7 A4 {+ O
#if 0( }$ C' v0 \+ j" g! l n% W8 f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 d: y. E2 A% z6 P1 G$ X if (ret)
2 K7 ~4 k9 V( ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. a) o* s5 \2 B- H3 h+ s( B/ ]$ L, ?" k "%d\n", ret);
6 S3 j" Y; i# b1 C#endif
* Y) f2 G5 l* `2 U6 @$ d3 I- E6 u ret = platform_device_register(&da850_evm_tl_leds_device);3 s% d( m H7 S7 `8 V' p0 f U" s
if (ret): u6 m; s @" d
pr_warning("Could not register som GPIO expander LEDS");* P9 U( J# [! {
else
. t: k1 |5 K: H% n% J( A printk(KERN_INFO "LED register sucessful!\n");
T$ R8 a Y( Z4 g0 ^
$ F' h, Y; l. | return ret;
$ a4 p; p) k" u. Y}
: v: _( S3 M8 _$ P/ j+ g' g
9 V4 S. ^' ~% {1 g& l2 A8 f! Q. zstatic void __exit led_platform_exit(void)# Q: _$ \: c9 n' `* ]7 G
{
, j5 {9 g# o, [3 P3 i+ n platform_device_unregister(&da850_evm_tl_leds_device);
; _9 w+ Y( U7 S9 P) a
) D1 p. U# O w. Z, x/ C printk(KERN_INFO "LED unregister!\n");
1 Y6 `# J8 u" n" H- L}
% d0 x% i* `; j! l% b1 [; W- q
3 O3 e4 `* Y2 R$ f' _. h3 Q6 gmodule_init(led_platform_init);& z" L( I, n, b% t
module_exit(led_platform_exit);7 _8 j* ~, [) y
- C) W9 D% v! q. g: sMODULE_DESCRIPTION("Led platform driver");1 D( o% p( I& u7 J4 @2 V) g+ B4 _8 N1 x
MODULE_AUTHOR("Tronlong");
! s9 d" F# z. x' }8 v% WMODULE_LICENSE("GPL");
2 q E' Q# |! S+ O; I
; N% |5 v. s5 X) I: I" @) z6 v2 o |
|