|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) h( N: J7 ^' ]$ U
#include <linux/init.h>% X) b! w: ?9 K- {
#include <linux/module.h>8 @7 f$ b6 [! I
#include <linux/kernel.h>: d' e$ m. v* Z" G
#include <linux/types.h>
) ]$ S$ c u- l8 `0 W( r#include <linux/gpio.h>6 m: D/ }7 [5 E- d1 O3 w/ X0 T
#include <linux/leds.h>( K# S+ ~) U! z# c* Z: ~4 u" K
#include <linux/platform_device.h>
1 t3 `: Y6 ~- q' d3 G6 ]* [2 A0 H1 k
0 ]7 |. X: Y+ G. V) M. J" u#include <asm/mach-types.h>
5 W2 D: ~! G5 D* y# o- ?. R h#include <asm/mach/arch.h>+ D! b# ^2 L$ x/ W+ T* j
#include <mach/da8xx.h>
- _& d2 q' N z9 r. I#include <mach/mux.h>$ t `% z% [/ M9 E
6 ~0 W8 ~; s: x- [+ C8 U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" r4 [6 k, v3 t# a' n o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); Y' p4 p E$ o D: }, t+ s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); D% k$ `0 O/ H' X4 Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 M4 I& S9 a* y: N) g H( t) K2 ~) Q4 I. z
/* assign the tl som board LED-GPIOs*/
( w" D: i) [( N& }static const short da850_evm_tl_user_led_pins[] = {
! v, v5 ?, o7 F5 c Q /* These pins are definition at <mach/mux.h> file */
$ ~( c: j- I, x: F' g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ P% p, e$ O4 D$ F6 r" L7 t6 X4 ` -1
8 W9 c, a( T$ a};
' m3 [; T P. \' {0 S' I: I0 _4 ]5 @" K: z& ]: P. Z; j
static struct gpio_led da850_evm_tl_leds[] = {2 a& t2 S' `. L1 I
{
4 D) c9 I, f* r7 L .active_low = 0,
$ e7 ?$ Z7 R! i .gpio = DA850_USER_LED0, U" S: |0 h9 W9 r4 i$ X; i
.name = "user_led0",
7 @& }$ ~6 b' o3 O7 X .default_trigger = "default-on",
: X4 y4 {+ t9 V4 @$ d' c },9 t9 `& P! o! K7 Y; ~. C# A
{
/ [5 H2 b# k3 s4 C .active_low = 0," U% W' l( O; q | X
.gpio = DA850_USER_LED1,
5 H0 }3 @7 u+ V$ y. p: T* c( i .name = "user_led1",
- u) G2 c" p7 E$ [5 [- H8 M .default_trigger = "default-on",
0 L4 w! |8 \- S' y( W7 S$ ` },
+ S S; |: P/ P$ |, ^: R9 q/ I* X" f {" c @9 Q% w: \/ c" a
.active_low = 0,
, u( A3 T2 e" }& x+ t; f .gpio = DA850_USER_LED2,8 \: c1 e. h9 W9 d
.name = "user_led2",
/ d& [" w( |( [& l) _& ~3 t .default_trigger = "default-on",' @& o* e% y1 Y! \, o. e' b
},
. ^, {' S7 \& P7 ]2 r! b3 ]* i {5 t) P u. f+ {
.active_low = 0,
3 k" q7 g7 @+ ~4 V .gpio = DA850_USER_LED3,% B# }2 N& k. J
.name = "user_led3",. I- n# s7 c/ O( l
.default_trigger = "default-on",
1 ~, B( h8 w" M- \) c' d3 J },) v% |/ \: v7 e* J3 |4 U6 f
}; C8 ]5 c# b& g1 j- U; U
* a5 n$ V: {- i# J% Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ Z( [% R5 b1 H5 w j. P. ^- Q6 F+ x .leds = da850_evm_tl_leds,, x: j I$ E8 ~' b6 z* D, f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ m8 } [/ W. ^/ ^
};
, L3 x5 `- c6 |1 `6 h
/ h' x8 i, P3 s0 D8 fstatic void led_dev_release(struct device *dev). A. E! q3 F/ E* ]5 n! c
{
% ?# Y: C9 U4 @};, a% y6 c# \* W5 F& K+ D! L& E" A
, @6 u/ X! x+ P7 {! Ystatic struct platform_device da850_evm_tl_leds_device = {
6 d$ |% y& E0 Q .name = "leds-gpio",, q2 N7 q$ G1 I5 T+ {; N, ]. s
.id = 1,1 D3 H& `4 O" ~; W3 R
.dev = {
0 k* J$ {. W5 K- c# V$ R5 z .platform_data = &da850_evm_tl_leds_pdata,
* i' E7 s" _5 k, J# A' f .release = led_dev_release,
4 w1 L4 s0 E' [- ]2 N! y1 I }. s/ ]# B& ]3 T: q% C% @
};, S7 \5 d4 B( ~3 ]4 x/ s
9 y# @- ^8 \1 f4 U$ v
static int __init led_platform_init(void)
6 L! `6 C6 ~2 S- ~% h) E{
' g) E$ _9 L" C! ?, n int ret;. z4 G' ]4 H% B, z' Z+ a
#if 02 s. F: v& f+ ^. R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; [. R! b- I. l. r8 ^) g if (ret)1 Y; {% ^8 \+ M7 Y; U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% T# T! `5 }; ?' m/ H
"%d\n", ret);
- ]& K% b/ U9 S, d. r$ C* i% l) a: A#endif
! O& a( t3 D/ }, _) f ret = platform_device_register(&da850_evm_tl_leds_device);
' T) F: R* G1 z% a! ?$ ^0 [ if (ret); ]. k5 p3 X+ o# g; Z8 ]9 z
pr_warning("Could not register som GPIO expander LEDS");
% O4 D& z) R& `# U5 S- s else1 `0 I0 e2 G/ l2 E3 I+ G/ S
printk(KERN_INFO "LED register sucessful!\n");9 b2 x$ f' [: l( ]3 L
8 S: ^ E7 z2 k" |% E2 R
return ret;
1 T4 V% J5 A" e8 `/ L}0 S, K, E5 |1 D9 U
- } a6 ]& P7 O2 ?/ z
static void __exit led_platform_exit(void)
: t& e9 ~- J- v{
$ p0 {5 ~2 {! Y' |5 M platform_device_unregister(&da850_evm_tl_leds_device);( j9 V- _# O) Q K/ z) Z! `6 n9 m
& m5 A: B6 z6 I3 n! O7 H9 A0 @: P printk(KERN_INFO "LED unregister!\n");3 j3 M' C y# G: h
}( B" ~6 U" U& H* v& x% g7 y. C
7 o9 ]6 M% {/ X. ymodule_init(led_platform_init);0 O5 `3 E# X; x3 {# Z- e; \) ~1 L0 U
module_exit(led_platform_exit);8 g7 A, `+ U9 I3 u
# W' g5 |; s& ]. _MODULE_DESCRIPTION("Led platform driver");5 X9 m# i, _/ h; b7 d
MODULE_AUTHOR("Tronlong");3 h5 `# g& j$ y3 Q: S! W. F
MODULE_LICENSE("GPL");6 x% A& {5 G: t& F# x: G
o1 J0 n( n' B0 V; w# B
|
|