|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ S/ @" L: E# G; g
#include <linux/init.h>
9 h1 a% @0 E9 C2 R& ^( x: y#include <linux/module.h>7 l6 K) b" L: o7 K8 v! |) {) z1 E
#include <linux/kernel.h>
' ~+ J# @' z+ }8 q; O4 b#include <linux/types.h>) S! m0 h$ x( F# G8 b
#include <linux/gpio.h>
# m7 P8 s3 y ~, @2 F#include <linux/leds.h>
5 E0 u7 {, Z0 ~! _7 s, ?#include <linux/platform_device.h>( v( U; j$ T, X
+ ?9 f' K' |. { c7 z" Q" S* d#include <asm/mach-types.h>9 S+ s& o; K- c5 N4 R# G
#include <asm/mach/arch.h>+ |9 f# I4 d' O3 W* S
#include <mach/da8xx.h>
" C9 d% Z% K# b' O" h* t* }5 M#include <mach/mux.h>
: M- t# U7 Q/ }9 d3 k( K
0 g; M+ h4 Q" J+ A: o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; F3 k9 ^9 t& z- Z) @. k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ Z" p' N6 L7 P0 o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 z1 Y ^2 Y- u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 C# Z0 @* H* C$ }, @4 s" Z; n
8 D$ ?4 ]9 D1 t4 c/* assign the tl som board LED-GPIOs*/2 P' z# F# j) y( S5 P/ M W
static const short da850_evm_tl_user_led_pins[] = {
* L9 ^+ G0 r9 S /* These pins are definition at <mach/mux.h> file */
+ K0 w' T" Q0 Z7 ?+ A/ T/ B" @# c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) a2 \ [$ o6 A# {6 y# r$ t
-1
9 R! k$ ~9 u: d! e};( Z* }* {: a. w# s# ~
9 A% [' d% y7 J. Q) P% ]- B5 R' }
static struct gpio_led da850_evm_tl_leds[] = {
+ e5 I) D7 m) @* S& w {
& Y; L4 F; W9 F; X; j: C; l- a .active_low = 0,4 `5 U* W( j* C. x% `% V0 {
.gpio = DA850_USER_LED0,/ U5 S3 T. n% F0 v+ l2 D0 B+ Y
.name = "user_led0", M0 l" I# V: Y% G$ L+ `5 ?( p' D
.default_trigger = "default-on",
* }8 r8 F* _/ V5 u2 }; q4 C },
9 S9 U3 k3 S! B1 r, E {
s% L, n. d/ O ~ X) v+ ^ .active_low = 0,2 x$ O. h O$ q
.gpio = DA850_USER_LED1,
P% D% W$ }6 b9 R .name = "user_led1",! j/ _- |7 E0 A
.default_trigger = "default-on",
9 e' r5 F# ^2 ^. P/ z A8 E/ u$ B9 C },
% f( e& Z; H- N, {8 ?- |6 c {; d& H0 G/ [9 _, t- W
.active_low = 0, G& G9 i9 w9 N, V8 e I
.gpio = DA850_USER_LED2,
( E2 e' \$ M" T' S2 \, K .name = "user_led2",* j1 O4 z! B* |) r+ i' `1 o
.default_trigger = "default-on",' h. U# |" v- w. W' V7 g2 i
}, V! h& i0 ^; \3 z9 i
{( F4 P! ~, q P, e% Z& X. @. L' f, P
.active_low = 0,4 |4 m w8 u# ?$ j+ {" |
.gpio = DA850_USER_LED3,, b7 O7 Q; R& b: }5 V9 {/ v$ o
.name = "user_led3",' ^1 T6 S6 c: S% F$ `
.default_trigger = "default-on",# P# m: J! E) a) y% I
},
! z$ d( n5 i, k' a0 y ?' |};& m8 a7 f7 I7 d* ?
+ D0 w# X: e( |6 l% rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& Q4 w4 |: D% Q( v0 Q
.leds = da850_evm_tl_leds,
1 q8 o$ ?6 E& G ?: o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: X8 E& Z- M+ [3 b; b
};
. v$ b2 ?" ~+ `& @9 y L q0 L/ E, {1 l- z( d( D! z
static void led_dev_release(struct device *dev)
. r5 o: i9 V* l{
2 {0 e0 S, A, f, A% w" u& X7 |' K};$ C* @9 g+ f1 N% Q+ t( {
0 ]" K/ N) \ q- j* Q) }5 Fstatic struct platform_device da850_evm_tl_leds_device = {
: M: I! M' V/ p" h .name = "leds-gpio",$ w C% R$ i& ?6 W
.id = 1,7 H& W6 @3 n0 l# b
.dev = {
; W: o5 t: S Y .platform_data = &da850_evm_tl_leds_pdata,) q1 T& }$ |$ ^( C6 `% d/ t6 P
.release = led_dev_release,! x5 g$ T: U# C- T" [+ m
}
* G6 ~/ c# J$ z3 @" s};! a* Q( @$ g4 n6 I2 ]
% R0 n+ \# b7 H" ]: X
static int __init led_platform_init(void)6 S- J1 `. V( F, v& r
{+ e _$ \3 X3 t8 l g
int ret;
% @# Z7 L8 g9 a s6 _* M#if 0
/ L/ f3 s& E; F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" w" ^: ^1 g* s3 i. a1 f
if (ret)
: q& }8 f7 d } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 ~$ c% X2 D+ I( n+ D( e" n% P) g "%d\n", ret);
; M- ^& j) A0 p" w) S#endif
+ C$ K" L: a9 l. a, w ret = platform_device_register(&da850_evm_tl_leds_device);" P, F( U7 `# A4 l3 A
if (ret)" x; S m, W' G- S: a" C; o
pr_warning("Could not register som GPIO expander LEDS");
$ c1 X |9 c9 v+ L else7 S; \ w& P5 j, J6 t! N
printk(KERN_INFO "LED register sucessful!\n");9 t R+ I0 J: k1 u# ?! a
3 x1 I9 d: R- r! u- C l
return ret;% \1 P; c' j1 p& @: ~7 H0 |
}
6 O" ?+ ~4 i9 u2 l! F6 }7 T
7 K; e, j$ w. Hstatic void __exit led_platform_exit(void)
) F, S" e0 o( C{
9 ^& z. J6 S1 o, j( _# e6 U) R/ v3 o. o platform_device_unregister(&da850_evm_tl_leds_device);1 I6 z" v7 s$ O9 S9 n+ ]- d& n
, i3 z: I$ D# a1 Y" g6 h
printk(KERN_INFO "LED unregister!\n");
# K/ `5 u, W" X# n$ z" y% j* v}: f9 P, A) L! b" i) J
: O1 U" r B$ Z9 D1 }5 c# B
module_init(led_platform_init);+ C* [, T4 x4 z! u. {' d/ }7 H8 m
module_exit(led_platform_exit);3 @0 V M0 `2 O3 U w
3 Y1 G0 b2 r8 ^0 U. g$ TMODULE_DESCRIPTION("Led platform driver");1 E: t ] U" P ]
MODULE_AUTHOR("Tronlong");, I$ E3 P# r9 M$ e4 T, t
MODULE_LICENSE("GPL");
# n1 _+ Y9 m" K% D4 |: L! @: Z; _+ J% o8 x6 ]) a t; _7 g$ @1 o+ z
|
|