|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 E" l. ]" W) j; j; M( j" t2 e
#include <linux/init.h>+ n. Y" w) _3 u
#include <linux/module.h>
! M( i% h1 d. J" G#include <linux/kernel.h>
4 [2 X+ x- A q4 l/ Q3 I t#include <linux/types.h>
( ^/ g8 I9 i8 g) m$ Z4 e% r#include <linux/gpio.h>8 F0 I! W9 M; J1 j) C
#include <linux/leds.h>
G# R! u7 @% X( y v- v#include <linux/platform_device.h>2 P5 J5 P5 \& @& L5 j- Y
0 [( Q9 b1 X+ a( {3 o, Y% c#include <asm/mach-types.h>
& B3 {2 l7 m$ J5 F3 B#include <asm/mach/arch.h> T2 p- N+ Z; |4 |
#include <mach/da8xx.h>
2 n* \; V! ~( F1 n3 \5 W# t- ?#include <mach/mux.h>
% i% T: Q4 s ~! J8 v0 `2 [- o. r3 t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' U( o+ b2 P: @0 F3 N y( V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# c- b" e/ Y+ n9 b8 D+ }/ t; R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 ?" W3 v& Q8 G+ I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 n2 \( R6 J+ j4 o! l$ Y: s. `
9 B& y5 ]& l. q& Z2 H4 z/* assign the tl som board LED-GPIOs*/* p+ G0 _# d& X6 R7 l
static const short da850_evm_tl_user_led_pins[] = {
1 Q2 p3 t8 V6 g% K /* These pins are definition at <mach/mux.h> file */8 Y) |5 O$ v+ {/ {* ]; H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) G5 T8 Z. L* B: h, G
-19 _) u/ [( b+ _* {6 Z
};& p1 V$ }3 N6 a' U2 V
. c( {# `7 F. D1 V5 l J& Tstatic struct gpio_led da850_evm_tl_leds[] = {; Z0 [4 f9 |( l; z4 I( @/ K. ^( g
{9 J, k2 s3 q+ c
.active_low = 0,: v* g) Y7 g5 |0 p, y, h
.gpio = DA850_USER_LED0,4 a- \% f1 V+ [0 C: T n7 @2 i- l5 c
.name = "user_led0",8 Z8 a+ p6 K! m' L& ]
.default_trigger = "default-on",
% p) Y2 ^8 q: E" ~ },1 z) Z1 D& f: ?+ D% g
{$ B# i8 B9 ]) s" [ z# `5 m; _
.active_low = 0,, G8 k& h9 c; n0 p* O+ e8 `( o
.gpio = DA850_USER_LED1,
. m. m& f6 D: [7 ]4 b) W5 h# ?% X .name = "user_led1"," p& H5 ]: O$ d- I+ ^
.default_trigger = "default-on",
% D j- l$ Y R- a },- O5 S6 m% C% {$ Q8 H h
{
. x" A7 o( I: s4 c; q .active_low = 0,% [ c b. W( G- o8 I$ ?" x4 o8 ]
.gpio = DA850_USER_LED2," Y( o& Z4 @5 N( G3 r0 w7 `; M
.name = "user_led2",
6 J' [& b4 t9 v- s+ }6 H( |* l, L .default_trigger = "default-on",
# d. }4 I3 I$ x8 ^) s },& w/ h$ W6 _8 ]' B! t* l
{
2 X, T) B8 x$ b7 Z( ^" g .active_low = 0,
% y5 ]5 V2 D0 x! a4 ^9 b .gpio = DA850_USER_LED3,
, D% _1 |; B: u .name = "user_led3",
1 L/ h, n/ e/ s7 m; }: c .default_trigger = "default-on",
) n0 d3 O- Z7 S, W9 q( P },
, G4 r4 s2 \/ b; D9 C};6 c5 T; |2 Z1 V7 p u
: p/ T( F/ J- B2 F( N$ T( `7 @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 X$ r7 I1 T# I5 L# z1 |+ W .leds = da850_evm_tl_leds,# L$ X5 D' [6 V. X! j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! I2 N; E6 ~0 u8 ~3 C! ]6 W) ?};
6 p0 b4 R4 m5 x W9 }$ w9 n
% s) g' A) p4 G7 mstatic void led_dev_release(struct device *dev)
1 B/ Y9 |) l1 d- \4 t{2 `# V, Z2 r3 ?" @
};! Z4 x# P+ j, m2 G9 k( \7 Q
2 U: q5 Q3 m" |4 s& I5 ?! v/ _
static struct platform_device da850_evm_tl_leds_device = {7 n0 W) _! A2 p. P+ b! Q
.name = "leds-gpio",
( ]0 a4 l7 P" Y | .id = 1,$ e- b% ?+ ]/ @ @) t$ I
.dev = {
& ]+ A, ^: i& p0 J .platform_data = &da850_evm_tl_leds_pdata,+ M' ~5 F! x, }# @( V0 ]1 }8 K
.release = led_dev_release,0 c" f* q9 X# ?+ g- N$ G2 a
}
5 p8 S& z5 {2 U1 T. P i3 u+ o};
% @' K2 T% N$ y- v) N! C" X4 {8 W1 K' w8 ^" [
static int __init led_platform_init(void)% { ^# L+ Y2 `
{
, D, u/ ~ _0 v- M+ M& E3 H& X c; o int ret;
( g ~* o4 f3 p# q2 c#if 0# u* o* k9 q4 A: {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* h4 ~7 c/ U8 S) @1 h if (ret)% w' y8 K1 m3 |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: _3 I8 e3 F; s' J8 x' o "%d\n", ret);' [ P+ p; [8 v; L* D
#endif
$ S3 X2 i2 D4 X6 _) J, s0 P ret = platform_device_register(&da850_evm_tl_leds_device);
- i* O5 p/ Y* X if (ret)7 X. c0 o+ J# v/ s8 `( l' @
pr_warning("Could not register som GPIO expander LEDS");
1 K' g/ V2 p! c6 W' M1 n. A2 `$ e else
9 T7 I7 y7 f7 R& v4 w' ~5 T ?( }5 b printk(KERN_INFO "LED register sucessful!\n");
X/ C0 Q5 D7 W# f" k% W; a# G4 J
3 _& W3 g' w; c5 j5 O$ Y return ret;. i x! ^3 |; U
}& A# k5 u+ V2 U3 w/ o, n
, [* s. v. R7 k6 fstatic void __exit led_platform_exit(void)9 z* U2 q5 v7 x0 Y8 k
{4 o- M: ^, x" D- _+ J8 \! k% g
platform_device_unregister(&da850_evm_tl_leds_device);% L; x" h* k5 t
! U8 G' h1 j3 t4 S& @, Y
printk(KERN_INFO "LED unregister!\n");
/ {! p# K8 I; \+ z) M% o* P}7 ]# g- y* W9 J& T; p& Y% K
* H t) q% ?5 I$ q3 ^% s4 I2 Jmodule_init(led_platform_init);' L/ \' {6 J, Z1 A. t8 ~
module_exit(led_platform_exit);/ `& _ h0 K& G, h8 r
: [% {: R( b/ v( b6 Z& A, S
MODULE_DESCRIPTION("Led platform driver");
; |# [& N) G) \MODULE_AUTHOR("Tronlong");+ y; B q7 l' O1 e* ^, X
MODULE_LICENSE("GPL");
8 o3 k1 s* w5 D3 V6 X4 y) T7 B0 l& E f# J
|
|