|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( b* G% I# E' M, I. y( g6 F#include <linux/init.h>
- w* p7 \! W5 E* j+ ~9 |# k4 k#include <linux/module.h>" W* L4 ]2 H9 K, X B
#include <linux/kernel.h>( E4 y5 n+ w! `% e+ ~# E' l8 i
#include <linux/types.h>5 f. U) ?: f! |" L9 x5 E4 h
#include <linux/gpio.h>9 m& T+ P) {# M2 ^
#include <linux/leds.h>
6 W. s+ H, W% N1 W6 s6 e0 I% Q* ?#include <linux/platform_device.h>
& M: i% S( U7 u4 @1 B7 V# ~- P7 H4 X. |/ {: `5 @0 v
#include <asm/mach-types.h>! s) l! C7 n" z9 [8 U7 b
#include <asm/mach/arch.h>
3 W5 v2 u( @9 G9 ]#include <mach/da8xx.h>+ G% C! u4 _' a, V+ K' a
#include <mach/mux.h>
( k$ `2 `; G w0 D6 a- D
8 c8 k1 e7 n8 d- g3 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 n1 ?7 D: n9 M. g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 a+ Q% S# Q4 E% s. Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): m( y# B3 X" U3 o1 w( `: `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 e4 \) \0 S# l* V1 ]$ t( m1 I# p. T3 S
/* assign the tl som board LED-GPIOs*/( q- o6 e) e$ I- J
static const short da850_evm_tl_user_led_pins[] = {9 R% L+ |& ~5 B+ h) B( j
/* These pins are definition at <mach/mux.h> file */
! }- m* R: m0 c9 R9 ^7 {! g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 _1 K4 u5 t/ K: p7 `% k. Y2 \6 r
-1
0 w M" |' w% |- v2 c};/ C7 O) M0 o/ h8 @' u/ e
/ l h5 d6 Z% f. a! R. L7 J6 rstatic struct gpio_led da850_evm_tl_leds[] = {3 {) w& G6 J% N8 Q5 S$ m& j7 }+ R
{$ t$ g' x, r( X* Y* @
.active_low = 0,) s' s8 r1 w$ J+ g {
.gpio = DA850_USER_LED0,/ T+ H9 m! y$ \$ f, d# o$ I
.name = "user_led0",
4 b3 u9 ~2 I3 k3 y& J3 i .default_trigger = "default-on",
: }& t! p% j2 w) O1 q: }$ c, K },) y% \$ x% { y, w o: F
{
( [2 W; x, V1 Q4 O .active_low = 0,
- i$ k8 h% U2 W% J4 z6 J. N .gpio = DA850_USER_LED1,
) ^+ S/ T$ d6 J- j: M" f .name = "user_led1",7 Q) r7 ^+ Y7 ^7 @2 o6 I
.default_trigger = "default-on",
& T- D) z+ a" t8 a, i0 X2 F },
; z* ~# _2 i: ?) }1 q7 B& C& q K$ ` Q {
, `6 s" a) B# y0 e% O+ m7 C, J .active_low = 0, T3 ?# x4 X) m, P
.gpio = DA850_USER_LED2,
$ e4 q3 m4 e" s9 a) D1 S .name = "user_led2",6 @( p: ~' n5 o3 v
.default_trigger = "default-on",
; T- O6 Z3 }8 T- K: u }, Q; N+ a+ A: C, K3 n% w( i
{
$ t6 _$ u% F* `0 C& o .active_low = 0,: M' R) Y4 F7 [6 s# N" X! [
.gpio = DA850_USER_LED3,
2 c" r0 W+ O M# C6 ~! W* _0 X# V .name = "user_led3",
6 P8 o: _+ P; Q1 ] .default_trigger = "default-on",
/ q$ ` q# t% k7 q- r0 b },
9 O( Y4 r3 p6 a6 R( \4 c0 l};
9 G& K1 Q0 J8 \. m& D( ~$ S4 Q. u( E& T
; y3 L% S! n/ pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* C9 v) O# x7 C7 _6 }* e* X .leds = da850_evm_tl_leds,# v2 S! T* k" \$ o f! G! y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# p+ x$ Z: Z" e- A9 c
};5 N9 Z" K' q* y% c
7 a3 e! v' w; b f/ }8 y
static void led_dev_release(struct device *dev)
! v3 l7 l: m* J! G" ~{8 Q0 P3 ^" u& m# Y& o
};; p8 Q! D3 |; ^, U2 x8 F
* P0 D x' K% w+ b
static struct platform_device da850_evm_tl_leds_device = {
% F3 R; K, i a- w% D8 U$ h& S .name = "leds-gpio",
( S& `( U; R4 J% h: \6 ?' G .id = 1,2 I+ x+ J9 |' F/ n: m% G4 ]: \
.dev = {
+ D: I' @! E+ ]9 W# l) X3 C7 w .platform_data = &da850_evm_tl_leds_pdata,+ v& M2 i4 i2 q
.release = led_dev_release,
% O1 z, s' j; {, n# f1 C }5 C _% `# |9 S: Y* D! ]
};
% ?1 ^& m3 s; V, i6 N3 S+ T( P2 ?0 d1 a3 s) O# P! F$ C6 g
static int __init led_platform_init(void). [$ j4 t' o9 L) j
{: S0 k8 v. h$ j) R) W/ ]
int ret;( _7 s- @( M6 g2 M) W
#if 0
5 X* t9 W) s5 K5 Y* W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# t5 l& ?- {3 h# q7 U
if (ret)# r. a4 Q( x; r8 u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 i8 X% C6 l* {/ l7 G/ h' f' B9 N "%d\n", ret);
5 ?# Y. ^( a7 \# |: q#endif
7 `, |0 A3 ^* d ret = platform_device_register(&da850_evm_tl_leds_device);
7 i! i+ g( B6 C if (ret)9 x: |% @& f! i" i3 k3 W
pr_warning("Could not register som GPIO expander LEDS");
/ ?3 h: _. e2 m9 a3 ~% @ else
/ v, M' o8 ~( v6 x. [ printk(KERN_INFO "LED register sucessful!\n");2 q, B' D' q6 b. ?/ q% j6 f4 J. o
: N0 q+ m" e# L/ R4 R, u. F
return ret;
) U1 E4 l2 s; e7 W}
& N, ^0 |3 e9 C/ B& ?& y1 C
; q, c* e' j4 O; {+ Y3 i1 kstatic void __exit led_platform_exit(void)
: d: u4 n; j; |1 N{- l7 K; e( h4 d$ Z2 P
platform_device_unregister(&da850_evm_tl_leds_device);" Q# G8 k. n+ ]2 s0 Y8 F
' _' s. d' N: a4 j2 T8 k; }
printk(KERN_INFO "LED unregister!\n");2 B) r3 R6 Z& N8 W0 h
}
5 z7 E# |' C# m. t) r( E& U" c7 ^# A+ F! A% i
module_init(led_platform_init);
( U' n/ Y: P! C. k0 d) ^module_exit(led_platform_exit);0 j4 y% W/ a( z: K, `7 E
- k [6 P2 `3 l& }
MODULE_DESCRIPTION("Led platform driver");
- C% @' c% A( [: a. D& E* l7 [/ D& XMODULE_AUTHOR("Tronlong");* D: o, C" I* w) }+ c+ ]# b% i2 |
MODULE_LICENSE("GPL");. Z/ w; L3 V- x2 {* G" U/ V
% D* M' f; c- {" k. C6 g+ p$ c# a
|
|