|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 u% V" r9 m8 R7 ^' G N f) e
#include <linux/init.h>
8 n& @# n7 p3 l% d7 D4 M8 V. i* `#include <linux/module.h>
' _0 ?+ m; G, j#include <linux/kernel.h>
% e7 H2 Z; `, g0 S3 W#include <linux/types.h>/ q/ D" u v/ ~/ ~. g; H5 i3 y4 G3 ~2 u
#include <linux/gpio.h>
! k$ A: q" N& A, X! M. i- U#include <linux/leds.h>
" X; W/ F" ] W+ @! l7 r#include <linux/platform_device.h>" G U1 C9 h8 A0 R% S7 O
& l$ g, v8 {! `9 x! o: J#include <asm/mach-types.h> y( p0 a" d6 z1 T* d8 t& w$ t/ B
#include <asm/mach/arch.h>3 R5 [. ~" R4 h; {
#include <mach/da8xx.h>, J/ ^- e w9 u2 ^/ n; d
#include <mach/mux.h>4 ^/ Q, O% I" \$ L6 d8 a% R# M4 {: i
; Y) F3 A. j) J1 J" r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
@: z! I! m- ]* O6 L/ v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 k6 t- o: ]! w- K' h0 h6 ^/ L9 }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 n( ~' d3 y2 u9 f" O/ q+ O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# V! K7 n$ E2 B/ E4 q
8 Y- B u; G" G3 D4 z, S/* assign the tl som board LED-GPIOs*/+ H+ v8 {4 G: d+ o* @$ J* |
static const short da850_evm_tl_user_led_pins[] = {
- ^* W/ J% k; ~. A8 N /* These pins are definition at <mach/mux.h> file */0 o. o( d2 k1 B# ~0 _' d6 i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 q) v8 S) |5 K0 ` -1, l: K c% p8 F) _- ?$ G' H; t
};
( r6 A4 F- o7 X6 }$ @; R7 |- m7 \6 l- z$ E4 f# a
static struct gpio_led da850_evm_tl_leds[] = {
( q L4 i3 {0 _! G, D {; W& _$ L8 V) }7 q, p: [: J
.active_low = 0,
b" R$ @8 C3 D .gpio = DA850_USER_LED0,
+ {+ W# ]4 j- P9 Q .name = "user_led0",
2 X7 n: A( e. G8 A" w .default_trigger = "default-on",
) M' ]# [! X5 Y& {+ M( k% s1 t },
) b F- i! K1 c: @3 K* ` {
4 e9 n) K) ~6 \# w% C5 i! X .active_low = 0,
1 o& ?4 p& A8 B1 T" w4 }% j# ^ .gpio = DA850_USER_LED1,' M( _" E9 l [+ i5 ^
.name = "user_led1",2 q8 H+ \+ H; ]: }/ V% U2 b4 s
.default_trigger = "default-on",+ E, ^' ?4 f$ H6 { V' n- R( X0 d
},
. K5 a1 K2 [9 k1 N6 @% x {
& C6 K* U- V" a x! j# C .active_low = 0,- X+ M9 C( d7 t9 n
.gpio = DA850_USER_LED2,+ l8 p* |. M5 ^6 W. L& Y5 A+ W3 K# q
.name = "user_led2",
% r3 L0 J; ^4 Z" }$ [4 V0 S9 ] .default_trigger = "default-on",
1 n9 l6 m; R, e1 A7 q. c2 x7 E4 Z },
1 V9 D6 T8 X1 x' g2 f B {
' ~; [* O+ E0 g: N2 K# G. |) u5 m .active_low = 0,
3 i# ]+ T% Q0 Z1 M .gpio = DA850_USER_LED3,
. J# A8 Q' a) ?( C; `* D .name = "user_led3"," `- G' Z8 o2 F5 q% s
.default_trigger = "default-on",! A5 P% o7 h6 N( A4 Q
}, V( A. p$ U0 `- J8 g# I/ y7 E
};0 Y- j2 S* k% Y( ~
) q O+ E2 u* n( j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 N! C# d, m+ q' m/ b9 J0 I
.leds = da850_evm_tl_leds,1 h' a& V9 H7 N' a: ^& k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 u" ]: }6 I, D# f) S
};: [/ y* J2 O' d
7 b% b# }1 Z# n$ V
static void led_dev_release(struct device *dev)
: E$ T2 _* }7 ~% w* }1 P! n+ a+ c% B{
9 Y, N# P) ?/ ]};- x) A% X+ O5 F7 x% z& I
& t0 I" N0 {+ I: E E
static struct platform_device da850_evm_tl_leds_device = {
5 W5 @1 B) v3 u( ^, m' k- }) t5 [ .name = "leds-gpio",
: T- [; d4 N4 T! [! K0 P8 D .id = 1,: ~. J/ M! h7 z4 [, ^
.dev = {5 J2 A; l R! N6 L( J
.platform_data = &da850_evm_tl_leds_pdata,, h9 r" w% E" n5 Y( [* w3 F6 p# A Q, Z
.release = led_dev_release,
/ j5 l" s3 l c& h2 i- W5 K }4 y- k8 @6 O8 V6 ?. S% `
};
* D3 P/ i( Y& k; I8 [2 G6 y6 L8 q' n" F* O) Y2 I+ [7 d
static int __init led_platform_init(void)
+ G% ?' Y) B6 U. y& W+ A: ?{4 r& l& a0 u0 M0 f& q# W- V
int ret;
7 f. K9 e: r- f" o, Y7 j#if 0
0 k6 w1 P, Y; W" e' l" G8 H7 D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) ?8 U( s& V) x, W8 v, e
if (ret)7 \: X; R+ B4 a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ C8 s* b6 s5 h "%d\n", ret);
3 m. r* Y9 _" B' ]1 ?. I0 h#endif5 U8 c, r& X6 s, ^* V; v# v4 ~- J
ret = platform_device_register(&da850_evm_tl_leds_device);" B2 B( {7 K% q; e/ ?/ X5 F
if (ret)4 h5 k: |; Z* W1 R2 x9 ?3 u
pr_warning("Could not register som GPIO expander LEDS");% R8 o4 J/ H1 B7 E* @& G
else
* W& u, Z5 p' }' Q# B printk(KERN_INFO "LED register sucessful!\n");
$ z" J5 s1 P4 d( `5 o8 j$ b2 i4 p! t4 Y$ k6 i
return ret;
+ F' F1 v8 H8 ~}" ?& _2 F* m5 a2 v4 ?0 u% T
! l3 w' a9 }) _* q8 h. m
static void __exit led_platform_exit(void)3 ?8 t7 {& a+ B) R
{
& b h: w: o3 s; w: j! t. x platform_device_unregister(&da850_evm_tl_leds_device);; }. A1 t& P1 D p# Y4 X1 {
- e0 N* S# s2 N8 T9 }$ t
printk(KERN_INFO "LED unregister!\n");
% ^. o2 o0 j3 {6 F}
! j. ^' @0 f2 H5 _7 l' v4 g$ C1 Z( h+ B6 i' W
module_init(led_platform_init);' \6 e8 z1 U6 P2 C
module_exit(led_platform_exit);0 c4 T" o1 X& ^1 @% R% B! m, I
' Q, \+ `5 T- a; r: S: ~
MODULE_DESCRIPTION("Led platform driver");
2 e5 `, w+ z1 q0 a) a5 _1 @* v/ D. WMODULE_AUTHOR("Tronlong");
8 m/ ^) A. ~# s5 {' ]& LMODULE_LICENSE("GPL"); L5 q/ J' e( a
: L% c) W' o7 j r. X |
|