|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. G$ R# w; V2 g7 p# J8 c. P
#include <linux/init.h>
: x3 i6 c$ ^2 c& V! ]#include <linux/module.h>
% W4 Z! o. l* v2 d7 P#include <linux/kernel.h>
) ^- m# i8 N* z6 q, Y( L#include <linux/types.h>7 @% w+ q. Q' R! R* T1 ?$ X
#include <linux/gpio.h>4 t6 v3 m, i, y( ?; }" c
#include <linux/leds.h>( h- y& p, n5 H
#include <linux/platform_device.h>
8 N0 J4 v! q# k( J; R" o3 s- T) W" v4 w5 p2 Q
#include <asm/mach-types.h>' I( C* v3 A: `$ ]' g8 \
#include <asm/mach/arch.h>
6 S0 r4 F- w& `1 e# M: B#include <mach/da8xx.h>
! {3 v* F5 [4 |+ y2 i6 p#include <mach/mux.h>! a w3 w% |- o) _
9 }" z9 h# \9 ?9 E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 P4 ~) I V/ z4 H$ f0 K# o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): @- O1 U! c' C1 u+ W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% d S& K# L' e3 y( o0 _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% F; w" o% a1 | }7 X5 A9 j
+ q' V& q# F0 S& w2 {2 r/* assign the tl som board LED-GPIOs*/
+ L7 k2 y- n( Dstatic const short da850_evm_tl_user_led_pins[] = {$ F8 T. k K1 n1 \* Z
/* These pins are definition at <mach/mux.h> file */! f& {% S* V& E/ z( _0 D- z* U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 ?0 X7 D4 l; B! H0 k
-1
& ~: I* A; N0 L};
4 {+ H/ b9 G2 x2 l
! T# \+ M! o; Kstatic struct gpio_led da850_evm_tl_leds[] = {2 ]9 B( F1 Q; v" `
{( q8 i d2 G/ S2 _
.active_low = 0,
; A5 ^2 x& V" a4 n .gpio = DA850_USER_LED0,
# R" z' I; P* }& l$ }% G .name = "user_led0",
2 R' d' F' [+ h3 r0 S! h" ^3 m .default_trigger = "default-on",
% V. k$ x% T' v },3 y( Y, A5 V/ v! {& h- ~
{9 G4 ` b: I( y4 w! k& _8 v0 j7 H
.active_low = 0,
* B; ^0 u' l! ?; }# s .gpio = DA850_USER_LED1,
% Z( U" _7 y) a( ?2 [% Y .name = "user_led1",: Y2 j# ^$ s- z5 y! J
.default_trigger = "default-on",
: L1 j( |0 {: V4 v* n! k* ^ },
- w8 B9 ?' a! L( N1 W5 O {; e Y& t1 Q! a; c4 M! }8 {5 e
.active_low = 0,
7 N) G# n( O( ]$ q# y: _ .gpio = DA850_USER_LED2,
& E2 L9 o4 p& c8 c" C& q .name = "user_led2",3 Q& G" ^+ G, c$ w; e
.default_trigger = "default-on",
( l8 Q6 l* F8 V' y/ | },, H9 B7 Z2 ^/ x, l6 [4 A I" D+ B
{
4 l0 J; U( g- G/ d/ s/ A/ f G: f .active_low = 0,. @' V8 x4 D( g ?* ]
.gpio = DA850_USER_LED3,
+ ]/ e3 y, \0 {: N: l .name = "user_led3",
3 ~9 e+ {) q4 e, M1 ^: S" l5 P" _ .default_trigger = "default-on",
! w8 ^1 @! X+ B8 v( |; L, ^+ g },; y9 H+ X: D! K5 @% v2 `2 W6 o
};
, k O, y! I* M, e. L) W% Y, q8 ^3 ]. W, t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ o7 L' x# {8 [6 Q6 ] .leds = da850_evm_tl_leds,
3 P% g) {1 O9 z% {+ g+ a, @+ A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& d J7 k- r+ H" o/ ^$ A
};" X9 M# T, ?7 L& {' M- w7 L
$ Y( W/ K- I1 L9 o$ P* [; t$ pstatic void led_dev_release(struct device *dev)2 E1 W/ M. L6 b7 H7 o, ^8 s0 g$ b
{8 r9 h! C2 {5 g3 m, w/ f: Z& I
};
, c, D! T& d8 Z" _0 E' Q
4 _5 B p7 y& {! |static struct platform_device da850_evm_tl_leds_device = {9 c% m( V" F5 t$ D" u* M0 F
.name = "leds-gpio",
% L: _* l. k8 |' l3 i# R .id = 1,! ?; T8 v/ a& g9 z6 o4 c
.dev = {
" g% ]/ O+ j$ A$ E) v& F6 `6 ?# F. x .platform_data = &da850_evm_tl_leds_pdata,' l0 d; N' G5 p" Y* a* ^
.release = led_dev_release,
/ w3 ]7 o1 i( Y* O }
& ]" @) r' ^5 u' d) M};
0 V' f1 h) x4 m1 ^) q N
* x5 M, ` t5 `& [" h* Gstatic int __init led_platform_init(void)" j; ^% R: A. n" @1 O" h
{
! y6 h' D6 {: a; [! l int ret;
& {, A$ @) c/ I" M& B* C) g! L#if 0
( v, `0 T6 _# q: v( x ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& h- V D0 o5 [, c8 N" w if (ret)
" G2 ?$ r! e9 }* C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 x3 l( p7 W7 K
"%d\n", ret);
3 ?) `% t0 S& I7 a#endif
) }8 V4 |4 t8 x" L* X# j ret = platform_device_register(&da850_evm_tl_leds_device);2 ?! g3 ~% _; u5 K, ?
if (ret)2 t1 f, R- G9 x
pr_warning("Could not register som GPIO expander LEDS");0 `# B4 B' z# [
else6 n& {( T- K6 q
printk(KERN_INFO "LED register sucessful!\n");
* v" D) x" S+ f( }
5 ~* w. H1 `/ h, R8 Q return ret;
# Q. s. r6 t# \" h4 j}
$ b. Y: ^* ` [* r* W. M
; j0 f& |0 a! z- F; J1 m, pstatic void __exit led_platform_exit(void)/ W; H. W/ a+ X- w3 w( A
{
& A7 W& ?0 n* m# o platform_device_unregister(&da850_evm_tl_leds_device);0 C: c i& h$ x# ]5 ]" `( Y
r( B! \$ q7 J( @+ \ printk(KERN_INFO "LED unregister!\n");
( X; q& x; C' D; K/ m4 l, j4 r}" |* E9 X8 f' `( ], x" p
5 |% R& M+ b8 Y8 X# j& U
module_init(led_platform_init);( z3 E' V8 i$ B8 g3 U5 U
module_exit(led_platform_exit);$ d: P* B: \* k
: M& b' J! `; A( N
MODULE_DESCRIPTION("Led platform driver");* p& B9 k$ e& R( ~ A* }+ e# b
MODULE_AUTHOR("Tronlong");% n1 l/ h7 E* o7 S) U W$ m
MODULE_LICENSE("GPL");
' l2 T) Y x/ Y: v3 Q( x! Q- P1 w. ~6 x. a" e
|
|