|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: k2 Z3 j% p! W7 P- i: K#include <linux/init.h>
; w9 ?0 I" h; V! g) p#include <linux/module.h>
m$ T0 u3 @/ N, i, P. ?" H& m#include <linux/kernel.h>
$ y" {* I4 ]/ K+ l* D0 l+ `4 g#include <linux/types.h>5 I/ s7 Q; ^/ f( ]# z
#include <linux/gpio.h>: y% X, E% |) u6 a% i, i4 _
#include <linux/leds.h>. M: r3 ^5 i; v9 Q: a( x* f; ?. U: O
#include <linux/platform_device.h>
2 ]: d, A7 {. Y5 d5 c* e$ a3 d; X5 S6 i
* l" c$ C3 `/ ~7 {7 L( Y5 v+ R* @#include <asm/mach-types.h>: }9 q5 A7 G/ \- B# s1 i% M: ~- y
#include <asm/mach/arch.h>
4 x) @# ?' l% n( R& m, n- c4 w& \#include <mach/da8xx.h>( t; G7 T# o% c' u9 @* l5 p
#include <mach/mux.h>, Q7 s8 n# S5 n, P4 I9 A+ n/ |
/ G# r/ A: p. i+ r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 K) [% m% ~. W) }) v! }. _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): q' S: N' M* y0 j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 b$ a# C. p$ i3 M% i. Y$ S+ E6 N- R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' u/ L3 W5 t8 q3 ~! U+ S
5 f: v. Y( t! c+ t, y a6 l/* assign the tl som board LED-GPIOs*/
( K' [) b: t0 [9 Dstatic const short da850_evm_tl_user_led_pins[] = {
# j& V# @2 r5 z' S( B /* These pins are definition at <mach/mux.h> file */
- W X3 b, E. x, U" w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, i' m! ~! k( Y# q
-1
/ b r+ m. _; H( W* U/ V0 O1 X# u};
: T3 U7 P: x. k# t
4 k+ d: i3 a* W2 nstatic struct gpio_led da850_evm_tl_leds[] = {
& J! o7 [+ r$ c% U8 a% Q {
, J% d3 I: Z. G8 h7 d .active_low = 0, `* a* ~0 m: L* d
.gpio = DA850_USER_LED0,) V; m; V( w4 K% x8 g# l
.name = "user_led0",
+ P7 W: H. A# b$ i+ C% h .default_trigger = "default-on",
0 R1 M% [: `. ^; { },
% z, H: }0 o- x% g {- _1 |; C5 Y. L9 v; _$ C8 A w3 C6 k
.active_low = 0,* T, ]/ I L% w% n. T, q, e+ j
.gpio = DA850_USER_LED1,
2 B% c' e% l: T; Q$ q .name = "user_led1",
+ L( T1 W0 e0 B; l3 L% Y4 S. `7 i .default_trigger = "default-on",
! a. H. Z5 C! G( g( u( E },
9 x$ H" J" x; ~6 e* E; A {1 @6 _! ^, s' U8 `4 U1 X7 }5 V
.active_low = 0,) r: L* E3 q j, Y. l
.gpio = DA850_USER_LED2,
6 U3 A% d; I6 ?- r2 o# q .name = "user_led2",
d ^/ R& { k f2 H& k .default_trigger = "default-on",7 W2 _; s2 T( D0 M
},
1 K/ l! D Q) U ?3 K1 J3 j {
) _% w% o( `9 I8 E* U: c! L3 i9 F .active_low = 0,
6 Y, K) N) Z( t4 J% J( h .gpio = DA850_USER_LED3,- ]% r, ^0 z- j
.name = "user_led3",
; }. d. f3 }; @% b3 `; e0 A .default_trigger = "default-on",
1 ^3 @: T1 d3 l },) P- c% G& n! B# y4 s& z
};
' [4 `, N2 ~7 x- G3 m7 ~. o c4 e9 n% Q+ [' \) c/ L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" Z$ G- L) c6 ?9 w/ |9 G .leds = da850_evm_tl_leds,- t% x* M: D( E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- w# w$ p" ]0 [9 [" K4 q, T7 @5 S};
( |7 u6 `# L3 k# ?3 |9 k
/ o3 i* U1 g/ Lstatic void led_dev_release(struct device *dev)
1 @3 G ]* X9 I{
! C, r6 e% s" E4 \' c4 S};5 O0 i; l& j6 J }
9 M: y3 h$ R) {8 D* a8 Ustatic struct platform_device da850_evm_tl_leds_device = {* L) V, \# D' @8 V# `* E) o0 W
.name = "leds-gpio",# I+ n. P5 ]4 P N
.id = 1,
- B! m, n# R- b5 h .dev = {' Z( d- z/ b [% `+ j
.platform_data = &da850_evm_tl_leds_pdata,
, p0 o! D' d+ ~0 y- d" Y& h .release = led_dev_release,/ O/ V% D7 F8 S
}
" Y8 s1 Z2 W1 q; k5 L};
! K( M1 f' r/ X- B7 K7 z, E) w2 K3 M
' t( P' @$ \" c8 K' m/ lstatic int __init led_platform_init(void)* h& K2 U& m0 T+ M' I
{
( w4 h3 l8 K* f& V0 c. Y int ret;
9 k/ Y, Y& ]$ G4 K* {2 z* V#if 0
9 w |& A( b& B: |& C( X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 B' W- l" `# q2 C if (ret) M2 z2 T" k" e8 u" @9 P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& K3 v0 X* P1 S* ~0 ?" q( M# x "%d\n", ret);
) E' i P6 g: L. A: {( Q; a$ D$ D#endif t1 r# V9 U4 t2 \
ret = platform_device_register(&da850_evm_tl_leds_device);
3 P) D8 |5 a% F- T) H3 e0 k8 _5 w if (ret)" X" L, Q6 v- j! C8 x" P6 o# X
pr_warning("Could not register som GPIO expander LEDS");, I J* Y9 u* ?! }. B5 V
else
" p9 Q1 }4 O+ t7 w printk(KERN_INFO "LED register sucessful!\n");1 d- p* k* |: x1 S
( z! A$ I" ~7 V/ N A return ret;
- U! ~4 h4 l# K}, t# ^! A C' S1 d% W
1 z. F5 ]' e: p& F* q+ {- ?$ C
static void __exit led_platform_exit(void)
, g: p# K& q6 [/ W{
$ u3 Z3 _8 l' P* o$ D platform_device_unregister(&da850_evm_tl_leds_device);" K E: h" s. u1 W. ]# o
& z$ u1 o# n/ B) w0 b6 { printk(KERN_INFO "LED unregister!\n");0 S. N, M* P& n
}
! n3 j# y+ Z5 b' {* O+ A8 `8 v0 ?9 h
module_init(led_platform_init);
" v7 `% }3 ]. G" ?7 d4 ^$ w# nmodule_exit(led_platform_exit);% J3 X& a7 w2 s* C7 P' s }
+ \% y* a$ U1 g- `7 kMODULE_DESCRIPTION("Led platform driver");! p V! ~1 C3 g6 I7 A6 M
MODULE_AUTHOR("Tronlong");+ Z, N: U& B" @3 e3 v8 D' e1 h& N
MODULE_LICENSE("GPL");( S' |/ j+ u1 ]+ Q O* i5 m
% a: b1 e1 ^" t3 z
|
|