|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" S5 A3 c# \# O; {. _4 I q0 }! g4 m
#include <linux/init.h>
, K6 ]( b+ l _) J#include <linux/module.h>
; O5 q5 k* \4 B) k8 L0 @) o7 w9 a#include <linux/kernel.h>: s2 m; b C7 z* o. G! H( A
#include <linux/types.h>' k7 S8 u: N# v, J8 e5 M' U: J: A
#include <linux/gpio.h>1 q0 y4 [; O; m9 u9 ?
#include <linux/leds.h>
7 a9 e# k, ^5 o4 V X7 J* v1 x, A#include <linux/platform_device.h>' [1 W1 r4 X- e; j' Y: R/ o% S6 F
3 y" g- C0 ]/ V#include <asm/mach-types.h>8 q4 N( O( `) j3 o9 U1 g( R
#include <asm/mach/arch.h>
1 c+ r f2 ]: W. k- R2 S#include <mach/da8xx.h>
. u7 h0 L3 X3 L3 n+ e#include <mach/mux.h>
1 P9 ]9 ?6 q1 \( j2 R4 v
. v+ y- |. T9 W* \' ~3 z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 ^3 {( T1 H7 k! {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). H! h$ E( j4 a/ D8 k6 _/ H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 K1 |! ^% G" k0 D" y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 w# ~% F, ^- N
$ N% S( i9 s& s& ^5 g( w/* assign the tl som board LED-GPIOs*/
# v$ e: x- U1 z4 o' Ustatic const short da850_evm_tl_user_led_pins[] = {* a4 c" A& ?3 E' N& S$ b. h
/* These pins are definition at <mach/mux.h> file */
$ G% Z q7 P7 U3 h5 ^1 s5 j& @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 @# L" b) J, _6 D! c% u
-1
0 S* n$ p$ g S6 w};2 |$ B( m# S5 ?% f2 O* T& l5 T
( K8 u3 K' R8 p. Hstatic struct gpio_led da850_evm_tl_leds[] = {
( {! y5 N& P G {
: l: S" `0 t+ |* S$ O* h .active_low = 0,& R1 A# M0 ~9 C* {- g% d) C
.gpio = DA850_USER_LED0,3 M5 x* L2 `8 y4 d
.name = "user_led0",
5 T6 M7 N( ~7 R .default_trigger = "default-on",# V8 i( N- e7 m/ D
},( W" ?. o4 B7 a$ D9 y
{
F3 S, s* o! i1 \7 h; Q. M .active_low = 0,- q& {4 B( u) X4 R1 Z
.gpio = DA850_USER_LED1,* h& c" h, a, |
.name = "user_led1",
( [/ F+ K x& n, W" j .default_trigger = "default-on",& G% Z M J5 b8 D; ~0 J
},
+ y0 R# I0 C$ O5 f3 K { R2 y! f: h l
.active_low = 0,
5 A$ z+ H7 S4 K* N: H .gpio = DA850_USER_LED2,8 J# }* p$ l* d6 n4 ]
.name = "user_led2",6 m- b; |" V. d
.default_trigger = "default-on",# V! D0 F; [' p0 s* @
},
7 n& y3 _ }, B {; t% q5 G# \. z
.active_low = 0,
$ K" \$ k6 `; J .gpio = DA850_USER_LED3,
4 Q9 S# K0 g: ^$ W .name = "user_led3",
- b3 b- `( ^( m$ t5 j( i' _5 _ .default_trigger = "default-on",0 V0 k# w6 S8 L% U4 T2 P0 K
},
% J) M# u5 L' v- _8 |) Z};+ }' F8 R1 h; N3 F' |: B! [" o# s
4 i8 p0 o4 f! I5 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: L4 Q, q: B: r% {" t
.leds = da850_evm_tl_leds,; u4 v2 j0 L) X4 Y p. A- h! W0 j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: z9 T- D3 b ^3 b- w9 z};# u: T1 v4 o, {" k, H
& I; l9 o2 f( f- j9 Estatic void led_dev_release(struct device *dev), c; q! L ?+ A+ z" H
{
* {. j+ Q) \7 Z6 _};
m& s1 E' [- C+ Y: o1 d- A( y# s( n. _
static struct platform_device da850_evm_tl_leds_device = {. g, j8 x6 L, Y
.name = "leds-gpio",
1 D6 x; q) _1 b2 j3 M5 p d* l .id = 1,
4 t! t# b1 |# v .dev = {
8 e! F+ ]( k1 ? .platform_data = &da850_evm_tl_leds_pdata,
* o* r: E' C$ p6 m i+ n! p .release = led_dev_release, ~7 s: S: X+ u3 c: ~+ o
}2 x' z& k! Y P5 W y- z: r" L
};
& ~ p) J2 t& G% q3 }* Q
% L& o$ D( o* E5 ^# \9 ~static int __init led_platform_init(void)
; e! s b8 ]. q$ p% d; ]) _# U{
( V! U) O+ |5 s9 k7 i8 D int ret;
% |' s8 X5 X, _#if 0
5 P O2 O. _8 P+ h# i6 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& v) W+ k% P q. B# w0 p9 R3 [
if (ret)
! ^) ?! A) D0 n; l) } pr_warning("da850_evm_tl_leds_init : User LED mux failed :") r# r0 a) A; `9 i: B/ ?. u
"%d\n", ret);
* Z& @- v' f' r! A7 m, b#endif" a* e2 t! B1 a; F6 C
ret = platform_device_register(&da850_evm_tl_leds_device);
' N( x( P4 M$ Q+ E! M& W# p if (ret)0 l" b% b5 _+ J9 n) R: T
pr_warning("Could not register som GPIO expander LEDS");$ U: P; }! |# p/ Q" Z$ R: ]
else. w* R0 d1 P" ]( d" A
printk(KERN_INFO "LED register sucessful!\n");8 u" c3 j: J3 w) c5 q, M
7 C6 O6 m1 ~9 r( H- K4 \5 P F7 @2 K: B
return ret;
) S( ]5 J( _6 w t5 z! e! ?, Y}! X3 E1 ?, Z! [! a7 U
# U% S3 W: j' p2 h lstatic void __exit led_platform_exit(void), Z, ?0 T8 ?9 B; X
{
! b6 ?2 l. V+ s) \1 q) a5 R platform_device_unregister(&da850_evm_tl_leds_device);* I* q: T( I* c# w$ u
" g# N8 N0 v5 F3 M% V3 N printk(KERN_INFO "LED unregister!\n");
7 Q( o k# x/ M# `}
0 q1 o$ F9 U* f: E7 ?
% j1 t1 C$ f9 I) Gmodule_init(led_platform_init);
$ j3 h2 f. u* m- `1 ^module_exit(led_platform_exit);, ~1 O& X+ K' ?0 Q' u
- v. ?1 _/ `$ }MODULE_DESCRIPTION("Led platform driver");5 D6 Z u v% G9 r0 u2 c
MODULE_AUTHOR("Tronlong");: ]0 L3 w1 y/ N
MODULE_LICENSE("GPL");8 Z6 ^# ^; z. q, x q5 |
4 S! r0 O- a: D1 Y0 o) d. J# B |
|