|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 F( e3 d3 j# h7 J R
#include <linux/init.h>3 \/ D, F1 g9 [2 x6 y4 l
#include <linux/module.h>8 M" }2 `8 G$ E5 f. X' B( U
#include <linux/kernel.h>) Z% t; d) U6 i$ X" ~$ e
#include <linux/types.h>, W- k" u# {0 j5 y# k( c' S6 g
#include <linux/gpio.h>0 _7 s+ J! D! z! W ^/ x' Z2 g9 w
#include <linux/leds.h>( \" `8 w$ H1 B6 l" k( X6 d0 u* ?
#include <linux/platform_device.h>
% ^+ R1 J2 @. a. p% M# P8 R: R5 r$ }8 f) M
#include <asm/mach-types.h>
2 ~1 s% \; f1 f#include <asm/mach/arch.h>
( ^9 a+ [$ y1 w: X- E* e3 M#include <mach/da8xx.h>5 _+ J6 Q; t& y5 w! d N
#include <mach/mux.h>
3 ` u. m, f2 R" O! g F& |" D5 e4 x+ n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- [8 H1 b" X! |0 ~/ I8 Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, p4 j4 z! T! ?2 X! S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ R' t r, a5 y- s) t& O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% @1 P5 s4 L0 a. y
2 w1 e+ v* h0 X/* assign the tl som board LED-GPIOs*/
0 C* S/ I3 }' v4 E jstatic const short da850_evm_tl_user_led_pins[] = {
# a& s) p+ O" q# @& T9 C3 L* k /* These pins are definition at <mach/mux.h> file */
1 |( H: _# H; ^) m: Z0 q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ W+ h5 s6 V3 Q U2 k/ ]
-1- U, o3 K+ b% {1 ^, Q; _; n
};5 C/ v# l+ ~" p
+ o' f% W& T }% C8 d
static struct gpio_led da850_evm_tl_leds[] = {
* E7 ], |# U: n) M7 e. ^4 h {
4 B6 F b, \) C6 a .active_low = 0,; H4 W/ v# E) k: k, _, y+ R+ j t
.gpio = DA850_USER_LED0,
; y/ x. t U" v .name = "user_led0",
1 s& y1 X. w( X% S- E8 z .default_trigger = "default-on",
+ L+ [- P9 t; i( G0 n3 t },) U8 n# I: D k/ m
{
1 Q) u+ n* L' X @. F9 | .active_low = 0,- S8 p' @. s8 S$ y
.gpio = DA850_USER_LED1,/ N. ~1 |; |1 v
.name = "user_led1",1 [. c2 D: @! r8 K4 w5 m3 p/ h
.default_trigger = "default-on",+ }) P* b2 i0 y, X
},
" L' V/ a0 `4 R+ b& ]. d- J" M {& J2 a' \, D/ C) B% P
.active_low = 0,
5 E8 v) ]9 ~: q5 r I .gpio = DA850_USER_LED2,
2 e/ }3 m" S' b; X: ^! ` .name = "user_led2",
( f& u: ^. Y% A7 D: _ .default_trigger = "default-on",9 {3 W% @! w1 m- j; N1 J
},1 s# Q/ b [5 h1 J! g
{
- d5 m) k O: S .active_low = 0,5 Q, F$ ?+ ]2 O y" |
.gpio = DA850_USER_LED3,9 s: k$ w7 y; o2 X2 A3 L+ |
.name = "user_led3"," h4 u6 c% v% J
.default_trigger = "default-on",% s" g; Z. H3 o+ o( n
},
- i Q4 j- W7 c1 ]! c};) U3 B8 ^; A5 z" Z! B* e
7 \8 s1 O) Z# F1 x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( q3 k$ Z5 T+ o e0 p9 } .leds = da850_evm_tl_leds,
$ x) ~% b: f% q4 @- ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 t( Y9 R2 e* j: H6 n+ C7 ]$ O};3 y$ f2 w* O. f6 H& p
: ?% g' x( h" {, F
static void led_dev_release(struct device *dev)
# r9 } g' \% T# f! Y! f( g{- [% x5 S& U- ^2 M0 f; A
};+ _; u4 G3 ~8 z$ H* m Z
5 x# m4 }+ k! i! w
static struct platform_device da850_evm_tl_leds_device = {* p. c: V: B3 z9 Y
.name = "leds-gpio",
/ k: w8 A0 s0 B* x7 M .id = 1,5 L# j8 W. x$ {& W" [% E( a4 d
.dev = {
& ?" g/ X# g5 D! h# a6 p .platform_data = &da850_evm_tl_leds_pdata,5 ?* B, H& R. V* A$ y) o- @- ^# D
.release = led_dev_release,- G8 r) Y. I# L$ O$ C- v
}* }# X% W" P* T a7 X! o$ T t* t) G
};
h$ e# k+ {! |$ Z5 k- K" W" Q. `, I$ w( h6 Z% e
static int __init led_platform_init(void)
+ {$ @- n. J8 w$ T1 N, C4 k{
# I$ `% @+ y1 T( c& O2 x" r$ G$ W int ret;
! S; x( x( O; Z. x; e; z#if 0" s+ m- _; Z/ Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ P5 g3 d2 U" A9 `. l4 p% C! {0 y7 t
if (ret)
9 w* d, b8 X8 \$ D( s2 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :") n3 Q" M3 p1 ^3 `5 ]& a
"%d\n", ret);( P+ ] J+ }. f: t/ C# ?, X" ]
#endif
+ Z* I; f# p X; l- h; U ret = platform_device_register(&da850_evm_tl_leds_device);
/ T/ p G* c/ ? if (ret)
. e% w% ?' n4 ? pr_warning("Could not register som GPIO expander LEDS");
# V5 ]% g0 e" M$ D8 I else" O+ M1 P* U7 j% l& P: P. Z* g/ c% c
printk(KERN_INFO "LED register sucessful!\n");
1 ?6 ?1 c6 I# b
: p8 M) h- |5 j0 ]; U( F return ret;3 v5 i* A# r. H) q8 L+ j
}: y; L ]! K E7 F1 F
, U1 p; I: P( f6 J
static void __exit led_platform_exit(void)
. d+ Q6 N( o5 C" c+ B4 Y9 w: n! {{5 B, |$ p* C7 [9 Z/ F# f
platform_device_unregister(&da850_evm_tl_leds_device);! }) a2 [6 }7 J% L* @2 M/ w- f
) v7 l$ F1 p5 |* v* E( v$ m8 X
printk(KERN_INFO "LED unregister!\n");" D$ ?, p1 B3 k* _& v: M& K
}4 [8 W- W5 b1 i( ?$ d- S
9 |/ \8 c4 {- w2 M4 A( P0 E
module_init(led_platform_init);0 X- e2 U" H/ e: |8 r
module_exit(led_platform_exit);- N9 ~4 }1 P5 u; L7 N
; F- s/ U3 ]& n7 F) k" Q
MODULE_DESCRIPTION("Led platform driver");! w4 {5 M5 Z0 a2 S j; U0 x
MODULE_AUTHOR("Tronlong");
; v# W `3 \. N4 e4 E7 JMODULE_LICENSE("GPL");# [5 _ n5 u J4 F3 J. q [1 [! I
$ C! S) T( x1 s- x A9 m* [
|
|