|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( }6 n+ W" U! y) e
#include <linux/init.h>
+ b+ V6 Y# ]- n2 W9 ^" @, X#include <linux/module.h>
# \8 F( b' z0 B! @! e#include <linux/kernel.h>
! ?% l; u$ |' s" q$ F#include <linux/types.h>
( b l6 n3 z3 [. k6 D& [8 a) P5 C#include <linux/gpio.h>
4 Z% e! k F+ o! G$ _#include <linux/leds.h>; ^* g+ x/ d. R
#include <linux/platform_device.h>
; H1 O4 w* m' F- Q6 A( G V, h4 i* c% p8 d8 @
#include <asm/mach-types.h>$ G6 ]7 _4 g( H
#include <asm/mach/arch.h>
# g. i: m7 Z, m# ?#include <mach/da8xx.h>: P1 {! o8 {2 L& l* W3 {
#include <mach/mux.h>
% ~: A. d" W8 [, Z" h! T% {: b5 a+ V+ i% L, ?9 ^, J) h. r, ?# e% B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- h( X" V& j$ Y1 E# h* Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! S1 _* T* |. n0 j: l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' m+ x* c* \/ k0 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- j: x0 x$ K3 W8 ]' Q
$ x* w0 |& E8 T9 Z" r/* assign the tl som board LED-GPIOs*/# E3 ]4 o1 u" f( H. h. D
static const short da850_evm_tl_user_led_pins[] = {
6 Q* H( h& j: R9 Z /* These pins are definition at <mach/mux.h> file */& K3 Q9 B6 l/ N, D: b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," Q# B4 s( R8 I+ {! _
-17 X! D9 |* j- Y% F3 j7 G
};
+ ^4 ^* U) Z+ O8 u
/ x6 n' Y/ n7 O5 v$ }static struct gpio_led da850_evm_tl_leds[] = {5 k6 R- [. @5 N
{' I- {% a7 T. o
.active_low = 0,' `1 _% n" G) s, i$ _2 Z
.gpio = DA850_USER_LED0,
; W$ m) D% I1 |( u9 h4 h( t b .name = "user_led0",
- `8 S G5 i: |7 w: F .default_trigger = "default-on",
/ \6 l2 A# p; u6 J! A9 ^5 Q },
; n; e+ \( D! j8 s- J, `$ l {( j% t0 ~' T) ] u( y3 ~
.active_low = 0,) g+ F, w5 X" P. |5 c
.gpio = DA850_USER_LED1,2 S- V; f$ Y l, W+ j5 U7 {" l
.name = "user_led1",
0 D+ f1 [1 _+ Z8 m9 o) _2 P .default_trigger = "default-on",' l! u' [' O1 n3 `& h. u+ t1 }
},. D5 B5 G2 N, k( T
{$ W2 n0 K2 R& A
.active_low = 0,. L5 p6 k" L5 K+ }! l, B
.gpio = DA850_USER_LED2,
^- n" ^8 y4 D0 D .name = "user_led2",3 q8 E1 n6 K% X. x$ D1 Z# x6 {
.default_trigger = "default-on",5 C2 l2 W* p/ I. I
},6 |8 k. n5 U# Z. ^. j
{5 d* P' C$ \% t" c. A* N2 t* e$ s
.active_low = 0,
$ u4 r3 G/ W( v5 L( n4 b4 S. Y% F5 `- d' X3 q .gpio = DA850_USER_LED3,5 _2 f, d) T% W; Q+ p3 d: E
.name = "user_led3",
/ O8 d+ E3 d8 [4 |- ] .default_trigger = "default-on",( j* f0 r/ Q9 n7 v
},6 ]& ? b h- r3 D# D& |3 U: f# C
}; z! H9 @. m1 {5 D# X- Z) i/ X
* a: U8 c9 \9 x4 K% i* E6 E1 R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; G3 }% _2 n5 y; [5 u1 Q: I5 ]
.leds = da850_evm_tl_leds,
' i( d5 V7 r7 x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: h; B4 }: o J* J; a' R
};
p9 p$ v$ D5 l
6 n, q: W* R* a9 g1 z% y9 ^static void led_dev_release(struct device *dev)3 L5 n. d5 _6 e; K& A- a3 F1 _
{
( L- n9 K; B2 }7 P" [& J& g};
# \+ e; n9 g" R2 c2 E, v9 Q9 Q9 e4 E/ l! y' V5 ?# b
static struct platform_device da850_evm_tl_leds_device = {: b$ f. i$ r7 y# c; H5 f! p% \
.name = "leds-gpio",+ w4 O z( l$ S1 [9 g3 O
.id = 1,
; y3 r- K5 t7 Y. R .dev = {
. o, q6 N1 E0 e0 a& r .platform_data = &da850_evm_tl_leds_pdata,% t: u) Y, N+ }4 A+ @7 O
.release = led_dev_release,
% o0 ~- T4 \6 y: A( [( c* _ }! l ~3 h0 e0 p/ }6 k
};
3 e4 m/ y* G; \( ~( J7 B! H4 x. M* i+ W
static int __init led_platform_init(void) T- ?) e- Y( J2 e7 [
{# P' W( U0 x( E0 w* `5 |
int ret;( [- t" p3 A9 a/ |, m
#if 0% G- l2 @' u* f4 k+ Z/ \# c* Z+ |6 t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" e! X1 F1 p6 C* C- s% ?" H* `8 D) _
if (ret)" b2 h3 Q8 | w1 L7 B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 _5 y& Y8 y. E9 m7 Q' e "%d\n", ret);* O9 M- N2 H" s* D( `% I+ ~
#endif. q& ^8 V9 D4 F" }. Q2 H& ^1 d- V
ret = platform_device_register(&da850_evm_tl_leds_device);
* m8 X( B3 Y1 M9 R8 W if (ret)0 O8 g4 e% d- \& o5 ]# v+ q
pr_warning("Could not register som GPIO expander LEDS");
4 {: q5 r" W& s4 V) T else
+ e, y# c9 J( s7 } printk(KERN_INFO "LED register sucessful!\n");% \1 ^7 u7 t0 q
' Q8 U u) L' I6 S6 Y2 s4 m& l
return ret;
: _+ G& \0 a$ H w: B}
! P' A0 Y/ P5 B6 f7 a: @# K2 Z" l4 B2 X
static void __exit led_platform_exit(void)
5 `7 m7 B8 g9 t{5 u9 T8 u* o" Q. g# `1 ^& M4 K( V
platform_device_unregister(&da850_evm_tl_leds_device);4 c- f) e0 e+ {: I7 `( `# I
$ D% d) [$ c* R: g) J" A
printk(KERN_INFO "LED unregister!\n");- Z. i$ i+ p- e5 I3 [
}
# L! S0 p- {" E1 S. P9 z3 f$ @5 c& Z7 |- B" l" ^
module_init(led_platform_init);
5 Q5 o9 {7 V! Z$ Amodule_exit(led_platform_exit);
7 K# A! r+ j1 [% w5 I! q I& |- j: y; N
MODULE_DESCRIPTION("Led platform driver");7 r2 J7 R7 _/ S W$ }
MODULE_AUTHOR("Tronlong");6 M: D6 P& F# B% \! c% [ @
MODULE_LICENSE("GPL");
# Y; [ D. @5 i! E* V2 `7 b3 T
0 `5 ]7 {& O7 [ |
|