|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* ]: Z! u' m5 l; n# ~8 ^#include <linux/init.h>( L" `6 K6 V$ o; p! p/ V
#include <linux/module.h>5 i; B, t4 n! ?( S
#include <linux/kernel.h>' m% J$ a% O& M
#include <linux/types.h>: q& C/ {' y& w: Y
#include <linux/gpio.h>2 A* b& B" Q. n' A8 O
#include <linux/leds.h>
/ I+ x9 C/ I0 ~ ^#include <linux/platform_device.h>" a4 F- [4 w1 g, g
N# x8 @8 s9 C# D# [$ ` w
#include <asm/mach-types.h>
) r7 p( F4 x! Q# ]#include <asm/mach/arch.h>
4 r1 ^8 ~! c! U#include <mach/da8xx.h>
6 l% h& L x2 p. E#include <mach/mux.h>
2 q' n# D. Z/ k J$ p0 o" S7 K' A/ C# i+ @) ]6 f( M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 z: ?) A0 f. e+ O' }4 X6 c5 J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 Z/ z0 z, ]( B+ q& E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 z' V" `% C: `4 P+ y9 ?$ U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# h6 X" Q* M: w* f3 U- Q. |
# r: `% T7 c" i3 _: v. F/* assign the tl som board LED-GPIOs*/
2 s7 R0 f* V! T9 k; e6 estatic const short da850_evm_tl_user_led_pins[] = {" ]' a$ g+ y, F* W3 }
/* These pins are definition at <mach/mux.h> file */
& d& |; n( d) e, R+ V" ^# s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! G9 c) W3 h+ `6 D6 p O5 F -1+ V. u+ W& t6 V' j9 f; |3 M" {
};& ^* y P$ H/ L! d* o. J% M
9 k2 E2 F( ~+ B6 b1 [/ L: Q$ `static struct gpio_led da850_evm_tl_leds[] = {' @. ^9 b7 ?6 I( K" v9 {
{/ Y3 \0 M. A$ y* n
.active_low = 0,
/ j3 `' a4 f1 b" w7 s4 ? .gpio = DA850_USER_LED0,
$ ~$ g$ t' T. {1 V8 E% ] .name = "user_led0",
0 @6 a* J" @$ Y0 p+ j, C .default_trigger = "default-on",
: d% [6 Z9 l( M8 g },$ P; g4 a: o1 ^0 @5 u3 `
{
. h- |* O* H- b; O* B! B5 ~1 ~# Z .active_low = 0,( g6 c5 V; c# A3 V! ?
.gpio = DA850_USER_LED1,3 v. t/ C: x, h+ R" A7 w
.name = "user_led1",
V* k9 P8 m1 a4 A# ? .default_trigger = "default-on",
# \- ? H5 J7 v- e },, ^4 u* Q/ t( f* x
{* {# w! T* d& T/ h5 P0 [$ h
.active_low = 0,
: s% O7 X0 n) c L. D3 ? C .gpio = DA850_USER_LED2, a" G+ _7 _% A0 j0 [* a
.name = "user_led2",
, h0 K7 y* N2 [* ]# H: i' i% D .default_trigger = "default-on",1 ^7 d" e* b0 y1 u
},# s" ~ m1 Q z! d! Q, t
{$ Z8 |$ J/ H" f5 a# V1 V5 F
.active_low = 0,- u' L9 D& o* }' [9 F6 U# }' E
.gpio = DA850_USER_LED3,
9 d0 r% Z% G7 e .name = "user_led3",
% M: w P' g$ \+ {% a" s .default_trigger = "default-on",& D) e( i; P4 e$ c
},
8 h( \/ L! P; n};0 j* Y/ u& o1 O, M$ s- x( M
" m) D! G9 ~ gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ w' ?: M# ?6 q r/ b# A# G .leds = da850_evm_tl_leds,
: c, a3 F, U3 K5 ?5 I( g; }: O1 Y) m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( G( F( p) o; Z% i& n5 O! J
};( X8 D6 E/ A6 C5 P# G
+ M" p* K" Y! }' ~
static void led_dev_release(struct device *dev)6 k3 {( F% n U% z e6 v6 `/ _
{3 `) c5 n1 v* J1 m
};
4 s9 m; Q' ~% T7 y+ B) N( |, ^. E* a. n3 z( X! c T; S
static struct platform_device da850_evm_tl_leds_device = {, {( w" g7 i( g3 i `
.name = "leds-gpio",
& m) i/ A9 r( b' A& l1 s .id = 1,) v7 H8 h* c# t( c: w
.dev = {
/ @6 Y* ?* R$ L- g0 d .platform_data = &da850_evm_tl_leds_pdata,
+ D W1 ?! v: Q8 i! i: z8 M .release = led_dev_release,
7 U) E. A1 V0 i0 y$ _ }' R5 d8 N0 E. D4 d; w! X0 W5 a
};
5 F2 k- |7 M: H. u
& B7 P4 p- k0 V% Cstatic int __init led_platform_init(void)
; X8 B0 p0 B% k+ X+ o Q0 p: t{
+ ~- f; b* h4 n* u4 T! L0 B7 V int ret;
+ y7 I: n$ ~9 t; g$ a9 `$ F#if 0* @% k3 F% z& B8 O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 B4 Z# A0 ?4 a: d6 ^ if (ret)
5 i" ]/ d [) G6 p: t3 L! p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; O, G4 \2 t. H3 r "%d\n", ret);% o9 t0 Q' o o$ I$ T; F" I
#endif
4 H- Q, ^- y% i o ret = platform_device_register(&da850_evm_tl_leds_device);; X" N1 t K- v& a0 h# o( @
if (ret)% X# e) \) o/ n% z
pr_warning("Could not register som GPIO expander LEDS");
+ i# ?1 W* `5 }' H1 }4 M else ~. C$ ]2 R2 Q& W; V1 c
printk(KERN_INFO "LED register sucessful!\n");, s3 W1 U% e2 U8 ^! ~) ~; m
4 Z7 q) r3 t _
return ret;4 ^0 m# p6 ^2 |- k5 o& I, i
}6 p4 A0 w' v' ]" J8 W# }/ c6 s
; F- T8 p( C( u* E) ^3 qstatic void __exit led_platform_exit(void)
, y! L9 r8 T. z7 a( w3 c{- i1 a; h# Y% f5 O4 `0 M( t4 S
platform_device_unregister(&da850_evm_tl_leds_device);- R! W: m7 G1 c" W; A' w' Q$ B! n7 V
' q% f; ]7 m% e, ^2 ~8 j9 l printk(KERN_INFO "LED unregister!\n");
( z' j- c+ I' A! ~- k! }1 Y: _}2 M) w6 b9 I( i" b" N' S2 s9 U/ C
& B7 V a; w6 \9 a" i) c7 Tmodule_init(led_platform_init);
/ ]( m& N$ g9 | o; ^# f. nmodule_exit(led_platform_exit);# s. A+ |! ^$ T) j, H! V, \
: w) Z: U# } G
MODULE_DESCRIPTION("Led platform driver");
5 q. C, O7 V. o3 Y! P4 VMODULE_AUTHOR("Tronlong");
7 M9 ]0 ]" T- c9 e0 {( h! |# \MODULE_LICENSE("GPL");
( ^) I" F! \, t7 R
0 R! V1 Q2 Z/ V |
|