|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 [7 U( Q7 }; ^5 I# x
#include <linux/init.h>
6 j+ W! e6 e$ {+ Z7 h4 \6 s#include <linux/module.h>9 w, c8 M/ x/ Y5 N! w2 J/ W
#include <linux/kernel.h>
) D. K d1 ? Z6 G% {#include <linux/types.h>( k+ Q% W, T6 J
#include <linux/gpio.h>
$ U4 R( H4 E- D: r+ ]# C5 R6 `* b#include <linux/leds.h>7 p! t4 i W( t) y1 J! ~
#include <linux/platform_device.h># k: {6 G) I8 j+ s f4 T5 w
2 d S' v2 u' Z* {; ]7 v# r
#include <asm/mach-types.h>
& m: t2 P' ]- ]( U#include <asm/mach/arch.h>
@. ~( X' A- w+ \ u# Z#include <mach/da8xx.h>
6 F' t2 {) I) @3 M2 e#include <mach/mux.h>( h; x" r( l( m2 G
( ~( F6 R0 G; j. O# k! ~: G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ~1 z! p" r. t* c b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) L* D5 Y% Y0 B/ }2 X7 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ f1 R# u0 S5 S8 Q9 y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 N$ J8 Q5 t+ y6 o2 Q7 G, Q- {3 i( m7 W% ~7 o$ X( G
/* assign the tl som board LED-GPIOs*/
1 P% d- b! k0 Z& ~& q7 Y" O7 pstatic const short da850_evm_tl_user_led_pins[] = {$ \2 c: o! O3 e
/* These pins are definition at <mach/mux.h> file */" i! p" o2 A' G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, A( t& j9 j2 Z; z! X0 D$ [% O
-1
- m* y4 b z" n; \6 j( o/ F' q};
0 b1 r) r; D3 N: d
0 F) U- L! n* G# @) tstatic struct gpio_led da850_evm_tl_leds[] = {
* M: ?% m& q3 E* d' `5 ^- h {
7 c( Y8 n1 @5 J; U5 Z/ f# | .active_low = 0,5 `6 }' Q" E+ h6 R9 k% P4 }2 l% n+ i ^
.gpio = DA850_USER_LED0,
& M* F- r1 u- c4 \0 e4 I .name = "user_led0",
$ B8 v% ^& N+ `; f! d, N .default_trigger = "default-on"," R" M8 W3 ^) _' ^0 F& }+ U
},
, [) ] O, d( D4 N! p {
4 v5 }$ p, O; {" q2 S# a8 Y0 I& @ .active_low = 0,
$ p0 m/ u) C( k, l1 V .gpio = DA850_USER_LED1,7 r3 N- [9 [0 K# c6 \; ~- `; f
.name = "user_led1",
3 \6 a8 R/ H- Z .default_trigger = "default-on",( d" M# U- o" I0 ], P
},
+ x9 G% F" L8 J. j5 V {
+ O; _$ u/ [; g9 l" e .active_low = 0,2 P* e! H; ?* `. {
.gpio = DA850_USER_LED2,
4 u7 a0 @8 u# z8 O) B# R2 r) w/ j, M7 A .name = "user_led2",1 t1 v/ P; O$ a+ M
.default_trigger = "default-on",
3 b H% H% O. O d! q5 x( k2 y },
) _# `8 E, W/ Q9 {& U# q4 c2 j2 l7 Y {
$ Q9 P3 f' c1 K1 U0 e( K. K4 A" t .active_low = 0,2 g9 {$ |0 r1 q
.gpio = DA850_USER_LED3,) k* i* h- b4 | h* d' ~
.name = "user_led3",
4 B3 f( o; j4 P" n% z .default_trigger = "default-on",
3 K5 p& x" @/ ]" X" F+ q7 a },& M2 I- _- ~& e3 R% d. N3 P# b
};, G( [) c" K: h" }
0 U0 E2 g) c0 T1 m! Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: }. h6 \: h( p .leds = da850_evm_tl_leds,$ z, _! P9 h2 ]4 h6 r9 N4 \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 ]% |! K+ f# u+ W% J
};
) h. h0 u' r; x
3 Z" p# j& X5 Q) s, L0 v6 H" hstatic void led_dev_release(struct device *dev)1 C0 q% m2 I1 T0 { D G
{
- L! l1 I( m2 }: N& f};
0 l5 T3 p, H3 |; b' T+ \. r8 o3 y! }4 e. N! g
static struct platform_device da850_evm_tl_leds_device = {
, R3 D" @* f8 ] .name = "leds-gpio",' X% y- |+ }- R- v
.id = 1,
4 v5 ]+ [* r8 e .dev = {5 n8 j4 C/ n7 v5 s3 w
.platform_data = &da850_evm_tl_leds_pdata,, O5 |, H7 S! T i
.release = led_dev_release," r( m( Q) e: w) G" A$ f; }
}
" e1 O0 S8 H6 _$ x% {9 p: B};
. ]7 D7 p/ \. c7 f' ~1 v2 i9 G: p9 U) z7 L! C( Z0 C# ]0 }5 _" |
static int __init led_platform_init(void)6 t# x- `, c4 Q0 K0 z X
{4 k4 Q6 l J6 c- [: Q4 l, m
int ret;
2 v) Q# i) m: v ?1 ?; m7 _#if 0
; v% w. k. X, J& [. H1 U, d ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 Q0 h$ Y1 D7 |" P
if (ret); F7 O! B- v2 s/ m3 A" e: _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 l- Z5 g* V" d3 Y& V2 ~% F "%d\n", ret);
0 q, U( q% j2 F2 \9 s B8 p#endif$ j) F, L9 w" P: `6 l2 g
ret = platform_device_register(&da850_evm_tl_leds_device);
6 E; t" }* P/ G" G1 K$ ~, L if (ret)1 r+ O: a' T2 s* B) A
pr_warning("Could not register som GPIO expander LEDS");1 S0 {& `# _" P
else
# A2 P- U& _/ m printk(KERN_INFO "LED register sucessful!\n");* T4 `, J6 n, \' z% ^" Z
1 f0 P V% f4 ]4 ^8 l' i
return ret;9 i; L& S | G9 J- L; u
}% |- ^' h" O z- S
3 G0 h0 ?4 ~1 kstatic void __exit led_platform_exit(void)/ e$ s( b4 Q7 `3 a2 e8 [) M
{) T. @9 D* M- h9 d) J
platform_device_unregister(&da850_evm_tl_leds_device);" Z( T! h; i' k+ G! U4 V; B4 B
+ v+ e9 U1 e5 o/ s printk(KERN_INFO "LED unregister!\n");
# w1 y! Y/ O; |9 \; [}6 H3 h( J! J0 n3 i% f
$ u/ n4 t7 x; @3 L
module_init(led_platform_init);; X% h* d+ x3 t9 J4 c1 k6 n
module_exit(led_platform_exit);; _- s: \, z* ~& H
# W& |8 {- H( P5 LMODULE_DESCRIPTION("Led platform driver");
) d5 G) {, }# F wMODULE_AUTHOR("Tronlong");' J& c1 f$ H7 T8 U! D
MODULE_LICENSE("GPL");
$ S9 b4 [: W% I+ ^1 n
+ i0 U1 s* \5 X. r |
|