|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- e6 t' p2 U* n$ y5 h7 t#include <linux/init.h>. {0 W* I: T' @9 F- ?$ @
#include <linux/module.h>, U0 ~" d2 ^/ P5 S p2 Q
#include <linux/kernel.h>; e9 P% Y9 d, | d! T& G- {4 |
#include <linux/types.h>
( F% Y) e& s4 a2 a7 G5 ?5 s5 m#include <linux/gpio.h>% v% P. m& T5 I! ~1 z
#include <linux/leds.h>0 l6 e( @5 T, \
#include <linux/platform_device.h>; t7 p, l/ `1 M! n# U) a8 b+ h
, A, F. G( s+ _9 F5 U0 H' J# X#include <asm/mach-types.h>+ V; a/ G9 b. ?6 e; E8 g/ e+ b
#include <asm/mach/arch.h>
8 W3 z$ l; C3 h" Q#include <mach/da8xx.h>
2 t6 ]/ J: Y# `#include <mach/mux.h>
2 {/ \5 x# P! P
4 a) u. v9 X4 f+ R( e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 s6 k, g# z, Q; b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 ~; }% G3 c2 Y/ O4 C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) n* {; O- d/ H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 W" O9 Q. L/ v% i. O% j, _
# L5 _2 a8 n$ u7 s9 E/* assign the tl som board LED-GPIOs*/, s7 M" y5 v2 E. f: ^. N( ]
static const short da850_evm_tl_user_led_pins[] = {9 C# A1 k9 f- M$ j
/* These pins are definition at <mach/mux.h> file */
, v# \; u6 g4 n, _+ p @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
y0 I& O7 y! o1 @1 @$ |8 g6 M -10 _% H; e5 e8 {( B
};
$ O4 p7 m# V1 I" `, V$ |) ?: x4 K! C0 c) f3 u. q& q% ~
static struct gpio_led da850_evm_tl_leds[] = {
$ G1 n) u! d7 k' H6 g, c {$ y7 r t1 Q# G
.active_low = 0,
% k% z- i U" c4 g% r8 ^4 @+ f .gpio = DA850_USER_LED0,
2 U; e5 p- o* b7 r( E' ~ d c+ L .name = "user_led0", ]0 x7 p; A7 J
.default_trigger = "default-on",, b/ p" |3 c+ C0 Y- t/ G
},0 l2 N6 P+ C3 _; R
{
3 r& r! d0 |& F7 l% Z w5 Y .active_low = 0,# k( v$ e8 n9 {. o; O
.gpio = DA850_USER_LED1, t3 P# |4 [/ V2 b3 Z
.name = "user_led1",
; i( B& C$ I; F6 x, I# O .default_trigger = "default-on",& T. L. s1 k# T" R
},
9 A4 _" C4 V$ x7 k" B C( q {
7 e' F5 P3 r k0 i- B) u/ [ .active_low = 0,/ o0 }+ K3 d1 R% F' r: G
.gpio = DA850_USER_LED2,5 Y, Z( U- F: d d# q% U& u
.name = "user_led2",
4 C& R" O4 V1 H; S6 p7 x .default_trigger = "default-on",
! ?1 T; h% }9 _ },
. K% ~3 U' ^. Z; j" G1 S) g) f. f5 K% H {4 I' h {1 @2 @+ Q7 ^# U+ N
.active_low = 0,
0 R$ e" E6 U$ ?4 q: d .gpio = DA850_USER_LED3,
% t9 k1 s9 C0 t7 [3 @# Z! j6 Z .name = "user_led3",3 p( k: l! l) a1 M9 x
.default_trigger = "default-on",$ x4 i: E+ U) ~$ Z9 u& V; J4 t
},2 D- m+ Q. y& f( G* Q
};
% [' M. }) F8 v+ d" p# I
9 K+ n& ?( o, z- E5 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* Y5 }! w" A' l2 k
.leds = da850_evm_tl_leds,
+ o/ ?; r( u) o3 F) { Q4 s0 o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- W) @2 b, o% N; ?7 @};% X: C P& S0 C' T- _# j3 Y
# K# _, F+ e7 D; \6 W% k `# c
static void led_dev_release(struct device *dev)
3 t1 |8 }2 N' \8 Y{" ^; t: A# s [/ q, w: @0 |
};
1 l* u$ O: C E: D2 b/ q, _. V" ?- C+ \
static struct platform_device da850_evm_tl_leds_device = { p0 @6 o: @! U" r
.name = "leds-gpio",$ K/ _' M1 u& _" Y% C4 M
.id = 1,
6 W$ G4 j8 c: m; X% f( C .dev = {
" l9 h0 S- E" V% | .platform_data = &da850_evm_tl_leds_pdata,2 L5 y# {7 w" P4 ^
.release = led_dev_release,
- o/ Y8 x% b" G3 V E# T }8 R* {1 s S7 z# U* ~. r- L
};1 |5 W) ~7 h9 O3 f2 R. y
+ L8 t }, v qstatic int __init led_platform_init(void)
; M& D; O7 K. h{
" B0 U: B: B' p5 o int ret;
* B- v, C4 U, y6 w, i ~9 d+ k#if 0. e9 h! F; E- {: u" ?; P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" {3 s/ V# {' h v* {/ M9 g4 G: L. P if (ret)5 r4 n) ~7 r: g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! f, \; J* I( R$ w3 w& y$ W- T
"%d\n", ret);* L/ T' R3 T( S `
#endif
+ V! y5 B: C* o# J/ N ret = platform_device_register(&da850_evm_tl_leds_device);
: \$ Z+ Z. i! o! D4 x; W1 S if (ret)
$ X4 C1 T% Y$ }# {1 R pr_warning("Could not register som GPIO expander LEDS");9 V& v$ _2 T% z1 F( e
else
" Z- D. d! p' f printk(KERN_INFO "LED register sucessful!\n");- w- U# f5 P& H9 t) }) U3 R
" C/ _4 h# f% u4 J3 `9 s% K
return ret;8 b7 Q/ n/ z/ H+ }7 J$ G! M7 ?
}& v" Z- U1 o' Z4 P8 C$ x; r
! D0 |5 F7 n$ z$ V z3 N
static void __exit led_platform_exit(void)5 I+ p+ `5 ~* W }! Z( Q* a5 ~" A5 e
{
5 H3 m; r2 Z* W8 q platform_device_unregister(&da850_evm_tl_leds_device);
) H( \8 `; @" o* u2 r2 R1 k. g
( v( x1 x8 `7 O: y& v printk(KERN_INFO "LED unregister!\n");
5 o' } l+ x+ S3 ^}9 v; p j" o/ Y9 J6 D) e! b" X7 t S
+ g: r, _0 H) `2 {' [9 v& Hmodule_init(led_platform_init);
4 {4 ^+ z( n( s4 @" \+ nmodule_exit(led_platform_exit);, M( ?, a% F g G4 Y
3 E, j% \( D1 [' [1 F5 o8 { O
MODULE_DESCRIPTION("Led platform driver");# s" _! V* ^* j/ g$ W) p; E
MODULE_AUTHOR("Tronlong");
1 D! T9 a: S. t8 C( b& v; IMODULE_LICENSE("GPL");
- e5 n* O( o% c. Y1 u% {( T( R; F1 }9 H9 ]# b. ?) _+ Y+ a% _
|
|