|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- N9 | b5 _1 M
#include <linux/init.h>9 ?& a X. }: ~9 L
#include <linux/module.h>
) z( G+ g8 B0 s- h. z3 b' [#include <linux/kernel.h>
. I1 \- _. f) I% d5 G {#include <linux/types.h>
! v* h% B b4 P/ p v$ ?" f#include <linux/gpio.h>5 K3 U8 N4 W" |# z$ V
#include <linux/leds.h>
l+ h' x% g! n9 f/ ^% N3 b1 I; Q#include <linux/platform_device.h>, q0 T5 L, r; Y& _
S' U0 n1 k3 J7 u. y* M* J#include <asm/mach-types.h>. N* K' s% L8 F
#include <asm/mach/arch.h>
0 L# S; w v; v3 M' A$ o#include <mach/da8xx.h>* I C5 d% `9 k! a9 n; q" _
#include <mach/mux.h>
+ q3 j$ b, a; ]) G
. B5 H/ X" Q, p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 q/ m8 r8 }; k# K+ d) W8 b6 g- w2 E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 {3 K: G0 L* ?6 W: K; l; Z1 h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) e' e# ?$ Y- [4 ] @# a* I& {( V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( R3 V/ J! w' w" s( O; m8 B2 k; L3 q* K( X" d
/* assign the tl som board LED-GPIOs*/# R b# E% k5 l% s. y$ n# \
static const short da850_evm_tl_user_led_pins[] = {3 n- V4 B$ U+ V2 Q6 F* ^
/* These pins are definition at <mach/mux.h> file */
, ]( q7 `/ z4 { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: [1 E8 C' P5 u# {7 ^; m -13 D% y7 ]' `: e6 Z. x$ X
};
% M+ B0 B$ `. A, M, h/ H0 i
$ D7 z" ]( [3 I8 ]) |7 W0 Tstatic struct gpio_led da850_evm_tl_leds[] = {! ~' w% A) ~/ ^/ y- u9 q' Y' `
{0 J6 c- X7 K$ q Q7 Z" |3 G W
.active_low = 0,3 ~* v7 f1 P3 y2 k# @1 g6 b
.gpio = DA850_USER_LED0,% U" H, \6 ^: M
.name = "user_led0",
# c L/ E) I, \* r .default_trigger = "default-on",
" H9 U% H' I/ E$ t/ G$ l, ? },
+ U" F1 a, m8 Y/ S' }8 j4 _. [- B' b {: f! f& U3 P" y/ @/ R
.active_low = 0,
7 p/ s, c. j) ?# ^7 z5 x" F7 x; w .gpio = DA850_USER_LED1,
% `5 v) t* {( N; t .name = "user_led1",
( n, K H+ R' u+ X9 g& G .default_trigger = "default-on",
( `& J+ `- m& O* a7 q },/ z6 o/ U$ t$ Q9 T; _
{
# { s, v) N# z2 c2 l .active_low = 0,
8 R, Z+ Y* ?! A .gpio = DA850_USER_LED2,+ ?$ ~( d2 N6 ?" g9 f/ Z
.name = "user_led2",8 a& W% u+ C$ n! B: b k, b
.default_trigger = "default-on",
0 C' T' S# I1 W; ~9 j: l$ Q% @' b },
# N: a: [/ i8 b* q1 E; B) a {
/ W/ q- G3 r, t3 e s .active_low = 0,, {4 T% N7 v* }
.gpio = DA850_USER_LED3,
( F- w* y1 J" q4 K% L5 {9 @ .name = "user_led3",
+ A2 q1 `! ~+ f" v) T7 q. l .default_trigger = "default-on",7 D; _& P& F2 Q
},
" R: S4 w5 l& E' s$ o4 V1 G) Y7 \};2 w! I( _% N2 n7 C! x
( A5 {6 j7 M5 q" n4 l* R& }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 G. p4 h; v6 O5 g2 @( w
.leds = da850_evm_tl_leds,
4 e- a0 M/ `6 O+ h; I$ _# S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 c4 L/ N$ r# D9 c& R};0 ]% e, ]: V0 t
M/ @6 c6 c' F9 J1 Bstatic void led_dev_release(struct device *dev)+ j+ m* {+ |, I- e$ J" K. y& ]
{
) L& ~3 d, |6 t% h* K/ C};
, o$ f) n1 A% e/ o( X8 o
( u y. u3 S4 o% m! ? B$ C, mstatic struct platform_device da850_evm_tl_leds_device = {) M2 E0 y$ i2 {/ K) \* j r
.name = "leds-gpio",1 G9 [* J- l3 I. g% P
.id = 1,
8 x* M; K: k3 j1 Z( j! R- p" i .dev = {1 M1 ~! W. c/ g0 q; R2 ^
.platform_data = &da850_evm_tl_leds_pdata,
/ j0 X2 Y. l* [5 {9 z5 Y) { .release = led_dev_release,
+ s, G4 P- [2 t n9 b }* Y( y. x# q; W9 v; X9 e+ V- p
};# G- i4 }) O+ M( D
) ~# Q! ~# q1 ?0 P3 p1 r' Wstatic int __init led_platform_init(void)
, [! N# S6 ?( \9 u5 R6 A2 Q{
; C! b, w6 p m9 C- n5 @# @+ @* p int ret;
2 T, F$ [6 }1 R( M% ?% m#if 0& e5 B7 A+ T6 k- A* G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 X5 E9 b( a, N/ ]
if (ret)
( e' Q7 F+ g7 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# d% d) Y& _5 L1 [0 r "%d\n", ret);
r- r; K5 }$ A9 r' B& {) s#endif0 A" U8 o! E& C" f& s
ret = platform_device_register(&da850_evm_tl_leds_device);6 [% Y: D! c3 h+ p
if (ret)1 c3 @5 J1 O$ c2 ]( }& U3 f
pr_warning("Could not register som GPIO expander LEDS");
5 u- {) a1 ~7 k$ a# o else
5 L* T1 r2 M4 L0 s; }1 I( O, d6 `6 e8 h printk(KERN_INFO "LED register sucessful!\n");3 T! J( N- i# }7 @8 q! S
2 r% }0 o" g4 {" p return ret;! B. H+ y3 Y3 Y
}2 A4 x4 {( J& m7 ?
; S* c5 g8 ]* H7 H! p8 u
static void __exit led_platform_exit(void). W( m1 [5 C+ f5 _ E1 N0 C
{7 f- ?. @7 ?7 o4 W5 h. H1 v
platform_device_unregister(&da850_evm_tl_leds_device);! m/ c- d8 O) [
0 \/ m6 X8 z" g1 n, L printk(KERN_INFO "LED unregister!\n");
0 R( n+ f/ V2 O# A0 w}9 F! e6 j: y; |* `
: f9 Z/ \6 _% F+ `- R2 @$ hmodule_init(led_platform_init);
- E* N; t+ X! D# R6 T) t, Kmodule_exit(led_platform_exit);0 ?; N* o) z8 C" z" ]' S
4 ^2 \6 M+ ~; U' J
MODULE_DESCRIPTION("Led platform driver");# b' M5 L' f% F" _+ L( C$ ?" j
MODULE_AUTHOR("Tronlong");
. q! l/ o# `' a% ~' Q: P, FMODULE_LICENSE("GPL");7 \( w3 V- R7 G" p8 B" L8 w
* J% V) T2 Y) G
|
|