|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' H& S4 j+ |4 S! S& b2 P! u
#include <linux/init.h>6 @; A6 e' n$ V5 S( f+ m
#include <linux/module.h>
1 M1 T# E( s ]: l \1 ^0 U7 s#include <linux/kernel.h>( i4 G# A2 Q9 v* ^5 U, Q4 A5 N
#include <linux/types.h>
: y* O$ |1 k: D+ t8 \' m#include <linux/gpio.h>! W' ]7 r2 B2 Y: e1 q5 o
#include <linux/leds.h>% ^. ?& t2 N0 I% x- a+ x1 f8 M
#include <linux/platform_device.h>% o- d/ R2 u; R6 D: q
W8 y4 ^; u% c" p' x5 e% U" M; M
#include <asm/mach-types.h>
# `4 n9 a7 F0 A- @; @" i: V1 a6 S/ I#include <asm/mach/arch.h>
2 R0 d" c* ?% y7 b z4 S) H+ {8 c z#include <mach/da8xx.h>
0 O9 i. d2 O5 ^) ^1 H/ U+ C#include <mach/mux.h>" ?6 G7 z1 R5 ~: W q
- R4 G' w6 L( h9 @ _ Y. ]& C) `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 G+ w U0 {6 o; }" x4 z% W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): g! ^7 O( {% O* y1 i* x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 _6 P, r# d u; d) [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 F8 A1 g* T. E$ B
. x9 C! X3 n- U* ^9 h/* assign the tl som board LED-GPIOs*/
, \$ y2 h! Q* }static const short da850_evm_tl_user_led_pins[] = {$ T( b2 c& S+ Y( p# G A) J; t
/* These pins are definition at <mach/mux.h> file */
9 A/ }9 A. T3 O- f0 }6 C T& j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* ^4 w: `& K$ s1 z
-1$ ? Y/ n3 ^! R. _- A! J7 y
};
3 O7 p( q3 k% b6 G7 `& R# e8 K
) `5 }. Y8 l! t( g: h3 Q; estatic struct gpio_led da850_evm_tl_leds[] = {
3 c5 H8 m& S1 @- H7 s {- v0 A; Z/ Q+ M# @
.active_low = 0,
0 R7 e+ w3 W4 v .gpio = DA850_USER_LED0,
. M' u9 I9 K! Z& d .name = "user_led0",
& Q/ k4 p- q! L# k/ X6 \, D .default_trigger = "default-on",/ o) d9 A P) s$ D
},2 V: K/ w! R- o6 y/ i# V& p, v( ]/ y
{- i( C0 f/ a& z" O4 y+ H4 L) R. S
.active_low = 0,
. y, }+ L! S7 i# ]& Z% X1 Y .gpio = DA850_USER_LED1,7 ^7 s. A0 P2 t
.name = "user_led1",3 G! S0 J2 ]; P5 D* V* t
.default_trigger = "default-on",
" S3 [# [( F/ E+ _, q3 T },
* p& K" R* d7 p d {
- `; ]8 _8 T2 E5 b! b, R .active_low = 0, A% K \; W- \8 k
.gpio = DA850_USER_LED2,
& T2 t0 }- s5 U1 [* L .name = "user_led2"," P0 @) c. s1 t4 K
.default_trigger = "default-on",
$ g3 c0 U- q( Y' P+ C" s: b },
, o2 P" \' L8 E7 U- E* E" e {
/ ~2 C8 A% U( A" \" Q .active_low = 0,
: N' y; {% L- Q O" X- y .gpio = DA850_USER_LED3,( h [6 }5 P: M' u0 D1 X
.name = "user_led3",
1 A$ t' r4 ?8 c# P( t .default_trigger = "default-on",1 F9 H `, x3 h' b9 ~2 {
},
% R5 o# @ ~' c) y, {7 @};
1 d/ G8 d3 ~: G2 K) |: ^
8 U- }2 v4 B1 f3 }+ x2 Q$ f" bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# b$ F7 L$ r' C .leds = da850_evm_tl_leds,
9 c* l% }' V: A% @7 ?! i9 u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- {% j$ J9 J! Z4 ~- R};7 Y1 N5 ^: e' s# {+ R+ U
1 e' n" c( i- j9 i" M1 d; {
static void led_dev_release(struct device *dev)
1 A) X: U0 K$ }{
; k$ s5 T7 P, S# ?$ Z( B};
& A" e; s8 P `( q0 G
- S% C( a3 u+ Sstatic struct platform_device da850_evm_tl_leds_device = {
& C/ u1 L: {* ~* A/ X .name = "leds-gpio",
4 O8 S( e2 G) }- O0 K9 j9 w; Z .id = 1,
8 H& L7 N1 d8 n; I+ Y. a .dev = {1 ^7 k) Y4 i: O; W8 e( i
.platform_data = &da850_evm_tl_leds_pdata,9 `* [. C/ c6 q- a4 x2 s9 x
.release = led_dev_release,
' C9 h1 c$ j9 ^2 c2 f }
! ~( Z% r' c. a& V G! @};
7 b+ v2 o( q2 o1 N/ E( D. o. L9 F
* R7 {- i) I8 cstatic int __init led_platform_init(void)
9 ~: E; z# b' a; A; a7 {4 ^6 p{: c" [0 |8 E) n9 r/ E7 T
int ret;: D( s6 I# K$ O& S' |- _4 a( g
#if 0
7 {6 [+ T( {, J. K& Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- } ~) _ D* g% I7 P- X
if (ret)
7 a. y' i- i) N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 C; V- a; f6 ~
"%d\n", ret);/ Y$ f8 C2 U- f1 y. Z% k! l! f/ ?
#endif! w+ H4 N5 O/ ~
ret = platform_device_register(&da850_evm_tl_leds_device);
8 W9 s7 `& `7 c8 a if (ret)
3 ?% _2 }/ {+ v& M: N4 F' z pr_warning("Could not register som GPIO expander LEDS");
, c/ M% k1 b( J) K4 W/ b! |, S& f else
; D1 g% V: j7 X4 N2 r2 M3 d printk(KERN_INFO "LED register sucessful!\n");
0 F2 f" P$ u# e8 Z o
; ]% m4 R' d5 ~$ V return ret;% `# t, P% f/ \5 P+ `
}
/ F+ M `" Q% m% d N6 v
8 i, ]$ o0 c" u4 U" g Fstatic void __exit led_platform_exit(void)
D! u2 O3 m9 u{( Z8 ^3 r$ _7 B/ V" d
platform_device_unregister(&da850_evm_tl_leds_device);2 o; ^; E6 Y) y: c) j$ [' o- ^
; l5 p+ g0 |+ d& g2 R printk(KERN_INFO "LED unregister!\n");" K3 m, P& ]" I8 J' F6 [
}
! ~, j" O# z2 a- }# B: w0 b. u9 @0 E2 `2 {
module_init(led_platform_init);
2 d z1 C3 a8 w4 kmodule_exit(led_platform_exit);
5 Z' K: k" j& S' ^+ |, q5 Z, `: V$ a& v8 ^
MODULE_DESCRIPTION("Led platform driver");8 Z7 B J/ M0 Y% _; ^9 L
MODULE_AUTHOR("Tronlong");
* q: w# l: ?6 b& `- |MODULE_LICENSE("GPL");
2 b% g- b& V* I: r# M; C
- z* m4 l/ o. S' T8 \! S |
|