|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 m6 r: _$ H! e1 x4 ^6 N- L
#include <linux/init.h>
" y) s" i7 D+ ?# J" ?: q2 x#include <linux/module.h>2 W u. ], K1 x
#include <linux/kernel.h>
a) p& e* E3 i" x) }#include <linux/types.h>
4 z% F7 I! T4 |2 k#include <linux/gpio.h>
' y3 h) B9 \* l9 E2 l l#include <linux/leds.h>
- t% U( o6 E. g#include <linux/platform_device.h>
6 h7 o* d" } e0 C7 j
+ s7 Z! M$ A" i#include <asm/mach-types.h>
! q+ x2 h5 z# s/ A0 D#include <asm/mach/arch.h>
% \# _9 @- _$ N- @#include <mach/da8xx.h>
5 R7 h# F9 n: D1 e' x#include <mach/mux.h>
, M. @- u2 J( i, `7 ~8 h& X* q" h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" s4 k @0 g5 ~" y9 J* f' N, }1 @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): X. O* j9 a4 S$ I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- _3 g" ]3 h0 \6 N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 f, n; O2 [5 z( a, T5 v
2 L1 s3 R; |" }/* assign the tl som board LED-GPIOs*/
- t8 {& N" X: W1 N3 U# pstatic const short da850_evm_tl_user_led_pins[] = {
! h3 U: Q2 _9 g# \7 w. z4 L /* These pins are definition at <mach/mux.h> file */
: q3 b. Q( q% K2 ^' k; |! c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 C+ R; T1 o( ]# Y! ] -1
2 a3 D: O! u( o/ x};
1 Q ], |$ y+ ?1 x' L$ J; R4 T. P% w8 x- {7 V
static struct gpio_led da850_evm_tl_leds[] = {" J7 e" O4 p8 A# X, j7 K% N
{3 @5 T0 q( x( r) G* h- J5 }. @
.active_low = 0, S7 x- E* w1 Q/ _" y0 u% M
.gpio = DA850_USER_LED0,
: [) x( Z: r B) q- c .name = "user_led0",! g6 C$ V: M: [' O8 c4 t
.default_trigger = "default-on",
/ u0 a b& r# ?$ e) A },
; ]$ h5 P) J. X: c. t Q% _ {
& M8 H. b/ @4 I! w3 r .active_low = 0,
2 _$ ?0 T% T# e) k" z2 ]) ]% |0 [ .gpio = DA850_USER_LED1,
! t- q: J# m3 N2 [ .name = "user_led1",, s5 ~% [5 F' y, r( A& d
.default_trigger = "default-on",
8 i/ l2 { m; u7 a },; b( @, r0 ^9 q% B0 F8 ~+ [9 K. G
{# I' }+ x, g6 m+ p' U5 f9 v3 ]( b
.active_low = 0," B) w7 T7 N, [
.gpio = DA850_USER_LED2,
5 q. D; c/ {& {0 Q; `$ N& ` .name = "user_led2",
) ] b8 s& J. z .default_trigger = "default-on",
. o# O0 T- R* B9 ]: A- i& \ },
% M3 r, `0 r7 O8 y7 n( M: h6 T/ g {
$ |! r1 j- N6 q4 o% j .active_low = 0,
" }4 q) }! W# E0 s9 { .gpio = DA850_USER_LED3,* o% ]# W& v# \# E# U& I
.name = "user_led3",! ^+ f2 k+ }$ G9 }# A9 E6 U% i& \
.default_trigger = "default-on",
" ]" [; ?4 Y3 q0 V' P( `# x' N },; t- M3 o" G% Q, m6 ?
};: {$ L9 ?' g6 R- t% L+ ]- J
' U7 }+ r' E3 x" Z9 J, _# Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 ^0 U/ W, A& k
.leds = da850_evm_tl_leds,
/ G) ]1 U/ u7 D6 f: M! L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( \( D2 p, [) ^- `1 c
};" ]* u( G' q, t$ I" d+ X5 T; |, c
; |5 f" A2 d; n" K, Rstatic void led_dev_release(struct device *dev)& N' j( |6 J8 Y% k- C
{
/ L1 P2 p, K- j8 {};
8 @& i' Y+ Q- g# r: n' |6 D& }; m& J7 T( t% O- L( L. u% L; I
static struct platform_device da850_evm_tl_leds_device = {/ L* u2 P S" x( P& @
.name = "leds-gpio",
- J' \8 ]- c2 S; x" [, g .id = 1,
+ A+ P6 E2 X, i6 T, e, ~ .dev = {; }) T O/ J5 F$ O% \) `( u7 d( D4 F" |
.platform_data = &da850_evm_tl_leds_pdata,/ ~# S2 o t$ B" |, D: n6 k! T* q
.release = led_dev_release,
0 O) w& j: b" `& V }3 O3 J+ h5 A! j2 Q) U! U9 h9 ~( _% @
};
0 D* }/ F9 H) U# `
5 v# y' d8 K' C" E' H) Vstatic int __init led_platform_init(void)
9 o' ^4 L0 M; }8 W( \8 c8 J{
; O7 b% `6 Y* |- a u! Z$ ^5 f int ret;* F P3 X# _+ K! p
#if 0
4 {' T8 G7 u+ U6 X$ W1 A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 U: i6 p* M2 w0 H7 N- c' f if (ret)( z- c9 J5 y4 Q3 q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% t0 H, E( d0 k! ]5 j$ [0 _2 n "%d\n", ret);3 n/ H& N# X" Q) n
#endif! l6 g, e( w5 G/ V
ret = platform_device_register(&da850_evm_tl_leds_device);4 L$ Y$ f1 [+ Q! I6 Y6 I' ]6 S
if (ret)
- q* k5 A/ o; s+ L) M# T2 W4 ?8 [ pr_warning("Could not register som GPIO expander LEDS");
# q3 h1 _: b' L2 L9 V9 t else
8 Q3 F1 _7 m+ q& V* G1 n2 W printk(KERN_INFO "LED register sucessful!\n");2 D1 ?: I7 v: O- H0 {; \" ^0 @' c
# N' `% p* X4 j) i# Q2 h5 p return ret;
5 g9 ?+ G! P% k" c}5 F: ^9 P/ C: ~8 b: i
3 w% K1 h' U w5 Lstatic void __exit led_platform_exit(void)- F1 L; {9 V' @' Z0 m
{
' }* ^) a& X! @! }) w/ u; f platform_device_unregister(&da850_evm_tl_leds_device);' d6 S+ [. t; O) e; t6 D+ w; I6 T
. i* X' E Y2 X- W+ \- K4 u2 S
printk(KERN_INFO "LED unregister!\n");, I2 i6 n3 j8 P7 a
}1 R$ J2 I7 v* h$ Q* Q" k; S
9 |) a. G2 H1 A) Z
module_init(led_platform_init);
2 U% X. ^3 d: q1 Z9 b( J$ w9 r1 Gmodule_exit(led_platform_exit);
0 m) H1 |8 U) G. f3 z( x' o' Y
7 A6 ~5 }' U" p( |MODULE_DESCRIPTION("Led platform driver");$ l; v/ a8 C+ V4 ^4 }! E/ j: x2 b; ]
MODULE_AUTHOR("Tronlong"); Q& @3 v. D6 o# [5 e$ ^7 ~" ^ S
MODULE_LICENSE("GPL");
7 ]; t& P2 ^0 b. x
9 T6 c" @2 ?/ E1 l# g |
|