|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 M3 @/ c( d) U. P
#include <linux/init.h>
/ ^& i& j* K/ d9 {4 M5 O9 j* J e#include <linux/module.h>
6 Q& o7 R4 T, [1 i#include <linux/kernel.h>9 l' r, Q" j! Z2 t
#include <linux/types.h>0 {0 g+ G6 ~0 y# N7 S, H
#include <linux/gpio.h>/ `9 B0 ?. f7 X! ?
#include <linux/leds.h>& r k M% ~* n% i! z$ s4 ?* W/ n$ \
#include <linux/platform_device.h>6 n* y2 F& V. e h) I3 F
) x* U; q2 K5 ^7 {' H$ {) i
#include <asm/mach-types.h># b4 D9 p# z5 ?# q! J5 I, f! L
#include <asm/mach/arch.h>
/ B( W9 V6 F" ^2 z7 V% Q' G9 p#include <mach/da8xx.h>1 b3 f1 Q* V; F+ E4 V E1 F4 G
#include <mach/mux.h>+ B4 ]+ B/ K8 y& P0 K! h& [2 j/ I' B1 ~
* s1 n9 D y6 n% Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 J3 S; \: D8 K/ ]4 U$ [" f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 `8 @( d' h' d) w6 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 T- b9 \: D3 H3 Y4 K1 J" z) C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# c! P- p1 l+ {7 F) m% W1 Y7 _
& E3 ? C& ~' ^. ?/* assign the tl som board LED-GPIOs*/' t. o5 T, S4 P n0 R, K% c
static const short da850_evm_tl_user_led_pins[] = {
* {2 Y" J5 O* P+ W7 D1 y# R /* These pins are definition at <mach/mux.h> file */
: m! `, d- S6 T: Y% D3 ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 R0 U g7 o: A9 ~% [
-15 m+ ~) Y9 @; U; C' d; O
};
7 ^, t9 M0 S5 W! T' U D3 X% C2 a# w+ ~* `* r) \
static struct gpio_led da850_evm_tl_leds[] = {7 s: j/ u: f% D( V' ], o7 F
{
1 q: @( O" ^4 A2 g2 t* z .active_low = 0,
9 T, i& p2 i# k$ q& M5 Z" @ .gpio = DA850_USER_LED0,7 d! E4 T. |& N$ i
.name = "user_led0",
3 D5 u( [; X) r2 ?& `! `% } P' W+ a .default_trigger = "default-on",
4 c* r: e" k1 q# d5 u* { },8 D; B3 a! S3 K$ p) @3 h/ ?
{
1 b: e) F) U6 F- \8 P# ]% j4 ^. E9 H .active_low = 0,# [- O0 P) G2 A1 K% l
.gpio = DA850_USER_LED1,
w. H# V% _' ]* i( n* f; w0 M .name = "user_led1",
. h1 ]( z5 ?& _: ] .default_trigger = "default-on",
; X6 f, r* u5 w7 n },8 T1 f/ g+ c0 _0 \" h, L
{# ], p; Q# x# j0 q
.active_low = 0,
5 a6 `; }1 M; V1 O .gpio = DA850_USER_LED2,5 c1 k; `* E- w/ [/ N$ p& O
.name = "user_led2",
- T- g4 d& x1 O0 X" ^* [ .default_trigger = "default-on",
4 x0 s6 k+ B; n- N },
3 k& k2 c0 B- w5 f { D# z4 G( Q/ q0 r0 ~
.active_low = 0,% v. H; z1 L W
.gpio = DA850_USER_LED3,# a$ c! X% f$ |* [7 H) U' g
.name = "user_led3",
/ J$ d+ q9 H! q0 }2 w .default_trigger = "default-on",
/ ^+ ?/ a! k# v! x9 G9 k },. U/ e J, q0 N }, E
};. a2 [4 ~# Z- U9 X; _2 Y9 _3 h+ j' o
' B U+ P, k) `. s4 G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 Y1 r3 h o. Z9 p7 @+ h0 z .leds = da850_evm_tl_leds,
* [/ p, A7 b! d" T# ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; h; {# s7 b4 ^6 \};
, O6 a2 T2 i% [- C0 o' y
& i" i/ w) t% p0 ^7 Vstatic void led_dev_release(struct device *dev): `4 M2 l) M, J$ k
{1 g* z6 h, {! x3 A
};
m! L5 \# P" A8 ?6 ^) }. I/ E$ Q2 J7 C, F5 J# f
static struct platform_device da850_evm_tl_leds_device = {+ J- b. P% J6 ~3 s# v/ I# r
.name = "leds-gpio",6 p, U5 C7 M$ s9 w' c! r
.id = 1,
* O0 Y1 L) g0 B. j .dev = {
0 b2 S% l0 W) W .platform_data = &da850_evm_tl_leds_pdata,* I" m3 h p! [- E
.release = led_dev_release,0 s# h2 x! o3 T1 k" M- y
}5 P2 P' }' B j
};
1 H/ i+ d4 @5 F' p) L
5 N O, E7 |9 b/ ]8 xstatic int __init led_platform_init(void)
5 w4 w: H% O+ h* M- G{
" t6 w& t$ v0 D5 e' N* o int ret;
9 X5 v% B2 t% W5 O& ^" Y, @#if 0
8 ?* x5 P$ [6 R% O3 s; w; `: k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 N- `4 t4 x& A: I if (ret)* ]- {9 R2 F. O. g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" d- g Q6 T$ I" w+ I1 U "%d\n", ret);$ t* `; a/ A' H+ X `
#endif
( i6 `0 l" a" g6 }+ i) A ret = platform_device_register(&da850_evm_tl_leds_device);; n$ E2 D6 V. ~
if (ret)/ x& {0 F4 b0 h* P& f
pr_warning("Could not register som GPIO expander LEDS");1 r) z k; e* U, a" e: l) `/ y
else
0 F- Q r% p. n7 S( U: q printk(KERN_INFO "LED register sucessful!\n");
/ |9 ^8 ~/ D6 G- R# O8 E% P8 w* x" }& i4 _
return ret;$ F6 c1 M* X. K
}0 U" i$ P$ d8 H+ \1 c& ?5 p
, K8 N2 d7 d) Fstatic void __exit led_platform_exit(void)( _1 L8 {) ^' u9 N: ] v
{
+ n* |4 k- d! w9 {2 R% T platform_device_unregister(&da850_evm_tl_leds_device);
$ X5 l, P1 I: L- R' W) M
* R1 \' r4 ~: Y* ^# Z( f printk(KERN_INFO "LED unregister!\n");
7 F" b! w" N- P) v( K* f$ s}; W( s, P( g4 ]. e" F- ^' Q _
2 S; s! |5 c2 A- d
module_init(led_platform_init);
9 @, M0 A5 r# t4 v" o% V. P( qmodule_exit(led_platform_exit);
' Y6 `- U- N4 i* @3 X$ a! `! @+ p1 S
MODULE_DESCRIPTION("Led platform driver");7 C& n" D$ M, r# J9 |
MODULE_AUTHOR("Tronlong");
* K L( t( {2 m1 c9 a/ y4 P+ jMODULE_LICENSE("GPL");; B# a7 A4 z# b+ u7 a3 h& z" b
( o+ ]* l; a+ m1 k; z$ z7 b2 h |
|