|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 y" f4 }% g$ B6 b+ n4 t: W#include <linux/init.h># Q6 m, w$ H. B) h9 s
#include <linux/module.h>' B1 T* q; h& Y* E7 V
#include <linux/kernel.h>$ g% [% C& L( C; T# |& L4 q; i
#include <linux/types.h>
, I- o5 ~ ^' R3 c5 y% I#include <linux/gpio.h>
& ^) H- ]' D7 C#include <linux/leds.h>
7 W+ j+ W9 m8 G#include <linux/platform_device.h>6 S3 ~& m' g6 |: ~ t
5 }) w0 t# o$ F( ?* t. p#include <asm/mach-types.h>& K) O# } O) j0 {
#include <asm/mach/arch.h>
$ u: B! L S! t- ` |* f#include <mach/da8xx.h>
6 d5 D+ S8 y$ W* z5 r, {! J2 v#include <mach/mux.h>/ K4 N; A% @/ L& c4 d& V; X
/ j' ^# p) b! V' @: O* P6 ^' H6 n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). G& h) p# A% x" I1 f. a, {( B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 C5 H# u4 _( S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 x3 Z" b0 \, |* U4 v' w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* I+ c. w3 {& c }! n- c7 v4 R
; H7 O# ?7 j- `4 D/* assign the tl som board LED-GPIOs*/4 I. c; o( `4 H; T8 O
static const short da850_evm_tl_user_led_pins[] = {
: l. P$ x9 W+ {# O/ m /* These pins are definition at <mach/mux.h> file */$ D' R6 v& B- J' X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! o2 k6 R1 d8 X: f8 e- n& ^! r! E
-1& r) }! O O& M1 v8 S
};
# l: b. k. J# I$ B6 W* n# P( g' r
static struct gpio_led da850_evm_tl_leds[] = {. m+ G3 \6 q& U y7 I
{
1 U _. _/ y- `" C6 @' ^" a0 X# s .active_low = 0,
) ^( ^, M. C9 C6 [/ I! w( z7 z# U8 @1 t! l .gpio = DA850_USER_LED0,* J i' M, v( n. R0 I9 V5 t4 z
.name = "user_led0",. r! M9 }% P4 @/ N# O) e! J7 w
.default_trigger = "default-on",
/ ^, S7 R/ {; y, q# m },2 V: ?! T G x5 _
{8 _: h9 _( D! ~: d, C
.active_low = 0,3 A3 G6 _# U* R% m
.gpio = DA850_USER_LED1,
J0 Q/ D6 F1 C( p .name = "user_led1",
3 R9 Y) g6 {! `7 T- O* i0 H y .default_trigger = "default-on",
$ i" _7 A O& h# H4 t },
0 P: ?; T; A6 C) U {
: X' k6 x, J$ K: j/ f/ H .active_low = 0,
E5 n9 u$ S* n9 X .gpio = DA850_USER_LED2,7 M8 W/ s( a. R* m2 r
.name = "user_led2",. x' }# M/ | _! r4 z9 E- r
.default_trigger = "default-on",' T! _% O7 _' j4 A8 g) J- N
},
* p- w g7 O3 M0 w {6 A( j+ g8 n8 L. }
.active_low = 0,
$ N5 x7 V5 @: t3 r .gpio = DA850_USER_LED3,0 {' |4 S, w1 O. @$ k" q1 U; [4 X! |+ v
.name = "user_led3",
2 ]/ ^, N; p# }' ], ` .default_trigger = "default-on",
; [# U! X5 z9 P },
4 O7 {3 J R" M m. J- Z7 l Q};
" I6 r9 ]& J+ E" Z6 `) ?+ N7 o8 K8 I* J6 t. E0 t; d* ]' f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: g/ F3 l0 [6 A' o/ `6 g+ |) J .leds = da850_evm_tl_leds,
1 F& n) A& P& {$ ]4 | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: Z# b' s! r# U};2 N; o% `4 q; E$ r* x6 D' G
& o3 ~" o. ^2 A" ~! x% Pstatic void led_dev_release(struct device *dev)! ^6 D5 V+ e+ W! o( @
{
, ^# I2 Z2 p" g};6 R. H9 }1 c* Y% B! \
+ x5 U0 h4 [. [# f" `0 V2 ]
static struct platform_device da850_evm_tl_leds_device = {
& ], `+ C& E* I .name = "leds-gpio",
; f/ E5 M3 O! Z$ l1 Y* G. H .id = 1,2 I, @2 y; ^6 ]) R" o8 J
.dev = {: ?* Y) r H- n' C; K
.platform_data = &da850_evm_tl_leds_pdata,
+ J4 E; v$ `2 `- @ .release = led_dev_release,
d5 j( f5 Z. W5 g }
9 V b! }# Q. V q9 b! [9 c6 b" K};0 z3 ?6 G$ Z# s4 V; u. k
% A; w N3 s$ q! M% l1 Z1 c* lstatic int __init led_platform_init(void)" p% D e* r# `" ^: G
{. I) b7 u u+ @
int ret;! e7 K i1 [+ d7 [
#if 00 y+ S- m Z* e9 c, c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 M3 c. W7 B6 r6 d9 r6 J0 ^# x
if (ret)% y! H6 l) R2 S' j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; a5 f! I5 Y' a# n
"%d\n", ret);
. q) t9 R0 p' E7 c* v/ E4 C4 J#endif
( ]1 F: Z2 a0 j7 c5 x ret = platform_device_register(&da850_evm_tl_leds_device);, f. @% I9 t# t/ g
if (ret) p) f2 g- Z5 K
pr_warning("Could not register som GPIO expander LEDS");4 y; P3 L: E- x& l7 ^- Q
else: z7 f+ u; q- }: X% N: \
printk(KERN_INFO "LED register sucessful!\n");
C( r! O6 z: v9 m2 J' m/ Q$ I# k% F( U) C$ u" }
return ret;9 J* z# B1 {0 w+ Z* X- _3 U/ l
}- q2 G5 k2 f( X+ [ f3 V
i! @* P+ G2 Y+ ^: Y1 |
static void __exit led_platform_exit(void)
7 u' M& b" u1 P" ~1 a{
, G t5 W( K& k( Y: R platform_device_unregister(&da850_evm_tl_leds_device);
# N1 ~1 B4 ^! b: ]0 k6 n0 V- |5 x! q8 H2 E( I0 Q* M3 W) c Q
printk(KERN_INFO "LED unregister!\n");
$ y2 G( s, G+ F. t/ D# H6 T6 B1 s}
" Z e: w8 _( `. D3 Q
' d# w4 D7 n% N7 R( ^8 P b+ fmodule_init(led_platform_init);* e# u0 Y1 M5 l# t
module_exit(led_platform_exit);
3 c1 e' i$ W, v, z) _/ v
( h* f" G! \$ EMODULE_DESCRIPTION("Led platform driver");" k' p* V6 V# q/ |6 S" a, q
MODULE_AUTHOR("Tronlong");& h$ R) [8 y% s7 ^3 d
MODULE_LICENSE("GPL");1 R5 B: _. o& B8 [ {: j
4 D1 t% j3 F8 I [* B" ]8 Z* T/ O1 u |
|