|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- I( y4 k3 l5 t1 j6 @% N#include <linux/init.h>
" O$ R e, m% b; e% `$ q#include <linux/module.h>
2 n7 o9 H( N7 I#include <linux/kernel.h>
|) Y6 U' ?& ], B( c#include <linux/types.h>
; l, e; q; a2 N# C* d! J5 s#include <linux/gpio.h>- P* }+ a; |7 _% } i
#include <linux/leds.h>
" w; D9 I+ ~5 C$ i! C5 S2 {#include <linux/platform_device.h>
4 Y% f) \2 o1 ~3 [) ~" ?
. W6 n/ Q4 A7 V* U% }/ t#include <asm/mach-types.h>
" \7 ]4 n. U3 ~7 h) U: ~$ `3 g( c#include <asm/mach/arch.h>, ?6 O' a Y- m) ~; H; \! M
#include <mach/da8xx.h>8 Q) h3 [% w: J' @* l, M
#include <mach/mux.h> C6 F) j7 r* x% Z) c! [" |# U
" S7 K3 a r$ ^ z2 i$ M% @9 Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, n2 U! c( ^: o2 o6 j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; v/ B' b1 O. }2 G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 s' l0 G" p. E6 d1 |4 ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 I* f% a9 x( n* z4 D
# y. c+ ~" r2 m* A6 V9 e' d/* assign the tl som board LED-GPIOs*/
5 m; v4 u' W+ r, `/ rstatic const short da850_evm_tl_user_led_pins[] = {
) f& [5 h: E& w2 F9 \ /* These pins are definition at <mach/mux.h> file */. q2 j1 _( c7 v8 K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 T4 U- e" H L0 p+ f -1
) n8 U& m7 H# Q. F};
9 A# \" Y: x4 B3 z |3 K, b0 e* B2 X/ F- j! O
static struct gpio_led da850_evm_tl_leds[] = {5 x% \: T J' {7 Y' K2 P
{; U( ~. e/ \; u
.active_low = 0,
: f) z( E' V8 s L* k .gpio = DA850_USER_LED0,
1 p4 _ i: `! `9 A& t .name = "user_led0",
8 M+ t9 k/ ^- C' W- I& X .default_trigger = "default-on",4 ?7 [ [: }' z9 j! W
},
3 U* W" s+ A# e {
+ ^; `% [) x5 G: l0 G .active_low = 0,
$ S" ^/ B1 `: e4 n. ^ .gpio = DA850_USER_LED1,# K" b5 j' A) R0 ]
.name = "user_led1",
. s1 A3 y* \& l9 Q" W/ e: T .default_trigger = "default-on",
' P5 Y3 P, {) v+ ^% s },8 B8 @; T4 e7 p3 t
{2 z& j1 y4 N g4 U( ], ^- J
.active_low = 0,
( }; |, u- ^2 h0 P/ L5 B* J h7 \ .gpio = DA850_USER_LED2,
+ L# e8 q9 C" h3 z .name = "user_led2",
; `* z* y6 g6 Z. m2 Y, U .default_trigger = "default-on",: u9 @( }: h# P' n, U
},
1 L# [' i: f3 X3 q {
1 q' g/ |% V, | .active_low = 0,3 P4 G+ x" f% n7 r6 \$ S1 e
.gpio = DA850_USER_LED3,
8 F# X7 B d3 { .name = "user_led3",! N& h. F, O5 M1 Z# q
.default_trigger = "default-on",* \: ]- n' @0 V9 R
},
; x O! J! H+ X# c};
8 ]1 i; g k; \: G' C
- f& f8 J# {- K! Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ s' T1 x( O4 @6 Y9 {3 N
.leds = da850_evm_tl_leds,
3 t1 P0 D. O/ t& T: n9 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 M2 P- q% \( C8 [. e7 j9 M};
: o2 G9 c- W4 I) e
; M. p9 G& A2 ]( m; F+ cstatic void led_dev_release(struct device *dev)
" _" z# y! ]3 J" }; Q{
1 @8 {7 U0 ? E1 N# l; C};
( y% H, C- l0 Y2 v$ I+ W6 N$ c, ~6 K) |8 \6 y6 @
static struct platform_device da850_evm_tl_leds_device = {
: {. g6 ]# v& f$ L% i6 s .name = "leds-gpio",+ ~+ G5 R; ^& E3 R B
.id = 1,2 P4 P8 W; ?1 s, c& X
.dev = {
& F4 D( J# q& f9 L) n .platform_data = &da850_evm_tl_leds_pdata,& j& T) Z9 x3 {7 h
.release = led_dev_release,
6 ~6 |8 Q( [; a4 r+ s t2 O }# w; C: [$ F, u; B- I8 F
};2 R `# |" n) x/ D$ {2 i
. w/ _) c- v0 m) s
static int __init led_platform_init(void)
% L# N" k; j/ ~6 q# D. R. s$ d0 b{2 k# B; K1 @! N
int ret;; r- t, f* G/ m y9 t/ Y
#if 0
1 S. B4 A0 o. |7 a- j1 S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! X% c- z2 }1 Z if (ret)
( U6 K) ?# H$ q4 t& G" u. M% s, D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) _' K/ }! ^7 D' l4 e! A "%d\n", ret);
* M& {* h! F/ i' u D. e4 Z8 C* B#endif
. u+ C0 D% P3 `- H+ w, J& }" h ret = platform_device_register(&da850_evm_tl_leds_device);# Z) B0 k2 c( A1 ~
if (ret)
* J! E S: a# [5 r pr_warning("Could not register som GPIO expander LEDS");5 s0 _! a0 m! f1 I2 K4 t+ E
else
6 V1 b$ Y" Y) d+ ~$ e# o printk(KERN_INFO "LED register sucessful!\n"); i9 \: N7 K q, F7 v+ |
r" K6 ]6 o4 k# j" z6 r return ret;! j1 N3 s0 D/ }/ X
}# P& m& K/ t v8 u+ R( T
1 ?* c' S: R: x8 t1 \. K+ h" i
static void __exit led_platform_exit(void)
5 x; _9 Z* E+ ~' n3 W{- F; v$ U, ]9 {. l9 N
platform_device_unregister(&da850_evm_tl_leds_device);- l8 ?; [1 ? j$ V9 U
9 c! G$ v( t7 V1 x, m1 Z8 i) ` printk(KERN_INFO "LED unregister!\n");: o. j; l: w! A9 d* i) Z, h. k
}
- O6 \2 \, ^& b' u) b
3 ~2 u' `, W* I4 A. Kmodule_init(led_platform_init);
. s) q. w' {3 l7 {3 x: Omodule_exit(led_platform_exit);+ g! O" h6 H9 W) ^0 |$ ?& T
0 Y. v3 P, C2 |
MODULE_DESCRIPTION("Led platform driver");
1 ` |4 W N: e1 q% MMODULE_AUTHOR("Tronlong");
: @# u [- _% M$ U. v, @MODULE_LICENSE("GPL");, H3 {- C1 }3 v4 Z( X- m% H
! s2 r, I" V3 {0 H0 a
|
|