|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% c$ P, u e. n. Y3 M% W#include <linux/init.h>! s8 g- a% l4 o: H0 _ A0 G
#include <linux/module.h> j# o& h0 C; F8 V8 b. W5 P7 ^. ]
#include <linux/kernel.h>
) {3 x! B4 B! Q7 S7 n" G8 H7 n#include <linux/types.h>
" L' I2 n7 f( J9 V5 S# h#include <linux/gpio.h>
8 t7 A9 b: j7 Y/ `. }1 [#include <linux/leds.h>3 ]$ q: C& `, q
#include <linux/platform_device.h>. r) Y6 O' F( j, D5 X
7 D6 h) B9 b* D7 C% H L, L( k#include <asm/mach-types.h>
6 z" u) }$ }' f' Z#include <asm/mach/arch.h>
$ _0 `: M9 r3 f8 U, `5 Y K" x#include <mach/da8xx.h>
# n% X+ B4 W" g- E6 X#include <mach/mux.h>
6 C1 T2 a" d$ k) ~. r
( O3 ^) C# m0 ^# G$ U5 x3 Q# x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ t" I y! z! h A/ o; Y' M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' T4 g% s; f/ Z3 Y; @; O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' y3 \ E; T0 M" r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 R2 T) J. a; e8 E, z" B* x' N3 j7 c$ b
/* assign the tl som board LED-GPIOs*/! S; |3 L7 g9 t
static const short da850_evm_tl_user_led_pins[] = {9 ]+ }+ H0 R! g, w
/* These pins are definition at <mach/mux.h> file *// _3 h' b4 l' U$ q- S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( s) w# v4 S$ S; ]
-1! P+ ~; m' T; A/ G- M
};, h1 y, _" I. D% E* r
& o+ b6 T& f. a8 \
static struct gpio_led da850_evm_tl_leds[] = {3 i5 ]2 J/ R* a) e3 k2 Z' ?" k& h+ ~
{
( m o0 q& p1 y7 Y+ G# i .active_low = 0,
6 S- ~) Z# N) B0 n4 m .gpio = DA850_USER_LED0,2 g* O! P* _) D% W. y
.name = "user_led0",
& h: Q) S+ x$ `0 G6 j$ M .default_trigger = "default-on",
& d& V. x6 t$ D$ U3 j5 a },
" F0 S. W4 {# g1 H. ]. D0 g {
. R( a8 u# w6 j% d .active_low = 0,5 u5 p S+ U+ p; a
.gpio = DA850_USER_LED1," V" [* \) T- H
.name = "user_led1",7 l: m5 ] a8 L+ ?! s& h
.default_trigger = "default-on",
, M- {8 V+ t3 U0 S( O },8 l! R S/ ^. O; T
{
8 D$ [) Z( D" K# ] .active_low = 0,
9 ]( w; e* |8 K6 ]& [* w .gpio = DA850_USER_LED2,; y( o; k0 e3 l" `0 N
.name = "user_led2",9 Q! s1 v. A& v( d
.default_trigger = "default-on",( s1 Q, l! x+ t' F- g2 e% x
},; Y- K+ w! g7 X6 u4 t7 _
{# n6 ?8 o' u5 R6 b) i% \8 X6 U
.active_low = 0,9 ^' S! Z2 B! m, J' K% U1 ^
.gpio = DA850_USER_LED3,* f0 i2 d* W$ i) U# e( k( S
.name = "user_led3",
5 J& H5 _. D9 ` n/ d .default_trigger = "default-on",
$ I; b$ u( F' U3 s) E },0 A# U$ r: h o" Q; I6 H- I# U
};3 w) n+ R) x$ Z4 ?( q
- T# p5 O, `! ^8 `6 l5 ]7 E k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 ~7 T5 k5 P f8 O
.leds = da850_evm_tl_leds,
% b, g7 B2 U" J6 b3 _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 P: \* v- _1 N4 Z6 J, Z, k; h
};
, \5 Q3 Q Z3 p2 S5 F/ E5 s9 ^8 o8 i8 n
static void led_dev_release(struct device *dev)
% C+ V1 t( B8 q5 f{! Q, }1 A6 {* t0 a7 k8 e7 F
};
8 h' J$ }- N; `1 U; @- i2 i5 x4 ?# T' `5 m7 W
static struct platform_device da850_evm_tl_leds_device = {
# P3 n& _& T0 o2 Q+ H .name = "leds-gpio",9 H0 P/ V* t8 ]. j1 {+ {& H! N
.id = 1,, g/ Z" f0 V: G9 [! \! L" S
.dev = {% _6 Z! @6 t7 V. [! n/ T. D# y
.platform_data = &da850_evm_tl_leds_pdata,
% j3 D/ D9 x5 ^ .release = led_dev_release,% z$ X! g6 ^4 S, Q& ~8 ]. _7 I' I
}, y6 O: J( g& z/ {2 r0 q$ X
};; D' u l2 A; h
; L2 ~" X c1 K, g1 j; Nstatic int __init led_platform_init(void)
" P: A3 j- I h& ~( T# g{3 h* e- z* a" D9 A5 h
int ret;8 N5 x" O. a7 V2 I0 A7 _) s4 _
#if 0
, f5 F/ z) T( I% H- W! W5 q6 i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 b4 A R9 F1 H: v1 O4 |
if (ret)
% s$ A! r6 [; m4 y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) J$ v7 L) R Z% d$ l* _6 x "%d\n", ret);$ `$ S* D- I8 x
#endif" C" ?/ F5 T+ J7 G( S5 _' J
ret = platform_device_register(&da850_evm_tl_leds_device);
$ n5 u9 z6 Z: j, P if (ret): ` U3 A0 H" l" V0 B5 M! N
pr_warning("Could not register som GPIO expander LEDS");
7 s1 m' x$ `- g% |' [+ ^" M2 V else
: Q* u0 r9 D! ?0 x) ? printk(KERN_INFO "LED register sucessful!\n");
( z$ d8 h* [& W& c% z, }; s) P' r i$ R/ U v+ G& p8 ]1 ^; H0 B$ G' @- b4 {
return ret;3 }; `0 {: w8 k9 a: @6 y% m' ~
}0 s9 g5 U# r/ X
+ @: q* z$ A5 Q8 J3 R
static void __exit led_platform_exit(void)5 }1 g: J# K9 J: K
{3 W% ~# r) a8 }
platform_device_unregister(&da850_evm_tl_leds_device);: i+ z- `: Y; ^* ~
" A D+ z) M, N9 j printk(KERN_INFO "LED unregister!\n");! H+ [$ M- ]' C: H. `; A( k
}
: [# R h9 H" G" q% n$ i
0 M; ]% i) G2 N# l' Z' Y, \module_init(led_platform_init);
' O& Q1 X* D+ [9 N& z' ymodule_exit(led_platform_exit);2 F1 k2 K. W6 m" Z: v8 U
% v4 M& b# m- \; T3 Z* N; z4 U- xMODULE_DESCRIPTION("Led platform driver");
, l. V7 I$ i0 H! cMODULE_AUTHOR("Tronlong");9 o; n: D* T4 T4 g- ^: ~
MODULE_LICENSE("GPL");# `- C- ^( _# _) f Y8 y
9 {! V. d$ U. ~$ N2 b' s5 g' ` |
|