|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! V. E n3 e6 X b) l6 j
#include <linux/init.h>/ t- x/ q: B1 f
#include <linux/module.h>8 v% L/ ^' w) C* ?- H
#include <linux/kernel.h># O7 a. P0 |1 e9 Z) s5 N
#include <linux/types.h>6 P8 F7 r/ Z& O) x# @( F
#include <linux/gpio.h>
% A- ^8 b9 O+ A1 q8 k#include <linux/leds.h>: b5 r3 B, V% v: t& ~3 B6 U5 g2 ?5 N
#include <linux/platform_device.h>
/ F& ~7 t4 |/ h% o8 Y
( F. O9 z8 Q' J# d5 G#include <asm/mach-types.h>
4 d, H! s9 l/ ~5 B& X#include <asm/mach/arch.h>8 b3 c& F# F) B/ C p2 P
#include <mach/da8xx.h>+ v, M, I4 K$ p( ?2 Y
#include <mach/mux.h>0 J- m* e- g, N$ S' h
8 _4 b* v5 H6 f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' r9 ?& F+ F% ` r, p) b6 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): I, w! i4 s, E5 k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ B0 K9 ^$ j8 G" ~8 a) f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ x _$ I* A# L+ i0 `7 I
0 V9 O1 ]% B6 Q2 Z
/* assign the tl som board LED-GPIOs*/5 I/ P& y1 U0 M
static const short da850_evm_tl_user_led_pins[] = {# o3 x) r: o( D' n4 ~
/* These pins are definition at <mach/mux.h> file */7 d, Y/ ^4 A; C) p I" g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& ?8 Q. U) v5 q' P0 l -10 H% }' {3 C9 \7 z3 F& Z
};
# h4 V* ?3 R9 r4 `0 H$ {
* c a3 s" D# E9 F( q6 L! sstatic struct gpio_led da850_evm_tl_leds[] = {
$ M) N5 N, o0 ~ {5 U5 v2 k' o1 D% w$ u1 @7 E; `* e
.active_low = 0,
) S& V0 x" D6 w% Y$ R0 t3 V0 n .gpio = DA850_USER_LED0,
. B4 k z( p# t# d- t .name = "user_led0",
0 P7 I3 H! c7 W2 Z) H9 p' |3 Y .default_trigger = "default-on",, D$ o# ] ]1 C. X
},
& K$ ?1 s) N$ l) J0 x! Z {
' ~0 c3 M8 A7 b9 B# F p .active_low = 0,
- p- s2 t% T. S .gpio = DA850_USER_LED1,$ |/ x' W& i4 A( T9 b
.name = "user_led1",
! h' p$ c. i+ A. V/ h3 v) g .default_trigger = "default-on",+ g; T4 p, \2 ~: ]" }
},
: r5 G" }" V. F+ g) L' ? {
7 O+ E, Z2 e5 q) e: D4 Z! M/ a .active_low = 0," k u" e3 W4 \& s1 f1 J1 E6 S+ m
.gpio = DA850_USER_LED2,) i7 M/ U& ]( M( u- K& {
.name = "user_led2",
- M) J. P9 ~( L- }6 k8 o+ g .default_trigger = "default-on",( O0 z% v2 f$ X- i: S
},! R6 H- i) ~ E3 v4 A/ o$ n) ]
{
' z9 b+ q* {: T- }' p .active_low = 0,
, o, O4 g9 u. }# k: s8 ?$ j8 F _: g .gpio = DA850_USER_LED3,
; L! t @8 M# X' t* t. B .name = "user_led3", b g T! y- n5 h4 {! e
.default_trigger = "default-on",
. j% r' | ? T/ M },
* g" R( |& A4 w};
/ y# n& P3 b, [, j7 R' Y1 [
9 }' u5 S$ L; c. `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! K5 A. p) g6 l, A' Q/ a$ c! g .leds = da850_evm_tl_leds,
7 P; `, Z j% J" h) y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ E) J$ a2 K) G, ~2 c
};' n; X8 ]; N7 w V
- h3 f5 j$ I' n+ }- ^4 I& r3 `static void led_dev_release(struct device *dev)
4 c; c) m( j: [0 |) L{1 h. t3 s s d8 m# v7 o
};
. C/ `. l! {% n- v" T
6 q* M* p/ U7 \static struct platform_device da850_evm_tl_leds_device = {
: o3 |* x% B/ ] ? z) u .name = "leds-gpio",
?- \7 ~5 ~ Q/ J& ?( S: l0 m .id = 1,1 M, s" Y# K, N
.dev = {5 K- S' _1 G7 z$ a
.platform_data = &da850_evm_tl_leds_pdata,1 }+ o c R7 d
.release = led_dev_release,
6 g& q0 O( ~. L3 F8 b( e5 `) U% p }( {* p" d+ V2 n" b8 D6 `, ~
};
9 d# ^) ]1 A! k# ~( m
# ]9 s7 w" ^: U- ]static int __init led_platform_init(void)6 S' ?, p) Q, k) E, f7 @
{) ~# j3 P2 z1 b: ]4 A, F$ Y; [: T) T
int ret;0 N8 E) s j+ x& c+ O( q2 p, Z6 x
#if 0& z* f6 L2 F0 ]; t( }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& Y# v J( j# Q) Z
if (ret)$ k1 m6 D% [, j3 N% [) R9 M* \' V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". w5 C6 {% t6 j" K* g9 H* Z
"%d\n", ret);
% F1 i& d& ]* R3 Q4 Y- {6 ]' R#endif0 p9 O# |9 N O% o( [7 k# F1 V
ret = platform_device_register(&da850_evm_tl_leds_device);
. v4 L5 u9 {* j" x: W [0 P if (ret). Q i3 n9 W: ^
pr_warning("Could not register som GPIO expander LEDS");
$ r6 n" f% R% C else9 q& p( F3 {4 s% z+ N
printk(KERN_INFO "LED register sucessful!\n");( ?! a5 i9 ]% O' {. b0 T, C0 v, X
3 I; J: ?9 h J( K5 } return ret;5 a' d, M9 d: S% P
}
. T# ?5 q- }- t) Y* q3 X% b1 V B* L' S( V$ ^' q: b8 V6 g6 l! z
static void __exit led_platform_exit(void)
n6 [8 L/ e" ]: c* c# J3 K{1 l1 j/ O$ s- s+ L- z4 l
platform_device_unregister(&da850_evm_tl_leds_device);
0 a8 x. U% p0 M) ]" N. v
0 A( v! K3 W& s1 H printk(KERN_INFO "LED unregister!\n");& b- v" g& _- b' T
}
* w' D' w2 s& z1 J. W3 ^: K/ m# y/ \2 O8 h$ K9 }2 Z% H7 M+ `% c# _
module_init(led_platform_init); ]. Y6 t% R, r I8 k" S4 R
module_exit(led_platform_exit);
* d4 V& X `! Z" \) x) Y D9 ~0 V1 U" ^6 D# h* F8 q
MODULE_DESCRIPTION("Led platform driver");" z5 h+ j- k* O0 ]
MODULE_AUTHOR("Tronlong");
6 L" i* f* ^2 H+ F fMODULE_LICENSE("GPL");
$ O Q3 ~" {+ B. M6 Z: o; C/ [# O- H( u% J0 e3 `& u/ R
|
|