|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( O( A9 P, ]$ Y1 X( E( _
#include <linux/init.h>
. c5 m6 b. }, U8 N+ ?9 k5 ~#include <linux/module.h>
) O3 R! r+ k8 M E#include <linux/kernel.h>3 V" {# S* n7 Q
#include <linux/types.h>4 |* \; V, E! k+ @) P* R
#include <linux/gpio.h>
+ S, E9 _5 u8 G#include <linux/leds.h>2 l5 {6 H# J: c5 A
#include <linux/platform_device.h>+ N: |) D# w9 X- k9 u i) d/ f; F
' c6 ]# X( s% p, Q& G- r
#include <asm/mach-types.h>
# q0 Z. D: l3 C$ m) x8 K& X* f#include <asm/mach/arch.h>
4 t2 T/ X/ w% `% N w#include <mach/da8xx.h>! z# }/ ]0 R, f. O# l
#include <mach/mux.h>1 [; d! o2 G! t+ @* R& R- l: W
; k( A9 m8 J b8 `1 K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 R" S- w( M& A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* n8 p. X# l% v! g! c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' `( x5 v; @* w# k+ n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' `2 V3 X- o* t6 \" b' U7 k6 A& g0 y' }( g+ x( T3 X! [' w( ]
/* assign the tl som board LED-GPIOs*/
9 i% @# N2 b4 }9 Wstatic const short da850_evm_tl_user_led_pins[] = {2 P! u2 V7 m$ n* W: B0 l" O" J
/* These pins are definition at <mach/mux.h> file */6 ~4 t) D% P# w% [" f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% U9 d6 q4 h. i. g -1
( A4 W% |6 t9 y! i& c: t};
3 r7 Z5 J" w6 K) S }
& }' D7 n( i2 `) Z* c' C% d/ Ostatic struct gpio_led da850_evm_tl_leds[] = {
{9 s# l. y* G" u, n0 | {
' `7 g% I2 G8 R- I1 x( B; A4 t$ ?- M .active_low = 0,4 O7 Y/ G, z. f
.gpio = DA850_USER_LED0,& p1 o; f) q& l
.name = "user_led0",+ Q1 S8 k# `" k5 d; X
.default_trigger = "default-on", D+ t: |, B# i3 [' B9 ]$ P/ {) C2 K
},5 K# e$ N: B4 p4 f% c- c" K
{
/ o* I& s8 \5 s: j9 S .active_low = 0,
. r+ Z! I1 P* f6 X4 R! O4 |% K/ t/ U .gpio = DA850_USER_LED1,3 n J' ?' ]. }) Y; V- h1 }
.name = "user_led1",
4 i& _, q- B' P8 z/ Q .default_trigger = "default-on",. x @" b* a' i- ]. h. r- |7 p
},! }" W9 [+ q8 n- f% K( h
{
* k; g) o+ m) o0 g! U .active_low = 0,
2 _! V, X8 B. U) S' o .gpio = DA850_USER_LED2,+ a2 b! n- P% Y$ D; d
.name = "user_led2",
1 D5 c5 `- Y+ Q; I, U e .default_trigger = "default-on",! e0 V9 e2 T5 j! [ ~
},# G8 ~- f* t( B9 F: E7 _5 i0 }
{
$ i6 x# l5 P C3 G7 h1 A .active_low = 0,
& y. {1 S$ h0 P9 y1 q) Y .gpio = DA850_USER_LED3,; H! y/ ^! X) T/ V- q& Y
.name = "user_led3",- |7 P* r1 |/ m
.default_trigger = "default-on",8 |: T2 Y- M2 [& o* o" s
},6 w3 ?4 s6 l9 n A
};7 q% E4 ]) }5 E# R2 T
4 n' G' P: E# G# |5 X) H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 m4 U: I7 Y ^- J; k
.leds = da850_evm_tl_leds,
+ F& O. M: A. q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& D3 g8 k8 _0 k9 [# ~& M% t8 ?};
; Y7 F! ~9 q5 W
( Z2 F' t) E% H7 ustatic void led_dev_release(struct device *dev)1 S7 d: ? e1 \
{$ T: c8 E; J* h0 K2 a( i
};
% {1 L8 O1 ~* @8 d6 m8 B0 I8 Y' @' h- ^
static struct platform_device da850_evm_tl_leds_device = {
: }1 o! e$ j7 s, h .name = "leds-gpio",4 I$ v# S& n: r! W8 x5 o
.id = 1,7 s# J# n+ q0 U5 B+ {) A8 F
.dev = {6 L4 g6 h; L# n. p
.platform_data = &da850_evm_tl_leds_pdata,
?# I0 d5 e3 N! M: G .release = led_dev_release,: T9 L( N& c$ v! m! R3 |5 R( w/ d5 n
}
+ @" ~, K+ r, V' z6 p) }}; N) `5 a. X( J! J; W" L
. j- l% R# S- G! D, I& {% c
static int __init led_platform_init(void)
5 b* p \$ [% X% b$ u{$ ^" d6 Q- A$ z
int ret;
7 ^( ^& C) M. m' Y& l# c#if 0
% ~3 g8 c0 `5 Q/ D6 E8 i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- @+ b2 A6 u5 S: Q+ q5 Z if (ret)
, J/ g" a. K' P1 ?# k- O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 G: T- _ X+ i) Q: ~! g "%d\n", ret);, d9 Y- g8 ?5 e$ J% p) e( U
#endif! o2 ]& Z( I7 j. C
ret = platform_device_register(&da850_evm_tl_leds_device); j- h3 j( G2 \5 V$ [! u( J* t
if (ret)) G7 c- R7 L$ I! X. J' m
pr_warning("Could not register som GPIO expander LEDS");3 h: A8 u6 d* x' T
else+ a. e. P) A0 ]9 E
printk(KERN_INFO "LED register sucessful!\n");
2 [% D; B. h/ N8 ?( P. b
* P1 d- ~& ^2 _1 U6 ~: ~ return ret;" }& b0 x/ q$ H8 Z
}; v1 m* M6 h3 R* A& R
' V4 v. ]7 n! _ E
static void __exit led_platform_exit(void)
* [ h4 I. L6 B {: N{
( x1 o! \0 Y1 p8 S+ u+ a platform_device_unregister(&da850_evm_tl_leds_device);
* b. k0 |5 u; @
3 v% e. e2 a9 T printk(KERN_INFO "LED unregister!\n");
% V" F5 F: A9 y" a2 V. F; M}
$ L# L7 N/ O; u7 x, {$ e% \. {7 g
module_init(led_platform_init);
% z$ t6 o/ Z4 ?2 d% G) ~module_exit(led_platform_exit);
5 y+ S, ^9 f+ `3 H# D" d z
! t) C3 b! f' r, YMODULE_DESCRIPTION("Led platform driver");3 l, o, \' Y5 B2 h
MODULE_AUTHOR("Tronlong");
8 { n( w6 V+ c3 k2 yMODULE_LICENSE("GPL");
7 A* p- U, S! H3 p( g; c e# M# B5 G
|
|