|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 K9 f) M8 X/ I1 U* h#include <linux/init.h>+ g7 u4 }- z6 u: `2 M
#include <linux/module.h>
" \, ]+ L$ K7 \' h% a7 J#include <linux/kernel.h>% ~* [. `5 C: p: k
#include <linux/types.h>5 x% N( X. d& s+ `
#include <linux/gpio.h>
3 m2 K+ Q0 j& {4 W/ J ` K#include <linux/leds.h>
/ ~7 e4 |8 _: u8 R#include <linux/platform_device.h>: I, S' r+ ~% Z& [
3 b! ]/ q5 k, L1 _6 w#include <asm/mach-types.h>
/ U R4 n9 d* y3 h$ h#include <asm/mach/arch.h>
" G. d4 l7 N. f' T9 L3 h#include <mach/da8xx.h>
* O- `2 G ^9 w/ E' ?#include <mach/mux.h>
! Y/ o3 W# y! U4 W* h, B4 B
( _" t7 z+ I( T* L5 _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 }6 i1 n& {7 L/ m/ M; p! m: o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): R0 @+ w2 O! p4 c" a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- b; M+ O6 l h- Y1 L3 t& ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( k6 [" E! O4 ~; Y, C
6 S- e5 ~4 L3 l9 E" `3 E( y
/* assign the tl som board LED-GPIOs*/
2 V) j3 O. L+ t4 G* Fstatic const short da850_evm_tl_user_led_pins[] = {
. T h3 v& X& r /* These pins are definition at <mach/mux.h> file */
4 g' d% Z) m/ i- Q4 u) |# I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ T4 Q! R' w; H/ ~
-1
% d/ O ^6 I" V* k0 L( u6 U};
) a0 B: C; w3 D" r! \: V
& d9 \& Z* ]0 C* P _static struct gpio_led da850_evm_tl_leds[] = {+ b* _+ ]+ n, }1 I
{5 v0 E3 B* L; M0 W
.active_low = 0,
' l* \) i2 O8 J, ?; j .gpio = DA850_USER_LED0,, |: g+ h/ g' J1 h# y
.name = "user_led0",+ B) x. ]. M0 J7 x
.default_trigger = "default-on",! A/ E& ^1 c" A2 r* r; j# x
},9 @6 S% e7 a4 R$ U7 g/ L
{
3 X; ?+ U- w3 M7 Q' k$ X3 v .active_low = 0,) _( t, d2 `/ m3 B( o
.gpio = DA850_USER_LED1,
7 [% n% O, w( m4 r .name = "user_led1",& F( Z/ D/ M5 M* Y* g' K
.default_trigger = "default-on",4 p9 S4 ?, m1 ^. @% {0 E
},* K6 r; D7 u9 L& L* @! z0 Y6 |: J9 L
{
0 ]) E& [5 U. B7 \ .active_low = 0,
" ?* @1 U# N; J( U& f6 @: g .gpio = DA850_USER_LED2,
) o$ Z, _/ J3 V! J .name = "user_led2",3 E V/ ?$ W" ?
.default_trigger = "default-on",* `( }; m; e9 ] R& @
},, Y; i, c0 g- E( p3 h( D
{
! @ a: W% a2 o6 L4 W4 u& x .active_low = 0,
8 w6 k2 q2 [& R! Y7 l' d7 | .gpio = DA850_USER_LED3,
" {6 m) O9 q! m4 Z- c .name = "user_led3",3 ^6 _6 J( h/ O6 \$ H/ O% |( A
.default_trigger = "default-on", N# C# J! d3 G) _
},
- _! [# e& |6 Y" H' e* b};
: @ V# J* x8 [6 c8 m8 n
, H# C. `# O; I" \' Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- j* b3 `1 ?% g; r+ Z! A .leds = da850_evm_tl_leds,
# P9 x# l. x6 v4 k4 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
Q: n! W+ {4 q8 w2 m- K7 c/ ~};
7 c9 p Q g1 _0 m, O# Y! ~! Q
; B6 ?* \7 ^# gstatic void led_dev_release(struct device *dev)
% |1 p+ v- A4 Z& g5 ]' {2 s7 V{
% Z" T! V4 G/ ]* |' u};
$ R5 R6 V1 n3 u0 }% t }3 j; B( ~# g/ N0 z, M
static struct platform_device da850_evm_tl_leds_device = {
3 A: ~7 v& T- b; [ .name = "leds-gpio",. s& L+ u+ k, E8 {% a4 k
.id = 1,5 g4 x! m" x: ^
.dev = {
9 }& |" Z1 }4 A% t# T4 L/ n .platform_data = &da850_evm_tl_leds_pdata,9 F4 Y, k' q- t$ G! Y# C3 g
.release = led_dev_release,* d: A! Q' }$ s# I
}
* H6 w7 j0 J$ I) W};
" m5 K1 @( V0 e# \. S; y
4 i, E7 A) T8 b. t1 T9 c2 K) K" ?static int __init led_platform_init(void)- g9 `; R& [) Z* {! f/ A
{
' @3 S9 t" g$ j int ret;
: Q% ]4 K q9 o _1 v- E#if 07 P6 L( p* W. s& Q- O) E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' j( J$ |2 R9 w6 p3 |7 R3 U if (ret)
; t5 ` M! v/ c. P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, a. I: d6 G9 h/ y$ W "%d\n", ret);
) R5 @# w: p3 ~#endif- d! ]- x$ ~/ ~4 m% o
ret = platform_device_register(&da850_evm_tl_leds_device);
& |( Q3 m+ q+ F$ w% n$ V, d; Y1 c* @, U if (ret)! J' q& h) Q4 f, q) O/ ?8 C8 d) O
pr_warning("Could not register som GPIO expander LEDS");
# [+ c7 K' C- @0 l. F4 B3 C else
. `3 N% M M. R printk(KERN_INFO "LED register sucessful!\n");6 u( J9 q0 S( |5 q K) @7 {
% e1 h# h$ T0 q; G return ret;) L/ R$ _0 K- N# ?
}3 o4 S' z1 s9 T( e2 F7 C0 _
/ }, p) T7 y2 Y! d! m1 U7 `" F
static void __exit led_platform_exit(void)
7 W# k! g" u6 g. ?* k{
$ P8 V' y' f$ @. R platform_device_unregister(&da850_evm_tl_leds_device);
# K! \- \8 A- K) ?9 m. q# p4 ?( _. t( Y! E. P
printk(KERN_INFO "LED unregister!\n");5 l( ^8 g8 p5 p8 x) l: S
}2 X0 w7 \" a/ w1 G b& t
7 U0 j( e1 z; s/ l- mmodule_init(led_platform_init);
* C3 Q* I0 d4 H; k* nmodule_exit(led_platform_exit);+ |! p. r! H: D
" O: a5 v# {6 YMODULE_DESCRIPTION("Led platform driver");2 ^7 Z6 z2 O$ R6 o. ? G, b7 m/ [
MODULE_AUTHOR("Tronlong");1 z$ ^- W( f6 D% T
MODULE_LICENSE("GPL");1 \0 e$ s6 W# o$ N
+ R7 r9 U- z2 g8 d! q L- b
|
|