|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* u. h7 p, k3 O9 C#include <linux/init.h>
5 k3 w. q& t( q' H8 b#include <linux/module.h>+ @+ a5 Z& h/ f9 G0 B' x- Z- [& R
#include <linux/kernel.h>; `7 X8 A& \( D9 @
#include <linux/types.h>( O7 t, P) c- V
#include <linux/gpio.h>
4 X4 @) L. \* i, D( ^9 O0 `9 I+ e/ T3 O#include <linux/leds.h>
1 S, @5 O# Q: o& F/ P. s#include <linux/platform_device.h>, w/ P B) q$ J3 ~+ ~; z/ r
% @, z7 Q5 P) N) w
#include <asm/mach-types.h>
6 B3 I! o; q+ R6 @#include <asm/mach/arch.h>
( H$ Q! }& V0 G% g* r8 w7 _" g#include <mach/da8xx.h>8 ?6 H% u' ^, H2 F: [
#include <mach/mux.h>; M, Q. o! t! \4 Y9 z, v
, e8 r" P+ K- o, Y) _9 c) N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ P. d2 k, {2 S8 w, e" E0 z7 Z# S% N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 o& y O8 G0 C1 i) d1 ^1 H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): D2 S) }( e1 F% H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* d1 N/ E" F' Y: a; T$ m4 B, t" F. ^, g& {
/* assign the tl som board LED-GPIOs*/2 M% F/ J5 s ]! ~9 T
static const short da850_evm_tl_user_led_pins[] = {5 Z! A$ X+ ]1 c: H
/* These pins are definition at <mach/mux.h> file */
2 j, S! q8 P3 `# ^( O, S: | W, W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ l2 U: _ ?# n4 }, O* n! t W -1
. G: e: f4 W; f! _( W$ U};7 p1 k8 {% O9 U7 M& }6 @% W2 ^
5 y8 Q% _- k0 p2 p& l+ F. U7 Xstatic struct gpio_led da850_evm_tl_leds[] = {% A' ^6 B5 ^4 L, F. W+ U/ E4 Y) {2 ?/ T
{
L9 L+ _1 ?8 [; r$ Q1 \ .active_low = 0,, q, v1 K- B0 G* n
.gpio = DA850_USER_LED0,( s* A$ b4 y8 Q; }0 B% s- [- G1 ^
.name = "user_led0",6 j9 r2 N# u# D% \% _# P% P
.default_trigger = "default-on",
) v5 F2 k& D2 a+ s& \" e },
/ b# S- p' A ^- A {
# N* c+ B$ d& t5 O$ d1 D# ^& V+ V4 U .active_low = 0,
( P9 o* e' z" S. H .gpio = DA850_USER_LED1,5 T' p' |& V; ] ]6 H
.name = "user_led1",
. d3 M5 o9 L& O r# |3 [, h3 q9 r .default_trigger = "default-on",
# ]* T# o K- c3 c, J- a9 U2 M: { },! g- C, m& r: L0 u8 v" O7 o- |7 P0 o
{" {/ j0 R) Z) b1 G& w6 J
.active_low = 0,
$ H( n+ D; I3 ~6 } .gpio = DA850_USER_LED2,
~7 P1 X) C9 p% k2 g6 D8 d* r% M6 i .name = "user_led2",$ \" Q- s& w* n8 f, e" |4 {
.default_trigger = "default-on",1 M! b5 o& K ~
},. Y) N0 ^9 b3 g
{
( T$ }3 K- E; M- t$ N .active_low = 0,
7 F5 X' @& e. t" S" [ .gpio = DA850_USER_LED3,% _3 Y( b6 ~8 t; H5 x
.name = "user_led3",
! N) Z6 v' C1 Y. \ .default_trigger = "default-on",/ d. D) B2 \4 n: d
},7 x7 B1 w1 a$ w
};/ ]6 j- [* x: ~& V, {+ ]
+ t S, U. y; [6 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. I; x! |2 v" w1 E. @
.leds = da850_evm_tl_leds,! R e5 ]! e% t d% t0 `/ g- u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% u5 c' C! P8 L0 j};
& g' h) R: K" [- A6 R% X1 k. a+ D9 m, m0 P& o# U
static void led_dev_release(struct device *dev)1 P/ C' D" s0 u, Q0 [ T& A
{7 q# z- u" ^: U' A% \! S
};% ^' {. _2 R5 h
1 Z2 T0 ?6 D0 C: ystatic struct platform_device da850_evm_tl_leds_device = {
! S c2 C0 h/ I4 \$ t/ q .name = "leds-gpio",0 W1 p: ~- G& [: f- S! d- S
.id = 1,
0 }' I% a4 h* y4 ^ .dev = {# ]9 D4 v, [( W% A1 K: l6 C
.platform_data = &da850_evm_tl_leds_pdata,/ Q- G) ~. G$ B* ?" N/ L% G
.release = led_dev_release,
% M: m% X& `. I. m! o0 m/ M }% Q, g' Z! j, J" K- C- w# d& B
};
4 f( ]: C% @# H& Q9 |$ @. }2 A' o5 W; ]: |
static int __init led_platform_init(void): u/ m9 o& B0 t4 i7 F9 M- v+ r: D/ w
{ Q" s/ g' `3 a
int ret;8 T* Y5 C& p9 C; [4 m" u
#if 0
% [. H" A' z; C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ j! {# A( b' ?
if (ret)- G! f7 w2 }, P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 v) Y7 }' M8 K6 G9 Z% y* } "%d\n", ret);
: C$ i! ^3 O% A. O: r#endif* f7 L5 T( ]: I- w
ret = platform_device_register(&da850_evm_tl_leds_device); d0 W ?6 P1 u
if (ret)
# b; N3 d" [2 ]9 k% f+ V pr_warning("Could not register som GPIO expander LEDS");. y" {. a) b$ X
else0 g% c t3 {9 r9 V n# c
printk(KERN_INFO "LED register sucessful!\n");
# b+ f. D0 E- X. U3 G8 P5 ^, J. ]/ V8 U0 [
return ret;
8 q' K6 z$ }! z$ C/ H}
' V% S8 \' k, O* w. o, d5 s
! O2 v7 p3 z4 z5 K& hstatic void __exit led_platform_exit(void)' v* y( W* |2 Q4 j, H
{2 R7 O8 k, M7 b; D9 b4 O
platform_device_unregister(&da850_evm_tl_leds_device);+ c: ]; n; K( T% ]& A* z! k
$ x+ F- z. e! x# F; \0 R9 K/ F printk(KERN_INFO "LED unregister!\n");
: K& e2 Z/ l7 S# \9 |}) B8 y/ g2 S2 |, Y6 n9 z
; [- T& E) t. B" N
module_init(led_platform_init);
$ m, b: k8 y* m* v, Fmodule_exit(led_platform_exit);
% Q( a4 j1 V1 W* c7 d) Q' W( ]+ x
# c |& _$ ]9 e- s. OMODULE_DESCRIPTION("Led platform driver");
- S- P' H2 ^2 |" z1 C# uMODULE_AUTHOR("Tronlong");" |- b: z3 s- ~) T( E4 W8 h
MODULE_LICENSE("GPL");
1 Y& K- _6 q$ n5 ?3 c, Y8 Z" K3 O
6 `5 ` j9 w8 ]( G. A0 r3 {, _ |
|