|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 a H; B, ^* F4 u
#include <linux/init.h>, c8 I" F- N0 I( _1 R
#include <linux/module.h>
- M0 J+ R! y0 K6 V3 S* V! l#include <linux/kernel.h>0 S. `+ m4 J# ]! `
#include <linux/types.h>8 Q6 ~0 K) M& y0 p
#include <linux/gpio.h>
5 K* A1 a! a1 W. `" Y0 p#include <linux/leds.h>& r# C: y$ M$ O( q& v
#include <linux/platform_device.h># f+ M# {* |! F, h: Q' l+ N
4 A* z" J: U2 s/ d2 a( |/ k
#include <asm/mach-types.h>
( q/ J7 o$ D. X! \0 S& W#include <asm/mach/arch.h>( u1 Y1 h) y( m6 `8 ^% [: P) h
#include <mach/da8xx.h>1 H$ |' l$ S1 b: h
#include <mach/mux.h>
7 S+ `; U# Y, w1 l
/ e% n4 d* E# ^$ X( x' ?$ M9 M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ y' n- @ p$ V5 b: K. _! K2 j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# ]! m3 G& _5 E6 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- a0 X( E* d+ k3 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), D. R& \2 }8 i. q2 f0 @: z. E1 o
& r2 h1 _" T" ^- r" |
/* assign the tl som board LED-GPIOs*/$ q& v/ }9 P' \# ~, o$ N, w m
static const short da850_evm_tl_user_led_pins[] = {+ Z3 v4 H5 |' O5 ]/ V* M
/* These pins are definition at <mach/mux.h> file */2 }6 U+ L" t) p6 \' v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 n. ?- X. j4 X3 M+ e) @
-10 L" } j! \* H' B. C" s
};( |0 q3 h6 W, w& I
& ]& U5 y% e4 s: B; \static struct gpio_led da850_evm_tl_leds[] = {# l: Z7 m" m! X6 ?* i
{# h3 `; y% x1 G3 N1 K+ j" D
.active_low = 0,
$ p4 U9 U9 e" T .gpio = DA850_USER_LED0,
' q) O) {1 z% o& ~! l- S: m/ } .name = "user_led0",8 L) p5 g. a3 e
.default_trigger = "default-on",
$ a# ?% Q* d" q c4 n1 h },
2 V) q6 w) Q. O' G$ }+ v2 r7 E& [ {; z* T4 m3 g' ?9 t5 n7 b
.active_low = 0,& O, d' q( e$ }
.gpio = DA850_USER_LED1,
; \6 ]& S' |. B5 e- O7 ] .name = "user_led1",
M; r+ ?6 l- ^! ] .default_trigger = "default-on",
. e! Y) _2 x) }7 y },3 A& v4 J1 h( k7 \* C7 b! H* F9 h
{. d6 n. v6 h; `5 b& _
.active_low = 0,
A7 j9 e, ^ m$ Q6 _# b8 ^ .gpio = DA850_USER_LED2,& y$ `. i3 E) ]$ V4 L4 s/ d
.name = "user_led2",1 q' ~7 E9 n$ }- N
.default_trigger = "default-on",
2 ^8 m7 Y( R1 s( t7 v! |$ G },: H7 w) O) ^) O4 ^5 Y: V
{
$ l8 H6 t$ u& H7 U .active_low = 0,5 q8 Z8 j/ X _# e: d
.gpio = DA850_USER_LED3,( r% F9 V. G5 i8 R
.name = "user_led3",9 k* H4 c% w: Q d1 T
.default_trigger = "default-on",, D) I. M0 x$ u/ _
},
8 L6 _" l; u2 o2 d};
1 G$ w) g9 _# T4 {9 C }! N8 W6 S A% M0 @; N; l( U) _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; D5 B. L2 Z* C8 O .leds = da850_evm_tl_leds,
. E, @8 n# M% y( N' A( n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( s2 R" Z4 B0 y3 o9 j. {};" d' P6 [3 x. l. c
0 A! ?5 H/ L5 d* |5 r) s) w
static void led_dev_release(struct device *dev)0 y$ E' P) s; ^* a' u
{1 E- \: e. j* g: [; ~
};- S9 h+ |; h+ v2 J' W
3 L' M" I) g3 f/ ]& Istatic struct platform_device da850_evm_tl_leds_device = {
* @+ H3 {3 Q$ w' Z& I1 ^ .name = "leds-gpio",# C& ]1 p6 l f! T9 T7 ?" x
.id = 1,1 ]' B( P* [2 N$ g8 a+ c5 ~
.dev = {- v9 I6 r# P; M3 N7 u+ U
.platform_data = &da850_evm_tl_leds_pdata,
- u! t& h; S7 P: {& x* o .release = led_dev_release,
- S5 f, P+ G; G' s }
' b* {* j4 x( ~8 E$ h& ?! w};" N* S& _: m6 Z" c, b* n9 Z3 V
% _& m' F# X- J% O! |# `
static int __init led_platform_init(void): c2 _0 A, i, Q6 S
{' j# l. v. D9 v& {) R% }+ z' M' d0 @
int ret;$ M- V5 r- o4 i! {8 @
#if 0
/ x4 \- n' c9 E& ?* M+ T+ u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 T: u8 S+ x9 m, _( _ if (ret)
- }0 Y' A* ]: U- M$ X- l, K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 f9 x/ c2 }/ Q' H. ~9 T* K "%d\n", ret);1 R1 _% g' f# |( q
#endif
3 X: g8 u5 D: j) V: w ret = platform_device_register(&da850_evm_tl_leds_device);# ^# K' Q% @+ H" m$ N5 Z
if (ret)0 [& q* I+ {* {
pr_warning("Could not register som GPIO expander LEDS");( {! x- s* j7 ~: d7 _' o
else
; x; D2 c! s w% U+ S- n printk(KERN_INFO "LED register sucessful!\n");
2 N j8 O7 J4 o5 L% l9 S+ D! U1 s) E6 k& Z3 Y+ m4 \$ k
return ret;
( O3 t/ d* W, o- e+ }5 B& S- i}0 s: O0 A- {) E4 v) u# L
3 S3 p; ?1 _# Pstatic void __exit led_platform_exit(void)( {7 T2 V1 H" k! W0 Z
{
8 Y) d1 C }( \* I" P# T+ Z platform_device_unregister(&da850_evm_tl_leds_device);5 i" Y# t# E5 G
9 t, V4 Y2 C) F; o, R
printk(KERN_INFO "LED unregister!\n");4 ~: [( o& g1 p; v, L- g
}' @6 C/ g1 q8 }% Z9 D- }* ]- `
* {) K: I0 ?7 a- ~( C% R |
module_init(led_platform_init);
! Y, Q- A5 E& @0 W8 Bmodule_exit(led_platform_exit);
) c; \3 [$ |' l, F, `5 ~4 u T5 C. [/ j* q* g
MODULE_DESCRIPTION("Led platform driver");
! ]/ E$ N6 L7 R3 |: }8 u2 K# VMODULE_AUTHOR("Tronlong");& P* m& B9 ?# L" X( t+ C
MODULE_LICENSE("GPL");
3 B8 G+ K$ N) \7 \8 V1 l, o) S9 k- O9 K+ V* L* h( G
|
|