|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 J& F" t! B; g
#include <linux/init.h>
7 q: e0 c2 m: b1 _: _& s* P#include <linux/module.h>9 ]7 G q$ ~8 t8 l# R( B2 h
#include <linux/kernel.h>
1 D1 r0 I+ L' e#include <linux/types.h>
# n4 U0 @! m1 `2 |2 i* `#include <linux/gpio.h>
7 b! l% K# [6 {/ L6 |. P* E#include <linux/leds.h>0 z4 A$ ^; v- m" ]" I; \
#include <linux/platform_device.h>
1 D8 S/ m0 z# b3 I p1 ?) m h4 a, u
+ X1 R7 X6 h% m! a5 b% n2 [3 H#include <asm/mach-types.h>3 h% y' e! W* m( r: v2 f
#include <asm/mach/arch.h>- z, R7 ~4 Z0 S! n
#include <mach/da8xx.h>
3 e1 B' ]+ n& V$ R' U( z#include <mach/mux.h>
3 B0 G, M7 C1 g+ M+ }( H0 G& C. j1 [0 j2 ]' n( J! q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ L3 Z" \+ r2 u+ N6 Z0 f8 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# l4 ~. P8 E% {0 H, S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 |0 d3 O' z0 y8 l4 k8 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 E" K6 u* F/ J7 L5 i) z
' ? z! X$ t5 i, J: V! s# r/* assign the tl som board LED-GPIOs*/- a0 V0 y" d+ P. `2 l7 V" N
static const short da850_evm_tl_user_led_pins[] = {5 Y- p+ f4 a4 o: g
/* These pins are definition at <mach/mux.h> file */) X* N+ K. W! {9 S" a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ h4 k" [0 x! [
-1
1 F! Z, `' S, P8 ]* i8 O& `};
1 f. A, [& d+ u. X- v: @/ O* V! D9 d- V7 O
static struct gpio_led da850_evm_tl_leds[] = {
- K( a8 v0 m* j% k/ ]% ~ {
+ j7 W9 d9 h) ^4 \& p1 u& [! _6 r .active_low = 0,9 \5 Y2 @% [9 Q4 g" v5 V8 a, o# h
.gpio = DA850_USER_LED0,
9 P9 L, t1 [- D .name = "user_led0",' i; n2 i/ @7 {( z6 D3 c
.default_trigger = "default-on",
1 E8 R1 I: o, w. T) p! F },1 i5 P. L. Y2 I [ m5 o# K
{
7 w) U* [% {5 r9 I; |0 x% t .active_low = 0,
) b1 V& c8 |4 ~; K .gpio = DA850_USER_LED1,, J1 ~. {$ J$ b6 V
.name = "user_led1",3 M8 o* C# r$ K# N
.default_trigger = "default-on",$ z/ c, y% ]! h2 @ O$ u y
},
8 T* N+ g$ F( e4 f {
4 a6 w$ F; g& R .active_low = 0,; T8 |( k7 N5 t' i6 z
.gpio = DA850_USER_LED2,) H/ v( z* E( W/ I; ^- v
.name = "user_led2",! H* c/ I8 d; x' S
.default_trigger = "default-on",
2 a8 b$ }" u# h( a( o& H; ^ },5 j1 M* H3 v0 F8 c+ @0 b& Y
{% ~( X) P2 {8 L, k3 V& x
.active_low = 0,$ L& B, ~: Y) l/ x) D: @* i
.gpio = DA850_USER_LED3,
& B& o0 Z" j/ _" q/ C4 ~+ `4 b .name = "user_led3",
g2 a0 H7 C. N& s* d .default_trigger = "default-on",
p% o3 M: D3 I },
% F. [% T) N! v1 L0 [9 a};
/ H, u' z1 A: Y0 K8 t# s
7 R3 F; ~4 a! Z8 c- t- f* |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 E, s! l R- ~. Z .leds = da850_evm_tl_leds,; r* G/ D& H" W6 `7 T5 T7 ^6 ~ p) m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, V+ O4 p- j6 N+ R};! @/ a+ U2 I9 f# M" W, ]& H/ Y! U
- J7 [, A# k" g; H8 R0 z$ a9 lstatic void led_dev_release(struct device *dev)
# { I+ ~; h: u- q* z8 Z+ S0 x{" j$ E, U+ k$ k+ d' V5 S9 q
}; j8 p7 }2 N, j% I( T7 [
6 H7 A& T5 c- c/ T" @* U
static struct platform_device da850_evm_tl_leds_device = {
) U* S4 C; z9 | N, K .name = "leds-gpio",2 U& X0 z# U* G! N; W
.id = 1,
: [4 W7 W5 N' _3 Y .dev = {
/ [" A) W# B* t3 ]/ j5 S .platform_data = &da850_evm_tl_leds_pdata,8 E. A- B% ^6 f6 W6 F; \( x" @
.release = led_dev_release,
/ |% ^/ c, t" |/ N/ u& Y0 Y }0 l) d! _9 R; ^+ o+ _4 J5 g
};
) _8 H1 ^2 W7 k
* X% z+ T$ ~; r. Y5 O; q& \2 C" Fstatic int __init led_platform_init(void)) k# E0 {2 b9 f1 L1 d) x; S
{
4 [( a( M0 i' v, L' Z+ _; Q' c int ret;
1 z% M0 y9 f2 `" Q' l% R! x#if 0# F5 Y( U+ k6 c2 i/ |6 I4 V, L; j0 Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) y+ D8 C5 a0 Q+ S0 G9 t
if (ret)
0 p2 G3 K# T, O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 D( }% U0 c% x
"%d\n", ret);5 _' w( K& g) }: Z" k
#endif
0 v# I; A3 {7 s1 {4 a5 Y; t- n5 s ret = platform_device_register(&da850_evm_tl_leds_device);% \6 G( S' p& `5 ?
if (ret)
6 o0 P7 X0 b! Y, X! p5 a pr_warning("Could not register som GPIO expander LEDS");
f0 w0 j1 R" b) ~, c" Y, n' I0 p else
/ e! H& h3 g; m0 Y4 J, V+ {+ N printk(KERN_INFO "LED register sucessful!\n");6 \! ~, [% g' z$ z, g( A/ M
9 Q6 j9 J0 ?6 M9 q. i. o/ W
return ret;8 F! u0 Z9 S1 e
}
* @9 i {* I! J! Y6 `: S' i! X3 I
static void __exit led_platform_exit(void)- r4 J8 f, p% n
{1 K* [6 W7 Z8 b; W( i3 }7 n9 e& |
platform_device_unregister(&da850_evm_tl_leds_device);
1 \ M' q3 N r6 e& H3 b# x/ }% p- _* f& v
printk(KERN_INFO "LED unregister!\n");+ t( a# Y1 E0 r! M
}; X5 [4 l- O) H% @/ q
: g" Z1 }" q9 i* a
module_init(led_platform_init);* S8 o: B! H; W6 M
module_exit(led_platform_exit);6 W" k, H: n$ ?3 c
: m; \ f+ ?- g }
MODULE_DESCRIPTION("Led platform driver");
5 V7 P9 v/ S6 g2 j2 j, y; L$ dMODULE_AUTHOR("Tronlong");
# d- l& p# N" Z0 m: ?# uMODULE_LICENSE("GPL");; F! a6 y4 a1 x/ _
e4 k8 e0 o6 H+ P |
|