|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 V7 ]- E4 R' l; q5 }1 o#include <linux/init.h>- \+ g; m9 r8 `* |- Y; q, ~
#include <linux/module.h> I6 S. B) V$ m. h+ U2 S O( y
#include <linux/kernel.h>3 ?8 {% c3 ^ G) J
#include <linux/types.h>% T: t6 E, N, c$ k
#include <linux/gpio.h># G/ N+ T3 ^4 `
#include <linux/leds.h>5 v% F2 y. ~! x+ c' \
#include <linux/platform_device.h>, }2 `6 \" E; [7 R1 i
% A5 X/ B( C1 n$ m#include <asm/mach-types.h>7 ^1 C" @" ?3 U) ]; {( s8 c
#include <asm/mach/arch.h>6 K/ Z+ W' m+ C& ]8 [
#include <mach/da8xx.h>
' u, I" z9 m3 k: |% X#include <mach/mux.h>" f" b4 `, X2 v6 o, I) z; A
7 [$ s- q0 @& w0 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' o" {8 S5 a* I6 V, g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- S6 K9 S7 E3 P/ w" k* I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 M+ i* _0 T+ ^3 v0 I% {8 S% y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% }. t( m2 N8 O6 e! D3 x2 g4 v7 u( o' k% g6 D: v" N/ I0 b! q
/* assign the tl som board LED-GPIOs*/2 Y' @& N/ E5 _( N
static const short da850_evm_tl_user_led_pins[] = {' f3 M" `# g/ I3 t3 s
/* These pins are definition at <mach/mux.h> file */
1 K9 y* g/ {. l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 k2 J# E" {9 w' T: L -1! z. K! _/ L5 I+ R& A! E- h
};( [: S% n9 S. p! t& `
. i2 g# t. Q0 W$ s$ K5 ystatic struct gpio_led da850_evm_tl_leds[] = {/ s) C- l; U1 Z" J+ S
{
0 W% ^& v* C7 t0 v% J .active_low = 0,
( M% \) w# h$ Q7 [: X7 h7 a .gpio = DA850_USER_LED0,
5 p+ ]( q% K: V* n$ Q .name = "user_led0",
( `+ b# Y m% k3 Z( U! e .default_trigger = "default-on",) _, P% e' q9 q' Q$ f
},3 I5 f C- x t/ j# p7 \
{7 {, G' h+ T/ `# k8 y
.active_low = 0,
1 S# R4 x4 ` m9 u. q- q: F .gpio = DA850_USER_LED1,
9 v! s) b U* B" F% ~. T: R .name = "user_led1",
) d- }4 j9 n/ m4 B3 J .default_trigger = "default-on",4 [% \- V4 z6 X4 b! g) s
}," E; o* t: f ]' [0 S1 r) R
{
$ l% @) C- h |3 {) r7 L .active_low = 0,! F1 M$ {2 \6 }! o8 l1 s7 M
.gpio = DA850_USER_LED2,! m( Y( b7 }9 c* s$ V
.name = "user_led2",
) c! @7 i0 J V0 k1 `* ? .default_trigger = "default-on",
7 h- }: b1 B0 B4 Y! X5 { },' g1 ?! x0 z! R' N# s
{
( ?) T2 A1 I# n p/ O, S- X .active_low = 0,) x3 O# L6 k7 \0 l# g' ?
.gpio = DA850_USER_LED3,* k$ b$ U! ~" Q2 c, \! c2 i
.name = "user_led3",; |# O- f' N) V& b( a" C
.default_trigger = "default-on",
, P# I8 N" i* g; z# q: e; e7 G },: D+ c6 d+ _5 d- U$ x* Z; E
};
" C: a$ q$ y$ p V2 K" [* \. ^% t+ I4 d& i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 a y2 V( v1 x' K
.leds = da850_evm_tl_leds,
* f% p5 c" v) b5 I6 H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ C, {+ x* @, F};: {- t" ~0 a- v$ W/ l# e
1 @& I$ r8 c7 S$ K
static void led_dev_release(struct device *dev)
& D% _4 \3 m0 c: ^/ m+ K4 Y4 o{/ J6 ]: ]. w% s) x: U0 H# C
};9 Y3 r3 M3 u& ~) G8 k
. x( K$ |; O$ S+ ?- @# pstatic struct platform_device da850_evm_tl_leds_device = {
4 T. U# M7 `* B3 x3 r .name = "leds-gpio",2 l5 |( q: Z6 @
.id = 1,; }$ v& q- H8 M. h$ Q
.dev = {. d: u4 T/ _3 Y t) U
.platform_data = &da850_evm_tl_leds_pdata,5 g8 C' U( g* d: F5 l
.release = led_dev_release,- p% o4 Y9 z; b) T! d
}
- I& ^/ X* y- C* e4 q; N}; ?% a8 ~3 X( V' ~+ n7 j
. m) }4 g6 y* G( P: x- }0 P" S
static int __init led_platform_init(void)
7 c* P$ M) I3 J& F5 S# O' @ U0 @{; s' L3 I! y9 [
int ret;
, r1 P9 x8 v: O#if 0& c' U6 w- z& S3 G: F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 A! t/ G( o9 l* T7 f' L$ F if (ret): ?3 i. A/ g' c3 w( x6 z7 {: ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% M% B& c, [* U- [1 ]; F1 X3 c
"%d\n", ret);
( z7 D! w. T. p7 [" [#endif
5 Q* [& R; M& {# ^' `& J3 m0 R ret = platform_device_register(&da850_evm_tl_leds_device);& `7 t. C9 z1 l `) x( w
if (ret)3 X) n9 W: I7 V# h0 H* W
pr_warning("Could not register som GPIO expander LEDS");
; Y4 W, [2 K7 h1 a else/ y' {" C. `9 e# A6 `7 q. j4 K* c
printk(KERN_INFO "LED register sucessful!\n");' Q+ d' N! W+ J* _
2 T7 ^9 _' s, P, s3 K. l
return ret;
6 f( J9 u- ]# U& Z}) p2 [& d. N. O+ I% _: D; D
) d# Z9 @- T$ Z! c( B" B/ d
static void __exit led_platform_exit(void)
+ b4 {1 l; c0 c+ L8 e5 s/ C{9 }4 k/ l! A1 m0 R+ L# k
platform_device_unregister(&da850_evm_tl_leds_device);
3 E/ r% E5 Q' [! x M$ v6 U7 V% B4 r. e) n
printk(KERN_INFO "LED unregister!\n");
5 O- {8 Q) j- J6 l( I}- f" z$ h3 e d/ q! m3 C: u( |/ s
- n6 F! a1 L1 E3 u. i
module_init(led_platform_init);# [) V/ M3 z! h! j" j
module_exit(led_platform_exit);, h' Y2 i* {+ Z V$ i! ?
3 \( m% ?" n& V0 L# z9 PMODULE_DESCRIPTION("Led platform driver");
8 v5 m A. H6 uMODULE_AUTHOR("Tronlong");
4 p$ ]3 m) g8 |! yMODULE_LICENSE("GPL");
9 ]$ c' d1 |6 @4 q) A( u8 R6 {6 D% ?5 g+ _
|
|