|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 {& S/ r @- @% {5 l( k#include <linux/init.h>
) ^, j$ T; y/ q0 ?6 o#include <linux/module.h>
( K/ C5 c3 d; S% l1 A5 u7 b0 O% u#include <linux/kernel.h>
+ B' f0 n2 R9 b* l, j( M#include <linux/types.h>
1 E+ b, ^, D& H b. U3 }#include <linux/gpio.h>
- L4 f# r* F$ Q2 N4 M5 g7 E. W#include <linux/leds.h> g) D' f; P6 e" h9 |9 Q
#include <linux/platform_device.h>
7 m l4 |9 K ^$ n! u" P$ ]
; ~! b7 y, V# c6 ^#include <asm/mach-types.h># X% k/ C/ c! T
#include <asm/mach/arch.h>" B$ L8 R$ Y5 g& ]5 X
#include <mach/da8xx.h>+ Q& r5 f2 B2 q O7 ~; o9 J
#include <mach/mux.h>
5 O5 [5 a( `+ j% e* M H9 X, }
% ^5 k+ }9 h5 z- r8 n% S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ j) X1 r0 c- |6 ~/ C#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 E# r1 U2 W, G+ h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); R' N; z2 ~& w5 v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ @, q, g8 P+ O; G3 F
- P" v0 Y" ?, V9 [9 E1 R( S2 ~/* assign the tl som board LED-GPIOs*/
& J. L1 c6 l: A' Tstatic const short da850_evm_tl_user_led_pins[] = {
' M& K$ T9 e: E3 B9 | ~2 w2 r /* These pins are definition at <mach/mux.h> file */
- G7 f$ I/ M1 J8 Z( b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 F, j, L4 n# c0 s0 J, N9 p -1
& d" d4 W! T2 A4 v: G9 {};" d" Z$ D/ y0 U7 x7 _
6 c3 u1 W6 w/ C9 e+ q9 gstatic struct gpio_led da850_evm_tl_leds[] = {
& L% J/ x; j; R/ N3 ^ {& p+ z9 F$ l% d; R( {) d b
.active_low = 0,
& E4 ?( W" b* E+ w7 t .gpio = DA850_USER_LED0,$ N6 {/ S% q1 v- n# _! w. B
.name = "user_led0",0 G# J1 W! e4 ~# |# C
.default_trigger = "default-on",$ J1 `, |4 P- L/ ^4 s
},4 Q# c9 j! L$ @7 N' }8 s
{
l5 w2 f& [# ?: X .active_low = 0,
& y, A: a% P* p6 o g- b9 S t .gpio = DA850_USER_LED1,. p/ k7 E: K8 q* t1 X- s
.name = "user_led1",; v; k0 S W0 u
.default_trigger = "default-on",
! ]2 U, T& _' f2 r: [9 G5 ? },6 t& M& G9 c# K
{
* o, m+ d9 O7 ?6 _2 s/ B$ Y: q0 w .active_low = 0,
6 g, E. q/ H9 e; U7 g- w- L .gpio = DA850_USER_LED2,+ |8 h3 a+ ]6 n) f( K( I. _
.name = "user_led2",- K: F9 H3 l- v) y
.default_trigger = "default-on",
% r6 L3 F0 [/ X' @, f },
, M e/ Y) I' C1 } {
6 @* ]2 f9 _5 B& J4 x- P" U .active_low = 0,6 q( p4 M1 D7 u: t6 _% D( Q |
.gpio = DA850_USER_LED3,& Z" ^& C$ C% c) D! \( J; I
.name = "user_led3",/ V* I8 O3 v [& P2 L
.default_trigger = "default-on",
& ~1 g. U6 }3 I( v l, J },
/ c6 _% w1 T+ J' T};& a" s2 s+ W3 W3 P2 ?: X
0 D. H. m4 m5 { m! Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 o& n# c5 {. ]' S; M: L8 C .leds = da850_evm_tl_leds,- o9 N& O$ z. I/ \: Y% q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 h8 H3 h8 q) G7 E* v};* K% w5 H# a( g5 t3 ]& l+ V! A
1 W. k" f2 n3 E* ?/ I7 e. W
static void led_dev_release(struct device *dev)& C0 ]9 Z4 s3 c1 V
{
* q# |/ E7 e3 z: M) A};6 X* ^0 O' C' {( X
5 T- S* B, c+ \5 m( ystatic struct platform_device da850_evm_tl_leds_device = {6 G4 K3 [+ e3 f9 f' m
.name = "leds-gpio",: X1 g$ [7 H" P" G2 ~
.id = 1,6 S$ y0 k! N9 A" R
.dev = {. {$ k% @* m: V( L M
.platform_data = &da850_evm_tl_leds_pdata,) N H, H( m2 X( \( C
.release = led_dev_release," o; o6 s8 [# H" k3 K4 u3 y
}
& `( S" r& v4 e8 t};
2 {4 V! b8 u- S" Q! [' s+ f+ B& @) v! Z* W, K0 m
static int __init led_platform_init(void)
' j, R( Z5 X3 Z+ ^$ D, u{0 _: a/ k: V, p( i
int ret;
" \- a4 ]' I/ l! K* W# @#if 0+ p8 p, J5 T+ p3 @$ D" K! p1 f* J( G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 _! Y4 Q# T' h' s- a4 [ if (ret)
! L+ r& b/ j4 X9 \) B2 } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, R) g) Z4 y3 _ n) {' | "%d\n", ret);
0 S6 y9 d) F& p; b#endif
, h: C U" v: f: E* m( _: Q ret = platform_device_register(&da850_evm_tl_leds_device);. @- k' C& m1 ]- H5 q7 V
if (ret)% y' i1 x* @' d. h$ Z1 L
pr_warning("Could not register som GPIO expander LEDS");
0 I$ p# V- Q6 J+ ?. e3 @+ ]+ X else
2 m% p( a% f0 R& x1 X, I y printk(KERN_INFO "LED register sucessful!\n");
; v$ g- o7 | m) E
5 S/ K# o) a4 V9 T, l return ret;
7 C) U3 H% s1 j6 C+ c- U' V6 U}
j+ l6 p" n% o" V" @" @( C
6 H# r& s* x$ A; X! Z+ d8 ]static void __exit led_platform_exit(void)
" j2 a2 [3 m9 M$ m% V9 t( B3 c{' F' |- x1 @% f, u
platform_device_unregister(&da850_evm_tl_leds_device);3 Q; o5 p; p1 _4 _, v
8 A. z. U: Z' D" ]7 @# { printk(KERN_INFO "LED unregister!\n");
- _* |; L. D0 f' }6 R0 f}
- T+ j6 e2 _' c) [( r0 X" M7 n; ]) z& d* q) |; o1 o2 ^, R
module_init(led_platform_init);7 s+ w) ^! M' D- D3 O% [; s
module_exit(led_platform_exit);/ J% P& M5 K4 i a
% G: E6 Y( o0 w* g4 _ X1 ]) g
MODULE_DESCRIPTION("Led platform driver");
: }, Z5 U1 y0 ]$ |; ^) ZMODULE_AUTHOR("Tronlong");! H' ~' l: ~/ ?, W0 b- O, z
MODULE_LICENSE("GPL");) ^; B0 }% ^& Q {
4 F; K! N; O. C2 @1 x
|
|