|
求大神给下面的程序做注解,请稍详细些,谢谢。
( r6 ^2 F9 [( M2 B/ n8 C#include <linux/init.h>
9 Q/ w( Q/ x5 n+ W#include <linux/module.h>
; V: X; i% T: ^1 z5 D h% Q#include <linux/kernel.h>& N4 P+ ~2 ^$ }
#include <linux/types.h>
& | P2 ]6 |9 ~8 N$ e5 ?' T#include <linux/gpio.h>; J9 J/ l, S7 l- K
#include <linux/leds.h>0 Y0 \. X& h% } K2 Y3 z
#include <linux/platform_device.h>
8 B& }: {5 t. @
8 K ]9 _% \" t#include <asm/mach-types.h>) N) H+ y# N+ U4 M% {7 G$ T
#include <asm/mach/arch.h>
4 O3 I# m, R) { t' k/ @# i#include <mach/da8xx.h>$ u# x3 H6 Z: v) Z4 Y1 a
#include <mach/mux.h>" \+ A! x1 h- {
- J9 o0 ^& H. p- [' y0 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" ^+ @& I2 R0 R: V" V, f# `* I/ x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ p, V9 @& J0 w+ U' J( S9 j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! N' J! m" M2 K) k, _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 Z! Q3 m4 G9 u7 g( P' o2 b' [ F) `" R. P9 z6 w+ r9 L
/* assign the tl som board LED-GPIOs*/7 V( H5 r; Z/ F
static const short da850_evm_tl_user_led_pins[] = {
; @1 r6 n* ?- E+ E" x /* These pins are definition at <mach/mux.h> file */. v" { b6 \8 ^' V/ e' n5 E& l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' O* i" V. \4 R8 ^! c, x
-18 ^8 }! y3 z& M' t' d
};
, e# \! k! a: g! a( T) U
3 }: G. t0 D# x6 wstatic struct gpio_led da850_evm_tl_leds[] = {/ G& }6 K' h, N: O" b& X' }' N* J
{$ H; [- `4 f! d- v* ~
.active_low = 0,% k9 H7 ^, \/ K9 f$ T
.gpio = DA850_USER_LED0,
; T5 b& `" V+ H .name = "user_led0",1 |1 v% @# M- [+ ]& h; X
.default_trigger = "default-on",
; q# V# v: J7 f' [' k/ D i },
$ s* ]% m3 O9 E {
6 L3 J- I( E& `$ M% H .active_low = 0,
. w' j' @$ u7 Q9 B .gpio = DA850_USER_LED1,
( p) J0 f% C5 |4 a .name = "user_led1",) H# [9 l$ n- `3 \, h, o* ?9 _
.default_trigger = "default-on",' ]; L( A5 ~; P* D' g9 L/ E8 A
},
h# j" V& B! Y: y {
0 q# F) `; j# p/ d8 T/ Q1 C* c; W .active_low = 0,
! e( S0 \, ^ j1 Y .gpio = DA850_USER_LED2,
" ]: H2 R2 K- ~: _& G! N .name = "user_led2",
. o3 X y, G+ B+ o2 O1 t4 ^% p9 ] .default_trigger = "default-on",
: j/ x; \% b# w },
8 X: Z7 v6 h' e3 i" r {' w- X: G6 ?2 s5 ?
.active_low = 0,6 a3 }- ]% h8 I
.gpio = DA850_USER_LED3,& D% o B3 [+ C: m9 t. c, u1 M
.name = "user_led3",
# m- W- u6 S5 o) G+ Q; C, m .default_trigger = "default-on",, u. D3 U& F. m1 l/ t
},5 _; Z8 m. N+ C7 R2 ]8 T$ Y
};
* |4 y, j! w1 K; g0 |; L' a; U: t/ r& N e) r( B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. f( X6 x( A3 R B' l( \ .leds = da850_evm_tl_leds,7 s5 Y% L& ~" G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 e- X" R5 M( A$ i
};* M, t4 I0 h8 X6 Y' P
: y* X: f, I3 [0 l% d; a9 nstatic void led_dev_release(struct device *dev)' N9 K0 j7 o; B. @: x7 {/ c
{3 }& ~* K5 j# K
};
) B: V j- C0 Y( K" w1 Z& w5 n8 |! T1 i
static struct platform_device da850_evm_tl_leds_device = {
; S4 t7 V' g7 x5 u: { .name = "leds-gpio",0 {- ]( K# |. P" m' \! U9 r
.id = 1,' V# X$ q- b9 G$ z
.dev = {9 h' y- M3 x4 F) h9 c' |
.platform_data = &da850_evm_tl_leds_pdata,
B5 ?7 J. U3 d6 V' n .release = led_dev_release,
3 N3 Q$ g7 l3 L7 W }$ \6 } B! o3 Q+ _6 l' H
};7 o/ C! Y' _9 ?& g% G
1 i/ D9 R+ w# U$ N+ G s5 p- V
static int __init led_platform_init(void)8 t! o1 N! K; a0 L; k
{5 m# q0 W. H" x) v. g! _
int ret;+ V# N' ~& y: T& @' i
#if 0) ?, [3 ^+ ?" C! [/ i2 k+ L( i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ N9 R% v! H' g: K/ x
if (ret)7 W9 E% a# ]( ]! `3 v% b( K4 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 m- J* A0 F3 B2 @0 r
"%d\n", ret);5 O6 w5 Z' d- w3 I# i7 W8 p6 G
#endif
4 R) K( {, t; X8 K+ g ret = platform_device_register(&da850_evm_tl_leds_device);/ o4 g; L% C0 V6 w3 s9 r" O
if (ret)% U' i# U$ }' W7 D
pr_warning("Could not register som GPIO expander LEDS");6 v4 |: c* o6 [
else
$ I4 _) Q6 {. F; c" } printk(KERN_INFO "LED register sucessful!\n");* P2 u" N0 q6 {& E
; [; G" v+ B1 X( Z6 k return ret;
^. b) k: C' }1 _3 E( D. m; p; U}
% y5 j9 S. L0 U7 r
% D) q/ d& k- `, w' L- |: u* Q0 cstatic void __exit led_platform_exit(void)
" Z/ c0 M& ~' h1 @' Y( ~3 P3 J{
8 B; W7 W4 I/ U, f) |8 v platform_device_unregister(&da850_evm_tl_leds_device);# f. T- u. b6 o, j+ B$ |' R2 y$ A
( e; o% t/ V/ G: l" Y% v- X printk(KERN_INFO "LED unregister!\n");8 D0 i& ^6 W. q7 S g9 p4 ~
}
6 W7 V$ L# K" u9 d5 B
3 n- Z/ d5 v& i" N9 k, K# ]/ xmodule_init(led_platform_init);0 N, @* r" ?+ |
module_exit(led_platform_exit);. z9 t/ T2 J- N; C7 D. M
0 a, q5 r% c8 QMODULE_DESCRIPTION("Led platform driver");
- h, Y; S) i% L; V2 Z9 GMODULE_AUTHOR("Tronlong");7 T F( b' c5 p# r! A1 z' X: d6 `
MODULE_LICENSE("GPL");
; ?7 C# S( D2 ]3 R
) {2 X2 o& E0 E; t |
|