|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 U6 ~: T% D: y# `3 U
#include <linux/init.h>! B# I) k" I, {# s# E T; c/ C
#include <linux/module.h>
6 x/ ~+ [# v R" C$ g1 P#include <linux/kernel.h>5 v% f% w# F, O& D5 ?# k
#include <linux/types.h>
! Y9 L# s% k$ I& e: P- D1 k! {# H#include <linux/gpio.h>" Q7 h9 b( S u- |
#include <linux/leds.h>" l3 `+ g1 J& ?; D# q' U* l
#include <linux/platform_device.h>
- O! C9 w/ O) D$ J, k! M/ `' ^3 x+ f" x$ m7 b, _
#include <asm/mach-types.h>
9 e2 E3 Y. D0 @1 D, {% L' k; c- F#include <asm/mach/arch.h>* ~8 x9 `) r0 {
#include <mach/da8xx.h>1 h0 M; P# S" A- x4 h
#include <mach/mux.h>, y, \3 N! V) K2 Q5 Z! H+ l! w
6 i5 s4 E/ t: B& I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& E3 W. y2 t1 u6 _; V# L0 Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 c* O( z8 w7 ^" z: c- t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 P5 e0 y$ U, X, m' X+ q7 A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 q7 x, Z; K R; {; p: a) J
: X1 N& g' K% Q
/* assign the tl som board LED-GPIOs*/
4 o; k; \5 ~- k4 @. k; @static const short da850_evm_tl_user_led_pins[] = { \1 y2 M2 x; ]4 a4 e: @
/* These pins are definition at <mach/mux.h> file */& \+ n3 R6 M; ?, y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 `" H- D4 t; D9 E/ S$ ~ -1' ]' D. U1 P% i- v+ k1 U
};; `7 c: P7 D% F6 W
# P" H |& k) m
static struct gpio_led da850_evm_tl_leds[] = {
- q: |4 i/ z. I! |% C {
[& j+ \. `3 Y/ M4 ~ .active_low = 0,+ T& k; X# |! ]+ a
.gpio = DA850_USER_LED0,
- g6 _( ]7 B; [( m3 _ .name = "user_led0",
4 U) U+ T$ M$ b+ E. K/ _ .default_trigger = "default-on",; Y# d( C% e( K( G5 S
},5 ?- }- o# q3 u1 ~6 U
{
5 w! |3 l1 v) l0 r- [ .active_low = 0,
j6 f4 l" y! D8 h1 K .gpio = DA850_USER_LED1,
% F3 r) ~9 C3 P+ ]7 K" q" ] .name = "user_led1",4 x/ g* d* j9 h$ }
.default_trigger = "default-on",
( {' e8 p o3 P ], d$ Y" Z0 t },# d5 P8 {$ J! x/ P: d3 p- W
{& v: l) k; g1 \7 Z2 ~( k% G- [" l
.active_low = 0,
/ P8 ^) x! E: u" t( ~: ? .gpio = DA850_USER_LED2,
/ l. e- I4 c( z: K4 V .name = "user_led2",
5 m# C2 C1 [3 \2 [! W .default_trigger = "default-on",
! C4 W$ K- v; u! K },
. W- {, W/ j" R5 D {. H- u/ M( J+ d8 j9 V0 _8 ]7 ?% P4 g0 m
.active_low = 0,
( S+ f6 U7 _" Z& l: j0 d .gpio = DA850_USER_LED3,' k. b6 B Y Y4 {
.name = "user_led3",
% L. B5 b8 x$ p" L/ U2 P .default_trigger = "default-on",6 d- K" L7 D6 U+ B2 n0 |' O# X
},
. L1 ^& |4 _* ?% C8 X};
( u. ?' T1 p* n/ V d; |5 k
% l" F" V# V* b' \1 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
u6 W* d, `/ }7 `% p, @4 u4 O9 e .leds = da850_evm_tl_leds,
7 q% C: J) t8 Y! X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% g0 O, y* ]4 x, K( s};
5 G- \2 V' |6 w
! z% n3 P' o2 _! C3 Cstatic void led_dev_release(struct device *dev)
4 j$ ?3 W8 x, D/ ?{5 ?( F" a8 l- {
};
; C4 `, \: J0 J5 |% [& s4 O& s* D+ z: G& U
static struct platform_device da850_evm_tl_leds_device = {
- N. N3 o7 x$ y .name = "leds-gpio",
' _- }2 G/ j3 E8 p .id = 1,& [, T: r' d. [+ |! h
.dev = {
& h, M ^( k, B! t/ j .platform_data = &da850_evm_tl_leds_pdata,
2 l9 X/ a: S+ f% W( }. M' Z+ Y .release = led_dev_release,$ D1 f( |) w" ^' @6 C; |
}$ p W6 `& e( s, l3 c8 g7 q
};1 F! a+ t( B. Z
; r) ?* F# `$ E8 R# estatic int __init led_platform_init(void)
! r3 h u+ K) [, J! e8 Z5 V{5 K; n4 \, H% k8 n5 |7 m
int ret;- x3 b2 B. ?8 D. N0 [" H
#if 0, e* |; }! g: c4 t* w" P) G2 A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- D& n( D+ N4 q4 ~; e if (ret)
" R, o& A' _5 `1 W5 j$ h pr_warning("da850_evm_tl_leds_init : User LED mux failed :": U2 k, J5 J6 w
"%d\n", ret);2 S1 M0 z6 M$ f8 \+ A5 N
#endif
8 j# O: `: b% T ret = platform_device_register(&da850_evm_tl_leds_device);
: P6 _, `- {( _# J" \7 {% l: a/ f( k if (ret): W7 ^6 A2 a+ [- s$ o8 g
pr_warning("Could not register som GPIO expander LEDS"); e3 ~' q. r* h0 H5 a6 ? B
else
) X+ b6 Q+ X V' p+ p* M# l printk(KERN_INFO "LED register sucessful!\n");
, i5 e7 |2 u9 g) C B* r6 \0 G: q: `' p& F1 I# Z( M
return ret;+ \0 o- k1 b$ O6 n& i
}7 ~- @, h; d# a
- L/ R/ p" T# t) V8 ~- estatic void __exit led_platform_exit(void)6 t3 R! N/ e* K& x' P" s( n
{6 }. k- D3 P( A! j
platform_device_unregister(&da850_evm_tl_leds_device);6 a5 i, k( e; B
T' [# M% U- W/ x printk(KERN_INFO "LED unregister!\n");
% y' r4 ?- b* p/ x2 f0 ~( ]}. m8 X4 s) U, [, K2 V6 w6 S
) V5 E7 K8 L& U7 Kmodule_init(led_platform_init);
/ v$ s2 y/ ~0 G1 a, wmodule_exit(led_platform_exit);0 d* P* o- O6 e: I! B' r' I6 e; j0 j
7 Y4 P, \4 n) O5 q. p, m4 b) x
MODULE_DESCRIPTION("Led platform driver");* m A2 v( c2 h2 S* g
MODULE_AUTHOR("Tronlong");
* U2 m# X& N5 D4 N6 kMODULE_LICENSE("GPL");! w M" A' u1 f/ m1 G
4 r0 @* T$ j* [7 K |
|