|
求大神给下面的程序做注解,请稍详细些,谢谢。
) [! q! l- M0 {2 I" T#include <linux/init.h>
i1 w5 h9 m( ], z# g9 Y#include <linux/module.h>: F2 ?- D& C+ K+ I6 _
#include <linux/kernel.h>
- {* {- [6 H+ `/ n& O3 M+ {- i#include <linux/types.h>7 j3 E% h; d. e$ B. q! {& [) }
#include <linux/gpio.h>
" e0 T, L& c, h1 U, l P6 u#include <linux/leds.h>
! K% P" T# M6 K. C* U! Y#include <linux/platform_device.h>
: Q6 i8 [$ o2 t2 q' r# k) s; c7 r" z* u- E
#include <asm/mach-types.h>
7 g% q6 B5 E7 V% C: @#include <asm/mach/arch.h>
' Y0 o6 }9 O# u& [ T#include <mach/da8xx.h>6 m* g! d7 `3 B+ b( C2 ^4 l$ J3 T
#include <mach/mux.h>0 u1 U5 O2 w# [5 ~
1 N+ e6 t8 R9 [6 j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 E) E8 i. r- O* Q9 `7 H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 {1 \2 m! C' I: O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' R3 W! X( S6 a$ @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 u# I! h0 E8 v, Y; k9 i4 I
F. Y; x. [2 R) a# J3 _7 j# z2 u( ]9 S
/* assign the tl som board LED-GPIOs*/' G4 I1 v4 ?2 j l
static const short da850_evm_tl_user_led_pins[] = {
- L* h5 m& [, [- @" u0 T /* These pins are definition at <mach/mux.h> file */
1 n' f# T' a* f4 A8 H! A0 A* G$ z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! c h# N3 W1 r4 @% [ -12 r4 d6 h: B2 M! \9 b$ f M" i) P
};
% l) r9 x, m. N, Z' q. f7 u5 x9 ^
, a. e- V, ~; u& Q* e1 qstatic struct gpio_led da850_evm_tl_leds[] = {: H( D/ X4 t D' x5 f* F
{' f. v, c* Q8 a( i3 o% j% U
.active_low = 0,
8 j+ @" h) t! S9 \) d' a- G .gpio = DA850_USER_LED0,' j- _$ v4 f/ }0 J* p9 G
.name = "user_led0",
" x3 T$ L5 n1 g( a( h .default_trigger = "default-on",* Z( a/ K U! f' s, R: r- S
},
/ Q4 @9 V! n! I {# G6 n9 o9 n9 ?$ ]# z; L
.active_low = 0,% v5 H3 D; @ [ ^/ J
.gpio = DA850_USER_LED1,, b7 @4 W# \9 u# M! V' i
.name = "user_led1",
2 D4 q( @9 |5 U. q; x9 z3 F) c .default_trigger = "default-on",
7 F+ J/ G: l7 W7 d0 ]+ S" c },7 o) ~! y# q& J
{
" P& _9 N) {7 @1 b .active_low = 0,
/ z/ Z5 i6 |# }' H( L# L .gpio = DA850_USER_LED2,+ i5 c$ E( }" n) u* I2 \5 G2 t
.name = "user_led2"," q; }5 s' a* c0 ]
.default_trigger = "default-on",3 Z0 T7 {, U5 W
},
* @. R1 }$ O% ^( g- z {4 w' n3 t' Y8 V
.active_low = 0,
, V, s1 i# C, m+ B! d .gpio = DA850_USER_LED3,/ W j3 Y, W. {6 S: Z" |, f% z$ j* N
.name = "user_led3",* z6 {2 F+ D* ~) b" N$ z9 ?
.default_trigger = "default-on",& H) V# U( [) b! U/ {( A( q0 G2 f8 a6 v
},
- r& \4 m) s ]3 B/ r/ L};; ~2 t- L/ F) v; a8 w( g
$ {; Q( V2 U, q g# q# S* a+ qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 C. ?9 Q& z+ I
.leds = da850_evm_tl_leds,
f4 d" j7 L0 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* i3 \2 i: C9 W) f, T4 a$ D
};
3 p9 N; n W- D& C0 ?$ M; e; t, Q6 o2 X: d. o
static void led_dev_release(struct device *dev)
7 f! g# X6 _+ B' z4 n0 |8 o{4 Z) H4 { Y y5 J. M3 @4 e
};! ~1 b# M# k7 C: g
% s/ A6 }0 o K3 `2 n$ {% gstatic struct platform_device da850_evm_tl_leds_device = {+ `4 @! [- n7 ~1 G
.name = "leds-gpio",; J. I' @$ k( l, d1 \2 K
.id = 1,) M5 C: [, p' Z! }: X- L
.dev = {2 R6 P+ R- q! I( S
.platform_data = &da850_evm_tl_leds_pdata,9 e3 F! E, ]* N% { ~
.release = led_dev_release,
" ~, N) T- V; T2 d9 S" x }2 C! o! l9 c. e Y( N
};
% I( g# b$ Z2 a$ h. h6 q2 o. g+ S$ _) a0 Y1 o' W
static int __init led_platform_init(void) ]8 |! ^6 t3 U1 `
{& W% `. E$ n7 f5 s( ], A2 z6 t
int ret;
; _- {) b) o8 |- w1 h& Z#if 0
% c- N2 r$ {5 O7 D. ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% l8 [7 j$ S! l! b0 U4 {
if (ret)2 K2 z2 n" k0 x, \& W$ `7 S: O' A d' s& S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 }" I+ b/ u! S0 y( k "%d\n", ret);) s6 l6 S- u, H! J
#endif0 _9 L/ h3 |& |
ret = platform_device_register(&da850_evm_tl_leds_device);; g3 A! _* X/ n: U
if (ret)
$ Y$ H$ z& {3 K# K' H7 V pr_warning("Could not register som GPIO expander LEDS");) q( e# I6 y+ w
else
( v9 E8 W- c' y# W( R. b+ t printk(KERN_INFO "LED register sucessful!\n");7 x9 F( a& V' G) O$ A
" q& R1 j% s' a$ l$ j' m return ret;
' E3 X7 A' ~- d0 w}
6 p0 z! G" d6 `4 S! X. J6 ] s, u3 z9 P* z, g/ D5 L4 D: i6 h; g
static void __exit led_platform_exit(void)1 p- }! q: N! e
{
, V4 y2 [2 Q; T" I4 _3 x5 j platform_device_unregister(&da850_evm_tl_leds_device);) s6 ]& Q/ X( ?
. m9 q7 [( W4 h2 N# D3 | printk(KERN_INFO "LED unregister!\n");
# g: H1 `5 O! q ?}& E# K" Z$ ?/ _; U5 S! i. x
j: P, p) f9 X9 i a3 q o
module_init(led_platform_init);! p2 y0 X; `! V2 ^
module_exit(led_platform_exit);! F- [# P: S/ ~* K: h0 [% a
* U4 e: K/ c9 }7 ]8 _7 r! B
MODULE_DESCRIPTION("Led platform driver");: x m+ ~9 X+ S T# R
MODULE_AUTHOR("Tronlong");+ A1 W1 P! v+ d$ B
MODULE_LICENSE("GPL");
# K7 y9 E( G' _% U z) Y9 F6 V% g3 j$ K$ G& A, {" J
|
|