|
求大神给下面的程序做注解,请稍详细些,谢谢。
( Z: Q6 Z* P3 l5 A& k/ T#include <linux/init.h>* N% O; ?& J6 s( Z1 b$ g% @
#include <linux/module.h>
, G7 ?' n& B7 r; s/ U1 F* ~#include <linux/kernel.h>* a. U5 b! b' ]3 \: }
#include <linux/types.h>
, N' O2 p5 K3 z' N#include <linux/gpio.h>( Q1 J# |$ t; _) I- I% [: q9 x2 g
#include <linux/leds.h>
: F0 g1 Z" N* }6 v1 R0 f7 i0 B C#include <linux/platform_device.h>
3 v9 q( W! {" p/ j. B, S% b( i2 P! g. o& d" {! s; b3 [/ [- J
#include <asm/mach-types.h>
+ O) N% y- T9 y" l5 a+ d( b% P#include <asm/mach/arch.h>0 q) k* A1 D, T1 g/ p2 _ A
#include <mach/da8xx.h>7 L4 U7 \% h ?1 o" ^6 N
#include <mach/mux.h>: m4 Y" S% b, w9 Y- D; O0 U5 _0 Y- c
$ [4 H5 Y \& w, |5 Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' u# E( o' X- r+ P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ T& F, C4 F+ x1 y; [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# B7 J6 }' J+ p* E, M! Y/ D4 H- ^. `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ J$ d( E% y3 O5 Y# A# {/ ?
* g' l; u+ z0 T/ W% Z4 m/* assign the tl som board LED-GPIOs*/( }% ~" G5 W- F6 P, ]: L# [6 H
static const short da850_evm_tl_user_led_pins[] = {& W; Q. p2 s1 g5 A( p
/* These pins are definition at <mach/mux.h> file */
0 O, C4 k$ S; z! ?3 @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 U/ \* c1 `; X1 @# l
-1
8 S% X3 ~5 i" N};
2 D; N7 U/ a# O4 V
. S# a+ [3 w; b$ I" l) \3 Istatic struct gpio_led da850_evm_tl_leds[] = {
8 @5 N8 _ t; F7 r* ?: t. g {; u' l9 ~+ _7 N# a, b
.active_low = 0,
$ m4 \* k& H/ U6 Y0 h2 K .gpio = DA850_USER_LED0,
3 L1 r% N' q' y .name = "user_led0"," h* Z4 @; ~6 F7 S
.default_trigger = "default-on",9 w# }' ?3 _! v4 @. u! \; y# A! D6 v
},
0 r, A5 ]3 k/ F' S4 ? {
* l* }; b) c3 ~ g+ l7 G .active_low = 0,8 U H1 B4 [' o# B8 _$ Z( f
.gpio = DA850_USER_LED1,* ?+ u- _4 A3 R
.name = "user_led1",; w6 V& C/ D: |. ]; l V9 z! A
.default_trigger = "default-on",6 N+ m7 J8 X$ |- Z7 C a& |
},
6 V& b- J, n7 @* P' a: n7 m. o; l {: k% c. \' M9 t3 d( @# ?
.active_low = 0,- _/ T1 D) N; `0 c* g% F
.gpio = DA850_USER_LED2,
% |- k5 k' Z$ e$ A! w7 u .name = "user_led2",
/ `% C( C( x" a6 T6 ? .default_trigger = "default-on",
2 V* B9 @- N% I7 I1 w7 | },! Y" j& j9 k& B( j3 V) D+ T
{( J# j4 d4 ~0 p2 H6 K8 t' t G
.active_low = 0,
h' c; P$ s2 }0 i$ r. L .gpio = DA850_USER_LED3,# @6 W1 E+ I! X- J5 C0 _
.name = "user_led3",4 R: J" C/ |8 S/ N
.default_trigger = "default-on",
8 U# u) D3 s8 w7 \$ B$ d2 A( g- i },
* A: O3 `0 K* |) H- {% n};! n5 v' q* u1 \3 x# P( Z* A- i
. J, i+ O# v$ P& ?1 q$ X- Y- y R( U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 Y9 X" D) [$ w9 E
.leds = da850_evm_tl_leds,$ ?( @4 O# B$ |9 T: @6 k" s3 U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% ?# y& ~& W+ t" D! e9 E" r
};
7 b( s, y- B, m( K3 d7 ^7 q( h: x+ _' y. }, r2 {
static void led_dev_release(struct device *dev)
- s1 | c/ X- v3 H, ^/ U1 ^3 k8 w{+ Y, g1 e4 p+ b/ b6 i
};
; p" b3 f( i: e7 P4 Q
- E6 T5 X4 i# Q- E) b# ?" C- i7 ?' astatic struct platform_device da850_evm_tl_leds_device = {
+ l" \. q4 `$ d6 H& G .name = "leds-gpio",
c; O0 k3 ^: j0 D9 w .id = 1,
4 m% }+ I* D/ V, _& R .dev = {$ y" o. _( C$ x7 p: A2 L" v
.platform_data = &da850_evm_tl_leds_pdata,& ` x9 v( m( }5 w
.release = led_dev_release,( K( R0 C: }6 z$ |# C6 R+ D
}- [/ {5 v. s! `$ {9 H6 k
};
+ }- Z: W+ n# h6 U; r, |% K5 F4 U! {5 u, L4 |* x. l
static int __init led_platform_init(void)/ ^+ W+ E- w, ]$ i+ Z
{
! ]5 z/ T- k$ V8 \- M int ret;
# s" @% }- u- x; d#if 0 g5 s [' q2 j3 l3 O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) e/ }4 x5 J& p0 b# n/ \
if (ret), n3 {2 y/ A0 e( [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& z1 B7 S% _5 Q- h/ K "%d\n", ret);
7 n* U% [/ @/ @8 U5 \#endif. u! n/ V% ^5 w# b
ret = platform_device_register(&da850_evm_tl_leds_device);3 S% H/ L+ W7 Z& T V
if (ret)$ k8 g" r, V: A. D% e# J4 G2 f" C
pr_warning("Could not register som GPIO expander LEDS");
9 m. o4 V0 @9 j$ M7 W/ ?* N else
/ X P. c; @, w' C i$ i) y printk(KERN_INFO "LED register sucessful!\n");! d0 j* @# z' | _+ k/ ]
) c& X6 i9 t' u2 `3 G' i return ret;
5 F Z, z" ~" C6 m3 f2 r}
9 z* |/ c5 q1 `3 W% y/ }/ `, f. k
$ J8 V& |7 r) O% a0 R+ tstatic void __exit led_platform_exit(void)
+ |0 Y% C3 q4 ?{3 u. J# ~7 G9 T. `& O" q7 V
platform_device_unregister(&da850_evm_tl_leds_device);
8 y' f0 d- {6 I. a- ^+ O% V8 f2 @8 s( f" z# @( e; d! W
printk(KERN_INFO "LED unregister!\n");3 X1 }* h" i; X; e' e
}& P4 G4 v& Y+ C$ l5 c' h
, f0 y+ ~$ t, a" u) N
module_init(led_platform_init);* H4 a0 ~! }6 ?$ V& H0 X2 n" `
module_exit(led_platform_exit);
/ Y8 s5 l7 }& o+ P r5 p8 j1 K+ E! b2 ]8 T1 l5 J1 b5 {6 Y; p
MODULE_DESCRIPTION("Led platform driver");0 }0 h2 E' `. B4 z8 M
MODULE_AUTHOR("Tronlong");
3 |9 d/ O2 d5 e5 m8 i6 l2 C: aMODULE_LICENSE("GPL");, F- o! L0 \3 y: o6 ^* D9 Y
4 i0 _, R+ F8 Y6 p4 S
|
|