|
求大神给下面的程序做注解,请稍详细些,谢谢。
! ~% F/ s. |$ Z* K) `' D9 i#include <linux/init.h>4 C! u+ H8 R) B/ e+ P i% E) g2 [+ k
#include <linux/module.h>% }3 [9 C# d% L1 j6 w
#include <linux/kernel.h># J# u# T' U# e# w3 n0 Q7 P
#include <linux/types.h>
& m; b3 Z9 X8 @+ y#include <linux/gpio.h>; i/ a. j+ }# T, c3 w7 u0 f. a* k
#include <linux/leds.h>
3 n0 p/ C- \1 _ p#include <linux/platform_device.h>
b6 A; D+ L3 u% e8 ]/ b
' p, V& V! J8 b+ ^$ w* a# `- n#include <asm/mach-types.h>
8 {; C+ \0 C+ \- c& L2 ~& p0 j#include <asm/mach/arch.h>* M6 r$ E4 n, f* c
#include <mach/da8xx.h>
. ^" E% x* e# Z) N#include <mach/mux.h>6 L1 H$ L5 S' u
% L5 }! m9 h2 ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 s: s3 i ]: g8 Q3 M* n9 _0 \0 K' p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) K. @; |3 E$ \: m* n- D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ R* u7 T8 o& K# }9 x6 @7 L: D2 q8 h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- }$ }% @2 ]" m$ Y( R# D- Z" t# m9 s
/* assign the tl som board LED-GPIOs*/$ @/ B$ B8 d8 x7 T
static const short da850_evm_tl_user_led_pins[] = {
6 ?# I4 v% c: J6 g$ n8 }0 D9 n! T /* These pins are definition at <mach/mux.h> file */) M! S% b4 i! \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 c! ]" c2 n' E; D4 z
-1' W0 e3 r2 V( p7 P# y
};* x1 C" h7 Q( z5 p
. t0 D2 |3 i- T
static struct gpio_led da850_evm_tl_leds[] = {
0 H- s: F/ L$ v+ R4 q# w8 `& w9 C- j {
9 Q1 Y1 m, I, S. V/ b; V .active_low = 0,0 i/ f! r; k0 p; x7 R. Z
.gpio = DA850_USER_LED0,
2 A7 l4 |2 r) G2 l$ Z! E% ~, T# S3 Q .name = "user_led0",
6 c; n8 J: [8 N% l8 L A4 b) y .default_trigger = "default-on",9 ?# J7 K% s5 E( E) U; c
},- t- R. R* P3 u* _1 ~$ H+ u7 z
{
, U) ~# R; U+ L/ [1 E5 f .active_low = 0,: Z6 O. L% T4 J) |+ f
.gpio = DA850_USER_LED1,1 Z2 V0 j6 K3 e7 c# _9 N
.name = "user_led1",
- }% V# B6 m. L9 B: Y. b& M .default_trigger = "default-on", |/ s6 o r6 r i) e
},8 F7 Z# ~7 k O8 V# E
{
: P/ ?( ^% C0 G5 x( p) i& _ .active_low = 0,6 g- U* p2 ~4 y* \; k4 B' J/ a
.gpio = DA850_USER_LED2,
7 o/ J, s, `0 t! P8 G7 v .name = "user_led2",+ }/ ~# h* \, }2 X0 m
.default_trigger = "default-on",
j8 \* v, r8 K },' `7 U5 s0 n3 {9 W
{+ _ X9 L5 p; c# f3 O/ M1 T
.active_low = 0,
% L$ h( f! C6 q* O2 J$ I r .gpio = DA850_USER_LED3,. c+ q' b" J' D4 t
.name = "user_led3",
' F( m* ]3 Q2 P" L' ]. j3 b .default_trigger = "default-on",9 l4 P! a% _5 N5 w! S
},
4 Z4 |$ D; R: S7 z2 ~5 a: O};
$ D# q S% W" n( V; ~5 |8 N- H" ~9 d! c, E+ R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# y+ o1 z. C" b6 s& t" L* {
.leds = da850_evm_tl_leds,
; C# s- d& A1 w+ E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' s3 p, c" e, Y& H) e
};# ~: D4 A; ~2 m& _( r
8 w2 t" K9 j2 O
static void led_dev_release(struct device *dev) D4 {# G( k0 E
{
# S- t3 f0 q; B9 r; w};. C; k9 I) Y$ _# p" A' K7 ~
$ h. Q. H# Y( W
static struct platform_device da850_evm_tl_leds_device = {
8 K3 b8 `, ~0 `( T .name = "leds-gpio",/ n8 c+ S! h" j/ q
.id = 1,
7 E4 k2 h; v7 j* d4 `1 v) L" Y .dev = {. H& @ W* I+ J4 L% v7 G7 Y
.platform_data = &da850_evm_tl_leds_pdata,
- S: [. p! M& _9 M' o8 M i1 ?! M .release = led_dev_release,
! v6 G+ V) L" x- ? @: k: ]7 Z6 g }* m0 w! y8 x( \& f8 S
};7 F+ X- q5 A# j8 i( @: z9 x+ x8 Q
# T% t" j: I% {! j8 t$ ]- Nstatic int __init led_platform_init(void)
. l( }9 t7 F7 _3 M6 P% U/ d3 J5 C{+ T: M5 \9 O* n4 V7 l. |
int ret;
1 V: o+ [' \3 ~6 d" y% j" Y8 v9 o#if 0$ D9 T# c/ o. Y% C; g+ ], }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; P; _1 V/ q' g. L* H# u$ D
if (ret); _9 x1 {, C% z+ q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% x/ V( \( c6 t+ M& c; k* P "%d\n", ret);4 e+ L# h6 c8 x" v7 z6 P/ _
#endif
9 ^) \5 @1 x% A5 q/ n ret = platform_device_register(&da850_evm_tl_leds_device);0 M% N$ g# e, U7 Q+ x1 s
if (ret)# I4 P& C% z3 [1 V: u
pr_warning("Could not register som GPIO expander LEDS");
- n- E; N, n% C+ \8 D else) z4 g; p( H6 ?& e
printk(KERN_INFO "LED register sucessful!\n");
! F% ~, N3 a1 l# r' w/ o: T+ Q1 r- w+ c$ _. J1 i
return ret;
+ n: `4 @4 f$ ^( J% F}
7 U4 E4 ?% R! A
* B) |9 F; l5 T$ a1 F0 G! n0 {) }static void __exit led_platform_exit(void)$ z9 C j" f5 }! |5 T: c; L0 Q3 O
{' L( |2 |0 n& L- B+ E
platform_device_unregister(&da850_evm_tl_leds_device);
9 H& D- @9 m9 r
0 J& U; M3 U7 G3 j" ?; e printk(KERN_INFO "LED unregister!\n");- I! Z- f2 @$ N
}3 Q5 I$ \7 [* `" H
& P# A" d$ [$ f& Dmodule_init(led_platform_init);( k" S5 P8 @1 P; ?0 z) g
module_exit(led_platform_exit);' j- T' K$ N! E m( [) C
5 V/ x, I( E, d* v
MODULE_DESCRIPTION("Led platform driver");
, w! T" s5 p" v& {3 C, IMODULE_AUTHOR("Tronlong");% x+ Z( u6 \* h- w+ k+ a( l
MODULE_LICENSE("GPL");6 d, N& l$ i1 ?6 [
% E' \& K% d2 r1 z: X3 L- }
|
|