|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ R8 j! u: u3 p, Y. n H8 ]( A#include <linux/init.h>) X: \5 j; c( A5 k+ u3 [
#include <linux/module.h>
7 P; i0 k+ Q! V: _; q- o0 v#include <linux/kernel.h>
! j- u% i& k% ?( g8 w#include <linux/types.h>: ?, e# i( f3 @. ~4 P, t
#include <linux/gpio.h>0 x( `+ j$ I! G* w y
#include <linux/leds.h>- ~* s! N* f8 W2 [
#include <linux/platform_device.h>$ ]3 ^+ h2 H7 M0 P$ O$ N9 Y
+ E$ `' k5 m3 g# V) ^#include <asm/mach-types.h>3 m+ c6 J" i8 P# G4 Y& H% l. j
#include <asm/mach/arch.h>! V/ {6 b! D+ Y
#include <mach/da8xx.h>1 r% |1 g# Q; |* M3 x, E; \1 ?
#include <mach/mux.h>
% L4 d: t- a' A9 V) g% ]8 H
0 n7 W! m( A9 A- P$ v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ {8 F) n/ f, s2 j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# [* ?/ b) r8 Q! d" }+ b/ e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 i0 o! y( o. b1 i/ @* T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# o6 H. x4 F7 e0 W# ]. c
& ~( O) r) V4 {! D3 c- ~8 n n/* assign the tl som board LED-GPIOs*/
4 ~8 o: Z i7 m: estatic const short da850_evm_tl_user_led_pins[] = {8 \- J4 \5 }8 [3 t4 `
/* These pins are definition at <mach/mux.h> file */) o( H |, ]% I$ A; `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 C5 l; k% A. F% |" D6 V -1. z) x d7 i2 |& N- l0 T
};% s8 o# d' }4 K" T! d
; x4 M* Z- F' L! J8 lstatic struct gpio_led da850_evm_tl_leds[] = {- t, c% a/ {4 N6 X9 k0 X p# {9 A
{, t% i6 Y7 V: y. T* Q
.active_low = 0," R3 P+ c( _! g4 ~" y0 D
.gpio = DA850_USER_LED0,
! ~9 _) [/ h8 e6 L .name = "user_led0",
. F3 |* G0 R' o+ F# T3 P, C# I .default_trigger = "default-on",8 c, J" J, I) o8 r& S
},/ t5 A' M6 j& O' H4 [
{
- R( t0 `' D3 j9 p .active_low = 0," G# _. D# N) j; r2 b4 `* H' q& d
.gpio = DA850_USER_LED1,; N1 d* T: q- d
.name = "user_led1",
1 f- y2 T2 x( r/ P .default_trigger = "default-on",
& W9 K9 }3 p# i$ ?- l! F3 S },( I7 U5 A9 ]. v3 H
{
! w4 R" l2 K+ s9 n; N .active_low = 0,
" ^' D# [8 h/ k7 D .gpio = DA850_USER_LED2,
' |- w" _# d! S8 I* x, a: S .name = "user_led2",
3 }; `* \; C- w .default_trigger = "default-on",
# M0 y9 i/ j, a% c0 \ },
2 q# k; l8 T8 ?1 @) u; ~+ A) d {
2 p G! q I7 a' N' s+ b .active_low = 0,! U, F# \& i; M" g
.gpio = DA850_USER_LED3,' A/ v* q9 o& Y2 N7 S1 ^; q, y
.name = "user_led3", X6 y8 o& H Z1 D$ b
.default_trigger = "default-on",
, ~3 j. l/ b( l# Z) ]% j& H2 w },
1 g& I$ p8 t8 W1 H0 V};* U" [. G; _ M; ^/ o" C) r8 A
0 j1 X* S$ u5 F8 y+ H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" \: o9 q5 j+ }- q' k0 J .leds = da850_evm_tl_leds,. g/ S: G K2 @, W( W6 `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 _$ S9 S( f+ @};
8 e# v/ p* D) U2 H4 W0 S$ d! E' G o7 q* A% n, K1 d3 P8 ^
static void led_dev_release(struct device *dev), v- d' i4 j. L6 d7 K$ Q# A! p
{
U7 C7 u- D) e4 I0 |};9 P3 c6 D5 p. c8 m+ u
8 a3 S; f. n* v+ a6 O
static struct platform_device da850_evm_tl_leds_device = {7 K E+ z! _/ p9 f
.name = "leds-gpio",
$ Y1 @& c7 w' d& I' c' ^6 H .id = 1,- f$ b# V8 p* D. d/ M
.dev = {9 a Z4 B; ^" e2 D6 w: D( `
.platform_data = &da850_evm_tl_leds_pdata,
5 Q& c; C+ F9 n |% ` .release = led_dev_release,9 m2 |2 ^3 ] H( |- v' i) a
}' S: n$ C% g; e6 E2 ~& ^5 ~5 k- j
};0 X2 a1 Q* A# _' q
5 Q/ ]$ U: j1 G6 o$ ~2 b H% i
static int __init led_platform_init(void) c0 o. z$ v1 u: ?1 J2 V$ T+ i
{* ^* J- W, C% Z) ]' t3 B& B
int ret;2 g% y9 Z% c4 o' Y: M E/ b
#if 0
" k$ V0 ~& d; N! L) Z s2 ~) d: H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' j! N! }0 g& r& s: F8 p0 h3 {, n
if (ret)
; Q1 b4 n) z% l* Z: a- J4 y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 R' g- h" H7 E; l4 ]# @
"%d\n", ret);
0 J5 a; ^$ h! E$ X#endif
8 K0 v# O' U, N2 F; I% K' u ret = platform_device_register(&da850_evm_tl_leds_device);
4 q7 o/ M- A4 e6 T s if (ret)
$ m# z2 F) m6 Z! i/ E9 t0 f pr_warning("Could not register som GPIO expander LEDS");6 F V9 @; Z* Q7 ?1 A+ w
else$ S! h& d) k+ U5 Q4 Q5 e2 N
printk(KERN_INFO "LED register sucessful!\n");3 l5 \- W/ D# G, L: b9 b9 k" K
' p5 s) T( p3 U3 S8 P+ g) d
return ret;
- M6 Q4 D0 D% O* @5 W' b}: G) _* \; x2 O {% W" }
+ C/ w, a! M3 _1 `, bstatic void __exit led_platform_exit(void)
F9 f. U* u, w( {{% j& [9 k) {" G x
platform_device_unregister(&da850_evm_tl_leds_device);9 V3 y Q M( R& E$ G' S; C% g6 m! C% _
1 g) A4 }- _6 B2 l
printk(KERN_INFO "LED unregister!\n");
e2 e8 k7 n3 x0 ~# [}. T, _2 ^6 H3 l. J S3 ?& g! n% T9 G
1 g: ~% w; w4 `! K& e& w% Qmodule_init(led_platform_init);
9 y2 `2 ?* p/ A* `0 o& Tmodule_exit(led_platform_exit);, D" @, _. W( o3 h
; t+ C; V! v5 L9 s) a: M
MODULE_DESCRIPTION("Led platform driver");* } L; E2 n5 y" D/ w4 w
MODULE_AUTHOR("Tronlong");) v- @8 x4 D- x7 x1 H; T3 z/ x" V, ], W
MODULE_LICENSE("GPL");
% T$ j* k, K$ D& V( e) \8 v4 }
& R. L( J5 ]6 g3 a3 S |
|