|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 F$ v0 T9 j' x#include <linux/init.h>
# |* [5 K3 `8 t$ t#include <linux/module.h>) E. c* d: Z- v" q) W, I; m: F
#include <linux/kernel.h>
' f1 N$ j0 ]- z1 g) h. s#include <linux/types.h>
. o/ }3 ~7 x. F( y" Q& f#include <linux/gpio.h>4 n5 ~$ {5 |2 w f3 B
#include <linux/leds.h>; s# @9 P5 r- b/ a$ F- m6 r/ _
#include <linux/platform_device.h>
* W7 z9 H- o& I% k8 \! v- q
, l; y9 T& x4 ?+ ?1 `# d8 x4 \% f#include <asm/mach-types.h>
0 x) S3 r1 u5 k2 f q! j, P4 y#include <asm/mach/arch.h>
7 l- |/ x( e8 r: @7 A#include <mach/da8xx.h>% r* N+ ^9 D7 I V, ]. M1 D5 B/ T
#include <mach/mux.h>. R X* A& b' ~: G; y
$ L u2 E% {" P) U4 R( k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 I8 n6 C$ B6 y9 P: d6 M; r#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 b0 F: @ ~4 ]" @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
|* V ?$ W5 V1 f5 b' D( [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 w0 Y* i; i7 P: c0 R, ^: X
7 O: p9 x9 D' n! x! Z5 \/* assign the tl som board LED-GPIOs*/. _- Y2 x. q( y- n d7 I( }
static const short da850_evm_tl_user_led_pins[] = {2 o, B8 w) t" ?( I, E0 |% m: q
/* These pins are definition at <mach/mux.h> file */
- S7 k0 P3 S# b" b" d5 V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' N9 j9 b& z# x$ `* d -1' f# ?2 y+ T3 o, i" X
};# r& }0 J3 i4 }, w
; Q4 t W1 O! U; |6 L# {( X
static struct gpio_led da850_evm_tl_leds[] = {
& k/ y: j4 l6 [6 v {2 n4 z' ^- C3 V% ~% y; w; r4 a+ S
.active_low = 0,( Y( ~" N5 @! Z2 l
.gpio = DA850_USER_LED0,
; r+ C' p7 ]7 K .name = "user_led0",2 M! e; E. _& a* E) x( Y8 s
.default_trigger = "default-on",
- i. n! b; u s) J' n },/ w! q; ]: R- b p8 a' J) ^, o
{
" T L6 C0 b3 H% O, R4 w/ q .active_low = 0,- I+ p! A5 g/ O" j8 |+ _
.gpio = DA850_USER_LED1,
5 @: a! d. h$ {6 r2 a' a3 m .name = "user_led1",/ Q# q# H* F% C3 A
.default_trigger = "default-on",
2 n& Q9 O1 I7 q7 \' F. D& F },
& ~; B& x0 J9 P" t4 y {( Z# ]8 N5 R+ o7 c1 l3 C% b+ A
.active_low = 0,
0 f6 ]5 H9 ~; F6 ^2 m1 g .gpio = DA850_USER_LED2,) A" e3 [! N: l$ j( a( ^
.name = "user_led2",
8 I" h: ]% g9 Z .default_trigger = "default-on",1 T4 x0 K0 n- [% l% O4 V+ E8 ]
},/ p |8 D3 \! v4 y; Y( q/ ~5 z
{' l. G2 `; I y& k5 Q. Y' [/ I
.active_low = 0,, L; v6 t8 k, M8 P
.gpio = DA850_USER_LED3,
' F3 h7 B; w7 F* Z .name = "user_led3",
7 {' l- I+ f( P3 o .default_trigger = "default-on",! M' X+ I! d9 {2 i. p
},
+ D R0 V/ t" q: Y};
+ w k/ W3 u# W# j4 s9 B8 h
" ` n6 t. a$ \. T$ O" d6 astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 |% X4 a( H; L3 i% W$ Y .leds = da850_evm_tl_leds,
0 `) E! A9 w% X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ z H0 z/ q1 D# |( B# @# K};
+ F& L/ s A# s! N# n# z, ^& `0 z k c$ i1 e7 T* H1 v; n
static void led_dev_release(struct device *dev)
?* D, r- S R M/ C$ c{
* u7 P7 [4 U2 U% f7 X$ M};
* k: ^' e+ z. T; T# @1 u; z0 H6 B7 X" i4 H4 F; s) Q7 P
static struct platform_device da850_evm_tl_leds_device = {
6 j# B6 p5 Y) ~9 W, w2 _ .name = "leds-gpio",- o! c6 K x, d: ]0 Z# N. v4 Z
.id = 1,8 {9 n V+ h! l5 T7 J
.dev = {% A: l9 x8 e, ?8 F
.platform_data = &da850_evm_tl_leds_pdata,
6 |" Q0 g3 P8 e2 p. f P0 n! _ .release = led_dev_release,
. x& A2 F2 m1 l1 Z }: S9 u! y, b1 Q3 k$ @ ]7 P( P
};
$ w) Z' ~5 f8 ]
3 F' ^6 K) P: U) ~8 m# ~static int __init led_platform_init(void)
8 V0 s7 k: W `5 H{1 I2 H* U3 R6 Q1 _% {
int ret;. W4 V! M5 n2 ^
#if 04 g3 Z2 k( K* ?% N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; J U7 l1 S3 }- g if (ret): f) u( A4 l) I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* h3 J$ l% k3 K3 B% W+ `* V "%d\n", ret);
2 A! c& n: s# N#endif
1 _; z8 I& `. x) l% l ret = platform_device_register(&da850_evm_tl_leds_device);+ Q3 z1 v& L0 S% |/ T! |3 b/ m6 u
if (ret)
: c* P! h- ]7 k2 d5 w) f pr_warning("Could not register som GPIO expander LEDS");: u7 i, t- r) W+ C; n$ d5 |
else# {5 s. ?) A" h7 ]' s# ^" M' |
printk(KERN_INFO "LED register sucessful!\n");
* a2 `- w, t, T7 t: W% U- ?4 C0 M7 Z, H
return ret;
! l0 }- c. B) ]! Z7 }& O9 O}
# f+ F8 j" K6 ^6 b. v% R2 X& `* N, `5 B: C& x4 g
static void __exit led_platform_exit(void)! P m( Z# ?6 I% u5 O2 M! w6 ? {
{
7 R( M6 f/ y( u/ K& [- g1 d8 l platform_device_unregister(&da850_evm_tl_leds_device);) a" k# m, _# s2 }
8 V" ?# p/ M, N printk(KERN_INFO "LED unregister!\n");
/ R1 c# m( j2 \. p }+ F; Y# R}
4 e J/ l( i! {6 M* |4 E: v, ]/ S' R1 A% B/ l& E
module_init(led_platform_init);
, G$ O" y- i# b; O, Fmodule_exit(led_platform_exit);
( R8 n. x, Y" a3 d5 a! s- z
! Q1 `4 ^0 ]0 |MODULE_DESCRIPTION("Led platform driver");% S Z: A1 H0 j- w' M
MODULE_AUTHOR("Tronlong");
6 b9 F1 ^. H- }MODULE_LICENSE("GPL");/ p3 B, Z+ `6 y1 M
( S; n1 v3 w2 _% K8 f+ b
|
|