|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 T W3 }8 D. U3 p, ?, k( _
#include <linux/init.h>
# \1 x( C. F% V3 M6 U#include <linux/module.h>
5 a3 E. d! U+ R+ A; V3 ^#include <linux/kernel.h>1 e; U0 l+ z2 i5 ~- E
#include <linux/types.h>* ~0 F8 g, `$ T) f0 Y+ T; b# F
#include <linux/gpio.h>- s* y ~( P, {8 z# X% B
#include <linux/leds.h>/ S4 \' m3 e5 p- k) s( D
#include <linux/platform_device.h>7 {! O* g }% C( L. x8 e( s( n
5 T! W+ Y% G" Y1 P! b
#include <asm/mach-types.h>
, x* A7 b1 G" T ?6 o#include <asm/mach/arch.h>
. R6 O8 ~1 A+ B2 E#include <mach/da8xx.h>( Z! \. J9 Q2 {* C2 l
#include <mach/mux.h>3 r' W4 F3 t3 s& j7 {) s7 r
$ a" b, N4 A$ ]/ y2 l# _# K; d6 \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# V. A! M/ i! \$ r6 w! B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ m9 a8 k& A t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ q3 a0 A" J" z7 \5 J/ o; J" t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( K$ ?3 V- |8 q( ^* h
" n! T [( d3 c- Q/* assign the tl som board LED-GPIOs*/3 _7 w5 a% V- `
static const short da850_evm_tl_user_led_pins[] = {1 {& H" ?5 |" S% P7 q" A
/* These pins are definition at <mach/mux.h> file */
3 Q- {# k+ p9 l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, R( g4 `0 C/ M( V" I( g8 ~* z
-1
$ J3 T/ O# J; |: j8 e# [};
7 t, e8 t4 Q5 Z- ^
$ e3 H( c5 F6 G5 T2 Vstatic struct gpio_led da850_evm_tl_leds[] = {( t& B% e t' q# z d" b
{
" W a* x: c) j5 ~; Y2 V. n5 q .active_low = 0,8 k y4 O& W; H9 I
.gpio = DA850_USER_LED0,
# r( P$ q. Y3 P' g: { .name = "user_led0",, L* A( D; O% K5 |1 K
.default_trigger = "default-on",
/ F% t. t' G9 U V0 p) ^ },
8 Y( u( O/ {8 P, ^) w {7 A8 J# ^) `" \; V, ^& h3 {
.active_low = 0,
1 J9 N/ c- s# x( T' [0 P6 v5 \ .gpio = DA850_USER_LED1,; t" a) {9 X/ }& i
.name = "user_led1",, R- T: H2 u2 F4 `' p% p
.default_trigger = "default-on",
3 E7 H2 |8 C; _- g: j9 C/ x! R },
( L9 w" m8 S* R+ y3 S7 f {
) w' j% j8 [0 H/ J% O .active_low = 0,
$ S( p* E# |1 D# Z; N8 o% @ .gpio = DA850_USER_LED2,* R& q6 R8 i7 ^# m I
.name = "user_led2",6 v6 o: a* \4 a9 p) i
.default_trigger = "default-on",& A% a# h! J1 W* q9 D/ t$ Z/ B3 d( a6 p
}," T& a3 ]6 L& C" {5 i! M6 b
{. b! ]" h4 r6 T7 X
.active_low = 0, V- L5 L% V5 q# W3 b* G) y X
.gpio = DA850_USER_LED3,
! _& t% f/ V' h8 [! H1 Z .name = "user_led3",
% t; {; h- u* v7 J .default_trigger = "default-on",3 S/ L8 f: D. |2 r, z
},
9 O+ [) c3 I: |% }: O};
" L& i8 _) F9 w8 [, W) |+ Z+ }* b# }9 c+ F0 ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 a5 t. [# y* ~0 f: Z1 y, N, f ] .leds = da850_evm_tl_leds,
3 f1 ]% {6 d Z' H5 O( V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 J, }/ ?+ r/ Q5 @3 {6 M};0 u4 f+ g) [9 ? f" h
' W0 U* [" g4 ]
static void led_dev_release(struct device *dev)7 m' N! o3 H$ B2 u! J4 }
{
1 _& n0 f& x1 O};
8 C E* a1 i! K, Y3 \+ _3 `' T4 k4 Y5 V, i
static struct platform_device da850_evm_tl_leds_device = {# `& g( F4 W8 L' H* K
.name = "leds-gpio",
4 ~& d6 D) F! W5 x/ O! I/ y .id = 1,
5 p6 f% z& l1 S$ M% a# Q" ? .dev = {( j' w) k* H8 Y5 V* B/ k! u; a
.platform_data = &da850_evm_tl_leds_pdata,' ]7 f" r) |' W; u0 j
.release = led_dev_release,: q* o% R2 x7 O+ t1 U
}5 S" b+ B5 q, D3 K' e5 N3 L) Y
};, H0 f$ k# F8 b" b$ U+ [2 m
% `5 N, m, q2 b( r# U
static int __init led_platform_init(void)
7 ~1 T7 n6 x* I, }{4 J, q$ r$ g. Q% A
int ret;
- Z; x: [+ |. k7 f% q#if 02 ]( w6 ]* y/ Q/ o+ n' S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" j3 e( V. N4 }! D7 f if (ret)
3 F5 \6 u4 U) o) N$ j7 o$ X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 |( t j6 S9 T8 b "%d\n", ret);
6 b! I. O& U! |5 T- ~- J$ [#endif# w( @9 c% n3 ~& @$ d! P- `
ret = platform_device_register(&da850_evm_tl_leds_device);5 L: \/ L! n( x/ K% e8 ]/ w6 d. {6 q9 X/ C' m
if (ret)% E2 m5 B2 O! @$ z/ ~# Y8 @8 Z. u
pr_warning("Could not register som GPIO expander LEDS");- s1 Y+ U1 y" ~8 F. H" {
else+ `( B) M2 }5 ?5 U, {2 Y, T
printk(KERN_INFO "LED register sucessful!\n");9 b3 h. P, ~* R' K$ C/ f
5 {' p( h, V* G return ret;
) n! ~& i& L( y& W" y}
, E: v+ q2 ?1 N: B" z# [
/ }. a6 }' E: D$ m0 z [8 f1 Estatic void __exit led_platform_exit(void): G+ a( N' ~0 L, C$ C5 H5 i- F
{7 `# g. [/ \0 B0 q# {
platform_device_unregister(&da850_evm_tl_leds_device);
) b \6 p5 M+ `; l0 |/ l4 @/ L/ w0 q6 J4 x3 S
printk(KERN_INFO "LED unregister!\n");6 V/ b- x- p1 |$ f
}
' d# `" M! E7 g& ?8 R8 H$ s( o. h" b* C, \
module_init(led_platform_init);& _3 `' w4 @- y6 Q. s$ w- J
module_exit(led_platform_exit);1 N/ j6 O: \2 [5 |0 |
! Y1 p7 m) M% h$ \! h
MODULE_DESCRIPTION("Led platform driver");$ ^& l' ?5 k( O+ g
MODULE_AUTHOR("Tronlong");
7 E5 x c( q; j( ~1 ]* `MODULE_LICENSE("GPL");0 @* v! h; R* [) q
' ~; }9 H( s1 l
|
|