|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' H P u2 @. T: k; |+ q9 _#include <linux/init.h>
# S! D+ ^% N- z* U9 G: W#include <linux/module.h>5 E/ S4 ~, ^9 Z
#include <linux/kernel.h>
; z2 q) s0 [/ {9 P4 Q#include <linux/types.h>+ b* n% y, N" d7 F! E# E
#include <linux/gpio.h>
+ p6 [6 R5 C; g! v- `/ N#include <linux/leds.h>
' q8 M4 E: p, r* T/ f! ~+ Q |4 u#include <linux/platform_device.h>3 o/ r/ | {' W5 L, J( u8 p
" L- Q0 Q* C) W+ m% U#include <asm/mach-types.h>
# C0 w6 G/ t7 k+ |! N#include <asm/mach/arch.h>" {9 k! F! g! L9 n$ i
#include <mach/da8xx.h>0 m& l l, w3 N5 U
#include <mach/mux.h>
& ~8 e, g2 n! E! g& I7 {& L; e
6 ~; S$ g; |3 J9 Z& [$ G5 Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% j' D+ a0 c% c* ?6 d+ Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& s/ ^" v3 o& }# l6 C* l, a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# ] z2 E. I. t' i. d. q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ A* D4 R# S; e: i
+ g4 U x+ a. p) z8 |/* assign the tl som board LED-GPIOs*/. F( \. d# F& ]2 U/ q+ m
static const short da850_evm_tl_user_led_pins[] = {3 w5 ]0 V7 {4 q3 S% x" u
/* These pins are definition at <mach/mux.h> file */- [4 ~ ^( X/ p: T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# g" U" J2 f5 T9 ~ u- g6 T
-1
# D) g) Z, \. N( I' c& Z, |};
9 A" `* J+ V% o+ W: W* d3 q
; V- A4 D! s8 V+ i% ^static struct gpio_led da850_evm_tl_leds[] = {4 N% _& y+ x7 e( m1 H
{
0 B0 h& B1 } F. Z" L5 }, m0 R9 x .active_low = 0,& i9 b( M8 \/ Y1 c7 S4 P
.gpio = DA850_USER_LED0,0 Q. I- q% t1 n, X4 U8 R
.name = "user_led0",
H4 e& z6 l: K( j .default_trigger = "default-on",0 b; v8 A+ P3 X1 @1 X% i1 A
},
. x) { F2 E5 u- J3 C { q& j/ P8 Q% |% a% q" F
.active_low = 0,/ u& j" a* \9 T' u+ e: A- N* m
.gpio = DA850_USER_LED1,) v% M6 |0 s/ C& a. \! k
.name = "user_led1",
+ c7 h7 q3 F3 m7 } .default_trigger = "default-on",
) l. K( @$ H; a2 H$ k. i },, Z5 ]$ u" p& c, U( l
{" N' U2 H1 R# H# j E: G
.active_low = 0,! e' r$ s0 ]# ~- |
.gpio = DA850_USER_LED2,
1 C1 w5 W% v o3 f .name = "user_led2",
6 c* x. K u) R! I! w" N .default_trigger = "default-on",9 E1 L. R* R6 }7 a" q8 D; S
},
+ P, ?$ m8 x6 p# g7 ~1 [ {
8 A! w! c" h! {- g% f .active_low = 0,
: n$ }8 i0 m6 G' X .gpio = DA850_USER_LED3,
! f/ C! S1 y6 j7 w% }6 `" } .name = "user_led3",
4 A9 {5 A. P8 b C) f% ]1 g .default_trigger = "default-on",
! L, D0 N. K6 z- L },
9 V2 X& l7 U& K};
; P: X/ f5 V0 h6 a( p
% |' S9 n& x1 P6 ^" _) Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 T9 M m' J% G
.leds = da850_evm_tl_leds,
7 u/ C5 t0 V" P+ r( o. N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 D( j1 u) J' G, b};
' Y3 m2 @- i5 A! T; P# k" F. }/ C% B* P' S
static void led_dev_release(struct device *dev)/ q4 D8 x$ h0 E' s7 x: P6 I$ X9 c* R
{3 S& l' _6 Z; W' z" W/ t
};
! k5 d' b6 A$ m- s
! O/ z$ J" E6 F/ W3 Sstatic struct platform_device da850_evm_tl_leds_device = {
& W& w7 G: Z& ]" Z: L! ] .name = "leds-gpio",
% ], B+ ~! o! ^% H* O" Q .id = 1,! N8 K* @/ k* _/ T
.dev = {, I- x6 d x% N* v6 Z
.platform_data = &da850_evm_tl_leds_pdata, d6 q' w" A+ } s ~
.release = led_dev_release,
7 r) X* b4 b& L" C3 Z, k }- C: E7 {6 K2 n* Q7 j1 h6 x: A
};
$ j/ L, M$ B& e
% O8 c7 X: G! c/ ^' p; O2 Xstatic int __init led_platform_init(void)
& l. Z, m8 {; p( p: R{
8 U5 ?: z8 Z/ e* ^$ ^ int ret;
5 D4 M5 V' c e& e {#if 0
9 _5 U7 U8 k Z3 V3 L& b# H4 t" u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- V l. b- ^0 f4 t4 @* R* O if (ret)4 Q( @* R5 F( f5 v# c `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% j& Q% @& u& J! o1 w
"%d\n", ret);
$ {: N* ?) t0 a4 Z2 |! c7 Y#endif
- p6 b+ U% L6 W7 X. R* ~+ ` ret = platform_device_register(&da850_evm_tl_leds_device);7 H& Q0 m% ^8 Y& B8 u8 x8 ?4 f+ t
if (ret)! a9 c( J& _8 P3 N, m4 ^
pr_warning("Could not register som GPIO expander LEDS");6 S8 J+ @& w! Y, o3 }
else
& L: K( w3 i6 \& r printk(KERN_INFO "LED register sucessful!\n");
" t" G( x0 u H) U, j, A7 ]: b0 E1 g" J t+ ^5 k- o$ f8 j. v4 U) X! F
return ret;# p: y8 h- \5 s) Q! R7 k2 l
}
4 Q7 |, c% x$ C9 b- j
4 K# Y2 z. I+ n# ~' P- gstatic void __exit led_platform_exit(void)
3 B. G- y9 S; u& K) c{! Y7 R d- X( ]! V8 W. n
platform_device_unregister(&da850_evm_tl_leds_device);
0 a9 a0 o0 ~$ T, y% t% ~" m) j/ ]9 D+ E" R5 U. {* |
printk(KERN_INFO "LED unregister!\n");6 ?, \1 L( ~8 V3 s- k9 F
}
1 b: W% r9 _& j7 P# Y
/ ^, t3 K6 Y( amodule_init(led_platform_init);
0 N# l% i# R% X9 {! m7 J* E8 e; {module_exit(led_platform_exit);
( R8 U) m/ M+ E1 k
( O I3 r8 q, A( l0 x) B% H6 ~3 `MODULE_DESCRIPTION("Led platform driver");
% ?0 i. a8 h5 ~% R. z) N$ \" qMODULE_AUTHOR("Tronlong");
( e) @" R3 ^/ r- n- _6 ?1 nMODULE_LICENSE("GPL");
; q: n9 y' j7 K0 E4 S9 X% k' p+ U
E* d: Z. B& S/ D3 i6 |" h |
|