|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" O: T. ]0 f8 z( Z# ~- a3 a4 y7 b
#include <linux/init.h>
( i4 @3 a/ v4 w1 ^& b2 w#include <linux/module.h>; w. e- J! z5 Z" [3 L$ `' m
#include <linux/kernel.h>+ H; L- ]; P. m( w6 a S: S
#include <linux/types.h>
6 `* b* |3 h0 N2 V" {7 A#include <linux/gpio.h>
: t* R. r8 R0 r+ E1 y L/ D6 q+ ]0 k! K5 O#include <linux/leds.h>
8 O1 |/ {8 d- Z8 e9 g7 o#include <linux/platform_device.h>
+ i" h/ C! c6 s7 M; x( h7 z
* s. Q1 l+ A4 |; V, ?#include <asm/mach-types.h>
' Q# u. ?8 m' D7 p% M4 L#include <asm/mach/arch.h>
* B, ?2 |; H$ L2 E8 x. y8 N#include <mach/da8xx.h>
4 p4 z# s# x4 B; Z c' e#include <mach/mux.h>
, g# ^ y& U3 U0 [$ Z& Q8 O' L
9 p O, d8 q& v6 z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 U8 w8 s" c Z% o4 y3 K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- E9 I: J; u1 y. R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) j* F$ W, f% w. X6 J) L4 _& f5 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% J+ F' Y/ [- T7 o' k- R' n' I$ r/ s
/* assign the tl som board LED-GPIOs*/
. `( F2 _- \/ istatic const short da850_evm_tl_user_led_pins[] = {: e& q/ n4 Y1 k2 r
/* These pins are definition at <mach/mux.h> file */
- z+ G( x1 S0 G! X1 H; ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, ~. c% K& ^: B( Q' O, A+ h T3 A -1
9 Q h4 j- Q& e5 z};
1 \8 h. w1 H7 x" D4 k3 c
- n& Y) b9 b$ t& }( A& u& Zstatic struct gpio_led da850_evm_tl_leds[] = {$ L$ x' _5 T; [5 Y
{
$ d6 O D3 c8 v3 J6 E; ~/ A! L, J .active_low = 0,, p0 O2 V6 S! \. i
.gpio = DA850_USER_LED0,3 t& }- A/ w+ c" o
.name = "user_led0",
, K$ K+ M2 l9 R- w .default_trigger = "default-on",, f- d" U' C4 v; G
},
$ A9 m7 z1 v4 X0 h6 g {
. R+ {! }1 _9 d6 q; ] .active_low = 0,' C7 E7 _+ E. g
.gpio = DA850_USER_LED1,7 R2 M2 g' N" d2 r8 a" u
.name = "user_led1",# Q5 p& W- A5 N. C6 M
.default_trigger = "default-on",
/ G R' q8 v! { },' }: _& ?" f7 N6 I. B
{4 }- j- v, d7 |9 H4 _- J
.active_low = 0,
# H7 N. P( |" W8 m: L# v9 L .gpio = DA850_USER_LED2,
0 d% [. Y$ z# D% k .name = "user_led2",# ^4 J& J2 X6 K) _
.default_trigger = "default-on",8 {7 c" k. y6 g- O
},' X: Z# `7 z' Q7 K
{
1 Q. l0 n h/ ] .active_low = 0,. I5 R& ]: n7 V& i# u
.gpio = DA850_USER_LED3,
* o' B5 d. t2 L1 U& i5 O: { .name = "user_led3",& ]4 O7 ?) k( L, M' }, R w. A
.default_trigger = "default-on",5 ~) m2 |2 C7 i: \) k; f+ h
},' w9 q; z k0 m5 D2 |: r; U
};$ @$ G) {7 R: N- Y7 n3 v" [
% N q) @+ `4 @% A8 d9 R+ u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ v0 L+ s$ z, V6 B# _6 J
.leds = da850_evm_tl_leds,0 k' a# t, _: ?- {. ^ _0 R' i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 g4 i. l5 H0 }5 {
};# u5 {8 I( m4 u7 G
$ g' E/ |5 {0 _4 `8 g% b
static void led_dev_release(struct device *dev)
7 m; @2 [, J& G1 p c! p{
( W7 @4 |4 k7 g) U ^* z$ ]};
: K/ O1 G+ Y$ ?8 b; @3 }; d* M p' U2 W8 o+ h3 G
static struct platform_device da850_evm_tl_leds_device = {
0 ?' w' {* Z8 q: a3 ^ .name = "leds-gpio",6 P) V5 G2 B6 h. R) a
.id = 1,, |' Q2 e8 z5 W( a4 r+ F
.dev = {
. ?1 `1 m) j O8 ? I `$ W2 V+ q .platform_data = &da850_evm_tl_leds_pdata,
6 P8 c/ Z9 x. c* O8 M" s .release = led_dev_release,. r4 t. n2 f! k6 t) R
}
^8 H) \: k4 s9 T};& [0 s8 A( H5 B, Z0 C7 N" [7 Q- _+ t
. l# C1 {. c D/ G$ }6 ystatic int __init led_platform_init(void)
' M. ^& @% e8 r+ u( `{
7 K* L/ Z: K7 J$ q# ^ int ret;
& y) B. l. W' |" |; U2 c#if 08 i7 E* ^' C7 q/ _" w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ F z2 {0 F! a& Y$ Z: h: \8 ?3 Y( u
if (ret)5 Y2 M0 v. D- o1 M0 V( x, b1 I9 q; W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" l- V& P* Z2 a "%d\n", ret);
5 _+ h7 `+ E* c( J#endif
' A) z. X. P* f* Q ret = platform_device_register(&da850_evm_tl_leds_device);
! y- M; u& v0 [- O. m- V% q8 f if (ret)
2 V! w; K0 l' \& D# X pr_warning("Could not register som GPIO expander LEDS");2 m2 B- x. Y0 e6 j
else& `$ x. A+ }/ k8 f/ A- ?. X
printk(KERN_INFO "LED register sucessful!\n");* J; x* q4 | G
5 A. c1 v% W0 F% K% w" L5 l3 u$ B return ret;
% \1 w/ c( x$ c" g9 c( X} A$ t% b S/ }* z) W9 y Y
\) _9 c1 k3 x6 N# Y" N/ O7 ^
static void __exit led_platform_exit(void)# Q1 L" z3 w& ` I. D
{
5 y. F0 Q5 I' ^7 c. n4 U. P. K* n# ~/ z platform_device_unregister(&da850_evm_tl_leds_device);
) L2 w; d" v1 h. S7 ?
; @* _/ n) N$ t$ o# P$ {. b printk(KERN_INFO "LED unregister!\n");
" O' d, a$ T2 q4 n4 V0 x}
2 Y) Y6 z, |" y& n3 B9 y/ t
/ ], ]/ l) N0 ~9 E+ nmodule_init(led_platform_init);) D8 _" `" y) |) p% [, {1 w
module_exit(led_platform_exit); l4 G3 D" U+ S: o6 @' }. V
, P2 j4 P7 ~4 Y/ \1 a+ g$ T; eMODULE_DESCRIPTION("Led platform driver");
, d, s0 k* D+ G# k. k: QMODULE_AUTHOR("Tronlong");' M2 |! l7 Q @& G
MODULE_LICENSE("GPL");
9 o8 G6 I k/ a. Q( f8 H
8 T; Z* L1 u: _" D |
|