|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. A+ i! \0 g% j+ t
#include <linux/init.h>$ @9 v/ J) X; X- l
#include <linux/module.h>' _ ?0 J0 q4 s: o! X
#include <linux/kernel.h>
/ d$ P& z6 A# o) X: L6 C+ p#include <linux/types.h>
7 H+ J( }1 _0 u" g" f. A+ H" k& O#include <linux/gpio.h>
A& o" ^# ?% y i. @; D#include <linux/leds.h>, |. ~, g/ Z2 N' B" {) d
#include <linux/platform_device.h>" N, P; ~, i! D' s4 h
" ?4 ~" b8 t9 u/ h* Y) V$ s2 H" Y
#include <asm/mach-types.h>
; M# m' Q1 o* S. G3 E#include <asm/mach/arch.h>! I. g, y6 Y0 J6 f6 P$ @
#include <mach/da8xx.h>
( ~2 l9 I2 O, @% v6 o( K R#include <mach/mux.h>
+ k2 }9 I, Z& k& l3 {
- K: w$ o2 o+ o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ ~2 L; g1 Z, l" q7 D0 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 f; W$ l1 A8 L0 E$ P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): @, z9 b" w& r9 b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- X/ I3 I1 f4 \ a! v5 j Y
6 n- v5 c9 ` Z9 b( o2 ?( Z2 C
/* assign the tl som board LED-GPIOs*/
) |- x# c. D7 \' [static const short da850_evm_tl_user_led_pins[] = {
9 _8 I3 k) E5 e4 Q4 J /* These pins are definition at <mach/mux.h> file */! b+ _- Q3 T! Y, y9 |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 b2 w7 ]) p: I
-1
) }% H( U9 Y+ ]* C4 }};; x' P% k( S* V
+ Q8 q8 _- ~5 ?! F$ p m/ Y, ostatic struct gpio_led da850_evm_tl_leds[] = {# w6 B. |8 M' \& d
{
h7 }$ B# U Q% X9 T .active_low = 0,
: F) U2 K- R! I# b# j! j .gpio = DA850_USER_LED0,
; ?$ K) o! o# h& d .name = "user_led0",4 J7 F+ q6 l* L8 @8 C: a
.default_trigger = "default-on",0 S: g/ T2 `3 U. v& X
},
% B L# s$ f6 _5 X; W {
; p/ n; ~; F, s4 j, X6 J .active_low = 0,
, Q+ i `; S$ L .gpio = DA850_USER_LED1,
9 [' y. ^4 ?0 I2 d7 h6 G! j .name = "user_led1",9 f- J0 h$ a* N8 x
.default_trigger = "default-on",! R# n. j$ L5 S4 I5 s
},; t7 m7 l; G8 d+ F% h
{
[% w4 @, w% U/ g4 W2 A0 U .active_low = 0,! q6 i) k% Z8 E3 k- T* R8 ^
.gpio = DA850_USER_LED2,
1 P0 X; j2 e' j6 z+ x; O: b .name = "user_led2",
9 z$ y' ?$ v0 k! A, d .default_trigger = "default-on"," V% t( J3 O% x# r3 \! \8 n
},8 b4 W7 D* V2 U7 W& F. f* S! k7 p
{
1 p/ n& E& n1 @/ T .active_low = 0,, }+ m9 C# r: d
.gpio = DA850_USER_LED3,2 v. O! b7 I6 v$ A! l: \3 Y* p
.name = "user_led3",. L7 @5 C4 H8 G$ X' {! j; I
.default_trigger = "default-on",' ~& T" R' D: O" N" ]
},
% x- G) n! e: R}; g3 t- @; i/ b! p4 [6 ]# |8 n
$ i: c' T: E: q+ P- L% vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: ~3 h* p1 n4 d' L/ H% Q. n .leds = da850_evm_tl_leds,
2 ~$ A q! ^$ [$ t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 K; d9 _& d3 e5 s6 v* n1 K2 ?; g6 g
};* g+ w( D+ |# B4 d
' X. q) q+ m4 }# s& V
static void led_dev_release(struct device *dev)# o5 F* s$ o3 k! Z" ~. u6 \
{
+ i( V4 g/ a2 k* s7 ^6 g2 c+ m};3 L o6 c4 T/ m4 g6 [9 Q! P0 w
. V# q2 I/ E$ |; b/ \9 gstatic struct platform_device da850_evm_tl_leds_device = {
4 P* s9 g9 I3 K7 j2 w .name = "leds-gpio",
. \- V% _5 M( r$ g .id = 1,
3 D, N2 W0 {6 E .dev = {
+ v+ @7 O, y { .platform_data = &da850_evm_tl_leds_pdata,
1 m4 @) _* d$ n7 e .release = led_dev_release,
% \5 M4 O. H* W6 k4 t9 V }1 g" I# a6 _ {6 e9 w7 Q0 [, r6 |0 b
};7 w+ \- K. o) u T5 L$ J h
& \- X6 q1 U8 R2 I% `) bstatic int __init led_platform_init(void)4 i2 a2 V' |+ |) E+ A, F* ^" V
{
, @2 f9 a- ~: L/ F y int ret;
6 u+ p# Y+ L0 L+ ~& o#if 0
. m z0 S; x; b$ y" h/ a- }: U! J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! y" J9 {" l: v7 y if (ret)
( S7 _1 ~- R8 a* a2 L: S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 A+ j/ Q* ?6 V8 }1 U3 h* w- ?2 i "%d\n", ret);
" B3 V9 H6 T# A# M6 L( l#endif
- n5 M# z- h; d, }: ?* b+ b ret = platform_device_register(&da850_evm_tl_leds_device);# r) f( \# ]* b/ F& `
if (ret)) f* d3 ]: x/ v6 t4 ?
pr_warning("Could not register som GPIO expander LEDS");. a9 j7 s% E* J' Y- T
else( x5 @% \. S) e8 r% w. u
printk(KERN_INFO "LED register sucessful!\n");9 Y" ^9 ?4 V! Z* X: h3 X
# O8 u3 x) t4 K2 a9 ~
return ret;
1 h' @" R' q+ D$ f4 i}' K0 @/ O" z5 m* m
# m% D4 p o- z: f% F o6 @static void __exit led_platform_exit(void)3 E$ D1 @5 r d1 ?0 ? ~
{
5 U6 E; n+ G; A$ F# O9 `" Q9 B platform_device_unregister(&da850_evm_tl_leds_device);
' l0 V% i0 _ }9 ?) r; C: K9 b3 i2 R; N- E
printk(KERN_INFO "LED unregister!\n");
. c# _! j7 w4 p# q) a8 Z}1 T. L- {" l m1 ]% a; i; w# r
# R, K! p) g! S; x) u: @ b$ @$ P
module_init(led_platform_init);( y: j/ g0 M4 o
module_exit(led_platform_exit);2 N. J- i9 T; ]
. B9 s. ~; p9 r- N" G- d) W0 jMODULE_DESCRIPTION("Led platform driver");
7 I% d- \3 I: w# d9 a. TMODULE_AUTHOR("Tronlong");# @1 g$ S% c* A7 y+ N* o s" F
MODULE_LICENSE("GPL");0 `6 f, P9 i2 w7 ^+ T6 _
9 _4 g l% R, D$ I
|
|