|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 a1 Y" p+ f! T
#include <linux/init.h>, ~. D( f1 |+ B) s
#include <linux/module.h>% g2 _! y5 ^$ d1 }+ G/ K
#include <linux/kernel.h>
+ D) y6 H# Q U, i; h#include <linux/types.h>! B8 P/ @3 T+ o% L
#include <linux/gpio.h>
. r" P) y% c. K9 d- [& {. t, V#include <linux/leds.h>
5 d, N: k5 u: u/ l#include <linux/platform_device.h>
2 L3 E0 W- ?+ a7 C
% }# i3 h+ ~' w) H3 g4 r6 ]* G0 h#include <asm/mach-types.h> f6 e& Z$ X4 O; J
#include <asm/mach/arch.h>
+ b4 g0 f0 S/ J: G( X1 \#include <mach/da8xx.h>+ n: n5 W: j% {$ u' s. Z: v
#include <mach/mux.h>
5 q9 u% d% A* o( T# |2 o2 G" k/ P" \- c5 |, P6 C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) l# s: b2 l0 h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 {% `- _+ T0 M$ m) k4 w4 t: j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. R# E# H& M/ V. x3 M3 P6 _# `4 ^) g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( Y7 N; ^8 B9 \) Q4 w. \ L* _: o5 m' Y) Z x1 p, f! H {
/* assign the tl som board LED-GPIOs*/
u+ V0 K, E {/ \5 c3 @" Zstatic const short da850_evm_tl_user_led_pins[] = {, C5 U+ ~) z0 L! G8 P" l
/* These pins are definition at <mach/mux.h> file */! e8 F0 ^) |1 f" j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," ?7 X3 e' P0 I- ~5 [4 C
-1 a+ \! A/ }2 a9 y: K3 f5 E7 k
};
' ] F* L) H; J( l1 M
+ m5 ]- a5 r# `static struct gpio_led da850_evm_tl_leds[] = {
. b4 Q6 f& s$ `& n {
! {: e7 h6 ?, j8 i9 | .active_low = 0,3 t) b: f2 a6 A5 f
.gpio = DA850_USER_LED0,
7 o8 J( y1 Q9 V$ [) ~- P .name = "user_led0",
' _0 Q7 }$ p% B6 E) h' { .default_trigger = "default-on",
7 F9 @+ u* o; Q: U8 g) J; c( o6 Q },
4 x1 f- Z( ^7 u7 L" I" {; |9 b- |! V {; b2 V- K0 q! T% i; W
.active_low = 0,
* E* l' D$ i* \7 b& s& H9 k% k .gpio = DA850_USER_LED1,4 p3 N; ^) V8 u' o' R
.name = "user_led1",: P1 W! c. k9 h4 v3 a, V s5 \( z
.default_trigger = "default-on"," n$ z& K. y' E3 f1 v4 Y
},
# ~ x) e, f+ |3 H4 M3 g( e5 s$ Z$ ^ {7 t C0 q, e) e! B2 C5 n
.active_low = 0,+ X, @. \- r9 B9 T. i I
.gpio = DA850_USER_LED2,7 S$ v N X- `" s( L/ E3 W( c. O
.name = "user_led2"," i& [% }8 q: l
.default_trigger = "default-on",
4 D- y6 W% \7 u X5 P },; J. q& _0 X0 Z$ h
{
. b. C5 B, ]. o# M0 \$ `7 k) x .active_low = 0,
; _/ V/ L" h. P: v& d .gpio = DA850_USER_LED3,
4 X' B( S* r* s5 g .name = "user_led3",
" ?& {7 z. d1 Z$ q( w X9 D' F .default_trigger = "default-on",
5 f0 a4 [/ I% _# ^6 S },
/ I, C1 O; O5 X4 N6 u};
$ k: Z: O' d) y7 t- [8 |' s0 T8 s; C/ w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' J* P2 m" L& t# v% Q3 y .leds = da850_evm_tl_leds,
/ T/ d/ X5 } T; g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! Y+ n# C1 g8 I7 u% l};
3 r w9 U) g B7 P% ]8 w* U5 ^' f1 s. F, \
static void led_dev_release(struct device *dev)
9 ]" f9 o6 z Z. I4 k: Z{
# J D. P# E; i};& E7 s8 i$ u0 m7 V! N) V% E! C5 U
" K3 p+ ]. ~ ]- t
static struct platform_device da850_evm_tl_leds_device = {
9 c. G o7 \# y7 A! J# ]8 v! \" p .name = "leds-gpio",
1 v% K! V& U3 J! ?" R) |; S1 _ .id = 1,* h+ R" _7 {6 f6 F/ v
.dev = {! v' ~- V: @8 a7 O m+ g C" z8 @
.platform_data = &da850_evm_tl_leds_pdata,
# `' Q- U0 E3 J; d1 ?* t! ` .release = led_dev_release,
5 k) B# _' n+ V9 W5 e }
# W; Q5 S/ Z& S7 b" D0 ?7 ]! @( D# ^};. M5 W3 `% V& _/ R& g
7 [' T7 F3 ?) O& i4 J8 u' R0 b- Bstatic int __init led_platform_init(void)
0 S, E% _4 }2 s{" }# P$ v8 K: m5 z# |: c
int ret;8 B7 `* e# s' ?$ c9 Z/ g5 m
#if 0
6 y! K8 @ x( l( T ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 N! r5 Q: j% m9 |0 H7 [6 t4 M8 a6 Z
if (ret)6 m! {, C( K+ N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' H9 K" y9 f3 D# u3 d* L "%d\n", ret);8 Q2 g* N5 x4 d7 c6 K) T
#endif4 a, T* T! B' Y. _0 m4 d
ret = platform_device_register(&da850_evm_tl_leds_device);
" y# w+ ^2 ~0 q9 k if (ret)
4 s. s. f9 D+ C4 D# R9 `0 r pr_warning("Could not register som GPIO expander LEDS");
2 X( a3 C4 |1 U& h1 C- B0 j8 X else
% k: V" j3 C/ ~( h: x' B! S( a printk(KERN_INFO "LED register sucessful!\n");1 ~* @ O+ q7 x3 O# t
6 K o3 q+ o& z. ~! e7 j return ret; V+ [7 `: ^% r* l' C+ w9 {( _
}
% b4 S! N6 }, d/ b) b; ], p0 p# p: h* y& A6 l
static void __exit led_platform_exit(void)* [7 N. v! u, n' m
{! ]1 w) j1 V( s6 ]) T
platform_device_unregister(&da850_evm_tl_leds_device);. v+ s1 G0 ~# V: d( G1 g/ [# b
/ Z0 i: X, a8 t% l3 H: }' s" |; ` printk(KERN_INFO "LED unregister!\n");
/ m+ L: X. _* T. \4 h2 ?}! R9 Y" c+ _+ H7 v" ?
2 a) g) y! J/ {0 p
module_init(led_platform_init);2 ^) L2 ~- q. K" m4 n5 F
module_exit(led_platform_exit);6 c# D' x( }; {% \! ~0 Q( r
+ U/ s1 ]( b+ Z2 F0 ^& Y% oMODULE_DESCRIPTION("Led platform driver");
0 R2 I4 O/ }6 z3 UMODULE_AUTHOR("Tronlong");
, c. q1 Z) [1 g! @) `MODULE_LICENSE("GPL");4 u3 y" m& l m# D% Y
% x' h3 D9 i! o$ _9 C$ `! A |
|