|
求大神给下面的程序做注解,请稍详细些,谢谢。
' U. G- n" \) z4 ]) j0 |' E#include <linux/init.h>
2 T( e3 E2 N d1 @#include <linux/module.h>' U3 u5 r+ } o" _( m
#include <linux/kernel.h>" C6 l/ Q, A2 _6 g
#include <linux/types.h>( T- h8 K+ A% g
#include <linux/gpio.h>
8 I0 _; C2 g2 K#include <linux/leds.h>: A" B, l- h0 F: ^$ ?) u( D
#include <linux/platform_device.h>
* j6 @% M$ I; p# C, j2 ]; Q
% t1 q/ R$ E5 d7 c2 x#include <asm/mach-types.h>3 t2 B6 V. }! ^/ {1 t% m
#include <asm/mach/arch.h>
4 O" Q% p$ T- V+ x5 [#include <mach/da8xx.h>; F6 h: t! _% e9 r1 S, o
#include <mach/mux.h>% b2 O; ?$ g, l) A& `/ ~: R3 l
3 q7 ^! t' X, Y3 L8 [9 w y) ]5 @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, U F2 d- X6 Y1 B( b0 e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- p4 {4 {5 l! S! B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 S$ q# Y/ Y* A( s& h B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 L" C8 A& i8 Y: f
, z- [# _) c* b$ @, n) N# _5 d/* assign the tl som board LED-GPIOs*/
4 n3 [- N1 Z9 }* bstatic const short da850_evm_tl_user_led_pins[] = {
( t( o5 y! |4 t /* These pins are definition at <mach/mux.h> file */
/ C3 ~9 N, X; j1 }$ w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, X! l- R, y0 W! X" \6 x
-1
! [4 I2 V- @! q" N, T5 Y6 c};
: V8 M% a2 H, [3 C7 F
" h5 e6 R4 f( d7 C, t; Dstatic struct gpio_led da850_evm_tl_leds[] = {
; j% A8 ]! {1 E {
. g6 b$ z, \0 P5 E% e" \5 w .active_low = 0,8 @* u6 c7 x: m0 m
.gpio = DA850_USER_LED0,
: X. _% j8 p% I6 v# r5 Q .name = "user_led0",2 \- I. b* d0 f1 l) y
.default_trigger = "default-on",1 K( Z( Y' P) G8 C, }- g
},
4 t7 v5 `2 X* D5 r8 r8 ^) v {
" T4 @. O2 n1 D: i% ^: T& i .active_low = 0, W9 v5 R; a* H: L) {! ]6 r2 q
.gpio = DA850_USER_LED1,0 B' L3 c5 F. P D; q6 H+ |# I
.name = "user_led1",
! }9 H% H+ k; ]( A4 G" i q .default_trigger = "default-on",
t8 J2 U0 }9 z2 ~# C! t8 C! B8 O },; Y6 x! A) L) B* s2 [9 b
{
8 l/ P7 n* N- H0 C! M. p: o .active_low = 0,
" H. S5 ?2 _9 {6 }1 i .gpio = DA850_USER_LED2,3 Q1 V3 P- G8 |* C+ {' q7 ^
.name = "user_led2",' L8 B. W8 d- w( v7 T; ~9 U
.default_trigger = "default-on",
' Z- V6 \0 \( o2 a5 n( o }, L: y6 L$ e! @. z" {+ ~" v
{0 t9 W4 m$ H6 p' Z
.active_low = 0,$ a* e. x6 I2 @
.gpio = DA850_USER_LED3,8 o5 H: R! V/ q1 N/ J
.name = "user_led3",
2 G$ W! r3 V1 b/ T5 J+ C .default_trigger = "default-on",
% [% n# f1 Y- s9 ?9 W },
; A H* _% b- u};* w4 c4 n/ F* c- C9 y
0 K3 e s5 e+ q( @7 d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 ^7 `' D, a3 [ ]8 D6 q; S3 @
.leds = da850_evm_tl_leds,
0 G0 \+ ~" J4 A% S8 o9 D/ N; ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 |4 z/ M4 N. q
};" R K' D9 O$ g8 P# Q
( z5 h3 |9 v# d) q6 nstatic void led_dev_release(struct device *dev) k7 j1 b, @0 e- y
{' @/ [ s* B B Q l
};: v' c4 ~3 c8 @% @9 {7 @
/ D( n( X1 y' G1 nstatic struct platform_device da850_evm_tl_leds_device = {; M, [9 l! p. {0 L9 y
.name = "leds-gpio",
3 L8 u) W1 `( a& b }7 n4 \/ a% ` .id = 1,2 t& P0 q; i7 P' X
.dev = {
' y/ q0 s2 c9 z7 l! u7 a .platform_data = &da850_evm_tl_leds_pdata,
- \) D( }3 p# q7 a1 ^2 O* k% u .release = led_dev_release,# k" j o Z: }# `7 Q3 O
}
' V p- _/ E$ y" d/ B* e};$ j& ? J: g* J1 w& M N; }1 r
& Y0 Y' _1 U* Z2 k K
static int __init led_platform_init(void)
6 ^. c( @& M3 [3 n7 c{# V, h6 H- |! ?1 V% Y
int ret;1 s' j& @8 t o% A
#if 0$ g9 x: |; k# T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- ^3 [" h& F7 o" P' ~ if (ret)
6 Z7 `5 Z0 l; S$ J3 Y/ C, Q( A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 V/ o8 x0 b! U "%d\n", ret);
& t, {' Z+ K8 O* T5 X8 n% \+ E+ V#endif3 B+ |5 E7 W4 C( F; p
ret = platform_device_register(&da850_evm_tl_leds_device);
/ B& y' I2 a; h8 |0 x2 t3 V; |4 h if (ret)) ?: V/ Y0 u& m+ `7 r. j4 s
pr_warning("Could not register som GPIO expander LEDS");
: [0 i. Q' X& V& I# q: ]6 d else
# O) a7 h. C* U$ J1 C M' I( A5 m printk(KERN_INFO "LED register sucessful!\n");! G/ P ]! Z* t, N
- D8 i9 v# J$ P9 G8 ?, l4 n7 \
return ret;( k& ?# e8 Y! N; L
}
% u7 X1 k5 S9 l: E A. D& R# n& J/ \
( ?+ ^ w$ e# B. H) Cstatic void __exit led_platform_exit(void)% x, ]: h" G# t/ s; w4 c
{
5 C( K# L5 P% z, k) v! z platform_device_unregister(&da850_evm_tl_leds_device);# ~6 I! v2 n( ]. m! p: t
- [' G) Y; H% [: h
printk(KERN_INFO "LED unregister!\n");7 f( a S0 Y% }- v' a1 [* H5 A
}( o/ Q' @- n% o
0 J6 f t9 ]+ D# P2 d8 K' W& U7 wmodule_init(led_platform_init);
# h' J* {0 s. b2 wmodule_exit(led_platform_exit);# ^, v) c) ^; O2 ?* v( r7 E8 t
: Q4 z( V% c4 f, S7 ~
MODULE_DESCRIPTION("Led platform driver");
, }$ a9 f/ O, L& C dMODULE_AUTHOR("Tronlong");1 x3 h( p" {2 x2 U, e( M4 d5 E
MODULE_LICENSE("GPL");
) X6 @0 Z& R- r" ~* d$ P) i+ r( O. q: g
|
|