|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 a1 f& o* Z* l- e1 S; [ C
#include <linux/init.h>
1 \6 D1 u4 g6 A9 I. N. r0 ^#include <linux/module.h>
5 m; i2 N# G1 v/ W4 p#include <linux/kernel.h>
6 Y5 R/ A0 S# ]- c {/ i#include <linux/types.h>
' w3 w' t- L5 {$ _) k0 B#include <linux/gpio.h>
4 p/ R; C+ F; |, r#include <linux/leds.h>+ V! O) Q. E2 G9 h0 Y
#include <linux/platform_device.h>0 x$ K3 o4 C8 J2 h+ W
1 o" \" O; h! ?. g#include <asm/mach-types.h>( B9 {6 K0 \) R+ Y
#include <asm/mach/arch.h>% W2 {8 t: c; t B& j2 B# U* k1 P
#include <mach/da8xx.h># o0 I; G1 M' P; G. I4 [5 K# ~ e4 O1 u
#include <mach/mux.h>
% l& s& v& N! ^. I, `6 T! G" g
; l' } a/ M- i; i3 C/ ?. i4 E, b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' w2 ]' C) g& t7 {: V' O/ @% W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): u9 E9 Q: \) Z3 O% n/ g' g! w# l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- V' E3 ?' g1 U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' N- y2 U. n: |/ d p9 \! B7 h/ g, v
/* assign the tl som board LED-GPIOs*/9 }6 r0 l) g. T& z
static const short da850_evm_tl_user_led_pins[] = {
) Q3 T8 L9 Q6 M: g! q5 r! Q" q /* These pins are definition at <mach/mux.h> file */# u- n/ o' m0 M5 L1 U- M( b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 C/ G3 u; V) G6 J& W6 G
-1
/ r8 U! Q$ ?) x( a2 B4 k) B};
" P* M {3 Y' W2 h( E! I( w# s
static struct gpio_led da850_evm_tl_leds[] = {5 C4 x8 e# B8 N2 P
{+ K( h1 \; a( F, H; @
.active_low = 0,
. [/ G. Q9 d0 c .gpio = DA850_USER_LED0,; n2 g: S8 X0 j. {
.name = "user_led0",5 L" J' S9 I6 ~( G7 J4 S( J$ Y; J
.default_trigger = "default-on",
4 Y! Q2 U& g' q/ l) t },7 O/ t6 l4 a9 F* b) l
{" I& w9 p9 t# _2 J0 _1 _0 B7 P& J
.active_low = 0,1 L7 \5 _, o& o7 ]! ]( f
.gpio = DA850_USER_LED1,
6 I- d* A3 H, { .name = "user_led1",5 ?$ x2 N% ]5 D4 a' O, V9 E* r9 m2 `
.default_trigger = "default-on",# q- t: A1 d- x* h+ Q" ^
},
& h6 m3 H2 k0 `9 Y8 c8 ~! q {
; j3 z/ { Z3 E. A% I* h, m .active_low = 0,
: d. h' n1 I2 q; d3 s .gpio = DA850_USER_LED2,7 `% p/ _2 k9 b; N3 w% H6 K/ w
.name = "user_led2",
, |3 A5 P0 G; Y! _, n I3 r .default_trigger = "default-on",
+ o+ @( C/ T/ n' x, v },
& l" C1 b: S" x8 i3 o {
$ a$ T( u, P/ f8 _3 L2 E .active_low = 0,
9 H( b2 U/ {. t .gpio = DA850_USER_LED3,6 f$ n4 m1 B. v+ O9 q
.name = "user_led3",
7 i( v9 W7 G4 r9 h* ` .default_trigger = "default-on",
5 p- }3 `5 r; n. i* ]4 j' x },
* N8 o! {. x* Z};; R# R9 y I4 s/ Q1 s5 u
5 P# U- }3 q5 x0 a2 l3 C3 Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: v' f8 V7 u* t2 l( M) V9 A- Z+ l .leds = da850_evm_tl_leds,
: j0 c5 H2 {' k* Z. T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& ?) |6 Y3 H7 C# h' `) g" R
};4 T3 e9 y+ i: D, n9 T6 H
3 k9 C9 E' M+ U& U; ?4 [static void led_dev_release(struct device *dev)
$ E3 O! r+ G: ^{ E) P; s: V* p- X4 o
};
4 j' c" H, i% K8 V1 d- y7 T* x, G# n3 m8 s# x+ k0 I; U
static struct platform_device da850_evm_tl_leds_device = {5 D/ D7 x: U! a: x
.name = "leds-gpio",1 W' t; {2 ~3 F0 h- c2 X4 `
.id = 1,& P, i- t! K2 B/ R7 v3 {8 A/ W
.dev = {
7 ^6 z! j1 @; \9 J* l J7 E0 Q .platform_data = &da850_evm_tl_leds_pdata,
6 D# N0 G* x: l4 `3 _$ E .release = led_dev_release,
4 B: ?3 y: I6 t9 ^0 A }
& G" U G( P* i* f};
- _$ j9 r# N! P
% l! |+ M5 L% t' `static int __init led_platform_init(void)# ~3 P0 V1 d9 Q5 N" T, }
{
) H/ q s) |* K4 f1 g! {* u) d! { int ret;& o8 p+ ?7 _0 C6 R3 {7 E- m
#if 08 ~) Y$ T" B. E! R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 x& o" K" }* I4 I/ j
if (ret)
[3 Q2 G- }. `5 J9 ]% @& V: @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 V; T7 Z$ K: F1 f8 Z "%d\n", ret);# K; }' ^$ n+ K
#endif) O! r- O4 a, g3 a0 U0 D
ret = platform_device_register(&da850_evm_tl_leds_device);
8 p9 `0 x% R0 V' R# n. D. z if (ret)# f& G! v* c) R* R3 m+ @5 q
pr_warning("Could not register som GPIO expander LEDS");: T: N3 s3 m0 L: A! R
else
; o+ n6 q4 a: L2 S- H+ m5 B printk(KERN_INFO "LED register sucessful!\n");4 I k' x) d7 A* \( E9 b
% P7 [0 Q: d! e& y% A B( l2 h return ret;
( `% B) S/ O# U4 X8 S}
: F2 D' I! a% a( z0 t* R) l9 q3 h$ z# `* }' w
static void __exit led_platform_exit(void)6 R, t: H' E5 V' O# e7 \* T
{0 Q7 f$ m8 C) |' e% |% C
platform_device_unregister(&da850_evm_tl_leds_device);4 s, x7 l# J6 Z# H
# _& F7 w$ l2 z3 h8 q, q% R6 I printk(KERN_INFO "LED unregister!\n");
# ~: m+ ^/ V1 I" U; A% q}
2 P, b& ?- t* y1 M
8 S8 x2 V: B, l/ \module_init(led_platform_init);
# r/ Z1 M2 Y( Q- \. r& lmodule_exit(led_platform_exit);
: v5 {5 I$ j" y8 I! A( S: Y) O5 v/ c8 `2 y
MODULE_DESCRIPTION("Led platform driver");
: S Q' D$ X& [' p' U, H! m, D: TMODULE_AUTHOR("Tronlong");( E$ p3 t8 p+ D7 z! {
MODULE_LICENSE("GPL");7 m$ k. |1 V) y! K; ^
( L t( k) A1 T& Q4 Q( y |
|