|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" k& h0 T5 v* U& I
#include <linux/init.h>3 i0 u9 L' Y6 X3 M5 X. Q+ O2 }
#include <linux/module.h>) U( O+ @# p/ g$ k9 q
#include <linux/kernel.h>
. W1 V p9 {$ b- ?% x X4 F, I#include <linux/types.h>
1 h/ U0 m) l- U: x3 o! T#include <linux/gpio.h>3 J2 j& n+ d/ z% v" s7 X+ u0 @
#include <linux/leds.h>1 ~& Q, z( l& m! b I
#include <linux/platform_device.h>
T% z/ B# ^$ o& i# Y/ L, J( O' d1 G9 _& m: D( V3 r* v7 D& D
#include <asm/mach-types.h>3 |! V( F( u- Z- i2 R
#include <asm/mach/arch.h>
& C7 V8 f! B+ r' B' O7 ?+ A#include <mach/da8xx.h>
) @$ b- M" s& O5 ~#include <mach/mux.h>+ F, ?5 T' @9 s2 {( \1 S
. @) P# ~$ m5 X$ I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! {- u7 Q( `' s5 ?8 v! u& G H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 J8 d' e+ V3 d/ J( M8 o2 I' _3 G# p/ N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
V/ B& P# D. ~9 F$ k: H% c6 ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 @/ I- _" k! o4 _% _1 _- c. t
% A5 x- D3 b; V8 Z& R
/* assign the tl som board LED-GPIOs*/
2 G- C5 E1 ~$ C, M. lstatic const short da850_evm_tl_user_led_pins[] = {
$ }. J; a' W9 @3 _6 g! C /* These pins are definition at <mach/mux.h> file */- q+ d0 l1 K- _! o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Q3 r1 T. L( _, H5 C4 N -1
' w# ]$ P0 B7 _ [) b' ?};) t) y; f6 d. I Q, v$ c: ]$ [6 p
, g* y& s. `; L! j: \7 a6 x2 cstatic struct gpio_led da850_evm_tl_leds[] = {
9 k p& V0 t# a2 O4 H- C {1 o+ i' ]9 D) u, y, C* o5 |9 l9 d
.active_low = 0,- T% c8 A% r% |; b0 N$ z
.gpio = DA850_USER_LED0,
8 N( q% h' \: ^' w$ M" C$ a0 v .name = "user_led0",6 l1 e6 z8 U- }; i4 Y2 A
.default_trigger = "default-on",, b5 n, _, X0 j/ j$ K
},4 U* q8 ]) U7 w( N
{) w) h* F/ n6 A
.active_low = 0,
' Z- w& `+ E9 F, c. _ .gpio = DA850_USER_LED1,# W, g# @( w6 y/ J4 v d# l
.name = "user_led1",# j" T5 b# t! m1 z; c
.default_trigger = "default-on",
4 I) t7 I) } ^4 c, t) B },
8 e, X; D4 c* L$ z5 [5 [5 a3 y {6 O" e1 X! j: E7 r" w% m9 @/ t, c% C
.active_low = 0,
/ m* t0 F! T. K% g .gpio = DA850_USER_LED2,
% Z0 S- D# E. E, g8 _+ q2 l .name = "user_led2",1 O. m1 \ ~' v
.default_trigger = "default-on",
) E1 |7 P* w7 z( N4 o3 ^ }," w2 k4 D8 Z& m7 y& p- V
{/ u1 C7 D5 P$ D4 ^- \1 @. f3 E" b
.active_low = 0,1 l8 Q! w( t$ c2 L+ d6 _7 M
.gpio = DA850_USER_LED3,
" e2 A" z } B$ {# F .name = "user_led3",
5 x& |8 n; J. J4 f+ k6 o .default_trigger = "default-on",/ Z3 X/ z$ t4 w* s7 i
},3 G X N- y2 Q3 O) F0 L1 D4 h
};
# o; }5 l! E& v0 {+ [
. W' k7 {8 n9 p( a2 Z5 ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ |- E( s: |* f% Z4 F! ?. [
.leds = da850_evm_tl_leds,' d J9 }. A* M- ?: c2 o6 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" z' U* @9 w" ^; k4 B; U/ H; J};( p% x( k$ h+ Q# u% i
* z7 m. j( X. b0 ?2 K w) |
static void led_dev_release(struct device *dev)
8 q4 j$ R% a$ u{' Y/ d( L9 g" E5 y) I f3 a! o3 {
};
) _; K! c H: W/ |, m9 v( b2 p/ P& r( Q- L; |; D# k. U; x
static struct platform_device da850_evm_tl_leds_device = {
) z5 g# @* t; S* [" h2 O( S4 S; \ .name = "leds-gpio",
6 A) W. q. C0 F1 k+ W0 M) a .id = 1,
; f" P) l! e& q0 S* n9 G: B .dev = {( d* ?+ ?! T' y* U$ T0 Z
.platform_data = &da850_evm_tl_leds_pdata,3 h9 x/ h. O6 E8 g: N
.release = led_dev_release,6 U! o9 V- H4 J% z$ }" }" C5 U* T
}
+ s( Z# L! d& I0 S};# z( c( f$ B% h( K
: }1 p$ y+ T3 g2 Q3 mstatic int __init led_platform_init(void): C& a% |5 `* s% `4 M0 ^
{
% J) E0 R+ h7 k: P4 A R- w int ret;! g; M2 w) V# } k
#if 0' a, `8 \9 C$ x$ ^+ z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ {; E. h1 s$ _ if (ret)5 `0 |5 S$ V6 e/ t$ Z! ^; G6 l- R
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' l8 N* v* X* Q4 I& O2 e: R7 F
"%d\n", ret);
3 V4 W' b' a+ r/ K3 z- b) G#endif: j' t0 l1 V, C
ret = platform_device_register(&da850_evm_tl_leds_device);5 u* B. H) K& S9 U
if (ret)* f# }8 I2 E' h6 N& V
pr_warning("Could not register som GPIO expander LEDS");' j8 u/ `7 _- p+ |9 n2 K* {
else+ K2 ^ x. d/ h& L9 M3 v7 [
printk(KERN_INFO "LED register sucessful!\n");
$ X R( k' ^& f- ?3 }
6 r$ Q5 h# g; q( u, n/ Z" z' n return ret;
6 Z! ?2 |! g2 W5 h1 X9 d$ `}
8 G" G! Y" ^2 G8 S; q- `9 C
% d5 N" N7 {& ]+ i- r: r4 `static void __exit led_platform_exit(void)% L$ e' h- K- j) k( H' w" W
{- q- F( b W% k4 i
platform_device_unregister(&da850_evm_tl_leds_device);
8 h% ], U0 `8 L& h. T- G, `
: l/ v. e- w2 u1 U A; U, w printk(KERN_INFO "LED unregister!\n");
! m- [5 b( G- ?3 k}
0 \' r0 Q, B! Y" ?+ Q% m! r. ], \& p/ s
module_init(led_platform_init);* F4 J# N4 e* @1 m. r# B9 C
module_exit(led_platform_exit);) _4 X& G$ y0 Q$ s% g0 R
1 W7 i3 Z4 K: \& fMODULE_DESCRIPTION("Led platform driver");+ _. L( h% b8 l7 O% n/ C
MODULE_AUTHOR("Tronlong");& Y1 Y3 {5 f; d
MODULE_LICENSE("GPL");
5 M) }' F) ]6 X( j: _" Q4 `# N* D1 U* S. o
|
|