|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. R3 H4 u7 j5 v% n9 ` V#include <linux/init.h>6 q+ |6 l- w. L4 C' W
#include <linux/module.h>3 n. V7 ^9 _, ]6 |
#include <linux/kernel.h>9 E( W9 A* F2 c( O) H/ ]( y2 }
#include <linux/types.h>
( k; |4 g% O$ U: E2 y' m#include <linux/gpio.h> R+ E* F% y6 K# p3 [1 g
#include <linux/leds.h>
! w, N0 g$ ~! G- X: B#include <linux/platform_device.h>
: x7 f) H ^( P3 S \
* c4 A: Y3 D$ @7 I2 o5 w#include <asm/mach-types.h>, t6 o% Z" R, c+ c+ f
#include <asm/mach/arch.h>
" \- I! V" Q% ~ }/ c2 Z#include <mach/da8xx.h>
0 m- k/ o2 B" z4 s4 a#include <mach/mux.h>
2 D& p1 M3 c7 ^6 ]
) D3 @' d" R7 z: K( ?" X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& K4 c$ X1 s8 d: _" {) s& r3 E+ d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 A2 |& }7 w: N3 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ N7 F1 P6 r& g7 {: i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 M( W& l3 a% q# k
% J2 O) C4 `4 q Q0 U# s/* assign the tl som board LED-GPIOs*/ |8 M: n. P9 G( y1 D0 k' d' {
static const short da850_evm_tl_user_led_pins[] = {% a& e; k. G0 M0 u- G/ Q
/* These pins are definition at <mach/mux.h> file */
/ M6 H, X+ A% x# ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 A$ |8 n; r- F7 u3 D' d8 w -1
8 A7 ]4 q% v: c7 @2 i};
, Q; U3 N- a9 a% E! I) n5 j. P/ @- M
static struct gpio_led da850_evm_tl_leds[] = {/ B% Z4 ^$ S0 N
{+ ~$ P/ r0 a5 N+ M
.active_low = 0,1 `2 A4 J$ L% ^0 E% F' |
.gpio = DA850_USER_LED0,
5 b' k- \ e! ^+ ~ .name = "user_led0",
, i, Y: ^* G3 ]$ u" G .default_trigger = "default-on"," N! E3 ^7 R: o. i
},3 S8 V" l* J' ^. P- f; _& Z
{6 d7 Y: _6 Z7 U7 N, q3 ?
.active_low = 0,
! c; i+ z W: S .gpio = DA850_USER_LED1,, s9 k1 q% |& }1 V9 h8 x! Y+ ]
.name = "user_led1",
% S" ^: T* Z4 Z1 R# Y .default_trigger = "default-on",6 C0 X3 d) w" c4 `* b) O; D
},: N8 s: e4 K0 v3 k/ ]3 f
{
3 A4 X1 ]7 T5 b' }% O7 { .active_low = 0,
* m$ \. J3 `. v6 r) H .gpio = DA850_USER_LED2,+ P; c5 x9 t8 w3 H: \. l: Y7 Y V- H
.name = "user_led2",. c" I4 \/ J9 N' r
.default_trigger = "default-on",
2 q- `) h( E. ?- V# g },
5 I/ b# j8 q- w8 g9 R5 } {
, {( t( f( X) _7 g* h: { .active_low = 0,
1 A# d- u% c$ w4 Z0 E .gpio = DA850_USER_LED3,& O$ M) X% X* ?2 B( N0 n3 z
.name = "user_led3",
( |8 ]) i& N+ e .default_trigger = "default-on",
( e" z8 Z* l5 {) O8 o },
( F3 L5 q0 `8 K. ]};
3 m; W: M1 F, y+ Z
- ^8 v6 }% v2 W: Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# k' N4 d3 b, |2 B
.leds = da850_evm_tl_leds,
3 g4 \" k0 u; x9 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ I1 ^4 ~' ^' A& g# o( s5 _
};
. ^1 ?- p& }0 @) D$ K3 ?7 K* t' T0 M1 J/ B; F7 e
static void led_dev_release(struct device *dev)9 X0 t9 x4 D, {
{
- M3 F+ ]5 V2 s};
6 l6 L; ~) x4 j: A) R* a6 l$ l; I% Y' S9 K( f% n" T! F( e0 R
static struct platform_device da850_evm_tl_leds_device = {: d' s# F- ~/ S4 m0 O5 ]- C
.name = "leds-gpio",3 f. R' D9 {' U5 V' w& \
.id = 1,
1 Y2 R( V# t+ T$ C0 b% D .dev = {" {' i. K V$ Z& a' r- l
.platform_data = &da850_evm_tl_leds_pdata,
2 B. E! C$ i5 |/ ] .release = led_dev_release,
1 i! I+ t9 d7 _0 A1 o }9 f0 i) u- T8 \. }- i+ W+ q
};4 h. |! T* o' t4 o; e% Z, i) n
; r8 ?' B- m4 ~0 P$ Q. t
static int __init led_platform_init(void)
& O6 }* j: S7 \/ g( j; x{
: b& T# b8 A, C: K; a( r. a int ret;0 b0 w3 ?6 w7 b! b0 J) e
#if 0
+ w. k- m) C; o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ Y0 r% f, o' W( i
if (ret)
5 l6 f- [! ^/ m4 K8 o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 V, ?" d4 E# c# a& Y2 g( I4 C "%d\n", ret);3 F7 X+ m3 n, r d5 |
#endif
. ]9 Z2 F# ^; p) p* n ret = platform_device_register(&da850_evm_tl_leds_device);
3 h% @; [- U& k$ T5 O/ C if (ret)6 _: B( }: R; [* D( D5 X
pr_warning("Could not register som GPIO expander LEDS");
9 N6 ]3 K! y2 l ?$ N4 ~8 H else, Y3 u) o& h. D3 k1 ~0 W
printk(KERN_INFO "LED register sucessful!\n");
* ~6 _: K/ v: Z# X" n! x; u, d1 \
5 E9 {! V3 O/ p J8 a4 z return ret;0 n2 ^- h+ c6 ^3 L6 s
} ]( R6 }" T/ c: @
Z C2 F2 f7 r3 d
static void __exit led_platform_exit(void)
6 r- v/ A! {9 e; R. v{
. f) P2 Q% i/ W4 | platform_device_unregister(&da850_evm_tl_leds_device);
3 }' l3 o* \& V- R& r0 z F' [8 S6 n
printk(KERN_INFO "LED unregister!\n");
' H4 m2 o8 m" q6 X' D}
/ Q* _; g: ?, G+ W. q1 `5 y. U4 q7 v8 z" h; R" d! C I
module_init(led_platform_init);
n* j/ j% F6 M& C3 u' z, y7 Smodule_exit(led_platform_exit);' _4 U( L2 R" ^* s; H6 ?7 |
5 k# I! t( y+ t% q* Z& }- o7 D, gMODULE_DESCRIPTION("Led platform driver");, c5 p, j+ Y) x: V2 A
MODULE_AUTHOR("Tronlong");5 u+ V2 Y* a# G" k+ P, @9 b5 v0 e
MODULE_LICENSE("GPL");* t; q6 o B4 e; d/ D D
/ P$ y) B7 t, d% h" j9 G+ s! ` |
|