|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; N% T+ f, p& v) Y9 z" C+ ]2 Z
#include <linux/init.h>. @: b$ n' ]( p* B) G+ y o, H
#include <linux/module.h>
/ E" S/ u( [; s6 a#include <linux/kernel.h>
9 g5 Z9 o4 p2 d; z8 A/ ^#include <linux/types.h>
) L6 b& |7 p$ e#include <linux/gpio.h>
1 Y C. B; F* O2 D#include <linux/leds.h> G, I9 P7 {1 _; \1 I" O8 g
#include <linux/platform_device.h>
0 L) a/ W) m. Q- ?9 n, Z8 t0 y0 r" D! R; s5 b: F4 N
#include <asm/mach-types.h>! C o' q8 l' @# M) a
#include <asm/mach/arch.h>) |. z) s% Z4 m2 B
#include <mach/da8xx.h>
1 _3 w5 Q6 C+ D8 {6 [' o! A# C#include <mach/mux.h>
6 v9 p; m h1 U7 q, ?2 q8 X! H1 a3 K) C0 D- `& }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) t) i8 r% j1 j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), u! {% [( u4 g) u5 Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 b3 w) i+ ]1 O6 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): f; M% @3 g. [% \6 r: N
3 T$ J ]8 \3 E2 _& A/* assign the tl som board LED-GPIOs*/
, X( n; o3 O& M" fstatic const short da850_evm_tl_user_led_pins[] = {
' I- M$ L* H2 e x( J /* These pins are definition at <mach/mux.h> file */
8 b+ H3 ]: i5 l6 Q# B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* z" c( U: \9 g; w2 o( R/ u
-1! W- S- q' C, g3 p
};
& k1 E, p9 a8 q$ A# {- J$ [
+ W& ]/ S, P' I! G) p Nstatic struct gpio_led da850_evm_tl_leds[] = {' o6 E- s" d l7 z4 }7 M. f
{2 Z3 x5 Z- f5 _# L" N3 ~% b
.active_low = 0,
# O0 s5 W' a- d& B S# e .gpio = DA850_USER_LED0,
) @4 ~2 Q7 H) z. a8 h .name = "user_led0",
: p' c( {; K. C- {( T .default_trigger = "default-on",
4 M& n9 I! [% q9 R* w4 j },' X+ U, b# g; G: d% V. M+ m
{
( j$ i8 @- I2 t. g7 |3 l0 Y .active_low = 0,
* S% h- {6 t$ p4 Y9 B5 @2 H/ Q' U .gpio = DA850_USER_LED1,3 n; F) \* @2 C& t: L" @0 U
.name = "user_led1",/ e& B; L& j" c3 p; y
.default_trigger = "default-on",3 U" H5 z4 L% W3 e2 ~8 u# A5 w' ~: i% C
},
) H; {5 I. G" B9 e% r7 |- t, V {
4 Z4 F; c0 z M' M8 v! H8 T .active_low = 0,, L& U8 v) w, n
.gpio = DA850_USER_LED2,2 N" }& c5 f) ~: U1 D: h7 c- E
.name = "user_led2",5 u7 C( k+ j) h, f9 \; N) {1 ]% d
.default_trigger = "default-on",
7 p% S3 } e0 ]( B% V },' K& W6 V$ m$ {) j( e3 T. n8 n( M+ ~2 d
{4 a2 S2 u6 ~: i
.active_low = 0,( {3 ~% `' A: K2 |; b% M
.gpio = DA850_USER_LED3,( n5 a' z" ~) M: r9 ^5 w
.name = "user_led3",
1 y% P, Q# m; i$ Y' ^& o6 E+ w .default_trigger = "default-on",. R5 O+ T- K; D. S) s. _9 n/ l
},
8 Y4 _9 t* D8 ~};
" Q: B; a( {$ M8 z% G
2 Z( W+ O% H: g. L0 R. zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% T9 K; F' g* t8 P2 @/ i: l' p
.leds = da850_evm_tl_leds, n4 o4 _ Q7 X1 c% X: x! H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; V# d' {4 a8 n4 M0 S2 s2 E1 _
};8 y0 ]) Q( ^& {: n
) Q4 k; e+ F! N/ c. O8 M- @$ sstatic void led_dev_release(struct device *dev)7 z! v9 d4 N1 L3 R4 x
{
4 \+ K. `' o4 }8 }) _2 j: Y};$ P5 G' V& s7 E _, Y& t
" p* G, g# M$ h. e" O0 j. X
static struct platform_device da850_evm_tl_leds_device = {9 K. v% M; U0 {* Z- s& }1 f
.name = "leds-gpio",
& x- W4 o+ |0 k5 v/ M) j .id = 1,) Y0 F* q m5 N8 ~8 d7 V$ E0 F6 B9 F
.dev = {) D; }# p. q+ }% e/ I' F6 ^3 F- C
.platform_data = &da850_evm_tl_leds_pdata,
U* v6 d9 E0 P+ B# |) n6 C .release = led_dev_release,
4 L9 ]- E2 W" j6 q4 A }1 c d6 s- ~( u. [6 a0 b7 J
};: v- H1 O6 S/ z3 {( P& q
8 _! e9 v! a c) d# @2 R( qstatic int __init led_platform_init(void)
$ k4 c& M+ `! k1 p; p{3 j& _ D8 Y/ ~/ X- y/ z' E8 U' u9 M
int ret;
- u- Y( k- v* g/ ^- z#if 0
+ ?4 ^7 b* d( N( _/ b% v2 B+ L! a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( o, u) s( e# D* P) z
if (ret), a$ X9 v- T" F* x; r' P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ Y$ L! K8 z) B9 z "%d\n", ret);- P) c0 A9 Z7 w8 X0 x8 W/ A. G
#endif
* `; J% @, M0 [- R2 O8 @+ j ret = platform_device_register(&da850_evm_tl_leds_device);
9 W% i3 M2 k; q$ h if (ret)
# u4 I) v7 G3 C8 {4 ]9 q1 z5 k pr_warning("Could not register som GPIO expander LEDS");
! D3 H% D# Y8 H5 v else4 ?: ~ I7 e9 a) X
printk(KERN_INFO "LED register sucessful!\n");8 \/ G; c! x6 C# p5 o( F9 h/ {/ b! q
' ?. R# u, _6 e# S8 r7 e
return ret;2 ~0 I; H9 {* l/ I
}; v& M; ?6 U6 H9 y' b, L- t
* ^ U! x9 t3 ~# X% r: J/ b
static void __exit led_platform_exit(void)3 r# T, q7 N# ~9 n% E; @' _( B
{
/ w1 `$ h9 l& x# K4 m1 l* ]3 K; w platform_device_unregister(&da850_evm_tl_leds_device);1 I( B) L5 k* A! U6 [. r
1 o! J3 @8 H: ~* ?
printk(KERN_INFO "LED unregister!\n");6 O4 p+ ]& n& h
}
$ W0 A* J) q0 j6 G/ t$ g/ J2 D# c1 g. V
module_init(led_platform_init);: A, b# H7 K7 n; `' e
module_exit(led_platform_exit);! ^3 o3 y, Q; }" Q
8 Z' V) {$ ~6 c( I- }
MODULE_DESCRIPTION("Led platform driver");; k; j6 J" K/ m. a2 S$ `
MODULE_AUTHOR("Tronlong");+ J& j2 J4 b0 ]! K
MODULE_LICENSE("GPL");: P. v, X0 R4 O1 N* z3 }5 l
' N3 F6 J0 @: \
|
|