|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- b. w" v2 t& h#include <linux/init.h>
! H! m8 w Q1 F" C; ?2 e$ f4 X3 X- s#include <linux/module.h># P& b' j' \' M) `6 E7 h
#include <linux/kernel.h>, }% o* `7 P6 {, j5 t
#include <linux/types.h>8 z# E& C- X+ H: W& F! G8 g( E, G6 T
#include <linux/gpio.h>
* u3 s6 `& f$ z#include <linux/leds.h>( z6 V* ?6 c) p4 w
#include <linux/platform_device.h>* ?: q$ C* _; n" }1 L) l" W
7 |/ E6 X, g1 d6 V7 x#include <asm/mach-types.h>
% n% ^: @ z4 u; m* Y/ g#include <asm/mach/arch.h>; J$ i" g' P' G- @' f2 ]$ n
#include <mach/da8xx.h>
; l' @! `2 l7 x9 u3 j0 e7 D#include <mach/mux.h>
+ J4 N! u. B3 F! w, h- b% `9 Z/ ^6 T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 F( d' w! ^2 q% U% E, j8 a4 z \; U" t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 t0 M0 u2 d9 {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. T* |& | w) H9 v0 P# D+ ~' ^# _1 @8 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( l# E- N9 L5 _% |! h- c
: Q" R b4 F% p/ J
/* assign the tl som board LED-GPIOs*/
4 F: T$ p% }9 Y9 O2 ^# x* X% Zstatic const short da850_evm_tl_user_led_pins[] = {
; M* D: n, b# d. g% [+ ^4 ^ /* These pins are definition at <mach/mux.h> file */9 j4 ?2 }0 t3 q2 L5 y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 M, E1 O& A4 A( L$ S) ~$ F4 \ -1
9 j9 N% {* q! j7 w g! B l" U};
# {' ]# Z4 S8 i- i6 X; s
* q! V. g8 ?" C0 \4 f# O0 ^static struct gpio_led da850_evm_tl_leds[] = {
( o: W. K" b: }8 A% U {
" O6 Y1 k W/ f5 Q" v .active_low = 0,- {2 y0 k. v: P) }0 ?4 ~4 Y
.gpio = DA850_USER_LED0,8 a' ^0 k7 Q3 u, k8 E9 L Q( F
.name = "user_led0",* D5 A6 P7 _5 `% g/ P. o5 j1 G
.default_trigger = "default-on",
# @9 {9 l4 V; C4 H6 D8 g; F- b },
P1 F7 y3 G* n3 l8 J2 ` O# l+ ? {
% h ~: F$ Q4 e" |9 b- N. C$ W Y .active_low = 0,' \" o/ Z0 O% ]7 l3 W8 o
.gpio = DA850_USER_LED1,
" ^1 K5 p' C& s: G8 l% `3 T .name = "user_led1",5 Q0 |8 I0 ]/ W, c/ O f) _
.default_trigger = "default-on",
4 P8 M n. R/ N; p8 | },1 r b0 F/ |" n+ a0 Y' _; [, q
{% g, F0 [1 J9 B7 v
.active_low = 0,
; x: H! K& S O7 q! }+ Q3 }, V .gpio = DA850_USER_LED2,
5 Y1 ?- ~1 a4 |3 H: f! @ .name = "user_led2",3 w; h( W6 H" g: i: G- p% \( u _
.default_trigger = "default-on",
) a4 k! u' Z5 G4 I },
/ s* u( M0 Q# b- p% k7 k { f2 y: m8 I! F! U
.active_low = 0,9 C" h T) m" A R8 Q$ |( |3 O
.gpio = DA850_USER_LED3,, X- y) t7 ]9 U9 B1 F/ M! y. D
.name = "user_led3",
2 V( C' ^" A9 S9 V9 C .default_trigger = "default-on",! ~1 i3 h! f# B. O
},
2 G0 K B* U6 v& ^- x9 [};: G- r% }. ~" V- Q7 B; V p$ b" q) G
7 C& o3 J/ t; _; nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" _* T, }% s; E1 h& d9 x
.leds = da850_evm_tl_leds,
% ?7 v0 z3 |, e! k8 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, n) r9 q6 }# J" c2 q. }- x
};
; i& U: ?+ g& z0 C2 a$ e# B }5 L% ^, z9 e
static void led_dev_release(struct device *dev)
& d# }2 E& M4 ]" B% @% l{
0 f3 c5 E- S. l: S};; i) c; ?/ o2 B3 r9 T
& w- t+ x5 Q. e" s2 f- b: _4 u* T4 [static struct platform_device da850_evm_tl_leds_device = {9 J: O- a- ~ s9 h/ z
.name = "leds-gpio",
# Z! q3 [' g4 K5 z0 [! Q .id = 1,' F! q9 S# Y3 R* s" J4 Y
.dev = {
5 O: x# d0 u, n9 g. e. Z2 {0 v z .platform_data = &da850_evm_tl_leds_pdata,
8 i# g$ g5 @0 u# G8 J .release = led_dev_release,- [; t, T+ _3 w8 ]
}
* ]: \8 d* z: O/ D};
. D2 @9 O3 G" @' ]2 q* ~$ g% Z: V7 Y/ F% E! K* x
static int __init led_platform_init(void)( i( O3 O1 e1 { S, O$ l+ G$ {
{- Y( E% s) f6 |0 _) A* x! @' E6 ?; F
int ret;, N" O1 W* Q8 ?7 J4 _+ M! u$ Q
#if 0
4 y0 m* |+ m0 \. h4 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" z2 t/ c" ]! b& b# f9 | if (ret)9 G, }5 e; _2 Q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 K1 C& B3 _% ?3 _6 g$ O" P( y) i
"%d\n", ret);
! }7 C- r0 N& f8 ~& p: H#endif8 S: r9 b4 D! U3 b) _1 D, }' s
ret = platform_device_register(&da850_evm_tl_leds_device); y: T5 F( r& N
if (ret)
" J: e; }: R2 C! J( ~& e# i( d pr_warning("Could not register som GPIO expander LEDS");- ]. S7 w) e. T! a
else; C* s1 v6 \2 M' d
printk(KERN_INFO "LED register sucessful!\n");6 n* {8 ^ E6 `
+ I2 \/ f& | _* D8 Y. q0 a8 f
return ret;2 `+ g( B- q, ?
}) j8 a" u6 K q' i7 I7 B$ G4 B4 d
% \) A& ]+ k# M; A4 Q
static void __exit led_platform_exit(void)) K* M7 `; y2 y" |, O9 D2 }' G
{
* L# g8 j' {4 Q+ W platform_device_unregister(&da850_evm_tl_leds_device);& ^ e3 Y" y% k! Y# D, Z. C4 U
* B( }1 T" _0 ]. p) }$ i) I5 }
printk(KERN_INFO "LED unregister!\n");
5 S. B& k- v- K}2 i+ y% t9 c/ t% D5 ]0 I. f. Z
7 Z% @; V! `3 l' {
module_init(led_platform_init);
, F7 z5 f8 ?% x1 B9 Y6 A; wmodule_exit(led_platform_exit);( @. O: x/ O# l9 U% y
7 G8 Z( `3 g' q+ e1 [MODULE_DESCRIPTION("Led platform driver");
* h3 T( i2 ~/ a0 x [/ AMODULE_AUTHOR("Tronlong");
& ^# p1 N0 B7 h# sMODULE_LICENSE("GPL");
; g0 r. T+ }: [4 f/ C" n
$ g9 ^9 L1 p9 a5 |& Q |
|