|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- ?( N7 W( J+ n" f0 j a
#include <linux/init.h>' h" p* b2 a# O$ q
#include <linux/module.h>
2 k* ~ ~3 p& u2 j#include <linux/kernel.h>" h/ w5 ^) V; i; Q$ R, v
#include <linux/types.h>
p9 L4 I1 f9 ^! \#include <linux/gpio.h>
% ^5 r( n9 J- i, t3 G#include <linux/leds.h>
: O, q, k5 M7 c+ ^' [; j0 L#include <linux/platform_device.h>
1 _% e# d' g- k" U y! U: e$ M
- [6 z6 N) |3 V) T6 K#include <asm/mach-types.h>
' H: U+ I: e& k6 f' `$ W$ r#include <asm/mach/arch.h>0 @3 ]3 M, \$ R' [- f) h" e! l
#include <mach/da8xx.h>7 o3 A8 V% N; g
#include <mach/mux.h>( K/ \& ^3 G( V( o3 ]1 [
! e' `/ a* |0 R& ~/ ^1 }5 G4 x+ i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 D5 R8 z, T% d# q7 }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# D$ O) o; E0 \- O& D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& O4 \2 ]5 U7 |3 f6 P! @+ E1 O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 G; d j6 D* t5 Y( E6 l
; m, w P' z$ i7 w4 l% M
/* assign the tl som board LED-GPIOs*/& R9 c( R3 {, \
static const short da850_evm_tl_user_led_pins[] = {* G7 u. X6 k/ }6 e
/* These pins are definition at <mach/mux.h> file */
9 E: m% |0 V( v$ j4 d* K. n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ |6 y0 E% b( F0 U( H$ Q2 y -1
2 ?, e) d. s- \};
: U3 p) e, }3 e
4 k* ]* ~1 Q$ F" L5 U5 W2 _static struct gpio_led da850_evm_tl_leds[] = {
' G! p: G. y4 q5 F {
% C" a2 B1 A8 {! u0 ]2 ~/ o1 u .active_low = 0,
$ ]& n7 ^" I9 @. M5 B8 p2 P0 } .gpio = DA850_USER_LED0,
% A" b. V( d" \2 ^8 {: z3 B, _ .name = "user_led0",
- C. Y0 O$ R+ ~ .default_trigger = "default-on",
) @ U: t% H% N5 @$ J, a+ L },
: ]/ {7 N7 m4 b {* j6 m/ q6 i+ M+ r
.active_low = 0,
* u; M$ i$ c5 | .gpio = DA850_USER_LED1,* C" F" x; i2 p! ^6 r' [
.name = "user_led1",
* V; F# A" J! U1 k! I .default_trigger = "default-on",. R, \; B: ^0 M) z* m. @6 M* c3 R
},
/ ^+ I l4 s- |- l {
% r9 h7 J$ |0 o8 { .active_low = 0,
}; m, s( S. e# X9 {4 c0 u h( V .gpio = DA850_USER_LED2,! T' V$ b4 k' X) M/ U {$ R' X
.name = "user_led2",
: h8 y: i* `0 h& g .default_trigger = "default-on",
1 ^* l/ q* B+ U' ^* x& ]$ {5 [9 j$ X },
' X3 z1 J1 D4 w" P+ G, M. H {/ R$ M/ P5 s; x7 O% m, u$ }
.active_low = 0,% l! |9 o6 E! v; n9 a
.gpio = DA850_USER_LED3,: l( N! x1 X7 s! U0 `: R
.name = "user_led3",
# b% B% O; b6 u9 |" V5 R" a( T' e$ q) U .default_trigger = "default-on",/ _6 B/ z9 ?& c6 V# o5 e- p1 @. f
},
& h3 O7 w# M5 A& l' F2 M4 d5 N+ T4 {};
3 {* ~2 J$ s& H$ J# R' k
$ l% w, T* g# y9 x2 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 s+ _" q1 e8 F; s% e6 x1 O8 {9 C; O .leds = da850_evm_tl_leds,
5 K2 U0 j( j' ^- d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' I8 c- K9 c U0 `( D/ R
};
2 ]% e! T& \$ z6 @! `7 G* h% \5 `9 d4 W% Y/ K+ a
static void led_dev_release(struct device *dev)
7 l* }0 w3 D0 b) z( m; e/ x- P{- h8 x0 c; \( Q/ A. x0 p
};
V" V9 \0 a5 |% _+ Q* V$ g% s5 {) M# L2 e
static struct platform_device da850_evm_tl_leds_device = {4 V3 w2 _4 r2 G2 J
.name = "leds-gpio",
( J g' c/ t. p7 `, K .id = 1,
6 K9 a* n k3 n* K .dev = {4 `6 d# t$ u8 A1 t2 a3 o, s
.platform_data = &da850_evm_tl_leds_pdata,& e* K# m# [$ A; j5 Z. n
.release = led_dev_release,: C! ~2 x7 h& q8 o$ N7 E
}
% H: h# y7 b0 B$ Y9 t: p}; I* c- x* K# z
1 n/ |$ Q/ I% ~ K1 x
static int __init led_platform_init(void)
& j$ X7 L& B" D8 w7 J @- f{% B P. D) S/ q' x) M. k/ t( ~& Q9 _
int ret;
3 B$ E- |+ ]& V0 Y0 ^# F7 c$ C#if 0
|% f3 R3 ?8 t6 D. [; q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ q9 f: e: @% @
if (ret)
) C- o- \% c0 W* n$ n) V. D& x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( d2 O; c5 K- s5 x
"%d\n", ret);. I* h; N( A# Y8 T# r
#endif0 ]9 D" H, |9 D0 V, S
ret = platform_device_register(&da850_evm_tl_leds_device);
+ D# Z2 |1 X4 x& A$ v2 w if (ret)3 T; Y5 y, C: S9 e
pr_warning("Could not register som GPIO expander LEDS");
J, H; k% j9 O8 k# F8 r( Z else
1 o, A' V0 y. X) @- p, a) y3 U1 @ printk(KERN_INFO "LED register sucessful!\n");4 M8 M& u N2 x9 S4 T" b: w C
) d# i) b& o& {. m' Z+ U) C$ V return ret;$ x: s% X! _! c: H" ?: r0 E! B
}
8 ?; k. F- i& U. a; h: \8 Y+ b# j7 d# V7 k( j" u' s+ }" L- Q
static void __exit led_platform_exit(void)
$ E/ L s/ N0 J4 ?7 b: `% S4 c: s{
% y( w v5 V8 g: F) Y platform_device_unregister(&da850_evm_tl_leds_device);9 S2 F+ J8 m9 d6 B) f- j
, [ T6 D% g! Y# w, B6 w
printk(KERN_INFO "LED unregister!\n");, Y) U( g8 e5 _
}/ R1 Z- I9 t; Z$ p5 [% i
8 |' I8 q1 d0 r7 q8 D- J0 {+ g
module_init(led_platform_init);1 W% l* f0 Y+ s' [+ [. y
module_exit(led_platform_exit);
* h/ Q. e8 M/ v: d7 ?7 W3 ~5 O1 s, c/ W- ?0 c; G3 w+ A
MODULE_DESCRIPTION("Led platform driver");
$ d3 \+ ], u& S$ Q% PMODULE_AUTHOR("Tronlong");
0 H/ q& i: R1 I4 PMODULE_LICENSE("GPL");
1 g4 P6 O+ W0 g
' U8 }9 s O; d) d* f, b) h |
|