|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 e/ E/ @7 N( Y: O, s; I1 Y
#include <linux/init.h>
. |! l Y( x9 x. h- }#include <linux/module.h>' S' \# F F; b Y i9 T* i( v
#include <linux/kernel.h>
, C8 k1 Y" m1 G+ D#include <linux/types.h>
7 B1 F- e4 S/ e/ d) q#include <linux/gpio.h>
; ?0 y' i4 v# P) u% Y4 X7 d#include <linux/leds.h>4 K) l2 M; \' @( T
#include <linux/platform_device.h>
2 l/ U% j" d- |, S4 U4 ]! C) B/ Q+ I9 b$ X6 {; q W) ~7 x4 N' C% H
#include <asm/mach-types.h>
5 w$ `" b' s( i+ X* M8 G" Y2 u#include <asm/mach/arch.h>4 |8 l3 [1 A7 z8 z
#include <mach/da8xx.h>
4 a$ g; w: P4 m8 K#include <mach/mux.h>
A* p3 G' @/ U) \: @7 r2 b. H* L ?+ K1 T8 d$ _- U3 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); j$ _0 C+ }8 i2 F1 Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 N0 L6 i4 g- J9 U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): m2 Y8 q" x4 ?( F# D& c# a3 l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& n. L# v: _3 S5 e( m9 X
/ S8 q7 k) J6 \8 @7 |' E+ F' i/* assign the tl som board LED-GPIOs*/+ H1 I9 x4 c7 t, n) R! |: A
static const short da850_evm_tl_user_led_pins[] = {% S4 ]. C3 f$ g% K5 Y2 T" h
/* These pins are definition at <mach/mux.h> file *// K& `& R! `6 s ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 [, W: f' k& X# H -1
- c% u R; P' C4 [- R};
# d9 ~" Z8 R: H. {2 z
6 i! n7 s! H1 H- w) Y# X' fstatic struct gpio_led da850_evm_tl_leds[] = {
6 ~% x/ g/ P9 u) J+ |( S {
( u0 P- D4 q! K .active_low = 0,
! \/ H# m& u, q0 t/ s .gpio = DA850_USER_LED0,
/ U) H) ~& X8 [& ]" S .name = "user_led0",
( n" `0 _4 E6 N .default_trigger = "default-on",
& }6 z, H- ^8 p I; @+ x' E },9 c' x- _4 x0 d( k; {
{' f L$ `; c) }% Z4 b9 P
.active_low = 0,
, Q5 ~/ o- ]) A9 {& p f3 R+ S .gpio = DA850_USER_LED1,6 P( \- B. o/ r; Y9 n; k1 y$ `
.name = "user_led1",
9 Y8 P7 Z. o# `# q/ W .default_trigger = "default-on",
0 _6 k+ X B! H7 I, N5 s v1 g, ` },
2 P, r& p" ~4 c4 l {' O C3 K8 M" F" P9 D, d% K
.active_low = 0,
+ R w% _1 O3 ? .gpio = DA850_USER_LED2, }3 v( H6 s# ~: e
.name = "user_led2",
. U1 p$ _( E& b' ?" ` .default_trigger = "default-on",
6 i+ z; i. [, `: I" w4 T2 I$ H },1 b9 }8 h& c: b) s# Z n
{
7 e% ^6 w7 t% S# [! g: q .active_low = 0,
t* E2 b/ w5 Z6 X. H .gpio = DA850_USER_LED3,
/ ]6 {# Z: K! h$ `. ~ .name = "user_led3",: f; c# Q! P# a3 ]' {5 ^# V: {6 l
.default_trigger = "default-on",; b, |2 m4 k7 r
},
7 s2 W* b/ f- D! @4 W2 `4 S( Q4 h. ]}; I4 P- j( \ @3 ?9 h0 N
8 A' m& n; \1 q! W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 C7 X3 c9 g" ?1 f# `2 V+ m .leds = da850_evm_tl_leds,
5 }/ r, g/ N: r& _ E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 \8 v: q4 ]6 ~6 @# T" h3 E};
6 q* P. u' c* ~) A. a O7 S
) \7 I# s9 z& t6 S- Q) [# R7 {static void led_dev_release(struct device *dev); M# W1 N. b1 K8 a
{
. B$ R" F/ q- g9 c};* p3 D8 P! q/ b% K8 \
2 X& N# x# P- ^! ~
static struct platform_device da850_evm_tl_leds_device = { k0 b: w) a1 J& f( O4 M
.name = "leds-gpio",
/ }, t' [5 M% M .id = 1,
+ L# `$ ^% V3 d( g X' Y/ S1 p3 H .dev = {
A5 a2 i; [7 n/ ?8 P .platform_data = &da850_evm_tl_leds_pdata,: c$ {. C% R+ S
.release = led_dev_release,
* b. d" D1 m6 `3 I( N7 c* ]( c9 \ }
: s( r. J/ S2 _# y9 s};8 e# X0 z7 |) U) |, [
0 a$ o! a& w6 R, v1 Y. F
static int __init led_platform_init(void)
8 Y7 V6 R H& I% y{6 ^7 Z& x" l+ Q) _
int ret;3 ]7 P: L# g2 C$ g
#if 0- f# I' D D* `' G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! {, p/ m" \8 T" | if (ret) x) H* }* m, l# \: B- W% [0 K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( U* H* \/ q$ l2 F$ l8 T; R" C
"%d\n", ret);$ f" y/ Q% g; u
#endif
" H' A6 \, f/ W; p. H4 l ret = platform_device_register(&da850_evm_tl_leds_device);0 ~1 A9 O! ]2 A" A: b
if (ret)
. z' f* B& u) M& R pr_warning("Could not register som GPIO expander LEDS");
+ Q+ }. M4 J2 A$ {5 f; a) J4 S else: u& @ m8 s! |! m2 i: L
printk(KERN_INFO "LED register sucessful!\n");! Y- L' C9 r. o. J# b$ A: p
' d K* c+ d# H( c return ret;% d5 N0 {* `" h% D/ d% W
}
% M( c" P3 ^' W. O! v' P. W1 T" V8 M/ \% i4 V# |
static void __exit led_platform_exit(void)
- m- u) H m2 g{
% |; ~' B! h& P8 C platform_device_unregister(&da850_evm_tl_leds_device);8 ^5 O% E2 F& T* }4 v( r, D
6 E. O" j# Z- y' F6 ] printk(KERN_INFO "LED unregister!\n");
5 O' d6 b, i; F}- t& Q& u0 N7 P8 |0 T* d# I
/ c/ E- F$ u8 l) [, _+ o3 bmodule_init(led_platform_init);
) ^4 D7 ~# ^6 f0 Q/ J; |$ R# Imodule_exit(led_platform_exit);
. R5 n* E. e! p0 U4 j _; m$ R
. s/ m2 c- h6 X0 C7 t/ N4 HMODULE_DESCRIPTION("Led platform driver");" } R7 m! g8 z4 a9 T
MODULE_AUTHOR("Tronlong");
) ^9 ^4 ^. m: j, xMODULE_LICENSE("GPL");
5 O6 C Z+ g6 T0 t8 c# j
: |, ~& [- a% M9 O7 W0 _+ o |
|