|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' w( \! F0 q/ p
#include <linux/init.h>
* V# G% o+ I" H, o#include <linux/module.h> D4 E2 Q1 V. k: @8 U5 D
#include <linux/kernel.h>
, @4 P% |; }" ?( J- |9 m#include <linux/types.h>
- r) z4 P7 j* t; g#include <linux/gpio.h>) u8 s d8 |; P3 h) p* t
#include <linux/leds.h>
; S h8 o; `! X; L! v#include <linux/platform_device.h>/ z$ n) A: _$ o W5 R4 q
* C0 l [" b* F, x2 c+ E) f$ \
#include <asm/mach-types.h># ^% i; c/ M- E4 i) A
#include <asm/mach/arch.h>
- p9 w! O; P0 x t#include <mach/da8xx.h>7 `- T. e1 w) y! r
#include <mach/mux.h>, u. W7 W( H2 ^! O, D
8 g7 Z# ?4 S9 y2 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* f0 |! f E) ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 A+ m, m4 j3 A3 j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& M4 b; u2 Y9 @6 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! c7 D4 `0 N. m4 k2 c; _" J2 K+ j' i2 Y& h. ^; }( N( ~
/* assign the tl som board LED-GPIOs*/
) e B1 F( t% M* x0 Hstatic const short da850_evm_tl_user_led_pins[] = {3 ~. z, Y6 }: z$ s, R! }+ d6 V
/* These pins are definition at <mach/mux.h> file */
) M$ M8 I' L7 Y8 M/ o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! J6 o6 v" {: z) N4 K. u2 u' V% ~
-1% H- l0 t# F$ r7 L
};
5 C& V/ [! v8 I
. I( `2 L9 ?& W/ ?7 J0 W- `static struct gpio_led da850_evm_tl_leds[] = {1 _7 c* A; n- x2 `. c; p
{
7 L6 |9 A2 a- \* W' [7 r .active_low = 0,, N2 v Q$ t$ L0 k* `& ~
.gpio = DA850_USER_LED0,
% D( h1 t7 e/ Z( o2 k .name = "user_led0",! ^2 O% d3 Z7 }- _7 ]- B2 I; K
.default_trigger = "default-on",
$ W4 U. n" h" s },
2 d' L3 u9 l$ V" p$ n {
0 I7 |' P+ t8 K" N( Y f, b .active_low = 0,
" u, c' E0 h; }5 u .gpio = DA850_USER_LED1,7 J6 ]4 t A# z6 s; i
.name = "user_led1",
- y% _& H$ q. a, ]7 Z% k .default_trigger = "default-on",& F1 z( ~% G0 a: Z" H' A+ b$ ~
},
/ f- a' L# @) f& M! { {
E5 e$ `' h; ?2 M& B# _" i. X6 H .active_low = 0,
! k6 R2 d% y: |( o- M8 n N .gpio = DA850_USER_LED2,* o* u e* n' x# e
.name = "user_led2",2 E9 ^; @2 {, X7 E! N
.default_trigger = "default-on",# _* a+ H2 T* `4 ]) `% n
},, O3 S3 K# o( \3 [
{$ Y" l1 X/ n) h0 X" s7 V, x+ \: [( ?# V
.active_low = 0,* @3 d; z5 E& y
.gpio = DA850_USER_LED3,1 e6 N7 y: j Y2 N- p, i! o
.name = "user_led3",
9 z& @( R! Y! K2 |+ {, B% M3 ? m" Q .default_trigger = "default-on",
; A& A6 o8 P6 W, _% g6 O },' R9 B: B9 J& l
};
1 ^4 z+ x' y3 i5 n8 c% }1 U" B" q& f, T& x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# c3 `$ P; }3 t .leds = da850_evm_tl_leds,9 I. X8 E7 J1 I3 y. x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 w0 D9 I& @ W T: x0 J8 N4 X
};/ J/ @7 V' D4 m
, ~. n) x N. ^6 b; l. Kstatic void led_dev_release(struct device *dev)( Q( r4 d7 F; x
{/ u: W ?7 k! G8 ?9 t
};
+ {2 i; }- T3 D0 I: k: y" H5 }6 E. j: H. A% N% g0 J6 r
static struct platform_device da850_evm_tl_leds_device = {: |% @# _& z+ c, k; \0 j
.name = "leds-gpio",
7 O& J; x% P% C/ h .id = 1,
; I% Q$ i% C+ g0 Y! t) I .dev = {
9 }$ }; o% ]- X# C .platform_data = &da850_evm_tl_leds_pdata,
5 c- T% K% ?7 O. U& i( G .release = led_dev_release,! U# j# U" I* S) a. \, P- F) J" S% m
}
9 U3 |' S0 H' h0 C' L};6 @, y7 [7 Y4 o3 z) M0 S/ g' n
7 t- j* V% k" a. `
static int __init led_platform_init(void)2 C9 B% o* [9 |! H+ l/ Q! G( h& u
{6 i ~4 T0 G- g: m. _5 w
int ret;
: L6 X( n$ i0 g" }4 C#if 0
9 s& |2 j8 T, W7 L; { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 t; G/ R* c; N& n$ z
if (ret)
0 t, w) M' k$ }4 t; h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 x1 v( E; m7 w c5 h "%d\n", ret);) V* C7 x. L" z% h" ]9 u
#endif8 r% f: c' V( X3 j1 m" G% z
ret = platform_device_register(&da850_evm_tl_leds_device);: x' j7 Z; D/ O( a
if (ret)
( t* B. M/ E' w. Z# z* b; n pr_warning("Could not register som GPIO expander LEDS");
5 ]$ @6 _/ K3 N8 L$ z% t else
, Y: J. ]4 @& t) L" k printk(KERN_INFO "LED register sucessful!\n");: n9 L, k4 w. H. a
+ m# m+ F% y) ?! `
return ret;
) ^* i: J3 w+ I2 G}, d k# `. L1 l* X2 T- E V: R
! P) A! P% g% B, astatic void __exit led_platform_exit(void)' q0 H$ _: d! [; @
{# R8 C3 [0 F: A) r; k0 `
platform_device_unregister(&da850_evm_tl_leds_device);. k$ q; g4 c3 Y6 ]2 H+ y6 K1 p* m
2 W i" ?5 b. o3 F, h2 n; |7 P4 G
printk(KERN_INFO "LED unregister!\n");
3 {$ B, y7 W. U' j}
! T* i) |7 Q2 I7 x, e1 m+ m
% q3 V% q4 i% m2 t; \$ |module_init(led_platform_init);
/ @: `2 j" @$ h* C% fmodule_exit(led_platform_exit);$ O9 I) p: `. J9 g# s0 A
) l/ s$ j* {+ @( l+ ]' f( F# q# uMODULE_DESCRIPTION("Led platform driver");/ I" R- [* h+ Q. I
MODULE_AUTHOR("Tronlong");
- f* |% s! A# |4 aMODULE_LICENSE("GPL");
9 F4 R9 N4 E* E- E! L3 N/ D" A* n) O9 y5 [6 l4 C) M& m( P% v
|
|