|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 r9 L) \9 c4 _( }' @" E
#include <linux/init.h># W6 j5 D& u! e6 W1 {9 C2 F' E. ]
#include <linux/module.h>8 h) n8 c2 L6 @1 K
#include <linux/kernel.h>
@7 W8 U; k* ~( s! i$ A#include <linux/types.h>0 D% Q8 m3 v: q5 M( Y
#include <linux/gpio.h>
1 S' T' T3 {& C$ `' }#include <linux/leds.h> p. x! E$ T7 c8 j2 D% S1 b
#include <linux/platform_device.h>
' _1 A. q" K+ D# B
, U+ E' k" P7 g/ ^% i#include <asm/mach-types.h>+ y( V p8 t; I7 l- \& F8 r5 F0 H% ^
#include <asm/mach/arch.h>
: Y. Y f# z/ }) N9 Z2 g" K#include <mach/da8xx.h>8 u2 P& {2 h" ~& T0 B9 b: \ g
#include <mach/mux.h>! v6 W* e J5 A$ c7 `' z, n
% G6 J [( v8 {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" G* s* ?- K7 l$ ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 c- R& g+ f4 P4 s; }7 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): F0 y+ J: T6 A$ W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, i5 h8 R0 } ?+ W
' m0 S1 J" H2 B7 q7 o. _/* assign the tl som board LED-GPIOs*/- D1 N- q! t- n o% B# X$ `
static const short da850_evm_tl_user_led_pins[] = {+ N+ \* Q% K% R' s9 l
/* These pins are definition at <mach/mux.h> file */
+ c5 G9 M- _( ^2 Z2 Z N' J( _7 a0 B% ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 t$ |% f" ]6 }, L0 r -1& t) o; n/ p. Q/ `$ d3 S. E
};7 D9 x. Z" y% m6 O+ w/ w9 \- n
/ Q/ |% A' N! H& h R" `2 A- sstatic struct gpio_led da850_evm_tl_leds[] = {- E6 Q# N5 \% C8 Q! T/ v! Z
{
' A# H3 E3 ~2 Q .active_low = 0,
) G6 K0 `; @! B+ N! L5 ?. D1 M .gpio = DA850_USER_LED0,/ J: D0 U3 c( L: ~, \
.name = "user_led0",
$ E, ^7 u- K. V3 T/ S .default_trigger = "default-on",
$ C1 Z" f3 u& r+ ?: K, g },
: C. n& G/ W, V L# H5 M {4 V% y1 y q8 [! k) _
.active_low = 0, B3 O. @. s+ I+ ]2 S; P8 P2 g# [
.gpio = DA850_USER_LED1,
6 d$ a* A6 r% f0 b1 [: N. J .name = "user_led1",6 s( I; a9 B! Q2 C
.default_trigger = "default-on",9 c0 _- I; W# N5 w, K8 ?1 \
},
$ f( a" U. ^4 V: A {& ^# ^% N b8 {/ X% T. P/ s) K! F
.active_low = 0,
* r: k: j8 U# R6 U, V .gpio = DA850_USER_LED2,
0 I7 L& ?# |# \% w% S .name = "user_led2",9 q1 M+ Y [8 y. _0 ]
.default_trigger = "default-on",
; k; U R9 d9 d& r3 W4 J7 e% J0 {- ]0 J },
; d* S; W6 R% B {3 x( W3 [7 d1 T; M0 I
.active_low = 0,4 m+ _" H& L+ r# v
.gpio = DA850_USER_LED3,% v. M! w$ N7 Y$ r( ]* ~% D6 G7 U
.name = "user_led3",
# R1 K/ ^3 N8 L4 e+ R .default_trigger = "default-on",- w4 U. U C% p" w2 I
},
/ W: W# w, h1 T+ t};
- _" \0 i' P2 t M; M/ z; U+ P& _' k# O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
g3 U; t- t- p6 x: a# q- d .leds = da850_evm_tl_leds,
* x G# Q, W& M( m- a) z3 @% x" r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ }7 `% J' q7 Y% M+ ~4 r( K8 g$ X};
0 W! x7 d2 M5 A' p, `2 k$ d( l# r& K" ^
static void led_dev_release(struct device *dev)" s* J4 P! f; c
{
2 m' K# S3 p2 n* o. b& e};7 m4 u9 H8 B y2 m, {8 Z4 a
% \5 b0 ^7 V4 F
static struct platform_device da850_evm_tl_leds_device = {* v0 C$ E# k s$ Y2 A, r
.name = "leds-gpio",
1 x; L0 o1 q/ J8 k, J5 z .id = 1,
4 N# c6 D! z. ~ .dev = {% }) H! e4 z! Y( c( _, {% U
.platform_data = &da850_evm_tl_leds_pdata,# d+ c8 _( E0 ^$ V1 {9 {4 `) v3 M, E
.release = led_dev_release,
, }9 i1 x6 z- w% A }
& v8 Z* v1 B' k# _+ f: I: @}; W+ ^/ N8 ^& S R8 |, F
+ q; ~# k. y* u2 ?7 c* U7 H' y
static int __init led_platform_init(void)4 ?; v: s8 }+ q: |: K
{
' L% x' Q1 N' W7 H, k int ret;1 A, N% m$ C$ K% V; u- P
#if 0
" z; s) L+ e+ {$ A* h2 W2 ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ |- O8 f/ @ [$ i. s, B
if (ret)
0 h8 j7 ~! h8 i7 h$ c2 \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 z$ C% Z: B# M4 I/ c6 M "%d\n", ret);
5 j- e+ ~! V1 H9 w' A# S6 @#endif) I! S p' U5 J3 m+ ?+ w# y# v
ret = platform_device_register(&da850_evm_tl_leds_device);3 G$ }) a# ?+ ]" X" m. E0 ]5 J3 d
if (ret) v, K5 }$ C5 L* c4 D2 O. r( y
pr_warning("Could not register som GPIO expander LEDS");
5 y3 u$ Y5 ~+ _+ c else( j0 a# K- u; }# R
printk(KERN_INFO "LED register sucessful!\n");, l$ z& [0 u @: m
t/ A1 o; d+ Y" {2 @# V
return ret;6 V3 I E6 Q5 \+ M, H3 J4 N1 k
}# m( f% ]7 \1 l8 |* \4 X
7 T1 D/ O7 z- z$ d8 d4 R7 zstatic void __exit led_platform_exit(void)& T, i+ m8 c" g' |
{
) }' ?! I" M) o/ ?2 i platform_device_unregister(&da850_evm_tl_leds_device);. }3 S& F! t6 y, Y" U2 c
2 s, a; ~4 N' D5 |' u: Z' N
printk(KERN_INFO "LED unregister!\n");
$ g- F# R/ j% H' o' u1 m}) @- r) d# J/ S6 _2 w- r
; Y4 ^) {+ c2 Q( O6 a4 e7 Ymodule_init(led_platform_init);
. T" s6 I1 a5 l3 v) b8 H9 X# ]module_exit(led_platform_exit);: }' Q N% ?. r+ F: K6 _/ S+ h
9 T2 }' G( z! Z! k) u* ?9 g' d0 ]: E
MODULE_DESCRIPTION("Led platform driver");+ d7 U7 ~: L( S7 y, O" e* M0 w
MODULE_AUTHOR("Tronlong");3 F V! J* Q7 _2 Q% d, X
MODULE_LICENSE("GPL");
9 T0 L/ U5 | Y' L2 S
2 ]( g8 I% [- O6 h9 K1 v) s4 W |
|