|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% C0 h% I2 G+ ~- i#include <linux/init.h>$ K, k0 a/ U* s; B
#include <linux/module.h>
4 o% G' u( _8 G6 k$ J7 B: I#include <linux/kernel.h>
+ a9 v* x! ?' l+ P#include <linux/types.h>3 B. g- f2 c. r- w* D7 U2 ^
#include <linux/gpio.h>8 I; D. M! Y9 X0 @, U& N8 L" R
#include <linux/leds.h>
- {6 E1 O+ }% X#include <linux/platform_device.h>4 Q# I; v/ L: r
$ ~7 z- s7 Z6 K5 P6 \, O#include <asm/mach-types.h>0 W% \; E _9 h2 V, j
#include <asm/mach/arch.h>
& T& k% P$ R6 _4 p% i/ w#include <mach/da8xx.h>
$ h2 t4 B( X( | m' R$ N1 ]& H" t#include <mach/mux.h>
+ u# [5 B' Q! T, b( G G x/ T$ y/ ]' N1 z; ?3 ^) L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( j9 A0 z6 e6 G2 K9 i# Q" N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 s, P" V, a$ k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- d3 L( }/ ~3 w5 F b/ W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 ]) z( @" j. e! C) A* B
' K4 M7 m; Q; e; q9 C/* assign the tl som board LED-GPIOs*/" G: @ ~6 e9 e+ g2 {8 N
static const short da850_evm_tl_user_led_pins[] = {
4 g [5 c4 P4 P) ]# _* r /* These pins are definition at <mach/mux.h> file */
" |9 U5 s2 m# V" R( D- w' } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Z$ T$ K: |" S; h0 W! U+ ]% d3 d -1! }/ A& H/ c1 q* ?$ N6 o
};) Q h7 `9 \$ g+ [3 Z) ]; u9 e
& k; {5 E: c* r7 W
static struct gpio_led da850_evm_tl_leds[] = {
( I$ }8 v) @& D. N: { u3 T- u {6 p- n' ~6 E9 Q! J q3 }- G3 a( D) Z8 [
.active_low = 0,% f& d9 K( x5 }
.gpio = DA850_USER_LED0,
2 z; c9 |/ c+ f3 ]: ] .name = "user_led0",
: _: c3 m0 E, `8 q7 e .default_trigger = "default-on",6 R3 Q7 P8 A( O' z9 @2 Y5 `2 \
},1 v+ e1 P$ ?6 }! `
{* P' e# u3 m& i+ ^0 h% Y
.active_low = 0,
! c- P4 K, U* Q$ p) U( J. h .gpio = DA850_USER_LED1,+ I$ B; [* i2 E8 K0 z2 n: O7 R
.name = "user_led1",
5 m" N- S# v$ u( u* S# c# U .default_trigger = "default-on",
B% q, l+ m, e+ R, G }, S& A3 R) m/ L0 c3 q2 y
{+ L; Q5 t+ D; B, Q5 R. X
.active_low = 0,0 }# S- g) }2 m( u# G0 H* e
.gpio = DA850_USER_LED2,# v0 T: F4 Z! M. Q1 L5 \: H5 h/ [
.name = "user_led2",. K, W: }; u- S0 K5 V6 `
.default_trigger = "default-on",' d) h; l+ D6 C* U; v
},
* r# b; u' f1 R8 |+ _ {
. i7 S- x# U; R4 R6 D9 a .active_low = 0,0 f1 I8 }# K, e9 ~0 V! E0 t# u. Z% c
.gpio = DA850_USER_LED3,* b6 M4 J+ y6 q0 Z7 p
.name = "user_led3",( G( t; q5 m! A! j, F' U) t
.default_trigger = "default-on",( `& _! Y1 A# b& l( A" b5 D) s+ ^
},
1 p1 }9 I' ^- l% ]9 v! H};0 ]2 b. h# g! j
- M2 J% `8 U ]: f1 ^0 @9 Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ Y+ P2 i( m# w
.leds = da850_evm_tl_leds,% K: w, J5 J" Y2 ~, N# O0 S/ O; O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ A4 D! Y# w. `4 t8 @
};
. P) r! t1 ]# a
* M% D- K2 D. k7 {* G9 q$ E* rstatic void led_dev_release(struct device *dev)
5 I% S' O- z5 y{7 a2 |$ Y- ? M' R5 q/ c
};& |0 w0 w6 T0 [) s, X3 u# F
4 t( q' D4 @3 ^9 {/ D( V" ~% |. ]
static struct platform_device da850_evm_tl_leds_device = {
4 m% a& c" q: _: S .name = "leds-gpio",
4 U9 S, H5 r# r; h) v. t9 e) e .id = 1,) P5 r# \5 P- u0 g" l# @% d$ }
.dev = {
+ l5 x; k( b( x4 a) y1 O' R& Z& J .platform_data = &da850_evm_tl_leds_pdata, i O7 z! a, D+ j. G5 v* u
.release = led_dev_release,6 ]( T% c3 s( X2 }) H, s
}
) G6 K6 e% d# o8 }5 s3 @};
& J8 i5 e5 r1 H" z, A
/ @) |5 i: y$ X$ }static int __init led_platform_init(void)
( r8 R. [/ c+ l5 }7 t4 k{" F2 w3 K% a1 e( s9 Y) h+ g o
int ret;: C8 f, t0 ^1 i' }1 `/ b% ]* ~. g3 S
#if 0
6 Z/ e7 o9 T. Z) ]) x6 F& y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& g. g" q9 c. Z1 i% ?, Q if (ret)0 i* `) g! [( Q1 ]+ v( x% H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# \+ g7 x0 Q# c7 Z8 n3 m
"%d\n", ret);
* H: N7 z/ a+ T- }% l" w1 o" z#endif6 i7 e( y8 w# d! S$ K- Z( Y6 K
ret = platform_device_register(&da850_evm_tl_leds_device);
' V6 E1 n' I# f- c5 T5 g% `2 ^' Y if (ret)! {" |. P" w. h1 G, R3 z
pr_warning("Could not register som GPIO expander LEDS");4 l$ s; x: V0 ~3 N4 x- J( I/ Q C
else J8 U$ E* X" U
printk(KERN_INFO "LED register sucessful!\n");
$ g5 m* t9 Z( t6 P: p: q; {6 s% E8 }) E$ ~
return ret;# g# v* _- E9 z! |& G: Y
}7 K" H' U3 V! z
/ m* c) {. T- z8 Ostatic void __exit led_platform_exit(void)$ z @" M) \6 m* Q4 S0 J
{4 q# {! {; U: O5 I
platform_device_unregister(&da850_evm_tl_leds_device);
8 k$ R$ U- s- H$ X* a9 {6 }0 a$ _2 t; g+ H) P1 y3 Y
printk(KERN_INFO "LED unregister!\n");
' x6 o: \) v2 x+ Y1 n. _}
5 }. V/ z% ^6 U3 K) _
3 k- [7 K0 {5 Z; `) h( y' ^; g1 dmodule_init(led_platform_init);. g- i2 F/ I& r* n& [
module_exit(led_platform_exit);* b9 z4 ]. M% I2 G
3 I7 f* O. S" Z8 T# U4 S% A
MODULE_DESCRIPTION("Led platform driver");* z; |- t, w) V+ q
MODULE_AUTHOR("Tronlong");! D+ m# K: s$ a. `1 ?. K
MODULE_LICENSE("GPL");, k1 I6 F( C" z6 B# H8 |
$ \ k+ t% b9 @$ k& O1 `
|
|