|
求大神给下面的程序做注解,请稍详细些,谢谢。) _- ]. @: O% n1 y5 ~
#include <linux/init.h>
# i+ z3 M* S" \0 z" r: T- j$ J#include <linux/module.h>4 R/ F, P/ |& _
#include <linux/kernel.h>/ H' ?; h# x: M9 }, k) B6 t
#include <linux/types.h>
; {# v' Y: w- R% z9 @* R% ]7 `#include <linux/gpio.h>0 ^6 W. d, b/ q4 l) E
#include <linux/leds.h>- Y2 Z3 `' h' n- }
#include <linux/platform_device.h>& r' u3 ^" I2 g# e- d
+ L# W8 C, N/ a; b0 @# b#include <asm/mach-types.h>
! n5 Q! E% D' M/ M3 i/ S) h# O#include <asm/mach/arch.h>: | \' ^5 B9 }9 Z) }7 P0 j
#include <mach/da8xx.h>* ]/ q% s% P ^& c6 h2 K
#include <mach/mux.h>$ @5 c$ {1 o$ A8 w. c1 x5 S% t
9 ^5 J" ?" Q" S; c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 L* f, P1 B/ i0 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: ~) T7 C( Y0 d: S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 Y$ v8 ^* x* w; J( w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 v7 _3 l# s; B) C
/ L+ B0 [+ f# S; o. ~
/* assign the tl som board LED-GPIOs*/- y4 j8 B5 N* e& M- l9 {
static const short da850_evm_tl_user_led_pins[] = {) N6 x( }' Q! ?+ `( f, E, q/ E
/* These pins are definition at <mach/mux.h> file */& @- @/ u9 }7 A6 @, o6 }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 c2 Q( y- w0 t5 o7 j1 |" ^8 V" f -1+ O! i2 z, x! @ v8 v. V3 u; M
};* f, H9 T" i1 M$ i! v5 p+ c* ~
' e4 l0 P! [+ S* Z
static struct gpio_led da850_evm_tl_leds[] = {8 A' l1 w' h7 s1 p
{
. }" {* m3 K9 x! h .active_low = 0,
2 G, H4 E l% ?0 u0 n+ j/ u- u0 d .gpio = DA850_USER_LED0,
2 m9 Y, O! l y2 o+ U .name = "user_led0",+ s" m. _ g$ j: _3 y+ }7 ?
.default_trigger = "default-on",
" |3 g; ?$ i# z. f; ` },) ~7 l) i u( \
{1 U( A o$ I6 D
.active_low = 0,, R7 X+ `0 R3 T4 t% A: ~
.gpio = DA850_USER_LED1,
1 s P* V9 _. d4 v/ p* Z3 c .name = "user_led1",) d* f2 Q3 |9 R) L' N$ O9 I
.default_trigger = "default-on",9 k2 N5 v8 ~% J. D1 T4 q5 Q
}, V# |7 i* B( O, k
{+ Q4 Y) @, I! O! X
.active_low = 0,
2 K2 Z0 O( a7 x: F .gpio = DA850_USER_LED2,
- D3 u. V% Y1 k: {! {; N0 Q# Y .name = "user_led2",3 U2 e" T$ d6 I
.default_trigger = "default-on",7 L! r7 y( S/ F" W8 f, W6 j: O
},2 M/ `% v$ R% Y7 B$ n f: {3 Z
{
9 i9 s1 _$ \* c/ N+ S8 S .active_low = 0,
; k1 m$ N- X7 a' N .gpio = DA850_USER_LED3,
6 c7 d& {; Q. G1 M .name = "user_led3",8 Q8 i B. r; v5 b
.default_trigger = "default-on",
) k: C8 d2 }8 I% C },& q7 ]1 v. ?9 c& p1 G' c; c
};
e4 \7 M! e7 J% f" G8 w. ]
, J- w- `" M8 n5 C" \+ Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 e+ \. B. f9 q+ p) O" q5 C# |; U
.leds = da850_evm_tl_leds,
e1 k% e" L2 K! R% X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 i( G2 `0 {# m) \3 I
};
- A3 N) ^9 n( F0 F& C% I5 r, z9 w) \1 s& ]- ^3 [: _% T
static void led_dev_release(struct device *dev)0 d7 { f, Z7 p
{
. a2 ?6 v+ G# @9 x; r6 y& l};
) v( m8 H- |4 L4 h [1 y/ H
6 v k% |: H9 f, E2 Ystatic struct platform_device da850_evm_tl_leds_device = {5 R: G# a/ }% k( K! _! D8 y. Y
.name = "leds-gpio",
. G" c+ k* E2 f. d) h) _ .id = 1,' d8 S% A0 `) ?
.dev = {
( ~5 Z! [% W' b .platform_data = &da850_evm_tl_leds_pdata,
: v! a* @0 O5 ]" ^: w .release = led_dev_release,7 [2 R1 b. _! z" j9 V0 y4 `
}& Q1 c' s$ L7 R5 t- a
};
1 y" F8 y3 l3 L ?
( Y5 d( {& x! a) j# Xstatic int __init led_platform_init(void)
! ^' h0 {7 T3 F$ g) v{' z9 b3 B$ c* z
int ret;4 L# B7 `% {5 F8 N2 Q
#if 0
( i% w, G+ E$ n* {0 V# A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); C z" M) h8 R- l
if (ret)
3 @2 O2 g, v' w. V" t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 D Y7 v5 _' w/ s1 x
"%d\n", ret);
% x. v# s- Y3 _$ O$ L: n1 ~#endif6 B# m' q% c8 L6 t3 m
ret = platform_device_register(&da850_evm_tl_leds_device);
$ L' b+ i' c6 N A5 n if (ret)3 f* A0 t8 H3 b1 c
pr_warning("Could not register som GPIO expander LEDS");* d, j/ `* ^0 C! ^; _
else
) ]2 c3 a2 V. H3 E printk(KERN_INFO "LED register sucessful!\n");
5 P0 R1 ~) k' i2 d8 w) h! h
: ?7 P, v# i I- Z return ret;
7 O8 O! @; E: r}
0 b% L* I) k6 U. ^* g6 y1 K% B( M8 p( R2 g, j
static void __exit led_platform_exit(void)+ p) l1 T1 ^& F% G ` |8 F, X
{! }* G' q1 w2 n3 x( p& P
platform_device_unregister(&da850_evm_tl_leds_device);( {/ j0 C: M5 J2 V( g8 r
% X' Y |5 C0 t; D) e& d+ @- k
printk(KERN_INFO "LED unregister!\n");
; i, ~) X8 z, }}( e+ N$ |' j n* p4 K. f
1 ?7 b. o: m$ N0 \# e* `module_init(led_platform_init);: {3 U" \# k+ i _' O
module_exit(led_platform_exit);
" f( u/ n6 Z: o+ u: c+ b" ]3 w& ?8 A/ f2 ^0 J5 f
MODULE_DESCRIPTION("Led platform driver");( z, `3 r+ X; c3 l5 j
MODULE_AUTHOR("Tronlong");* ]7 |5 L4 b! S' J) W1 F
MODULE_LICENSE("GPL");
) s9 m$ x/ B) j3 R/ _0 _7 X1 s+ Y3 {# J0 x7 D
|
|