|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" I6 ^0 i, x0 W( v9 V#include <linux/init.h>
/ ?& x8 r! M5 K5 }- L#include <linux/module.h>
4 T) c) Q5 I/ I2 E( t i" C#include <linux/kernel.h>' N# j2 D5 w) X: n3 ]9 q, s
#include <linux/types.h>, p, N; S& W9 x* o7 ]# P
#include <linux/gpio.h>
+ N/ S7 d; n" M4 D& q& z0 l3 X#include <linux/leds.h>5 Q% s8 N( S$ \. y) w$ L
#include <linux/platform_device.h>
; b3 B P1 X4 i5 `2 C
1 B, A0 F& [" C- J) U" `. Q#include <asm/mach-types.h>
2 N( @# [$ O: d* {( I, z#include <asm/mach/arch.h>
O3 ^( ]$ r5 E#include <mach/da8xx.h>
3 l+ P6 s+ k% l9 ~, E! P: L% `4 S#include <mach/mux.h>
/ R, a. ]5 H) b1 }
# r/ D9 H8 p- s' l* W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 k' e# i7 u* E0 [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 O) }8 G. h, ~! F9 J6 g. x6 g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! ^0 c6 E( i- Z) k$ x' Y4 @' S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 \8 A3 {0 P1 W
/ V. J( s/ N( j# A- |7 i" ]/* assign the tl som board LED-GPIOs*/& Y- K9 V5 O5 w! E# S
static const short da850_evm_tl_user_led_pins[] = {! ~6 U8 \( K* s
/* These pins are definition at <mach/mux.h> file */
. A# `) b2 @* g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& W2 y: D/ T7 Z- _" v D2 J# u7 Q -1" ? M7 Y6 Q8 A# g8 `. F; U
};. }; ~6 ? i& B3 h
: @& }$ s, |8 V. ^3 Mstatic struct gpio_led da850_evm_tl_leds[] = {
2 h" x1 U3 B, a+ ]# X2 j {. w3 O# r+ {: {7 A! x
.active_low = 0,
- u! N, L' R. r7 Q2 C1 r .gpio = DA850_USER_LED0,! j8 t3 Z1 I0 V9 L- G0 T7 g
.name = "user_led0",0 P& s! L9 K, }4 ~- j5 J) |
.default_trigger = "default-on",4 m- ]0 B2 P$ r9 U& e( {
},! g9 C1 S7 ~2 ]/ |5 g7 w! n
{2 s; {# j9 G2 n- @* o! e; h9 s2 c
.active_low = 0,
$ e/ \- z) h. W- P" V* @: i .gpio = DA850_USER_LED1,
$ }8 }, F3 u7 I% E4 S .name = "user_led1",
: z- b4 r1 M( c N6 ]4 ~ .default_trigger = "default-on",6 X; n! }7 ?( R, Z f9 c6 o
},
# P: H0 C$ L4 J+ G {
2 J; I7 m( q: I& J" F; Q .active_low = 0,) _# A1 @; B6 Q \ v
.gpio = DA850_USER_LED2,- G5 X; _8 b; @+ ?4 s8 k
.name = "user_led2",
# v% {0 y1 w- S$ s- g .default_trigger = "default-on",
& }! O: |# {/ b9 r },
$ K* H. I- B4 m# t {$ y( o" a3 o" o0 d& w2 V9 ?
.active_low = 0,. l& l7 ^; d$ W+ t
.gpio = DA850_USER_LED3,
" N# t( y$ H1 b' ~: w+ M6 d5 b .name = "user_led3",# I! D- c/ q. k3 }
.default_trigger = "default-on",6 T4 J( V* @% e1 q% c
},
# C1 I( u, m% b4 S8 v};
9 ~& d# `& @% u8 g9 T$ I: O4 l% p
: C: w9 V$ G4 M7 ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 v8 x8 j- q" r .leds = da850_evm_tl_leds,
, P: p& L- K4 `* {. ]1 l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ P* u$ Y" P! t- A: I( p" b};$ c4 F S% b% ]0 h% e2 t9 w0 u
3 k& Z* A* E1 H! estatic void led_dev_release(struct device *dev)" O8 U+ F9 \, y+ B
{+ Q. h, M6 Y& ]5 D% i6 [
};
) b' o# D9 z4 O9 k/ y7 ^* w! x# R0 Q1 V( Y! X
static struct platform_device da850_evm_tl_leds_device = {5 d0 s/ X# f7 z+ c% ^' k
.name = "leds-gpio",
! l* a+ t! u) P, Y .id = 1,
# R2 @6 P& d2 z) e% m+ o, e .dev = {
) h/ y7 c# u" x) e/ q# O2 G( ^ .platform_data = &da850_evm_tl_leds_pdata,
: b# H& w3 I8 l0 R) n0 i .release = led_dev_release,
, z4 a! j5 x) B1 k! X7 n# A }; c. s2 t! Q2 E
};
7 U( |4 }- D9 A5 M# F- b0 `9 T" y
static int __init led_platform_init(void)
" n4 s5 i1 Q% j. z{
0 V+ Y. w. O1 W8 b int ret;! T/ p4 D: S! c2 u$ b! w
#if 07 A0 a* }# p( C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# N2 c, q E" e- Z( a" r
if (ret)7 j' c# k' l7 i! S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 E B* N, ] Q3 q& A( S+ B
"%d\n", ret);( o# O3 v9 S, V
#endif
7 W2 j4 e: B" w- }/ r( x ret = platform_device_register(&da850_evm_tl_leds_device);5 L Y3 z# R; m: X
if (ret)( f( `" \; u0 X# z
pr_warning("Could not register som GPIO expander LEDS");
7 Y9 @0 i' | \1 J else0 a" `+ @" P: [7 l: ]& n# n5 U
printk(KERN_INFO "LED register sucessful!\n");# h5 E$ J T" ~ j
* R( R$ l0 E( v9 S return ret;
5 B/ J2 [& J8 m5 y" v}+ h, l! y+ S" [9 t5 s
0 ~ T4 [% ^4 S9 J( e4 q
static void __exit led_platform_exit(void)( G# ~2 E1 B1 Y% ?+ H. u
{
2 z6 }* D- h( Y5 j$ x: L) P platform_device_unregister(&da850_evm_tl_leds_device);
+ A" ^; r- B7 ^7 z7 D) c( \" `5 J8 B8 W$ a8 K2 j) O, |
printk(KERN_INFO "LED unregister!\n");
* x1 L2 A1 q, k! `/ p/ m$ m8 m}! a; l* N. t( d! h! k& a
* e' j1 H# B0 f6 B* M0 {module_init(led_platform_init);
e/ ?* _$ t( z% I' \3 Y9 lmodule_exit(led_platform_exit); {" n' C* s/ b! _$ M
0 V$ h2 o6 P- h6 r
MODULE_DESCRIPTION("Led platform driver");+ c8 p2 E7 _8 _3 x4 l
MODULE_AUTHOR("Tronlong");
. \8 d# i# T. l( T( Z8 b! QMODULE_LICENSE("GPL");
* P. `' C$ `1 f* E q1 R' {$ A9 W* x! A3 u; c
|
|