|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ e1 n& v, _3 N" w4 U
#include <linux/init.h>
) H/ K# Q5 }- I#include <linux/module.h>9 S3 T, o! v @
#include <linux/kernel.h>' a' c% h8 v, B
#include <linux/types.h>; F' C. s8 X: l# v0 q/ N3 j n. X i/ }
#include <linux/gpio.h>
: Y( f) j. G7 q1 k: c4 w4 t" q s#include <linux/leds.h>, A+ k& U; a: U# q4 Q" Z: C
#include <linux/platform_device.h>4 F+ @8 q$ k5 Z6 K# n9 Z
5 C9 ]: j2 H4 n+ O4 L#include <asm/mach-types.h>
6 e) q$ g) w2 O, k! |8 e# q#include <asm/mach/arch.h>
; ]0 r$ G1 L% c2 K#include <mach/da8xx.h>
! x6 W4 F* V0 q8 ?8 J9 S#include <mach/mux.h>7 v5 f. J. M, b+ {5 }, y, U; r
, f# Z9 }. J# H/ V! _6 q3 A9 f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 B; T3 c7 i/ @3 ?5 M( s2 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 L& A/ o+ c' N! K1 `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" a s7 }9 Q) r2 F& B/ C# D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* F4 F) Q3 ^8 H
7 G, O% K o% M2 A1 S/* assign the tl som board LED-GPIOs*/
) d& x( l; J) mstatic const short da850_evm_tl_user_led_pins[] = {
- a2 r* d# D! K% M. W* v9 ~ /* These pins are definition at <mach/mux.h> file */* B9 Y6 n$ N. I! r. N" U0 e! S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 C$ T/ y( @( N* |
-17 @3 _4 Z2 i% D2 M% J, u
};
* ^) u( o: o D
2 { i* Q# p7 m$ O" hstatic struct gpio_led da850_evm_tl_leds[] = {8 g# ]" S6 N# {7 y3 ], w
{- v" @, h4 p" [5 p) l% C
.active_low = 0,
; p3 [" o! \( J7 W- E: W9 n .gpio = DA850_USER_LED0,1 z! C, L3 x' u" x) M
.name = "user_led0",
# [- z6 W1 e" R5 q, t% p .default_trigger = "default-on",
" f. l- F" L1 h3 M, e },
C4 c# b" P. l& l {
8 a9 Z7 E1 P+ E1 [3 E0 J0 P .active_low = 0,4 c- @% W% U6 K) j5 ]7 J
.gpio = DA850_USER_LED1,8 u) G: [# M1 f' k; Z8 U* J
.name = "user_led1",
8 b7 G/ q# {5 G* n$ T. W8 G2 M) k, \ .default_trigger = "default-on",
) Q. v* s: s& k% O' d },
( _ _. ^9 ]* S( e {
E3 z! S6 y& E: _# s: H3 @+ V- d .active_low = 0, d+ V( r8 s' s" l
.gpio = DA850_USER_LED2,
- J, L; o. L: ^" T$ h# R; k .name = "user_led2",7 [7 L$ `1 a5 w' N1 m
.default_trigger = "default-on",: O: o, [, P& F
},
0 y7 k+ T5 R0 K {
5 S3 D! N9 O# i% F! N .active_low = 0,) q& k5 P; Z6 W4 ?/ e! H
.gpio = DA850_USER_LED3,
$ |6 g2 K/ ]3 W X# \' U0 d& `. Y( g .name = "user_led3",
! W& r v. k, a7 X3 r8 W2 M .default_trigger = "default-on",
0 {4 f8 `5 K6 x2 g5 J$ w- j, e },/ O. z B2 v B
};# E! X3 ?5 ]* F+ i3 H- A( X* O0 `
; F9 _' S3 M# { h, D. _$ D5 ?3 W7 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 n/ y9 x; Z, F, r0 ~* ~' C .leds = da850_evm_tl_leds,
' b$ D0 X/ a/ { |1 u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 Q# a V U5 S, r};) ]0 i, d6 H7 o7 L
. g0 G D; E5 |. W1 Xstatic void led_dev_release(struct device *dev)9 e# Z6 o6 a( i- b
{
5 C" k4 c( q- T. h* J};( s) {4 K+ I, O6 K( z2 a
$ R. [* S! p# L6 |, P2 N
static struct platform_device da850_evm_tl_leds_device = {# ~4 W# s# L3 ?) W {' Q
.name = "leds-gpio",
% V7 ?5 J8 `. Z; n/ G5 P$ I .id = 1, V: c0 z1 H2 f4 x( g
.dev = {8 F3 {, f* G( `% ]
.platform_data = &da850_evm_tl_leds_pdata,& R( b5 O1 C* j2 |
.release = led_dev_release," H" u# `/ Y; k3 u. u
}
: _) ]' [3 L& d2 o# r H& i* A};+ O! \1 M# {2 X. A/ @
/ R( T5 ^8 O1 `+ ystatic int __init led_platform_init(void)9 J+ E# p" @: I' m& T* W/ K$ k
{
5 K6 U) y5 w3 y, j4 f' } int ret;
- d- u# V4 D: N0 F#if 0
" \$ S" \9 Z) R) H- I, H' f) f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 O- d, |( ]" n' X" F if (ret); G, x+ t1 e' `5 N. e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ t3 Z" n# _, e. @. H
"%d\n", ret);1 I' \ l8 |! ]
#endif1 y* }3 Q% b# G4 h
ret = platform_device_register(&da850_evm_tl_leds_device);4 O% d0 w, o t. G/ v
if (ret); _% u! E$ i; P
pr_warning("Could not register som GPIO expander LEDS");; o$ T# }' I1 h0 H9 }
else ]. Y3 v" y! w* P& D: B7 y
printk(KERN_INFO "LED register sucessful!\n");3 ?$ A9 U7 [' [* P8 R0 G! V/ p
# l+ s% Y- T* c- m) Q
return ret;" i9 S4 A4 |2 s4 U) m3 q6 x
}
8 [; |+ I8 s: {8 F& k a
2 }; h7 @# h* n5 fstatic void __exit led_platform_exit(void) Z3 G+ [6 U0 ?& \$ z
{
; @6 x/ D; n* K, r) | platform_device_unregister(&da850_evm_tl_leds_device);( h8 ^2 E7 J( B0 C5 t' V
+ o2 H6 R1 H3 i* ?8 J
printk(KERN_INFO "LED unregister!\n");; r9 M% j g" P: k
}0 z; g% j1 d8 l4 q/ ]
+ G/ i; d! r4 a+ R1 [( j p
module_init(led_platform_init);
. J# Y8 d }) A5 l, _, u) \1 i5 }module_exit(led_platform_exit);6 D8 g0 h2 I! C# e" s' c
* \' h# C: l( U: a5 T" @, tMODULE_DESCRIPTION("Led platform driver");4 F6 w% I6 ?$ \) N3 K% _ m
MODULE_AUTHOR("Tronlong");
4 G8 [+ g [2 [/ mMODULE_LICENSE("GPL");) ?5 C! A7 d1 K$ i, \
4 N4 E, X2 ^9 W8 |
|
|