|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 n/ b* @ ]+ t# P4 d. v#include <linux/init.h>
" s0 ^ F1 n" Z& u+ f/ I#include <linux/module.h>
. Z& E, H" |" g1 N# q#include <linux/kernel.h>6 q. a8 D) J1 S$ P, b. w
#include <linux/types.h>+ m% h, g! v) P0 R
#include <linux/gpio.h>
2 I! y1 I, B" d#include <linux/leds.h>6 u6 k" z" E2 l, g2 L! m
#include <linux/platform_device.h>
" ]" ^9 c% M, I1 X) [! q5 h$ A2 o7 M; c e
#include <asm/mach-types.h>. i/ m& @& P( m! A2 W [
#include <asm/mach/arch.h>3 R4 Z- t8 f% J3 k% e8 n
#include <mach/da8xx.h>
# u) J3 l! N7 r4 {3 _/ _& n#include <mach/mux.h>+ e. J5 D# X% P
/ _& n4 k. |( G$ [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ U) M: m3 l" I! q: F
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# Y0 B3 @6 Q# `) b- e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 k% n8 N5 B4 d- w! ~7 F- Z- R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 `4 j2 Z0 f3 q3 Z v& u9 G
; i2 {& u$ g5 k- L2 `% }, V/ `2 T/* assign the tl som board LED-GPIOs*/7 B1 Q! _# V9 C4 P, {
static const short da850_evm_tl_user_led_pins[] = {
) B* ], f- i! @% R* M /* These pins are definition at <mach/mux.h> file */( F4 z: ^. h5 u+ c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 i, R7 V- @0 u# G! R -1
' r0 m# u* B( n* c* S0 c};6 x3 p" O6 C+ h0 n
3 F( ^# [1 n, u4 ^static struct gpio_led da850_evm_tl_leds[] = {
. U$ ?! y0 \# |' T, ^3 s6 R {- g+ v- `& s$ C! X: t1 ?
.active_low = 0, {7 }7 Y( m# E6 V+ ?
.gpio = DA850_USER_LED0,1 ]! W5 `. K# Q
.name = "user_led0",! y9 q: v) a" E) C0 j. J
.default_trigger = "default-on",
9 \- s/ T, Q. M l! |4 z4 R. H( _ },
7 l% N1 k% a R# W3 B8 ^! X5 `- s {* e5 q& c4 J& u$ X9 K
.active_low = 0,; l) R' K; N' B4 V0 T; U
.gpio = DA850_USER_LED1,
' R$ o! S4 E! R- K .name = "user_led1",
. t* B' M; d9 w4 X9 j- n3 f .default_trigger = "default-on",
* M! V$ n6 w) @' y },0 p9 s9 O! @- L! I
{. {- }6 C( I) G; D2 n
.active_low = 0,
: {# z/ x6 d$ m. s% z: h( Z .gpio = DA850_USER_LED2,& b! q% G/ _2 k' y1 q9 {, w
.name = "user_led2",
4 e1 I. t4 n- D0 H$ \* `: E .default_trigger = "default-on",
6 b* ~; W! U$ H/ F3 r& Y( i9 B },+ V% o( Y( l6 A; E! X
{
3 {, z, Z! \4 [' E/ B. R! p- Z0 Q .active_low = 0,, [ C5 M$ E5 `* A! y: v( ^: x
.gpio = DA850_USER_LED3,$ e; f6 C, {8 \
.name = "user_led3",1 i9 I' ?) @9 G2 r8 V: Y
.default_trigger = "default-on",% M6 i9 `6 s* e/ H+ [$ K* k p
},
6 T+ M% V t% f};
! G( P9 t3 X* J/ w
& k4 i5 r; t( ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! d& |% E/ g# s. I) Z% ^ .leds = da850_evm_tl_leds,
6 Q) e3 J. V% ^9 A" H/ J- h. t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& t) [# k9 d1 d: B
};" z7 D! c) }7 x# y
7 N2 L. O- }) } L7 L9 Z% W) J3 x' ~% Ustatic void led_dev_release(struct device *dev)4 G, n2 q, V7 N1 `8 A. s
{
6 I$ }! W: Z/ ^5 m};
# l5 ?: K* P* k0 \
0 S* F% U$ o9 F: c1 `static struct platform_device da850_evm_tl_leds_device = {
2 C: }: B' Q- X .name = "leds-gpio",2 Y" m9 K% \8 |; M. [% W0 M5 s7 I& q
.id = 1,( l( x1 @* z# F( \" S; x! n
.dev = {* N5 Y- J* K* i5 t- ~/ i
.platform_data = &da850_evm_tl_leds_pdata,5 Y" `" S; N7 r7 Z' H- C
.release = led_dev_release,
' q3 ?6 g# P9 e1 D, E- { }
' z& j4 [ x8 Z' P7 G& a5 M};3 g9 f' H; M" p! K B& t) D
6 h4 b& |% t/ Zstatic int __init led_platform_init(void)' f+ ]' c |3 X, }% v' O+ p" U
{
6 I1 {, S+ {! Y: j int ret;
% ]3 g8 {$ m; @2 w' a7 ~/ ]#if 0
8 O% @* B* E& @! U% W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! g% e3 Y" {& w- K D4 {& R2 z
if (ret)
8 { ]; Q8 F% J3 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 ~; m% H/ H6 k9 R
"%d\n", ret);* K2 H0 e* u/ y0 T
#endif
- N7 i' {1 t% X/ r2 k ret = platform_device_register(&da850_evm_tl_leds_device);9 b- N- d9 C" c
if (ret)
0 ?. z1 u3 M7 K, {4 x, M3 z pr_warning("Could not register som GPIO expander LEDS");
* j: ]$ M6 O6 X: V else
7 U8 W# f5 j, h* r printk(KERN_INFO "LED register sucessful!\n");( w# I" z. c* v% P5 |1 z: X
0 o% D/ I( Z0 W& C
return ret;
! ^, O" R+ h8 C: R3 [}' m# s4 z! V' f+ j7 ?
( `' P1 E6 i9 ]* C+ C4 [3 K
static void __exit led_platform_exit(void)
; C" z7 m. e: T* I, d3 ?6 O{$ L. x2 C& j1 `% X1 ?- f
platform_device_unregister(&da850_evm_tl_leds_device);- g% L0 t; m3 _6 O9 r& i: Z0 u$ s8 j
5 G8 M! f) C+ n$ K* u
printk(KERN_INFO "LED unregister!\n");
5 }3 J( k" [" j}
% }9 I" Y8 H: N4 {# K* \/ i8 t
+ P1 m7 I% |4 k& a( I# M. G9 @' Tmodule_init(led_platform_init);4 D/ E( |3 T' \8 s8 R3 z
module_exit(led_platform_exit);
0 I; z! n% h# n/ K* b9 w$ S
. k6 p8 n+ u6 r, C$ pMODULE_DESCRIPTION("Led platform driver");
0 s x6 T' O. `2 A, bMODULE_AUTHOR("Tronlong");# \- E; L& |2 z' K
MODULE_LICENSE("GPL");
; p( _$ l, w B( A' U' c0 Q5 D( h! ^* ?
, p" ?% z. }4 u$ v5 ], b |
|