|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* z; u' Q9 ?. r c#include <linux/init.h>2 S7 y& U: N5 [0 L1 a
#include <linux/module.h>
. P I% w5 g9 a+ X: B9 q#include <linux/kernel.h>0 Y9 o) g9 }9 x' V9 R
#include <linux/types.h> u7 n3 z( w+ M: b9 @
#include <linux/gpio.h>
! ^2 T8 E5 K8 F4 o#include <linux/leds.h>$ z- d2 I' q( y# h# c0 O' w
#include <linux/platform_device.h>
1 ~( z+ v- o" c1 \, v* @* I% f4 n+ S& r! ]- l; K; x3 F
#include <asm/mach-types.h>. A( T6 C. W9 V& ]0 a4 z
#include <asm/mach/arch.h>4 f3 g2 g9 {' e8 L8 `
#include <mach/da8xx.h>
& B9 c" B B! t2 s$ A6 [#include <mach/mux.h>) k# R- O- Q+ O- @
4 c; z% j8 i' |8 `5 C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 g3 S* F! S$ c* V, y4 {% P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 Z! E3 r, d) }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 d" m4 P& R7 p9 J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 e7 v# T2 V3 f% v+ D4 a) W( N* C/ I( ~
/* assign the tl som board LED-GPIOs*/
# x# s0 I) G8 ?$ ]$ A" V6 z" Wstatic const short da850_evm_tl_user_led_pins[] = {; G9 ?. n# K' i- A" r a8 h3 u
/* These pins are definition at <mach/mux.h> file */2 o$ D: Z* J% g! j/ f, |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ b, w9 Z" K+ ^& Y0 p
-1' i2 p S# c! q& h% L
};% L! g8 k# d" I2 V) v2 A: h
' }7 y1 T# d9 d2 w5 T0 K
static struct gpio_led da850_evm_tl_leds[] = {
) D: i( L2 w0 ~% f( ~1 p {' E f: L1 J$ c& E' l/ ~ z
.active_low = 0,
5 p8 `$ v/ @$ D$ @0 L8 b, o .gpio = DA850_USER_LED0,) c1 T" x4 j0 [$ @& h! O
.name = "user_led0",
. c6 `5 h/ A$ P; }& K. Q) y .default_trigger = "default-on",
/ Y1 L$ u! ~: d/ B6 K; y8 m5 l },# C) p6 R4 a) t; q' Z
{
$ x. u) p$ q" P7 ` .active_low = 0,
5 M% \+ O% r5 _; s .gpio = DA850_USER_LED1,, e# y% V- i2 M) |$ Z
.name = "user_led1",! E& L, \' ]& E. `. i
.default_trigger = "default-on",7 _& J4 \- Z4 _4 @# w
},2 b6 D6 U$ q8 m! |% l1 _, \
{
* _) P/ b" x+ _% f# x .active_low = 0,
' {. I b: y: P; G1 Z+ L .gpio = DA850_USER_LED2,
' w" q% \! C3 O; ^5 _9 X. t8 U .name = "user_led2",
. R7 w# `: O4 e. D3 c .default_trigger = "default-on",8 x) |. z Q+ l7 j; p
},1 V! Q( R: B; |/ S' J5 f+ F
{: E8 Y( r2 ^4 l. `% q, {8 Z/ A
.active_low = 0,9 h ~; H) N9 q1 m
.gpio = DA850_USER_LED3,6 Y( |' @$ C. T6 u0 w
.name = "user_led3",8 M, Z: `, h: {) _% Z( x0 N6 _
.default_trigger = "default-on",
! c# M6 k3 y6 ]5 W U },) J$ O6 c6 c+ e
};( C) L) J% h7 }
: k1 Z& L# s) c* g2 G) j' |3 X* C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 s5 A$ q/ Z& h7 D
.leds = da850_evm_tl_leds,' `$ P! C- [, y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ q- Z; I8 P D1 O+ ^* G& Y
};5 o3 P- T% g! Z: g
. H# o1 L6 l# v3 i4 _' k) p. e; ~static void led_dev_release(struct device *dev)
2 e( p; y `: u, i{3 e; }9 ]( v ]
};
1 F3 R8 y+ q9 t/ A' d& J5 S
- V7 V# X4 p8 \: e; m# Zstatic struct platform_device da850_evm_tl_leds_device = {6 \1 q0 U: @. D- K9 o
.name = "leds-gpio",9 ]! H2 M* R& w3 l" Z$ i
.id = 1,
8 m- J, R: }& H; b1 R .dev = {
. p/ t! f$ I) Q3 f( B4 { .platform_data = &da850_evm_tl_leds_pdata,, y* ~+ P& f- J. r
.release = led_dev_release,
0 `7 W: X1 i( f% t$ q9 G8 s: E% J4 G }
" S' F+ E; o: n! [) }};1 A6 ?4 }' A- m! h% |
" x$ n: }2 y9 C0 G
static int __init led_platform_init(void)9 g* S' H# [! M |( A6 r/ `
{) ?9 s, _( O; E6 Y$ O, N
int ret;
4 e6 y, c6 E+ ~" z8 M, J8 m% K7 u$ ?' d#if 06 y5 \8 g5 u2 n4 B: F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) b5 r' w' }5 x% Y! `7 ^
if (ret)/ k1 a. P2 z$ A7 |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 J& V; B3 F2 {; S+ H
"%d\n", ret);4 e; Y. O$ h3 T' }. ~
#endif
& L0 O' B- K$ ^, L6 ] ret = platform_device_register(&da850_evm_tl_leds_device);7 d! }8 `0 K- Y) o# {+ U I
if (ret)
; n0 ]$ m: C; S$ @ pr_warning("Could not register som GPIO expander LEDS");( L* [8 g6 f# M" ?! k7 k
else5 g( g( F: I3 y
printk(KERN_INFO "LED register sucessful!\n");
( D9 w& l2 Q9 J$ |
3 P. D* A0 O& d8 K5 F! x+ ^ return ret;
" t* }8 F3 s) d( O1 F" u6 ?% O}6 X1 K( ~+ ^6 Z, T- o! [; ]
1 j7 Q+ q- S! `3 ?8 @. H0 i9 A
static void __exit led_platform_exit(void)
- R* q: F. g @4 C{
! w7 y3 f5 t O8 H1 A8 q platform_device_unregister(&da850_evm_tl_leds_device);6 {& N, U5 s, V2 F( v6 u8 h" M& \
. {8 P) u% _, O, H) t printk(KERN_INFO "LED unregister!\n");
& @! L9 l+ d0 i) A! K# P}
( g/ l. A. S( L% M/ X9 }; U5 C& g) H0 d# W9 `
module_init(led_platform_init);
4 x0 I' k8 B7 X" o5 m4 smodule_exit(led_platform_exit);
* k9 T9 j# Y: c% Y8 m8 @( D. i r( P# | R) n. @
MODULE_DESCRIPTION("Led platform driver");
8 e/ r" s# {) y8 Q1 FMODULE_AUTHOR("Tronlong");0 }$ n" f$ B, \' h. o* g
MODULE_LICENSE("GPL");2 |5 z5 m% O6 A( X8 y
6 s' d) U! U9 S& E& c$ M( m9 {" z3 |! c |
|