|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( [. ]+ I; J+ r# P* o/ `6 W# U
#include <linux/init.h>! K% k, F3 \# k j
#include <linux/module.h>
% e) S& |9 g+ C. K! o4 U4 l4 k#include <linux/kernel.h>
2 [8 S& {- |3 M8 s) t2 x#include <linux/types.h>
, |! p2 b( ?# B#include <linux/gpio.h>
. \5 X' l0 T; G: L* z#include <linux/leds.h>4 E7 H5 t, v/ e9 c6 A( i
#include <linux/platform_device.h>
% c! O, d/ ~ ]- e. [0 Z* f
7 @3 ?$ A9 s5 R" N& }( x) n9 @#include <asm/mach-types.h>/ x# V% Y2 }. b% |
#include <asm/mach/arch.h>
u! i0 H$ o e#include <mach/da8xx.h>+ c( Q ~+ [0 s2 ?; p5 N* G1 j9 `4 R
#include <mach/mux.h>
# O+ G/ s1 {9 g6 {7 g
4 b+ Y/ J$ O! S! I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; d- Q! n2 ~3 p, U3 `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 P7 M2 D2 k0 A9 t- d* R3 C- |6 j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 W. N$ u: p# s1 Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 g" H, `9 T6 v
0 S% V" n6 ~" F5 \# u( t$ u/* assign the tl som board LED-GPIOs*/. d7 F0 J( W* ~' \) z- Y# S
static const short da850_evm_tl_user_led_pins[] = {) N% r+ N' j& q6 q! j$ ?
/* These pins are definition at <mach/mux.h> file */4 @7 A8 }7 F" Z% a' r4 q0 X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 m+ B6 T( S" i8 H; E
-1
1 M- h: ?% b* {! Y/ h# \};9 J$ R, Y! T4 ^/ I) z
$ R' f* J6 N$ D# k
static struct gpio_led da850_evm_tl_leds[] = {
7 p$ g- Q E% v# W, p9 o {
, R6 j/ ?& S1 s2 d! Z3 A .active_low = 0,
0 E# E& y( V& ]# z. t .gpio = DA850_USER_LED0,: A0 x0 [( b" z4 f! ~! Y
.name = "user_led0",0 p7 o' N, u& G- V0 v, s
.default_trigger = "default-on",( V( k( Q |$ m/ w$ o9 t3 p
},2 Z1 T+ {% A6 h
{+ Z) x$ \/ N; t2 b5 X; N: q! d2 c6 p+ I
.active_low = 0,
: @) i5 A" h* N, g7 ]. R .gpio = DA850_USER_LED1,
+ c+ b5 B1 j# U/ [, w .name = "user_led1",
9 ]6 q3 h+ v" c9 v/ X3 s/ M .default_trigger = "default-on", N: i& J: A8 @. s; Y/ u( T
},
* p m/ x3 N7 |4 C, | [1 A4 I {
0 L3 U6 T& k9 |7 k/ h3 v- [4 @# u .active_low = 0,
) D: L. E& t) ?: [ .gpio = DA850_USER_LED2,
2 P1 d4 L1 j8 a; ~1 r .name = "user_led2",0 n$ i7 S. O$ W/ S6 t" F
.default_trigger = "default-on",8 E( N8 `' I/ f: n W
},
+ Q$ n3 V0 y c$ C8 x0 S9 ]; i {& O9 W! r5 G. j& Q
.active_low = 0,4 }. {1 I: b% Z; J* l7 M
.gpio = DA850_USER_LED3,: ?2 z0 M7 q" m- w7 T
.name = "user_led3",
) x+ F- Z8 D5 w0 X& K# [ .default_trigger = "default-on",
. o, C9 X9 w1 X- s& m: z },
% u1 T n& r- U& L& c6 b};" N7 s/ o6 O5 ]$ g- J' T8 f# L
2 {' {, S2 K8 X) V/ U1 y9 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 D4 x* ~( y- ~6 y: T8 { .leds = da850_evm_tl_leds,3 D5 l2 g u8 N+ ]2 N% [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% m; H9 i6 o6 D7 e) k! O- Z
};+ l b* E& r' ] e" G( I/ H: F7 G
/ X$ ?8 p' n. }+ istatic void led_dev_release(struct device *dev)
2 y, a# o2 R# h# \: I G{$ [( G( ^# i! F! E. j+ N
};2 a# h( ]7 x- |8 j2 Z
- N; \4 y% M6 {8 l+ ?0 A" Gstatic struct platform_device da850_evm_tl_leds_device = {
( P6 r O2 M% P3 i" n% P9 K .name = "leds-gpio",! s( E+ d7 Y! R- |/ ^
.id = 1,4 ^1 U1 |" i$ N1 o9 t/ l' W
.dev = {
) Q$ O' [5 j: I, E .platform_data = &da850_evm_tl_leds_pdata,
) S: u2 g/ F* |$ N4 a# F .release = led_dev_release,
- p; B1 `* R& _4 d4 [ }
( c" J8 o3 J+ B4 q4 Q, z};" C0 b* u4 L+ m! h( c5 l
! J4 V1 _6 H3 b9 t2 P8 wstatic int __init led_platform_init(void); ?; U; V0 `! {3 G/ ?) R5 F
{
( Q1 H4 w- I. p4 q: r int ret;* X4 }5 ], D. [; }( Q
#if 03 {4 P @5 I, b7 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ Z3 c" ?3 z' Z/ b, s
if (ret)0 K! ?6 w) D8 \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& b4 L% m. Q3 `6 c' _+ ]& T "%d\n", ret);" l' N5 G% @4 i+ K) p
#endif
E1 T2 r( \! V& N; a; |* C k8 X) v ret = platform_device_register(&da850_evm_tl_leds_device);
8 q: T9 V( n0 e; j/ g% n7 k" E( Q if (ret)( C2 J3 t" [0 U4 M' ?: t* p
pr_warning("Could not register som GPIO expander LEDS");
6 R4 B( s, y* M' t0 S5 c9 b else
, b9 K" p1 V) P7 ]$ ] printk(KERN_INFO "LED register sucessful!\n");
3 G3 A4 s7 e# {7 \# n: O" t
3 @& V* R# b: n2 i return ret;& N4 D* @( h6 |' V
}/ V1 _" t2 B' I- u& T, D* L) s1 T- Z
# O- o6 ~$ S6 k7 |- w; t7 j8 `
static void __exit led_platform_exit(void)6 s* y/ ~+ o& ` ~
{
3 K$ ?9 v4 c/ L) S3 g5 O platform_device_unregister(&da850_evm_tl_leds_device);+ z" N& b9 d; Z' E9 o. Z
: W. l# N& x( t" i# c: v( d. v
printk(KERN_INFO "LED unregister!\n");
* v, D7 }3 Q5 Z- a9 |}' g; {: X6 r4 L: }; F3 v4 y. {
" i+ K# q# K% ]' _( S! \8 Q6 f2 r
module_init(led_platform_init);
) ^2 c5 _$ E1 W( V, Cmodule_exit(led_platform_exit);: r. s7 Y' d4 U
' F# B; l: N( y6 D, [; S5 h
MODULE_DESCRIPTION("Led platform driver");5 g/ v- p! z8 `' Y3 s% `
MODULE_AUTHOR("Tronlong");
- Q5 a% w& ~7 O1 U3 R {MODULE_LICENSE("GPL");
( L0 T; k" o6 N" O3 v8 |7 u# F
7 G% l+ _ \% f8 Z% t" Z |
|